[FFmpeg-devel] [PATCH] lavf/vf_deinterlace_vaapi: flush queued frame in field mode

Mark Thompson sw at jkqxz.net
Tue Aug 20 23:49:17 EEST 2019


On 02/08/2019 10:53, Linjie Fu wrote:
> Add deint_vaapi_request_frame for deinterlace_vaapi, send NULL frame
> to flush the queued frame.
> 
> Fix the frame drop issue in field mode:
> 
> ffmpeg -hwaccel vaapi -vaapi_device /dev/dri/renderD128 -v verbose -c:v
> h264 -i ./input.h264 -vf 'format=nv12|vaapi,hwupload,
>         deinterlace_vaapi=mode=bob:rate=field,hwdownload,format=nv12'
> -pix_fmt yuv420p -f rawvideo -vsync passthrough -y dump.yuv
> 
> Signed-off-by: Linjie Fu <linjie.fu at intel.com>
> ---
>  libavfilter/vf_deinterlace_vaapi.c | 46 ++++++++++++++++++++++++++++++++------
>  1 file changed, 39 insertions(+), 7 deletions(-)

Can you explain in more detail what the problem is here?  What frame is being dropped?


I already get the expected number of frames out with both rate settings (input total - forward references - backward references, all multiplied by 2 for field rate output).  E.g. for 100 frames/field-pairs of input:

$ ./ffmpeg_g -hwaccel vaapi -hwaccel_device /dev/dri/renderD129 -hwaccel_output_format vaapi -i f100.mp4 -an -vf deinterlace_vaapi=rate=frame -f null -
...
frame=   97

$ ./ffmpeg_g -hwaccel vaapi -hwaccel_device /dev/dri/renderD129 -hwaccel_output_format vaapi -i f100.mp4 -an -vf deinterlace_vaapi=rate=field -f null -
...
frame=  194

(With forward = 2, backward = 1.)


With this patch applied, the filter always segfaults for me at the end of the stream when set to field rate:

$ gdb --args ./ffmpeg_g -hwaccel vaapi -hwaccel_device /dev/dri/renderD129 -hwaccel_output_format vaapi -i f100.mp4 -an -vf deinterlace_vaapi=rate=field -f null -
...
Thread 1 "ffmpeg_g" received signal SIGSEGV, Segmentation fault.
0x0000555555755fb1 in deint_vaapi_filter_frame (inlink=0x555559092300, input_frame=0x555558d42000) at src/libavfilter/vf_deinterlace_vaapi.c:227
227                 ctx->frame_queue[current_frame_index + i + 1]->data[3];
(gdb) bt
#0  0x0000555555755fb1 in deint_vaapi_filter_frame (inlink=0x555559092300, input_frame=0x555558d42000) at src/libavfilter/vf_deinterlace_vaapi.c:227
#1  0x00005555557565d2 in deint_vaapi_request_frame (link=0x5555590928c0) at src/libavfilter/vf_deinterlace_vaapi.c:342
#2  0x00005555556ce950 in ff_request_frame_to_filter (link=0x5555590928c0) at src/libavfilter/avfilter.c:458
#3  0x00005555556d0cd0 in forward_status_change (filter=0x555559088940, in=0x555559092300) at src/libavfilter/avfilter.c:1243
#4  0x00005555556d0eaf in ff_filter_activate_default (filter=0x555559088940) at src/libavfilter/avfilter.c:1274
#5  0x00005555556d0fec in ff_filter_activate (filter=0x555559088940) at src/libavfilter/avfilter.c:1430
#6  0x00005555556d5d29 in ff_filter_graph_run_once (graph=0x55555908ff00) at src/libavfilter/avfiltergraph.c:1456
#7  0x00005555556d71d8 in push_frame (graph=0x55555908ff00) at src/libavfilter/buffersrc.c:187
#8  0x00005555556d77a9 in av_buffersrc_close (ctx=0x555559091ac0, pts=300300, flags=4) at src/libavfilter/buffersrc.c:275
#9  0x000055555569356a in ifilter_send_eof (ifilter=0x5555580d0e40, pts=300300) at src/fftools/ffmpeg.c:2213
#10 0x00005555556949fd in send_filter_eof (ist=0x5555580f3ac0) at src/fftools/ffmpeg.c:2562
#11 0x0000555555695336 in process_input_packet (ist=0x5555580f3ac0, pkt=0x0, no_eof=0) at src/fftools/ffmpeg.c:2701
#12 0x000055555569a9db in process_input (file_index=0) at src/fftools/ffmpeg.c:4313
#13 0x000055555569c5f9 in transcode_step () at src/fftools/ffmpeg.c:4638
#14 0x000055555569c726 in transcode () at src/fftools/ffmpeg.c:4692
#15 0x000055555569cfb6 in main (argc=15, argv=0x7fffffffe488) at src/fftools/ffmpeg.c:4894
(gdb) p current_frame_index 
$1 = 2
(gdb) p i
$2 = 0
(gdb) p ctx->frame_queue[current_frame_index + i + 1]
$3 = (AVFrame *) 0x0


- Mark


More information about the ffmpeg-devel mailing list