Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 6 additions & 0 deletions videodecoder/Info.plist
Original file line number Diff line number Diff line change
Expand Up @@ -111,6 +111,12 @@
<key>CodecType</key>
<string>AFLC</string>
</dict>
<dict>
<key>CodecName</key>
<string>NotchLC</string>
<key>CodecType</key>
<string>nclc</string>
</dict>
<dict>
<key>CodecName</key>
<string>Indeo 2</string>
Expand Down
17 changes: 15 additions & 2 deletions videodecoder/videodecoder.swift
Original file line number Diff line number Diff line change
Expand Up @@ -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'
Expand Down Expand Up @@ -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(
Expand Down Expand Up @@ -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 {
Expand Down Expand Up @@ -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<AVFrame>) {
func fixupColors(frame: UnsafeMutablePointer<AVFrame>) {

// 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
Comment thread
dev-joss marked this conversation as resolved.
}
frame.pointee.color_range = AVCOL_RANGE_JPEG
frame.pointee.color_primaries = AVCOL_PRI_BT709
frame.pointee.color_trc = AVCOL_TRC_IEC61966_2_1
Expand Down