From 0a9adee00b5be463f6cd5729e337750625950887 Mon Sep 17 00:00:00 2001 From: Damiano Galassi Date: Wed, 30 Nov 2016 10:50:20 +0100 Subject: [PATCH] Set par to 1/1 nothing is set in MP42AVFImporter. --- MP42/MP42AVFImporter.m | 92 +++++++++++++++++++++++------------------- 1 file changed, 51 insertions(+), 41 deletions(-) diff --git a/MP42/MP42AVFImporter.m b/MP42/MP42AVFImporter.m index 7cec770..1082d14 100644 --- a/MP42/MP42AVFImporter.m +++ b/MP42/MP42AVFImporter.m @@ -138,6 +138,10 @@ videoTrack.hSpacing = hSpacing; videoTrack.vSpacing = vSpacing; } + else { + videoTrack.hSpacing = 1; + videoTrack.vSpacing = 1; + } // Reads the clean aperture information CFDictionaryRef cleanApertureFromCMFormatDescription = CMFormatDescriptionGetExtension(formatDescription, kCMFormatDescriptionExtension_CleanAperture); @@ -167,55 +171,61 @@ // Color CFStringRef colorPrimaries = CMFormatDescriptionGetExtension(formatDescription, kCMFormatDescriptionExtension_ColorPrimaries); - if (CFEqual(colorPrimaries, kCMFormatDescriptionColorPrimaries_ITU_R_709_2)) { - videoTrack.colorPrimaries = 1; - } - else if (CFEqual(colorPrimaries, kCMFormatDescriptionColorPrimaries_EBU_3213)) { - videoTrack.colorPrimaries = 5; - } - else if (CFEqual(colorPrimaries, kCMFormatDescriptionColorPrimaries_SMPTE_C)) { - videoTrack.colorPrimaries = 6; - } - else if (CFEqual(colorPrimaries, kCMFormatDescriptionColorPrimaries_ITU_R_2020)) { - videoTrack.colorPrimaries = 9; - } - else if (CFEqual(colorPrimaries, kCMFormatDescriptionColorPrimaries_DCI_P3)) { - videoTrack.colorPrimaries = 11; - } - else if (CFEqual(colorPrimaries, kCMFormatDescriptionColorPrimaries_P3_D65)) { - videoTrack.colorPrimaries = 12; - } - else if (CFEqual(colorPrimaries, kCMFormatDescriptionColorPrimaries_P22)) { - // ??? - videoTrack.colorPrimaries = 1; + if (colorPrimaries) { + if (CFEqual(colorPrimaries, kCMFormatDescriptionColorPrimaries_ITU_R_709_2)) { + videoTrack.colorPrimaries = 1; + } + else if (CFEqual(colorPrimaries, kCMFormatDescriptionColorPrimaries_EBU_3213)) { + videoTrack.colorPrimaries = 5; + } + else if (CFEqual(colorPrimaries, kCMFormatDescriptionColorPrimaries_SMPTE_C)) { + videoTrack.colorPrimaries = 6; + } + else if (CFEqual(colorPrimaries, kCMFormatDescriptionColorPrimaries_ITU_R_2020)) { + videoTrack.colorPrimaries = 9; + } + else if (CFEqual(colorPrimaries, kCMFormatDescriptionColorPrimaries_DCI_P3)) { + videoTrack.colorPrimaries = 11; + } + else if (CFEqual(colorPrimaries, kCMFormatDescriptionColorPrimaries_P3_D65)) { + videoTrack.colorPrimaries = 12; + } + else if (CFEqual(colorPrimaries, kCMFormatDescriptionColorPrimaries_P22)) { + // ??? + videoTrack.colorPrimaries = 1; + } } CFStringRef transferFunctions = CMFormatDescriptionGetExtension(formatDescription, kCMFormatDescriptionExtension_TransferFunction); - if (CFEqual(transferFunctions, kCMFormatDescriptionTransferFunction_ITU_R_709_2) || - CFEqual(transferFunctions, kCMFormatDescriptionTransferFunction_ITU_R_2020)) { - videoTrack.transferCharacteristics = 1; - } - else if (CFEqual(transferFunctions, kCMFormatDescriptionTransferFunction_SMPTE_240M_1995)) { - videoTrack.transferCharacteristics = 7; - } - else if (CFEqual(transferFunctions, kCMFormatDescriptionTransferFunction_SMPTE_ST_428_1)) { - videoTrack.transferCharacteristics = 17; + if (transferFunctions) { + if (CFEqual(transferFunctions, kCMFormatDescriptionTransferFunction_ITU_R_709_2) || + CFEqual(transferFunctions, kCMFormatDescriptionTransferFunction_ITU_R_2020)) { + videoTrack.transferCharacteristics = 1; + } + else if (CFEqual(transferFunctions, kCMFormatDescriptionTransferFunction_SMPTE_240M_1995)) { + videoTrack.transferCharacteristics = 7; + } + else if (CFEqual(transferFunctions, kCMFormatDescriptionTransferFunction_SMPTE_ST_428_1)) { + videoTrack.transferCharacteristics = 17; + } } CFStringRef YCbCrMatrix = CMFormatDescriptionGetExtension(formatDescription, kCMFormatDescriptionExtension_YCbCrMatrix); - if (CFEqual(YCbCrMatrix, kCMFormatDescriptionYCbCrMatrix_ITU_R_709_2)) { - videoTrack.matrixCoefficients = 1; - } - else if (CFEqual(YCbCrMatrix, kCMFormatDescriptionYCbCrMatrix_ITU_R_601_4)) { - videoTrack.matrixCoefficients = 6; - } - else if (CFEqual(YCbCrMatrix, kCMFormatDescriptionYCbCrMatrix_SMPTE_240M_1995)) { - videoTrack.matrixCoefficients = 7; - } - else if (CFEqual(YCbCrMatrix, kCMFormatDescriptionYCbCrMatrix_ITU_R_2020)) { - videoTrack.matrixCoefficients = 9; + if (YCbCrMatrix) { + if (CFEqual(YCbCrMatrix, kCMFormatDescriptionYCbCrMatrix_ITU_R_709_2)) { + videoTrack.matrixCoefficients = 1; + } + else if (CFEqual(YCbCrMatrix, kCMFormatDescriptionYCbCrMatrix_ITU_R_601_4)) { + videoTrack.matrixCoefficients = 6; + } + else if (CFEqual(YCbCrMatrix, kCMFormatDescriptionYCbCrMatrix_SMPTE_240M_1995)) { + videoTrack.matrixCoefficients = 7; + } + else if (CFEqual(YCbCrMatrix, kCMFormatDescriptionYCbCrMatrix_ITU_R_2020)) { + videoTrack.matrixCoefficients = 9; + } } } newTrack = videoTrack;