[FFmpeg-devel] [PATCH] avfilter/vf_idet: Fixes issue with idet not flushing last frame.
Uses a similar approach as vf_yadif to flush the last frame in idet. Quick test with 50 frames from vsynth1: ./ffmpeg.old -i fate-suite/ffmpeg-synthetic/vsynth1/%02d.pgm -vf idet -f mp4 -y /dev/null 21 | grep Multi (gives) [Parsed_idet_0 @ 0x261ebb0] Multi frame detection: TFF:0 BFF:0 Progressive:48 Undetermined:1 ./ffmpeg -i fate-suite/ffmpeg-synthetic/vsynth1/%02d.pgm -vf idet -f mp4 -y /dev/null 21 | grep Multi (gives) [Parsed_idet_0 @ 0x35a0bb0] Multi frame detection: TFF:0 BFF:0 Progressive:49 Undetermined:1 Fate tests have been updated. (In testing, it seems this filter will also need a subsequent patch for single frame input) Signed-off-by: Neil Birkbeck neil.birkb...@gmail.com --- libavfilter/vf_idet.c | 31 +++ libavfilter/vf_idet.h | 1 + tests/ref/fate/filter-idet | 2 +- 3 files changed, 33 insertions(+), 1 deletion(-) diff --git a/libavfilter/vf_idet.c b/libavfilter/vf_idet.c index 339f4a6..b9c4070 100644 --- a/libavfilter/vf_idet.c +++ b/libavfilter/vf_idet.c @@ -191,6 +191,35 @@ static int filter_frame(AVFilterLink *link, AVFrame *picref) return ff_filter_frame(ctx-outputs[0], av_frame_clone(idet-cur)); } +static int request_frame(AVFilterLink *link) +{ +AVFilterContext *ctx = link-src; +IDETContext *idet = ctx-priv; + +do { +int ret; + +if (idet-eof) +return AVERROR_EOF; + +ret = ff_request_frame(link-src-inputs[0]); + +if (ret == AVERROR_EOF idet-cur) { +AVFrame *next = av_frame_clone(idet-next); + +if (!next) +return AVERROR(ENOMEM); + +filter_frame(link-src-inputs[0], next); +idet-eof = 1; +} else if (ret 0) { +return ret; +} +} while (!idet-cur); + +return 0; +} + static av_cold void uninit(AVFilterContext *ctx) { IDETContext *idet = ctx-priv; @@ -253,6 +282,7 @@ static av_cold int init(AVFilterContext *ctx) { IDETContext *idet = ctx-priv; +idet-eof = 0; idet-last_type = UNDETERMINED; memset(idet-history, UNDETERMINED, HIST_SIZE); @@ -279,6 +309,7 @@ static const AVFilterPad idet_outputs[] = { .name = default, .type = AVMEDIA_TYPE_VIDEO, .config_props = config_output, +.request_frame = request_frame }, { NULL } }; diff --git a/libavfilter/vf_idet.h b/libavfilter/vf_idet.h index ef29fff..57332df 100644 --- a/libavfilter/vf_idet.h +++ b/libavfilter/vf_idet.h @@ -50,6 +50,7 @@ typedef struct { ff_idet_filter_func filter_line; const AVPixFmtDescriptor *csp; +int eof; } IDETContext; void ff_idet_init_x86(IDETContext *idet, int for_16b); diff --git a/tests/ref/fate/filter-idet b/tests/ref/fate/filter-idet index f1396c5..2f9f11c 100644 --- a/tests/ref/fate/filter-idet +++ b/tests/ref/fate/filter-idet @@ -1 +1 @@ -idet1790336872e844c867a53150b8ee8810 +idet005e6ddc8a5daf11cf866a1ec76c2572 -- 2.1.0.rc2.206.gedb03e5 ___ ffmpeg-devel mailing list ffmpeg-devel@ffmpeg.org http://ffmpeg.org/mailman/listinfo/ffmpeg-devel
Re: [FFmpeg-devel] [PATCH] avfilter/vf_idet: Fixes issue with idet not flushing last frame.
Hi, On Tue, Oct 21, 2014 at 11:40 PM, Neil Birkbeck neil.birkb...@gmail.com wrote: Uses a similar approach as vf_yadif to flush the last frame in idet. Quick test with 50 frames from vsynth1: ./ffmpeg.old -i fate-suite/ffmpeg-synthetic/vsynth1/%02d.pgm -vf idet -f mp4 -y /dev/null 21 | grep Multi (gives) [Parsed_idet_0 @ 0x261ebb0] Multi frame detection: TFF:0 BFF:0 Progressive:48 Undetermined:1 ./ffmpeg -i fate-suite/ffmpeg-synthetic/vsynth1/%02d.pgm -vf idet -f mp4 -y /dev/null 21 | grep Multi (gives) [Parsed_idet_0 @ 0x35a0bb0] Multi frame detection: TFF:0 BFF:0 Progressive:49 Undetermined:1 Seems ok. Note that it seems to be reporting one extra frame always. E.g.: ./ffmpeg -i test.mov -vframes 3 -an -vf idet -f null /dev/null 21 | grep idet [Parsed_idet_0 @ 0x7feab8500160] Single frame detection: TFF:0 BFF:0 Progressive:4 Undetermined:0 [Parsed_idet_0 @ 0x7feab8500160] Multi frame detection: TFF:0 BFF:0 Progressive:4 Undetermined:0 or, with 1 frame: ./ffmpeg -i test.mov -vframes 1 -an -vf idet -f null /dev/null 21 | grep idet [Parsed_idet_0 @ 0x7fc958600c80] Single frame detection: TFF:0 BFF:0 Progressive:2 Undetermined:0 [Parsed_idet_0 @ 0x7fc958600c80] Multi frame detection: TFF:0 BFF:0 Progressive:2 Undetermined:0 Fate tests have been updated. (In testing, it seems this filter will also need a subsequent patch for single frame input) Signed-off-by: Neil Birkbeck neil.birkb...@gmail.com --- libavfilter/vf_idet.c | 31 +++ libavfilter/vf_idet.h | 1 + tests/ref/fate/filter-idet | 2 +- 3 files changed, 33 insertions(+), 1 deletion(-) diff --git a/libavfilter/vf_idet.c b/libavfilter/vf_idet.c index 339f4a6..b9c4070 100644 --- a/libavfilter/vf_idet.c +++ b/libavfilter/vf_idet.c @@ -191,6 +191,35 @@ static int filter_frame(AVFilterLink *link, AVFrame *picref) return ff_filter_frame(ctx-outputs[0], av_frame_clone(idet-cur)); } +static int request_frame(AVFilterLink *link) +{ +AVFilterContext *ctx = link-src; +IDETContext *idet = ctx-priv; + +do { +int ret; + +if (idet-eof) +return AVERROR_EOF; + +ret = ff_request_frame(link-src-inputs[0]); + +if (ret == AVERROR_EOF idet-cur) { +AVFrame *next = av_frame_clone(idet-next); + +if (!next) +return AVERROR(ENOMEM); + +filter_frame(link-src-inputs[0], next); +idet-eof = 1; +} else if (ret 0) { +return ret; +} +} while (!idet-cur); + +return 0; +} + static av_cold void uninit(AVFilterContext *ctx) { IDETContext *idet = ctx-priv; @@ -253,6 +282,7 @@ static av_cold int init(AVFilterContext *ctx) { IDETContext *idet = ctx-priv; +idet-eof = 0; idet-last_type = UNDETERMINED; memset(idet-history, UNDETERMINED, HIST_SIZE); @@ -279,6 +309,7 @@ static const AVFilterPad idet_outputs[] = { .name = default, .type = AVMEDIA_TYPE_VIDEO, .config_props = config_output, +.request_frame = request_frame }, { NULL } }; diff --git a/libavfilter/vf_idet.h b/libavfilter/vf_idet.h index ef29fff..57332df 100644 --- a/libavfilter/vf_idet.h +++ b/libavfilter/vf_idet.h @@ -50,6 +50,7 @@ typedef struct { ff_idet_filter_func filter_line; const AVPixFmtDescriptor *csp; +int eof; } IDETContext; void ff_idet_init_x86(IDETContext *idet, int for_16b); diff --git a/tests/ref/fate/filter-idet b/tests/ref/fate/filter-idet index f1396c5..2f9f11c 100644 --- a/tests/ref/fate/filter-idet +++ b/tests/ref/fate/filter-idet @@ -1 +1 @@ -idet1790336872e844c867a53150b8ee8810 +idet005e6ddc8a5daf11cf866a1ec76c2572 -- 2.1.0.rc2.206.gedb03e5 ___ ffmpeg-devel mailing list ffmpeg-devel@ffmpeg.org http://ffmpeg.org/mailman/listinfo/ffmpeg-devel ___ ffmpeg-devel mailing list ffmpeg-devel@ffmpeg.org http://ffmpeg.org/mailman/listinfo/ffmpeg-devel
Re: [FFmpeg-devel] [PATCH] avfilter/vf_idet: Fixes issue with idet not flushing last frame.
On Wed, Oct 22, 2014 at 7:43 AM, Pascal Massimino pascal.massim...@gmail.com wrote: Hi, On Tue, Oct 21, 2014 at 11:40 PM, Neil Birkbeck neil.birkb...@gmail.com wrote: Uses a similar approach as vf_yadif to flush the last frame in idet. Quick test with 50 frames from vsynth1: ./ffmpeg.old -i fate-suite/ffmpeg-synthetic/vsynth1/%02d.pgm -vf idet -f mp4 -y /dev/null 21 | grep Multi (gives) [Parsed_idet_0 @ 0x261ebb0] Multi frame detection: TFF:0 BFF:0 Progressive:48 Undetermined:1 ./ffmpeg -i fate-suite/ffmpeg-synthetic/vsynth1/%02d.pgm -vf idet -f mp4 -y /dev/null 21 | grep Multi (gives) [Parsed_idet_0 @ 0x35a0bb0] Multi frame detection: TFF:0 BFF:0 Progressive:49 Undetermined:1 Seems ok. Note that it seems to be reporting one extra frame always. E.g.: ./ffmpeg -i test.mov -vframes 3 -an -vf idet -f null /dev/null 21 | grep idet [Parsed_idet_0 @ 0x7feab8500160] Single frame detection: TFF:0 BFF:0 Progressive:4 Undetermined:0 [Parsed_idet_0 @ 0x7feab8500160] Multi frame detection: TFF:0 BFF:0 Progressive:4 Undetermined:0 or, with 1 frame: ./ffmpeg -i test.mov -vframes 1 -an -vf idet -f null /dev/null 21 | grep idet [Parsed_idet_0 @ 0x7fc958600c80] Single frame detection: TFF:0 BFF:0 Progressive:2 Undetermined:0 [Parsed_idet_0 @ 0x7fc958600c80] Multi frame detection: TFF:0 BFF:0 Progressive:2 Undetermined:0 it seems the option -vframes is applied after the filter chain. You can check by doing: ffmpeg -i test.mov -vframes 1 -vf showinfo,idet,showinfo -f null /dev/null 21 | grep Parsed_showinfo_0 [Parsed_showinfo_0 @ 0x3643860] n:0 pts:4 pts_time:4.4e-05 pos:564959 fmt:yuv420p sar:0/1 s:640x360 i:P iskey:1 type:I checksum:A1E65077 plane_checksum:[A0094348 02828690 02828690] [Parsed_showinfo_0 @ 0x3643860] n:1 pts:3758 pts_time:0.0417556 pos:565077 fmt:yuv420p sar:0/1 s:640x360 i:P iskey:0 type:B checksum:A1E65077 plane_checksum:[A0094348 02828690 02828690] [Parsed_showinfo_0 @ 0x3643860] n:2 pts:7512 pts_time:0.0834667 pos:565094 fmt:yuv420p sar:0/1 s:640x360 i:P iskey:0 type:B checksum:A1E65077 plane_checksum:[A0094348 02828690 02828690] [Parsed_showinfo_0 @ 0x3643860] n:3 pts:11265 pts_time:0.125167 pos:565058 fmt:yuv420p sar:0/1 s:640x360 i:P iskey:0 type:P checksum:A1E65077 plane_checksum:[A0094348 02828690 02828690] [Parsed_showinfo_0 @ 0x3643860] n:4 pts:15019 pts_time:0.166878 pos:565131 fmt:yuv420p sar:0/1 s:640x360 i:P iskey:0 type:B checksum:A1E65077 plane_checksum:[A0094348 02828690 02828690] [Parsed_showinfo_0 @ 0x3643860] n:5 pts:18773 pts_time:0.208589 pos:565148 fmt:yuv420p sar:0/1 s:640x360 i:P iskey:0 type:B checksum:A1E65077 plane_checksum:[A0094348 02828690 02828690] [Parsed_showinfo_0 @ 0x3643860] n:6 pts:22527 pts_time:0.2503 pos:565111 fmt:yuv420p sar:0/1 s:640x360 i:P iskey:0 type:P checksum:A1E65077 plane_checksum:[A0094348 02828690 02828690] [Parsed_showinfo_0 @ 0x3643860] n:7 pts:26280 pts_time:0.292 pos:565184 fmt:yuv420p sar:0/1 s:640x360 i:P iskey:0 type:B checksum:A1E65077 plane_checksum:[A0094348 02828690 02828690] [Parsed_showinfo_0 @ 0x3643860] n:8 pts:30034 pts_time:0.333711 pos:565201 fmt:yuv420p sar:0/1 s:640x360 i:P iskey:0 type:B checksum:A1E65077 plane_checksum:[A0094348 02828690 02828690] [Parsed_showinfo_0 @ 0x3643860] n:9 pts:33788 pts_time:0.375422 pos:565165 fmt:yuv420p sar:0/1 s:640x360 i:P iskey:0 type:P checksum:A1E65077 plane_checksum:[A0094348 02828690 02828690] [Parsed_showinfo_0 @ 0x3643860] n:10 pts:37542 pts_time:0.417133 pos:565237 fmt:yuv420p sar:0/1 s:640x360 i:P iskey:0 type:B checksum:A1E65077 plane_checksum:[A0094348 02828690 02828690] [Parsed_showinfo_0 @ 0x3643860] n:11 pts:41295 pts_time:0.458833 pos:573273 fmt:yuv420p sar:0/1 s:640x360 i:P iskey:0 type:B checksum:A1E65077 plane_checksum:[A0094348 02828690 02828690] [Parsed_showinfo_0 @ 0x3643860] n:12 pts:45049 pts_time:0.500544 pos:565218 fmt:yuv420p sar:0/1 s:640x360 i:P iskey:0 type:P checksum:A1E65077 plane_checksum:[A0094348 02828690 02828690] [Parsed_showinfo_0 @ 0x3643860] n:13 pts:48803 pts_time:0.542256 pos:573309 fmt:yuv420p sar:0/1 s:640x360 i:P iskey:0 type:B checksum:A1E65077 plane_checksum:[A0094348 02828690 02828690] [Parsed_showinfo_0 @ 0x3643860] n:14 pts:56310 pts_time:0.625667 pos:573290 fmt:yuv420p sar:0/1 s:640x360 i:P iskey:0 type:P checksum:A1E65077 plane_checksum:[A0094348 02828690 02828690] and you will see that more than 1 frame are injected in the filter. but if you look at the output file, it will contains 1 frame only. Fate tests have been updated. (In testing, it seems this filter will also need a subsequent patch for single frame input) Signed-off-by: Neil Birkbeck neil.birkb...@gmail.com --- libavfilter/vf_idet.c | 31 +++ libavfilter/vf_idet.h | 1 + tests/ref/fate/filter-idet | 2 +- 3 files changed, 33 insertions(+), 1 deletion(-) diff --git a/libavfilter/vf_idet.c b/libavfilter/vf_idet.c index 339f4a6..b9c4070 100644 ---