ffplay: fix odd YUV width by cropping the video
Should fix issue #1322. Signed-off-by: Marton Balint <cus@passwd.hu> Signed-off-by: Michael Niedermayer <michaelni@gmx.at>
This commit is contained in:

committed by
Michael Niedermayer

parent
95d1af1188
commit
a366beaf6a
12
ffplay.c
12
ffplay.c
@@ -1586,7 +1586,7 @@ static int configure_video_filters(AVFilterGraph *graph, VideoState *is, const c
|
|||||||
char buffersrc_args[256];
|
char buffersrc_args[256];
|
||||||
int ret;
|
int ret;
|
||||||
AVBufferSinkParams *buffersink_params = av_buffersink_params_alloc();
|
AVBufferSinkParams *buffersink_params = av_buffersink_params_alloc();
|
||||||
AVFilterContext *filt_src = NULL, *filt_out = NULL, *filt_format;
|
AVFilterContext *filt_src = NULL, *filt_out = NULL, *filt_format, *filt_crop;
|
||||||
AVCodecContext *codec = is->video_st->codec;
|
AVCodecContext *codec = is->video_st->codec;
|
||||||
|
|
||||||
snprintf(sws_flags_str, sizeof(sws_flags_str), "flags=%d", sws_flags);
|
snprintf(sws_flags_str, sizeof(sws_flags_str), "flags=%d", sws_flags);
|
||||||
@@ -1612,14 +1612,22 @@ static int configure_video_filters(AVFilterGraph *graph, VideoState *is, const c
|
|||||||
if (ret < 0)
|
if (ret < 0)
|
||||||
return ret;
|
return ret;
|
||||||
|
|
||||||
|
/* SDL YUV code is not handling odd width/height for some driver
|
||||||
|
* combinations, therefore we crop the picture to an even width/height. */
|
||||||
|
if ((ret = avfilter_graph_create_filter(&filt_crop,
|
||||||
|
avfilter_get_by_name("crop"),
|
||||||
|
"ffplay_crop", "floor(in_w/2)*2:floor(in_h/2)*2", NULL, graph)) < 0)
|
||||||
|
return ret;
|
||||||
if ((ret = avfilter_graph_create_filter(&filt_format,
|
if ((ret = avfilter_graph_create_filter(&filt_format,
|
||||||
avfilter_get_by_name("format"),
|
avfilter_get_by_name("format"),
|
||||||
"format", "yuv420p", NULL, graph)) < 0)
|
"format", "yuv420p", NULL, graph)) < 0)
|
||||||
return ret;
|
return ret;
|
||||||
|
if ((ret = avfilter_link(filt_crop, 0, filt_format, 0)) < 0)
|
||||||
|
return ret;
|
||||||
if ((ret = avfilter_link(filt_format, 0, filt_out, 0)) < 0)
|
if ((ret = avfilter_link(filt_format, 0, filt_out, 0)) < 0)
|
||||||
return ret;
|
return ret;
|
||||||
|
|
||||||
if ((ret = configure_filtergraph(graph, vfilters, filt_src, filt_format)) < 0)
|
if ((ret = configure_filtergraph(graph, vfilters, filt_src, filt_crop)) < 0)
|
||||||
return ret;
|
return ret;
|
||||||
|
|
||||||
is->in_video_filter = filt_src;
|
is->in_video_filter = filt_src;
|
||||||
|
Reference in New Issue
Block a user