Welcome to mirror list, hosted at ThFree Co, Russian Federation.

github.com/FFmpeg/FFmpeg.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMichael Niedermayer <michael@niedermayer.cc>2016-08-20 01:36:38 +0300
committerMichael Niedermayer <michael@niedermayer.cc>2016-08-20 01:36:38 +0300
commitf10ea03df3dd1c15e3a957ca0aba528251438a79 (patch)
tree430c55a5b706d26c1f1f371c0c918eba16b92c9f /libavcodec/h2645_parse.h
parentb8b36717217c6f45db71c77ad4e7c65521e7d9ff (diff)
avcodec/h264_parser: Factor get_avc_nalsize() out
Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
Diffstat (limited to 'libavcodec/h2645_parse.h')
-rw-r--r--libavcodec/h2645_parse.h20
1 files changed, 20 insertions, 0 deletions
diff --git a/libavcodec/h2645_parse.h b/libavcodec/h2645_parse.h
index 630235994e..3a60f3fb9b 100644
--- a/libavcodec/h2645_parse.h
+++ b/libavcodec/h2645_parse.h
@@ -90,4 +90,24 @@ int ff_h2645_packet_split(H2645Packet *pkt, const uint8_t *buf, int length,
*/
void ff_h2645_packet_uninit(H2645Packet *pkt);
+static inline int get_nalsize(int nal_length_size, const uint8_t *buf,
+ int buf_size, int *buf_index, void *logctx)
+{
+ int i, nalsize = 0;
+
+ if (*buf_index >= buf_size - nal_length_size) {
+ // the end of the buffer is reached, refill it
+ return AVERROR(EAGAIN);
+ }
+
+ for (i = 0; i < nal_length_size; i++)
+ nalsize = ((unsigned)nalsize << 8) | buf[(*buf_index)++];
+ if (nalsize <= 0 || nalsize > buf_size - *buf_index) {
+ av_log(logctx, AV_LOG_ERROR,
+ "Invalid nal size %d\n", nalsize);
+ return AVERROR_INVALIDDATA;
+ }
+ return nalsize;
+}
+
#endif /* AVCODEC_H2645_PARSE_H */