PR #24386 opened by 06needhamt URL: https://code.ffmpeg.org/FFmpeg/FFmpeg/pulls/24386 Patch URL: https://code.ffmpeg.org/FFmpeg/FFmpeg/pulls/24386.patch
# Summary of changes Briefly describe what this PR does and why. <!-- If this PR requires new FATE test samples, attach them to the PR and list their target paths below (relative to the fate-suite root). Attached filenames must match the sample's filename: ```fate-samples # e.g. vorbis/new-sample.ogg ``` --> This PR adds an Infinity IMM6 video Decoder to libavcodec. IMM6 video can be decoded as standard H264 once the 24 byte infinity header has been removed. This decoder does just that. For the FATE test I have sent an email to [email protected] to get my sample added. I have also attached it to this PR. The path should be as below ```fate-samples imm6/imm6.avi ``` This completes the support for the IMM codec family in FFmpeg as IMM4 and IMM5 are already supported. >From 97ca6adfaf5fa95f755737e38e3faf3796348c47 Mon Sep 17 00:00:00 2001 From: Tom Needham <[email protected]> Date: Sat, 5 Sep 2026 22:19:14 +0000 Subject: [PATCH 1/3] libavcodec: Add Infinity IMM6 Decoder Signed-off-by: Tom Needham <[email protected]> --- Changelog | 1 + configure | 1 + doc/APIchanges | 3 + doc/general_contents.texi | 2 + libavcodec/Makefile | 1 + libavcodec/allcodecs.c | 1 + libavcodec/codec_desc.c | 7 ++ libavcodec/codec_id.h | 1 + libavcodec/imm6.c | 142 ++++++++++++++++++++++++++++++++++++++ libavcodec/version.h | 2 +- 10 files changed, 160 insertions(+), 1 deletion(-) create mode 100644 libavcodec/imm6.c diff --git a/Changelog b/Changelog index 5da3610497..52068372a3 100644 --- a/Changelog +++ b/Changelog @@ -12,6 +12,7 @@ version <next>: - AVFoundation input device selection by unique ID and USB serial number - NVIDIA optical flow accelerated interpolation filter (vf_fruc_vulkan) - H.264 data partitioning support +- Infinity IMM6 video decoder version 9.0: diff --git a/configure b/configure index 5fecdfd898..8cb6049f07 100755 --- a/configure +++ b/configure @@ -3234,6 +3234,7 @@ iac_decoder_select="imc_decoder" imc_decoder_select="bswapdsp sinewin" imm4_decoder_select="bswapdsp idctdsp" imm5_decoder_select="h264_decoder hevc_decoder" +imm6_decoder_select="h264_decoder" indeo3_decoder_select="hpeldsp" indeo4_decoder_select="ividsp" indeo5_decoder_select="ividsp" diff --git a/doc/APIchanges b/doc/APIchanges index 9cf1f85702..51d6b49917 100644 --- a/doc/APIchanges +++ b/doc/APIchanges @@ -2,6 +2,9 @@ The last version increases of all libraries were on 2026-06-23. API changes, most recent first: +2026-09-05 - xxxxxxxxxx - lavc 63.11.100 - codec_id.h + Add AV_CODEC_ID_IMM6. + 2026-09-01 - xxxxxxxxxx - lavc 63.10.100 - avcodec.h Add AVCodecContext.skip_pred. diff --git a/doc/general_contents.texi b/doc/general_contents.texi index d446391429..11f99e24c6 100644 --- a/doc/general_contents.texi +++ b/doc/general_contents.texi @@ -1077,6 +1077,8 @@ following image formats are supported: @item IFF ByteRun1 @tab @tab X @tab IFF run length encoded bitmap @item Infinity IMM4 @tab @tab X +@item Infinity IMM5 @tab @tab X +@item Infinity IMM6 @tab @tab X @item Intel H.263 @tab @tab X @item Intel Indeo 2 @tab @tab X @item Intel Indeo 3 @tab @tab X diff --git a/libavcodec/Makefile b/libavcodec/Makefile index 3cdfa4f383..5c9db2ad50 100644 --- a/libavcodec/Makefile +++ b/libavcodec/Makefile @@ -499,6 +499,7 @@ OBJS-$(CONFIG_ILBC_DECODER) += ilbcdec.o OBJS-$(CONFIG_IMC_DECODER) += imc.o OBJS-$(CONFIG_IMM4_DECODER) += imm4.o OBJS-$(CONFIG_IMM5_DECODER) += imm5.o +OBJS-$(CONFIG_IMM6_DECODER) += imm6.o OBJS-$(CONFIG_INDEO2_DECODER) += indeo2.o OBJS-$(CONFIG_INDEO3_DECODER) += indeo3.o OBJS-$(CONFIG_INDEO4_DECODER) += indeo4.o ivi.o diff --git a/libavcodec/allcodecs.c b/libavcodec/allcodecs.c index 2d7496a20d..fad0131b0c 100644 --- a/libavcodec/allcodecs.c +++ b/libavcodec/allcodecs.c @@ -173,6 +173,7 @@ extern const FFCodec ff_idcin_decoder; extern const FFCodec ff_iff_ilbm_decoder; extern const FFCodec ff_imm4_decoder; extern const FFCodec ff_imm5_decoder; +extern const FFCodec ff_imm6_decoder; extern const FFCodec ff_indeo2_decoder; extern const FFCodec ff_indeo3_decoder; extern const FFCodec ff_indeo4_decoder; diff --git a/libavcodec/codec_desc.c b/libavcodec/codec_desc.c index f5f2b17ec0..1bf38dedf5 100644 --- a/libavcodec/codec_desc.c +++ b/libavcodec/codec_desc.c @@ -1992,6 +1992,13 @@ static const AVCodecDescriptor codec_descriptors[] = { .props = AV_CODEC_PROP_LOSSY | AV_CODEC_PROP_LOSSLESS, .mime_types= MT("image/webp"), }, + { + .id = AV_CODEC_ID_IMM6, + .type = AVMEDIA_TYPE_VIDEO, + .name = "imm6", + .long_name = NULL_IF_CONFIG_SMALL("Infinity IMM6"), + .props = AV_CODEC_PROP_LOSSY, + }, /* various PCM "codecs" */ { diff --git a/libavcodec/codec_id.h b/libavcodec/codec_id.h index 7cafac610e..dfa8ca17b9 100644 --- a/libavcodec/codec_id.h +++ b/libavcodec/codec_id.h @@ -324,6 +324,7 @@ enum AVCodecID { AV_CODEC_ID_PRORES_RAW, AV_CODEC_ID_JPEGXS, AV_CODEC_ID_WEBP_ANIM, + AV_CODEC_ID_IMM6, /* various PCM "codecs" */ AV_CODEC_ID_FIRST_AUDIO = 0x10000, ///< A dummy id pointing at the start of audio codecs diff --git a/libavcodec/imm6.c b/libavcodec/imm6.c new file mode 100644 index 0000000000..99d05c57eb --- /dev/null +++ b/libavcodec/imm6.c @@ -0,0 +1,142 @@ +/* + * Infinity IMM6 video decoder + * + * Copyright (c) 2026 Tom Needham + * + * This file is part of FFmpeg. + * + * FFmpeg is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 2.1 of the License, or (at your option) any later version. + * + * FFmpeg is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with FFmpeg; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA + */ + +#include "libavutil/attributes.h" +#include "libavutil/attributes_internal.h" +#include "libavutil/intreadwrite.h" + +#include "avcodec.h" +#include "codec_internal.h" + +typedef struct IMM6Context { + AVCodecContext *h264_avctx; +} IMM6Context; + +static av_cold int imm6_init(AVCodecContext *avctx) +{ + IMM6Context *ctx = avctx->priv_data; + int ret; + + EXTERN const FFCodec ff_h264_decoder; + + ctx->h264_avctx = avcodec_alloc_context3(&ff_h264_decoder.p); + if (!ctx->h264_avctx) + return AVERROR(ENOMEM); + + ctx->h264_avctx->thread_count = 1; + ctx->h264_avctx->flags = avctx->flags; + ctx->h264_avctx->flags2 = avctx->flags2; + ctx->h264_avctx->max_pixels = avctx->max_pixels; + + ret = avcodec_open2(ctx->h264_avctx, NULL, NULL); + if (ret < 0) + return ret; + + return 0; +} + +static int imm6_decode_frame(AVCodecContext *avctx, AVFrame *frame, + int *got_frame, AVPacket *avpkt) +{ + IMM6Context *ctx = avctx->priv_data; + AVPacket h264_pkt; + uint32_t payload_size; + int ret; + + if (avpkt->size < 24) { + av_log(avctx, AV_LOG_ERROR, + "Packet too small for IMM6 header: %d bytes\\n", avpkt->size); + return AVERROR_INVALIDDATA; + } + + if (avpkt->data[8] > 1) { + av_log(avctx, AV_LOG_ERROR, + "Invalid IMM6 mode %u\\n", avpkt->data[8]); + return AVERROR_INVALIDDATA; + } + + payload_size = AV_RL32(avpkt->data + 4); + if (payload_size > (unsigned)avpkt->size - 24) { + av_log(avctx, AV_LOG_ERROR, + "Invalid IMM6 payload size %u in %d-byte packet\\n", + payload_size, avpkt->size); + return AVERROR_INVALIDDATA; + } + + h264_pkt = *avpkt; + h264_pkt.data += 24; + h264_pkt.size = payload_size; + + ret = avcodec_send_packet(ctx->h264_avctx, &h264_pkt); + if (ret < 0) { + av_log(avctx, AV_LOG_ERROR, + "Error submitting IMM6 H.264 payload for decoding\\n"); + return ret; + } + + ret = avcodec_receive_frame(ctx->h264_avctx, frame); + if (ret == AVERROR(EAGAIN)) + return avpkt->size; + if (ret < 0) + return ret; + + avctx->pix_fmt = ctx->h264_avctx->pix_fmt; + avctx->coded_width = ctx->h264_avctx->coded_width; + avctx->coded_height = ctx->h264_avctx->coded_height; + avctx->width = ctx->h264_avctx->width; + avctx->height = ctx->h264_avctx->height; + avctx->bit_rate = ctx->h264_avctx->bit_rate; + avctx->colorspace = ctx->h264_avctx->colorspace; + avctx->color_range = ctx->h264_avctx->color_range; + avctx->color_trc = ctx->h264_avctx->color_trc; + avctx->color_primaries = ctx->h264_avctx->color_primaries; + avctx->chroma_sample_location = ctx->h264_avctx->chroma_sample_location; + + *got_frame = 1; + return avpkt->size; +} + +static av_cold void imm6_flush(AVCodecContext *avctx) +{ + IMM6Context *ctx = avctx->priv_data; + avcodec_flush_buffers(ctx->h264_avctx); +} + +static av_cold int imm6_close(AVCodecContext *avctx) +{ + IMM6Context *ctx = avctx->priv_data; + avcodec_free_context(&ctx->h264_avctx); + return 0; +} + +const FFCodec ff_imm6_decoder = { + .p.name = "imm6", + CODEC_LONG_NAME("Infinity IMM6"), + .p.type = AVMEDIA_TYPE_VIDEO, + .p.id = AV_CODEC_ID_IMM6, + .init = imm6_init, + FF_CODEC_DECODE_CB(imm6_decode_frame), + .close = imm6_close, + .flush = imm6_flush, + .priv_data_size = sizeof(IMM6Context), + .caps_internal = FF_CODEC_CAP_INIT_CLEANUP, +}; diff --git a/libavcodec/version.h b/libavcodec/version.h index 80e2ae630d..8b53586be1 100644 --- a/libavcodec/version.h +++ b/libavcodec/version.h @@ -29,7 +29,7 @@ #include "version_major.h" -#define LIBAVCODEC_VERSION_MINOR 10 +#define LIBAVCODEC_VERSION_MINOR 11 #define LIBAVCODEC_VERSION_MICRO 100 #define LIBAVCODEC_VERSION_INT AV_VERSION_INT(LIBAVCODEC_VERSION_MAJOR, \ -- 2.52.0 >From a39c9fc4013c81f05a1018ac3597c1ac5bd57cb3 Mon Sep 17 00:00:00 2001 From: Tom Needham <[email protected]> Date: Sat, 5 Sep 2026 22:20:30 +0000 Subject: [PATCH 2/3] libavformat/riff: Add IMM6 tag to ff_codec_bmp_tags Signed-off-by: Tom Needham <[email protected]> --- libavformat/riff.c | 1 + 1 file changed, 1 insertion(+) diff --git a/libavformat/riff.c b/libavformat/riff.c index 21de951e3a..2430d19184 100644 --- a/libavformat/riff.c +++ b/libavformat/riff.c @@ -502,6 +502,7 @@ const AVCodecTag ff_codec_bmp_tags[] = { { AV_CODEC_ID_AGM, MKTAG('A', 'G', 'M', '7') }, { AV_CODEC_ID_LSCR, MKTAG('L', 'S', 'C', 'R') }, { AV_CODEC_ID_IMM5, MKTAG('I', 'M', 'M', '5') }, + { AV_CODEC_ID_IMM6, MKTAG('I', 'M', 'M', '6') }, { AV_CODEC_ID_MVDV, MKTAG('M', 'V', 'D', 'V') }, { AV_CODEC_ID_MVHA, MKTAG('M', 'V', 'H', 'A') }, { AV_CODEC_ID_MV30, MKTAG('M', 'V', '3', '0') }, -- 2.52.0 >From e4401b6236b5e0cb5ad0e4e81b0e4b67425b22b4 Mon Sep 17 00:00:00 2001 From: Tom Needham <[email protected]> Date: Sun, 6 Sep 2026 00:04:57 +0000 Subject: [PATCH 3/3] fate/imm6: Add FATE tests for IMM6 This FATE test uses a sample encoded directly using the "vcmimm6.dll" video for windows library downloaded from: https://web.archive.org/web/20150908042148/http://samples.ffmpeg.org/drivers32/newcodecpack/vcmimm6.dll The DLL file no longer exists on the live website as of today. The imm6.avi sample for the FATE test can be downloaded from https://streams.videolan.org/ffmpeg/incoming/imm6.avi Signed-off-by: Tom Needham <[email protected]> --- tests/fate/video.mak | 3 + tests/ref/fate/imm6 | 130 +++++++++++++++++++++++++++++++++++++++++++ 2 files changed, 133 insertions(+) create mode 100644 tests/ref/fate/imm6 diff --git a/tests/fate/video.mak b/tests/fate/video.mak index fa7b202052..ef6dfbdc96 100644 --- a/tests/fate/video.mak +++ b/tests/fate/video.mak @@ -416,6 +416,9 @@ fate-rv60-72x72: CMD = framecrc -i $(TARGET_SAMPLES)/rv60/test72x72.rmhd -an fate-rv60: fate-rv60-72x72 fate-rv60-512x512 +FATE_VIDEO-$(call FRAMECRC, AVI, IMM6) += fate-imm6 +fate-imm6: CMD = framecrc -i $(TARGET_SAMPLES)/imm6/imm6.avi -an + FATE_VIDEO += $(FATE_VIDEO-yes) FATE_SAMPLES_FFMPEG += $(FATE_VIDEO) diff --git a/tests/ref/fate/imm6 b/tests/ref/fate/imm6 new file mode 100644 index 0000000000..1209704b27 --- /dev/null +++ b/tests/ref/fate/imm6 @@ -0,0 +1,130 @@ +#software: Lavf61.7.103 +#tb 0: 1/25 +#media_type 0: video +#codec_id 0: rawvideo +#dimensions 0: 1280x720 +#sar 0: 81/256 +0, 0, 0, 1, 2764800, 0xe57aa7a6 +0, 3, 3, 1, 2764800, 0x57504f30 +0, 4, 4, 1, 2764800, 0x068318f9 +0, 5, 5, 1, 2764800, 0x6d4ae138 +0, 6, 6, 1, 2764800, 0x66052a17 +0, 7, 7, 1, 2764800, 0x1bf8b500 +0, 8, 8, 1, 2764800, 0x02910d87 +0, 9, 9, 1, 2764800, 0xe7cda225 +0, 10, 10, 1, 2764800, 0x6aeb5ca1 +0, 11, 11, 1, 2764800, 0x4aa269d1 +0, 12, 12, 1, 2764800, 0x7b07a281 +0, 13, 13, 1, 2764800, 0xed2b72bd +0, 14, 14, 1, 2764800, 0xafa8432d +0, 15, 15, 1, 2764800, 0x0d728481 +0, 16, 16, 1, 2764800, 0xffc20436 +0, 17, 17, 1, 2764800, 0x92734c9c +0, 18, 18, 1, 2764800, 0x3b3b86fd +0, 19, 19, 1, 2764800, 0x6be95eab +0, 20, 20, 1, 2764800, 0x72e7be51 +0, 21, 21, 1, 2764800, 0x2cf444e7 +0, 22, 22, 1, 2764800, 0xb017098c +0, 23, 23, 1, 2764800, 0x94771258 +0, 24, 24, 1, 2764800, 0x3de7ff63 +0, 25, 25, 1, 2764800, 0x0ad99e6b +0, 26, 26, 1, 2764800, 0x55d31222 +0, 27, 27, 1, 2764800, 0xcc728aac +0, 28, 28, 1, 2764800, 0x79b9ec10 +0, 29, 29, 1, 2764800, 0x7b118904 +0, 30, 30, 1, 2764800, 0x7bd2e496 +0, 31, 31, 1, 2764800, 0xcb4177c4 +0, 32, 32, 1, 2764800, 0x3bd642e7 +0, 33, 33, 1, 2764800, 0x480fea7d +0, 34, 34, 1, 2764800, 0xc0a19890 +0, 35, 35, 1, 2764800, 0xf036f4dd +0, 36, 36, 1, 2764800, 0x97411409 +0, 37, 37, 1, 2764800, 0x6196f0c3 +0, 38, 38, 1, 2764800, 0x86645cbd +0, 39, 39, 1, 2764800, 0x5b0f62d9 +0, 40, 40, 1, 2764800, 0x1a125eee +0, 41, 41, 1, 2764800, 0xd79da30d +0, 42, 42, 1, 2764800, 0xfbed1d02 +0, 43, 43, 1, 2764800, 0x52160246 +0, 44, 44, 1, 2764800, 0x196e4d08 +0, 45, 45, 1, 2764800, 0x9ee49357 +0, 46, 46, 1, 2764800, 0xb231375b +0, 47, 47, 1, 2764800, 0x92cd9b15 +0, 48, 48, 1, 2764800, 0x4d7f47e4 +0, 49, 49, 1, 2764800, 0xec11ce5c +0, 50, 50, 1, 2764800, 0x4e54e76a +0, 51, 51, 1, 2764800, 0xceb0d13d +0, 52, 52, 1, 2764800, 0xbcdd86fa +0, 53, 53, 1, 2764800, 0xff2bb5a3 +0, 54, 54, 1, 2764800, 0x54536550 +0, 55, 55, 1, 2764800, 0x16c19635 +0, 56, 56, 1, 2764800, 0x0d1db814 +0, 57, 57, 1, 2764800, 0x57873dbe +0, 58, 58, 1, 2764800, 0x06cd1209 +0, 59, 59, 1, 2764800, 0x174b1a68 +0, 60, 60, 1, 2764800, 0x6db227f2 +0, 61, 61, 1, 2764800, 0x67dcbc8f +0, 62, 62, 1, 2764800, 0xcd54d2c5 +0, 63, 63, 1, 2764800, 0x5dbddb2a +0, 64, 64, 1, 2764800, 0x3018de6b +0, 65, 65, 1, 2764800, 0xbcd14b64 +0, 66, 66, 1, 2764800, 0x3d6761a5 +0, 67, 67, 1, 2764800, 0x025527d0 +0, 68, 68, 1, 2764800, 0xce211757 +0, 69, 69, 1, 2764800, 0x03e03f03 +0, 70, 70, 1, 2764800, 0x50e454ce +0, 71, 71, 1, 2764800, 0x31084e09 +0, 72, 72, 1, 2764800, 0xc5ebd777 +0, 73, 73, 1, 2764800, 0x6dc151ab +0, 74, 74, 1, 2764800, 0xa4d14107 +0, 75, 75, 1, 2764800, 0x30e646ba +0, 76, 76, 1, 2764800, 0x68e251ec +0, 77, 77, 1, 2764800, 0x9db5fc99 +0, 78, 78, 1, 2764800, 0x9c8090fc +0, 79, 79, 1, 2764800, 0x7f580d1b +0, 80, 80, 1, 2764800, 0x0f90d19d +0, 81, 81, 1, 2764800, 0x39279875 +0, 82, 82, 1, 2764800, 0x55b2ee0e +0, 83, 83, 1, 2764800, 0xd345820e +0, 84, 84, 1, 2764800, 0xcdd9de9a +0, 85, 85, 1, 2764800, 0xd7913558 +0, 86, 86, 1, 2764800, 0x514f8bce +0, 87, 87, 1, 2764800, 0xcb47e0dc +0, 88, 88, 1, 2764800, 0x40b70ba9 +0, 89, 89, 1, 2764800, 0xa638e934 +0, 90, 90, 1, 2764800, 0xa1c545bc +0, 91, 91, 1, 2764800, 0x14c9cd39 +0, 92, 92, 1, 2764800, 0x4fd09e52 +0, 93, 93, 1, 2764800, 0x1c427122 +0, 94, 94, 1, 2764800, 0x6c694ce7 +0, 95, 95, 1, 2764800, 0x86857458 +0, 96, 96, 1, 2764800, 0x8c4e7dee +0, 97, 97, 1, 2764800, 0x8e2699d4 +0, 98, 98, 1, 2764800, 0x51dd047b +0, 99, 99, 1, 2764800, 0x76c2bcbf +0, 100, 100, 1, 2764800, 0xee82d7bc +0, 101, 101, 1, 2764800, 0xf8bf70bd +0, 102, 102, 1, 2764800, 0x8ee9553a +0, 103, 103, 1, 2764800, 0xa8f9bdbc +0, 104, 104, 1, 2764800, 0x14e6ab36 +0, 105, 105, 1, 2764800, 0x658340cf +0, 106, 106, 1, 2764800, 0xcf9edca9 +0, 107, 107, 1, 2764800, 0x8d28b5a4 +0, 108, 108, 1, 2764800, 0xedbcf30b +0, 109, 109, 1, 2764800, 0xef224be1 +0, 110, 110, 1, 2764800, 0xee911ecd +0, 111, 111, 1, 2764800, 0x4bcb7cdf +0, 112, 112, 1, 2764800, 0x1b712fba +0, 113, 113, 1, 2764800, 0x97a25be1 +0, 114, 114, 1, 2764800, 0x4bd86ab8 +0, 115, 115, 1, 2764800, 0x801d96ca +0, 116, 116, 1, 2764800, 0x852c6549 +0, 117, 117, 1, 2764800, 0xe2ca6318 +0, 118, 118, 1, 2764800, 0x843fd6bf +0, 119, 119, 1, 2764800, 0xc0112f8e +0, 120, 120, 1, 2764800, 0xbfab9bf0 +0, 121, 121, 1, 2764800, 0x37d771c6 +0, 122, 122, 1, 2764800, 0x2c8cb0f0 +0, 123, 123, 1, 2764800, 0x3e19b15a +0, 124, 124, 1, 2764800, 0xb47a35a0 +0, 125, 125, 1, 2764800, 0x96507076 -- 2.52.0 _______________________________________________ ffmpeg-devel mailing list -- [email protected] To unsubscribe send an email to [email protected]
