mirror of https://github.com/mpv-player/mpv
ima4 mov audio support
git-svn-id: svn://svn.mplayerhq.hu/mplayer/trunk@2421 b3059339-0415-0410-9bf9-f77b7e298cf2
This commit is contained in:
parent
adfdd89012
commit
5462f7f527
28
dec_audio.c
28
dec_audio.c
|
@ -32,6 +32,8 @@ int fakemono=0;
|
|||
|
||||
#include "ac3-iec958.h"
|
||||
|
||||
#include "ima4.h"
|
||||
|
||||
#ifdef USE_DIRECTSHOW
|
||||
#include "loader/DirectShow/DS_AudioDec.h"
|
||||
#endif
|
||||
|
@ -227,6 +229,12 @@ case AFM_GSM:
|
|||
// 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 @@ case AFM_GSM: {
|
|||
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 @@ int decode_audio(sh_audio_t *sh_audio,unsigned char *buf,int minlen,int maxlen){
|
|||
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();
|
||||
|
|
9
ima4.c
9
ima4.c
|
@ -23,11 +23,6 @@ static int quicktime_ima4_index[16] =
|
|||
-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 @@ void ima4_decode_sample(int *predictor, int *nibble, int *index, int *step)
|
|||
*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 ima4_decode_block(int16_t *output, unsigned char *input, int maxlen)
|
|||
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 */
|
||||
|
|
14
ima4.h
14
ima4.h
|
@ -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 @@ typedef struct
|
|||
long read_size; /* Size of read buffer. */
|
||||
} quicktime_ima4_codec_t;
|
||||
|
||||
#endif
|
||||
|
||||
#endif
|
||||
|
|
Loading…
Reference in New Issue