diff options
author | Michael Niedermayer <michaelni@gmx.at> | 2012-05-06 21:31:08 +0200 |
---|---|---|
committer | Michael Niedermayer <michaelni@gmx.at> | 2012-05-06 21:53:19 +0200 |
commit | 715c8a5a5052d67423f27192444474a3d61dce60 (patch) | |
tree | 4d96bf6fdbbbebef82f0263d2fde088cd4ee9a09 /libavfilter | |
parent | cbbc4724672ec5839427f9b4129051fac9de390b (diff) | |
parent | fb5c1aaea60a714dab3d4e6e71228855fd816222 (diff) | |
download | ffmpeg-715c8a5a5052d67423f27192444474a3d61dce60.tar.gz |
Merge remote-tracking branch 'qatar/master'
* qatar/master: (28 commits)
dfa: use more meaningful return codes
eatgv: check vector_bits
eatgv: check motion vectors
Mark a number of variables only used in av_dlog() calls as av_unused.
dvdec: drop const qualifier from variable to eliminate a warning
avcodec: Improve comment for thread_safe_callbacks to avoid misinterpretation.
tests/utils: don't ignore the return value of fwrite()
lavfi/formats: use sizeof(var) instead of sizeof(type).
lavfi: remove avfilter_default_config_input_link() declaration
lavfi: always enable the scale filter and depend on sws.
vf_split: support user-specifiable number of outputs.
avconv: remove stray useless comment.
mpegmux: add stuffing to avoid incomplete PCM frames
rtsp: avoid const warnings from strtol() call
avserver: check return value of ftruncate()
lagarith: make offset array type unsigned
dfa: add some checks to ensure that decoder won't write past frame end
aacps: NEON optimisations
aacps: align some arrays
aacps: move some loops to function pointers
...
Conflicts:
configure
doc/filters.texi
libavcodec/dfa.c
libavcodec/eatgv.c
libavfilter/Makefile
libavfilter/allfilters.c
libavfilter/avfilter.h
libavfilter/formats.c
libavfilter/vf_split.c
Merged-by: Michael Niedermayer <michaelni@gmx.at>
Diffstat (limited to 'libavfilter')
-rw-r--r-- | libavfilter/Makefile | 7 | ||||
-rw-r--r-- | libavfilter/allfilters.c | 8 | ||||
-rw-r--r-- | libavfilter/formats.c | 14 | ||||
-rw-r--r-- | libavfilter/vf_split.c | 68 |
4 files changed, 71 insertions, 26 deletions
diff --git a/libavfilter/Makefile b/libavfilter/Makefile index f25a1e3297..e7ed1a5250 100644 --- a/libavfilter/Makefile +++ b/libavfilter/Makefile @@ -1,15 +1,14 @@ include $(SUBDIR)../config.mak NAME = avfilter -FFLIBS = avutil +FFLIBS = avutil swscale FFLIBS-$(CONFIG_ACONVERT_FILTER) += swresample FFLIBS-$(CONFIG_AMOVIE_FILTER) += avformat avcodec FFLIBS-$(CONFIG_ARESAMPLE_FILTER) += swresample FFLIBS-$(CONFIG_MOVIE_FILTER) += avformat avcodec FFLIBS-$(CONFIG_PAN_FILTER) += swresample -FFLIBS-$(CONFIG_REMOVELOGO_FILTER) += swscale avformat avcodec -FFLIBS-$(CONFIG_SCALE_FILTER) += swscale +FFLIBS-$(CONFIG_REMOVELOGO_FILTER) += avformat avcodec FFLIBS-$(CONFIG_MP_FILTER) += avcodec postproc HEADERS = asrc_abuffer.h avcodec.h avfilter.h avfiltergraph.h buffersink.h buffersrc.h version.h vsrc_buffer.h @@ -24,6 +23,7 @@ OBJS = allfilters.o \ graphparser.o \ src_buffer.o \ transform.o \ + vf_scale.o \ OBJS-$(CONFIG_AVCODEC) += avcodec.o OBJS-$(CONFIG_AVFORMAT) += lavfutils.o @@ -83,7 +83,6 @@ OBJS-$(CONFIG_OVERLAY_FILTER) += vf_overlay.o OBJS-$(CONFIG_PAD_FILTER) += vf_pad.o OBJS-$(CONFIG_PIXDESCTEST_FILTER) += vf_pixdesctest.o OBJS-$(CONFIG_REMOVELOGO_FILTER) += bbox.o lswsutils.o lavfutils.o vf_removelogo.o -OBJS-$(CONFIG_SCALE_FILTER) += vf_scale.o OBJS-$(CONFIG_SELECT_FILTER) += vf_select.o OBJS-$(CONFIG_SETDAR_FILTER) += vf_aspect.o OBJS-$(CONFIG_SETFIELD_FILTER) += vf_setfield.o diff --git a/libavfilter/allfilters.c b/libavfilter/allfilters.c index 5241fc09ad..96de563606 100644 --- a/libavfilter/allfilters.c +++ b/libavfilter/allfilters.c @@ -89,7 +89,6 @@ void avfilter_register_all(void) REGISTER_FILTER (PAD, pad, vf); REGISTER_FILTER (PIXDESCTEST, pixdesctest, vf); REGISTER_FILTER (REMOVELOGO, removelogo, vf); - REGISTER_FILTER (SCALE, scale, vf); REGISTER_FILTER (SELECT, select, vf); REGISTER_FILTER (SETDAR, setdar, vf); REGISTER_FILTER (SETFIELD, setfield, vf); @@ -123,9 +122,14 @@ void avfilter_register_all(void) REGISTER_FILTER (BUFFERSINK, buffersink, vsink); REGISTER_FILTER (NULLSINK, nullsink, vsink); - /* vsrc_buffer is a part of public API => registered unconditionally */ + /* those filters are part of public or internal API => registered + * unconditionally */ { extern AVFilter avfilter_vsrc_buffer; avfilter_register(&avfilter_vsrc_buffer); } + { + extern AVFilter avfilter_vf_scale; + avfilter_register(&avfilter_vf_scale); + } } diff --git a/libavfilter/formats.c b/libavfilter/formats.c index d01ea42f8b..c52c79dd26 100644 --- a/libavfilter/formats.c +++ b/libavfilter/formats.c @@ -49,7 +49,7 @@ AVFilterFormats *avfilter_merge_formats(AVFilterFormats *a, AVFilterFormats *b) if (a == b) return a; - ret = av_mallocz(sizeof(AVFilterFormats)); + ret = av_mallocz(sizeof(*ret)); /* merge list of formats */ ret->formats = av_malloc(sizeof(*ret->formats) * FFMIN(a->format_count, @@ -74,7 +74,7 @@ AVFilterFormats *avfilter_merge_formats(AVFilterFormats *a, AVFilterFormats *b) return NULL; } - ret->refs = av_malloc(sizeof(AVFilterFormats**)*(a->refcount+b->refcount)); + ret->refs = av_malloc(sizeof(*ret->refs) * (a->refcount + b->refcount)); merge_ref(ret, a); merge_ref(ret, b); @@ -158,7 +158,7 @@ int avfilter_add_format(AVFilterFormats **avff, int64_t fmt) { int64_t *fmts; - if (!(*avff) && !(*avff = av_mallocz(sizeof(AVFilterFormats)))) + if (!(*avff) && !(*avff = av_mallocz(sizeof(**avff)))) return AVERROR(ENOMEM); fmts = av_realloc((*avff)->formats, @@ -217,7 +217,7 @@ AVFilterFormats *avfilter_make_all_packing_formats(void) void avfilter_formats_ref(AVFilterFormats *f, AVFilterFormats **ref) { *ref = f; - f->refs = av_realloc(f->refs, sizeof(AVFilterFormats**) * ++f->refcount); + f->refs = av_realloc(f->refs, sizeof(*f->refs) * ++f->refcount); f->refs[f->refcount-1] = ref; } @@ -239,9 +239,9 @@ void avfilter_formats_unref(AVFilterFormats **ref) idx = find_ref_index(ref); - if (idx >= 0) - memmove((*ref)->refs + idx, (*ref)->refs + idx+1, - sizeof(AVFilterFormats**) * ((*ref)->refcount-idx-1)); + if(idx >= 0) + memmove((*ref)->refs + idx, (*ref)->refs + idx + 1, + sizeof(*(*ref)->refs) * ((*ref)->refcount - idx - 1)); if (!--(*ref)->refcount) { av_free((*ref)->formats); diff --git a/libavfilter/vf_split.c b/libavfilter/vf_split.c index ee46ad08c1..e7e2dee90d 100644 --- a/libavfilter/vf_split.c +++ b/libavfilter/vf_split.c @@ -25,24 +25,67 @@ #include "avfilter.h" +static int split_init(AVFilterContext *ctx, const char *args, void *opaque) +{ + int i, nb_outputs = 2; + + if (args) { + nb_outputs = strtol(args, NULL, 0); + if (nb_outputs <= 0) { + av_log(ctx, AV_LOG_ERROR, "Invalid number of outputs specified: %d.\n", + nb_outputs); + return AVERROR(EINVAL); + } + } + + for (i = 0; i < nb_outputs; i++) { + char name[32]; + AVFilterPad pad = { 0 }; + + snprintf(name, sizeof(name), "output%d", i); + pad.type = AVMEDIA_TYPE_VIDEO; + pad.name = av_strdup(name); + + avfilter_insert_outpad(ctx, i, &pad); + } + + return 0; +} + +static void split_uninit(AVFilterContext *ctx) +{ + int i; + + for (i = 0; i < ctx->output_count; i++) + av_freep(&ctx->output_pads[i].name); +} + static void start_frame(AVFilterLink *inlink, AVFilterBufferRef *picref) { - avfilter_start_frame(inlink->dst->outputs[0], - avfilter_ref_buffer(picref, ~AV_PERM_WRITE)); - avfilter_start_frame(inlink->dst->outputs[1], - avfilter_ref_buffer(picref, ~AV_PERM_WRITE)); + AVFilterContext *ctx = inlink->dst; + int i; + + for (i = 0; i < ctx->output_count; i++) + avfilter_start_frame(ctx->outputs[i], + avfilter_ref_buffer(picref, ~AV_PERM_WRITE)); } static void draw_slice(AVFilterLink *inlink, int y, int h, int slice_dir) { - avfilter_draw_slice(inlink->dst->outputs[0], y, h, slice_dir); - avfilter_draw_slice(inlink->dst->outputs[1], y, h, slice_dir); + AVFilterContext *ctx = inlink->dst; + int i; + + for (i = 0; i < ctx->output_count; i++) + avfilter_draw_slice(ctx->outputs[i], y, h, slice_dir); } static void end_frame(AVFilterLink *inlink) { - avfilter_end_frame(inlink->dst->outputs[0]); - avfilter_end_frame(inlink->dst->outputs[1]); + AVFilterContext *ctx = inlink->dst; + int i; + + for (i = 0; i < ctx->output_count; i++) + avfilter_end_frame(ctx->outputs[i]); avfilter_unref_buffer(inlink->cur_buf); } @@ -51,6 +94,9 @@ AVFilter avfilter_vf_split = { .name = "split", .description = NULL_IF_CONFIG_SMALL("Pass on the input to two outputs."), + .init = split_init, + .uninit = split_uninit, + .inputs = (const AVFilterPad[]) {{ .name = "default", .type = AVMEDIA_TYPE_VIDEO, .get_video_buffer= avfilter_null_get_video_buffer, @@ -58,9 +104,5 @@ AVFilter avfilter_vf_split = { .draw_slice = draw_slice, .end_frame = end_frame, }, { .name = NULL}}, - .outputs = (const AVFilterPad[]) {{ .name = "output1", - .type = AVMEDIA_TYPE_VIDEO, }, - { .name = "output2", - .type = AVMEDIA_TYPE_VIDEO, }, - { .name = NULL}}, + .outputs = (AVFilterPad[]) {{ .name = NULL}}, }; |