]> git.sesse.net Git - ffmpeg/blobdiff - libavcodec/parser.c
decode: be more explicit about storing the last packet properties
[ffmpeg] / libavcodec / parser.c
index 080bbc345dd4553dc56bec3bd3febb5238e92217..355187ae45ba59daa066f6ae1771fb48f61a5c4c 100644 (file)
 #include <stdint.h>
 #include <string.h>
 
+#include "libavutil/internal.h"
 #include "libavutil/mem.h"
 
+#include "internal.h"
 #include "parser.h"
 
 static AVCodecParser *av_first_parser = NULL;
 
-AVCodecParser *av_parser_next(AVCodecParser *p)
+AVCodecParser *av_parser_next(const AVCodecParser *p)
 {
     if (p)
         return p->next;
@@ -85,10 +87,16 @@ found:
     s->fetch_timestamp      = 1;
     s->pict_type            = AV_PICTURE_TYPE_I;
     s->key_frame            = -1;
+#if FF_API_CONVERGENCE_DURATION
+FF_DISABLE_DEPRECATION_WARNINGS
     s->convergence_duration = 0;
+FF_ENABLE_DEPRECATION_WARNINGS
+#endif
     s->dts_sync_point       = INT_MIN;
     s->dts_ref_dts_delta    = INT_MIN;
     s->pts_dts_delta        = INT_MIN;
+    s->format               = -1;
+
     return s;
 }
 
@@ -123,7 +131,7 @@ int av_parser_parse2(AVCodecParserContext *s, AVCodecContext *avctx,
                      int64_t pts, int64_t dts, int64_t pos)
 {
     int index, i;
-    uint8_t dummy_buf[FF_INPUT_BUFFER_PADDING_SIZE];
+    uint8_t dummy_buf[AV_INPUT_BUFFER_PADDING_SIZE];
 
     if (!(s->flags & PARSER_FLAG_FETCHED_OFFSET)) {
         s->next_frame_offset =
@@ -176,8 +184,8 @@ int av_parser_change(AVCodecParserContext *s, AVCodecContext *avctx,
                      const uint8_t *buf, int buf_size, int keyframe)
 {
     if (s && s->parser->split) {
-        if (avctx->flags  & CODEC_FLAG_GLOBAL_HEADER ||
-            avctx->flags2 & CODEC_FLAG2_LOCAL_HEADER) {
+        if (avctx->flags  & AV_CODEC_FLAG_GLOBAL_HEADER ||
+            avctx->flags2 & AV_CODEC_FLAG2_LOCAL_HEADER) {
             int i = s->parser->split(avctx, buf, buf_size);
             buf      += i;
             buf_size -= i;
@@ -188,15 +196,17 @@ int av_parser_change(AVCodecParserContext *s, AVCodecContext *avctx,
     *poutbuf      = (uint8_t *) buf;
     *poutbuf_size = buf_size;
     if (avctx->extradata) {
-        if (keyframe && (avctx->flags2 & CODEC_FLAG2_LOCAL_HEADER)) {
+        if (keyframe && (avctx->flags2 & AV_CODEC_FLAG2_LOCAL_HEADER)) {
             int size = buf_size + avctx->extradata_size;
 
             *poutbuf_size = size;
-            *poutbuf      = av_malloc(size + FF_INPUT_BUFFER_PADDING_SIZE);
+            *poutbuf      = av_malloc(size + AV_INPUT_BUFFER_PADDING_SIZE);
+            if (!*poutbuf)
+                return AVERROR(ENOMEM);
 
             memcpy(*poutbuf, avctx->extradata, avctx->extradata_size);
             memcpy(*poutbuf + avctx->extradata_size, buf,
-                   buf_size + FF_INPUT_BUFFER_PADDING_SIZE);
+                   buf_size + AV_INPUT_BUFFER_PADDING_SIZE);
             return 1;
         }
     }
@@ -218,9 +228,9 @@ int ff_combine_frame(ParseContext *pc, int next,
                      const uint8_t **buf, int *buf_size)
 {
     if (pc->overread) {
-        av_dlog(NULL, "overread %d, state:%X next:%d index:%d o_index:%d\n",
+        ff_dlog(NULL, "overread %d, state:%X next:%d index:%d o_index:%d\n",
                 pc->overread, pc->state, next, pc->index, pc->overread_index);
-        av_dlog(NULL, "%X %X %X %X\n",
+        ff_dlog(NULL, "%X %X %X %X\n",
                 (*buf)[0], (*buf)[1], (*buf)[2], (*buf)[3]);
     }
 
@@ -238,7 +248,7 @@ int ff_combine_frame(ParseContext *pc, int next,
     if (next == END_NOT_FOUND) {
         void *new_buffer = av_fast_realloc(pc->buffer, &pc->buffer_size,
                                            *buf_size + pc->index +
-                                           FF_INPUT_BUFFER_PADDING_SIZE);
+                                           AV_INPUT_BUFFER_PADDING_SIZE);
 
         if (!new_buffer)
             return AVERROR(ENOMEM);
@@ -255,14 +265,14 @@ int ff_combine_frame(ParseContext *pc, int next,
     if (pc->index) {
         void *new_buffer = av_fast_realloc(pc->buffer, &pc->buffer_size,
                                            next + pc->index +
-                                           FF_INPUT_BUFFER_PADDING_SIZE);
+                                           AV_INPUT_BUFFER_PADDING_SIZE);
 
         if (!new_buffer)
             return AVERROR(ENOMEM);
         pc->buffer = new_buffer;
-        if (next > -FF_INPUT_BUFFER_PADDING_SIZE)
+        if (next > -AV_INPUT_BUFFER_PADDING_SIZE)
             memcpy(&pc->buffer[pc->index], *buf,
-                   next + FF_INPUT_BUFFER_PADDING_SIZE);
+                   next + AV_INPUT_BUFFER_PADDING_SIZE);
         pc->index = 0;
         *buf      = pc->buffer;
     }
@@ -275,9 +285,9 @@ int ff_combine_frame(ParseContext *pc, int next,
     }
 
     if (pc->overread) {
-        av_dlog(NULL, "overread %d, state:%X next:%d index:%d o_index:%d\n",
+        ff_dlog(NULL, "overread %d, state:%X next:%d index:%d o_index:%d\n",
                 pc->overread, pc->state, next, pc->index, pc->overread_index);
-        av_dlog(NULL, "%X %X %X %X\n",
+        ff_dlog(NULL, "%X %X %X %X\n",
                 (*buf)[0], (*buf)[1], (*buf)[2], (*buf)[3]);
     }