Merge commit 'f6b6d6ac42c0ee427fcd3fae4c398b2103b491b8'

* commit 'f6b6d6ac42c0ee427fcd3fae4c398b2103b491b8':
  vf_frei0r: use the name 's' for the pointer to the private context
  vf_format: use the name 's' for the pointer to the private context
  vf_fieldorder: use the name 's' for the pointer to the private context
  vf_fieldorder: cosmetics, remove an extra linebreak

Conflicts:
	libavfilter/vf_frei0r.c

Merged-by: Michael Niedermayer <michaelni@gmx.at>
pull/18/head
Michael Niedermayer 12 years ago
commit e55092b12b
  1. 10
      libavfilter/vf_fieldorder.c
  2. 10
      libavfilter/vf_format.c
  3. 134
      libavfilter/vf_frei0r.c

@ -68,17 +68,15 @@ static int query_formats(AVFilterContext *ctx)
static int config_input(AVFilterLink *inlink) static int config_input(AVFilterLink *inlink)
{ {
AVFilterContext *ctx = inlink->dst; AVFilterContext *ctx = inlink->dst;
FieldOrderContext *fieldorder = ctx->priv; FieldOrderContext *s = ctx->priv;
int plane; int plane;
/** full an array with the number of bytes that the video /** full an array with the number of bytes that the video
* data occupies per line for each plane of the input video */ * data occupies per line for each plane of the input video */
for (plane = 0; plane < 4; plane++) { for (plane = 0; plane < 4; plane++) {
fieldorder->line_size[plane] = av_image_get_linesize( s->line_size[plane] = av_image_get_linesize(inlink->format, inlink->w,
inlink->format, plane);
inlink->w,
plane);
} }
return 0; return 0;

@ -50,14 +50,14 @@ typedef struct {
static av_cold int init(AVFilterContext *ctx) static av_cold int init(AVFilterContext *ctx)
{ {
FormatContext *format = ctx->priv; FormatContext *s = ctx->priv;
const char *cur, *sep; const char *cur, *sep;
char pix_fmt_name[AV_PIX_FMT_NAME_MAXSIZE]; char pix_fmt_name[AV_PIX_FMT_NAME_MAXSIZE];
int pix_fmt_name_len, ret; int pix_fmt_name_len, ret;
enum AVPixelFormat pix_fmt; enum AVPixelFormat pix_fmt;
/* parse the list of formats */ /* parse the list of formats */
for (cur = format->pix_fmts; cur; cur = sep ? sep + 1 : NULL) { for (cur = s->pix_fmts; cur; cur = sep ? sep + 1 : NULL) {
if (!(sep = strchr(cur, '|'))) if (!(sep = strchr(cur, '|')))
pix_fmt_name_len = strlen(cur); pix_fmt_name_len = strlen(cur);
else else
@ -73,13 +73,13 @@ static av_cold int init(AVFilterContext *ctx)
if ((ret = ff_parse_pixel_format(&pix_fmt, pix_fmt_name, ctx)) < 0) if ((ret = ff_parse_pixel_format(&pix_fmt, pix_fmt_name, ctx)) < 0)
return ret; return ret;
format->listed_pix_fmt_flags[pix_fmt] = 1; s->listed_pix_fmt_flags[pix_fmt] = 1;
} }
return 0; return 0;
} }
static AVFilterFormats *make_format_list(FormatContext *format, int flag) static AVFilterFormats *make_format_list(FormatContext *s, int flag)
{ {
AVFilterFormats *formats; AVFilterFormats *formats;
enum AVPixelFormat pix_fmt; enum AVPixelFormat pix_fmt;
@ -88,7 +88,7 @@ static AVFilterFormats *make_format_list(FormatContext *format, int flag)
formats->formats = av_malloc(sizeof(enum AVPixelFormat) * AV_PIX_FMT_NB); formats->formats = av_malloc(sizeof(enum AVPixelFormat) * AV_PIX_FMT_NB);
for (pix_fmt = 0; pix_fmt < AV_PIX_FMT_NB; pix_fmt++) for (pix_fmt = 0; pix_fmt < AV_PIX_FMT_NB; pix_fmt++)
if (format->listed_pix_fmt_flags[pix_fmt] == flag) if (s->listed_pix_fmt_flags[pix_fmt] == flag)
formats->formats[formats->format_count++] = pix_fmt; formats->formats[formats->format_count++] = pix_fmt;
return formats; return formats;

@ -78,8 +78,8 @@ typedef struct Frei0rContext {
static void *load_sym(AVFilterContext *ctx, const char *sym_name) static void *load_sym(AVFilterContext *ctx, const char *sym_name)
{ {
Frei0rContext *frei0r = ctx->priv; Frei0rContext *s = ctx->priv;
void *sym = dlsym(frei0r->dl_handle, sym_name); void *sym = dlsym(s->dl_handle, sym_name);
if (!sym) if (!sym)
av_log(ctx, AV_LOG_ERROR, "Could not find symbol '%s' in loaded module\n", sym_name); av_log(ctx, AV_LOG_ERROR, "Could not find symbol '%s' in loaded module\n", sym_name);
return sym; return sym;
@ -87,7 +87,7 @@ static void *load_sym(AVFilterContext *ctx, const char *sym_name)
static int set_param(AVFilterContext *ctx, f0r_param_info_t info, int index, char *param) static int set_param(AVFilterContext *ctx, f0r_param_info_t info, int index, char *param)
{ {
Frei0rContext *frei0r = ctx->priv; Frei0rContext *s = ctx->priv;
union { union {
double d; double d;
f0r_param_color_t col; f0r_param_color_t col;
@ -125,7 +125,7 @@ static int set_param(AVFilterContext *ctx, f0r_param_info_t info, int index, cha
break; break;
} }
frei0r->set_param_value(frei0r->instance, &val, index); s->set_param_value(s->instance, &val, index);
return 0; return 0;
fail: fail:
@ -136,18 +136,18 @@ fail:
static int set_params(AVFilterContext *ctx, const char *params) static int set_params(AVFilterContext *ctx, const char *params)
{ {
Frei0rContext *frei0r = ctx->priv; Frei0rContext *s = ctx->priv;
int i; int i;
if (!params) if (!params)
return 0; return 0;
for (i = 0; i < frei0r->plugin_info.num_params; i++) { for (i = 0; i < s->plugin_info.num_params; i++) {
f0r_param_info_t info; f0r_param_info_t info;
char *param; char *param;
int ret; int ret;
frei0r->get_param_info(&info, i); s->get_param_info(&info, i);
if (*params) { if (*params) {
if (!(param = av_get_token(&params, "|"))) if (!(param = av_get_token(&params, "|")))
@ -180,27 +180,27 @@ static int set_params(AVFilterContext *ctx, const char *params)
case F0R_PARAM_BOOL: case F0R_PARAM_BOOL:
v = &d; v = &d;
frei0r->get_param_value(frei0r->instance, v, i); s->get_param_value(s->instance, v, i);
av_log(ctx, AV_LOG_DEBUG, "%s", d >= 0.5 && d <= 1.0 ? "y" : "n"); av_log(ctx, AV_LOG_DEBUG, "%s", d >= 0.5 && d <= 1.0 ? "y" : "n");
break; break;
case F0R_PARAM_DOUBLE: case F0R_PARAM_DOUBLE:
v = &d; v = &d;
frei0r->get_param_value(frei0r->instance, v, i); s->get_param_value(s->instance, v, i);
av_log(ctx, AV_LOG_DEBUG, "%f", d); av_log(ctx, AV_LOG_DEBUG, "%f", d);
break; break;
case F0R_PARAM_COLOR: case F0R_PARAM_COLOR:
v = &col; v = &col;
frei0r->get_param_value(frei0r->instance, v, i); s->get_param_value(s->instance, v, i);
av_log(ctx, AV_LOG_DEBUG, "%f/%f/%f", col.r, col.g, col.b); av_log(ctx, AV_LOG_DEBUG, "%f/%f/%f", col.r, col.g, col.b);
break; break;
case F0R_PARAM_POSITION: case F0R_PARAM_POSITION:
v = &pos; v = &pos;
frei0r->get_param_value(frei0r->instance, v, i); s->get_param_value(s->instance, v, i);
av_log(ctx, AV_LOG_DEBUG, "%f/%f", pos.x, pos.y); av_log(ctx, AV_LOG_DEBUG, "%f/%f", pos.x, pos.y);
break; break;
default: /* F0R_PARAM_STRING */ default: /* F0R_PARAM_STRING */
v = s; v = s;
frei0r->get_param_value(frei0r->instance, v, i); s->get_param_value(s->instance, v, i);
av_log(ctx, AV_LOG_DEBUG, "'%s'\n", s); av_log(ctx, AV_LOG_DEBUG, "'%s'\n", s);
break; break;
} }
@ -225,7 +225,7 @@ static int load_path(AVFilterContext *ctx, void **handle_ptr, const char *prefix
static av_cold int frei0r_init(AVFilterContext *ctx, static av_cold int frei0r_init(AVFilterContext *ctx,
const char *dl_name, int type) const char *dl_name, int type)
{ {
Frei0rContext *frei0r = ctx->priv; Frei0rContext *s = ctx->priv;
f0r_init_f f0r_init; f0r_init_f f0r_init;
f0r_get_plugin_info_f f0r_get_plugin_info; f0r_get_plugin_info_f f0r_get_plugin_info;
f0r_plugin_info_t *pi; f0r_plugin_info_t *pi;
@ -252,11 +252,11 @@ static av_cold int frei0r_init(AVFilterContext *ctx,
ret = AVERROR(ENOMEM); ret = AVERROR(ENOMEM);
goto check_path_end; goto check_path_end;
} }
ret = load_path(ctx, &frei0r->dl_handle, p1, dl_name); ret = load_path(ctx, &s->dl_handle, p1, dl_name);
av_free(p1); av_free(p1);
if (ret < 0) if (ret < 0)
goto check_path_end; goto check_path_end;
if (frei0r->dl_handle) if (s->dl_handle)
break; break;
} }
@ -265,39 +265,39 @@ static av_cold int frei0r_init(AVFilterContext *ctx,
if (ret < 0) if (ret < 0)
return ret; return ret;
} }
if (!frei0r->dl_handle && (path = getenv("HOME"))) { if (!s->dl_handle && (path = getenv("HOME"))) {
char *prefix = av_asprintf("%s/.frei0r-1/lib/", path); char *prefix = av_asprintf("%s/.frei0r-1/lib/", path);
if (!prefix) if (!prefix)
return AVERROR(ENOMEM); return AVERROR(ENOMEM);
ret = load_path(ctx, &frei0r->dl_handle, prefix, dl_name); ret = load_path(ctx, &s->dl_handle, prefix, dl_name);
av_free(prefix); av_free(prefix);
if (ret < 0) if (ret < 0)
return ret; return ret;
} }
if (!frei0r->dl_handle) { if (!s->dl_handle) {
ret = load_path(ctx, &frei0r->dl_handle, "/usr/local/lib/frei0r-1/", dl_name); ret = load_path(ctx, &s->dl_handle, "/usr/local/lib/frei0r-1/", dl_name);
if (ret < 0) if (ret < 0)
return ret; return ret;
} }
if (!frei0r->dl_handle) { if (!s->dl_handle) {
ret = load_path(ctx, &frei0r->dl_handle, "/usr/lib/frei0r-1/", dl_name); ret = load_path(ctx, &s->dl_handle, "/usr/lib/frei0r-1/", dl_name);
if (ret < 0) if (ret < 0)
return ret; return ret;
} }
if (!frei0r->dl_handle) { if (!s->dl_handle) {
av_log(ctx, AV_LOG_ERROR, "Could not find module '%s'\n", dl_name); av_log(ctx, AV_LOG_ERROR, "Could not find module '%s'\n", dl_name);
return AVERROR(EINVAL); return AVERROR(EINVAL);
} }
if (!(f0r_init = load_sym(ctx, "f0r_init" )) || if (!(f0r_init = load_sym(ctx, "f0r_init" )) ||
!(f0r_get_plugin_info = load_sym(ctx, "f0r_get_plugin_info")) || !(f0r_get_plugin_info = load_sym(ctx, "f0r_get_plugin_info")) ||
!(frei0r->get_param_info = load_sym(ctx, "f0r_get_param_info" )) || !(s->get_param_info = load_sym(ctx, "f0r_get_param_info" )) ||
!(frei0r->get_param_value = load_sym(ctx, "f0r_get_param_value")) || !(s->get_param_value = load_sym(ctx, "f0r_get_param_value")) ||
!(frei0r->set_param_value = load_sym(ctx, "f0r_set_param_value")) || !(s->set_param_value = load_sym(ctx, "f0r_set_param_value")) ||
!(frei0r->update = load_sym(ctx, "f0r_update" )) || !(s->update = load_sym(ctx, "f0r_update" )) ||
!(frei0r->construct = load_sym(ctx, "f0r_construct" )) || !(s->construct = load_sym(ctx, "f0r_construct" )) ||
!(frei0r->destruct = load_sym(ctx, "f0r_destruct" )) || !(s->destruct = load_sym(ctx, "f0r_destruct" )) ||
!(frei0r->deinit = load_sym(ctx, "f0r_deinit" ))) !(s->deinit = load_sym(ctx, "f0r_deinit" )))
return AVERROR(EINVAL); return AVERROR(EINVAL);
if (f0r_init() < 0) { if (f0r_init() < 0) {
@ -305,8 +305,8 @@ static av_cold int frei0r_init(AVFilterContext *ctx,
return AVERROR(EINVAL); return AVERROR(EINVAL);
} }
f0r_get_plugin_info(&frei0r->plugin_info); f0r_get_plugin_info(&s->plugin_info);
pi = &frei0r->plugin_info; pi = &s->plugin_info;
if (pi->plugin_type != type) { if (pi->plugin_type != type) {
av_log(ctx, AV_LOG_ERROR, av_log(ctx, AV_LOG_ERROR,
"Invalid type '%s' for the plugin\n", "Invalid type '%s' for the plugin\n",
@ -331,44 +331,44 @@ static av_cold int frei0r_init(AVFilterContext *ctx,
static av_cold int filter_init(AVFilterContext *ctx) static av_cold int filter_init(AVFilterContext *ctx)
{ {
Frei0rContext *frei0r = ctx->priv; Frei0rContext *s = ctx->priv;
return frei0r_init(ctx, frei0r->dl_name, F0R_PLUGIN_TYPE_FILTER); return frei0r_init(ctx, s->dl_name, F0R_PLUGIN_TYPE_FILTER);
} }
static av_cold void uninit(AVFilterContext *ctx) static av_cold void uninit(AVFilterContext *ctx)
{ {
Frei0rContext *frei0r = ctx->priv; Frei0rContext *s = ctx->priv;
if (frei0r->destruct && frei0r->instance) if (s->destruct && s->instance)
frei0r->destruct(frei0r->instance); s->destruct(s->instance);
if (frei0r->deinit) if (s->deinit)
frei0r->deinit(); s->deinit();
if (frei0r->dl_handle) if (s->dl_handle)
dlclose(frei0r->dl_handle); dlclose(s->dl_handle);
} }
static int config_input_props(AVFilterLink *inlink) static int config_input_props(AVFilterLink *inlink)
{ {
AVFilterContext *ctx = inlink->dst; AVFilterContext *ctx = inlink->dst;
Frei0rContext *frei0r = ctx->priv; Frei0rContext *s = ctx->priv;
if (!(frei0r->instance = frei0r->construct(inlink->w, inlink->h))) { if (!(s->instance = s->construct(inlink->w, inlink->h))) {
av_log(ctx, AV_LOG_ERROR, "Impossible to load frei0r instance\n"); av_log(ctx, AV_LOG_ERROR, "Impossible to load frei0r instance\n");
return AVERROR(EINVAL); return AVERROR(EINVAL);
} }
return set_params(ctx, frei0r->params); return set_params(ctx, s->params);
} }
static int query_formats(AVFilterContext *ctx) static int query_formats(AVFilterContext *ctx)
{ {
Frei0rContext *frei0r = ctx->priv; Frei0rContext *s = ctx->priv;
AVFilterFormats *formats = NULL; AVFilterFormats *formats = NULL;
if (frei0r->plugin_info.color_model == F0R_COLOR_MODEL_BGRA8888) { if (s->plugin_info.color_model == F0R_COLOR_MODEL_BGRA8888) {
ff_add_format(&formats, AV_PIX_FMT_BGRA); ff_add_format(&formats, AV_PIX_FMT_BGRA);
} else if (frei0r->plugin_info.color_model == F0R_COLOR_MODEL_RGBA8888) { } else if (s->plugin_info.color_model == F0R_COLOR_MODEL_RGBA8888) {
ff_add_format(&formats, AV_PIX_FMT_RGBA); ff_add_format(&formats, AV_PIX_FMT_RGBA);
} else { /* F0R_COLOR_MODEL_PACKED32 */ } else { /* F0R_COLOR_MODEL_PACKED32 */
static const enum AVPixelFormat pix_fmts[] = { static const enum AVPixelFormat pix_fmts[] = {
@ -386,7 +386,7 @@ static int query_formats(AVFilterContext *ctx)
static int filter_frame(AVFilterLink *inlink, AVFrame *in) static int filter_frame(AVFilterLink *inlink, AVFrame *in)
{ {
Frei0rContext *frei0r = inlink->dst->priv; Frei0rContext *s = inlink->dst->priv;
AVFilterLink *outlink = inlink->dst->outputs[0]; AVFilterLink *outlink = inlink->dst->outputs[0];
AVFrame *out; AVFrame *out;
@ -397,7 +397,7 @@ static int filter_frame(AVFilterLink *inlink, AVFrame *in)
} }
av_frame_copy_props(out, in); av_frame_copy_props(out, in);
frei0r->update(frei0r->instance, in->pts * av_q2d(inlink->time_base) * 1000, s->update(s->instance, in->pts * av_q2d(inlink->time_base) * 1000,
(const uint32_t *)in->data[0], (const uint32_t *)in->data[0],
(uint32_t *)out->data[0]); (uint32_t *)out->data[0]);
@ -457,56 +457,56 @@ AVFilter avfilter_vf_frei0r = {
static av_cold int source_init(AVFilterContext *ctx) static av_cold int source_init(AVFilterContext *ctx)
{ {
Frei0rContext *frei0r = ctx->priv; Frei0rContext *s = ctx->priv;
AVRational frame_rate_q; AVRational frame_rate_q;
if (av_parse_video_size(&frei0r->w, &frei0r->h, frei0r->size) < 0) { if (av_parse_video_size(&s->w, &s->h, s->size) < 0) {
av_log(ctx, AV_LOG_ERROR, "Invalid frame size: '%s'\n", frei0r->size); av_log(ctx, AV_LOG_ERROR, "Invalid frame size: '%s'\n", s->size);
return AVERROR(EINVAL); return AVERROR(EINVAL);
} }
if (av_parse_video_rate(&frame_rate_q, frei0r->framerate) < 0) { if (av_parse_video_rate(&frame_rate_q, s->framerate) < 0) {
av_log(ctx, AV_LOG_ERROR, "Invalid frame rate: '%s'\n", frei0r->framerate); av_log(ctx, AV_LOG_ERROR, "Invalid frame rate: '%s'\n", s->framerate);
return AVERROR(EINVAL); return AVERROR(EINVAL);
} }
frei0r->time_base.num = frame_rate_q.den; s->time_base.num = frame_rate_q.den;
frei0r->time_base.den = frame_rate_q.num; s->time_base.den = frame_rate_q.num;
return frei0r_init(ctx, frei0r->dl_name, F0R_PLUGIN_TYPE_SOURCE); return frei0r_init(ctx, s->dl_name, F0R_PLUGIN_TYPE_SOURCE);
} }
static int source_config_props(AVFilterLink *outlink) static int source_config_props(AVFilterLink *outlink)
{ {
AVFilterContext *ctx = outlink->src; AVFilterContext *ctx = outlink->src;
Frei0rContext *frei0r = ctx->priv; Frei0rContext *s = ctx->priv;
if (av_image_check_size(frei0r->w, frei0r->h, 0, ctx) < 0) if (av_image_check_size(s->w, s->h, 0, ctx) < 0)
return AVERROR(EINVAL); return AVERROR(EINVAL);
outlink->w = frei0r->w; outlink->w = s->w;
outlink->h = frei0r->h; outlink->h = s->h;
outlink->time_base = frei0r->time_base; outlink->time_base = s->time_base;
outlink->sample_aspect_ratio = (AVRational){1,1}; outlink->sample_aspect_ratio = (AVRational){1,1};
if (!(frei0r->instance = frei0r->construct(outlink->w, outlink->h))) { if (!(s->instance = s->construct(outlink->w, outlink->h))) {
av_log(ctx, AV_LOG_ERROR, "Impossible to load frei0r instance\n"); av_log(ctx, AV_LOG_ERROR, "Impossible to load frei0r instance\n");
return AVERROR(EINVAL); return AVERROR(EINVAL);
} }
return set_params(ctx, frei0r->params); return set_params(ctx, s->params);
} }
static int source_request_frame(AVFilterLink *outlink) static int source_request_frame(AVFilterLink *outlink)
{ {
Frei0rContext *frei0r = outlink->src->priv; Frei0rContext *s = outlink->src->priv;
AVFrame *frame = ff_get_video_buffer(outlink, outlink->w, outlink->h); AVFrame *frame = ff_get_video_buffer(outlink, outlink->w, outlink->h);
if (!frame) if (!frame)
return AVERROR(ENOMEM); return AVERROR(ENOMEM);
frame->sample_aspect_ratio = (AVRational) {1, 1}; frame->sample_aspect_ratio = (AVRational) {1, 1};
frame->pts = frei0r->pts++; frame->pts = s->pts++;
frei0r->update(frei0r->instance, av_rescale_q(frame->pts, frei0r->time_base, (AVRational){1,1000}), s->update(s->instance, av_rescale_q(frame->pts, s->time_base, (AVRational){1,1000}),
NULL, (uint32_t *)frame->data[0]); NULL, (uint32_t *)frame->data[0]);
return ff_filter_frame(outlink, frame); return ff_filter_frame(outlink, frame);

Loading…
Cancel
Save