[FFmpeg-cvslog] avcodec/hap : move parse_section_header to hap.c in order to be use by new bsf filter
Martin Vignali
git at videolan.org
Tue Mar 13 21:27:11 EET 2018
ffmpeg | branch: master | Martin Vignali <martin.vignali at gmail.com> | Sun Mar 11 19:15:56 2018 +0100| [f869e54d228d43adb3b1e0026a48273befe443eb] | committer: Martin Vignali
avcodec/hap : move parse_section_header to hap.c in order to be use by new bsf filter
> http://git.videolan.org/gitweb.cgi/ffmpeg.git/?a=commit;h=f869e54d228d43adb3b1e0026a48273befe443eb
---
libavcodec/hap.c | 22 ++++++++++++++++++++++
libavcodec/hap.h | 6 ++++++
libavcodec/hapdec.c | 33 ++++-----------------------------
3 files changed, 32 insertions(+), 29 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;
+}
diff --git a/libavcodec/hap.h b/libavcodec/hap.h
index 74455f3dd9..bbeed11e32 100644
--- a/libavcodec/hap.h
+++ b/libavcodec/hap.h
@@ -103,4 +103,10 @@ int ff_hap_set_chunk_count(HapContext *ctx, int count, int first_in_frame);
*/
av_cold void ff_hap_free_context(HapContext *ctx);
+/* The first three bytes are the size of the section past the header, or zero
+ * if the length is stored in the next long word. The fourth byte in the first
+ * long word indicates the type of the current section. */
+int ff_hap_parse_section_header(GetByteContext *gbc, int *section_size,
+ enum HapSectionType *section_type);
+
#endif /* AVCODEC_HAP_H */
diff --git a/libavcodec/hapdec.c b/libavcodec/hapdec.c
index 8fd4aa962c..8c845770cf 100644
--- a/libavcodec/hapdec.c
+++ b/libavcodec/hapdec.c
@@ -43,31 +43,6 @@
#include "texturedsp.h"
#include "thread.h"
-/* The first three bytes are the size of the section past the header, or zero
- * if the length is stored in the next long word. The fourth byte in the first
- * long word indicates the type of the current section. */
-static int 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;
-}
-
static int hap_parse_decode_instructions(HapContext *ctx, int size)
{
GetByteContext *gbc = &ctx->gbc;
@@ -78,7 +53,7 @@ static int hap_parse_decode_instructions(HapContext *ctx, int size)
while (size > 0) {
int stream_remaining = bytestream2_get_bytes_left(gbc);
- ret = parse_section_header(gbc, §ion_size, §ion_type);
+ ret = ff_hap_parse_section_header(gbc, §ion_size, §ion_type);
if (ret != 0)
return ret;
@@ -159,7 +134,7 @@ static int hap_parse_frame_header(AVCodecContext *avctx)
const char *compressorstr;
int i, ret;
- ret = parse_section_header(gbc, &ctx->texture_section_size, §ion_type);
+ ret = ff_hap_parse_section_header(gbc, &ctx->texture_section_size, §ion_type);
if (ret != 0)
return ret;
@@ -190,7 +165,7 @@ static int hap_parse_frame_header(AVCodecContext *avctx)
}
break;
case HAP_COMP_COMPLEX:
- ret = parse_section_header(gbc, §ion_size, §ion_type);
+ ret = ff_hap_parse_section_header(gbc, §ion_size, §ion_type);
if (ret == 0 && section_type != HAP_ST_DECODE_INSTRUCTIONS)
ret = AVERROR_INVALIDDATA;
if (ret == 0)
@@ -342,7 +317,7 @@ static int hap_decode(AVCodecContext *avctx, void *data,
/* check for multi texture header */
if (ctx->texture_count == 2) {
- ret = parse_section_header(&ctx->gbc, §ion_size, §ion_type);
+ ret = ff_hap_parse_section_header(&ctx->gbc, §ion_size, §ion_type);
if (ret != 0)
return ret;
if ((section_type & 0x0F) != 0x0D) {
More information about the ffmpeg-cvslog
mailing list