]> git.sesse.net Git - ffmpeg/blobdiff - libavcodec/vc1_parser.c
adx: Convert to the new bitstream reader
[ffmpeg] / libavcodec / vc1_parser.c
index 43ca0ede871b6e10ecab794da90159d56f2ad74b..7234db69ae68aadf20d32593be0a41e0b74d9293 100644 (file)
@@ -47,7 +47,7 @@ typedef enum {
     ONE
 } VC1ParseSearchState;
 
-typedef struct {
+typedef struct VC1ParseContext {
     ParseContext pc;
     VC1Context v;
     uint8_t prev_start_code;
@@ -108,6 +108,14 @@ static void vc1_extract_header(AVCodecParserContext *s, AVCodecContext *avctx,
 
         break;
     }
+    s->format = vpc->v.chromaformat == 1 ? AV_PIX_FMT_YUV420P
+                                         : AV_PIX_FMT_NONE;
+    if (avctx->width && avctx->height) {
+        s->width        = avctx->width;
+        s->height       = avctx->height;
+        s->coded_width  = FFALIGN(avctx->coded_width,  16);
+        s->coded_height = FFALIGN(avctx->coded_height, 16);
+    }
 }
 
 static int vc1_parse(AVCodecParserContext *s,
@@ -123,6 +131,7 @@ static int vc1_parse(AVCodecParserContext *s,
     uint8_t *unesc_buffer = vpc->unesc_buffer;
     size_t unesc_index = vpc->unesc_index;
     VC1ParseSearchState search_state = vpc->search_state;
+    int start_code_found = 0;
     int next = END_NOT_FOUND;
     int i = vpc->bytes_to_skip;
 
@@ -133,8 +142,8 @@ static int vc1_parse(AVCodecParserContext *s,
         next = 0;
     }
     while (i < buf_size) {
-        int start_code_found = 0;
         uint8_t b;
+        start_code_found = 0;
         while (i < buf_size && unesc_index < UNESCAPED_THRESHOLD) {
             b = buf[i++];
             unesc_buffer[unesc_index++] = b;
@@ -232,7 +241,7 @@ static int vc1_parse(AVCodecParserContext *s,
      * the start code we've already seen, or cause extra bytes to be
      * inserted at the start of the unescaped buffer. */
     vpc->bytes_to_skip = 4;
-    if (next < 0)
+    if (next < 0 && start_code_found)
         vpc->bytes_to_skip += next;
 
     *poutbuf = buf;