diff options
author | Limin Wang <lance.lmwang@gmail.com> | 2022-01-14 13:53:19 +0800 |
---|---|---|
committer | Limin Wang <lance.lmwang@gmail.com> | 2022-01-14 22:00:19 +0800 |
commit | 008cc90d1a5fa85bb1b07c6d789be13b184d4d2a (patch) | |
tree | 1fa3928c25020af18cc1f01c38240058800858cb /libavcodec/libopenh264enc.c | |
parent | b57656e28bace8835208fec938ff82a85671941e (diff) | |
download | ffmpeg-008cc90d1a5fa85bb1b07c6d789be13b184d4d2a.tar.gz |
avcodec/libopenh264enc: support for colorspace and range information
Reviewed-by: Martin Storsjö <martin@martin.st>
Signed-off-by: Limin Wang <lance.lmwang@gmail.com>
Diffstat (limited to 'libavcodec/libopenh264enc.c')
-rw-r--r-- | libavcodec/libopenh264enc.c | 22 |
1 files changed, 22 insertions, 0 deletions
diff --git a/libavcodec/libopenh264enc.c b/libavcodec/libopenh264enc.c index de4b85c411..5b5914c2cf 100644 --- a/libavcodec/libopenh264enc.c +++ b/libavcodec/libopenh264enc.c @@ -330,6 +330,28 @@ static av_cold int svc_encode_init(AVCodecContext *avctx) } } +#if OPENH264_VER_AT_LEAST(1, 6) + param.sSpatialLayers[0].uiVideoFormat = VF_UNDEF; + if (avctx->color_range != AVCOL_RANGE_UNSPECIFIED) { + param.sSpatialLayers[0].bVideoSignalTypePresent = true; + param.sSpatialLayers[0].bFullRange = (avctx->color_range == AVCOL_RANGE_JPEG); + } + + if (avctx->colorspace != AVCOL_SPC_UNSPECIFIED || + avctx->color_primaries != AVCOL_PRI_UNSPECIFIED || + avctx->color_trc != AVCOL_TRC_UNSPECIFIED) { + param.sSpatialLayers[0].bVideoSignalTypePresent = true; + param.sSpatialLayers[0].bColorDescriptionPresent = true; + } + + if (avctx->colorspace != AVCOL_SPC_UNSPECIFIED) + param.sSpatialLayers[0].uiColorMatrix = avctx->colorspace; + if (avctx->color_primaries != AVCOL_PRI_UNSPECIFIED) + param.sSpatialLayers[0].uiColorPrimaries = avctx->color_primaries; + if (avctx->color_trc != AVCOL_TRC_UNSPECIFIED) + param.sSpatialLayers[0].uiTransferCharacteristics = avctx->color_trc; +#endif + if ((*s->encoder)->InitializeExt(s->encoder, ¶m) != cmResultSuccess) { av_log(avctx, AV_LOG_ERROR, "Initialize failed\n"); return AVERROR_UNKNOWN; |