deps/media-playback: Fix init of swscale with hw decode

Checking the format of the AVCodecContext will result in using the
format of the hardware-side frames, not the software-side frames. This
uses the software frame parameters itself to initialize the swscale
context.
This commit is contained in:
tt2468 2024-06-15 17:04:18 -07:00 committed by Rodney
parent 0d7478c017
commit 4eef796f80

View file

@ -246,15 +246,14 @@ static inline int get_sws_range(enum AVColorRange r)
static bool mp_media_init_scaling(mp_media_t *m)
{
int space = get_sws_colorspace(m->v.decoder->colorspace);
int range = get_sws_range(m->v.decoder->color_range);
int space = get_sws_colorspace(m->v.frame->colorspace);
int range = get_sws_range(m->v.frame->color_range);
const int *coeff = sws_getCoefficients(space);
m->swscale = sws_getCachedContext(NULL, m->v.decoder->width,
m->v.decoder->height,
m->v.decoder->pix_fmt,
m->v.decoder->width,
m->v.decoder->height, m->scale_format,
m->swscale = sws_getCachedContext(NULL, m->v.frame->width,
m->v.frame->height,
m->v.frame->format, m->v.frame->width,
m->v.frame->height, m->scale_format,
SWS_POINT, NULL, NULL, NULL);
if (!m->swscale) {
blog(LOG_WARNING, "MP: Failed to initialize scaler");
@ -265,7 +264,7 @@ static bool mp_media_init_scaling(mp_media_t *m)
FIXED_1_0, FIXED_1_0);
int ret = av_image_alloc(m->scale_pic, m->scale_linesizes,
m->v.decoder->width, m->v.decoder->height,
m->v.frame->width, m->v.frame->height,
m->scale_format, 32);
if (ret < 0) {
blog(LOG_WARNING, "MP: Failed to create scale pic data");