[FFmpeg-devel] [PATCH] avformat/avidec: use avpriv_find_start_code in avi_read_packet()
zhaoxiu.zeng
zhaoxiu.zeng at gmail.com
Sun Mar 15 09:38:27 CET 2015
>From 50cefc3b62bf45e16b858f5e414777afb1a9bd36 Mon Sep 17 00:00:00 2001
From: Zeng Zhaoxiu <zhaoxiu.zeng at gmail.com>
Date: Sun, 15 Mar 2015 11:54:13 +0800
Subject: [PATCH 1/7] avformat/avidec: use avpriv_find_start_code in
avi_read_packet()
Signed-off-by: Zeng Zhaoxiu <zhaoxiu.zeng at gmail.com>
---
libavformat/avidec.c | 25 ++++++++++++-------------
1 file changed, 12 insertions(+), 13 deletions(-)
diff --git a/libavformat/avidec.c b/libavformat/avidec.c
index 00f0037..42599bf 100644
--- a/libavformat/avidec.c
+++ b/libavformat/avidec.c
@@ -36,7 +36,8 @@
#include "riff.h"
#include "libavcodec/bytestream.h"
#include "libavcodec/exif.h"
-#include "libavformat/isom.h"
+#include "libavcodec/internal.h"
+#include "isom.h"
typedef struct AVIStream {
int64_t frame_offset; /* current frame (video) or byte (audio) counter
@@ -1444,19 +1445,17 @@ FF_ENABLE_DEPRECATION_WARNINGS
e = &st->index_entries[index];
if (index >= 0 && e->timestamp == ast->frame_offset) {
- if (index == st->nb_index_entries-1) {
- int key=1;
- int i;
- uint32_t state=-1;
- for (i=0; i<FFMIN(size,256); i++) {
- if (st->codec->codec_id == AV_CODEC_ID_MPEG4) {
- if (state == 0x1B6) {
- key= !(pkt->data[i]&0xC0);
- break;
- }
- }else
+ if (index == st->nb_index_entries - 1 &&
+ st->codec->codec_id == AV_CODEC_ID_MPEG4) {
+ const uint8_t *ptr = pkt->data, *end = ptr + FFMIN(size, 256);
+ int key = 1;
+ uint32_t state = -1;
+ while (ptr < end) {
+ ptr = avpriv_find_start_code(ptr, end, &state);
+ if (state == 0x1B6 && ptr < end) {
+ key = !(*ptr & 0xC0);
break;
- state= (state<<8) + pkt->data[i];
+ }
}
if (!key)
e->flags &= ~AVINDEX_KEYFRAME;
--
2.1.0
More information about the ffmpeg-devel
mailing list