X-Git-Url: https://git.sesse.net/?a=blobdiff_plain;f=libavcodec%2Fhap.c;h=1a330c9c9b3cc7e4faa5c45e8bc9ef2a98e38e50;hb=7246bf365a1f2f12f1e7f1162aef8930924866dc;hp=5b3af5e1d0f492e64115d70a6b5179d6660cdebb;hpb=0cc8e34a94c84132cf5b0f6472c5f61c8a66cee1;p=ffmpeg diff --git a/libavcodec/hap.c b/libavcodec/hap.c index 5b3af5e1d0f..1a330c9c9b3 100644 --- a/libavcodec/hap.c +++ b/libavcodec/hap.c @@ -53,3 +53,25 @@ av_cold void ff_hap_free_context(HapContext *ctx) av_freep(&ctx->chunks); av_freep(&ctx->chunk_results); } + +int ff_hap_parse_section_header(GetByteContext *gbc, int *section_size, + enum HapSectionType *section_type) +{ + if (bytestream2_get_bytes_left(gbc) < 4) + return AVERROR_INVALIDDATA; + + *section_size = bytestream2_get_le24(gbc); + *section_type = bytestream2_get_byte(gbc); + + if (*section_size == 0) { + if (bytestream2_get_bytes_left(gbc) < 4) + return AVERROR_INVALIDDATA; + + *section_size = bytestream2_get_le32(gbc); + } + + if (*section_size > bytestream2_get_bytes_left(gbc) || *section_size < 0) + return AVERROR_INVALIDDATA; + else + return 0; +}