[FFmpeg-devel] [PATCH] ffplay: fix odd YUV width

Marton Balint cus at passwd.hu
Fri Aug 24 13:05:29 CEST 2012


Should fix issue #1322.

Signed-off-by: Marton Balint <cus at passwd.hu>
---
 ffplay.c |   12 ++++++++++--
 1 files changed, 10 insertions(+), 2 deletions(-)

diff --git a/ffplay.c b/ffplay.c
index f81bd7c..f996b68 100644
--- a/ffplay.c
+++ b/ffplay.c
@@ -1586,7 +1586,7 @@ static int configure_video_filters(AVFilterGraph *graph, VideoState *is, const c
     char buffersrc_args[256];
     int ret;
     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_scale;
     AVCodecContext *codec = is->video_st->codec;
 
     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)
         return ret;
 
+    /* SDL YUV code is not handling odd width/height for some driver
+     * combinations, therefore we upscale the picture to an even width/height. */
+    if ((ret = avfilter_graph_create_filter(&filt_scale,
+                                            avfilter_get_by_name("scale"),
+                                            "ffplay_scale", "ceil(in_w/2)*2:ceil(in_h/2)*2", NULL, graph)) < 0)
+        return ret;
     if ((ret = avfilter_graph_create_filter(&filt_format,
                                             avfilter_get_by_name("format"),
                                             "format", "yuv420p", NULL, graph)) < 0)
         return ret;
+    if ((ret = avfilter_link(filt_scale, 0, filt_format, 0)) < 0)
+        return ret;
     if ((ret = avfilter_link(filt_format, 0, filt_out, 0)) < 0)
         return ret;
 
-    if ((ret = configure_filtergraph(graph, vfilters, filt_src, filt_format)) < 0)
+    if ((ret = configure_filtergraph(graph, vfilters, filt_src, filt_scale)) < 0)
         return ret;
 
     is->in_video_filter  = filt_src;
-- 
1.7.3.4



More information about the ffmpeg-devel mailing list