[vlc-commits] codec: videotoolbox: don't use VT colorimetry
Thomas Guillem
git at videolan.org
Wed Sep 13 11:15:27 CEST 2017
vlc | branch: master | Thomas Guillem <thomas at gllm.fr> | Wed Sep 13 11:10:15 2017 +0200| [eb9fe5ad0866dd05a9023746960ffea3e0243ecd] | committer: Thomas Guillem
codec: videotoolbox: don't use VT colorimetry
It's always the same: kCVImageBufferYCbCrMatrix_ITU_R_601_4 for SD or HD
content and doesn't match the value in the SPS.
When unknown, it's better to don't set the colorimetry and let
video_format_AdjustColorSpace() (called by the core) guess it.
> http://git.videolan.org/gitweb.cgi/vlc.git/?a=commit;h=eb9fe5ad0866dd05a9023746960ffea3e0243ecd
---
modules/codec/videotoolbox.m | 79 +++++++++++++-------------------------------
1 file changed, 23 insertions(+), 56 deletions(-)
diff --git a/modules/codec/videotoolbox.m b/modules/codec/videotoolbox.m
index 2ac35149d2..aa56aae0f7 100644
--- a/modules/codec/videotoolbox.m
+++ b/modules/codec/videotoolbox.m
@@ -1494,65 +1494,32 @@ static int UpdateVideoFormat(decoder_t *p_dec, CVPixelBufferRef imageBuffer)
{
CFDictionaryRef attachments = CVBufferGetAttachments(imageBuffer, kCVAttachmentMode_ShouldPropagate);
NSDictionary *attachmentDict = (NSDictionary *)attachments;
-#ifndef NDEBUG
- NSLog(@"%@", attachments);
-#endif
- if (attachmentDict == nil || attachmentDict.count == 0)
- return -1;
-
- NSString *colorSpace = attachmentDict[(NSString *)kCVImageBufferYCbCrMatrixKey];
- if (colorSpace != nil) {
- if ([colorSpace isEqualToString:(NSString *)kCVImageBufferYCbCrMatrix_ITU_R_601_4])
- p_dec->fmt_out.video.space = COLOR_SPACE_BT601;
- else if ([colorSpace isEqualToString:(NSString *)kCVImageBufferYCbCrMatrix_ITU_R_709_2])
- p_dec->fmt_out.video.space = COLOR_SPACE_BT709;
- else
- p_dec->fmt_out.video.space = COLOR_SPACE_UNDEF;
- }
- NSString *colorprimary = attachmentDict[(NSString *)kCVImageBufferColorPrimariesKey];
- if (colorprimary != nil) {
- if ([colorprimary isEqualToString:(NSString *)kCVImageBufferColorPrimaries_SMPTE_C] ||
- [colorprimary isEqualToString:(NSString *)kCVImageBufferColorPrimaries_EBU_3213])
- p_dec->fmt_out.video.primaries = COLOR_PRIMARIES_BT601_625;
- else if ([colorprimary isEqualToString:(NSString *)kCVImageBufferColorPrimaries_ITU_R_709_2])
- p_dec->fmt_out.video.primaries = COLOR_PRIMARIES_BT709;
- else if ([colorprimary isEqualToString:(NSString *)kCVImageBufferColorPrimaries_P22])
- p_dec->fmt_out.video.primaries = COLOR_PRIMARIES_DCI_P3;
- else
- p_dec->fmt_out.video.primaries = COLOR_PRIMARIES_UNDEF;
- }
- NSString *transfer = attachmentDict[(NSString *)kCVImageBufferTransferFunctionKey];
- if (transfer != nil) {
- if ([transfer isEqualToString:(NSString *)kCVImageBufferTransferFunction_ITU_R_709_2] ||
- [transfer isEqualToString:(NSString *)kCVImageBufferTransferFunction_SMPTE_240M_1995])
- p_dec->fmt_out.video.transfer = TRANSFER_FUNC_BT709;
- else
- p_dec->fmt_out.video.transfer = TRANSFER_FUNC_UNDEF;
- }
-
- NSString *chromaLocation = attachmentDict[(NSString *)kCVImageBufferChromaLocationTopFieldKey];
- if (chromaLocation != nil) {
- if ([chromaLocation isEqualToString:(NSString *)kCVImageBufferChromaLocation_Left] ||
- [chromaLocation isEqualToString:(NSString *)kCVImageBufferChromaLocation_DV420])
- p_dec->fmt_out.video.chroma_location = CHROMA_LOCATION_LEFT;
- else if ([chromaLocation isEqualToString:(NSString *)kCVImageBufferChromaLocation_Center])
- p_dec->fmt_out.video.chroma_location = CHROMA_LOCATION_CENTER;
- else if ([chromaLocation isEqualToString:(NSString *)kCVImageBufferChromaLocation_TopLeft])
- p_dec->fmt_out.video.chroma_location = CHROMA_LOCATION_TOP_LEFT;
- else if ([chromaLocation isEqualToString:(NSString *)kCVImageBufferChromaLocation_Top])
- p_dec->fmt_out.video.chroma_location = CHROMA_LOCATION_TOP_CENTER;
- else
- p_dec->fmt_out.video.chroma_location = CHROMA_LOCATION_UNDEF;
- }
- if (p_dec->fmt_out.video.chroma_location == CHROMA_LOCATION_UNDEF) {
- chromaLocation = attachmentDict[(NSString *)kCVImageBufferChromaLocationBottomFieldKey];
+ if (attachmentDict != nil && attachmentDict.count > 0
+ && p_dec->fmt_out.video.chroma_location == CHROMA_LOCATION_UNDEF)
+ {
+ NSString *chromaLocation = attachmentDict[(NSString *)kCVImageBufferChromaLocationTopFieldKey];
if (chromaLocation != nil) {
- if ([chromaLocation isEqualToString:(NSString *)kCVImageBufferChromaLocation_BottomLeft])
- p_dec->fmt_out.video.chroma_location = CHROMA_LOCATION_BOTTOM_LEFT;
- else if ([chromaLocation isEqualToString:(NSString *)kCVImageBufferChromaLocation_Bottom])
- p_dec->fmt_out.video.chroma_location = CHROMA_LOCATION_BOTTOM_CENTER;
+ if ([chromaLocation isEqualToString:(NSString *)kCVImageBufferChromaLocation_Left] ||
+ [chromaLocation isEqualToString:(NSString *)kCVImageBufferChromaLocation_DV420])
+ p_dec->fmt_out.video.chroma_location = CHROMA_LOCATION_LEFT;
+ else if ([chromaLocation isEqualToString:(NSString *)kCVImageBufferChromaLocation_Center])
+ p_dec->fmt_out.video.chroma_location = CHROMA_LOCATION_CENTER;
+ else if ([chromaLocation isEqualToString:(NSString *)kCVImageBufferChromaLocation_TopLeft])
+ p_dec->fmt_out.video.chroma_location = CHROMA_LOCATION_TOP_LEFT;
+ else if ([chromaLocation isEqualToString:(NSString *)kCVImageBufferChromaLocation_Top])
+ p_dec->fmt_out.video.chroma_location = CHROMA_LOCATION_TOP_CENTER;
+ }
+ if (p_dec->fmt_out.video.chroma_location == CHROMA_LOCATION_UNDEF)
+ {
+ chromaLocation = attachmentDict[(NSString *)kCVImageBufferChromaLocationBottomFieldKey];
+ if (chromaLocation != nil) {
+ if ([chromaLocation isEqualToString:(NSString *)kCVImageBufferChromaLocation_BottomLeft])
+ p_dec->fmt_out.video.chroma_location = CHROMA_LOCATION_BOTTOM_LEFT;
+ else if ([chromaLocation isEqualToString:(NSString *)kCVImageBufferChromaLocation_Bottom])
+ p_dec->fmt_out.video.chroma_location = CHROMA_LOCATION_BOTTOM_CENTER;
+ }
}
}
More information about the vlc-commits
mailing list