diff options
author | wm4 <wm4@nowhere> | 2016-07-15 11:54:44 +0200 |
---|---|---|
committer | wm4 <wm4@nowhere> | 2016-07-15 13:04:17 +0200 |
commit | 85488f68928ed40020e545b736118e0273e06cd1 (patch) | |
tree | e9e6344f5eff9206a08bc2732dd411fe56269ae7 /video/decode | |
parent | 4a4a9f330281ad11eb39a013bf7308063767bab8 (diff) | |
download | mpv-85488f68928ed40020e545b736118e0273e06cd1.tar.bz2 mpv-85488f68928ed40020e545b736118e0273e06cd1.tar.xz |
video: change hw_subfmt meaning
The hw_subfmt field roughly corresponds to the field
AVHWFramesContext.sw_format in ffmpeg. The ffmpeg one is of the type
AVPixelFormat (instead of the underlying hardware format), so it's a
good idea to switch to this too for preparation.
Now the hw_subfmt field is an mp_imgfmt instead of an opaque/API-
specific number. VDPAU and Direct3D11 already used mp_imgfmt, but
Videotoolbox and VAAPI had to be switched.
One somewhat user-visible change is that the verbose log will now always
show the hw_subfmt as image format, instead of as nonsensical number.
(In the end it would be good if we could switch to AVHWFramesContext
completely, but the upstream API is incomplete and doesn't cover
Direct3D11 and Videotoolbox.)
Diffstat (limited to 'video/decode')
-rw-r--r-- | video/decode/videotoolbox.c | 32 |
1 files changed, 15 insertions, 17 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; } |