aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorNuo Mi <nuomi2021@gmail.com>2021-01-12 00:33:14 +0800
committerMark Thompson <sw@jkqxz.net>2021-01-11 21:34:43 +0000
commit2ad21ee9d4d0e50bed2519598127e48206639961 (patch)
treee9105a261547e08f51683c7e1b712db6cedc73c9
parent71de4ebedefda1cd9aef1ba60b3e04fc5f1992ce (diff)
downloadffmpeg-2ad21ee9d4d0e50bed2519598127e48206639961.tar.gz
avcodec/cbs_h2645: Move zero_byte check to its own function
Signed-off-by: Mark Thompson <sw@jkqxz.net>
-rw-r--r--libavcodec/cbs_h2645.c25
1 files changed, 17 insertions, 8 deletions
diff --git a/libavcodec/cbs_h2645.c b/libavcodec/cbs_h2645.c
index 434322492c..550c059ef3 100644
--- a/libavcodec/cbs_h2645.c
+++ b/libavcodec/cbs_h2645.c
@@ -1207,6 +1207,22 @@ static int cbs_h265_write_nal_unit(CodedBitstreamContext *ctx,
return 0;
}
+static int cbs_h2645_unit_requires_zero_byte(enum AVCodecID codec_id,
+ CodedBitstreamUnitType type,
+ int nal_unit_index)
+{
+ // Section B.1.2 in H.264, section B.2.2 in H.265.
+ if (nal_unit_index == 0) {
+ // Assume that this is the first NAL unit in an access unit.
+ return 1;
+ }
+ 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 +1257,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;
}