summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--video/decode/videotoolbox.c32
-rw-r--r--video/mp_image.c2
-rw-r--r--video/mp_image.h3
-rw-r--r--video/out/opengl/hwdec_osx.c2
-rw-r--r--video/out/opengl/hwdec_vaegl.c7
-rw-r--r--video/vaapi.c2
6 files changed, 22 insertions, 26 deletions
diff --git a/video/decode/videotoolbox.c b/video/decode/videotoolbox.c
index 355017ffd4..c6f1a472bf 100644
--- a/video/decode/videotoolbox.c
+++ b/video/decode/videotoolbox.c
@@ -138,6 +138,17 @@ static void uninit(struct lavc_ctx *ctx)
ctx->hwdec_priv = NULL;
}
+static int mp_imgfmt_from_cvpixelformat(uint32_t cvpixfmt)
+{
+ switch (cvpixfmt) {
+ case kCVPixelFormatType_420YpCbCr8Planar: return IMGFMT_420P;
+ case kCVPixelFormatType_422YpCbCr8: return IMGFMT_UYVY;
+ case kCVPixelFormatType_32BGRA: return IMGFMT_RGB0;
+ case kCVPixelFormatType_420YpCbCr8BiPlanarVideoRange: return IMGFMT_NV12;
+ }
+ return 0;
+}
+
static struct mp_image *copy_image(struct lavc_ctx *ctx, struct mp_image *hw_image)
{
if (hw_image->imgfmt != IMGFMT_VIDEOTOOLBOX)
@@ -150,23 +161,9 @@ static struct mp_image *copy_image(struct lavc_ctx *ctx, struct mp_image *hw_ima
size_t width = CVPixelBufferGetWidth(pbuf);
size_t height = CVPixelBufferGetHeight(pbuf);
uint32_t cvpixfmt = CVPixelBufferGetPixelFormatType(pbuf);
- int pixfmt = 0;
- switch (cvpixfmt) {
- case kCVPixelFormatType_420YpCbCr8Planar:
- pixfmt = IMGFMT_420P;
- break;
- case kCVPixelFormatType_422YpCbCr8:
- pixfmt = IMGFMT_UYVY;
- break;
- case kCVPixelFormatType_32BGRA:
- pixfmt = IMGFMT_RGB0;
- break;
- case kCVPixelFormatType_420YpCbCr8BiPlanarVideoRange:
- pixfmt = IMGFMT_NV12;
- break;
- default:
+ int pixfmt = mp_imgfmt_from_cvpixelformat(cvpixfmt);
+ if (!pixfmt)
goto unlock;
- }
struct mp_image img = {0};
mp_image_setfmt(&img, pixfmt);
@@ -202,7 +199,8 @@ static struct mp_image *process_image(struct lavc_ctx *ctx, struct mp_image *img
{
if (img->imgfmt == IMGFMT_VIDEOTOOLBOX) {
CVPixelBufferRef pbuf = (CVPixelBufferRef)img->planes[3];
- img->params.hw_subfmt = CVPixelBufferGetPixelFormatType(pbuf);
+ uint32_t cvpixfmt = CVPixelBufferGetPixelFormatType(pbuf);
+ img->params.hw_subfmt = mp_imgfmt_from_cvpixelformat(cvpixfmt);
}
return img;
}
diff --git a/video/mp_image.c b/video/mp_image.c
index a4ce6d1cc5..531565f837 100644
--- a/video/mp_image.c
+++ b/video/mp_image.c
@@ -512,7 +512,7 @@ char *mp_image_params_to_str_buf(char *b, size_t bs,
mp_snprintf_cat(b, bs, " [%d:%d]", p->p_w, p->p_h);
mp_snprintf_cat(b, bs, " %s", mp_imgfmt_to_name(p->imgfmt));
if (p->hw_subfmt)
- mp_snprintf_cat(b, bs, "[%llu]", (unsigned long long)(p->hw_subfmt));
+ mp_snprintf_cat(b, bs, "[%s]", mp_imgfmt_to_name(p->hw_subfmt));
mp_snprintf_cat(b, bs, " %s/%s",
m_opt_choice_str(mp_csp_names, p->color.space),
m_opt_choice_str(mp_csp_levels_names, p->color.levels));
diff --git a/video/mp_image.h b/video/mp_image.h
index dfbe4ee0ba..13e364ae24 100644
--- a/video/mp_image.h
+++ b/video/mp_image.h
@@ -39,8 +39,7 @@
// usually copy the whole struct, so that fields added later will be preserved.
struct mp_image_params {
enum mp_imgfmt imgfmt; // pixel format
- uint64_t hw_subfmt; // underlying format for some hwaccel pixfmts
- // (will use the HW API's format identifiers)
+ enum mp_imgfmt hw_subfmt; // underlying format for some hwaccel pixfmts
int w, h; // image dimensions
int p_w, p_h; // define pixel aspect ratio (undefined: 0/0)
struct mp_colorspace color;
diff --git a/video/out/opengl/hwdec_osx.c b/video/out/opengl/hwdec_osx.c
index 6ddfa66e0a..17399a80f4 100644
--- a/video/out/opengl/hwdec_osx.c
+++ b/video/out/opengl/hwdec_osx.c
@@ -186,7 +186,7 @@ static int reinit(struct gl_hwdec *hw, struct mp_image_params *params)
{
assert(params->imgfmt == hw->driver->imgfmt);
- struct vt_format *f = vt_get_gl_format(params->hw_subfmt);
+ struct vt_format *f = vt_get_gl_format_from_imgfmt(params->hw_subfmt);
if (!f) {
MP_ERR(hw, "Unsupported CVPixelBuffer format.\n");
return -1;
diff --git a/video/out/opengl/hwdec_vaegl.c b/video/out/opengl/hwdec_vaegl.c
index 6c52cdde11..1de5969bc4 100644
--- a/video/out/opengl/hwdec_vaegl.c
+++ b/video/out/opengl/hwdec_vaegl.c
@@ -250,17 +250,16 @@ static int reinit(struct gl_hwdec *hw, struct mp_image_params *params)
}
gl->BindTexture(GL_TEXTURE_2D, 0);
- p->current_mpfmt = va_fourcc_to_imgfmt(params->hw_subfmt);
+ p->current_mpfmt = params->hw_subfmt;
if (p->current_mpfmt != IMGFMT_NV12 &&
p->current_mpfmt != IMGFMT_420P)
{
MP_FATAL(p, "unsupported VA image format %s\n",
- mp_tag_str(params->hw_subfmt));
+ mp_imgfmt_to_name(p->current_mpfmt));
return -1;
}
- MP_VERBOSE(p, "format: %s %s\n", mp_tag_str(params->hw_subfmt),
- mp_imgfmt_to_name(p->current_mpfmt));
+ MP_VERBOSE(p, "hw format: %s\n", mp_imgfmt_to_name(p->current_mpfmt));
params->imgfmt = p->current_mpfmt;
diff --git a/video/vaapi.c b/video/vaapi.c
index f8d0faba34..604fffa738 100644
--- a/video/vaapi.c
+++ b/video/vaapi.c
@@ -509,7 +509,7 @@ void va_surface_init_subformat(struct mp_image *mpi)
if (status != VA_STATUS_SUCCESS)
goto err;
- mpi->params.hw_subfmt = va_image.format.fourcc;
+ mpi->params.hw_subfmt = va_fourcc_to_imgfmt(va_image.format.fourcc);
status = vaDestroyImage(p->display, va_image.image_id);
CHECK_VA_STATUS(p->ctx, "vaDestroyImage()");