[FFmpeg-cvslog] [ffmpeg] branch master updated. 990edfee5b libavcodec/vima: reindent
ffmpeg-git at ffmpeg.org
ffmpeg-git at ffmpeg.org
Wed Aug 20 12:36:51 EEST 2025
The branch, master has been updated
via 990edfee5b9ca65ef71feddb595dcda9f195120e (commit)
via 9141fe9653dc078d81bff8308ffdd2aaaf35495c (commit)
via 1e95f1b269e25dd8907ac65f2963de54d2b73142 (commit)
from 4c3f94f2651ce4d6834fbef10e5c287f25720ac9 (commit)
- Log -----------------------------------------------------------------
commit 990edfee5b9ca65ef71feddb595dcda9f195120e
Author: Manuel Lauss <manuel.lauss at gmail.com>
AuthorDate: Mon Aug 18 09:46:57 2025 +0200
Commit: Manuel Lauss <manuel.lauss at gmail.com>
CommitDate: Wed Aug 20 11:20:14 2025 +0200
libavcodec/vima: reindent
Signed-off-by: Manuel Lauss <manuel.lauss at gmail.com>
diff --git a/libavcodec/vima.c b/libavcodec/vima.c
index 0423fff091..bde7033c2c 100644
--- a/libavcodec/vima.c
+++ b/libavcodec/vima.c
@@ -173,47 +173,47 @@ static int decode_frame(AVCodecContext *avctx, AVFrame *frame,
*dest++ = cs.predictor;
}
} else {
- for (chan = 0; chan < channels; chan++) {
- uint16_t *dest = (uint16_t *)frame->data[0] + chan;
- int step_index = channel_hint[chan];
- int output = pcm_data[chan];
- int sample;
-
- for (sample = 0; sample < samples; sample++) {
- int lookup_size, lookup, highbit, lowbits;
-
- step_index = av_clip(step_index, 0, 88);
- lookup_size = size_table[step_index];
- lookup = get_bits(&gb, lookup_size);
- highbit = 1 << (lookup_size - 1);
- lowbits = highbit - 1;
-
- if (lookup & highbit)
- lookup ^= highbit;
- else
- highbit = 0;
-
- if (lookup == lowbits) {
- output = get_sbits(&gb, 16);
- } else {
- int predict_index, diff;
-
- predict_index = (lookup << (7 - lookup_size)) | (step_index << 6);
- predict_index = av_clip(predict_index, 0, 5785);
- diff = predict_table[predict_index];
- if (lookup)
- diff += ff_adpcm_step_table[step_index] >> (lookup_size - 1);
- if (highbit)
- diff = -diff;
-
- output = av_clip_int16(output + diff);
+ for (chan = 0; chan < channels; chan++) {
+ uint16_t *dest = (uint16_t *)frame->data[0] + chan;
+ int step_index = channel_hint[chan];
+ int output = pcm_data[chan];
+ int sample;
+
+ for (sample = 0; sample < samples; sample++) {
+ int lookup_size, lookup, highbit, lowbits;
+
+ step_index = av_clip(step_index, 0, 88);
+ lookup_size = size_table[step_index];
+ lookup = get_bits(&gb, lookup_size);
+ highbit = 1 << (lookup_size - 1);
+ lowbits = highbit - 1;
+
+ if (lookup & highbit)
+ lookup ^= highbit;
+ else
+ highbit = 0;
+
+ if (lookup == lowbits) {
+ output = get_sbits(&gb, 16);
+ } else {
+ int predict_index, diff;
+
+ predict_index = (lookup << (7 - lookup_size)) | (step_index << 6);
+ predict_index = av_clip(predict_index, 0, 5785);
+ diff = predict_table[predict_index];
+ if (lookup)
+ diff += ff_adpcm_step_table[step_index] >> (lookup_size - 1);
+ if (highbit)
+ diff = -diff;
+
+ output = av_clip_int16(output + diff);
+ }
+
+ *dest = output;
+ dest += channels;
+
+ step_index += step_index_tables[lookup_size - 2][lookup];
}
-
- *dest = output;
- dest += channels;
-
- step_index += step_index_tables[lookup_size - 2][lookup];
- }
}
}
commit 9141fe9653dc078d81bff8308ffdd2aaaf35495c
Author: Manuel Lauss <manuel.lauss at gmail.com>
AuthorDate: Sat Aug 16 10:44:06 2025 +0200
Commit: Manuel Lauss <manuel.lauss at gmail.com>
CommitDate: Wed Aug 20 11:20:14 2025 +0200
avcodec/vima: IMA4 subtag support
Support decoding of the IMA4 ADPCM QT scheme used in some LucasArts
SANM files.
Signed-off-by: Manuel Lauss <manuel.lauss at gmail.com>
diff --git a/libavcodec/vima.c b/libavcodec/vima.c
index 56cc1b7a85..0423fff091 100644
--- a/libavcodec/vima.c
+++ b/libavcodec/vima.c
@@ -28,6 +28,7 @@
#include "libavutil/channel_layout.h"
#include "libavutil/thread.h"
+#include "adpcm.h"
#include "adpcm_data.h"
#include "avcodec.h"
#include "codec_internal.h"
@@ -159,6 +160,19 @@ static int decode_frame(AVCodecContext *avctx, AVFrame *frame,
if ((ret = ff_get_buffer(avctx, frame, 0)) < 0)
return ret;
+ if (show_bits_long(&gb, 32) == MKBETAG('I','M','A','4')) {
+ int16_t *dest = (int16_t *)frame->data[0];
+ ADPCMChannelStatus cs;
+
+ skip_bits_long(&gb, 32); /* skip the 'IMA4' tag */
+ cs.predictor = (int16_t)get_xbits_le(&gb, 16);
+ cs.step_index = av_clip(get_bits(&gb, 8), 0, 88);
+ for (int i = 0; i < samples; i++) {
+ ff_adpcm_ima_qt_expand_nibble(&cs, get_bits(&gb, 4));
+ for (int j = 0; j < channels; j++)
+ *dest++ = cs.predictor;
+ }
+ } else {
for (chan = 0; chan < channels; chan++) {
uint16_t *dest = (uint16_t *)frame->data[0] + chan;
int step_index = channel_hint[chan];
@@ -200,6 +214,7 @@ static int decode_frame(AVCodecContext *avctx, AVFrame *frame,
step_index += step_index_tables[lookup_size - 2][lookup];
}
+ }
}
*got_frame_ptr = 1;
commit 1e95f1b269e25dd8907ac65f2963de54d2b73142
Author: Manuel Lauss <manuel.lauss at gmail.com>
AuthorDate: Sat Aug 16 10:24:34 2025 +0200
Commit: Manuel Lauss <manuel.lauss at gmail.com>
CommitDate: Wed Aug 20 11:20:11 2025 +0200
avcodec/adpcm: export ff_adpcm_ima_qt_expand_nibble
For use in the LucasArts VIMA decoder, where it is used as a subvariant.
Signed-off-by: Manuel Lauss <manuel.lauss at gmail.com>
diff --git a/libavcodec/adpcm.c b/libavcodec/adpcm.c
index 83ef7c780a..4c15be6207 100644
--- a/libavcodec/adpcm.c
+++ b/libavcodec/adpcm.c
@@ -518,7 +518,7 @@ static inline int16_t adpcm_ima_wav_expand_nibble(ADPCMChannelStatus *c, GetBitC
return (int16_t)c->predictor;
}
-static inline int adpcm_ima_qt_expand_nibble(ADPCMChannelStatus *c, int nibble)
+int16_t ff_adpcm_ima_qt_expand_nibble(ADPCMChannelStatus *c, int nibble)
{
int step_index;
int predictor;
@@ -1335,8 +1335,8 @@ static int adpcm_decode_frame(AVCodecContext *avctx, AVFrame *frame,
for (int m = 0; m < 64; m += 2) {
int byte = bytestream2_get_byteu(&gb);
- samples[m ] = adpcm_ima_qt_expand_nibble(cs, byte & 0x0F);
- samples[m + 1] = adpcm_ima_qt_expand_nibble(cs, byte >> 4 );
+ samples[m ] = ff_adpcm_ima_qt_expand_nibble(cs, byte & 0x0F);
+ samples[m + 1] = ff_adpcm_ima_qt_expand_nibble(cs, byte >> 4 );
}
}
) /* End of CASE */
@@ -1689,16 +1689,16 @@ static int adpcm_decode_frame(AVCodecContext *avctx, AVFrame *frame,
CASE(ADPCM_IMA_SSI,
for (int n = nb_samples >> (1 - st); n > 0; n--) {
int v = bytestream2_get_byteu(&gb);
- *samples++ = adpcm_ima_qt_expand_nibble(&c->status[0], v >> 4 );
- *samples++ = adpcm_ima_qt_expand_nibble(&c->status[st], v & 0x0F);
+ *samples++ = ff_adpcm_ima_qt_expand_nibble(&c->status[0], v >> 4 );
+ *samples++ = ff_adpcm_ima_qt_expand_nibble(&c->status[st], v & 0x0F);
}
) /* End of CASE */
CASE(ADPCM_IMA_APM,
for (int n = nb_samples / 2; n > 0; n--) {
for (int channel = 0; channel < channels; channel++) {
int v = bytestream2_get_byteu(&gb);
- *samples++ = adpcm_ima_qt_expand_nibble(&c->status[channel], v >> 4 );
- samples[st] = adpcm_ima_qt_expand_nibble(&c->status[channel], v & 0x0F);
+ *samples++ = ff_adpcm_ima_qt_expand_nibble(&c->status[channel], v >> 4 );
+ samples[st] = ff_adpcm_ima_qt_expand_nibble(&c->status[channel], v & 0x0F);
}
samples += channels;
}
@@ -2154,8 +2154,8 @@ static int adpcm_decode_frame(AVCodecContext *avctx, AVFrame *frame,
for (int n = nb_samples >> (1 - st); n > 0; n--) {
int v = bytestream2_get_byteu(&gb);
- *samples++ = adpcm_ima_qt_expand_nibble(&c->status[0 ], v >> 4 );
- *samples++ = adpcm_ima_qt_expand_nibble(&c->status[st], v & 0xf);
+ *samples++ = ff_adpcm_ima_qt_expand_nibble(&c->status[0 ], v >> 4 );
+ *samples++ = ff_adpcm_ima_qt_expand_nibble(&c->status[st], v & 0xf);
}
) /* End of CASE */
CASE(ADPCM_CT,
diff --git a/libavcodec/adpcm.h b/libavcodec/adpcm.h
index 0ffc3da1d0..ff70e62078 100644
--- a/libavcodec/adpcm.h
+++ b/libavcodec/adpcm.h
@@ -44,5 +44,6 @@ typedef struct ADPCMChannelStatus {
} ADPCMChannelStatus;
int16_t ff_adpcm_argo_expand_nibble(ADPCMChannelStatus *cs, int nibble, int shift, int flag);
+int16_t ff_adpcm_ima_qt_expand_nibble(ADPCMChannelStatus *c, int nibble);
#endif /* AVCODEC_ADPCM_H */
-----------------------------------------------------------------------
Summary of changes:
libavcodec/adpcm.c | 18 +++++------
libavcodec/adpcm.h | 1 +
libavcodec/vima.c | 93 +++++++++++++++++++++++++++++++-----------------------
3 files changed, 64 insertions(+), 48 deletions(-)
hooks/post-receive
--
More information about the ffmpeg-cvslog
mailing list