diff options
author | Martin Vignali <martin.vignali@gmail.com> | 2018-03-11 21:15:56 +0300 |
---|---|---|
committer | Martin Vignali <martin.vignali@gmail.com> | 2018-03-13 22:26:02 +0300 |
commit | f869e54d228d43adb3b1e0026a48273befe443eb (patch) | |
tree | 51533758e9ff23222894de17732ff6e7f86c3c19 /libavcodec/hap.c | |
parent | 688060fbb7233d9212a92ce171e3b94784f95ca1 (diff) |
avcodec/hap : move parse_section_header to hap.c in order to be use by new bsf filter
Diffstat (limited to 'libavcodec/hap.c')
-rw-r--r-- | libavcodec/hap.c | 22 |
1 files changed, 22 insertions, 0 deletions
diff --git a/libavcodec/hap.c b/libavcodec/hap.c index 5b3af5e1d0..1a330c9c9b 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; +} |