Hi all, This series adds a decoder for TICO RAW, the intoPIX codec that Nikon uses for its raw video clips: R3D NE (.R3D, Nikon ZR, fourcc NR3D) and N-RAW (.NEV, Z8/Z9/Z6III, fourcc NRAW). The mov demuxer already reads these files; only the decoder is missing.
Motivation: these clips are hard to view on a Mac today, and in my experience RED's own REDCINE-X offers no GPU decoding for R3D NE. With a decoder in FFmpeg, every tool built on it can decode these files. What the decoder does - Outputs the sensor data as Bayer with 14-bit values, like the ProRes RAW and RW2 decoders. No debayering, no colour processing. - Exports black level, white balance and the colour matrix as AV_FRAME_DATA_RAW_COLOR_PARAMS with a new AV_RAW_COLOR_PARAMS_TICO_RAW type (patch 3), following the RW2 type added in e7420679a3. - Output is bayer_rggb16le written with AV_WL16, so the FATE CRC is the same on every host. - Frame threads and slice threads. On an Apple M-series Mac a 6060x3410 frame decodes in about 163 ms on one thread and about 25 ms with 8 slice threads (median, measured on the same decoder code in my fork: https://github.com/alperkaganavci/nikon-raw-playback/blob/main/docs/results.md). - Only the Nikon ZR profile is supported. Other profiles return AVERROR_PATCHWELCOME. Why a separate codec ID and not JPEG XS The codestream is JPEG XS based, but it is not a standard JPEG XS stream: it signals Cpih = 0 and still needs the inverse Star-Tetrix transform; the PIH carries vendor bytes with a square-root transfer curve; it has a vendor CAP string; and each frame is wrapped in a Nikon NRAW box with NRMT tags. Testing - The decoded Bayer planes match blue-compressor (an Apache-2.0 Rust decoder, used only as a black box) byte for byte on the test frames. - Two FATE tests (1 thread and 4 slice threads, same CRC). make fate without samples: 3169 run, 0 failed. - Damaged input: 38 corrupted files x 3 thread setups under ASan and UBSan, no reports. target_dec_tico_raw_fuzzer under ASan and UBSan with a simple mutation driver (libFuzzer was not available here): 600 s, 19,781 runs, no crash, OOM or timeout. A real libFuzzer run is still to do. - Tested only on arm64 macOS. Only one camera mode (ZR, 6060x3410, 25 fps) was available; N-RAW was tested only with a lossless rewrap of that clip. FATE sample ticoraw/nikon-zr-r3dne-cut.mov, 919,461 bytes, SHA-256 c817bcb091820db1548dc4448b15d9e8fa588e9775ca7c520c1c9e3f41e3771c. It is one frame cut to 6060x402 (6 full slices and a partial slice, with the headers rewritten to match): https://github.com/alperkaganavci/nikon-raw-playback/releases/download/fate-sample-ticoraw-1/nikon-zr-r3dne-cut.mov I shot this clip myself, and I allow unrestricted redistribution (CC0) in fate-suite. Two wrapper blocks (a maker-note-like block and one of unknown content) were zeroed; the decoded output is unchanged. How this code was written This code was written with AI assistance (Anthropic Claude). I directed the work and tested the results, and I take responsibility for the code and its licence. Because blue-compressor is Apache-2.0, the work used a clean-room split: one role read blue-compressor and wrote a facts-only format note; the decoder authors never read its source and worked from the note, FFmpeg's own code, the public standards and the clip bytes. SVT-JPEG-XS was only built and run as a black box in a study; no SVT code is in this series. A final review compared the decoder with the blue-compressor source and found no derivation. Record and format note: https://github.com/alperkaganavci/nikon-raw-playback/blob/main/docs/clean-room.md https://github.com/alperkaganavci/nikon-raw-playback/blob/main/docs/format/tico-raw-nikon.md Notes on the series - Patches 4 to 6 are split only for size (about 97 KB together, close to the list limit); 4 and 5 add files that are first built in patch 6. I can squash them if you prefer. - Questions: is the codec-specific raw colour params type fine, or do you want generic fields in AVRawColorParams? Would a later filter that applies the white balance, matrix and transfer curve from this side data be welcome? Thanks for reviewing, Alper Kagan AVCI Alper Kagan AVCI (7): avcodec: add TICO RAW codec ID and descriptor avformat/isom_tags: add the Nikon TICO RAW sample entry tags lavu/raw_color_params: add TICO RAW parameters avcodec/ticoraw: add the Nikon wrapper and codestream header parsers avcodec/ticoraw: add entropy decoding, inverse transforms and the core avcodec/ticoraw: add the TICO RAW decoder fate: add a TICO RAW decoder test Changelog | 1 + doc/APIchanges | 6 + doc/general_contents.texi | 3 + libavcodec/Makefile | 2 + libavcodec/allcodecs.c | 1 + libavcodec/codec_desc.c | 7 + libavcodec/codec_id.h | 1 + libavcodec/ticoraw_core.c | 353 +++++++++++++++++++++ libavcodec/ticoraw_core.h | 103 ++++++ libavcodec/ticoraw_dsp.c | 212 +++++++++++++ libavcodec/ticoraw_dsp.h | 70 ++++ libavcodec/ticoraw_entropy.c | 440 ++++++++++++++++++++++++++ libavcodec/ticoraw_entropy.h | 114 +++++++ libavcodec/ticoraw_header.c | 358 +++++++++++++++++++++ libavcodec/ticoraw_header.h | 104 ++++++ libavcodec/ticoraw_nraw.c | 396 +++++++++++++++++++++++ libavcodec/ticoraw_nraw.h | 51 +++ libavcodec/ticorawdec.c | 223 +++++++++++++ libavcodec/version.h | 2 +- libavformat/isom_tags.c | 3 + libavutil/raw_color_params.h | 42 +++ libavutil/version.h | 2 +- tests/Makefile | 1 + tests/fate/ticoraw.mak | 11 + tests/ref/fate/ticoraw-nikon-zr-r3dne | 6 + 25 files changed, 2510 insertions(+), 2 deletions(-) create mode 100644 libavcodec/ticoraw_core.c create mode 100644 libavcodec/ticoraw_core.h create mode 100644 libavcodec/ticoraw_dsp.c create mode 100644 libavcodec/ticoraw_dsp.h create mode 100644 libavcodec/ticoraw_entropy.c create mode 100644 libavcodec/ticoraw_entropy.h create mode 100644 libavcodec/ticoraw_header.c create mode 100644 libavcodec/ticoraw_header.h create mode 100644 libavcodec/ticoraw_nraw.c create mode 100644 libavcodec/ticoraw_nraw.h create mode 100644 libavcodec/ticorawdec.c create mode 100644 tests/fate/ticoraw.mak create mode 100644 tests/ref/fate/ticoraw-nikon-zr-r3dne -- 2.56.1 _______________________________________________ ffmpeg-devel mailing list -- [email protected] To unsubscribe send an email to [email protected]
