1
0
mirror of https://github.com/FFmpeg/FFmpeg.git synced 2026-06-19 19:03:00 +02:00

avcodec/codec_par: copy AVCodecContext sw_pix_fmt instead of pix_fmt to AVCodecParameters if set

In case of an encoding scenario using a hardware encoder, AVCodecContext->pix_fmt may be a
hwaccel format that conveys no information muxers can use when looking at its descriptor,
as is the case of bitdepth.
As such, if sw_pix_fmt is set, copy that value instead.

Fixes issue #23420

Signed-off-by: James Almer <jamrial@gmail.com>
This commit is contained in:
James Almer
2026-06-10 14:06:25 -03:00
parent 7338d08bcf
commit 140d708d65
+2 -1
View File
@@ -154,7 +154,8 @@ int avcodec_parameters_from_context(AVCodecParameters *par,
switch (par->codec_type) {
case AVMEDIA_TYPE_VIDEO:
par->format = codec->pix_fmt;
par->format = codec->sw_pix_fmt != AV_PIX_FMT_NONE ?
codec->sw_pix_fmt : codec->pix_fmt;
par->width = codec->width;
par->height = codec->height;
par->field_order = codec->field_order;