@@ -102,6 +102,7 @@ av_cold static int lavfi_read_header(AVFormatContext *avctx)
LavfiContext *lavfi = avctx->priv_data;
AVFilterInOut *input_links = NULL, *output_links = NULL, *inout;
const AVFilter *buffersink, *abuffersink;
+ AVFrame *params = NULL;
enum AVMediaType type;
int ret = 0, i, n;
@@ -287,33 +288,39 @@ av_cold static int lavfi_read_header(AVFormatContext *avctx)
}
}
+ params = av_frame_alloc();
+ if (!params)
+ FAIL(AVERROR(ENOMEM));
+
/* fill each stream with the information in the corresponding sink */
for (i = 0; i < lavfi->nb_sinks; i++) {
AVFilterContext *sink = lavfi->sinks[lavfi->stream_sink_map[i]];
- AVRational time_base = av_buffersink_get_time_base(sink);
AVRational frame_rate = av_buffersink_get_frame_rate(sink);
AVStream *st = avctx->streams[i];
AVCodecParameters *const par = st->codecpar;
- avpriv_set_pts_info(st, 64, time_base.num, time_base.den);
+
+ av_frame_unref(params);
+ ret = av_buffersink_get_frame_flags(sink, params, AV_BUFFERSINK_FLAG_PARAMS);
+ if (ret < 0)
+ goto end;
+
+ avpriv_set_pts_info(st, 64, params->time_base.num, params->time_base.den);
par->codec_type = av_buffersink_get_type(sink);
+ par->format = params->format;
if (par->codec_type == AVMEDIA_TYPE_VIDEO) {
par->codec_id = AV_CODEC_ID_WRAPPED_AVFRAME;
- par->format = av_buffersink_get_format(sink);
- par->width = av_buffersink_get_w(sink);
- par->height = av_buffersink_get_h(sink);
+ par->width = params->width;
+ par->height = params->height;
avctx->probesize = FFMAX(avctx->probesize, sizeof(AVFrame) * 30);
st ->sample_aspect_ratio =
- par->sample_aspect_ratio = av_buffersink_get_sample_aspect_ratio(sink);
+ par->sample_aspect_ratio = params->sample_aspect_ratio;
if (frame_rate.num > 0 && frame_rate.den > 0) {
st->avg_frame_rate = frame_rate;
st->r_frame_rate = frame_rate;
}
} else if (par->codec_type == AVMEDIA_TYPE_AUDIO) {
- par->sample_rate = av_buffersink_get_sample_rate(sink);
- ret = av_buffersink_get_ch_layout(sink, &par->ch_layout);
- if (ret < 0)
- goto end;
- par->format = av_buffersink_get_format(sink);
+ par->sample_rate = params->sample_rate;
+ FFSWAP(AVChannelLayout, par->ch_layout, params->ch_layout);
par->codec_id = av_get_pcm_codec(par->format, -1);
if (par->codec_id == AV_CODEC_ID_NONE)
av_log(avctx, AV_LOG_ERROR,
@@ -326,6 +333,7 @@ av_cold static int lavfi_read_header(AVFormatContext *avctx)
goto end;
end:
+ av_frame_free(¶ms);
avfilter_inout_free(&input_links);
avfilter_inout_free(&output_links);
return ret;