Mercurial > mplayer.hg
changeset 2420:311676805f20
ima4 mov audio support
author | arpi |
---|---|
date | Tue, 23 Oct 2001 13:56:44 +0000 |
parents | 24ba3dfb8e89 |
children | 32df4022fb1d |
files | dec_audio.c ima4.c ima4.h |
diffstat | 3 files changed, 40 insertions(+), 11 deletions(-) [+] |
line wrap: on
line diff
--- a/dec_audio.c Tue Oct 23 13:55:49 2001 +0000 +++ b/dec_audio.c Tue Oct 23 13:56:44 2001 +0000 @@ -32,6 +32,8 @@ #include "ac3-iec958.h" +#include "ima4.h" + #ifdef USE_DIRECTSHOW #include "loader/DirectShow/DS_AudioDec.h" #endif @@ -227,6 +229,12 @@ // MS-GSM audio codec: sh_audio->audio_out_minsize=4*320; break; +case AFM_IMA4: + // IMA-ADPCM 4:1 audio codec: + sh_audio->audio_out_minsize=4096; //4*IMA4_SAMPLES_PER_BLOCK; + sh_audio->ds->ss_div=IMA4_SAMPLES_PER_BLOCK; + sh_audio->ds->ss_mul=IMA4_BLOCK_SIZE; + break; case AFM_MPEG: // MPEG Audio: sh_audio->audio_out_minsize=4608; @@ -412,6 +420,14 @@ sh_audio->i_bps=65*(sh_audio->channels*sh_audio->samplerate)/320; // 1:10 break; } +case AFM_IMA4: { + // IMA-ADPCM 4:1 audio codec: + sh_audio->channels=sh_audio->wf->nChannels; + sh_audio->samplerate=sh_audio->wf->nSamplesPerSec; + // decodes 34 byte -> 64 short + sh_audio->i_bps=IMA4_BLOCK_SIZE*(sh_audio->channels*sh_audio->samplerate)/IMA4_SAMPLES_PER_BLOCK; // 1:4 + break; +} case AFM_MPEG: { // MPEG Audio: dec_audio_sh=sh_audio; // save sh_audio for the callback: @@ -773,13 +789,19 @@ break; } case AFM_GSM: // MS-GSM decoder - { unsigned char buf[65]; // 65 bytes / frame - if(demux_read_data(sh_audio->ds,buf,65)!=65) break; // EOF - XA_MSGSM_Decoder(buf,(unsigned short *) buf); // decodes 65 byte -> 320 short + { unsigned char ibuf[65]; // 65 bytes / frame + if(demux_read_data(sh_audio->ds,ibuf,65)!=65) break; // EOF + XA_MSGSM_Decoder(ibuf,(unsigned short *) buf); // decodes 65 byte -> 320 short // XA_GSM_Decoder(buf,(unsigned short *) &sh_audio->a_buffer[sh_audio->a_buffer_len]); // decodes 33 byte -> 160 short len=2*320; break; } + case AFM_IMA4: // IMA-ADPCM 4:1 audio codec: + { unsigned char ibuf[IMA4_BLOCK_SIZE]; // bytes / frame + if(demux_read_data(sh_audio->ds,ibuf,IMA4_BLOCK_SIZE)!=IMA4_BLOCK_SIZE) break; // EOF + len=2*ima4_decode_block(buf,ibuf,2*IMA4_SAMPLES_PER_BLOCK); + break; + } case AFM_AC3: // AC3 decoder //printf("{1:%d}",avi_header.idx_pos);fflush(stdout); if(!sh_audio->ac3_frame) sh_audio->ac3_frame=ac3_decode_frame();
--- a/ima4.c Tue Oct 23 13:55:49 2001 +0000 +++ b/ima4.c Tue Oct 23 13:56:44 2001 +0000 @@ -23,11 +23,6 @@ -1, -1, -1, -1, 2, 4, 6, 8 }; -/* Known by divine revelation */ - -#define BLOCK_SIZE 0x22 -#define SAMPLES_PER_BLOCK 0x40 - /* ================================== private for ima4 */ @@ -66,7 +61,7 @@ *step = quicktime_ima4_step[*index]; } -int ima4_decode_block(int16_t *output, unsigned char *input, int maxlen) +int ima4_decode_block(unsigned short *output, unsigned char *input, int maxlen) { int predictor; int index; @@ -74,7 +69,7 @@ int i, nibble, nibble_count, block_size; int olen = 0; unsigned char *block_ptr; - unsigned char *input_end = input + BLOCK_SIZE; + unsigned char *input_end = input + IMA4_BLOCK_SIZE; // quicktime_ima4_codec_t *codec = ((quicktime_codec_t*)atrack->codec)->priv; /* Get the chunk header */
--- a/ima4.h Tue Oct 23 13:55:49 2001 +0000 +++ b/ima4.h Tue Oct 23 13:56:44 2001 +0000 @@ -2,7 +2,18 @@ #define QUICKTIME_IMA4_H //#include "quicktime.h" -#include "inttypes.h" +//#include "inttypes.h" + +/* Known by divine revelation */ + +#define IMA4_BLOCK_SIZE 0x22 +#define IMA4_SAMPLES_PER_BLOCK 0x40 + +// in: out buffer, in buffer (IMA4_BLOCK_SIZE bytes), outbuf max size +// return: number of samples decoded +int ima4_decode_block(unsigned short *output, unsigned char *input, int maxlen); + +#if 0 typedef struct { @@ -24,5 +35,6 @@ long read_size; /* Size of read buffer. */ } quicktime_ima4_codec_t; +#endif #endif