aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorAnton Khirnov <anton@khirnov.net>2023-05-28 17:11:58 +0200
committerAnton Khirnov <anton@khirnov.net>2023-06-05 16:15:04 +0200
commit2baae6434b997294b4a122a0ee2a37d3996f1e48 (patch)
tree77575c3fb9a72bb1bee081f82e40325b195f7859
parentc8a85d1b2fcf4a34ef55570d374bda1719bf2569 (diff)
downloadffmpeg-2baae6434b997294b4a122a0ee2a37d3996f1e48.tar.gz
fftools/ffmpeg_enc: merge two adjacent video-specific blocks
There is no meaningful reason for them to be separated.
-rw-r--r--fftools/ffmpeg_enc.c38
1 files changed, 18 insertions, 20 deletions
diff --git a/fftools/ffmpeg_enc.c b/fftools/ffmpeg_enc.c
index d390e384ed..07928b3557 100644
--- a/fftools/ffmpeg_enc.c
+++ b/fftools/ffmpeg_enc.c
@@ -219,7 +219,24 @@ int enc_open(OutputStream *ost, AVFrame *frame)
dec_ctx = ist->dec_ctx;
}
- if (enc_ctx->codec_type == AVMEDIA_TYPE_VIDEO) {
+ switch (enc_ctx->codec_type) {
+ case AVMEDIA_TYPE_AUDIO:
+ enc_ctx->sample_fmt = av_buffersink_get_format(ost->filter->filter);
+ enc_ctx->sample_rate = av_buffersink_get_sample_rate(ost->filter->filter);
+ ret = av_buffersink_get_ch_layout(ost->filter->filter, &enc_ctx->ch_layout);
+ if (ret < 0)
+ return ret;
+
+ if (ost->bits_per_raw_sample)
+ enc_ctx->bits_per_raw_sample = ost->bits_per_raw_sample;
+ else if (dec_ctx && ost->filter->graph->is_meta)
+ enc_ctx->bits_per_raw_sample = FFMIN(dec_ctx->bits_per_raw_sample,
+ av_get_bytes_per_sample(enc_ctx->sample_fmt) << 3);
+
+ init_encoder_time_base(ost, av_make_q(1, enc_ctx->sample_rate));
+ break;
+
+ case AVMEDIA_TYPE_VIDEO:
if (!ost->frame_rate.num)
ost->frame_rate = av_buffersink_get_frame_rate(ost->filter->filter);
if (!ost->frame_rate.num && !ost->max_frame_rate.num) {
@@ -245,26 +262,7 @@ int enc_open(OutputStream *ost, AVFrame *frame)
av_reduce(&ost->frame_rate.num, &ost->frame_rate.den,
ost->frame_rate.num, ost->frame_rate.den, 65535);
}
- }
- switch (enc_ctx->codec_type) {
- case AVMEDIA_TYPE_AUDIO:
- enc_ctx->sample_fmt = av_buffersink_get_format(ost->filter->filter);
- enc_ctx->sample_rate = av_buffersink_get_sample_rate(ost->filter->filter);
- ret = av_buffersink_get_ch_layout(ost->filter->filter, &enc_ctx->ch_layout);
- if (ret < 0)
- return ret;
-
- if (ost->bits_per_raw_sample)
- enc_ctx->bits_per_raw_sample = ost->bits_per_raw_sample;
- else if (dec_ctx && ost->filter->graph->is_meta)
- enc_ctx->bits_per_raw_sample = FFMIN(dec_ctx->bits_per_raw_sample,
- av_get_bytes_per_sample(enc_ctx->sample_fmt) << 3);
-
- init_encoder_time_base(ost, av_make_q(1, enc_ctx->sample_rate));
- break;
-
- case AVMEDIA_TYPE_VIDEO:
init_encoder_time_base(ost, av_inv_q(ost->frame_rate));
if (!(enc_ctx->time_base.num && enc_ctx->time_base.den))