Mercurial > mplayer.hg
comparison libmpcodecs/ad_hwac3.c @ 5340:0f12fb7c1c5d
imported from MPlayerXP, dlopen() hack removed, some bugs fixed, interface functions changed to static, info->author field added
author | arpi |
---|---|
date | Mon, 25 Mar 2002 21:06:01 +0000 |
parents | |
children | bb1d63fea638 |
comparison
equal
deleted
inserted
replaced
5339:e72d8e3955ea | 5340:0f12fb7c1c5d |
---|---|
1 #include <stdio.h> | |
2 #include <stdlib.h> | |
3 #include <unistd.h> | |
4 | |
5 #include "config.h" | |
6 #include "mp_msg.h" | |
7 #include "help_mp.h" | |
8 | |
9 #include "ad_internal.h" | |
10 | |
11 #include "../liba52/a52.h" | |
12 #include "../ac3-iec958.h" | |
13 | |
14 extern int a52_fillbuff(sh_audio_t *sh_audio); | |
15 | |
16 static ad_info_t info = | |
17 { | |
18 "AC3 through SPDIF", | |
19 "hwac3", | |
20 AFM_HWAC3, | |
21 "Nick Kurshev", | |
22 "???", | |
23 "" | |
24 }; | |
25 | |
26 LIBAD_EXTERN(hwac3) | |
27 | |
28 static int preinit(sh_audio_t *sh) | |
29 { | |
30 /* Dolby AC3 audio: */ | |
31 sh->audio_out_minsize=4*256*6; | |
32 sh->channels=2; | |
33 return 1; | |
34 } | |
35 | |
36 static int init(sh_audio_t *sh_audio) | |
37 { | |
38 /* Dolby AC3 passthrough:*/ | |
39 sample_t *a52_samples=a52_init(0); | |
40 if (a52_samples == NULL) { | |
41 mp_msg(MSGT_DECAUDIO,MSGL_ERR,"A52 init failed\n"); | |
42 return 0; | |
43 } | |
44 sh_audio->a_in_buffer_size=3840; | |
45 sh_audio->a_in_buffer=malloc(sh_audio->a_in_buffer_size); | |
46 sh_audio->a_in_buffer_len=0; | |
47 if(a52_fillbuff(sh_audio)<0) { | |
48 mp_msg(MSGT_DECAUDIO,MSGL_ERR,"A52 sync failed\n"); | |
49 return 0; | |
50 } | |
51 /* | |
52 sh_audio->samplerate=ai.samplerate; // SET by a52_fillbuff() | |
53 sh_audio->samplesize=ai.framesize; | |
54 sh_audio->i_bps=ai.bitrate*(1000/8); // SET by a52_fillbuff() | |
55 sh_audio->ac3_frame=malloc(6144); | |
56 sh_audio->o_bps=sh_audio->i_bps; // XXX FIXME!!! XXX | |
57 | |
58 o_bps is calculated from samplesize*channels*samplerate | |
59 a single ac3 frame is always translated to 6144 byte packet. (zero padding)*/ | |
60 sh_audio->channels=2; | |
61 sh_audio->samplesize=2; /* 2*2*(6*256) = 6144 (very TRICKY!)*/ | |
62 return 1; | |
63 } | |
64 | |
65 static void uninit(sh_audio_t *sh) | |
66 { | |
67 } | |
68 | |
69 static int control(sh_audio_t *sh,int cmd,void* arg, ...) | |
70 { | |
71 switch(cmd) | |
72 { | |
73 case ADCTRL_SKIP_FRAME: | |
74 a52_fillbuff(sh); break; // skip AC3 frame | |
75 return CONTROL_TRUE; | |
76 } | |
77 return CONTROL_UNKNOWN; | |
78 } | |
79 | |
80 static int decode_audio(sh_audio_t *sh_audio,unsigned char *buf,int minlen,int maxlen) | |
81 { | |
82 int len=-1; | |
83 if(!sh_audio->a_in_buffer_len) | |
84 if((len=a52_fillbuff(sh_audio))<0) return len; /*EOF*/ | |
85 sh_audio->a_in_buffer_len=0; | |
86 len = ac3_iec958_build_burst(len, 0x01, 1, sh_audio->a_in_buffer, buf); | |
87 return len; | |
88 } |