@@ -725,7 +725,8 @@ static int cbs_h2645_split_fragment(CodedBitstreamContext *ctx,
err = ff_h2645_packet_split(&priv->read_packet,
frag->data + start, end - start,
ctx->log_ctx, 2, AV_CODEC_ID_VVC,
- H2645_FLAG_IS_NALFF | H2645_FLAG_SMALL_PADDING | H2645_FLAG_USE_REF);
+ H2645_FLAG_IS_NALFF | H2645_FLAG_SMALL_PADDING |
+ H2645_FLAG_USE_REF | H2645_FLAG_SKIPPED_BYTES);
if (err < 0) {
av_log(ctx->log_ctx, AV_LOG_ERROR, "Failed to split "
"VVCC array %d (%d NAL units of type %d).\n",
@@ -737,7 +738,8 @@ static int cbs_h2645_split_fragment(CodedBitstreamContext *ctx,
return err;
}
} else {
- int flags = (H2645_FLAG_IS_NALFF * !!priv->mp4) | H2645_FLAG_SMALL_PADDING | H2645_FLAG_USE_REF;
+ int flags = (H2645_FLAG_IS_NALFF * !!priv->mp4) | H2645_FLAG_SMALL_PADDING | H2645_FLAG_USE_REF |
+ (H2645_FLAG_SKIPPED_BYTES * (codec_id == AV_CODEC_ID_VVC));
// Annex B, or later MP4 with already-known parameters.
err = ff_h2645_packet_split(&priv->read_packet,
@@ -540,10 +540,12 @@ int ff_h2645_packet_split(H2645Packet *pkt, const uint8_t *buf, int length,
memset(pkt->nals + pkt->nals_allocated, 0, sizeof(*pkt->nals));
nal = &pkt->nals[pkt->nb_nals];
- nal->skipped_bytes_pos_size = FFMIN(1024, extract_length/3+1); // initial buffer size
- nal->skipped_bytes_pos = av_malloc_array(nal->skipped_bytes_pos_size, sizeof(*nal->skipped_bytes_pos));
- if (!nal->skipped_bytes_pos)
- return AVERROR(ENOMEM);
+ if (flags & H2645_FLAG_SKIPPED_BYTES) {
+ nal->skipped_bytes_pos_size = FFMIN(1024, extract_length/3+1); // initial buffer size
+ nal->skipped_bytes_pos = av_malloc_array(nal->skipped_bytes_pos_size, sizeof(*nal->skipped_bytes_pos));
+ if (!nal->skipped_bytes_pos)
+ return AVERROR(ENOMEM);
+ }
pkt->nals_allocated = new_size;
}
@@ -97,6 +97,7 @@ enum {
H2645_FLAG_IS_NALFF = (1 << 0),
H2645_FLAG_SMALL_PADDING = (1 << 1),
H2645_FLAG_USE_REF = (1 << 2),
+ H2645_FLAG_SKIPPED_BYTES = (1 << 3),
};
/**
@@ -3321,7 +3321,7 @@ static int decode_nal_units(HEVCContext *s, const uint8_t *buf, int length)
{
int i, ret = 0;
int eos_at_start = 1;
- int flags = (H2645_FLAG_IS_NALFF * !!s->is_nalff) | H2645_FLAG_SMALL_PADDING;
+ int flags = (H2645_FLAG_IS_NALFF * !!s->is_nalff) | H2645_FLAG_SMALL_PADDING | H2645_FLAG_SKIPPED_BYTES;
s->cur_frame = s->collocated_ref = NULL;
s->last_eos = s->eos;
This is only used by two out of several modules, so it's a waste of resources for the rest. Signed-off-by: James Almer <jamrial@gmail.com> --- libavcodec/cbs_h2645.c | 6 ++++-- libavcodec/h2645_parse.c | 10 ++++++---- libavcodec/h2645_parse.h | 1 + libavcodec/hevc/hevcdec.c | 2 +- 4 files changed, 12 insertions(+), 7 deletions(-)