1 #include "mpeg3private.h"
2 #include "mpeg3protos.h"
7 mpeg3_pcm_t
* mpeg3_new_pcm()
9 mpeg3_pcm_t
*result
= calloc(1, sizeof(mpeg3_pcm_t
));
15 void mpeg3_delete_pcm(mpeg3_pcm_t
*audio
)
21 int mpeg3_pcm_check(unsigned char *header
)
23 if(header
[0] == ((MPEG3_PCM_START_CODE
& 0xff000000) >> 24) &&
24 header
[1] == ((MPEG3_PCM_START_CODE
& 0xff0000) >> 16) &&
25 header
[2] == ((MPEG3_PCM_START_CODE
& 0xff00) >> 8) &&
26 header
[3] == (MPEG3_PCM_START_CODE
& 0xff))
35 int mpeg3_pcm_header(mpeg3_pcm_t
*audio
, unsigned char *data
)
37 if(mpeg3_pcm_check(data
)) return 0;
39 /* Custom header generated by the demuxer */
40 audio
->samplerate
= *(int32_t*)(data
+ 4);
41 audio
->bits
= *(int32_t*)(data
+ 8);
42 audio
->channels
= *(int32_t*)(data
+ 12);
43 audio
->framesize
= *(int32_t*)(data
+ 16);
45 return audio
->framesize
;
48 int mpeg3audio_dopcm(mpeg3_pcm_t
*audio
,
54 int bytes_per_sample
= audio
->bits
/ 8 * audio
->channels
;
55 int output_size
= (frame_size
- PCM_HEADERSIZE
) / bytes_per_sample
;
57 //printf("mpeg3audio_dopcm 2 %d\n", frame_size);
61 for(i
= 0; i
< audio
->channels
; i
++)
63 //printf("mpeg3audio_dopcm 3\n");
64 float *output_channel
= output
[i
];
65 //printf("mpeg3audio_dopcm 4\n");
70 //printf("mpeg3audio_dopcm 5\n");
71 unsigned char *input
= frame
+
75 //printf("mpeg3audio_dopcm 6\n");
76 for(j
= 0; j
< output_size
; j
++)
78 sample
= ((int16_t)(input
[0])) << 8;
80 *output_channel
= (float)sample
/ 32767.0;
81 input
+= bytes_per_sample
;
84 //printf("mpeg3audio_dopcm 7\n");
92 * printf("mpeg3audio_dopcm 2 %02x%02x%02x%02x\n",
93 * *(unsigned char*)(frame + PCM_HEADERSIZE + 0),
94 * *(unsigned char*)(frame + PCM_HEADERSIZE + 1),
95 * *(unsigned char*)(frame + PCM_HEADERSIZE + 2),
96 * *(unsigned char*)(frame + PCM_HEADERSIZE + 3));