avcodec/h264: be more tolerant on what pixel format changes trigger reinits
authorMichael Niedermayer <michaelni@gmx.at>
Mon, 17 Mar 2014 01:25:20 +0000 (02:25 +0100)
committerMichael Niedermayer <michaelni@gmx.at>
Mon, 17 Mar 2014 01:37:29 +0000 (02:37 +0100)
Fixes Ticket3260

Signed-off-by: Michael Niedermayer <michaelni@gmx.at>
libavcodec/h264.c

index 9379b2f..ec3601f 100644 (file)
@@ -3444,6 +3444,17 @@ int ff_set_ref_count(H264Context *h)
     return 0;
 }
 
+static enum AVPixelFormat non_j_pixfmt(enum AVPixelFormat a)
+{
+    switch (a) {
+    case AV_PIX_FMT_YUVJ420P: return AV_PIX_FMT_YUV420P;
+    case AV_PIX_FMT_YUVJ422P: return AV_PIX_FMT_YUV422P;
+    case AV_PIX_FMT_YUVJ444P: return AV_PIX_FMT_YUV444P;
+    default:
+        return a;
+    }
+}
+
 /**
  * Decode a slice header.
  * This will (re)intialize the decoder and call h264_frame_start() as needed.
@@ -3573,7 +3584,7 @@ static int decode_slice_header(H264Context *h, H264Context *h0)
                      || h->mb_width  != h->sps.mb_width
                      || h->mb_height != h->sps.mb_height * (2 - h->sps.frame_mbs_only_flag)
                     ));
-    if (h0->avctx->pix_fmt != get_pixel_format(h0, 0))
+    if (non_j_pixfmt(h0->avctx->pix_fmt) != non_j_pixfmt(get_pixel_format(h0, 0)))
         must_reinit = 1;
 
     h->mb_width  = h->sps.mb_width;