vlc | branch: master | Zhao Zhili <[email protected]> | Tue Jul 17 
19:27:01 2018 +0800| [3b83d151cfbec2762c275f195cabc5c140632e19] | committer: 
Thomas Guillem

codec: avcodec: fix chroma compare

Due to d3c6ad0b, pictures may have different chroma. All frames are
dropped.

Signed-off-by: Thomas Guillem <[email protected]>

> http://git.videolan.org/gitweb.cgi/vlc.git/?a=commit;h=3b83d151cfbec2762c275f195cabc5c140632e19
---

 modules/codec/avcodec/video.c | 22 +++++++++++++++++++++-
 1 file changed, 21 insertions(+), 1 deletion(-)

diff --git a/modules/codec/avcodec/video.c b/modules/codec/avcodec/video.c
index 375b9d1b33..ba51a42961 100644
--- a/modules/codec/avcodec/video.c
+++ b/modules/codec/avcodec/video.c
@@ -369,6 +369,26 @@ static int lavc_UpdateVideoFormat(decoder_t *dec, 
AVCodecContext *ctx,
     return decoder_UpdateVideoFormat(dec);
 }
 
+static bool chroma_compatible(vlc_fourcc_t a, vlc_fourcc_t b)
+{
+    static const vlc_fourcc_t compat_lists[][2] = {
+        {VLC_CODEC_J420, VLC_CODEC_I420},
+        {VLC_CODEC_J422, VLC_CODEC_I422},
+        {VLC_CODEC_J440, VLC_CODEC_I440},
+        {VLC_CODEC_J444, VLC_CODEC_I444},
+    };
+
+    if (a == b)
+        return true;
+
+    for (size_t i = 0; i < ARRAY_SIZE(compat_lists); i++) {
+        if ((a == compat_lists[i][0] || a == compat_lists[i][1]) &&
+            (b == compat_lists[i][0] || b == compat_lists[i][1]))
+            return true;
+    }
+    return false;
+}
+
 /**
  * Copies a picture from the libavcodec-allocate buffer to a picture_t.
  * This is used when not in direct rendering mode.
@@ -385,7 +405,7 @@ static int lavc_CopyPicture(decoder_t *dec, picture_t *pic, 
AVFrame *frame)
         msg_Err(dec, "Unsupported decoded output format %d (%s)",
                 sys->p_context->pix_fmt, (name != NULL) ? name : "unknown");
         return VLC_EGENERIC;
-    } else if (fourcc != pic->format.i_chroma
+    } else if (!chroma_compatible(fourcc, pic->format.i_chroma)
      || frame->width > (int) pic->format.i_width
      || frame->height > (int) pic->format.i_height)
     {

_______________________________________________
vlc-commits mailing list
[email protected]
https://mailman.videolan.org/listinfo/vlc-commits

Reply via email to