diff options
author | Akemi <der.richter@gmx.de> | 2019-04-13 16:36:01 +0200 |
---|---|---|
committer | Aman Gupta <aman@tmm1.net> | 2019-09-04 10:51:20 -0700 |
commit | 2a9d461abcc88ab74f2143aada1e366a0961830c (patch) | |
tree | d341c55f70bf1a79f5737cdd7b233d965d5e54f4 /libavutil | |
parent | 787c56b9e9e5f9a1b82d2b47f26e8b0924781599 (diff) | |
download | ffmpeg-2a9d461abcc88ab74f2143aada1e366a0961830c.tar.gz |
avcodec/videotoolbox: add support for full range pixel formats
Signed-off-by: Aman Gupta <aman@tmm1.net>
Diffstat (limited to 'libavutil')
-rw-r--r-- | libavutil/hwcontext_videotoolbox.c | 20 | ||||
-rw-r--r-- | libavutil/hwcontext_videotoolbox.h | 6 |
2 files changed, 20 insertions, 6 deletions
diff --git a/libavutil/hwcontext_videotoolbox.c b/libavutil/hwcontext_videotoolbox.c index 6eac2c0774..bded9873fe 100644 --- a/libavutil/hwcontext_videotoolbox.c +++ b/libavutil/hwcontext_videotoolbox.c @@ -34,16 +34,19 @@ static const struct { uint32_t cv_fmt; + bool full_range; enum AVPixelFormat pix_fmt; } cv_pix_fmts[] = { - { kCVPixelFormatType_420YpCbCr8Planar, AV_PIX_FMT_YUV420P }, - { kCVPixelFormatType_422YpCbCr8, AV_PIX_FMT_UYVY422 }, - { kCVPixelFormatType_32BGRA, AV_PIX_FMT_BGRA }, + { kCVPixelFormatType_420YpCbCr8Planar, false, AV_PIX_FMT_YUV420P }, + { kCVPixelFormatType_422YpCbCr8, false, AV_PIX_FMT_UYVY422 }, + { kCVPixelFormatType_32BGRA, false, AV_PIX_FMT_BGRA }, #ifdef kCFCoreFoundationVersionNumber10_7 - { kCVPixelFormatType_420YpCbCr8BiPlanarVideoRange, AV_PIX_FMT_NV12 }, + { kCVPixelFormatType_420YpCbCr8BiPlanarVideoRange, false, AV_PIX_FMT_NV12 }, + { kCVPixelFormatType_420YpCbCr8BiPlanarFullRange, true, AV_PIX_FMT_NV12 }, #endif #if HAVE_KCVPIXELFORMATTYPE_420YPCBCR10BIPLANARVIDEORANGE - { kCVPixelFormatType_420YpCbCr10BiPlanarVideoRange, AV_PIX_FMT_P010 }, + { kCVPixelFormatType_420YpCbCr10BiPlanarVideoRange, false, AV_PIX_FMT_P010 }, + { kCVPixelFormatType_420YpCbCr10BiPlanarFullRange, true, AV_PIX_FMT_P010 }, #endif }; @@ -59,9 +62,14 @@ enum AVPixelFormat av_map_videotoolbox_format_to_pixfmt(uint32_t cv_fmt) uint32_t av_map_videotoolbox_format_from_pixfmt(enum AVPixelFormat pix_fmt) { + return av_map_videotoolbox_format_from_pixfmt2(pix_fmt, false); +} + +uint32_t av_map_videotoolbox_format_from_pixfmt2(enum AVPixelFormat pix_fmt, bool full_range) +{ int i; for (i = 0; i < FF_ARRAY_ELEMS(cv_pix_fmts); i++) { - if (cv_pix_fmts[i].pix_fmt == pix_fmt) + if (cv_pix_fmts[i].pix_fmt == pix_fmt && cv_pix_fmts[i].full_range == full_range) return cv_pix_fmts[i].cv_fmt; } return 0; diff --git a/libavutil/hwcontext_videotoolbox.h b/libavutil/hwcontext_videotoolbox.h index 380918d92e..5074d79e68 100644 --- a/libavutil/hwcontext_videotoolbox.h +++ b/libavutil/hwcontext_videotoolbox.h @@ -51,4 +51,10 @@ enum AVPixelFormat av_map_videotoolbox_format_to_pixfmt(uint32_t cv_fmt); */ uint32_t av_map_videotoolbox_format_from_pixfmt(enum AVPixelFormat pix_fmt); +/** + * Same as av_map_videotoolbox_format_from_pixfmt function, but can map and + * return full range pixel formats via a flag. + */ +uint32_t av_map_videotoolbox_format_from_pixfmt2(enum AVPixelFormat pix_fmt, bool full_range); + #endif /* AVUTIL_HWCONTEXT_VIDEOTOOLBOX_H */ |