diff options
-rw-r--r-- | Changelog | 1 | ||||
-rw-r--r-- | Makefile | 1 | ||||
-rw-r--r-- | doc/general.texi | 2 | ||||
-rw-r--r-- | libavcodec/adpcm.c | 40 | ||||
-rw-r--r-- | libavcodec/allcodecs.c | 2 | ||||
-rw-r--r-- | libavcodec/avcodec.h | 4 | ||||
-rw-r--r-- | tests/ffmpeg.regression.ref | 4 | ||||
-rwxr-xr-x | tests/regression.sh | 5 | ||||
-rw-r--r-- | tests/rotozoom.regression.ref | 4 | ||||
-rw-r--r-- | tests/seek.regression.ref | 55 |
10 files changed, 111 insertions, 7 deletions
@@ -110,6 +110,7 @@ version <next> - TechnoTrend PVA demuxer - Linux Media Labs MPEG-4 (LMLM4) demuxer - AVM2 (Flash 9) SWF muxer +- QT variant of IMA ADPCM encoder version 0.4.9-pre1: @@ -314,6 +314,7 @@ CODEC_TESTS = $(addprefix regtest-, \ ac3 \ g726 \ adpcm_ima_wav \ + adpcm_ima_qt \ adpcm_ms \ adpcm_yam \ adpcm_swf \ diff --git a/doc/general.texi b/doc/general.texi index 8fc27d6..df7c5e7 100644 --- a/doc/general.texi +++ b/doc/general.texi @@ -261,7 +261,7 @@ following image formats are supported: @item AMV IMA ADPCM @tab @tab X @tab Used in AMV files @item MS IMA ADPCM @tab X @tab X -@item QT IMA ADPCM @tab @tab X +@item QT IMA ADPCM @tab X @tab X @item 4X IMA ADPCM @tab @tab X @item G.726 ADPCM @tab X @tab X @item Duck DK3 IMA ADPCM @tab @tab X diff --git a/libavcodec/adpcm.c b/libavcodec/adpcm.c index eadcfae..4e5c54e 100644 --- a/libavcodec/adpcm.c +++ b/libavcodec/adpcm.c @@ -165,6 +165,10 @@ static int adpcm_encode_init(AVCodecContext *avctx) avctx->block_align = BLKSIZE; /* seems frame_size isn't taken into account... have to buffer the samples :-( */ break; + case CODEC_ID_ADPCM_IMA_QT: + avctx->frame_size = 64; + avctx->block_align = 34 * avctx->channels; + break; case CODEC_ID_ADPCM_MS: avctx->frame_size = (BLKSIZE - 7 * avctx->channels) * 2 / avctx->channels + 2; /* each 16 bits sample gives one nibble */ /* and we have 7 bytes per channel overhead */ @@ -295,7 +299,7 @@ static void adpcm_compress_trellis(AVCodecContext *avctx, const short *samples, nodes[0]->step = c->step_index; nodes[0]->sample1 = c->sample1; nodes[0]->sample2 = c->sample2; - if((version == CODEC_ID_ADPCM_IMA_WAV) || (version == CODEC_ID_ADPCM_SWF)) + if((version == CODEC_ID_ADPCM_IMA_WAV) || (version == CODEC_ID_ADPCM_IMA_QT) || (version == CODEC_ID_ADPCM_SWF)) nodes[0]->sample1 = c->prev_sample; if(version == CODEC_ID_ADPCM_MS) nodes[0]->step = c->idelta; @@ -366,7 +370,7 @@ static void adpcm_compress_trellis(AVCodecContext *avctx, const short *samples, next_##NAME:; STORE_NODE(ms, FFMAX(16, (AdaptationTable[nibble] * step) >> 8)); } - } else if((version == CODEC_ID_ADPCM_IMA_WAV)|| (version == CODEC_ID_ADPCM_SWF)) { + } else if((version == CODEC_ID_ADPCM_IMA_WAV)|| (version == CODEC_ID_ADPCM_IMA_QT)|| (version == CODEC_ID_ADPCM_SWF)) { #define LOOP_NODES(NAME, STEP_TABLE, STEP_INDEX)\ const int predictor = nodes[j]->sample1;\ const int div = (sample - predictor) * 4 / STEP_TABLE;\ @@ -509,6 +513,36 @@ static int adpcm_encode_frame(AVCodecContext *avctx, samples += 8 * avctx->channels; } break; + case CODEC_ID_ADPCM_IMA_QT: + { + int ch, i; + PutBitContext pb; + init_put_bits(&pb, dst, buf_size*8); + + for(ch=0; ch<avctx->channels; ch++){ + put_bits(&pb, 9, (c->status[ch].prev_sample + 0x10000) >> 7); + put_bits(&pb, 7, c->status[ch].step_index); + if(avctx->trellis > 0) { + uint8_t buf[64]; + adpcm_compress_trellis(avctx, samples+ch, buf, &c->status[ch], 64); + for(i=0; i<64; i++) + put_bits(&pb, 4, buf[i^1]); + c->status[ch].prev_sample = c->status[ch].predictor & ~0x7F; + } else { + for (i=0; i<64; i+=2){ + int t1, t2; + t1 = adpcm_ima_compress_sample(&c->status[ch], samples[avctx->channels*(i+0)+ch]); + t2 = adpcm_ima_compress_sample(&c->status[ch], samples[avctx->channels*(i+1)+ch]); + put_bits(&pb, 4, t2); + put_bits(&pb, 4, t1); + } + c->status[ch].prev_sample &= ~0x7F; + } + } + + dst += put_bits_count(&pb)>>3; + break; + } case CODEC_ID_ADPCM_SWF: { int i; @@ -1588,7 +1622,7 @@ ADPCM_DECODER(CODEC_ID_ADPCM_IMA_DK3, adpcm_ima_dk3); ADPCM_DECODER(CODEC_ID_ADPCM_IMA_DK4, adpcm_ima_dk4); ADPCM_DECODER(CODEC_ID_ADPCM_IMA_EA_EACS, adpcm_ima_ea_eacs); ADPCM_DECODER(CODEC_ID_ADPCM_IMA_EA_SEAD, adpcm_ima_ea_sead); -ADPCM_DECODER(CODEC_ID_ADPCM_IMA_QT, adpcm_ima_qt); +ADPCM_CODEC (CODEC_ID_ADPCM_IMA_QT, adpcm_ima_qt); ADPCM_DECODER(CODEC_ID_ADPCM_IMA_SMJPEG, adpcm_ima_smjpeg); ADPCM_CODEC (CODEC_ID_ADPCM_IMA_WAV, adpcm_ima_wav); ADPCM_DECODER(CODEC_ID_ADPCM_IMA_WS, adpcm_ima_ws); diff --git a/libavcodec/allcodecs.c b/libavcodec/allcodecs.c index 9bb35fa..1eaf093 100644 --- a/libavcodec/allcodecs.c +++ b/libavcodec/allcodecs.c @@ -249,7 +249,7 @@ void avcodec_register_all(void) REGISTER_DECODER (ADPCM_IMA_DK4, adpcm_ima_dk4); REGISTER_DECODER (ADPCM_IMA_EA_EACS, adpcm_ima_ea_eacs); REGISTER_DECODER (ADPCM_IMA_EA_SEAD, adpcm_ima_ea_sead); - REGISTER_DECODER (ADPCM_IMA_QT, adpcm_ima_qt); + REGISTER_ENCDEC (ADPCM_IMA_QT, adpcm_ima_qt); REGISTER_DECODER (ADPCM_IMA_SMJPEG, adpcm_ima_smjpeg); REGISTER_ENCDEC (ADPCM_IMA_WAV, adpcm_ima_wav); REGISTER_DECODER (ADPCM_IMA_WS, adpcm_ima_ws); diff --git a/libavcodec/avcodec.h b/libavcodec/avcodec.h index 5e38cf6..7b4e1b4 100644 --- a/libavcodec/avcodec.h +++ b/libavcodec/avcodec.h @@ -31,8 +31,8 @@ #include <sys/types.h> /* size_t */ #define LIBAVCODEC_VERSION_MAJOR 51 -#define LIBAVCODEC_VERSION_MINOR 50 -#define LIBAVCODEC_VERSION_MICRO 1 +#define LIBAVCODEC_VERSION_MINOR 51 +#define LIBAVCODEC_VERSION_MICRO 0 #define LIBAVCODEC_VERSION_INT AV_VERSION_INT(LIBAVCODEC_VERSION_MAJOR, \ LIBAVCODEC_VERSION_MINOR, \ diff --git a/tests/ffmpeg.regression.ref b/tests/ffmpeg.regression.ref index 43f79ef..f175eb5 100644 --- a/tests/ffmpeg.regression.ref +++ b/tests/ffmpeg.regression.ref @@ -179,6 +179,10 @@ stddev:8368.02 PSNR:17.87 bytes:96256 266300 ./tests/data/a-adpcm_ima.wav 947196b1739a9d6fe0c29424cf61cd8c *./tests/data/adpcm_ima_wav.vsynth.out.wav stddev:904.20 PSNR:37.19 bytes:1056768 +efdae2746040dbc27be402b149556f1e *./tests/data/a-adpcm_qt.aiff +281184 ./tests/data/a-adpcm_qt.aiff +468fcd54a438f1b74060c2e9665be59e *./tests/data/adpcm_ima_qt.vsynth.out.wav +stddev:8931.22 PSNR:17.30 bytes:1056768 628d4789cf9ee16a756ac54b7fd8650d *./tests/data/a-adpcm_ms.wav 267320 ./tests/data/a-adpcm_ms.wav 91a84bb4f319a3a0bf0c0441b3d3a529 *./tests/data/adpcm_ms.vsynth.out.wav diff --git a/tests/regression.sh b/tests/regression.sh index 44bf9eb..cbbeda0 100755 --- a/tests/regression.sh +++ b/tests/regression.sh @@ -401,6 +401,11 @@ do_audio_encoding adpcm_ima.wav "-ar 44100" "-acodec adpcm_ima_wav" do_audio_decoding fi +if [ -n "$do_adpcm_ima_qt" ] ; then +do_audio_encoding adpcm_qt.aiff "-ar 44100" "-acodec adpcm_ima_qt" +do_audio_decoding +fi + if [ -n "$do_adpcm_ms" ] ; then do_audio_encoding adpcm_ms.wav "-ar 44100" "-acodec adpcm_ms" do_audio_decoding diff --git a/tests/rotozoom.regression.ref b/tests/rotozoom.regression.ref index 4ec5eb5..2f1b2b7 100644 --- a/tests/rotozoom.regression.ref +++ b/tests/rotozoom.regression.ref @@ -179,6 +179,10 @@ stddev:8368.02 PSNR:17.87 bytes:96256 266300 ./tests/data/a-adpcm_ima.wav 947196b1739a9d6fe0c29424cf61cd8c *./tests/data/adpcm_ima_wav.rotozoom.out.wav stddev:904.20 PSNR:37.19 bytes:1056768 +efdae2746040dbc27be402b149556f1e *./tests/data/a-adpcm_qt.aiff +281184 ./tests/data/a-adpcm_qt.aiff +468fcd54a438f1b74060c2e9665be59e *./tests/data/adpcm_ima_qt.rotozoom.out.wav +stddev:8931.22 PSNR:17.30 bytes:1056768 628d4789cf9ee16a756ac54b7fd8650d *./tests/data/a-adpcm_ms.wav 267320 ./tests/data/a-adpcm_ms.wav 91a84bb4f319a3a0bf0c0441b3d3a529 *./tests/data/adpcm_ms.rotozoom.out.wav diff --git a/tests/seek.regression.ref b/tests/seek.regression.ref index a760b9e..96c5cc7 100644 --- a/tests/seek.regression.ref +++ b/tests/seek.regression.ref @@ -95,6 +95,61 @@ ret: 0 st: 0 dts:0.511995 pts:0.511995 pos:8252 size:4096 flags:1 ret: 0 st:-1 ts:-0.645825 flags:1 ret: 0 st: 0 dts:-0.703991 pts:-0.703991 pos:41020 size:4096 flags:1 ---------------- +tests/data/a-adpcm_qt.aiff +ret: 0 st: 0 dts:0.000000 pts:0.000000 pos:72 size:4080 flags:1 +ret: 0 st:-1 ts:-1.000000 flags:0 +ret:-5 +ret: 0 st:-1 ts:1.894167 flags:1 +ret: 0 st: 0 dts:1.894059 pts:1.894059 pos:88812 size:4080 flags:1 +ret: 0 st: 0 ts:0.788345 flags:0 +ret: 0 st: 0 dts:0.789546 pts:0.789546 pos:37064 size:4080 flags:1 +ret: 0 st: 0 ts:-0.317506 flags:1 +ret: 0 st: 0 dts:-0.317846 pts:-0.317846 pos:69832 size:4080 flags:1 +ret: 0 st:-1 ts:2.576668 flags:0 +ret: 0 st: 0 dts:2.577642 pts:2.577642 pos:120840 size:4080 flags:1 +ret: 0 st:-1 ts:1.470835 flags:1 +ret: 0 st: 0 dts:1.470249 pts:1.470249 pos:68956 size:4080 flags:1 +ret: 0 st: 0 ts:0.365011 flags:0 +ret: 0 st: 0 dts:0.365737 pts:0.365737 pos:17208 size:4080 flags:1 +ret: 0 st: 0 ts:-0.740839 flags:1 +ret: 0 st: 0 dts:-0.741655 pts:-0.741655 pos:49976 size:4080 flags:1 +ret: 0 st:-1 ts:2.153336 flags:0 +ret: 0 st: 0 dts:2.153855 pts:2.153855 pos:100984 size:4080 flags:1 +ret: 0 st:-1 ts:1.047503 flags:1 +ret: 0 st: 0 dts:1.046440 pts:1.046440 pos:49100 size:4080 flags:1 +ret: 0 st: 0 ts:-0.058322 flags:0 +ret: 0 st: 0 dts:-0.058050 pts:-0.058050 pos:81868 size:4080 flags:1 +ret: 0 st: 0 ts:2.835828 flags:1 +ret: 0 st: 0 dts:2.834535 pts:2.834535 pos:132876 size:4080 flags:1 +ret: 0 st:-1 ts:1.730004 flags:0 +ret: 0 st: 0 dts:1.730045 pts:1.730045 pos:81128 size:4080 flags:1 +ret: 0 st:-1 ts:0.624171 flags:1 +ret: 0 st: 0 dts:0.624082 pts:0.624082 pos:29312 size:4080 flags:1 +ret: 0 st: 0 ts:-0.481655 flags:0 +ret: 0 st: 0 dts:-0.480408 pts:-0.480408 pos:62080 size:4080 flags:1 +ret: 0 st: 0 ts:2.412494 flags:1 +ret: 0 st: 0 dts:2.412200 pts:2.412200 pos:113088 size:4080 flags:1 +ret: 0 st:-1 ts:1.306672 flags:0 +ret: 0 st: 0 dts:1.307687 pts:1.307687 pos:61340 size:4080 flags:1 +ret: 0 st:-1 ts:0.200839 flags:1 +ret: 0 st: 0 dts:0.200295 pts:0.200295 pos:9456 size:4080 flags:1 +ret: 0 st: 0 ts:-0.904989 flags:0 +ret: 0 st: 0 dts:-0.904218 pts:-0.904218 pos:42224 size:4080 flags:1 +ret: 0 st: 0 ts:1.989184 flags:1 +ret: 0 st: 0 dts:1.988390 pts:1.988390 pos:93232 size:4080 flags:1 +ret: 0 st:-1 ts:0.883340 flags:0 +ret: 0 st: 0 dts:0.883900 pts:0.883900 pos:41484 size:4080 flags:1 +ret: 0 st:-1 ts:-0.222493 flags:1 +ret: 0 st: 0 dts:-0.223515 pts:-0.223515 pos:74252 size:4080 flags:1 +ret: 0 st: 0 ts:2.671678 flags:0 +ret: 0 st: 0 dts:2.671995 pts:2.671995 pos:125260 size:4080 flags:1 +ret: 0 st: 0 ts:1.565850 flags:1 +ret: 0 st: 0 dts:1.564580 pts:1.564580 pos:73376 size:4080 flags:1 +ret: 0 st:-1 ts:0.460008 flags:0 +ret: 0 st: 0 dts:0.460091 pts:0.460091 pos:21628 size:4080 flags:1 +ret: 0 st:-1 ts:-0.645825 flags:1 +ret: 0 st: 0 dts:-0.645873 pts:-0.645873 pos:54396 size:4080 flags:1 +---------------- tests/data/a-adpcm_ms.wav ret: 0 st: 0 dts:0.000000 pts:0.000000 pos:56 size:4096 flags:1 ret: 0 st:-1 ts:-1.000000 flags:0 |