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:
@@ -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;
|
||||
|
||||
Reference in New Issue
Block a user