mirror of
https://git.ffmpeg.org/ffmpeg.git
synced 2025-12-12 18:10:13 +01:00
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.
This commit is contained in:
@@ -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) &&
|
||||
|
||||
Reference in New Issue
Block a user