diff options
author | Anton Khirnov <anton@khirnov.net> | 2021-11-23 11:22:57 +0100 |
---|---|---|
committer | Anton Khirnov <anton@khirnov.net> | 2021-12-04 14:08:17 +0100 |
commit | ab3ef54c8c6a47576a07ecdaacbc0b0096374f4a (patch) | |
tree | 93ac5198dd958a20ed7c41e26a414b333e2a8422 /fftools/ffmpeg.c | |
parent | 425889396137451ae30288c84122e28532b71596 (diff) | |
download | ffmpeg-ab3ef54c8c6a47576a07ecdaacbc0b0096374f4a.tar.gz |
ffmpeg: only copy bits_per_sample from decoder when it remains valid
I.e. when the only filters that are applied do not modify the frame
data.
Diffstat (limited to 'fftools/ffmpeg.c')
-rw-r--r-- | fftools/ffmpeg.c | 14 |
1 files changed, 5 insertions, 9 deletions
diff --git a/fftools/ffmpeg.c b/fftools/ffmpeg.c index 03aec1af11..47e6a8683e 100644 --- a/fftools/ffmpeg.c +++ b/fftools/ffmpeg.c @@ -3335,7 +3335,7 @@ static int init_output_stream_encode(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) + 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); @@ -3361,7 +3361,10 @@ static int init_output_stream_encode(OutputStream *ost, AVFrame *frame) av_buffersink_get_sample_aspect_ratio(ost->filter->filter); enc_ctx->pix_fmt = av_buffersink_get_format(ost->filter->filter); - if (dec_ctx) + + 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_pix_fmt_desc_get(enc_ctx->pix_fmt)->comp[0].depth); @@ -3377,13 +3380,6 @@ static int init_output_stream_encode(OutputStream *ost, AVFrame *frame) ost->st->avg_frame_rate = ost->frame_rate; - if (!dec_ctx || - enc_ctx->width != dec_ctx->width || - enc_ctx->height != dec_ctx->height || - enc_ctx->pix_fmt != dec_ctx->pix_fmt) { - enc_ctx->bits_per_raw_sample = ost->bits_per_raw_sample; - } - // Field order: autodetection if (frame) { if (enc_ctx->flags & (AV_CODEC_FLAG_INTERLACED_DCT | AV_CODEC_FLAG_INTERLACED_ME) && |