浏览代码

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.
tt2468 1 年之前
父节点
当前提交
4eef796f80
共有 1 个文件被更改,包括 7 次插入8 次删除
  1. 7 8
      deps/media-playback/media-playback/media.c

+ 7 - 8
deps/media-playback/media-playback/media.c

@@ -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");