[FFmpeg-cvslog] avcodec: Implement Acorn Replay IMA ADPCM decoder

Cameron Cawley git at videolan.org
Sun May 9 10:20:57 EEST 2021


ffmpeg | branch: master | Cameron Cawley <ccawley2011 at gmail.com> | Fri May  7 17:50:47 2021 +0100| [5c7313c740dbd04e1a98937ca31d2c4a30ac6b99] | committer: Zane van Iperen

avcodec: Implement Acorn Replay IMA ADPCM decoder

Signed-off-by: Zane van Iperen <zane at zanevaniperen.com>

> http://git.videolan.org/gitweb.cgi/ffmpeg.git/?a=commit;h=5c7313c740dbd04e1a98937ca31d2c4a30ac6b99
---

 Changelog                 |  1 +
 doc/general_contents.texi |  1 +
 libavcodec/Makefile       |  1 +
 libavcodec/adpcm.c        | 19 +++++++++++++++++++
 libavcodec/allcodecs.c    |  1 +
 libavcodec/codec_desc.c   |  7 +++++++
 libavcodec/codec_id.h     |  1 +
 libavcodec/utils.c        |  1 +
 libavcodec/version.h      |  2 +-
 9 files changed, 33 insertions(+), 1 deletion(-)

diff --git a/Changelog b/Changelog
index ad950354d0..c38c5d63a0 100644
--- a/Changelog
+++ b/Changelog
@@ -4,6 +4,7 @@ releases are sorted from youngest to oldest.
 version <next>:
 - ADPCM IMA Westwood encoder
 - Westwood AUD muxer
+- ADPCM IMA Acorn Replay decoder
 
 
 version 4.4:
diff --git a/doc/general_contents.texi b/doc/general_contents.texi
index e01347f8d4..354899ad17 100644
--- a/doc/general_contents.texi
+++ b/doc/general_contents.texi
@@ -1126,6 +1126,7 @@ following image formats are supported:
 @item ADPCM Electronic Arts XAS @tab     @tab  X
 @item ADPCM G.722            @tab  X  @tab  X
 @item ADPCM G.726            @tab  X  @tab  X
+ at item ADPCM IMA Acorn Replay @tab     @tab  X
 @item ADPCM IMA AMV          @tab  X  @tab  X
     @tab Used in AMV files
 @item ADPCM IMA Cunning Developments  @tab     @tab  X
diff --git a/libavcodec/Makefile b/libavcodec/Makefile
index 075b0ad7a3..4fa8d7ab10 100644
--- a/libavcodec/Makefile
+++ b/libavcodec/Makefile
@@ -868,6 +868,7 @@ OBJS-$(CONFIG_ADPCM_G726_DECODER)         += g726.o
 OBJS-$(CONFIG_ADPCM_G726_ENCODER)         += g726.o
 OBJS-$(CONFIG_ADPCM_G726LE_DECODER)       += g726.o
 OBJS-$(CONFIG_ADPCM_G726LE_ENCODER)       += g726.o
+OBJS-$(CONFIG_ADPCM_IMA_ACORN_DECODER)    += adpcm.o adpcm_data.o
 OBJS-$(CONFIG_ADPCM_IMA_AMV_DECODER)      += adpcm.o adpcm_data.o
 OBJS-$(CONFIG_ADPCM_IMA_ALP_DECODER)      += adpcm.o adpcm_data.o
 OBJS-$(CONFIG_ADPCM_IMA_ALP_ENCODER)      += adpcmenc.o adpcm_data.o
diff --git a/libavcodec/adpcm.c b/libavcodec/adpcm.c
index 3da6b734cf..8fe43b5720 100644
--- a/libavcodec/adpcm.c
+++ b/libavcodec/adpcm.c
@@ -747,6 +747,7 @@ static int get_nb_samples(AVCodecContext *avctx, GetByteContext *gb,
     switch (avctx->codec->id) {
         case AV_CODEC_ID_ADPCM_4XM:
         case AV_CODEC_ID_ADPCM_AGM:
+        case AV_CODEC_ID_ADPCM_IMA_ACORN:
         case AV_CODEC_ID_ADPCM_IMA_DAT4:
         case AV_CODEC_ID_ADPCM_IMA_MOFLEX:
         case AV_CODEC_ID_ADPCM_IMA_ISS:     header_size = 4 * ch;      break;
@@ -1665,6 +1666,23 @@ static int adpcm_decode_frame(AVCodecContext *avctx, void *data,
             }
         }
         break;
+    case AV_CODEC_ID_ADPCM_IMA_ACORN:
+        for (channel = 0; channel < avctx->channels; channel++) {
+            cs = &c->status[channel];
+            cs->predictor  = sign_extend(bytestream2_get_le16u(&gb), 16);
+            cs->step_index = bytestream2_get_le16u(&gb) & 0xFF;
+            if (cs->step_index > 88u){
+                av_log(avctx, AV_LOG_ERROR, "ERROR: step_index[%d] = %i\n",
+                       channel, cs->step_index);
+                return AVERROR_INVALIDDATA;
+            }
+        }
+        for (n = nb_samples >> (1 - st); n > 0; n--) {
+            int byte = bytestream2_get_byteu(&gb);
+            *samples++ = adpcm_ima_expand_nibble(&c->status[0],  byte & 0x0F, 3);
+            *samples++ = adpcm_ima_expand_nibble(&c->status[st], byte >> 4,   3);
+        }
+        break;
     case AV_CODEC_ID_ADPCM_IMA_AMV:
         av_assert0(avctx->channels == 1);
 
@@ -2160,6 +2178,7 @@ ADPCM_DECODER(AV_CODEC_ID_ADPCM_EA_R1,       sample_fmts_s16p, adpcm_ea_r1,
 ADPCM_DECODER(AV_CODEC_ID_ADPCM_EA_R2,       sample_fmts_s16p, adpcm_ea_r2,       "ADPCM Electronic Arts R2");
 ADPCM_DECODER(AV_CODEC_ID_ADPCM_EA_R3,       sample_fmts_s16p, adpcm_ea_r3,       "ADPCM Electronic Arts R3");
 ADPCM_DECODER(AV_CODEC_ID_ADPCM_EA_XAS,      sample_fmts_s16p, adpcm_ea_xas,      "ADPCM Electronic Arts XAS");
+ADPCM_DECODER(AV_CODEC_ID_ADPCM_IMA_ACORN,   sample_fmts_s16,  adpcm_ima_acorn,   "ADPCM IMA Acorn Replay");
 ADPCM_DECODER(AV_CODEC_ID_ADPCM_IMA_AMV,     sample_fmts_s16,  adpcm_ima_amv,     "ADPCM IMA AMV");
 ADPCM_DECODER(AV_CODEC_ID_ADPCM_IMA_APC,     sample_fmts_s16,  adpcm_ima_apc,     "ADPCM IMA CRYO APC");
 ADPCM_DECODER(AV_CODEC_ID_ADPCM_IMA_APM,     sample_fmts_s16,  adpcm_ima_apm,     "ADPCM IMA Ubisoft APM");
diff --git a/libavcodec/allcodecs.c b/libavcodec/allcodecs.c
index 73dd3d0695..0b15b59364 100644
--- a/libavcodec/allcodecs.c
+++ b/libavcodec/allcodecs.c
@@ -619,6 +619,7 @@ extern const AVCodec ff_adpcm_g726_encoder;
 extern const AVCodec ff_adpcm_g726_decoder;
 extern const AVCodec ff_adpcm_g726le_encoder;
 extern const AVCodec ff_adpcm_g726le_decoder;
+extern const AVCodec ff_adpcm_ima_acorn_decoder;
 extern const AVCodec ff_adpcm_ima_amv_decoder;
 extern const AVCodec ff_adpcm_ima_amv_encoder;
 extern const AVCodec ff_adpcm_ima_alp_decoder;
diff --git a/libavcodec/codec_desc.c b/libavcodec/codec_desc.c
index 17f8a14044..35527dcc37 100644
--- a/libavcodec/codec_desc.c
+++ b/libavcodec/codec_desc.c
@@ -2462,6 +2462,13 @@ static const AVCodecDescriptor codec_descriptors[] = {
         .long_name = NULL_IF_CONFIG_SMALL("ADPCM IMA MobiClip MOFLEX"),
         .props     = AV_CODEC_PROP_INTRA_ONLY | AV_CODEC_PROP_LOSSY,
     },
+    {
+        .id        = AV_CODEC_ID_ADPCM_IMA_ACORN,
+        .type      = AVMEDIA_TYPE_AUDIO,
+        .name      = "adpcm_ima_acorn",
+        .long_name = NULL_IF_CONFIG_SMALL("ADPCM IMA Acorn Replay"),
+        .props     = AV_CODEC_PROP_INTRA_ONLY | AV_CODEC_PROP_LOSSY,
+    },
 
     /* AMR */
     {
diff --git a/libavcodec/codec_id.h b/libavcodec/codec_id.h
index 3cfa8f9459..83e1dbb4b3 100644
--- a/libavcodec/codec_id.h
+++ b/libavcodec/codec_id.h
@@ -398,6 +398,7 @@ enum AVCodecID {
     AV_CODEC_ID_ADPCM_IMA_MTF,
     AV_CODEC_ID_ADPCM_IMA_CUNNING,
     AV_CODEC_ID_ADPCM_IMA_MOFLEX,
+    AV_CODEC_ID_ADPCM_IMA_ACORN,
 
     /* AMR */
     AV_CODEC_ID_AMR_NB = 0x12000,
diff --git a/libavcodec/utils.c b/libavcodec/utils.c
index bc5f652dec..c08f9a7da3 100644
--- a/libavcodec/utils.c
+++ b/libavcodec/utils.c
@@ -699,6 +699,7 @@ static int get_audio_frame_duration(enum AVCodecID id, int sr, int ch, int ba,
                     return 0;
                 return frame_bytes * 28;
             case AV_CODEC_ID_ADPCM_4XM:
+            case AV_CODEC_ID_ADPCM_IMA_ACORN:
             case AV_CODEC_ID_ADPCM_IMA_DAT4:
             case AV_CODEC_ID_ADPCM_IMA_ISS:
                 return (frame_bytes - 4 * ch) * 2 / ch;
diff --git a/libavcodec/version.h b/libavcodec/version.h
index 8d37666d5e..48165b9ac4 100644
--- a/libavcodec/version.h
+++ b/libavcodec/version.h
@@ -28,7 +28,7 @@
 #include "libavutil/version.h"
 
 #define LIBAVCODEC_VERSION_MAJOR  59
-#define LIBAVCODEC_VERSION_MINOR   0
+#define LIBAVCODEC_VERSION_MINOR   1
 #define LIBAVCODEC_VERSION_MICRO 100
 
 #define LIBAVCODEC_VERSION_INT  AV_VERSION_INT(LIBAVCODEC_VERSION_MAJOR, \



More information about the ffmpeg-cvslog mailing list