summaryrefslogtreecommitdiff
path: root/avconv_opt.c
diff options
context:
space:
mode:
authorAnton Khirnov <anton@khirnov.net>2014-04-05 08:48:24 +0200
committerAnton Khirnov <anton@khirnov.net>2014-06-01 08:33:11 +0200
commit41776ba9c0ebbb71394cefdf7dd1b243e6c852d5 (patch)
treeb282e400618dc04d9a431ef518f54a73f74b32cb /avconv_opt.c
parente19d48dfce52f1417f7f06143b96fed00cbcdc52 (diff)
avconv: do not use the stream codec context for decoding
Diffstat (limited to 'avconv_opt.c')
-rw-r--r--avconv_opt.c28
1 files changed, 20 insertions, 8 deletions
diff --git a/avconv_opt.c b/avconv_opt.c
index 12d676054d..539b1a0f61 100644
--- a/avconv_opt.c
+++ b/avconv_opt.c
@@ -462,7 +462,7 @@ static AVCodec *choose_decoder(OptionsContext *o, AVFormatContext *s, AVStream *
* list of input streams. */
static void add_input_streams(OptionsContext *o, AVFormatContext *ic)
{
- int i;
+ int i, ret;
for (i = 0; i < ic->nb_streams; i++) {
AVStream *st = ic->streams[i];
@@ -497,11 +497,23 @@ static void add_input_streams(OptionsContext *o, AVFormatContext *ic)
ist->dec = choose_decoder(o, ic, st);
ist->decoder_opts = filter_codec_opts(o->g->codec_opts, ist->st->codec->codec_id, ic, st, ist->dec);
+ ist->dec_ctx = avcodec_alloc_context3(ist->dec);
+ if (!ist->dec_ctx) {
+ av_log(NULL, AV_LOG_ERROR, "Error allocating the decoder context.\n");
+ exit_program(1);
+ }
+
+ ret = avcodec_copy_context(ist->dec_ctx, dec);
+ if (ret < 0) {
+ av_log(NULL, AV_LOG_ERROR, "Error initializing the decoder context.\n");
+ exit_program(1);
+ }
+
switch (dec->codec_type) {
case AVMEDIA_TYPE_VIDEO:
- ist->resample_height = dec->height;
- ist->resample_width = dec->width;
- ist->resample_pix_fmt = dec->pix_fmt;
+ ist->resample_height = ist->dec_ctx->height;
+ ist->resample_width = ist->dec_ctx->width;
+ ist->resample_pix_fmt = ist->dec_ctx->pix_fmt;
MATCH_PER_STREAM_OPT(frame_rates, str, framerate, ic, st);
if (framerate && av_parse_video_rate(&ist->framerate,
@@ -550,10 +562,10 @@ static void add_input_streams(OptionsContext *o, AVFormatContext *ic)
case AVMEDIA_TYPE_AUDIO:
guess_input_channel_layout(ist);
- ist->resample_sample_fmt = dec->sample_fmt;
- ist->resample_sample_rate = dec->sample_rate;
- ist->resample_channels = dec->channels;
- ist->resample_channel_layout = dec->channel_layout;
+ ist->resample_sample_fmt = ist->dec_ctx->sample_fmt;
+ ist->resample_sample_rate = ist->dec_ctx->sample_rate;
+ ist->resample_channels = ist->dec_ctx->channels;
+ ist->resample_channel_layout = ist->dec_ctx->channel_layout;
break;
case AVMEDIA_TYPE_DATA: