hdr dolby vision video color correction to 8 bit still images

Hey guys, tried to follow the super confusing doc on this, but no luck yet.

https://developer.apple.com/av-foundation/Incorporating-HDR-video-with-Dolby-Vision-into-your-apps.pdf

I have code that uses AVAssetReader and AVAssetReaderTrackOutput to directly pull frames from a video, but the colors are wrong for HDR dolby videos. Basically what I want is to extract frames from an HDR Dolby video as images and have those images not be the wrong color. Don't care if they are only 8 bit per color instead of 10 and all the all new stuff, just the closest that old fashioned 8 bit per color supports.

I added the statement marked // added for dolby hdr per the above doc, (spread across several lines), no luck, still bad colors.

Any hints of what I am missing?

NSMutableDictionary* dictionary = [[NSMutableDictionary alloc] init];

                               [dictionary setObject:[NSNumber numberWithInt:kCVPixelFormatType_32BGRA] forKey:(NSString*)kCVPixelBufferPixelFormatTypeKey];

               // added for dolby hdr

               dictionary[AVVideoColorPropertiesKey] = @{

                AVVideoColorPrimariesKey: AVVideoColorPrimaries_ITU_R_709_2,

                AVVideoTransferFunctionKey: AVVideoTransferFunction_ITU_R_709_2,

                AVVideoYCbCrMatrixKey: AVVideoYCbCrMatrix_ITU_R_709_2

                };

              

                AVAssetReaderTrackOutput* asset_reader_output = [[AVAssetReaderTrackOutput alloc] initWithTrack:video_track outputSettings:dictionary];

                

                [asset_reader addOutput:asset_reader_output];

// from here we get sample buffers like this

CMSampleBufferRef buffer2 = [asset_reader_output copyNextSampleBuffer];

// then pixel buffer

 CVPixelBufferRef inputPixelBuffer = CMSampleBufferGetImageBuffer(buffer2);

// then a CIImage

  CIImage* ciImage = [CIImage imageWithCVPixelBuffer:inputPixelBuffer]; // one vid frame

then we use standard stuff to convert that to a CGImage/UIImage