AVDictionaryEntry *t = NULL;
int sample_rate, nb_channels;
int64_t channel_layout;
- int ret;
+ int ret = 0;
int stream_lowres = lowres;
if (stream_index < 0 || stream_index >= ic->nb_streams)
av_dict_set_int(&opts, "lowres", stream_lowres, 0);
if (avctx->codec_type == AVMEDIA_TYPE_VIDEO || avctx->codec_type == AVMEDIA_TYPE_AUDIO)
av_dict_set(&opts, "refcounted_frames", "1", 0);
- if (avcodec_open2(avctx, codec, &opts) < 0)
- return -1;
+ if ((ret = avcodec_open2(avctx, codec, &opts)) < 0) {
+ goto fail;
+ }
if ((t = av_dict_get(opts, "", NULL, AV_DICT_IGNORE_SUFFIX))) {
av_log(NULL, AV_LOG_ERROR, "Option %s not found.\n", t->key);
- return AVERROR_OPTION_NOT_FOUND;
+ ret = AVERROR_OPTION_NOT_FOUND;
+ goto fail;
}
ic->streams[stream_index]->discard = AVDISCARD_DEFAULT;
is->audio_filter_src.channel_layout = get_valid_channel_layout(avctx->channel_layout, avctx->channels);
is->audio_filter_src.fmt = avctx->sample_fmt;
if ((ret = configure_audio_filters(is, afilters, 0)) < 0)
- return ret;
+ goto fail;
link = is->out_audio_filter->inputs[0];
sample_rate = link->sample_rate;
nb_channels = link->channels;
/* prepare audio output */
if ((ret = audio_open(is, channel_layout, nb_channels, sample_rate, &is->audio_tgt)) < 0)
- return ret;
+ goto fail;
is->audio_hw_buf_size = ret;
is->audio_src = is->audio_tgt;
is->audio_buf_size = 0;
default:
break;
}
- return 0;
+
+fail:
+ av_dict_free(&opts);
+
+ return ret;
}
static void stream_component_close(VideoState *is, int stream_index)