[FFmpeg-devel] [PATCH WIP 4/5] avcodec/hevc/sei: Add support for alpha channel information
James Almer
jamrial at gmail.com
Sat Dec 14 17:20:09 EET 2024
On 12/11/2024 1:23 AM, Zhao Zhili wrote:
> From: Zhao Zhili <zhilizhao at tencent.com>
>
> ---
> libavcodec/hevc/sei.c | 30 ++++++++++++++++++++++++++++++
> libavcodec/hevc/sei.h | 14 ++++++++++++++
> 2 files changed, 44 insertions(+)
>
> diff --git a/libavcodec/hevc/sei.c b/libavcodec/hevc/sei.c
> index e11a33773c..56983fe96e 100644
> --- a/libavcodec/hevc/sei.c
> +++ b/libavcodec/hevc/sei.c
> @@ -150,6 +150,34 @@ static int decode_nal_sei_timecode(HEVCSEITimeCode *s, GetBitContext *gb)
> return 0;
> }
>
> +static int decode_nal_sei_alpha_info(HEVCSEIAlphaChannelInfo *s, GetBitContext *gb)
> +{
> + int length;
> +
> + s->has_alpha_channel_info = true;
> +
> + s->alpha_channel_cancel_flag = get_bits1(gb);
> + if (!s->alpha_channel_cancel_flag) {
This should trigger when alpha_channel_cancel_flag is 1.
> + s->alpha_channel_use_idc = 2;
> + s->alpha_channel_incr_flag = 0;
> + s->alpha_channel_clip_flag = 0;
> +
> + return 0;
> + }
> +
> + s->alpha_channel_use_idc = get_bits(gb, 3);
> + s->alpha_channel_bit_depth_minus8 = get_bits(gb, 3);
> + length = s->alpha_channel_bit_depth_minus8 + 9;
> + s->alpha_transparent_value = get_bits(gb, length);
> + s->alpha_opaque_value = get_bits(gb, length);
> + s->alpha_channel_incr_flag = get_bits1(gb);
> + s->alpha_channel_clip_flag = get_bits1(gb);
> + if (s->alpha_channel_clip_flag)
> + s->alpha_channel_clip_type_flag = get_bits1(gb);
> +
> + return 0;
> +}
> +
> static int decode_nal_sei_3d_reference_displays_info(HEVCSEITDRDI *s, GetBitContext *gb)
> {
> s->prec_ref_display_width = get_ue_golomb(gb);
> @@ -216,6 +244,8 @@ static int decode_nal_sei_prefix(GetBitContext *gb, GetByteContext *gbyte,
> return decode_nal_sei_active_parameter_sets(s, gb, logctx);
> case SEI_TYPE_TIME_CODE:
> return decode_nal_sei_timecode(&s->timecode, gb);
> + case SEI_TYPE_ALPHA_CHANNEL_INFO:
> + return decode_nal_sei_alpha_info(&s->alpha, gb);
> case SEI_TYPE_THREE_DIMENSIONAL_REFERENCE_DISPLAYS_INFO:
> return decode_nal_sei_3d_reference_displays_info(&s->tdrdi, gb);
> default: {
> diff --git a/libavcodec/hevc/sei.h b/libavcodec/hevc/sei.h
> index ee640003bc..54122c27df 100644
> --- a/libavcodec/hevc/sei.h
> +++ b/libavcodec/hevc/sei.h
> @@ -21,6 +21,7 @@
> #ifndef AVCODEC_HEVC_SEI_H
> #define AVCODEC_HEVC_SEI_H
>
> +#include <stdbool.h>
Are we using bool anywhere else? Afaik, we just use uint8_t everywhere
since it's going to be a whole byte anyway.
> #include <stdint.h>
>
> #include "libavutil/buffer.h"
> @@ -95,6 +96,18 @@ typedef struct HEVCSEITDRDI {
> uint8_t three_dimensional_reference_displays_extension_flag;
> } HEVCSEITDRDI;
>
> +typedef struct HEVCSEIAlphaChannelInfo {
> + bool has_alpha_channel_info;
> + uint8_t alpha_channel_cancel_flag;
> + uint8_t alpha_channel_use_idc;
> + uint8_t alpha_channel_bit_depth_minus8;
> + uint16_t alpha_transparent_value;
> + uint16_t alpha_opaque_value;
> + uint8_t alpha_channel_incr_flag;
> + uint8_t alpha_channel_clip_flag;
> + uint8_t alpha_channel_clip_type_flag;
> +} HEVCSEIAlphaChannelInfo;
> +
> typedef struct HEVCSEI {
> H2645SEI common;
> HEVCSEIPictureHash picture_hash;
> @@ -102,6 +115,7 @@ typedef struct HEVCSEI {
> int active_seq_parameter_set_id;
> HEVCSEITimeCode timecode;
> HEVCSEITDRDI tdrdi;
> + HEVCSEIAlphaChannelInfo alpha;
> } HEVCSEI;
>
> struct HEVCParamSets;
-------------- next part --------------
A non-text attachment was scrubbed...
Name: OpenPGP_signature.asc
Type: application/pgp-signature
Size: 495 bytes
Desc: OpenPGP digital signature
URL: <https://ffmpeg.org/pipermail/ffmpeg-devel/attachments/20241214/45e0a244/attachment.sig>
More information about the ffmpeg-devel
mailing list