Commit d7705be9 authored by Vittorio Giovara's avatar Vittorio Giovara

mpegvideoenc: check color_range

Rework the comparison into something simpler to understand.
parent 27860819
...@@ -229,7 +229,7 @@ static void MPV_encode_defaults(MpegEncContext *s) ...@@ -229,7 +229,7 @@ static void MPV_encode_defaults(MpegEncContext *s)
av_cold int ff_MPV_encode_init(AVCodecContext *avctx) av_cold int ff_MPV_encode_init(AVCodecContext *avctx)
{ {
MpegEncContext *s = avctx->priv_data; MpegEncContext *s = avctx->priv_data;
int i, ret; int i, ret, format_supported;
MPV_encode_defaults(s); MPV_encode_defaults(s);
...@@ -243,11 +243,21 @@ av_cold int ff_MPV_encode_init(AVCodecContext *avctx) ...@@ -243,11 +243,21 @@ av_cold int ff_MPV_encode_init(AVCodecContext *avctx)
} }
break; break;
case AV_CODEC_ID_MJPEG: case AV_CODEC_ID_MJPEG:
if (avctx->pix_fmt != AV_PIX_FMT_YUVJ420P && format_supported = 0;
avctx->pix_fmt != AV_PIX_FMT_YUVJ422P && /* JPEG color space */
((avctx->pix_fmt != AV_PIX_FMT_YUV420P && if (avctx->pix_fmt == AV_PIX_FMT_YUVJ420P ||
avctx->pix_fmt != AV_PIX_FMT_YUV422P) || avctx->pix_fmt == AV_PIX_FMT_YUVJ422P ||
avctx->strict_std_compliance > FF_COMPLIANCE_UNOFFICIAL)) { (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"); av_log(avctx, AV_LOG_ERROR, "colorspace not supported in jpeg\n");
return -1; return -1;
} }
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment