diff --git a/videodecoder/Info.plist b/videodecoder/Info.plist index 0747c39..3012690 100644 --- a/videodecoder/Info.plist +++ b/videodecoder/Info.plist @@ -111,6 +111,12 @@ CodecType AFLC + + CodecName + NotchLC + CodecType + nclc + CodecName Indeo 2 diff --git a/videodecoder/videodecoder.swift b/videodecoder/videodecoder.swift index 7f722ae..d3596e6 100644 --- a/videodecoder/videodecoder.swift +++ b/videodecoder/videodecoder.swift @@ -42,6 +42,7 @@ class VideoDecoder: NSObject, MEVideoDecoder { 0x4458_4433: AV_CODEC_ID_DXV, // 'DXD3' 0x666C_6963: AV_CODEC_ID_FLIC, // 'flic' 0x4146_4C43: AV_CODEC_ID_FLIC, // 'AFLC' + 0x6e63_6c63: AV_CODEC_ID_NOTCHLC, // 'nclc' 0x5254_3231: AV_CODEC_ID_INDEO2, // 'RT21' 0x4956_3331: AV_CODEC_ID_INDEO3, // 'IV31' 0x4956_3332: AV_CODEC_ID_INDEO3, // 'IV32' @@ -227,6 +228,14 @@ class VideoDecoder: NSObject, MEVideoDecoder { } } } + case AV_CODEC_ID_NOTCHLC: + // NotchLC codec overwrites these with the same values in decode_init, but for consistency with + // other cases we set them here. + params.pointee.format = AV_PIX_FMT_YUVA444P.rawValue; + params.pointee.color_range = AVCOL_RANGE_JPEG + params.pointee.color_space = AVCOL_SPC_RGB // Note, should be BT709 but ffmpeg mislabels... + break + default: // Shouldn't get here logger.error( @@ -445,7 +454,7 @@ class VideoDecoder: NSObject, MEVideoDecoder { } // Fix up color info on the decoded frame - VideoDecoder.fixupColors(frame: frame!) + fixupColors(frame: frame!) var pixelBuffer: CVPixelBuffer do { @@ -522,10 +531,14 @@ class VideoDecoder: NSObject, MEVideoDecoder { // Infer color info from the decoded frame. Make educated guesses for unspecified values. // Mutates the frame's color_primaries, color_trc and colorspace fields in place. - class func fixupColors(frame: UnsafeMutablePointer) { + func fixupColors(frame: UnsafeMutablePointer) { // RGB space. Set color info in case we somehow end up on the zscale path. if frame.pointee.colorspace == AVCOL_SPC_RGB { + // FFmpeg decoder mislabels notchlc as RGB. + if self.dec_ctx?.pointee.codec_id == AV_CODEC_ID_NOTCHLC { + frame.pointee.colorspace = AVCOL_SPC_BT709 + } frame.pointee.color_range = AVCOL_RANGE_JPEG frame.pointee.color_primaries = AVCOL_PRI_BT709 frame.pointee.color_trc = AVCOL_TRC_IEC61966_2_1