annotate libmpcodecs/ad_realaud.c @ 8179:63a5e03f4346

Removed hard coded value for the length of the header separator. Used the value previous detected.
author bertrand
date Wed, 13 Nov 2002 09:02:55 +0000
parents b8a90a2af611
children 2d651a218031
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
6367
489c4bcbda13 readaudio decoder - not yet working
arpi
parents:
diff changeset
1
489c4bcbda13 readaudio decoder - not yet working
arpi
parents:
diff changeset
2 #include <stdio.h>
489c4bcbda13 readaudio decoder - not yet working
arpi
parents:
diff changeset
3 #include <stdlib.h>
489c4bcbda13 readaudio decoder - not yet working
arpi
parents:
diff changeset
4 #include <unistd.h>
489c4bcbda13 readaudio decoder - not yet working
arpi
parents:
diff changeset
5
489c4bcbda13 readaudio decoder - not yet working
arpi
parents:
diff changeset
6 #include "config.h"
489c4bcbda13 readaudio decoder - not yet working
arpi
parents:
diff changeset
7
489c4bcbda13 readaudio decoder - not yet working
arpi
parents:
diff changeset
8 #ifdef USE_REALCODECS
489c4bcbda13 readaudio decoder - not yet working
arpi
parents:
diff changeset
9
489c4bcbda13 readaudio decoder - not yet working
arpi
parents:
diff changeset
10 #include <stddef.h>
489c4bcbda13 readaudio decoder - not yet working
arpi
parents:
diff changeset
11 #include <dlfcn.h>
489c4bcbda13 readaudio decoder - not yet working
arpi
parents:
diff changeset
12
489c4bcbda13 readaudio decoder - not yet working
arpi
parents:
diff changeset
13 #include "ad_internal.h"
489c4bcbda13 readaudio decoder - not yet working
arpi
parents:
diff changeset
14
489c4bcbda13 readaudio decoder - not yet working
arpi
parents:
diff changeset
15 static ad_info_t info = {
6380
947d6a639c5a fixed copyright
arpi
parents: 6377
diff changeset
16 "RealAudio decoder",
7174
7672615cc811 sync driver names with codec-cfg
arpi
parents: 7172
diff changeset
17 "realaud",
6380
947d6a639c5a fixed copyright
arpi
parents: 6377
diff changeset
18 "A'rpi",
947d6a639c5a fixed copyright
arpi
parents: 6377
diff changeset
19 "Florian Schneider",
947d6a639c5a fixed copyright
arpi
parents: 6377
diff changeset
20 "binary real audio codecs"
6367
489c4bcbda13 readaudio decoder - not yet working
arpi
parents:
diff changeset
21 };
489c4bcbda13 readaudio decoder - not yet working
arpi
parents:
diff changeset
22
7174
7672615cc811 sync driver names with codec-cfg
arpi
parents: 7172
diff changeset
23 LIBAD_EXTERN(realaud)
6367
489c4bcbda13 readaudio decoder - not yet working
arpi
parents:
diff changeset
24
489c4bcbda13 readaudio decoder - not yet working
arpi
parents:
diff changeset
25 static void *handle=NULL;
489c4bcbda13 readaudio decoder - not yet working
arpi
parents:
diff changeset
26
489c4bcbda13 readaudio decoder - not yet working
arpi
parents:
diff changeset
27 void *__builtin_new(unsigned long size) {
489c4bcbda13 readaudio decoder - not yet working
arpi
parents:
diff changeset
28 return malloc(size);
489c4bcbda13 readaudio decoder - not yet working
arpi
parents:
diff changeset
29 }
489c4bcbda13 readaudio decoder - not yet working
arpi
parents:
diff changeset
30
6404
83b3315c679b Implement Nilmoni's and Bernd Ernesti's patches for:
atmos4
parents: 6380
diff changeset
31 #if defined(__FreeBSD__) || defined(__NetBSD__)
83b3315c679b Implement Nilmoni's and Bernd Ernesti's patches for:
atmos4
parents: 6380
diff changeset
32 void *__ctype_b=NULL;
6377
203128bcc6be FreeBSD hack
nexus
parents: 6376
diff changeset
33 #endif
6367
489c4bcbda13 readaudio decoder - not yet working
arpi
parents:
diff changeset
34
7472
c4434bdf6e51 tons of warning fixes, also some 10l bugfixes, including Dominik's PVA bug
arpi
parents: 7180
diff changeset
35 static unsigned long (*raCloseCodec)(void*);
7557
f296ff05bcd0 warning fixes
arpi
parents: 7472
diff changeset
36 static unsigned long (*raDecode)(void*, char*,unsigned long,char*,unsigned int*,long);
6745
9734bfbb200a Avoid ulong typedef clash and replace if by unsigned long, patch by Joey Parrish.
atmos4
parents: 6428
diff changeset
37 static unsigned long (*raFlush)(unsigned long,unsigned long,unsigned long);
7472
c4434bdf6e51 tons of warning fixes, also some 10l bugfixes, including Dominik's PVA bug
arpi
parents: 7180
diff changeset
38 static unsigned long (*raFreeDecoder)(void*);
7557
f296ff05bcd0 warning fixes
arpi
parents: 7472
diff changeset
39 static void* (*raGetFlavorProperty)(void*,unsigned long,unsigned long,int*);
6745
9734bfbb200a Avoid ulong typedef clash and replace if by unsigned long, patch by Joey Parrish.
atmos4
parents: 6428
diff changeset
40 //static unsigned long (*raGetNumberOfFlavors2)(void);
7472
c4434bdf6e51 tons of warning fixes, also some 10l bugfixes, including Dominik's PVA bug
arpi
parents: 7180
diff changeset
41 static unsigned long (*raInitDecoder)(void*, void*);
c4434bdf6e51 tons of warning fixes, also some 10l bugfixes, including Dominik's PVA bug
arpi
parents: 7180
diff changeset
42 static unsigned long (*raOpenCodec2)(void*);
c4434bdf6e51 tons of warning fixes, also some 10l bugfixes, including Dominik's PVA bug
arpi
parents: 7180
diff changeset
43 static unsigned long (*raSetFlavor)(void*,unsigned long);
7752
18f8233094da tell the codec wrapper the codec path (fixes realaudio Sipr)
arpi
parents: 7557
diff changeset
44 static void (*raSetDLLAccessPath)(char*);
7086
f0886fe4be89 support for 'sipr' codec - descrambling/reorder not yet fixed.
arpi
parents: 6745
diff changeset
45 static void (*raSetPwd)(char*,char*);
6367
489c4bcbda13 readaudio decoder - not yet working
arpi
parents:
diff changeset
46
489c4bcbda13 readaudio decoder - not yet working
arpi
parents:
diff changeset
47 typedef struct {
489c4bcbda13 readaudio decoder - not yet working
arpi
parents:
diff changeset
48 int samplerate;
489c4bcbda13 readaudio decoder - not yet working
arpi
parents:
diff changeset
49 short bits;
489c4bcbda13 readaudio decoder - not yet working
arpi
parents:
diff changeset
50 short channels;
489c4bcbda13 readaudio decoder - not yet working
arpi
parents:
diff changeset
51 int unk1;
489c4bcbda13 readaudio decoder - not yet working
arpi
parents:
diff changeset
52 int unk2;
489c4bcbda13 readaudio decoder - not yet working
arpi
parents:
diff changeset
53 int packetsize;
489c4bcbda13 readaudio decoder - not yet working
arpi
parents:
diff changeset
54 int unk3;
489c4bcbda13 readaudio decoder - not yet working
arpi
parents:
diff changeset
55 void* unk4;
489c4bcbda13 readaudio decoder - not yet working
arpi
parents:
diff changeset
56 } ra_init_t;
489c4bcbda13 readaudio decoder - not yet working
arpi
parents:
diff changeset
57
489c4bcbda13 readaudio decoder - not yet working
arpi
parents:
diff changeset
58 static int preinit(sh_audio_t *sh){
489c4bcbda13 readaudio decoder - not yet working
arpi
parents:
diff changeset
59 // let's check if the driver is available, return 0 if not.
489c4bcbda13 readaudio decoder - not yet working
arpi
parents:
diff changeset
60 // (you should do that if you use external lib(s) which is optional)
489c4bcbda13 readaudio decoder - not yet working
arpi
parents:
diff changeset
61 unsigned int result;
7472
c4434bdf6e51 tons of warning fixes, also some 10l bugfixes, including Dominik's PVA bug
arpi
parents: 7180
diff changeset
62 int len=0;
6380
947d6a639c5a fixed copyright
arpi
parents: 6377
diff changeset
63 void* prop;
6376
e3c74c01a3a2 use path & dllname from config
arpi
parents: 6373
diff changeset
64 char path[4096];
6404
83b3315c679b Implement Nilmoni's and Bernd Ernesti's patches for:
atmos4
parents: 6380
diff changeset
65 sprintf(path, REALCODEC_PATH "/%s", sh->codec->dll);
6376
e3c74c01a3a2 use path & dllname from config
arpi
parents: 6373
diff changeset
66 handle = dlopen (path, RTLD_LAZY);
6367
489c4bcbda13 readaudio decoder - not yet working
arpi
parents:
diff changeset
67 if(!handle){
489c4bcbda13 readaudio decoder - not yet working
arpi
parents:
diff changeset
68 mp_msg(MSGT_DECAUDIO,MSGL_WARN,"Cannot open dll: %s\n",dlerror());
489c4bcbda13 readaudio decoder - not yet working
arpi
parents:
diff changeset
69 return 0;
489c4bcbda13 readaudio decoder - not yet working
arpi
parents:
diff changeset
70 }
489c4bcbda13 readaudio decoder - not yet working
arpi
parents:
diff changeset
71
489c4bcbda13 readaudio decoder - not yet working
arpi
parents:
diff changeset
72 raCloseCodec = dlsym(handle, "RACloseCodec");
489c4bcbda13 readaudio decoder - not yet working
arpi
parents:
diff changeset
73 raDecode = dlsym(handle, "RADecode");
489c4bcbda13 readaudio decoder - not yet working
arpi
parents:
diff changeset
74 raFlush = dlsym(handle, "RAFlush");
489c4bcbda13 readaudio decoder - not yet working
arpi
parents:
diff changeset
75 raFreeDecoder = dlsym(handle, "RAFreeDecoder");
489c4bcbda13 readaudio decoder - not yet working
arpi
parents:
diff changeset
76 raGetFlavorProperty = dlsym(handle, "RAGetFlavorProperty");
489c4bcbda13 readaudio decoder - not yet working
arpi
parents:
diff changeset
77 raOpenCodec2 = dlsym(handle, "RAOpenCodec2");
489c4bcbda13 readaudio decoder - not yet working
arpi
parents:
diff changeset
78 raInitDecoder = dlsym(handle, "RAInitDecoder");
489c4bcbda13 readaudio decoder - not yet working
arpi
parents:
diff changeset
79 raSetFlavor = dlsym(handle, "RASetFlavor");
7752
18f8233094da tell the codec wrapper the codec path (fixes realaudio Sipr)
arpi
parents: 7557
diff changeset
80 raSetDLLAccessPath = dlsym(handle, "SetDLLAccessPath");
7086
f0886fe4be89 support for 'sipr' codec - descrambling/reorder not yet fixed.
arpi
parents: 6745
diff changeset
81 raSetPwd = dlsym(handle, "RASetPwd"); // optional, used by SIPR
6367
489c4bcbda13 readaudio decoder - not yet working
arpi
parents:
diff changeset
82
489c4bcbda13 readaudio decoder - not yet working
arpi
parents:
diff changeset
83 if(!raCloseCodec || !raDecode || !raFlush || !raFreeDecoder ||
489c4bcbda13 readaudio decoder - not yet working
arpi
parents:
diff changeset
84 !raGetFlavorProperty || !raOpenCodec2 || !raSetFlavor ||
7097
5c87f14ad947 SetDLLAccessPath isn't used. Patch by Andres Hess <jaska@gmx.net>
alex
parents: 7086
diff changeset
85 /*!raSetDLLAccessPath ||*/ !raInitDecoder){
7752
18f8233094da tell the codec wrapper the codec path (fixes realaudio Sipr)
arpi
parents: 7557
diff changeset
86 mp_msg(MSGT_DECAUDIO,MSGL_WARN,"Cannot resolve symbols - incompatible dll: %s\n",path);
6367
489c4bcbda13 readaudio decoder - not yet working
arpi
parents:
diff changeset
87 return 0;
489c4bcbda13 readaudio decoder - not yet working
arpi
parents:
diff changeset
88 }
489c4bcbda13 readaudio decoder - not yet working
arpi
parents:
diff changeset
89
7752
18f8233094da tell the codec wrapper the codec path (fixes realaudio Sipr)
arpi
parents: 7557
diff changeset
90 if(raSetDLLAccessPath){
18f8233094da tell the codec wrapper the codec path (fixes realaudio Sipr)
arpi
parents: 7557
diff changeset
91 sprintf(path, "DT_Codecs=" REALCODEC_PATH);
18f8233094da tell the codec wrapper the codec path (fixes realaudio Sipr)
arpi
parents: 7557
diff changeset
92 if(path[strlen(path)-1]!='/'){
18f8233094da tell the codec wrapper the codec path (fixes realaudio Sipr)
arpi
parents: 7557
diff changeset
93 path[strlen(path)+1]=0;
18f8233094da tell the codec wrapper the codec path (fixes realaudio Sipr)
arpi
parents: 7557
diff changeset
94 path[strlen(path)]='/';
18f8233094da tell the codec wrapper the codec path (fixes realaudio Sipr)
arpi
parents: 7557
diff changeset
95 }
18f8233094da tell the codec wrapper the codec path (fixes realaudio Sipr)
arpi
parents: 7557
diff changeset
96 path[strlen(path)+1]=0;
18f8233094da tell the codec wrapper the codec path (fixes realaudio Sipr)
arpi
parents: 7557
diff changeset
97 raSetDLLAccessPath(path);
18f8233094da tell the codec wrapper the codec path (fixes realaudio Sipr)
arpi
parents: 7557
diff changeset
98 }
18f8233094da tell the codec wrapper the codec path (fixes realaudio Sipr)
arpi
parents: 7557
diff changeset
99
6367
489c4bcbda13 readaudio decoder - not yet working
arpi
parents:
diff changeset
100 result=raOpenCodec2(&sh->context);
489c4bcbda13 readaudio decoder - not yet working
arpi
parents:
diff changeset
101 if(result){
489c4bcbda13 readaudio decoder - not yet working
arpi
parents:
diff changeset
102 mp_msg(MSGT_DECAUDIO,MSGL_WARN,"Decoder open failed, error code: 0x%X\n",result);
489c4bcbda13 readaudio decoder - not yet working
arpi
parents:
diff changeset
103 return 0;
489c4bcbda13 readaudio decoder - not yet working
arpi
parents:
diff changeset
104 }
489c4bcbda13 readaudio decoder - not yet working
arpi
parents:
diff changeset
105
489c4bcbda13 readaudio decoder - not yet working
arpi
parents:
diff changeset
106 sh->samplerate=sh->wf->nSamplesPerSec;
489c4bcbda13 readaudio decoder - not yet working
arpi
parents:
diff changeset
107 sh->samplesize=sh->wf->wBitsPerSample/8;
489c4bcbda13 readaudio decoder - not yet working
arpi
parents:
diff changeset
108 sh->channels=sh->wf->nChannels;
489c4bcbda13 readaudio decoder - not yet working
arpi
parents:
diff changeset
109
7472
c4434bdf6e51 tons of warning fixes, also some 10l bugfixes, including Dominik's PVA bug
arpi
parents: 7180
diff changeset
110 {
6367
489c4bcbda13 readaudio decoder - not yet working
arpi
parents:
diff changeset
111 ra_init_t init_data={
489c4bcbda13 readaudio decoder - not yet working
arpi
parents:
diff changeset
112 sh->wf->nSamplesPerSec,sh->wf->wBitsPerSample,sh->wf->nChannels,
6373
8d5d339f2944 get matrix w*h from the demuxer
arpi
parents: 6370
diff changeset
113 100, // ???
8d5d339f2944 get matrix w*h from the demuxer
arpi
parents: 6370
diff changeset
114 ((short*)(sh->wf+1))[0], // subpacket size
8094
b8a90a2af611 - realaudio ATRC (sony atrac3) codec support
arpi
parents: 7752
diff changeset
115 ((short*)(sh->wf+1))[3], // coded frame size
b8a90a2af611 - realaudio ATRC (sony atrac3) codec support
arpi
parents: 7752
diff changeset
116 ((short*)(sh->wf+1))[4], // codec data length
b8a90a2af611 - realaudio ATRC (sony atrac3) codec support
arpi
parents: 7752
diff changeset
117 ((char*)(sh->wf+1))+10 // extras
6367
489c4bcbda13 readaudio decoder - not yet working
arpi
parents:
diff changeset
118 };
489c4bcbda13 readaudio decoder - not yet working
arpi
parents:
diff changeset
119 result=raInitDecoder(sh->context,&init_data);
489c4bcbda13 readaudio decoder - not yet working
arpi
parents:
diff changeset
120 if(result){
489c4bcbda13 readaudio decoder - not yet working
arpi
parents:
diff changeset
121 mp_msg(MSGT_DECAUDIO,MSGL_WARN,"Decoder init failed, error code: 0x%X\n",result);
489c4bcbda13 readaudio decoder - not yet working
arpi
parents:
diff changeset
122 return 0;
489c4bcbda13 readaudio decoder - not yet working
arpi
parents:
diff changeset
123 }
489c4bcbda13 readaudio decoder - not yet working
arpi
parents:
diff changeset
124 }
7086
f0886fe4be89 support for 'sipr' codec - descrambling/reorder not yet fixed.
arpi
parents: 6745
diff changeset
125
f0886fe4be89 support for 'sipr' codec - descrambling/reorder not yet fixed.
arpi
parents: 6745
diff changeset
126 if(raSetPwd){
f0886fe4be89 support for 'sipr' codec - descrambling/reorder not yet fixed.
arpi
parents: 6745
diff changeset
127 // used by 'SIPR'
f0886fe4be89 support for 'sipr' codec - descrambling/reorder not yet fixed.
arpi
parents: 6745
diff changeset
128 raSetPwd(sh->context,"Ardubancel Quazanga"); // set password... lol.
f0886fe4be89 support for 'sipr' codec - descrambling/reorder not yet fixed.
arpi
parents: 6745
diff changeset
129 }
6367
489c4bcbda13 readaudio decoder - not yet working
arpi
parents:
diff changeset
130
6373
8d5d339f2944 get matrix w*h from the demuxer
arpi
parents: 6370
diff changeset
131 result=raSetFlavor(sh->context,((short*)(sh->wf+1))[2]);
6367
489c4bcbda13 readaudio decoder - not yet working
arpi
parents:
diff changeset
132 if(result){
489c4bcbda13 readaudio decoder - not yet working
arpi
parents:
diff changeset
133 mp_msg(MSGT_DECAUDIO,MSGL_WARN,"Decoder flavor setup failed, error code: 0x%X\n",result);
489c4bcbda13 readaudio decoder - not yet working
arpi
parents:
diff changeset
134 return 0;
489c4bcbda13 readaudio decoder - not yet working
arpi
parents:
diff changeset
135 }
489c4bcbda13 readaudio decoder - not yet working
arpi
parents:
diff changeset
136
6380
947d6a639c5a fixed copyright
arpi
parents: 6377
diff changeset
137 prop=raGetFlavorProperty(sh->context,((short*)(sh->wf+1))[2],0,&len);
947d6a639c5a fixed copyright
arpi
parents: 6377
diff changeset
138 mp_msg(MSGT_DECAUDIO,MSGL_INFO,"Audio codec: [%d] %s\n",((short*)(sh->wf+1))[2],prop);
947d6a639c5a fixed copyright
arpi
parents: 6377
diff changeset
139
947d6a639c5a fixed copyright
arpi
parents: 6377
diff changeset
140 prop=raGetFlavorProperty(sh->context,((short*)(sh->wf+1))[2],1,&len);
947d6a639c5a fixed copyright
arpi
parents: 6377
diff changeset
141 sh->i_bps=((*((int*)prop))+4)/8;
947d6a639c5a fixed copyright
arpi
parents: 6377
diff changeset
142 mp_msg(MSGT_DECAUDIO,MSGL_INFO,"Audio bitrate: %5.3f kbit/s (%d bps) \n",(*((int*)prop))*0.001f,sh->i_bps);
947d6a639c5a fixed copyright
arpi
parents: 6377
diff changeset
143
947d6a639c5a fixed copyright
arpi
parents: 6377
diff changeset
144 // prop=raGetFlavorProperty(sh->context,((short*)(sh->wf+1))[2],0x13,&len);
947d6a639c5a fixed copyright
arpi
parents: 6377
diff changeset
145 // mp_msg(MSGT_DECAUDIO,MSGL_INFO,"Samples/block?: %d \n",(*((int*)prop)));
947d6a639c5a fixed copyright
arpi
parents: 6377
diff changeset
146
947d6a639c5a fixed copyright
arpi
parents: 6377
diff changeset
147 sh->audio_out_minsize=128000; // no idea how to get... :(
6373
8d5d339f2944 get matrix w*h from the demuxer
arpi
parents: 6370
diff changeset
148 sh->audio_in_minsize=((short*)(sh->wf+1))[1]*sh->wf->nBlockAlign;
6367
489c4bcbda13 readaudio decoder - not yet working
arpi
parents:
diff changeset
149
489c4bcbda13 readaudio decoder - not yet working
arpi
parents:
diff changeset
150 return 1; // return values: 1=OK 0=ERROR
489c4bcbda13 readaudio decoder - not yet working
arpi
parents:
diff changeset
151 }
489c4bcbda13 readaudio decoder - not yet working
arpi
parents:
diff changeset
152
489c4bcbda13 readaudio decoder - not yet working
arpi
parents:
diff changeset
153 static int init(sh_audio_t *sh_audio){
489c4bcbda13 readaudio decoder - not yet working
arpi
parents:
diff changeset
154 // initialize the decoder, set tables etc...
489c4bcbda13 readaudio decoder - not yet working
arpi
parents:
diff changeset
155
489c4bcbda13 readaudio decoder - not yet working
arpi
parents:
diff changeset
156 // you can store HANDLE or private struct pointer at sh->context
489c4bcbda13 readaudio decoder - not yet working
arpi
parents:
diff changeset
157 // you can access WAVEFORMATEX header at sh->wf
489c4bcbda13 readaudio decoder - not yet working
arpi
parents:
diff changeset
158
489c4bcbda13 readaudio decoder - not yet working
arpi
parents:
diff changeset
159 // set sample format/rate parameters if you didn't do it in preinit() yet.
489c4bcbda13 readaudio decoder - not yet working
arpi
parents:
diff changeset
160
489c4bcbda13 readaudio decoder - not yet working
arpi
parents:
diff changeset
161 return 1; // return values: 1=OK 0=ERROR
489c4bcbda13 readaudio decoder - not yet working
arpi
parents:
diff changeset
162 }
489c4bcbda13 readaudio decoder - not yet working
arpi
parents:
diff changeset
163
489c4bcbda13 readaudio decoder - not yet working
arpi
parents:
diff changeset
164 static void uninit(sh_audio_t *sh){
489c4bcbda13 readaudio decoder - not yet working
arpi
parents:
diff changeset
165 // uninit the decoder etc...
489c4bcbda13 readaudio decoder - not yet working
arpi
parents:
diff changeset
166 // again: you don't have to free() a_in_buffer here! it's done by the core.
489c4bcbda13 readaudio decoder - not yet working
arpi
parents:
diff changeset
167 }
489c4bcbda13 readaudio decoder - not yet working
arpi
parents:
diff changeset
168
7104
6d784b2812b9 'sipr' descrambling implemented, at least for 16*6 matrix
arpi
parents: 7097
diff changeset
169 static unsigned char sipr_swaps[38][2]={
6d784b2812b9 'sipr' descrambling implemented, at least for 16*6 matrix
arpi
parents: 7097
diff changeset
170 {0,63},{1,22},{2,44},{3,90},{5,81},{7,31},{8,86},{9,58},{10,36},{12,68},
6d784b2812b9 'sipr' descrambling implemented, at least for 16*6 matrix
arpi
parents: 7097
diff changeset
171 {13,39},{14,73},{15,53},{16,69},{17,57},{19,88},{20,34},{21,71},{24,46},
6d784b2812b9 'sipr' descrambling implemented, at least for 16*6 matrix
arpi
parents: 7097
diff changeset
172 {25,94},{26,54},{28,75},{29,50},{32,70},{33,92},{35,74},{38,85},{40,56},
6d784b2812b9 'sipr' descrambling implemented, at least for 16*6 matrix
arpi
parents: 7097
diff changeset
173 {42,87},{43,65},{45,59},{48,79},{49,93},{51,89},{55,95},{61,76},{67,83},
6d784b2812b9 'sipr' descrambling implemented, at least for 16*6 matrix
arpi
parents: 7097
diff changeset
174 {77,80} };
6d784b2812b9 'sipr' descrambling implemented, at least for 16*6 matrix
arpi
parents: 7097
diff changeset
175
6367
489c4bcbda13 readaudio decoder - not yet working
arpi
parents:
diff changeset
176 static int decode_audio(sh_audio_t *sh,unsigned char *buf,int minlen,int maxlen){
489c4bcbda13 readaudio decoder - not yet working
arpi
parents:
diff changeset
177 int result;
489c4bcbda13 readaudio decoder - not yet working
arpi
parents:
diff changeset
178 int len=-1;
6373
8d5d339f2944 get matrix w*h from the demuxer
arpi
parents: 6370
diff changeset
179 int sps=((short*)(sh->wf+1))[0];
7086
f0886fe4be89 support for 'sipr' codec - descrambling/reorder not yet fixed.
arpi
parents: 6745
diff changeset
180 int w=sh->wf->nBlockAlign; // 5
6373
8d5d339f2944 get matrix w*h from the demuxer
arpi
parents: 6370
diff changeset
181 int h=((short*)(sh->wf+1))[1];
7104
6d784b2812b9 'sipr' descrambling implemented, at least for 16*6 matrix
arpi
parents: 7097
diff changeset
182
6d784b2812b9 'sipr' descrambling implemented, at least for 16*6 matrix
arpi
parents: 7097
diff changeset
183 // printf("bs=%d sps=%d w=%d h=%d \n",sh->wf->nBlockAlign,sps,w,h);
7086
f0886fe4be89 support for 'sipr' codec - descrambling/reorder not yet fixed.
arpi
parents: 6745
diff changeset
184
6373
8d5d339f2944 get matrix w*h from the demuxer
arpi
parents: 6370
diff changeset
185 #if 1
6368
9511fffdb8c6 yeah, it worx! but needs a big cleanup and removal of hardcoded stuff
arpi
parents: 6367
diff changeset
186 if(sh->a_in_buffer_len<=0){
9511fffdb8c6 yeah, it worx! but needs a big cleanup and removal of hardcoded stuff
arpi
parents: 6367
diff changeset
187 // fill the buffer!
7104
6d784b2812b9 'sipr' descrambling implemented, at least for 16*6 matrix
arpi
parents: 7097
diff changeset
188 if(!sps){
6d784b2812b9 'sipr' descrambling implemented, at least for 16*6 matrix
arpi
parents: 7097
diff changeset
189 // 'sipr' way
6d784b2812b9 'sipr' descrambling implemented, at least for 16*6 matrix
arpi
parents: 7097
diff changeset
190 int j,n;
6d784b2812b9 'sipr' descrambling implemented, at least for 16*6 matrix
arpi
parents: 7097
diff changeset
191 int bs=h*w*2/96; // nibbles per subpacket
6d784b2812b9 'sipr' descrambling implemented, at least for 16*6 matrix
arpi
parents: 7097
diff changeset
192 unsigned char *p=sh->a_in_buffer;
6d784b2812b9 'sipr' descrambling implemented, at least for 16*6 matrix
arpi
parents: 7097
diff changeset
193 demux_read_data(sh->ds, p, h*w);
6d784b2812b9 'sipr' descrambling implemented, at least for 16*6 matrix
arpi
parents: 7097
diff changeset
194 for(n=0;n<38;n++){
6d784b2812b9 'sipr' descrambling implemented, at least for 16*6 matrix
arpi
parents: 7097
diff changeset
195 int i=bs*sipr_swaps[n][0];
6d784b2812b9 'sipr' descrambling implemented, at least for 16*6 matrix
arpi
parents: 7097
diff changeset
196 int o=bs*sipr_swaps[n][1];
6d784b2812b9 'sipr' descrambling implemented, at least for 16*6 matrix
arpi
parents: 7097
diff changeset
197 // swap nibbles of block 'i' with 'o' TODO: optimize
6d784b2812b9 'sipr' descrambling implemented, at least for 16*6 matrix
arpi
parents: 7097
diff changeset
198 for(j=0;j<bs;j++){
6d784b2812b9 'sipr' descrambling implemented, at least for 16*6 matrix
arpi
parents: 7097
diff changeset
199 int x=(i&1) ? (p[(i>>1)]>>4) : (p[(i>>1)]&15);
6d784b2812b9 'sipr' descrambling implemented, at least for 16*6 matrix
arpi
parents: 7097
diff changeset
200 int y=(o&1) ? (p[(o>>1)]>>4) : (p[(o>>1)]&15);
6d784b2812b9 'sipr' descrambling implemented, at least for 16*6 matrix
arpi
parents: 7097
diff changeset
201 if(o&1) p[(o>>1)]=(p[(o>>1)]&0x0F)|(x<<4);
6d784b2812b9 'sipr' descrambling implemented, at least for 16*6 matrix
arpi
parents: 7097
diff changeset
202 else p[(o>>1)]=(p[(o>>1)]&0xF0)|x;
6d784b2812b9 'sipr' descrambling implemented, at least for 16*6 matrix
arpi
parents: 7097
diff changeset
203 if(i&1) p[(i>>1)]=(p[(i>>1)]&0x0F)|(y<<4);
6d784b2812b9 'sipr' descrambling implemented, at least for 16*6 matrix
arpi
parents: 7097
diff changeset
204 else p[(i>>1)]=(p[(i>>1)]&0xF0)|y;
6d784b2812b9 'sipr' descrambling implemented, at least for 16*6 matrix
arpi
parents: 7097
diff changeset
205 ++i;++o;
6d784b2812b9 'sipr' descrambling implemented, at least for 16*6 matrix
arpi
parents: 7097
diff changeset
206 }
6d784b2812b9 'sipr' descrambling implemented, at least for 16*6 matrix
arpi
parents: 7097
diff changeset
207 }
6d784b2812b9 'sipr' descrambling implemented, at least for 16*6 matrix
arpi
parents: 7097
diff changeset
208 sh->a_in_buffer_size=
6d784b2812b9 'sipr' descrambling implemented, at least for 16*6 matrix
arpi
parents: 7097
diff changeset
209 sh->a_in_buffer_len=w*h;
6d784b2812b9 'sipr' descrambling implemented, at least for 16*6 matrix
arpi
parents: 7097
diff changeset
210 } else {
6d784b2812b9 'sipr' descrambling implemented, at least for 16*6 matrix
arpi
parents: 7097
diff changeset
211 // 'cook' way
6368
9511fffdb8c6 yeah, it worx! but needs a big cleanup and removal of hardcoded stuff
arpi
parents: 6367
diff changeset
212 int x,y;
7104
6d784b2812b9 'sipr' descrambling implemented, at least for 16*6 matrix
arpi
parents: 7097
diff changeset
213 w/=sps;
6373
8d5d339f2944 get matrix w*h from the demuxer
arpi
parents: 6370
diff changeset
214 for(y=0;y<h;y++)
8d5d339f2944 get matrix w*h from the demuxer
arpi
parents: 6370
diff changeset
215 for(x=0;x<w;x++){
6428
88a06ebb3287 audio subpacket reordering fixed for odd matrix height
arpi
parents: 6404
diff changeset
216 demux_read_data(sh->ds, sh->a_in_buffer+sps*(h*x+((h+1)/2)*(y&1)+(y>>1)), sps);
6368
9511fffdb8c6 yeah, it worx! but needs a big cleanup and removal of hardcoded stuff
arpi
parents: 6367
diff changeset
217 }
6373
8d5d339f2944 get matrix w*h from the demuxer
arpi
parents: 6370
diff changeset
218 sh->a_in_buffer_size=
8d5d339f2944 get matrix w*h from the demuxer
arpi
parents: 6370
diff changeset
219 sh->a_in_buffer_len=w*h*sps;
7104
6d784b2812b9 'sipr' descrambling implemented, at least for 16*6 matrix
arpi
parents: 7097
diff changeset
220 }
6368
9511fffdb8c6 yeah, it worx! but needs a big cleanup and removal of hardcoded stuff
arpi
parents: 6367
diff changeset
221 }
6373
8d5d339f2944 get matrix w*h from the demuxer
arpi
parents: 6370
diff changeset
222
8d5d339f2944 get matrix w*h from the demuxer
arpi
parents: 6370
diff changeset
223 #else
8d5d339f2944 get matrix w*h from the demuxer
arpi
parents: 6370
diff changeset
224 if(sh->a_in_buffer_len<=0){
8d5d339f2944 get matrix w*h from the demuxer
arpi
parents: 6370
diff changeset
225 // fill the buffer!
8d5d339f2944 get matrix w*h from the demuxer
arpi
parents: 6370
diff changeset
226 demux_read_data(sh->ds, sh->a_in_buffer, sh->wf->nBlockAlign);
8d5d339f2944 get matrix w*h from the demuxer
arpi
parents: 6370
diff changeset
227 sh->a_in_buffer_size=
8d5d339f2944 get matrix w*h from the demuxer
arpi
parents: 6370
diff changeset
228 sh->a_in_buffer_len=sh->wf->nBlockAlign;
8d5d339f2944 get matrix w*h from the demuxer
arpi
parents: 6370
diff changeset
229 }
8d5d339f2944 get matrix w*h from the demuxer
arpi
parents: 6370
diff changeset
230 #endif
6367
489c4bcbda13 readaudio decoder - not yet working
arpi
parents:
diff changeset
231
6373
8d5d339f2944 get matrix w*h from the demuxer
arpi
parents: 6370
diff changeset
232 result=raDecode(sh->context, sh->a_in_buffer+sh->a_in_buffer_size-sh->a_in_buffer_len, sh->wf->nBlockAlign,
6367
489c4bcbda13 readaudio decoder - not yet working
arpi
parents:
diff changeset
233 buf, &len, -1);
6368
9511fffdb8c6 yeah, it worx! but needs a big cleanup and removal of hardcoded stuff
arpi
parents: 6367
diff changeset
234 sh->a_in_buffer_len-=sh->wf->nBlockAlign;
9511fffdb8c6 yeah, it worx! but needs a big cleanup and removal of hardcoded stuff
arpi
parents: 6367
diff changeset
235
6376
e3c74c01a3a2 use path & dllname from config
arpi
parents: 6373
diff changeset
236 // printf("radecode: %d bytes, res=0x%X \n",len,result);
6367
489c4bcbda13 readaudio decoder - not yet working
arpi
parents:
diff changeset
237
6368
9511fffdb8c6 yeah, it worx! but needs a big cleanup and removal of hardcoded stuff
arpi
parents: 6367
diff changeset
238 return len; // return value: number of _bytes_ written to output buffer,
6367
489c4bcbda13 readaudio decoder - not yet working
arpi
parents:
diff changeset
239 // or -1 for EOF (or uncorrectable error)
489c4bcbda13 readaudio decoder - not yet working
arpi
parents:
diff changeset
240 }
489c4bcbda13 readaudio decoder - not yet working
arpi
parents:
diff changeset
241
489c4bcbda13 readaudio decoder - not yet working
arpi
parents:
diff changeset
242 static int control(sh_audio_t *sh,int cmd,void* arg, ...){
489c4bcbda13 readaudio decoder - not yet working
arpi
parents:
diff changeset
243 // various optional functions you MAY implement:
489c4bcbda13 readaudio decoder - not yet working
arpi
parents:
diff changeset
244 switch(cmd){
489c4bcbda13 readaudio decoder - not yet working
arpi
parents:
diff changeset
245 case ADCTRL_RESYNC_STREAM:
489c4bcbda13 readaudio decoder - not yet working
arpi
parents:
diff changeset
246 // it is called once after seeking, to resync.
489c4bcbda13 readaudio decoder - not yet working
arpi
parents:
diff changeset
247 // Note: sh_audio->a_in_buffer_len=0; is done _before_ this call!
489c4bcbda13 readaudio decoder - not yet working
arpi
parents:
diff changeset
248 return CONTROL_TRUE;
489c4bcbda13 readaudio decoder - not yet working
arpi
parents:
diff changeset
249 case ADCTRL_SKIP_FRAME:
489c4bcbda13 readaudio decoder - not yet working
arpi
parents:
diff changeset
250 // it is called to skip (jump over) small amount (1/10 sec or 1 frame)
489c4bcbda13 readaudio decoder - not yet working
arpi
parents:
diff changeset
251 // of audio data - used to sync audio to video after seeking
489c4bcbda13 readaudio decoder - not yet working
arpi
parents:
diff changeset
252 // if you don't return CONTROL_TRUE, it will defaults to:
489c4bcbda13 readaudio decoder - not yet working
arpi
parents:
diff changeset
253 // ds_fill_buffer(sh_audio->ds); // skip 1 demux packet
489c4bcbda13 readaudio decoder - not yet working
arpi
parents:
diff changeset
254 return CONTROL_TRUE;
489c4bcbda13 readaudio decoder - not yet working
arpi
parents:
diff changeset
255 }
489c4bcbda13 readaudio decoder - not yet working
arpi
parents:
diff changeset
256 return CONTROL_UNKNOWN;
489c4bcbda13 readaudio decoder - not yet working
arpi
parents:
diff changeset
257 }
489c4bcbda13 readaudio decoder - not yet working
arpi
parents:
diff changeset
258
489c4bcbda13 readaudio decoder - not yet working
arpi
parents:
diff changeset
259 #endif