[vlc-commits] codec: vpx: do proper color mapping
Francois Cartegnie
git at videolan.org
Wed Aug 8 17:36:11 CEST 2018
vlc | branch: master | Francois Cartegnie <fcvlcdev at free.fr> | Wed Aug 8 17:26:32 2018 +0200| [bd8c94a42109a25588a86313f66cb00ff2209ed0] | committer: Francois Cartegnie
codec: vpx: do proper color mapping
> http://git.videolan.org/gitweb.cgi/vlc.git/?a=commit;h=bd8c94a42109a25588a86313f66cb00ff2209ed0
---
modules/codec/vpx.c | 59 ++++++++++++++++++++++++++++++++++++++---------------
1 file changed, 42 insertions(+), 17 deletions(-)
diff --git a/modules/codec/vpx.c b/modules/codec/vpx.c
index 0d0eae0538..7c111e66d0 100644
--- a/modules/codec/vpx.c
+++ b/modules/codec/vpx.c
@@ -33,6 +33,7 @@
#include <vpx/vpx_decoder.h>
#include <vpx/vp8dx.h>
+#include <vpx/vpx_image.h>
#ifdef ENABLE_SOUT
# include <vpx/vpx_encoder.h>
@@ -143,6 +144,41 @@ static const struct
{ VLC_CODEC_I444_16L, VPX_IMG_FMT_I44416, 16, 0 },
};
+struct video_color
+{
+ video_color_primaries_t primaries;
+ video_transfer_func_t transfer;
+ video_color_space_t space;
+};
+
+const struct video_color vpx_color_mapping_table[] =
+{
+ [VPX_CS_UNKNOWN] = { COLOR_PRIMARIES_UNDEF,
+ TRANSFER_FUNC_UNDEF,
+ COLOR_SPACE_UNDEF },
+ [VPX_CS_BT_601] = { COLOR_PRIMARIES_BT601_525,
+ TRANSFER_FUNC_BT709,
+ COLOR_SPACE_BT601 },
+ [VPX_CS_BT_709] = { COLOR_PRIMARIES_BT709,
+ TRANSFER_FUNC_BT709,
+ COLOR_SPACE_BT709 },
+ [VPX_CS_SMPTE_170] = { COLOR_PRIMARIES_SMTPE_170,
+ TRANSFER_FUNC_BT709,
+ COLOR_SPACE_BT601 },
+ [VPX_CS_SMPTE_240] = { COLOR_PRIMARIES_SMTPE_240,
+ TRANSFER_FUNC_SMPTE_240,
+ COLOR_SPACE_UNDEF },
+ [VPX_CS_BT_2020] = { COLOR_PRIMARIES_BT2020,
+ TRANSFER_FUNC_BT2020,
+ COLOR_SPACE_BT2020 },
+ [VPX_CS_RESERVED] = { COLOR_PRIMARIES_UNDEF,
+ TRANSFER_FUNC_UNDEF,
+ COLOR_SPACE_UNDEF },
+ [VPX_CS_SRGB] = { COLOR_PRIMARIES_SRGB,
+ TRANSFER_FUNC_SRGB,
+ COLOR_SPACE_UNDEF },
+};
+
static vlc_fourcc_t FindVlcChroma( struct vpx_image *img )
{
uint8_t hack = (img->fmt & VPX_IMG_FMT_I444) && (img->cs == VPX_CS_SRGB);
@@ -227,24 +263,13 @@ static int Decode(decoder_t *dec, block_t *block)
dec->fmt_out.video.i_sar_den = 1;
}
- v->b_color_range_full = img->range == VPX_CR_FULL_RANGE;
-
- switch( img->cs )
+ if(dec->fmt_in.video.primaries == COLOR_PRIMARIES_UNDEF &&
+ img->cs >= 0 && img->cs < ARRAY_SIZE(vpx_color_mapping_table))
{
- case VPX_CS_SRGB:
- case VPX_CS_BT_709:
- v->space = COLOR_SPACE_BT709;
- break;
- case VPX_CS_BT_601:
- case VPX_CS_SMPTE_170:
- case VPX_CS_SMPTE_240:
- v->space = COLOR_SPACE_BT601;
- break;
- case VPX_CS_BT_2020:
- v->space = COLOR_SPACE_BT2020;
- break;
- default:
- break;
+ v->primaries = vpx_color_mapping_table[img->cs].primaries;
+ v->transfer = vpx_color_mapping_table[img->cs].transfer;
+ v->space = vpx_color_mapping_table[img->cs].space;
+ v->b_color_range_full = img->range == VPX_CR_FULL_RANGE;
}
dec->fmt_out.video.projection_mode = dec->fmt_in.video.projection_mode;
More information about the vlc-commits
mailing list