aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorJames Almer <jamrial@gmail.com>2017-03-24 18:27:37 -0300
committerJames Almer <jamrial@gmail.com>2017-03-25 22:38:13 -0300
commitb53ac2a5283da595b5f5c7f685c5102dc3ed50ca (patch)
tree74c86c6181aa2efebc69ff72aae08af195adf76a
parent173fdc4dea1351a8de5e04a324ad7f0fcb1563ea (diff)
downloadffmpeg-b53ac2a5283da595b5f5c7f685c5102dc3ed50ca.tar.gz
avcodec/extract_extradata_bsf: use the parsing code from mpeg4video_split()
It's a simplifaction of the same code, originally commited as 3b5ad8fbf77. Reviewed-by: Michael Niedermayer <michael@niedermayer.cc> Signed-off-by: James Almer <jamrial@gmail.com>
-rw-r--r--libavcodec/extract_extradata_bsf.c12
1 files changed, 6 insertions, 6 deletions
diff --git a/libavcodec/extract_extradata_bsf.c b/libavcodec/extract_extradata_bsf.c
index 447afb9f9a..e9b3791dc0 100644
--- a/libavcodec/extract_extradata_bsf.c
+++ b/libavcodec/extract_extradata_bsf.c
@@ -201,14 +201,14 @@ static int extract_extradata_mpeg4(AVBSFContext *ctx, AVPacket *pkt,
uint8_t **data, int *size)
{
ExtractExtradataContext *s = ctx->priv_data;
+ const uint8_t *ptr = pkt->data, *end = pkt->data + pkt->size;
uint32_t state = UINT32_MAX;
- int i;
- for (i = 0; i < pkt->size; i++) {
- state = (state << 8) | pkt->data[i];
- if ((state == 0x1B3 || state == 0x1B6)) {
- if (i > 3) {
- *size = i - 3;
+ while (ptr < end) {
+ ptr = avpriv_find_start_code(ptr, end, &state);
+ if (state == 0x1B3 || state == 0x1B6) {
+ if (ptr - pkt->data > 4) {
+ *size = ptr - 4 - pkt->data;
*data = av_malloc(*size + AV_INPUT_BUFFER_PADDING_SIZE);
if (!*data)
return AVERROR(ENOMEM);