mirror of
https://github.com/obsproject/obs-studio.git
synced 2024-06-30 08:33:32 +00:00
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:
parent
0d7478c017
commit
4eef796f80
15
deps/media-playback/media-playback/media.c
vendored
15
deps/media-playback/media-playback/media.c
vendored
|
@ -246,15 +246,14 @@ static inline int get_sws_range(enum AVColorRange r)
|
||||||
|
|
||||||
static bool mp_media_init_scaling(mp_media_t *m)
|
static bool mp_media_init_scaling(mp_media_t *m)
|
||||||
{
|
{
|
||||||
int space = get_sws_colorspace(m->v.decoder->colorspace);
|
int space = get_sws_colorspace(m->v.frame->colorspace);
|
||||||
int range = get_sws_range(m->v.decoder->color_range);
|
int range = get_sws_range(m->v.frame->color_range);
|
||||||
const int *coeff = sws_getCoefficients(space);
|
const int *coeff = sws_getCoefficients(space);
|
||||||
|
|
||||||
m->swscale = sws_getCachedContext(NULL, m->v.decoder->width,
|
m->swscale = sws_getCachedContext(NULL, m->v.frame->width,
|
||||||
m->v.decoder->height,
|
m->v.frame->height,
|
||||||
m->v.decoder->pix_fmt,
|
m->v.frame->format, m->v.frame->width,
|
||||||
m->v.decoder->width,
|
m->v.frame->height, m->scale_format,
|
||||||
m->v.decoder->height, m->scale_format,
|
|
||||||
SWS_POINT, NULL, NULL, NULL);
|
SWS_POINT, NULL, NULL, NULL);
|
||||||
if (!m->swscale) {
|
if (!m->swscale) {
|
||||||
blog(LOG_WARNING, "MP: Failed to initialize scaler");
|
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);
|
FIXED_1_0, FIXED_1_0);
|
||||||
|
|
||||||
int ret = av_image_alloc(m->scale_pic, m->scale_linesizes,
|
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);
|
m->scale_format, 32);
|
||||||
if (ret < 0) {
|
if (ret < 0) {
|
||||||
blog(LOG_WARNING, "MP: Failed to create scale pic data");
|
blog(LOG_WARNING, "MP: Failed to create scale pic data");
|
||||||
|
|
Loading…
Reference in a new issue