[FFmpeg-devel] [PATCH v3 06/11] avcodec/cbs_h2645: reface, move zero bytes check to a function

Mark Thompson sw at jkqxz.net
Mon Jan 11 23:38:18 EET 2021


On 11/01/2021 16:33, Nuo Mi wrote:
> ---
>   libavcodec/cbs_h2645.c | 23 +++++++++++++++--------
>   1 file changed, 15 insertions(+), 8 deletions(-)
> 
> diff --git a/libavcodec/cbs_h2645.c b/libavcodec/cbs_h2645.c
> index 434322492c..5d7ae95931 100644
> --- a/libavcodec/cbs_h2645.c
> +++ b/libavcodec/cbs_h2645.c
> @@ -1207,6 +1207,20 @@ static int cbs_h265_write_nal_unit(CodedBitstreamContext *ctx,
>       return 0;
>   }
>   
> +//defined in B.2.2 zero_byte section
> +static int cbs_h2645_unit_requires_zero_byte(enum AVCodecID codec_id,
> +                                             CodedBitstreamUnitType type,
> +                                             int i)
> +{
> +    if (i == 0)
> +        return 1; /* (Assume this is the start of an access unit.) */
> +    if (codec_id == AV_CODEC_ID_H264)
> +        return type == H264_NAL_SPS || type == H264_NAL_PPS;
> +    if (codec_id == AV_CODEC_ID_HEVC)
> +        return type == HEVC_NAL_VPS || type == HEVC_NAL_SPS || type == HEVC_NAL_PPS;
> +    return 0;
> +}
> +
>   static int cbs_h2645_assemble_fragment(CodedBitstreamContext *ctx,
>                                          CodedBitstreamFragment *frag)
>   {
> @@ -1241,14 +1255,7 @@ static int cbs_h2645_assemble_fragment(CodedBitstreamContext *ctx,
>                   frag->data_bit_padding = unit->data_bit_padding;
>           }
>   
> -        if ((ctx->codec->codec_id == AV_CODEC_ID_H264 &&
> -             (unit->type == H264_NAL_SPS ||
> -              unit->type == H264_NAL_PPS)) ||
> -            (ctx->codec->codec_id == AV_CODEC_ID_HEVC &&
> -             (unit->type == HEVC_NAL_VPS ||
> -              unit->type == HEVC_NAL_SPS ||
> -              unit->type == HEVC_NAL_PPS)) ||
> -            i == 0 /* (Assume this is the start of an access unit.) */) {
> +        if (cbs_h2645_unit_requires_zero_byte(ctx->codec->codec_id, unit->type, i)) {
>               // zero_byte
>               data[dp++] = 0;
>           }
> 

I clarified the comments (the section reference is not the same for H.264) and applied.

Thanks,

- Mark


More information about the ffmpeg-devel mailing list