[FFmpeg-devel] [PATCH v1 1/2] lavc/vp9: set yuvj pixel format for full range decode

Thilo Borgmann thilo.borgmann at mail.de
Sat Jun 17 11:11:07 EEST 2023


While the yuvj pixel formats are deprecated lots of code still relies
on them to be set. Without setting a yuvj420p pixel format VP9
decoding ends up incorrectly due to auto conversion.

suggested-by: ffmpeg at meta.com
---
 libavcodec/vp9.c | 20 ++++++++++++++++++++
 1 file changed, 20 insertions(+)

diff --git a/libavcodec/vp9.c b/libavcodec/vp9.c
index 4f704ec0dd..e7be755fe6 100644
--- a/libavcodec/vp9.c
+++ b/libavcodec/vp9.c
@@ -202,6 +202,7 @@ static int update_size(AVCodecContext *avctx, int w, int h)
 
         switch (s->pix_fmt) {
         case AV_PIX_FMT_YUV420P:
+        case AV_PIX_FMT_YUVJ420P:
         case AV_PIX_FMT_YUV420P10:
 #if CONFIG_VP9_DXVA2_HWACCEL
             *fmtp++ = AV_PIX_FMT_DXVA2_VLD;
@@ -509,6 +510,25 @@ static int read_colorspace_details(AVCodecContext *avctx)
             s->ss_h = s->ss_v = 1;
             s->pix_fmt = pix_fmt_for_ss[bits][1][1];
         }
+
+        if (avctx->color_range == AVCOL_RANGE_JPEG) {
+            switch (s->pix_fmt) {
+                case AV_PIX_FMT_YUV444P:
+                    s->pix_fmt = AV_PIX_FMT_YUVJ444P;
+                    break;
+                case AV_PIX_FMT_YUV422P:
+                    s->pix_fmt = AV_PIX_FMT_YUVJ422P;
+                    break;
+                case AV_PIX_FMT_YUV440P:
+                    s->pix_fmt = AV_PIX_FMT_YUVJ440P;
+                    break;
+                case AV_PIX_FMT_YUV420P:
+                    s->pix_fmt = AV_PIX_FMT_YUVJ420P;
+                    break;
+                default:
+                    break;
+            }
+        }
     }
 
     return 0;
-- 
2.37.1 (Apple Git-137.1)



More information about the ffmpeg-devel mailing list