[FFmpeg-devel] [PATCH] avcodec/cbs_h264: add support for the Content light level information SEI message

Limin Wang lance.lmwang at gmail.com
Tue Dec 24 03:11:42 EET 2019


On Thu, Nov 28, 2019 at 11:06:52PM -0300, James Almer wrote:

> Defined in ITU-T H.264 (06/2019)

LGTM

> 
> Signed-off-by: James Almer <jamrial at gmail.com>
> ---
> This is basically a copy paste of the H.265 implementation, both here and in
> the spec.
> 
>  libavcodec/cbs_h264.h                 |  6 ++++++
>  libavcodec/cbs_h2645.c                |  1 +
>  libavcodec/cbs_h264_syntax_template.c | 17 +++++++++++++++++
>  libavcodec/h264_sei.h                 |  1 +
>  4 files changed, 25 insertions(+)
> 
> diff --git a/libavcodec/cbs_h264.h b/libavcodec/cbs_h264.h
> index 9f7c2a0d30..f8e5b743be 100644
> --- a/libavcodec/cbs_h264.h
> +++ b/libavcodec/cbs_h264.h
> @@ -314,6 +314,11 @@ typedef struct H264RawSEIMasteringDisplayColourVolume {
>      uint32_t min_display_mastering_luminance;
>  } H264RawSEIMasteringDisplayColourVolume;
>  
> +typedef struct H264RawSEIContentLightLevelInfo {
> +    uint16_t max_content_light_level;
> +    uint16_t max_pic_average_light_level;
> +} H264RawSEIContentLightLevelInfo;
> +
>  typedef struct H264RawSEIAlternativeTransferCharacteristics {
>      uint8_t preferred_transfer_characteristics;
>  } H264RawSEIAlternativeTransferCharacteristics;
> @@ -331,6 +336,7 @@ typedef struct H264RawSEIPayload {
>          H264RawSEIRecoveryPoint recovery_point;
>          H264RawSEIDisplayOrientation display_orientation;
>          H264RawSEIMasteringDisplayColourVolume mastering_display_colour_volume;
> +        H264RawSEIContentLightLevelInfo content_light_level;
>          H264RawSEIAlternativeTransferCharacteristics
>              alternative_transfer_characteristics;
>          struct {
> diff --git a/libavcodec/cbs_h2645.c b/libavcodec/cbs_h2645.c
> index 88fa0029cd..0944585fa8 100644
> --- a/libavcodec/cbs_h2645.c
> +++ b/libavcodec/cbs_h2645.c
> @@ -458,6 +458,7 @@ static void cbs_h264_free_sei_payload(H264RawSEIPayload *payload)
>      case H264_SEI_TYPE_PAN_SCAN_RECT:
>      case H264_SEI_TYPE_RECOVERY_POINT:
>      case H264_SEI_TYPE_DISPLAY_ORIENTATION:
> +    case H264_SEI_TYPE_CONTENT_LIGHT_LEVEL_INFO:
>      case H264_SEI_TYPE_MASTERING_DISPLAY_COLOUR_VOLUME:
>      case H264_SEI_TYPE_ALTERNATIVE_TRANSFER:
>          break;
> diff --git a/libavcodec/cbs_h264_syntax_template.c b/libavcodec/cbs_h264_syntax_template.c
> index 1671a15d33..62b40dfb42 100644
> --- a/libavcodec/cbs_h264_syntax_template.c
> +++ b/libavcodec/cbs_h264_syntax_template.c
> @@ -819,6 +819,19 @@ static int FUNC(sei_mastering_display_colour_volume)(CodedBitstreamContext *ctx,
>      return 0;
>  }
>  
> +static int FUNC(sei_content_light_level)(CodedBitstreamContext *ctx, RWContext *rw,
> +                                         H264RawSEIContentLightLevelInfo *current)
> +{
> +    int err;
> +
> +    HEADER("Content Light Level");
> +
> +    ub(16, max_content_light_level);
> +    ub(16, max_pic_average_light_level);
> +
> +    return 0;
> +}
> +
>  static int FUNC(sei_alternative_transfer_characteristics)(CodedBitstreamContext *ctx,
>                                                            RWContext *rw,
>                                                            H264RawSEIAlternativeTransferCharacteristics *current)
> @@ -883,6 +896,10 @@ static int FUNC(sei_payload)(CodedBitstreamContext *ctx, RWContext *rw,
>          CHECK(FUNC(sei_mastering_display_colour_volume)
>                (ctx, rw, &current->payload.mastering_display_colour_volume));
>          break;
> +    case H264_SEI_TYPE_CONTENT_LIGHT_LEVEL_INFO:
> +        CHECK(FUNC(sei_content_light_level)
> +              (ctx, rw, &current->payload.content_light_level));
> +        break;
>      case H264_SEI_TYPE_ALTERNATIVE_TRANSFER:
>          CHECK(FUNC(sei_alternative_transfer_characteristics)
>                (ctx, rw, &current->payload.alternative_transfer_characteristics));
> diff --git a/libavcodec/h264_sei.h b/libavcodec/h264_sei.h
> index a75c3aa175..ffd3948c5b 100644
> --- a/libavcodec/h264_sei.h
> +++ b/libavcodec/h264_sei.h
> @@ -36,6 +36,7 @@ typedef enum {
>      H264_SEI_TYPE_DISPLAY_ORIENTATION    = 47,  ///< display orientation
>      H264_SEI_TYPE_GREEN_METADATA         = 56,  ///< GreenMPEG information
>      H264_SEI_TYPE_MASTERING_DISPLAY_COLOUR_VOLUME = 137,  ///< mastering display properties
> +    H264_SEI_TYPE_CONTENT_LIGHT_LEVEL_INFO = 144,  ///< content light level information
>      H264_SEI_TYPE_ALTERNATIVE_TRANSFER   = 147, ///< alternative transfer
>  } H264_SEI_Type;
>  
> -- 
> 2.24.0
> 
> _______________________________________________
> ffmpeg-devel mailing list
> ffmpeg-devel at ffmpeg.org
> https://ffmpeg.org/mailman/listinfo/ffmpeg-devel
> 
> To unsubscribe, visit link above, or email
> ffmpeg-devel-request at ffmpeg.org with subject "unsubscribe".


More information about the ffmpeg-devel mailing list