diff options
author | Michael Niedermayer <michaelni@gmx.at> | 2012-05-16 02:27:31 +0200 |
---|---|---|
committer | Michael Niedermayer <michaelni@gmx.at> | 2012-05-16 02:27:31 +0200 |
commit | 1cbf7fb4345a3e5b7791d483241bf4759bde4ece (patch) | |
tree | d7acd8317309e051fb240e3505f77aabe2ea0437 /libavfilter/vf_yadif.c | |
parent | a48abf5e263ad7f2e68821766e7cf4d29befb58e (diff) | |
parent | 0ff0af731ce4544f84b2f748dcc699717a2df8d6 (diff) |
Merge remote-tracking branch 'qatar/master'
* qatar/master: (26 commits)
fate: use diff -b in oneline comparison
Add missing version bumps and APIchanges/Changelog entries.
lavfi: move buffer management function to a separate file.
lavfi: move formats-related functions from default.c to formats.c
lavfi: move video-related functions to a separate file.
fate: make smjpeg a demux test
fate: separate sierra-vmd audio and video tests
fate: separate smacker audio and video tests
libmp3lame: set supported channel layouts.
avconv: automatically insert asyncts when -async is used.
avconv: add support for audio filters.
lavfi: add asyncts filter.
lavfi: add aformat filter
lavfi: add an audio buffer sink.
lavfi: add an audio buffer source.
buffersrc: add av_buffersrc_write_frame().
buffersrc: fix invalid read in uninit if the fifo hasn't been allocated
lavfi: rename vsrc_buffer.c to buffersrc.c
avfiltergraph: reindent
lavfi: add channel layout/sample rate negotiation.
...
Conflicts:
Changelog
doc/APIchanges
doc/filters.texi
ffmpeg.c
ffprobe.c
libavcodec/libmp3lame.c
libavfilter/Makefile
libavfilter/af_aformat.c
libavfilter/allfilters.c
libavfilter/avfilter.c
libavfilter/avfilter.h
libavfilter/avfiltergraph.c
libavfilter/buffersrc.c
libavfilter/defaults.c
libavfilter/formats.c
libavfilter/src_buffer.c
libavfilter/version.h
libavfilter/vf_yadif.c
libavfilter/vsrc_buffer.c
libavfilter/vsrc_buffer.h
libavutil/avutil.h
tests/fate/audio.mak
tests/fate/demux.mak
tests/fate/video.mak
Merged-by: Michael Niedermayer <michaelni@gmx.at>
Diffstat (limited to 'libavfilter/vf_yadif.c')
-rw-r--r-- | libavfilter/vf_yadif.c | 54 |
1 files changed, 36 insertions, 18 deletions
diff --git a/libavfilter/vf_yadif.c b/libavfilter/vf_yadif.c index 684f9099fa..fb4862d0be 100644 --- a/libavfilter/vf_yadif.c +++ b/libavfilter/vf_yadif.c @@ -59,6 +59,7 @@ typedef struct { int w, int prefs, int mrefs, int parity, int mode); const AVPixFmtDescriptor *csp; + int eof; } YADIFContext; #define CHECK(j)\ @@ -216,22 +217,11 @@ static void return_frame(AVFilterContext *ctx, int is_second) filter(ctx, yadif->out, tff ^ !is_second, tff); if (is_second) { - if (yadif->next->pts != AV_NOPTS_VALUE && - yadif->cur->pts != AV_NOPTS_VALUE) { - uint64_t next_pts = yadif->next->pts; - uint64_t cur_pts = yadif->cur->pts; - uint64_t prev_pts = yadif->prev->pts; - - uint64_t ft = FFMIN3( cur_pts-prev_pts, - next_pts-cur_pts, - (next_pts-prev_pts)/2); - - if(next_pts - cur_pts < 2*ft) - yadif->out->pts = - (next_pts&cur_pts) + - ((next_pts^cur_pts)>>1); - else - yadif->out->pts = cur_pts + ft/2; + int64_t cur_pts = yadif->cur->pts; + int64_t next_pts = yadif->next->pts; + + if (next_pts != AV_NOPTS_VALUE && cur_pts != AV_NOPTS_VALUE) { + yadif->out->pts = cur_pts + next_pts; } else { yadif->out->pts = AV_NOPTS_VALUE; } @@ -264,6 +254,8 @@ static void start_frame(AVFilterLink *link, AVFilterBufferRef *picref) yadif->out = avfilter_ref_buffer(yadif->cur, AV_PERM_READ); avfilter_unref_buffer(yadif->prev); yadif->prev = NULL; + if (yadif->out->pts != AV_NOPTS_VALUE) + yadif->out->pts *= 2; avfilter_start_frame(ctx->outputs[0], yadif->out); return; } @@ -276,6 +268,8 @@ static void start_frame(AVFilterLink *link, AVFilterBufferRef *picref) avfilter_copy_buffer_ref_props(yadif->out, yadif->cur); yadif->out->video->interlaced = 0; + if (yadif->out->pts != AV_NOPTS_VALUE) + yadif->out->pts *= 2; avfilter_start_frame(ctx->outputs[0], yadif->out); } @@ -309,8 +303,21 @@ static int request_frame(AVFilterLink *link) do { int ret; - if ((ret = avfilter_request_frame(link->src->inputs[0]))) + if (yadif->eof) + return AVERROR_EOF; + + ret = avfilter_request_frame(link->src->inputs[0]); + + if (ret == AVERROR_EOF && yadif->next) { + AVFilterBufferRef *next = avfilter_ref_buffer(yadif->next, AV_PERM_READ); + next->pts = yadif->next->pts * 2 - yadif->cur->pts; + + start_frame(link->src->inputs[0], next); + end_frame(link->src->inputs[0]); + yadif->eof = 1; + } else if (ret < 0) { return ret; + } } while (!yadif->cur); return 0; @@ -411,6 +418,16 @@ static av_cold int init(AVFilterContext *ctx, const char *args, void *opaque) static void null_draw_slice(AVFilterLink *link, int y, int h, int slice_dir) { } +static int config_props(AVFilterLink *link) +{ + link->time_base.num = link->src->inputs[0]->time_base.num; + link->time_base.den = link->src->inputs[0]->time_base.den * 2; + link->w = link->src->inputs[0]->w; + link->h = link->src->inputs[0]->h; + + return 0; +} + AVFilter avfilter_vf_yadif = { .name = "yadif", .description = NULL_IF_CONFIG_SMALL("Deinterlace the input image."), @@ -432,6 +449,7 @@ AVFilter avfilter_vf_yadif = { .outputs = (const AVFilterPad[]) {{ .name = "default", .type = AVMEDIA_TYPE_VIDEO, .poll_frame = poll_frame, - .request_frame = request_frame, }, + .request_frame = request_frame, + .config_props = config_props, }, { .name = NULL}}, }; |