]> git.sesse.net Git - ffmpeg/blobdiff - libavcodec/h264_parser.c
h264: Fix parameters to ff_er_add_slice() call
[ffmpeg] / libavcodec / h264_parser.c
index 52ff88b3a4fa6e2b3dceb045a48e95438725d05e..0464476382c6cd5583a2b1d37ef10f59afcfe1c6 100644 (file)
@@ -37,7 +37,6 @@ static int ff_h264_find_frame_end(H264Context *h, const uint8_t *buf, int buf_si
     int i;
     uint32_t state;
     ParseContext *pc = &(h->s.parse_context);
-//printf("first %02X%02X%02X%02X\n", buf[0], buf[1],buf[2],buf[3]);
 //    mb_addr= pc->mb_addr - 1;
     state= pc->state;
     if(state>13)
@@ -251,6 +250,13 @@ static int h264_parse(AVCodecParserContext *s,
         h->got_first = 1;
         if (avctx->extradata_size) {
             h->s.avctx = avctx;
+            // must be done like in the decoder.
+            // otherwise opening the parser, creating extradata,
+            // and then closing and opening again
+            // will cause has_b_frames to be always set.
+            // NB: estimate_timings_from_pts behaves exactly like this.
+            if (!avctx->has_b_frames)
+                h->s.low_delay = 1;
             ff_h264_decode_extradata(h);
         }
     }
@@ -330,14 +336,15 @@ static int init(AVCodecParserContext *s)
 {
     H264Context *h = s->priv_data;
     h->thread_context[0] = h;
+    h->s.slice_context_count = 1;
     return 0;
 }
 
 AVCodecParser ff_h264_parser = {
-    CODEC_ID_H264 },
-    sizeof(H264Context),
-    init,
-    h264_parse,
-    close,
-    h264_split,
+    .codec_ids      = { AV_CODEC_ID_H264 },
+    .priv_data_size = sizeof(H264Context),
+    .parser_init    = init,
+    .parser_parse   = h264_parse,
+    .parser_close   = close,
+    .split          = h264_split,
 };