[FFmpeg-cvslog] mpegvideoenc: check color_range

Vittorio Giovara git at videolan.org
Wed Jun 11 03:09:03 CEST 2014


ffmpeg | branch: master | Vittorio Giovara <vittorio.giovara at gmail.com> | Fri May 23 12:39:51 2014 -0400| [d7705be9617ed691c7a2924a2088de2d96f38af1] | committer: Vittorio Giovara

mpegvideoenc: check color_range

Rework the comparison into something simpler to understand.

> http://git.videolan.org/gitweb.cgi/ffmpeg.git/?a=commit;h=d7705be9617ed691c7a2924a2088de2d96f38af1
---

 libavcodec/mpegvideo_enc.c |   22 ++++++++++++++++------
 1 file changed, 16 insertions(+), 6 deletions(-)

diff --git a/libavcodec/mpegvideo_enc.c b/libavcodec/mpegvideo_enc.c
index 3550fde..28ab272 100644
--- a/libavcodec/mpegvideo_enc.c
+++ b/libavcodec/mpegvideo_enc.c
@@ -229,7 +229,7 @@ static void MPV_encode_defaults(MpegEncContext *s)
 av_cold int ff_MPV_encode_init(AVCodecContext *avctx)
 {
     MpegEncContext *s = avctx->priv_data;
-    int i, ret;
+    int i, ret, format_supported;
 
     MPV_encode_defaults(s);
 
@@ -243,11 +243,21 @@ av_cold int ff_MPV_encode_init(AVCodecContext *avctx)
         }
         break;
     case AV_CODEC_ID_MJPEG:
-        if (avctx->pix_fmt != AV_PIX_FMT_YUVJ420P &&
-            avctx->pix_fmt != AV_PIX_FMT_YUVJ422P &&
-            ((avctx->pix_fmt != AV_PIX_FMT_YUV420P &&
-              avctx->pix_fmt != AV_PIX_FMT_YUV422P) ||
-             avctx->strict_std_compliance > FF_COMPLIANCE_UNOFFICIAL)) {
+        format_supported = 0;
+        /* JPEG color space */
+        if (avctx->pix_fmt == AV_PIX_FMT_YUVJ420P ||
+            avctx->pix_fmt == AV_PIX_FMT_YUVJ422P ||
+            (avctx->color_range == AVCOL_RANGE_JPEG &&
+             (avctx->pix_fmt == AV_PIX_FMT_YUV420P ||
+              avctx->pix_fmt == AV_PIX_FMT_YUV422P)))
+            format_supported = 1;
+        /* MPEG color space */
+        else if (avctx->strict_std_compliance <= FF_COMPLIANCE_UNOFFICIAL &&
+                 (avctx->pix_fmt == AV_PIX_FMT_YUV420P ||
+                  avctx->pix_fmt == AV_PIX_FMT_YUV422P))
+            format_supported = 1;
+
+        if (!format_supported) {
             av_log(avctx, AV_LOG_ERROR, "colorspace not supported in jpeg\n");
             return -1;
         }



More information about the ffmpeg-cvslog mailing list