aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorAndreas Rheinhardt <andreas.rheinhardt@outlook.com>2021-12-02 18:35:50 +0100
committerAndreas Rheinhardt <andreas.rheinhardt@outlook.com>2021-12-03 16:59:34 +0100
commit88af0962ef76582a1f4772ee81816512a6646edb (patch)
treee75a33016c08380e81828d307b643e38bf8525aa
parent83ae589359203e83a7e9c1e96eb3f02f5a5bfa6b (diff)
downloadffmpeg-88af0962ef76582a1f4772ee81816512a6646edb.tar.gz
avdevice/lavfi: Avoid calling av_buffersink_get_* multiple times
Reviewed-by: Nicolas George <george@nsup.org> Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
-rw-r--r--libavdevice/lavfi.c16
1 files changed, 8 insertions, 8 deletions
diff --git a/libavdevice/lavfi.c b/libavdevice/lavfi.c
index 209ebed5fd..878bb193af 100644
--- a/libavdevice/lavfi.c
+++ b/libavdevice/lavfi.c
@@ -320,27 +320,27 @@ av_cold static int lavfi_read_header(AVFormatContext *avctx)
AVCodecParameters *const par = st->codecpar;
avpriv_set_pts_info(st, 64, time_base.num, time_base.den);
par->codec_type = av_buffersink_get_type(sink);
- if (av_buffersink_get_type(sink) == AVMEDIA_TYPE_VIDEO) {
+ if (par->codec_type == AVMEDIA_TYPE_VIDEO) {
+ int64_t probesize;
par->codec_id = AV_CODEC_ID_RAWVIDEO;
par->format = av_buffersink_get_format(sink);
par->width = av_buffersink_get_w(sink);
par->height = av_buffersink_get_h(sink);
+ probesize = par->width * par->height * 30 *
+ av_get_padded_bits_per_pixel(av_pix_fmt_desc_get(par->format));
+ avctx->probesize = FFMAX(avctx->probesize, probesize);
st ->sample_aspect_ratio =
par->sample_aspect_ratio = av_buffersink_get_sample_aspect_ratio(sink);
- avctx->probesize = FFMAX(avctx->probesize,
- av_buffersink_get_w(sink) * av_buffersink_get_h(sink) *
- av_get_padded_bits_per_pixel(av_pix_fmt_desc_get(av_buffersink_get_format(sink))) *
- 30);
- } else if (av_buffersink_get_type(sink) == AVMEDIA_TYPE_AUDIO) {
+ } else if (par->codec_type == AVMEDIA_TYPE_AUDIO) {
par->channels = av_buffersink_get_channels(sink);
par->sample_rate = av_buffersink_get_sample_rate(sink);
par->channel_layout = av_buffersink_get_channel_layout(sink);
par->format = av_buffersink_get_format(sink);
- par->codec_id = av_get_pcm_codec(av_buffersink_get_format(sink), -1);
+ par->codec_id = av_get_pcm_codec(par->format, -1);
if (par->codec_id == AV_CODEC_ID_NONE)
av_log(avctx, AV_LOG_ERROR,
"Could not find PCM codec for sample format %s.\n",
- av_get_sample_fmt_name(av_buffersink_get_format(sink)));
+ av_get_sample_fmt_name(par->format));
}
}