diff mbox series

[FFmpeg-devel,v2] lavc/aomdec: Allow RGB decoding

Message ID 20210604222207.89817-1-val.zapod.vz@gmail.com
State Superseded
Headers show
Series [FFmpeg-devel,v2] lavc/aomdec: Allow RGB decoding | expand

Checks

Context Check Description
andriy/x86_make success Make finished
andriy/x86_make_fate success Make fate finished
andriy/PPC64_make success Make finished
andriy/PPC64_make_fate success Make fate finished

Commit Message

Valerii Zapodovnikov June 4, 2021, 10:22 p.m. UTC
Yes, RGB is signalled by Identity matrix if and only if XYZ is not
in transfer. XYZ primaires are just normal primaries that can be
used for normal RGB, no problem, so I do not check for them.
No need to test for sRGB primaries (that is AVCOL_PRI_BT709), as
ffplay does not know what that is (is not color managed), but mpv
will do that automatically. This will also support other transfers
like DCI-P3 / DCI-D65 one, et cetera. See libvpxdec.c.
Also the default AV1 decoder is libdav1d, which is not affected.
For XYZ support someone should add correct pixel format in the code.
---
 libavcodec/libaomdec.c | 18 +++++++++++++++---
 1 file changed, 15 insertions(+), 3 deletions(-)

Comments

Valerii Zapodovnikov June 6, 2021, 5:03 a.m. UTC | #1
Forgot git commit -s, since it is more than 10 lines and not documentation
changes it should be required. Sorry, also I will not add Co-authored-by:
Carl <> since his patch was too flawed. Like really!? Oogh.
diff mbox series

Patch

diff --git a/libavcodec/libaomdec.c b/libavcodec/libaomdec.c
index 6e7324a832..156e644263 100644
--- a/libavcodec/libaomdec.c
+++ b/libavcodec/libaomdec.c
@@ -134,15 +134,27 @@  static int set_pix_fmt(AVCodecContext *avctx, struct aom_image *img)
     case AOM_IMG_FMT_I444:
     case AOM_IMG_FMT_I44416:
         if (img->bit_depth == 8) {
-            avctx->pix_fmt = AV_PIX_FMT_YUV444P;
+            if (avctx->colorspace == AVCOL_SPC_RGB && avctx->color_trc != AVCOL_TRC_SMPTE428) {
+                avctx->pix_fmt = AV_PIX_FMT_GBRP;
+            } else {
+                avctx->pix_fmt = AV_PIX_FMT_YUV444P;
+            }
             avctx->profile = FF_PROFILE_AV1_HIGH;
             return 0;
         } else if (img->bit_depth == 10) {
-            avctx->pix_fmt = AV_PIX_FMT_YUV444P10;
+            if (avctx->colorspace == AVCOL_SPC_RGB && avctx->color_trc != AVCOL_TRC_SMPTE428) {
+                avctx->pix_fmt = AV_PIX_FMT_GBRP10;
+            } else {
+                avctx->pix_fmt = AV_PIX_FMT_YUV444P10;
+            }
             avctx->profile = FF_PROFILE_AV1_HIGH;
             return 0;
         } else if (img->bit_depth == 12) {
-            avctx->pix_fmt = AV_PIX_FMT_YUV444P12;
+            if (avctx->colorspace == AVCOL_SPC_RGB && avctx->color_trc != AVCOL_TRC_SMPTE428) {
+                avctx->pix_fmt = AV_PIX_FMT_GBRP12;
+            } else {
+                avctx->pix_fmt = AV_PIX_FMT_YUV444P12;
+            }
             avctx->profile = FF_PROFILE_AV1_PROFESSIONAL;
             return 0;
         } else {