[FFmpeg-devel,11/24] avcodec/mjpegdec: replace YUVJ pixel formats

Submitted by Paul B Mahol on May 1, 2018, 7:40 p.m.

Details

Message ID 20180501194013.9552-11-onemda@gmail.com
State New
Headers show

Commit Message

Paul B Mahol May 1, 2018, 7:40 p.m.
Signed-off-by: Paul B Mahol <onemda@gmail.com>
---
 libavcodec/mjpegdec.c                | 18 +++++++++---------
 libavcodec/tdsc.c                    |  2 +-
 tests/fate/vcodec.mak                |  4 ++--
 tests/ref/fate/api-mjpeg-codec-param |  4 ++--
 tests/ref/fate/exif-image-embedded   |  2 +-
 tests/ref/fate/exif-image-jpg        |  2 +-
 6 files changed, 16 insertions(+), 16 deletions(-)

Comments

Michael Niedermayer May 2, 2018, 12:27 a.m.
On Tue, May 01, 2018 at 09:40:00PM +0200, Paul B Mahol wrote:
> Signed-off-by: Paul B Mahol <onemda@gmail.com>
> ---
>  libavcodec/mjpegdec.c                | 18 +++++++++---------
>  libavcodec/tdsc.c                    |  2 +-
>  tests/fate/vcodec.mak                |  4 ++--
>  tests/ref/fate/api-mjpeg-codec-param |  4 ++--
>  tests/ref/fate/exif-image-embedded   |  2 +-
>  tests/ref/fate/exif-image-jpg        |  2 +-
>  6 files changed, 16 insertions(+), 16 deletions(-)

the colors for the following look different between input and output after
this patch

./ffmpeg -i ~/tickets/3949/680.jpg -an -vcodec utvideo -t 1 -pix_fmt yuv420p out.avi

[...]

Patch hide | download patch | download mbox

diff --git a/libavcodec/mjpegdec.c b/libavcodec/mjpegdec.c
index 22ca69f841..656cf44bbb 100644
--- a/libavcodec/mjpegdec.c
+++ b/libavcodec/mjpegdec.c
@@ -479,7 +479,7 @@  int ff_mjpeg_decode_sof(MJpegDecodeContext *s)
             if (s->component_id[0] == 'Q' && s->component_id[1] == 'F' && s->component_id[2] == 'A') {
                 s->avctx->pix_fmt = s->bits <= 8 ? AV_PIX_FMT_GBRP : AV_PIX_FMT_GBRP16;
             } else {
-                if (s->bits <= 8) s->avctx->pix_fmt = s->cs_itu601 ? AV_PIX_FMT_YUV444P : AV_PIX_FMT_YUVJ444P;
+                if (s->bits <= 8) s->avctx->pix_fmt = AV_PIX_FMT_YUV444P;
                 else              s->avctx->pix_fmt = AV_PIX_FMT_YUV444P16;
             s->avctx->color_range = s->cs_itu601 ? AVCOL_RANGE_MPEG : AVCOL_RANGE_JPEG;
             }
@@ -521,7 +521,7 @@  int ff_mjpeg_decode_sof(MJpegDecodeContext *s)
     case 0x22122100:
     case 0x21211100:
     case 0x22211200:
-        if (s->bits <= 8) s->avctx->pix_fmt = s->cs_itu601 ? AV_PIX_FMT_YUV444P : AV_PIX_FMT_YUVJ444P;
+        if (s->bits <= 8) s->avctx->pix_fmt = AV_PIX_FMT_YUV444P;
         else
             goto unk_pixfmt;
         s->avctx->color_range = s->cs_itu601 ? AVCOL_RANGE_MPEG : AVCOL_RANGE_JPEG;
@@ -529,7 +529,7 @@  int ff_mjpeg_decode_sof(MJpegDecodeContext *s)
     case 0x22221100:
     case 0x22112200:
     case 0x11222200:
-        if (s->bits <= 8) s->avctx->pix_fmt = s->cs_itu601 ? AV_PIX_FMT_YUV444P : AV_PIX_FMT_YUVJ444P;
+        if (s->bits <= 8) s->avctx->pix_fmt = AV_PIX_FMT_YUV444P;
         else
             goto unk_pixfmt;
         s->avctx->color_range = s->cs_itu601 ? AVCOL_RANGE_MPEG : AVCOL_RANGE_JPEG;
@@ -561,7 +561,7 @@  int ff_mjpeg_decode_sof(MJpegDecodeContext *s)
         } else {
             if (pix_fmt_id == 0x14111100)
                 s->upscale_v[1] = s->upscale_v[2] = 1;
-            if (s->bits <= 8) s->avctx->pix_fmt = s->cs_itu601 ? AV_PIX_FMT_YUV440P : AV_PIX_FMT_YUVJ440P;
+            if (s->bits <= 8) s->avctx->pix_fmt = AV_PIX_FMT_YUV440P;
             else
                 goto unk_pixfmt;
             s->avctx->color_range = s->cs_itu601 ? AVCOL_RANGE_MPEG : AVCOL_RANGE_JPEG;
@@ -574,7 +574,7 @@  int ff_mjpeg_decode_sof(MJpegDecodeContext *s)
                 goto unk_pixfmt;
             s->upscale_h[0] = s->upscale_h[1] = 1;
         } else {
-            if (s->bits <= 8) s->avctx->pix_fmt = s->cs_itu601 ? AV_PIX_FMT_YUV422P : AV_PIX_FMT_YUVJ422P;
+            if (s->bits <= 8) s->avctx->pix_fmt = AV_PIX_FMT_YUV422P;
             else              s->avctx->pix_fmt = AV_PIX_FMT_YUV422P16;
             s->avctx->color_range = s->cs_itu601 ? AVCOL_RANGE_MPEG : AVCOL_RANGE_JPEG;
         }
@@ -582,13 +582,13 @@  int ff_mjpeg_decode_sof(MJpegDecodeContext *s)
     case 0x31111100:
         if (s->bits > 8)
             goto unk_pixfmt;
-        s->avctx->pix_fmt = s->cs_itu601 ? AV_PIX_FMT_YUV444P : AV_PIX_FMT_YUVJ444P;
+        s->avctx->pix_fmt = AV_PIX_FMT_YUV444P;
         s->avctx->color_range = s->cs_itu601 ? AVCOL_RANGE_MPEG : AVCOL_RANGE_JPEG;
         s->upscale_h[1] = s->upscale_h[2] = 2;
         break;
     case 0x22121100:
     case 0x22111200:
-        if (s->bits <= 8) s->avctx->pix_fmt = s->cs_itu601 ? AV_PIX_FMT_YUV422P : AV_PIX_FMT_YUVJ422P;
+        if (s->bits <= 8) s->avctx->pix_fmt = AV_PIX_FMT_YUV422P;
         else
             goto unk_pixfmt;
         s->avctx->color_range = s->cs_itu601 ? AVCOL_RANGE_MPEG : AVCOL_RANGE_JPEG;
@@ -596,7 +596,7 @@  int ff_mjpeg_decode_sof(MJpegDecodeContext *s)
     case 0x22111100:
     case 0x42111100:
     case 0x24111100:
-        if (s->bits <= 8) s->avctx->pix_fmt = s->cs_itu601 ? AV_PIX_FMT_YUV420P : AV_PIX_FMT_YUVJ420P;
+        if (s->bits <= 8) s->avctx->pix_fmt = AV_PIX_FMT_YUV420P;
         else              s->avctx->pix_fmt = AV_PIX_FMT_YUV420P16;
         s->avctx->color_range = s->cs_itu601 ? AVCOL_RANGE_MPEG : AVCOL_RANGE_JPEG;
         if (pix_fmt_id == 0x42111100) {
@@ -610,7 +610,7 @@  int ff_mjpeg_decode_sof(MJpegDecodeContext *s)
         }
         break;
     case 0x41111100:
-        if (s->bits <= 8) s->avctx->pix_fmt = s->cs_itu601 ? AV_PIX_FMT_YUV411P : AV_PIX_FMT_YUVJ411P;
+        if (s->bits <= 8) s->avctx->pix_fmt = AV_PIX_FMT_YUV411P;
         else
             goto unk_pixfmt;
         s->avctx->color_range = s->cs_itu601 ? AVCOL_RANGE_MPEG : AVCOL_RANGE_JPEG;
diff --git a/libavcodec/tdsc.c b/libavcodec/tdsc.c
index 4182404cf0..af92ef6ccc 100644
--- a/libavcodec/tdsc.c
+++ b/libavcodec/tdsc.c
@@ -357,7 +357,7 @@  static int tdsc_decode_jpeg_tile(AVCodecContext *avctx, int tile_size,
     }
 
     ret = avcodec_receive_frame(ctx->jpeg_avctx, ctx->jpgframe);
-    if (ret < 0 || ctx->jpgframe->format != AV_PIX_FMT_YUVJ420P) {
+    if (ret < 0 || ctx->jpgframe->format != AV_PIX_FMT_YUV420P) {
         av_log(avctx, AV_LOG_ERROR,
                "JPEG decoding error (%d).\n", ret);
 
diff --git a/tests/fate/vcodec.mak b/tests/fate/vcodec.mak
index bbcf25d72a..72fc46e83b 100644
--- a/tests/fate/vcodec.mak
+++ b/tests/fate/vcodec.mak
@@ -4,8 +4,8 @@  fate-vsynth_lena-%: SRC = tests/data/vsynth_lena.yuv
 fate-vsynth3-%: SRC = tests/data/vsynth3.yuv
 fate-vsynth%: CODEC = $(word 3, $(subst -, ,$(@)))
 fate-vsynth%: FMT = avi
-fate-vsynth%: CMD = enc_dec "rawvideo -s 352x288 -pix_fmt yuv420p $(RAWDECOPTS)" $(SRC) $(FMT) "-c $(CODEC) $(ENCOPTS)" rawvideo "-s 352x288 -pix_fmt yuv420p -vsync 0 $(DECOPTS)" -keep "$(DECINOPTS)"
-fate-vsynth3-%: CMD = enc_dec "rawvideo -s $(FATEW)x$(FATEH) -pix_fmt yuv420p $(RAWDECOPTS)" $(SRC) $(FMT) "-c $(CODEC) $(ENCOPTS)" rawvideo "-s $(FATEW)x$(FATEH) -pix_fmt yuv420p -vsync 0 $(DECOPTS)" -keep "$(DECINOPTS)"
+fate-vsynth%: CMD = enc_dec "rawvideo -s 352x288 -color_range tv -pix_fmt yuv420p $(RAWDECOPTS)" $(SRC) $(FMT) "-c $(CODEC) $(ENCOPTS)" rawvideo "-s 352x288 -pix_fmt yuv420p -color_range tv -vsync 0 $(DECOPTS)" -keep "$(DECINOPTS)"
+fate-vsynth3-%: CMD = enc_dec "rawvideo -s $(FATEW)x$(FATEH) -color_range tv -pix_fmt yuv420p $(RAWDECOPTS)" $(SRC) $(FMT) "-c $(CODEC) $(ENCOPTS)" rawvideo "-s $(FATEW)x$(FATEH) -pix_fmt yuv420p -color_range tv -vsync 0 $(DECOPTS)" -keep "$(DECINOPTS)"
 fate-vsynth%: CMP_UNIT = 1
 fate-vsynth%: REF = $(SRC_PATH)/tests/ref/vsynth/$(@:fate-%=%)
 
diff --git a/tests/ref/fate/api-mjpeg-codec-param b/tests/ref/fate/api-mjpeg-codec-param
index 290f941ff3..26f971d1cb 100644
--- a/tests/ref/fate/api-mjpeg-codec-param
+++ b/tests/ref/fate/api-mjpeg-codec-param
@@ -133,7 +133,7 @@  stream=0, decode=0
     field_order=0
     dump_separator=
     codec_whitelist=
-    pixel_format=yuvj422p
+    pixel_format=yuv422p
     video_size=400x225
     max_pixels=2147483647
     hwaccel_flags=0x00000001
@@ -273,7 +273,7 @@  stream=0, decode=1
     field_order=0
     dump_separator=
     codec_whitelist=
-    pixel_format=yuvj422p
+    pixel_format=yuv422p
     video_size=400x225
     max_pixels=2147483647
     hwaccel_flags=0x00000001
diff --git a/tests/ref/fate/exif-image-embedded b/tests/ref/fate/exif-image-embedded
index 392c145efb..4a5e10eba3 100644
--- a/tests/ref/fate/exif-image-embedded
+++ b/tests/ref/fate/exif-image-embedded
@@ -14,7 +14,7 @@  pkt_pos=N/A
 pkt_size=15760
 width=263
 height=263
-pix_fmt=yuvj420p
+pix_fmt=yuv420p
 sample_aspect_ratio=1:1
 pict_type=I
 coded_picture_number=0
diff --git a/tests/ref/fate/exif-image-jpg b/tests/ref/fate/exif-image-jpg
index eb18dede21..d55465e119 100644
--- a/tests/ref/fate/exif-image-jpg
+++ b/tests/ref/fate/exif-image-jpg
@@ -14,7 +14,7 @@  pkt_pos=N/A
 pkt_size=46095
 width=400
 height=225
-pix_fmt=yuvj422p
+pix_fmt=yuv422p
 sample_aspect_ratio=1:1
 pict_type=I
 coded_picture_number=0