diff options
author | Anton Khirnov <anton@khirnov.net> | 2023-05-27 17:38:36 +0200 |
---|---|---|
committer | Anton Khirnov <anton@khirnov.net> | 2023-06-19 09:48:55 +0200 |
commit | 5293adb1a72347a2c13de1f3b0b37d51625f6985 (patch) | |
tree | 3e18915cde13c2ef55ff5e0225b598875d6415b1 /fftools/ffmpeg_enc.c | |
parent | 7d4e00ccf0b77dab1bf74320b26af968ba670394 (diff) | |
download | ffmpeg-5293adb1a72347a2c13de1f3b0b37d51625f6985.tar.gz |
fftools/ffmpeg: attach bits_per_raw_sample information to frames
This way avoids encoders reaching into filters or decoders for this
information.
Diffstat (limited to 'fftools/ffmpeg_enc.c')
-rw-r--r-- | fftools/ffmpeg_enc.c | 13 |
1 files changed, 6 insertions, 7 deletions
diff --git a/fftools/ffmpeg_enc.c b/fftools/ffmpeg_enc.c index 0fdf7e7c4d..f42f4055d6 100644 --- a/fftools/ffmpeg_enc.c +++ b/fftools/ffmpeg_enc.c @@ -198,6 +198,7 @@ int enc_open(OutputStream *ost, AVFrame *frame) AVCodecContext *dec_ctx = NULL; const AVCodec *enc = enc_ctx->codec; OutputFile *of = output_files[ost->file_index]; + FrameData *fd = frame ? frame_data(frame) : NULL; int ret; if (e->opened) @@ -219,8 +220,8 @@ int enc_open(OutputStream *ost, AVFrame *frame) 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, + else if (fd) + enc_ctx->bits_per_raw_sample = FFMIN(fd->bits_per_raw_sample, av_get_bytes_per_sample(enc_ctx->sample_fmt) << 3); enc_ctx->time_base = ost->enc_timebase.num > 0 ? ost->enc_timebase : @@ -230,10 +231,8 @@ int enc_open(OutputStream *ost, AVFrame *frame) case AVMEDIA_TYPE_VIDEO: { AVRational fr = ost->frame_rate; - if (!fr.num && frame) { - FrameData *fd = frame_data(frame); + if (!fr.num && fd) fr = fd->frame_rate_filter; - } if (!fr.num && !ost->max_frame_rate.num) { fr = (AVRational){25, 1}; av_log(ost, AV_LOG_WARNING, @@ -282,8 +281,8 @@ int enc_open(OutputStream *ost, AVFrame *frame) 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, + else if (fd) + enc_ctx->bits_per_raw_sample = FFMIN(fd->bits_per_raw_sample, av_pix_fmt_desc_get(enc_ctx->pix_fmt)->comp[0].depth); if (frame) { |