From 7d17c00d8072286160dd8ae1b611e145cbc422f5 Mon Sep 17 00:00:00 2001 From: Damiano Galassi Date: Mon, 28 Nov 2016 12:49:10 +0100 Subject: [PATCH] Preliminary support of the colr atom. --- Classes/PropertyView/Base.lproj/VideoView.xib | 113 +++++++++++++----- Classes/PropertyView/SBVideoViewController.m | 78 +++++++++++- 2 files changed, 159 insertions(+), 32 deletions(-) diff --git a/Classes/PropertyView/Base.lproj/VideoView.xib b/Classes/PropertyView/Base.lproj/VideoView.xib index 23fdb93..2c0bdeb 100755 --- a/Classes/PropertyView/Base.lproj/VideoView.xib +++ b/Classes/PropertyView/Base.lproj/VideoView.xib @@ -1,14 +1,17 @@ - + - + + + + @@ -33,22 +36,22 @@ - + - + - + - + - + @@ -67,7 +70,7 @@ - + @@ -75,7 +78,7 @@ - + @@ -83,7 +86,7 @@ - + @@ -102,14 +105,14 @@ - + @@ -117,7 +120,7 @@ - + @@ -136,7 +139,7 @@ - + @@ -147,7 +150,7 @@ - + @@ -155,7 +158,7 @@ - + @@ -163,7 +166,7 @@ - + @@ -171,7 +174,7 @@ - + @@ -182,7 +185,7 @@ - + @@ -201,7 +204,7 @@ - + @@ -209,7 +212,7 @@ - + @@ -217,7 +220,7 @@ - + @@ -236,7 +239,7 @@ - + @@ -255,7 +258,7 @@ - + @@ -277,7 +280,7 @@ - + @@ -285,7 +288,7 @@ - + @@ -293,7 +296,7 @@ - + @@ -301,7 +304,7 @@ - + @@ -309,7 +312,7 @@ - + @@ -444,12 +447,56 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + @@ -459,6 +506,7 @@ + @@ -478,15 +526,18 @@ + - + + + @@ -527,7 +578,7 @@ - + diff --git a/Classes/PropertyView/SBVideoViewController.m b/Classes/PropertyView/SBVideoViewController.m index 5722005..1e37bab 100755 --- a/Classes/PropertyView/SBVideoViewController.m +++ b/Classes/PropertyView/SBVideoViewController.m @@ -20,6 +20,11 @@ @property (nonatomic, strong) IBOutlet NSView *profileView; @property (nonatomic, weak) IBOutlet NSLayoutConstraint *profileHeight; +@property (nonatomic, strong) IBOutlet NSView *colorView; +@property (nonatomic, weak) IBOutlet NSLayoutConstraint *colorHeight; + +@property (nonatomic, weak) IBOutlet NSPopUpButton *colorProfilePopUp; + @end @implementation SBVideoViewController @@ -102,6 +107,27 @@ static NSString *getLevelName(uint8_t level) { } } +static NSString *getColorProfileName(uint16_t colorPrimaries, + uint16_t transferCharacteristics, + uint16_t matrixCoefficients) { + if (colorPrimaries == 0 && transferCharacteristics == 0 && matrixCoefficients == 0) { + return NSLocalizedString(@"Implicit", @"Implicit color profile"); + } + else if (colorPrimaries == 1 && transferCharacteristics == 1 && matrixCoefficients == 1) { + return NSLocalizedString(@"Rec. 709 (1-1-1)", @"Implicit color profile"); + } + else if (colorPrimaries == 9 && transferCharacteristics == 1 && matrixCoefficients == 9) { + return NSLocalizedString(@"Rec. 2020 (9-1-9)", @"color profile"); + } + if (colorPrimaries == 5 && transferCharacteristics == 1 && matrixCoefficients == 6) { + return NSLocalizedString(@"Rec. 601 (5-1-6)", @"color profile"); + } + if (colorPrimaries == 6 && transferCharacteristics == 1 && matrixCoefficients == 6) { + return NSLocalizedString(@"Rec. 601 (6-1-6)", @"color profile"); + } + return [NSString stringWithFormat:@"%d-%d-%d", colorPrimaries, transferCharacteristics, matrixCoefficients]; +} + - (void)loadView { [super loadView]; @@ -148,6 +174,21 @@ static NSString *getLevelName(uint8_t level) { self.profileHeight.constant = 0; } + if (track.format == kMP42VideoCodecType_H264 || track.format == kMP42VideoCodecType_MPEG4Video || + track.format == kMP42VideoCodecType_HEVC || track.format == kMP42VideoCodecType_HEVC_2) { + NSString *colorProfile = getColorProfileName(track.colorPrimaries, track.transferCharacteristics, track.matrixCoefficients); + [self.colorProfilePopUp selectItemWithTitle:colorProfile]; + + if (self.colorProfilePopUp.indexOfSelectedItem == -1) { + [self.colorProfilePopUp addItemWithTitle:colorProfile]; + [self.colorProfilePopUp selectItemWithTitle:colorProfile]; + } + } + else { + self.colorView.hidden = YES; + self.colorHeight.constant = 0; + } + if ([track isKindOfClass:[MP42SubtitleTrack class]]) { MP42SubtitleTrack * subTrack = (MP42SubtitleTrack*)track; @@ -263,7 +304,6 @@ static NSString *getLevelName(uint8_t level) { } } - - (IBAction)setAltenateGroup:(id)sender { NSInteger tagName = [sender selectedItem].tag; @@ -274,6 +314,42 @@ static NSString *getLevelName(uint8_t level) { } } +- (IBAction)setColorProfile:(id)sender +{ + NSInteger tagName = [sender selectedItem].tag; + switch (tagName) { + case 1: + track.colorPrimaries = 0; + track.transferCharacteristics = 0; + track.matrixCoefficients = 0; + break; + case 2: + track.colorPrimaries = 5; + track.transferCharacteristics = 1; + track.matrixCoefficients = 6; + break; + case 3: + track.colorPrimaries = 6; + track.transferCharacteristics = 1; + track.matrixCoefficients = 6; + break; + case 4: + track.colorPrimaries = 1; + track.transferCharacteristics = 1; + track.matrixCoefficients = 1; + break; + case 5: + track.colorPrimaries = 9; + track.transferCharacteristics = 1; + track.matrixCoefficients = 9; + break; + default: + return; + } + + [self.view.window.windowController.document updateChangeCount:NSChangeDone]; +} + - (IBAction)setProfileLevel:(id)sender { NSInteger tagName = [sender selectedItem].tag;