[FFmpeg-cvslog] avconv: stop using AVStream.codec

Anton Khirnov git at videolan.org
Sun Jun 26 20:23:42 CEST 2016


ffmpeg | branch: release/3.1 | Anton Khirnov <anton at khirnov.net> | Sat May 21 11:37:33 2016 +0200| [35c858066840352d6d43385bbc728467c5150974] | committer: Diego Biurrun

avconv: stop using AVStream.codec

It is now only used by the av_parser_change() call during streamcopy, so
allocate a special AVCodecContext instance for this case. This instance
should go away when the new parser API is finished.

Signed-off-by: Diego Biurrun <diego at biurrun.de>

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

 avconv.c |   21 ++++++++-------------
 avconv.h |    1 +
 2 files changed, 9 insertions(+), 13 deletions(-)

diff --git a/avconv.c b/avconv.c
index 74459ab..e48f031 100644
--- a/avconv.c
+++ b/avconv.c
@@ -184,6 +184,7 @@ static void avconv_cleanup(int ret)
         av_frame_free(&ost->filtered_frame);
 
         av_parser_close(ost->parser);
+        avcodec_free_context(&ost->parser_avctx);
 
         av_freep(&ost->forced_keyframes);
         av_freep(&ost->avfilter);
@@ -1101,7 +1102,7 @@ static void do_streamcopy(InputStream *ist, OutputStream *ost, const AVPacket *p
        && ost->enc_ctx->codec_id != AV_CODEC_ID_MPEG2VIDEO
        && ost->enc_ctx->codec_id != AV_CODEC_ID_VC1
        ) {
-        if (av_parser_change(ost->parser, ost->st->codec,
+        if (av_parser_change(ost->parser, ost->parser_avctx,
                              &opkt.data, &opkt.size,
                              pkt->data, pkt->size,
                              pkt->flags & AV_PKT_FLAG_KEY)) {
@@ -1709,14 +1710,6 @@ static int init_output_stream(OutputStream *ost, char *error, int error_len)
                    "Error initializing the output stream codec context.\n");
             exit_program(1);
         }
-        /*
-         * FIXME: this is only so that the bitstream filters and parsers (that still
-         * work with a codec context) get the parameter values.
-         * This should go away with the new BSF/parser API.
-         */
-        ret = avcodec_copy_context(ost->st->codec, ost->enc_ctx);
-        if (ret < 0)
-            return ret;
 
         if (ost->enc_ctx->nb_coded_side_data) {
             int i;
@@ -1747,11 +1740,10 @@ static int init_output_stream(OutputStream *ost, char *error, int error_len)
             return ret;
 
         /*
-         * FIXME: this is only so that the bitstream filters and parsers (that still
-         * work with a codec context) get the parameter values.
-         * This should go away with the new BSF/parser API.
+         * FIXME: will the codec context used by the parser during streamcopy
+         * This should go away with the new parser API.
          */
-        ret = avcodec_parameters_to_context(ost->st->codec, ost->st->codecpar);
+        ret = avcodec_parameters_to_context(ost->parser_avctx, ost->st->codecpar);
         if (ret < 0)
             return ret;
     }
@@ -1913,6 +1905,9 @@ static int transcode_init(void)
             }
 
             ost->parser = av_parser_init(par_dst->codec_id);
+            ost->parser_avctx = avcodec_alloc_context3(NULL);
+            if (!ost->parser_avctx)
+                return AVERROR(ENOMEM);
 
             switch (par_dst->codec_type) {
             case AVMEDIA_TYPE_AUDIO:
diff --git a/avconv.h b/avconv.h
index 05abae6..84fabf6 100644
--- a/avconv.h
+++ b/avconv.h
@@ -372,6 +372,7 @@ typedef struct OutputStream {
     enum AVPixelFormat pix_fmts[2];
 
     AVCodecParserContext *parser;
+    AVCodecContext       *parser_avctx;
 
     /* stats */
     // combined size of all the packets written



More information about the ffmpeg-cvslog mailing list