4 #include <a52dec/a52.h>
5 #include "mpeg3private.h"
6 #include "mpeg3protos.h"
11 mpeg3_ac3_t
* mpeg3_new_ac3()
13 mpeg3_ac3_t
*result
= calloc(1, sizeof(mpeg3_ac3_t
));
14 result
->stream
= mpeg3bits_new_stream(0, 0);
15 result
->state
= a52_init(0);
16 result
->output
= a52_samples(result
->state
);
20 void mpeg3_delete_ac3(mpeg3_ac3_t
*audio
)
22 mpeg3bits_delete_stream(audio
->stream
);
23 a52_free(audio
->state
);
28 /* Return 1 if it isn't an AC3 header */
29 int mpeg3_ac3_check(unsigned char *header
)
31 int flags
, samplerate
, bitrate
;
32 return !a52_syncinfo(header
,
38 /* Decode AC3 header */
39 int mpeg3_ac3_header(mpeg3_ac3_t
*audio
, unsigned char *header
)
44 //printf("mpeg3_ac3_header %02x%02x%02x%02x%02x%02x%02x%02x\n", header[0], header[1], header[2], header[3], header[4], header[5], header[6], header[7]);
45 result
= a52_syncinfo(header
,
53 //printf("%d\n", result);
54 audio
->framesize
= result
;
57 if(audio
->flags
& A52_LFE
)
59 //printf("mpeg3_ac3_header %02x %02x\n", audio->flags & A52_LFE, audio->flags & A52_CHANNEL_MASK);
60 switch(audio
->flags
& A52_CHANNEL_MASK
)
90 printf("mpeg3_ac3_header: unknown channel code: %p\n", audio
->flags
& A52_CHANNEL_MASK
);
94 //printf("mpeg3_ac3_header 1 %d\n", audio->channels);
99 int mpeg3audio_doac3(mpeg3_ac3_t
*audio
,
105 int output_position
= 0;
109 //printf("mpeg3audio_doac3 1\n");
110 a52_frame(audio
->state
,
115 //printf("mpeg3audio_doac3 2\n");
116 a52_dynrng(audio
->state
, NULL
, NULL
);
117 //printf("mpeg3audio_doac3 3\n");
118 for(i
= 0; i
< 6; i
++)
120 if(!a52_block(audio
->state
))
125 for(j
= 0; j
< audio
->channels
; j
++)
127 for(k
= 0; k
< 256; k
++)
129 output
[j
][output_position
+ k
] = ((sample_t
*)audio
->output
)[l
];
134 output_position
+= 256;
139 return output_position
;