[FFmpeg-cvslog] hevc: Add support for alternative transfer characterics SEI
Vittorio Giovara
git at videolan.org
Tue Nov 7 21:33:27 EET 2017
ffmpeg | branch: master | Vittorio Giovara <vittorio.giovara at gmail.com> | Fri Jun 9 17:27:22 2017 -0400| [969f215957b25ec014aeed6e440ecb450e6927c1] | committer: Vittorio Giovara
hevc: Add support for alternative transfer characterics SEI
The use of this SEI is for backward compatibility in HLG HDR systems:
older devices that cannot interpret the "arib-std-b67" transfer will
get the compatible transfer (usually bt709 or bt2020) from the VUI,
while newer devices that can interpret HDR will read the SEI and use
its value instead.
Signed-off-by: Vittorio Giovara <vittorio.giovara at gmail.com>
> http://git.videolan.org/gitweb.cgi/ffmpeg.git/?a=commit;h=969f215957b25ec014aeed6e440ecb450e6927c1
---
libavcodec/hevc_sei.c | 9 +++++++++
libavcodec/hevc_sei.h | 7 +++++++
libavcodec/hevcdec.c | 6 ++++++
3 files changed, 22 insertions(+)
diff --git a/libavcodec/hevc_sei.c b/libavcodec/hevc_sei.c
index 153d211b4b..0a5d4440bf 100644
--- a/libavcodec/hevc_sei.c
+++ b/libavcodec/hevc_sei.c
@@ -86,6 +86,13 @@ static int decode_nal_sei_display_orientation(HEVCSEIDisplayOrientation *s, GetB
return 0;
}
+static int decode_nal_sei_alternative_transfer(HEVCSEIAlternativeTransfer *s, GetBitContext *gb)
+{
+ s->present = 1;
+ s->preferred_transfer_characteristics = get_bits(gb, 8);
+ return 0;
+}
+
static int decode_nal_sei_prefix(GetBitContext *gb, void *logctx, HEVCSEI *s,
int type, int size)
{
@@ -96,6 +103,8 @@ static int decode_nal_sei_prefix(GetBitContext *gb, void *logctx, HEVCSEI *s,
return decode_nal_sei_frame_packing_arrangement(&s->frame_packing, gb);
case HEVC_SEI_TYPE_DISPLAY_ORIENTATION:
return decode_nal_sei_display_orientation(&s->display_orientation, gb);
+ case HEVC_SEI_TYPE_ALTERNATIVE_TRANSFER_CHARACTERISTICS:
+ return decode_nal_sei_alternative_transfer(&s->alternative_transfer, gb);
default:
av_log(logctx, AV_LOG_DEBUG, "Skipped PREFIX SEI %d\n", type);
skip_bits_long(gb, 8 * size);
diff --git a/libavcodec/hevc_sei.h b/libavcodec/hevc_sei.h
index b699fef45d..e4aeac1fbe 100644
--- a/libavcodec/hevc_sei.h
+++ b/libavcodec/hevc_sei.h
@@ -54,6 +54,7 @@ typedef enum {
HEVC_SEI_TYPE_REGION_REFRESH_INFO = 134,
HEVC_SEI_TYPE_MASTERING_DISPLAY_INFO = 137,
HEVC_SEI_TYPE_CONTENT_LIGHT_LEVEL_INFO = 144,
+ HEVC_SEI_TYPE_ALTERNATIVE_TRANSFER_CHARACTERISTICS = 147,
} HEVC_SEI_Type;
typedef struct HEVCSEIPictureHash {
@@ -74,10 +75,16 @@ typedef struct HEVCSEIDisplayOrientation {
int hflip, vflip;
} HEVCSEIDisplayOrientation;
+typedef struct HEVCSEIAlternativeTransfer {
+ int present;
+ int preferred_transfer_characteristics;
+} HEVCSEIAlternativeTransfer;
+
typedef struct HEVCSEI {
HEVCSEIPictureHash picture_hash;
HEVCSEIFramePacking frame_packing;
HEVCSEIDisplayOrientation display_orientation;
+ HEVCSEIAlternativeTransfer alternative_transfer;
} HEVCSEI;
int ff_hevc_decode_nal_sei(GetBitContext *gb, void *logctx, HEVCSEI *s,
diff --git a/libavcodec/hevcdec.c b/libavcodec/hevcdec.c
index 7a9182af9b..ac0b1a3c1d 100644
--- a/libavcodec/hevcdec.c
+++ b/libavcodec/hevcdec.c
@@ -2407,6 +2407,12 @@ static int set_side_data(HEVCContext *s)
s->sei.display_orientation.vflip);
}
+ if (s->sei.alternative_transfer.present &&
+ av_color_transfer_name(s->sei.alternative_transfer.preferred_transfer_characteristics) &&
+ s->sei.alternative_transfer.preferred_transfer_characteristics != AVCOL_TRC_UNSPECIFIED) {
+ s->avctx->color_trc = s->sei.alternative_transfer.preferred_transfer_characteristics;
+ }
+
return 0;
}
More information about the ffmpeg-cvslog
mailing list