[FFmpeg-cvslog] avformat/avidec: use avpriv_find_start_code in avi_read_packet()

zhaoxiu.zeng git at videolan.org
Sun Mar 15 13:18:26 CET 2015


ffmpeg | branch: master | zhaoxiu.zeng <zhaoxiu.zeng at gmail.com> | Sun Mar 15 16:38:27 2015 +0800| [bf696e265a255676fbd3a93499bac007ac5d55e2] | committer: Michael Niedermayer

avformat/avidec: use avpriv_find_start_code in avi_read_packet()

Signed-off-by: Zeng Zhaoxiu <zhaoxiu.zeng at gmail.com>
Signed-off-by: Michael Niedermayer <michaelni at gmx.at>

> http://git.videolan.org/gitweb.cgi/ffmpeg.git/?a=commit;h=bf696e265a255676fbd3a93499bac007ac5d55e2
---

 libavformat/avidec.c |   16 ++++++++--------
 1 file changed, 8 insertions(+), 8 deletions(-)

diff --git a/libavformat/avidec.c b/libavformat/avidec.c
index 00f0037..508d34b 100644
--- a/libavformat/avidec.c
+++ b/libavformat/avidec.c
@@ -36,6 +36,7 @@
 #include "riff.h"
 #include "libavcodec/bytestream.h"
 #include "libavcodec/exif.h"
+#include "libavcodec/internal.h"
 #include "libavformat/isom.h"
 
 typedef struct AVIStream {
@@ -1446,17 +1447,16 @@ FF_ENABLE_DEPRECATION_WARNINGS
                 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);
+                        if (st->codec->codec_id == AV_CODEC_ID_MPEG4) {
+                            const uint8_t *ptr = pkt->data, *end = ptr + FFMIN(size, 256);
+                            while (ptr < end) {
+                                ptr = avpriv_find_start_code(ptr, end, &state);
+                                if (state == 0x1B6 && ptr < end) {
+                                    key = !(*ptr & 0xC0);
                                     break;
                                 }
-                            }else
-                                break;
-                            state= (state<<8) + pkt->data[i];
+                            }
                         }
                         if (!key)
                             e->flags &= ~AVINDEX_KEYFRAME;



More information about the ffmpeg-cvslog mailing list