aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorMichael Niedermayer <michaelni@gmx.at>2014-10-27 04:22:42 +0100
committerCarl Eugen Hoyos <cehoyos@ag.or.at>2014-11-01 20:12:16 +0100
commit7ddf252c7e1e08d0029e40cefd3f5e9e1592e35c (patch)
tree586fb4ed6587cac46d35acdd9eede2d86ffbafc6
parent1abb0e563918ffec4c76c12e23f1a0647062a0fe (diff)
downloadffmpeg-7ddf252c7e1e08d0029e40cefd3f5e9e1592e35c.tar.gz
Move get_avc_nalsize() and find_start_code() to h264.h
This allows sharing them with the h264 parser Signed-off-by: Michael Niedermayer <michaelni@gmx.at> (cherry picked from commit 4898440f6bd19152373969159fff057b532c6374) Conflicts: libavcodec/h264.c libavcodec/h264.h
-rw-r--r--libavcodec/h264.h36
1 files changed, 36 insertions, 0 deletions
diff --git a/libavcodec/h264.h b/libavcodec/h264.h
index 03be472c51..dbbfba25b4 100644
--- a/libavcodec/h264.h
+++ b/libavcodec/h264.h
@@ -969,6 +969,42 @@ static av_always_inline int get_dct8x8_allowed(H264Context *h)
0x0001000100010001ULL));
}
+static inline int find_start_code(const uint8_t *buf, int buf_size,
+ int buf_index, int next_avc)
+{
+ // start code prefix search
+ for (; buf_index + 3 < next_avc; buf_index++)
+ // This should always succeed in the first iteration.
+ if (buf[buf_index] == 0 &&
+ buf[buf_index + 1] == 0 &&
+ buf[buf_index + 2] == 1)
+ break;
+
+ buf_index += 3;
+
+ if (buf_index >= buf_size)
+ return buf_size;
+
+ return buf_index;
+}
+
+static inline int get_avc_nalsize(H264Context *h, const uint8_t *buf,
+ int buf_size, int *buf_index)
+{
+ int i, nalsize = 0;
+
+ if (*buf_index >= buf_size - h->nal_length_size)
+ return -1;
+
+ for (i = 0; i < h->nal_length_size; i++)
+ nalsize = ((unsigned)nalsize << 8) | buf[(*buf_index)++];
+ if (nalsize <= 0 || nalsize > buf_size - *buf_index) {
+ av_log(h->avctx, AV_LOG_ERROR,
+ "AVC: nal size %d\n", nalsize);
+ return -1;
+ }
+ return nalsize;
+}
void ff_h264_draw_horiz_band(H264Context *h, int y, int height);
#endif /* AVCODEC_H264_H */