summaryrefslogtreecommitdiffstats
path: root/libmpcodecs/ad_realaud.c
diff options
context:
space:
mode:
Diffstat (limited to 'libmpcodecs/ad_realaud.c')
-rw-r--r--libmpcodecs/ad_realaud.c126
1 files changed, 26 insertions, 100 deletions
diff --git a/libmpcodecs/ad_realaud.c b/libmpcodecs/ad_realaud.c
index 18039d49b6..2d4361f9ea 100644
--- a/libmpcodecs/ad_realaud.c
+++ b/libmpcodecs/ad_realaud.c
@@ -291,10 +291,10 @@ static int preinit(sh_audio_t *sh){
sh->wf->wBitsPerSample,
sh->wf->nChannels,
100, // quality
- ((short*)(sh->wf+1))[0], // subpacket size
- ((short*)(sh->wf+1))[3], // coded frame size
- ((short*)(sh->wf+1))[4], // codec data length
- ((char*)(sh->wf+1))+10 // extras
+ sh->wf->nBlockAlign, // subpacket size
+ sh->wf->nBlockAlign, // coded frame size
+ sh->wf->cbSize, // codec data length
+ (char*)(sh->wf+1) // extras
};
#ifdef USE_WIN32DLL
wra_init_t winit_data={
@@ -302,10 +302,10 @@ static int preinit(sh_audio_t *sh){
sh->wf->wBitsPerSample,
sh->wf->nChannels,
100, // quality
- ((short*)(sh->wf+1))[0], // subpacket size
- ((short*)(sh->wf+1))[3], // coded frame size
- ((short*)(sh->wf+1))[4], // codec data length
- ((char*)(sh->wf+1))+10 // extras
+ sh->wf->nBlockAlign, // subpacket size
+ sh->wf->nBlockAlign, // coded frame size
+ sh->wf->cbSize, // codec data length
+ (char*)(sh->wf+1) // extras
};
#endif
#ifdef USE_WIN32DLL
@@ -336,42 +336,35 @@ static int preinit(sh_audio_t *sh){
raSetPwd(sh->context,"Ardubancel Quazanga"); // set password... lol.
}
+ if (sh->format == mmioFOURCC('s','i','p','r')) {
+ short flavor;
+
+ if (sh->wf->nAvgBytesPerSec > 1531)
+ flavor = 3;
+ else if (sh->wf->nAvgBytesPerSec > 937)
+ flavor = 1;
+ else if (sh->wf->nAvgBytesPerSec > 719)
+ flavor = 0;
+ else
+ flavor = 2;
+ mp_msg(MSGT_DECAUDIO,MSGL_V,"Got sipr flavor %d from bitrate %d\n",flavor, sh->wf->nAvgBytesPerSec);
+
#ifdef USE_WIN32DLL
if (dll_type == 1)
- result=wraSetFlavor(sh->context,((short*)(sh->wf+1))[2]);
+ result=wraSetFlavor(sh->context,flavor);
else
#endif
- result=raSetFlavor(sh->context,((short*)(sh->wf+1))[2]);
+ result=raSetFlavor(sh->context,flavor);
if(result){
mp_msg(MSGT_DECAUDIO,MSGL_WARN,"Decoder flavor setup failed, error code: 0x%X\n",result);
return 0;
}
+ } // sipr flavor
-#ifdef USE_WIN32DLL
- if (dll_type == 1)
- prop=wraGetFlavorProperty(sh->context,((short*)(sh->wf+1))[2],0,&len);
- else
-#endif
- prop=raGetFlavorProperty(sh->context,((short*)(sh->wf+1))[2],0,&len);
- mp_msg(MSGT_DECAUDIO,MSGL_INFO,"Audio codec: [%d] %s\n",((short*)(sh->wf+1))[2],prop);
-
-#ifdef USE_WIN32DLL
- if (dll_type == 1)
- prop=wraGetFlavorProperty(sh->context,((short*)(sh->wf+1))[2],1,&len);
- else
-#endif
- prop=raGetFlavorProperty(sh->context,((short*)(sh->wf+1))[2],1,&len);
- if(prop){
- sh->i_bps=((*((int*)prop))+4)/8;
- mp_msg(MSGT_DECAUDIO,MSGL_INFO,"Audio bitrate: %5.3f kbit/s (%d bps) \n",(*((int*)prop))*0.001f,sh->i_bps);
- } else
- sh->i_bps=12000; // dunno :((( [12000 seems to be OK for crash.rmvb too]
+ sh->i_bps=sh->wf->nAvgBytesPerSec;
-// prop=raGetFlavorProperty(sh->context,((short*)(sh->wf+1))[2],0x13,&len);
-// mp_msg(MSGT_DECAUDIO,MSGL_INFO,"Samples/block?: %d \n",(*((int*)prop)));
-
sh->audio_out_minsize=128000; // no idea how to get... :(
- sh->audio_in_minsize=((short*)(sh->wf+1))[1]*sh->wf->nBlockAlign;
+ sh->audio_in_minsize = sh->wf->nBlockAlign;
return 1; // return values: 1=OK 0=ERROR
}
@@ -413,83 +406,16 @@ static void uninit(sh_audio_t *sh){
rv_handle = NULL;
}
-static unsigned char sipr_swaps[38][2]={
- {0,63},{1,22},{2,44},{3,90},{5,81},{7,31},{8,86},{9,58},{10,36},{12,68},
- {13,39},{14,73},{15,53},{16,69},{17,57},{19,88},{20,34},{21,71},{24,46},
- {25,94},{26,54},{28,75},{29,50},{32,70},{33,92},{35,74},{38,85},{40,56},
- {42,87},{43,65},{45,59},{48,79},{49,93},{51,89},{55,95},{61,76},{67,83},
- {77,80} };
-
static int decode_audio(sh_audio_t *sh,unsigned char *buf,int minlen,int maxlen){
int result;
int len=-1;
- int sps=((short*)(sh->wf+1))[0];
- int w=sh->wf->nBlockAlign; // 5
- int h=((short*)(sh->wf+1))[1];
- int cfs=((short*)(sh->wf+1))[3];
-// printf("bs=%d sps=%d w=%d h=%d \n",sh->wf->nBlockAlign,sps,w,h);
-
-#if 1
- if(sh->a_in_buffer_len<=0){
- if (sh->ds->eof) return 0;
- // fill the buffer!
- if (sh->format == mmioFOURCC('1','4','_','4')) {
- demux_read_data(sh->ds, sh->a_in_buffer, sh->wf->nBlockAlign);
- sh->a_in_buffer_size=
- sh->a_in_buffer_len=sh->wf->nBlockAlign;
- } else
- if (sh->format == mmioFOURCC('2','8','_','8')) {
- int i,j;
- for (j = 0; j < h; j++)
- for (i = 0; i < h/2; i++)
- demux_read_data(sh->ds, sh->a_in_buffer+i*2*w+j*cfs, cfs);
- sh->a_in_buffer_size=
- sh->a_in_buffer_len=sh->wf->nBlockAlign*h;
- } else
- if((sh->format == mmioFOURCC('s','i','p','r')) || !sps){ // is !sps really needed? (cook with sipr matrix?)
- // 'sipr' way
- int j,n;
- int bs=h*w*2/96; // nibbles per subpacket
- unsigned char *p=sh->a_in_buffer;
- demux_read_data(sh->ds, p, h*w);
- for(n=0;n<38;n++){
- int i=bs*sipr_swaps[n][0];
- int o=bs*sipr_swaps[n][1];
- // swap nibbles of block 'i' with 'o' TODO: optimize
- for(j=0;j<bs;j++){
- int x=(i&1) ? (p[(i>>1)]>>4) : (p[(i>>1)]&15);
- int y=(o&1) ? (p[(o>>1)]>>4) : (p[(o>>1)]&15);
- if(o&1) p[(o>>1)]=(p[(o>>1)]&0x0F)|(x<<4);
- else p[(o>>1)]=(p[(o>>1)]&0xF0)|x;
- if(i&1) p[(i>>1)]=(p[(i>>1)]&0x0F)|(y<<4);
- else p[(i>>1)]=(p[(i>>1)]&0xF0)|y;
- ++i;++o;
- }
- }
- sh->a_in_buffer_size=
- sh->a_in_buffer_len=w*h;
- } else {
- // 'cook' way
- int x,y;
- w/=sps;
- for(y=0;y<h;y++)
- for(x=0;x<w;x++){
- demux_read_data(sh->ds, sh->a_in_buffer+sps*(h*x+((h+1)/2)*(y&1)+(y>>1)), sps);
- }
- sh->a_in_buffer_size=
- sh->a_in_buffer_len=w*h*sps;
- }
- }
-
-#else
if(sh->a_in_buffer_len<=0){
// fill the buffer!
demux_read_data(sh->ds, sh->a_in_buffer, sh->wf->nBlockAlign);
sh->a_in_buffer_size=
sh->a_in_buffer_len=sh->wf->nBlockAlign;
}
-#endif
#ifdef USE_WIN32DLL
if (dll_type == 1)