Mercurial > mplayer.hg
annotate libmpcodecs/ad_hwac3.c @ 13163:665b66caf625
wording
author | paszczi |
---|---|
date | Fri, 27 Aug 2004 11:31:50 +0000 |
parents | aebf939834c3 |
children | 19589e978000 |
rev | line source |
---|---|
5370 | 1 |
2 // Reference: DOCS/tech/hwac3.txt !!!!! | |
3 | |
10012
f8f3f8b4e0d7
DTS support by Peter Schuller <peterschueller@telemed.de> (revised by arpi)
alex
parents:
8026
diff
changeset
|
4 /* DTS code based on "ac3/decode_dts.c" and "ac3/conversion.c" from "ogle 0.9" |
f8f3f8b4e0d7
DTS support by Peter Schuller <peterschueller@telemed.de> (revised by arpi)
alex
parents:
8026
diff
changeset
|
5 (see http://www.dtek.chalmers.se/~dvd/) |
f8f3f8b4e0d7
DTS support by Peter Schuller <peterschueller@telemed.de> (revised by arpi)
alex
parents:
8026
diff
changeset
|
6 */ |
f8f3f8b4e0d7
DTS support by Peter Schuller <peterschueller@telemed.de> (revised by arpi)
alex
parents:
8026
diff
changeset
|
7 |
5340
0f12fb7c1c5d
imported from MPlayerXP, dlopen() hack removed, some bugs fixed, interface functions changed to static, info->author field added
arpi
parents:
diff
changeset
|
8 #include <stdio.h> |
0f12fb7c1c5d
imported from MPlayerXP, dlopen() hack removed, some bugs fixed, interface functions changed to static, info->author field added
arpi
parents:
diff
changeset
|
9 #include <stdlib.h> |
5370 | 10 #include <string.h> |
5340
0f12fb7c1c5d
imported from MPlayerXP, dlopen() hack removed, some bugs fixed, interface functions changed to static, info->author field added
arpi
parents:
diff
changeset
|
11 #include <unistd.h> |
0f12fb7c1c5d
imported from MPlayerXP, dlopen() hack removed, some bugs fixed, interface functions changed to static, info->author field added
arpi
parents:
diff
changeset
|
12 |
0f12fb7c1c5d
imported from MPlayerXP, dlopen() hack removed, some bugs fixed, interface functions changed to static, info->author field added
arpi
parents:
diff
changeset
|
13 #include "config.h" |
8026
b465ba5897a3
usage of libmpeg2, liba52, mp3lib & svq1 can be disabled
arpi
parents:
7405
diff
changeset
|
14 #ifdef USE_LIBA52 |
b465ba5897a3
usage of libmpeg2, liba52, mp3lib & svq1 can be disabled
arpi
parents:
7405
diff
changeset
|
15 |
5340
0f12fb7c1c5d
imported from MPlayerXP, dlopen() hack removed, some bugs fixed, interface functions changed to static, info->author field added
arpi
parents:
diff
changeset
|
16 #include "mp_msg.h" |
0f12fb7c1c5d
imported from MPlayerXP, dlopen() hack removed, some bugs fixed, interface functions changed to static, info->author field added
arpi
parents:
diff
changeset
|
17 #include "help_mp.h" |
0f12fb7c1c5d
imported from MPlayerXP, dlopen() hack removed, some bugs fixed, interface functions changed to static, info->author field added
arpi
parents:
diff
changeset
|
18 |
0f12fb7c1c5d
imported from MPlayerXP, dlopen() hack removed, some bugs fixed, interface functions changed to static, info->author field added
arpi
parents:
diff
changeset
|
19 #include "ad_internal.h" |
0f12fb7c1c5d
imported from MPlayerXP, dlopen() hack removed, some bugs fixed, interface functions changed to static, info->author field added
arpi
parents:
diff
changeset
|
20 |
0f12fb7c1c5d
imported from MPlayerXP, dlopen() hack removed, some bugs fixed, interface functions changed to static, info->author field added
arpi
parents:
diff
changeset
|
21 #include "../liba52/a52.h" |
0f12fb7c1c5d
imported from MPlayerXP, dlopen() hack removed, some bugs fixed, interface functions changed to static, info->author field added
arpi
parents:
diff
changeset
|
22 |
10012
f8f3f8b4e0d7
DTS support by Peter Schuller <peterschueller@telemed.de> (revised by arpi)
alex
parents:
8026
diff
changeset
|
23 |
f8f3f8b4e0d7
DTS support by Peter Schuller <peterschueller@telemed.de> (revised by arpi)
alex
parents:
8026
diff
changeset
|
24 static int isdts = -1; |
5340
0f12fb7c1c5d
imported from MPlayerXP, dlopen() hack removed, some bugs fixed, interface functions changed to static, info->author field added
arpi
parents:
diff
changeset
|
25 |
0f12fb7c1c5d
imported from MPlayerXP, dlopen() hack removed, some bugs fixed, interface functions changed to static, info->author field added
arpi
parents:
diff
changeset
|
26 static ad_info_t info = |
0f12fb7c1c5d
imported from MPlayerXP, dlopen() hack removed, some bugs fixed, interface functions changed to static, info->author field added
arpi
parents:
diff
changeset
|
27 { |
10012
f8f3f8b4e0d7
DTS support by Peter Schuller <peterschueller@telemed.de> (revised by arpi)
alex
parents:
8026
diff
changeset
|
28 "AC3/DTS pass-through SP/DIF", |
f8f3f8b4e0d7
DTS support by Peter Schuller <peterschueller@telemed.de> (revised by arpi)
alex
parents:
8026
diff
changeset
|
29 "hwac3", |
f8f3f8b4e0d7
DTS support by Peter Schuller <peterschueller@telemed.de> (revised by arpi)
alex
parents:
8026
diff
changeset
|
30 "Nick Kurshev/Peter Schüller", |
f8f3f8b4e0d7
DTS support by Peter Schuller <peterschueller@telemed.de> (revised by arpi)
alex
parents:
8026
diff
changeset
|
31 "???", |
f8f3f8b4e0d7
DTS support by Peter Schuller <peterschueller@telemed.de> (revised by arpi)
alex
parents:
8026
diff
changeset
|
32 "" |
5340
0f12fb7c1c5d
imported from MPlayerXP, dlopen() hack removed, some bugs fixed, interface functions changed to static, info->author field added
arpi
parents:
diff
changeset
|
33 }; |
0f12fb7c1c5d
imported from MPlayerXP, dlopen() hack removed, some bugs fixed, interface functions changed to static, info->author field added
arpi
parents:
diff
changeset
|
34 |
0f12fb7c1c5d
imported from MPlayerXP, dlopen() hack removed, some bugs fixed, interface functions changed to static, info->author field added
arpi
parents:
diff
changeset
|
35 LIBAD_EXTERN(hwac3) |
0f12fb7c1c5d
imported from MPlayerXP, dlopen() hack removed, some bugs fixed, interface functions changed to static, info->author field added
arpi
parents:
diff
changeset
|
36 |
10012
f8f3f8b4e0d7
DTS support by Peter Schuller <peterschueller@telemed.de> (revised by arpi)
alex
parents:
8026
diff
changeset
|
37 |
f8f3f8b4e0d7
DTS support by Peter Schuller <peterschueller@telemed.de> (revised by arpi)
alex
parents:
8026
diff
changeset
|
38 static int dts_syncinfo(uint8_t *indata_ptr, int *flags, int *sample_rate, int *bit_rate); |
f8f3f8b4e0d7
DTS support by Peter Schuller <peterschueller@telemed.de> (revised by arpi)
alex
parents:
8026
diff
changeset
|
39 static int decode_audio_dts(unsigned char *indata_ptr, int len, unsigned char *buf); |
f8f3f8b4e0d7
DTS support by Peter Schuller <peterschueller@telemed.de> (revised by arpi)
alex
parents:
8026
diff
changeset
|
40 |
f8f3f8b4e0d7
DTS support by Peter Schuller <peterschueller@telemed.de> (revised by arpi)
alex
parents:
8026
diff
changeset
|
41 |
f8f3f8b4e0d7
DTS support by Peter Schuller <peterschueller@telemed.de> (revised by arpi)
alex
parents:
8026
diff
changeset
|
42 static int ac3dts_fillbuff(sh_audio_t *sh_audio) |
f8f3f8b4e0d7
DTS support by Peter Schuller <peterschueller@telemed.de> (revised by arpi)
alex
parents:
8026
diff
changeset
|
43 { |
f8f3f8b4e0d7
DTS support by Peter Schuller <peterschueller@telemed.de> (revised by arpi)
alex
parents:
8026
diff
changeset
|
44 int length = 0; |
f8f3f8b4e0d7
DTS support by Peter Schuller <peterschueller@telemed.de> (revised by arpi)
alex
parents:
8026
diff
changeset
|
45 int flags = 0; |
f8f3f8b4e0d7
DTS support by Peter Schuller <peterschueller@telemed.de> (revised by arpi)
alex
parents:
8026
diff
changeset
|
46 int sample_rate = 0; |
f8f3f8b4e0d7
DTS support by Peter Schuller <peterschueller@telemed.de> (revised by arpi)
alex
parents:
8026
diff
changeset
|
47 int bit_rate = 0; |
f8f3f8b4e0d7
DTS support by Peter Schuller <peterschueller@telemed.de> (revised by arpi)
alex
parents:
8026
diff
changeset
|
48 |
f8f3f8b4e0d7
DTS support by Peter Schuller <peterschueller@telemed.de> (revised by arpi)
alex
parents:
8026
diff
changeset
|
49 sh_audio->a_in_buffer_len = 0; |
f8f3f8b4e0d7
DTS support by Peter Schuller <peterschueller@telemed.de> (revised by arpi)
alex
parents:
8026
diff
changeset
|
50 /* sync frame:*/ |
f8f3f8b4e0d7
DTS support by Peter Schuller <peterschueller@telemed.de> (revised by arpi)
alex
parents:
8026
diff
changeset
|
51 while(1) |
f8f3f8b4e0d7
DTS support by Peter Schuller <peterschueller@telemed.de> (revised by arpi)
alex
parents:
8026
diff
changeset
|
52 { |
f8f3f8b4e0d7
DTS support by Peter Schuller <peterschueller@telemed.de> (revised by arpi)
alex
parents:
8026
diff
changeset
|
53 // DTS has a 10 byte header |
f8f3f8b4e0d7
DTS support by Peter Schuller <peterschueller@telemed.de> (revised by arpi)
alex
parents:
8026
diff
changeset
|
54 while(sh_audio->a_in_buffer_len < 10) |
f8f3f8b4e0d7
DTS support by Peter Schuller <peterschueller@telemed.de> (revised by arpi)
alex
parents:
8026
diff
changeset
|
55 { |
f8f3f8b4e0d7
DTS support by Peter Schuller <peterschueller@telemed.de> (revised by arpi)
alex
parents:
8026
diff
changeset
|
56 int c = demux_getc(sh_audio->ds); |
f8f3f8b4e0d7
DTS support by Peter Schuller <peterschueller@telemed.de> (revised by arpi)
alex
parents:
8026
diff
changeset
|
57 if(c<0) |
f8f3f8b4e0d7
DTS support by Peter Schuller <peterschueller@telemed.de> (revised by arpi)
alex
parents:
8026
diff
changeset
|
58 return -1; /* EOF*/ |
f8f3f8b4e0d7
DTS support by Peter Schuller <peterschueller@telemed.de> (revised by arpi)
alex
parents:
8026
diff
changeset
|
59 sh_audio->a_in_buffer[sh_audio->a_in_buffer_len++] = c; |
f8f3f8b4e0d7
DTS support by Peter Schuller <peterschueller@telemed.de> (revised by arpi)
alex
parents:
8026
diff
changeset
|
60 } |
f8f3f8b4e0d7
DTS support by Peter Schuller <peterschueller@telemed.de> (revised by arpi)
alex
parents:
8026
diff
changeset
|
61 |
f8f3f8b4e0d7
DTS support by Peter Schuller <peterschueller@telemed.de> (revised by arpi)
alex
parents:
8026
diff
changeset
|
62 length = dts_syncinfo(sh_audio->a_in_buffer, &flags, &sample_rate, &bit_rate); |
f8f3f8b4e0d7
DTS support by Peter Schuller <peterschueller@telemed.de> (revised by arpi)
alex
parents:
8026
diff
changeset
|
63 if(length >= 10) |
f8f3f8b4e0d7
DTS support by Peter Schuller <peterschueller@telemed.de> (revised by arpi)
alex
parents:
8026
diff
changeset
|
64 { |
f8f3f8b4e0d7
DTS support by Peter Schuller <peterschueller@telemed.de> (revised by arpi)
alex
parents:
8026
diff
changeset
|
65 if(isdts != 1) |
f8f3f8b4e0d7
DTS support by Peter Schuller <peterschueller@telemed.de> (revised by arpi)
alex
parents:
8026
diff
changeset
|
66 { |
f8f3f8b4e0d7
DTS support by Peter Schuller <peterschueller@telemed.de> (revised by arpi)
alex
parents:
8026
diff
changeset
|
67 mp_msg(MSGT_DECAUDIO, MSGL_STATUS, "hwac3: switched to DTS, %d bps, %d Hz\n", bit_rate, sample_rate); |
f8f3f8b4e0d7
DTS support by Peter Schuller <peterschueller@telemed.de> (revised by arpi)
alex
parents:
8026
diff
changeset
|
68 isdts = 1; |
f8f3f8b4e0d7
DTS support by Peter Schuller <peterschueller@telemed.de> (revised by arpi)
alex
parents:
8026
diff
changeset
|
69 } |
f8f3f8b4e0d7
DTS support by Peter Schuller <peterschueller@telemed.de> (revised by arpi)
alex
parents:
8026
diff
changeset
|
70 break; |
f8f3f8b4e0d7
DTS support by Peter Schuller <peterschueller@telemed.de> (revised by arpi)
alex
parents:
8026
diff
changeset
|
71 } |
f8f3f8b4e0d7
DTS support by Peter Schuller <peterschueller@telemed.de> (revised by arpi)
alex
parents:
8026
diff
changeset
|
72 length = a52_syncinfo(sh_audio->a_in_buffer, &flags, &sample_rate, &bit_rate); |
f8f3f8b4e0d7
DTS support by Peter Schuller <peterschueller@telemed.de> (revised by arpi)
alex
parents:
8026
diff
changeset
|
73 if(length >= 7 && length <= 3840) |
f8f3f8b4e0d7
DTS support by Peter Schuller <peterschueller@telemed.de> (revised by arpi)
alex
parents:
8026
diff
changeset
|
74 { |
f8f3f8b4e0d7
DTS support by Peter Schuller <peterschueller@telemed.de> (revised by arpi)
alex
parents:
8026
diff
changeset
|
75 if(isdts != 0) |
f8f3f8b4e0d7
DTS support by Peter Schuller <peterschueller@telemed.de> (revised by arpi)
alex
parents:
8026
diff
changeset
|
76 { |
f8f3f8b4e0d7
DTS support by Peter Schuller <peterschueller@telemed.de> (revised by arpi)
alex
parents:
8026
diff
changeset
|
77 mp_msg(MSGT_DECAUDIO, MSGL_STATUS, "hwac3: switched to AC3, %d bps, %d Hz\n", bit_rate, sample_rate); |
f8f3f8b4e0d7
DTS support by Peter Schuller <peterschueller@telemed.de> (revised by arpi)
alex
parents:
8026
diff
changeset
|
78 isdts = 0; |
f8f3f8b4e0d7
DTS support by Peter Schuller <peterschueller@telemed.de> (revised by arpi)
alex
parents:
8026
diff
changeset
|
79 } |
f8f3f8b4e0d7
DTS support by Peter Schuller <peterschueller@telemed.de> (revised by arpi)
alex
parents:
8026
diff
changeset
|
80 break; /* we're done.*/ |
f8f3f8b4e0d7
DTS support by Peter Schuller <peterschueller@telemed.de> (revised by arpi)
alex
parents:
8026
diff
changeset
|
81 } |
f8f3f8b4e0d7
DTS support by Peter Schuller <peterschueller@telemed.de> (revised by arpi)
alex
parents:
8026
diff
changeset
|
82 /* bad file => resync*/ |
f8f3f8b4e0d7
DTS support by Peter Schuller <peterschueller@telemed.de> (revised by arpi)
alex
parents:
8026
diff
changeset
|
83 memcpy(sh_audio->a_in_buffer, sh_audio->a_in_buffer + 1, 9); |
f8f3f8b4e0d7
DTS support by Peter Schuller <peterschueller@telemed.de> (revised by arpi)
alex
parents:
8026
diff
changeset
|
84 --sh_audio->a_in_buffer_len; |
f8f3f8b4e0d7
DTS support by Peter Schuller <peterschueller@telemed.de> (revised by arpi)
alex
parents:
8026
diff
changeset
|
85 } |
f8f3f8b4e0d7
DTS support by Peter Schuller <peterschueller@telemed.de> (revised by arpi)
alex
parents:
8026
diff
changeset
|
86 mp_msg(MSGT_DECAUDIO, MSGL_DBG2, "ac3dts: %s len=%d flags=0x%X %d Hz %d bit/s\n", isdts == 1 ? "DTS" : isdts == 0 ? "AC3" : "unknown", length, flags, sample_rate, bit_rate); |
f8f3f8b4e0d7
DTS support by Peter Schuller <peterschueller@telemed.de> (revised by arpi)
alex
parents:
8026
diff
changeset
|
87 |
f8f3f8b4e0d7
DTS support by Peter Schuller <peterschueller@telemed.de> (revised by arpi)
alex
parents:
8026
diff
changeset
|
88 sh_audio->samplerate = sample_rate; |
f8f3f8b4e0d7
DTS support by Peter Schuller <peterschueller@telemed.de> (revised by arpi)
alex
parents:
8026
diff
changeset
|
89 sh_audio->i_bps = bit_rate / 8; |
f8f3f8b4e0d7
DTS support by Peter Schuller <peterschueller@telemed.de> (revised by arpi)
alex
parents:
8026
diff
changeset
|
90 demux_read_data(sh_audio->ds, sh_audio->a_in_buffer + 10, length - 10); |
f8f3f8b4e0d7
DTS support by Peter Schuller <peterschueller@telemed.de> (revised by arpi)
alex
parents:
8026
diff
changeset
|
91 sh_audio->a_in_buffer_len = length; |
f8f3f8b4e0d7
DTS support by Peter Schuller <peterschueller@telemed.de> (revised by arpi)
alex
parents:
8026
diff
changeset
|
92 |
f8f3f8b4e0d7
DTS support by Peter Schuller <peterschueller@telemed.de> (revised by arpi)
alex
parents:
8026
diff
changeset
|
93 // TODO: is DTS also checksummed? |
f8f3f8b4e0d7
DTS support by Peter Schuller <peterschueller@telemed.de> (revised by arpi)
alex
parents:
8026
diff
changeset
|
94 if(isdts == 0 && crc16_block(sh_audio->a_in_buffer + 2, length - 2) != 0) |
f8f3f8b4e0d7
DTS support by Peter Schuller <peterschueller@telemed.de> (revised by arpi)
alex
parents:
8026
diff
changeset
|
95 mp_msg(MSGT_DECAUDIO, MSGL_STATUS, "a52: CRC check failed! \n"); |
f8f3f8b4e0d7
DTS support by Peter Schuller <peterschueller@telemed.de> (revised by arpi)
alex
parents:
8026
diff
changeset
|
96 |
f8f3f8b4e0d7
DTS support by Peter Schuller <peterschueller@telemed.de> (revised by arpi)
alex
parents:
8026
diff
changeset
|
97 return length; |
f8f3f8b4e0d7
DTS support by Peter Schuller <peterschueller@telemed.de> (revised by arpi)
alex
parents:
8026
diff
changeset
|
98 } |
f8f3f8b4e0d7
DTS support by Peter Schuller <peterschueller@telemed.de> (revised by arpi)
alex
parents:
8026
diff
changeset
|
99 |
f8f3f8b4e0d7
DTS support by Peter Schuller <peterschueller@telemed.de> (revised by arpi)
alex
parents:
8026
diff
changeset
|
100 |
5340
0f12fb7c1c5d
imported from MPlayerXP, dlopen() hack removed, some bugs fixed, interface functions changed to static, info->author field added
arpi
parents:
diff
changeset
|
101 static int preinit(sh_audio_t *sh) |
0f12fb7c1c5d
imported from MPlayerXP, dlopen() hack removed, some bugs fixed, interface functions changed to static, info->author field added
arpi
parents:
diff
changeset
|
102 { |
0f12fb7c1c5d
imported from MPlayerXP, dlopen() hack removed, some bugs fixed, interface functions changed to static, info->author field added
arpi
parents:
diff
changeset
|
103 /* Dolby AC3 audio: */ |
10012
f8f3f8b4e0d7
DTS support by Peter Schuller <peterschueller@telemed.de> (revised by arpi)
alex
parents:
8026
diff
changeset
|
104 sh->audio_out_minsize = 128 * 32 * 2 * 2; // DTS seems to need more than AC3 |
f8f3f8b4e0d7
DTS support by Peter Schuller <peterschueller@telemed.de> (revised by arpi)
alex
parents:
8026
diff
changeset
|
105 sh->audio_in_minsize = 8192; |
f8f3f8b4e0d7
DTS support by Peter Schuller <peterschueller@telemed.de> (revised by arpi)
alex
parents:
8026
diff
changeset
|
106 sh->channels = 2; |
f8f3f8b4e0d7
DTS support by Peter Schuller <peterschueller@telemed.de> (revised by arpi)
alex
parents:
8026
diff
changeset
|
107 sh->samplesize = 2; |
f8f3f8b4e0d7
DTS support by Peter Schuller <peterschueller@telemed.de> (revised by arpi)
alex
parents:
8026
diff
changeset
|
108 sh->sample_format = AFMT_AC3; |
5340
0f12fb7c1c5d
imported from MPlayerXP, dlopen() hack removed, some bugs fixed, interface functions changed to static, info->author field added
arpi
parents:
diff
changeset
|
109 return 1; |
0f12fb7c1c5d
imported from MPlayerXP, dlopen() hack removed, some bugs fixed, interface functions changed to static, info->author field added
arpi
parents:
diff
changeset
|
110 } |
0f12fb7c1c5d
imported from MPlayerXP, dlopen() hack removed, some bugs fixed, interface functions changed to static, info->author field added
arpi
parents:
diff
changeset
|
111 |
0f12fb7c1c5d
imported from MPlayerXP, dlopen() hack removed, some bugs fixed, interface functions changed to static, info->author field added
arpi
parents:
diff
changeset
|
112 static int init(sh_audio_t *sh_audio) |
0f12fb7c1c5d
imported from MPlayerXP, dlopen() hack removed, some bugs fixed, interface functions changed to static, info->author field added
arpi
parents:
diff
changeset
|
113 { |
0f12fb7c1c5d
imported from MPlayerXP, dlopen() hack removed, some bugs fixed, interface functions changed to static, info->author field added
arpi
parents:
diff
changeset
|
114 /* Dolby AC3 passthrough:*/ |
10012
f8f3f8b4e0d7
DTS support by Peter Schuller <peterschueller@telemed.de> (revised by arpi)
alex
parents:
8026
diff
changeset
|
115 sample_t *a52_samples = a52_init(0); |
f8f3f8b4e0d7
DTS support by Peter Schuller <peterschueller@telemed.de> (revised by arpi)
alex
parents:
8026
diff
changeset
|
116 if(a52_samples == NULL) |
f8f3f8b4e0d7
DTS support by Peter Schuller <peterschueller@telemed.de> (revised by arpi)
alex
parents:
8026
diff
changeset
|
117 { |
f8f3f8b4e0d7
DTS support by Peter Schuller <peterschueller@telemed.de> (revised by arpi)
alex
parents:
8026
diff
changeset
|
118 mp_msg(MSGT_DECAUDIO, MSGL_ERR, "A52 init failed\n"); |
f8f3f8b4e0d7
DTS support by Peter Schuller <peterschueller@telemed.de> (revised by arpi)
alex
parents:
8026
diff
changeset
|
119 return 0; |
5340
0f12fb7c1c5d
imported from MPlayerXP, dlopen() hack removed, some bugs fixed, interface functions changed to static, info->author field added
arpi
parents:
diff
changeset
|
120 } |
10012
f8f3f8b4e0d7
DTS support by Peter Schuller <peterschueller@telemed.de> (revised by arpi)
alex
parents:
8026
diff
changeset
|
121 if(ac3dts_fillbuff(sh_audio) < 0) |
f8f3f8b4e0d7
DTS support by Peter Schuller <peterschueller@telemed.de> (revised by arpi)
alex
parents:
8026
diff
changeset
|
122 { |
f8f3f8b4e0d7
DTS support by Peter Schuller <peterschueller@telemed.de> (revised by arpi)
alex
parents:
8026
diff
changeset
|
123 mp_msg(MSGT_DECAUDIO, MSGL_ERR, "AC3/DTS sync failed\n"); |
f8f3f8b4e0d7
DTS support by Peter Schuller <peterschueller@telemed.de> (revised by arpi)
alex
parents:
8026
diff
changeset
|
124 return 0; |
f8f3f8b4e0d7
DTS support by Peter Schuller <peterschueller@telemed.de> (revised by arpi)
alex
parents:
8026
diff
changeset
|
125 } |
5340
0f12fb7c1c5d
imported from MPlayerXP, dlopen() hack removed, some bugs fixed, interface functions changed to static, info->author field added
arpi
parents:
diff
changeset
|
126 return 1; |
0f12fb7c1c5d
imported from MPlayerXP, dlopen() hack removed, some bugs fixed, interface functions changed to static, info->author field added
arpi
parents:
diff
changeset
|
127 } |
0f12fb7c1c5d
imported from MPlayerXP, dlopen() hack removed, some bugs fixed, interface functions changed to static, info->author field added
arpi
parents:
diff
changeset
|
128 |
0f12fb7c1c5d
imported from MPlayerXP, dlopen() hack removed, some bugs fixed, interface functions changed to static, info->author field added
arpi
parents:
diff
changeset
|
129 static void uninit(sh_audio_t *sh) |
0f12fb7c1c5d
imported from MPlayerXP, dlopen() hack removed, some bugs fixed, interface functions changed to static, info->author field added
arpi
parents:
diff
changeset
|
130 { |
0f12fb7c1c5d
imported from MPlayerXP, dlopen() hack removed, some bugs fixed, interface functions changed to static, info->author field added
arpi
parents:
diff
changeset
|
131 } |
0f12fb7c1c5d
imported from MPlayerXP, dlopen() hack removed, some bugs fixed, interface functions changed to static, info->author field added
arpi
parents:
diff
changeset
|
132 |
0f12fb7c1c5d
imported from MPlayerXP, dlopen() hack removed, some bugs fixed, interface functions changed to static, info->author field added
arpi
parents:
diff
changeset
|
133 static int control(sh_audio_t *sh,int cmd,void* arg, ...) |
0f12fb7c1c5d
imported from MPlayerXP, dlopen() hack removed, some bugs fixed, interface functions changed to static, info->author field added
arpi
parents:
diff
changeset
|
134 { |
10012
f8f3f8b4e0d7
DTS support by Peter Schuller <peterschueller@telemed.de> (revised by arpi)
alex
parents:
8026
diff
changeset
|
135 switch(cmd) |
f8f3f8b4e0d7
DTS support by Peter Schuller <peterschueller@telemed.de> (revised by arpi)
alex
parents:
8026
diff
changeset
|
136 { |
f8f3f8b4e0d7
DTS support by Peter Schuller <peterschueller@telemed.de> (revised by arpi)
alex
parents:
8026
diff
changeset
|
137 case ADCTRL_SKIP_FRAME: |
f8f3f8b4e0d7
DTS support by Peter Schuller <peterschueller@telemed.de> (revised by arpi)
alex
parents:
8026
diff
changeset
|
138 ac3dts_fillbuff(sh); break; // skip AC3 frame |
f8f3f8b4e0d7
DTS support by Peter Schuller <peterschueller@telemed.de> (revised by arpi)
alex
parents:
8026
diff
changeset
|
139 return CONTROL_TRUE; |
f8f3f8b4e0d7
DTS support by Peter Schuller <peterschueller@telemed.de> (revised by arpi)
alex
parents:
8026
diff
changeset
|
140 } |
5340
0f12fb7c1c5d
imported from MPlayerXP, dlopen() hack removed, some bugs fixed, interface functions changed to static, info->author field added
arpi
parents:
diff
changeset
|
141 return CONTROL_UNKNOWN; |
0f12fb7c1c5d
imported from MPlayerXP, dlopen() hack removed, some bugs fixed, interface functions changed to static, info->author field added
arpi
parents:
diff
changeset
|
142 } |
0f12fb7c1c5d
imported from MPlayerXP, dlopen() hack removed, some bugs fixed, interface functions changed to static, info->author field added
arpi
parents:
diff
changeset
|
143 |
10012
f8f3f8b4e0d7
DTS support by Peter Schuller <peterschueller@telemed.de> (revised by arpi)
alex
parents:
8026
diff
changeset
|
144 |
5340
0f12fb7c1c5d
imported from MPlayerXP, dlopen() hack removed, some bugs fixed, interface functions changed to static, info->author field added
arpi
parents:
diff
changeset
|
145 static int decode_audio(sh_audio_t *sh_audio,unsigned char *buf,int minlen,int maxlen) |
0f12fb7c1c5d
imported from MPlayerXP, dlopen() hack removed, some bugs fixed, interface functions changed to static, info->author field added
arpi
parents:
diff
changeset
|
146 { |
10012
f8f3f8b4e0d7
DTS support by Peter Schuller <peterschueller@telemed.de> (revised by arpi)
alex
parents:
8026
diff
changeset
|
147 int len = sh_audio->a_in_buffer_len; |
f8f3f8b4e0d7
DTS support by Peter Schuller <peterschueller@telemed.de> (revised by arpi)
alex
parents:
8026
diff
changeset
|
148 |
f8f3f8b4e0d7
DTS support by Peter Schuller <peterschueller@telemed.de> (revised by arpi)
alex
parents:
8026
diff
changeset
|
149 if(len <= 0) |
f8f3f8b4e0d7
DTS support by Peter Schuller <peterschueller@telemed.de> (revised by arpi)
alex
parents:
8026
diff
changeset
|
150 if((len = ac3dts_fillbuff(sh_audio)) <= 0) |
f8f3f8b4e0d7
DTS support by Peter Schuller <peterschueller@telemed.de> (revised by arpi)
alex
parents:
8026
diff
changeset
|
151 return len; /*EOF*/ |
f8f3f8b4e0d7
DTS support by Peter Schuller <peterschueller@telemed.de> (revised by arpi)
alex
parents:
8026
diff
changeset
|
152 sh_audio->a_in_buffer_len = 0; |
f8f3f8b4e0d7
DTS support by Peter Schuller <peterschueller@telemed.de> (revised by arpi)
alex
parents:
8026
diff
changeset
|
153 |
f8f3f8b4e0d7
DTS support by Peter Schuller <peterschueller@telemed.de> (revised by arpi)
alex
parents:
8026
diff
changeset
|
154 if(isdts == 1) |
f8f3f8b4e0d7
DTS support by Peter Schuller <peterschueller@telemed.de> (revised by arpi)
alex
parents:
8026
diff
changeset
|
155 { |
f8f3f8b4e0d7
DTS support by Peter Schuller <peterschueller@telemed.de> (revised by arpi)
alex
parents:
8026
diff
changeset
|
156 return decode_audio_dts(sh_audio->a_in_buffer, len, buf); |
f8f3f8b4e0d7
DTS support by Peter Schuller <peterschueller@telemed.de> (revised by arpi)
alex
parents:
8026
diff
changeset
|
157 } |
f8f3f8b4e0d7
DTS support by Peter Schuller <peterschueller@telemed.de> (revised by arpi)
alex
parents:
8026
diff
changeset
|
158 else if(isdts == 0) |
f8f3f8b4e0d7
DTS support by Peter Schuller <peterschueller@telemed.de> (revised by arpi)
alex
parents:
8026
diff
changeset
|
159 { |
f8f3f8b4e0d7
DTS support by Peter Schuller <peterschueller@telemed.de> (revised by arpi)
alex
parents:
8026
diff
changeset
|
160 buf[0] = 0x72; |
f8f3f8b4e0d7
DTS support by Peter Schuller <peterschueller@telemed.de> (revised by arpi)
alex
parents:
8026
diff
changeset
|
161 buf[1] = 0xF8; |
f8f3f8b4e0d7
DTS support by Peter Schuller <peterschueller@telemed.de> (revised by arpi)
alex
parents:
8026
diff
changeset
|
162 buf[2] = 0x1F; |
f8f3f8b4e0d7
DTS support by Peter Schuller <peterschueller@telemed.de> (revised by arpi)
alex
parents:
8026
diff
changeset
|
163 buf[3] = 0x4E; |
f8f3f8b4e0d7
DTS support by Peter Schuller <peterschueller@telemed.de> (revised by arpi)
alex
parents:
8026
diff
changeset
|
164 buf[4] = 0x01; //(length) ? data_type : 0; /* & 0x1F; */ |
f8f3f8b4e0d7
DTS support by Peter Schuller <peterschueller@telemed.de> (revised by arpi)
alex
parents:
8026
diff
changeset
|
165 buf[5] = 0x00; |
f8f3f8b4e0d7
DTS support by Peter Schuller <peterschueller@telemed.de> (revised by arpi)
alex
parents:
8026
diff
changeset
|
166 buf[6] = (len << 3) & 0xFF; |
f8f3f8b4e0d7
DTS support by Peter Schuller <peterschueller@telemed.de> (revised by arpi)
alex
parents:
8026
diff
changeset
|
167 buf[7] = (len >> 5) & 0xFF; |
f8f3f8b4e0d7
DTS support by Peter Schuller <peterschueller@telemed.de> (revised by arpi)
alex
parents:
8026
diff
changeset
|
168 #ifdef WORDS_BIGENDIAN |
f8f3f8b4e0d7
DTS support by Peter Schuller <peterschueller@telemed.de> (revised by arpi)
alex
parents:
8026
diff
changeset
|
169 memcpy(buf + 8, sh_audio->a_in_buffer, len); // untested |
f8f3f8b4e0d7
DTS support by Peter Schuller <peterschueller@telemed.de> (revised by arpi)
alex
parents:
8026
diff
changeset
|
170 #else |
f8f3f8b4e0d7
DTS support by Peter Schuller <peterschueller@telemed.de> (revised by arpi)
alex
parents:
8026
diff
changeset
|
171 swab(sh_audio->a_in_buffer, buf + 8, len); |
f8f3f8b4e0d7
DTS support by Peter Schuller <peterschueller@telemed.de> (revised by arpi)
alex
parents:
8026
diff
changeset
|
172 #endif |
f8f3f8b4e0d7
DTS support by Peter Schuller <peterschueller@telemed.de> (revised by arpi)
alex
parents:
8026
diff
changeset
|
173 memset(buf + 8 + len, 0, 6144 - 8 - len); |
f8f3f8b4e0d7
DTS support by Peter Schuller <peterschueller@telemed.de> (revised by arpi)
alex
parents:
8026
diff
changeset
|
174 |
f8f3f8b4e0d7
DTS support by Peter Schuller <peterschueller@telemed.de> (revised by arpi)
alex
parents:
8026
diff
changeset
|
175 return 6144; |
f8f3f8b4e0d7
DTS support by Peter Schuller <peterschueller@telemed.de> (revised by arpi)
alex
parents:
8026
diff
changeset
|
176 } |
f8f3f8b4e0d7
DTS support by Peter Schuller <peterschueller@telemed.de> (revised by arpi)
alex
parents:
8026
diff
changeset
|
177 else |
f8f3f8b4e0d7
DTS support by Peter Schuller <peterschueller@telemed.de> (revised by arpi)
alex
parents:
8026
diff
changeset
|
178 return -1; |
f8f3f8b4e0d7
DTS support by Peter Schuller <peterschueller@telemed.de> (revised by arpi)
alex
parents:
8026
diff
changeset
|
179 } |
f8f3f8b4e0d7
DTS support by Peter Schuller <peterschueller@telemed.de> (revised by arpi)
alex
parents:
8026
diff
changeset
|
180 |
f8f3f8b4e0d7
DTS support by Peter Schuller <peterschueller@telemed.de> (revised by arpi)
alex
parents:
8026
diff
changeset
|
181 |
f8f3f8b4e0d7
DTS support by Peter Schuller <peterschueller@telemed.de> (revised by arpi)
alex
parents:
8026
diff
changeset
|
182 static int DTS_SAMPLEFREQS[16] = |
f8f3f8b4e0d7
DTS support by Peter Schuller <peterschueller@telemed.de> (revised by arpi)
alex
parents:
8026
diff
changeset
|
183 { |
f8f3f8b4e0d7
DTS support by Peter Schuller <peterschueller@telemed.de> (revised by arpi)
alex
parents:
8026
diff
changeset
|
184 0, |
f8f3f8b4e0d7
DTS support by Peter Schuller <peterschueller@telemed.de> (revised by arpi)
alex
parents:
8026
diff
changeset
|
185 8000, |
f8f3f8b4e0d7
DTS support by Peter Schuller <peterschueller@telemed.de> (revised by arpi)
alex
parents:
8026
diff
changeset
|
186 16000, |
f8f3f8b4e0d7
DTS support by Peter Schuller <peterschueller@telemed.de> (revised by arpi)
alex
parents:
8026
diff
changeset
|
187 32000, |
f8f3f8b4e0d7
DTS support by Peter Schuller <peterschueller@telemed.de> (revised by arpi)
alex
parents:
8026
diff
changeset
|
188 64000, |
f8f3f8b4e0d7
DTS support by Peter Schuller <peterschueller@telemed.de> (revised by arpi)
alex
parents:
8026
diff
changeset
|
189 128000, |
f8f3f8b4e0d7
DTS support by Peter Schuller <peterschueller@telemed.de> (revised by arpi)
alex
parents:
8026
diff
changeset
|
190 11025, |
f8f3f8b4e0d7
DTS support by Peter Schuller <peterschueller@telemed.de> (revised by arpi)
alex
parents:
8026
diff
changeset
|
191 22050, |
f8f3f8b4e0d7
DTS support by Peter Schuller <peterschueller@telemed.de> (revised by arpi)
alex
parents:
8026
diff
changeset
|
192 44100, |
f8f3f8b4e0d7
DTS support by Peter Schuller <peterschueller@telemed.de> (revised by arpi)
alex
parents:
8026
diff
changeset
|
193 88200, |
f8f3f8b4e0d7
DTS support by Peter Schuller <peterschueller@telemed.de> (revised by arpi)
alex
parents:
8026
diff
changeset
|
194 176400, |
f8f3f8b4e0d7
DTS support by Peter Schuller <peterschueller@telemed.de> (revised by arpi)
alex
parents:
8026
diff
changeset
|
195 12000, |
f8f3f8b4e0d7
DTS support by Peter Schuller <peterschueller@telemed.de> (revised by arpi)
alex
parents:
8026
diff
changeset
|
196 24000, |
f8f3f8b4e0d7
DTS support by Peter Schuller <peterschueller@telemed.de> (revised by arpi)
alex
parents:
8026
diff
changeset
|
197 48000, |
f8f3f8b4e0d7
DTS support by Peter Schuller <peterschueller@telemed.de> (revised by arpi)
alex
parents:
8026
diff
changeset
|
198 96000, |
f8f3f8b4e0d7
DTS support by Peter Schuller <peterschueller@telemed.de> (revised by arpi)
alex
parents:
8026
diff
changeset
|
199 192000 |
f8f3f8b4e0d7
DTS support by Peter Schuller <peterschueller@telemed.de> (revised by arpi)
alex
parents:
8026
diff
changeset
|
200 }; |
5370 | 201 |
10012
f8f3f8b4e0d7
DTS support by Peter Schuller <peterschueller@telemed.de> (revised by arpi)
alex
parents:
8026
diff
changeset
|
202 static int DTS_BITRATES[30] = |
f8f3f8b4e0d7
DTS support by Peter Schuller <peterschueller@telemed.de> (revised by arpi)
alex
parents:
8026
diff
changeset
|
203 { |
f8f3f8b4e0d7
DTS support by Peter Schuller <peterschueller@telemed.de> (revised by arpi)
alex
parents:
8026
diff
changeset
|
204 32000, |
f8f3f8b4e0d7
DTS support by Peter Schuller <peterschueller@telemed.de> (revised by arpi)
alex
parents:
8026
diff
changeset
|
205 56000, |
f8f3f8b4e0d7
DTS support by Peter Schuller <peterschueller@telemed.de> (revised by arpi)
alex
parents:
8026
diff
changeset
|
206 64000, |
f8f3f8b4e0d7
DTS support by Peter Schuller <peterschueller@telemed.de> (revised by arpi)
alex
parents:
8026
diff
changeset
|
207 96000, |
f8f3f8b4e0d7
DTS support by Peter Schuller <peterschueller@telemed.de> (revised by arpi)
alex
parents:
8026
diff
changeset
|
208 112000, |
f8f3f8b4e0d7
DTS support by Peter Schuller <peterschueller@telemed.de> (revised by arpi)
alex
parents:
8026
diff
changeset
|
209 128000, |
f8f3f8b4e0d7
DTS support by Peter Schuller <peterschueller@telemed.de> (revised by arpi)
alex
parents:
8026
diff
changeset
|
210 192000, |
f8f3f8b4e0d7
DTS support by Peter Schuller <peterschueller@telemed.de> (revised by arpi)
alex
parents:
8026
diff
changeset
|
211 224000, |
f8f3f8b4e0d7
DTS support by Peter Schuller <peterschueller@telemed.de> (revised by arpi)
alex
parents:
8026
diff
changeset
|
212 256000, |
f8f3f8b4e0d7
DTS support by Peter Schuller <peterschueller@telemed.de> (revised by arpi)
alex
parents:
8026
diff
changeset
|
213 320000, |
f8f3f8b4e0d7
DTS support by Peter Schuller <peterschueller@telemed.de> (revised by arpi)
alex
parents:
8026
diff
changeset
|
214 384000, |
f8f3f8b4e0d7
DTS support by Peter Schuller <peterschueller@telemed.de> (revised by arpi)
alex
parents:
8026
diff
changeset
|
215 448000, |
f8f3f8b4e0d7
DTS support by Peter Schuller <peterschueller@telemed.de> (revised by arpi)
alex
parents:
8026
diff
changeset
|
216 512000, |
f8f3f8b4e0d7
DTS support by Peter Schuller <peterschueller@telemed.de> (revised by arpi)
alex
parents:
8026
diff
changeset
|
217 576000, |
f8f3f8b4e0d7
DTS support by Peter Schuller <peterschueller@telemed.de> (revised by arpi)
alex
parents:
8026
diff
changeset
|
218 640000, |
f8f3f8b4e0d7
DTS support by Peter Schuller <peterschueller@telemed.de> (revised by arpi)
alex
parents:
8026
diff
changeset
|
219 768000, |
f8f3f8b4e0d7
DTS support by Peter Schuller <peterschueller@telemed.de> (revised by arpi)
alex
parents:
8026
diff
changeset
|
220 896000, |
f8f3f8b4e0d7
DTS support by Peter Schuller <peterschueller@telemed.de> (revised by arpi)
alex
parents:
8026
diff
changeset
|
221 1024000, |
f8f3f8b4e0d7
DTS support by Peter Schuller <peterschueller@telemed.de> (revised by arpi)
alex
parents:
8026
diff
changeset
|
222 1152000, |
f8f3f8b4e0d7
DTS support by Peter Schuller <peterschueller@telemed.de> (revised by arpi)
alex
parents:
8026
diff
changeset
|
223 1280000, |
f8f3f8b4e0d7
DTS support by Peter Schuller <peterschueller@telemed.de> (revised by arpi)
alex
parents:
8026
diff
changeset
|
224 1344000, |
f8f3f8b4e0d7
DTS support by Peter Schuller <peterschueller@telemed.de> (revised by arpi)
alex
parents:
8026
diff
changeset
|
225 1408000, |
f8f3f8b4e0d7
DTS support by Peter Schuller <peterschueller@telemed.de> (revised by arpi)
alex
parents:
8026
diff
changeset
|
226 1411200, |
f8f3f8b4e0d7
DTS support by Peter Schuller <peterschueller@telemed.de> (revised by arpi)
alex
parents:
8026
diff
changeset
|
227 1472000, |
f8f3f8b4e0d7
DTS support by Peter Schuller <peterschueller@telemed.de> (revised by arpi)
alex
parents:
8026
diff
changeset
|
228 1536000, |
f8f3f8b4e0d7
DTS support by Peter Schuller <peterschueller@telemed.de> (revised by arpi)
alex
parents:
8026
diff
changeset
|
229 1920000, |
f8f3f8b4e0d7
DTS support by Peter Schuller <peterschueller@telemed.de> (revised by arpi)
alex
parents:
8026
diff
changeset
|
230 2048000, |
f8f3f8b4e0d7
DTS support by Peter Schuller <peterschueller@telemed.de> (revised by arpi)
alex
parents:
8026
diff
changeset
|
231 3072000, |
f8f3f8b4e0d7
DTS support by Peter Schuller <peterschueller@telemed.de> (revised by arpi)
alex
parents:
8026
diff
changeset
|
232 3840000, |
f8f3f8b4e0d7
DTS support by Peter Schuller <peterschueller@telemed.de> (revised by arpi)
alex
parents:
8026
diff
changeset
|
233 4096000 |
f8f3f8b4e0d7
DTS support by Peter Schuller <peterschueller@telemed.de> (revised by arpi)
alex
parents:
8026
diff
changeset
|
234 }; |
f8f3f8b4e0d7
DTS support by Peter Schuller <peterschueller@telemed.de> (revised by arpi)
alex
parents:
8026
diff
changeset
|
235 |
f8f3f8b4e0d7
DTS support by Peter Schuller <peterschueller@telemed.de> (revised by arpi)
alex
parents:
8026
diff
changeset
|
236 static int dts_decode_header(uint8_t *indata_ptr, int *rate, int *nblks, int *sfreq) |
f8f3f8b4e0d7
DTS support by Peter Schuller <peterschueller@telemed.de> (revised by arpi)
alex
parents:
8026
diff
changeset
|
237 { |
f8f3f8b4e0d7
DTS support by Peter Schuller <peterschueller@telemed.de> (revised by arpi)
alex
parents:
8026
diff
changeset
|
238 int ftype; |
f8f3f8b4e0d7
DTS support by Peter Schuller <peterschueller@telemed.de> (revised by arpi)
alex
parents:
8026
diff
changeset
|
239 int surp; |
f8f3f8b4e0d7
DTS support by Peter Schuller <peterschueller@telemed.de> (revised by arpi)
alex
parents:
8026
diff
changeset
|
240 int unknown_bit; |
f8f3f8b4e0d7
DTS support by Peter Schuller <peterschueller@telemed.de> (revised by arpi)
alex
parents:
8026
diff
changeset
|
241 int fsize; |
f8f3f8b4e0d7
DTS support by Peter Schuller <peterschueller@telemed.de> (revised by arpi)
alex
parents:
8026
diff
changeset
|
242 int amode; |
f8f3f8b4e0d7
DTS support by Peter Schuller <peterschueller@telemed.de> (revised by arpi)
alex
parents:
8026
diff
changeset
|
243 |
f8f3f8b4e0d7
DTS support by Peter Schuller <peterschueller@telemed.de> (revised by arpi)
alex
parents:
8026
diff
changeset
|
244 if(((indata_ptr[0] << 24) | (indata_ptr[1] << 16) | (indata_ptr[2] << 8) |
f8f3f8b4e0d7
DTS support by Peter Schuller <peterschueller@telemed.de> (revised by arpi)
alex
parents:
8026
diff
changeset
|
245 | (indata_ptr[3])) != 0x7ffe8001) |
f8f3f8b4e0d7
DTS support by Peter Schuller <peterschueller@telemed.de> (revised by arpi)
alex
parents:
8026
diff
changeset
|
246 return -1; |
f8f3f8b4e0d7
DTS support by Peter Schuller <peterschueller@telemed.de> (revised by arpi)
alex
parents:
8026
diff
changeset
|
247 |
f8f3f8b4e0d7
DTS support by Peter Schuller <peterschueller@telemed.de> (revised by arpi)
alex
parents:
8026
diff
changeset
|
248 ftype = indata_ptr[4] >> 7; |
f8f3f8b4e0d7
DTS support by Peter Schuller <peterschueller@telemed.de> (revised by arpi)
alex
parents:
8026
diff
changeset
|
249 |
f8f3f8b4e0d7
DTS support by Peter Schuller <peterschueller@telemed.de> (revised by arpi)
alex
parents:
8026
diff
changeset
|
250 surp = (indata_ptr[4] >> 2) & 0x1f; |
f8f3f8b4e0d7
DTS support by Peter Schuller <peterschueller@telemed.de> (revised by arpi)
alex
parents:
8026
diff
changeset
|
251 surp = (surp + 1) % 32; |
f8f3f8b4e0d7
DTS support by Peter Schuller <peterschueller@telemed.de> (revised by arpi)
alex
parents:
8026
diff
changeset
|
252 |
f8f3f8b4e0d7
DTS support by Peter Schuller <peterschueller@telemed.de> (revised by arpi)
alex
parents:
8026
diff
changeset
|
253 unknown_bit = (indata_ptr[4] >> 1) & 0x01; |
f8f3f8b4e0d7
DTS support by Peter Schuller <peterschueller@telemed.de> (revised by arpi)
alex
parents:
8026
diff
changeset
|
254 |
f8f3f8b4e0d7
DTS support by Peter Schuller <peterschueller@telemed.de> (revised by arpi)
alex
parents:
8026
diff
changeset
|
255 *nblks = (indata_ptr[4] & 0x01) << 6 | (indata_ptr[5] >> 2); |
f8f3f8b4e0d7
DTS support by Peter Schuller <peterschueller@telemed.de> (revised by arpi)
alex
parents:
8026
diff
changeset
|
256 *nblks = *nblks + 1; |
5370 | 257 |
10012
f8f3f8b4e0d7
DTS support by Peter Schuller <peterschueller@telemed.de> (revised by arpi)
alex
parents:
8026
diff
changeset
|
258 fsize = (indata_ptr[5] & 0x03) << 12 | (indata_ptr[6] << 4) | (indata_ptr[7] >> 4); |
f8f3f8b4e0d7
DTS support by Peter Schuller <peterschueller@telemed.de> (revised by arpi)
alex
parents:
8026
diff
changeset
|
259 fsize = fsize + 1; |
f8f3f8b4e0d7
DTS support by Peter Schuller <peterschueller@telemed.de> (revised by arpi)
alex
parents:
8026
diff
changeset
|
260 |
f8f3f8b4e0d7
DTS support by Peter Schuller <peterschueller@telemed.de> (revised by arpi)
alex
parents:
8026
diff
changeset
|
261 amode = (indata_ptr[7] & 0x0f) << 2 | (indata_ptr[8] >> 6); |
f8f3f8b4e0d7
DTS support by Peter Schuller <peterschueller@telemed.de> (revised by arpi)
alex
parents:
8026
diff
changeset
|
262 *sfreq = (indata_ptr[8] >> 2) & 0x0f; |
f8f3f8b4e0d7
DTS support by Peter Schuller <peterschueller@telemed.de> (revised by arpi)
alex
parents:
8026
diff
changeset
|
263 *rate = (indata_ptr[8] & 0x03) << 3 | ((indata_ptr[9] >> 5) & 0x07); |
f8f3f8b4e0d7
DTS support by Peter Schuller <peterschueller@telemed.de> (revised by arpi)
alex
parents:
8026
diff
changeset
|
264 |
f8f3f8b4e0d7
DTS support by Peter Schuller <peterschueller@telemed.de> (revised by arpi)
alex
parents:
8026
diff
changeset
|
265 if(ftype != 1) |
f8f3f8b4e0d7
DTS support by Peter Schuller <peterschueller@telemed.de> (revised by arpi)
alex
parents:
8026
diff
changeset
|
266 { |
f8f3f8b4e0d7
DTS support by Peter Schuller <peterschueller@telemed.de> (revised by arpi)
alex
parents:
8026
diff
changeset
|
267 mp_msg(MSGT_DECAUDIO, MSGL_ERR, "DTS: Termination frames not handled, REPORT BUG\n"); |
f8f3f8b4e0d7
DTS support by Peter Schuller <peterschueller@telemed.de> (revised by arpi)
alex
parents:
8026
diff
changeset
|
268 return -1; |
f8f3f8b4e0d7
DTS support by Peter Schuller <peterschueller@telemed.de> (revised by arpi)
alex
parents:
8026
diff
changeset
|
269 } |
f8f3f8b4e0d7
DTS support by Peter Schuller <peterschueller@telemed.de> (revised by arpi)
alex
parents:
8026
diff
changeset
|
270 |
f8f3f8b4e0d7
DTS support by Peter Schuller <peterschueller@telemed.de> (revised by arpi)
alex
parents:
8026
diff
changeset
|
271 if(*sfreq != 13) |
f8f3f8b4e0d7
DTS support by Peter Schuller <peterschueller@telemed.de> (revised by arpi)
alex
parents:
8026
diff
changeset
|
272 { |
f8f3f8b4e0d7
DTS support by Peter Schuller <peterschueller@telemed.de> (revised by arpi)
alex
parents:
8026
diff
changeset
|
273 mp_msg(MSGT_DECAUDIO, MSGL_ERR, "DTS: Only 48kHz supported, REPORT BUG\n"); |
f8f3f8b4e0d7
DTS support by Peter Schuller <peterschueller@telemed.de> (revised by arpi)
alex
parents:
8026
diff
changeset
|
274 return -1; |
f8f3f8b4e0d7
DTS support by Peter Schuller <peterschueller@telemed.de> (revised by arpi)
alex
parents:
8026
diff
changeset
|
275 } |
f8f3f8b4e0d7
DTS support by Peter Schuller <peterschueller@telemed.de> (revised by arpi)
alex
parents:
8026
diff
changeset
|
276 |
f8f3f8b4e0d7
DTS support by Peter Schuller <peterschueller@telemed.de> (revised by arpi)
alex
parents:
8026
diff
changeset
|
277 if((fsize > 8192) || (fsize < 96)) |
f8f3f8b4e0d7
DTS support by Peter Schuller <peterschueller@telemed.de> (revised by arpi)
alex
parents:
8026
diff
changeset
|
278 { |
f8f3f8b4e0d7
DTS support by Peter Schuller <peterschueller@telemed.de> (revised by arpi)
alex
parents:
8026
diff
changeset
|
279 mp_msg(MSGT_DECAUDIO, MSGL_ERR, "DTS: fsize: %d invalid, REPORT BUG\n", fsize); |
f8f3f8b4e0d7
DTS support by Peter Schuller <peterschueller@telemed.de> (revised by arpi)
alex
parents:
8026
diff
changeset
|
280 return -1; |
f8f3f8b4e0d7
DTS support by Peter Schuller <peterschueller@telemed.de> (revised by arpi)
alex
parents:
8026
diff
changeset
|
281 } |
f8f3f8b4e0d7
DTS support by Peter Schuller <peterschueller@telemed.de> (revised by arpi)
alex
parents:
8026
diff
changeset
|
282 |
f8f3f8b4e0d7
DTS support by Peter Schuller <peterschueller@telemed.de> (revised by arpi)
alex
parents:
8026
diff
changeset
|
283 if(*nblks != 8 && |
f8f3f8b4e0d7
DTS support by Peter Schuller <peterschueller@telemed.de> (revised by arpi)
alex
parents:
8026
diff
changeset
|
284 *nblks != 16 && |
f8f3f8b4e0d7
DTS support by Peter Schuller <peterschueller@telemed.de> (revised by arpi)
alex
parents:
8026
diff
changeset
|
285 *nblks != 32 && |
f8f3f8b4e0d7
DTS support by Peter Schuller <peterschueller@telemed.de> (revised by arpi)
alex
parents:
8026
diff
changeset
|
286 *nblks != 64 && |
f8f3f8b4e0d7
DTS support by Peter Schuller <peterschueller@telemed.de> (revised by arpi)
alex
parents:
8026
diff
changeset
|
287 *nblks != 128 && |
f8f3f8b4e0d7
DTS support by Peter Schuller <peterschueller@telemed.de> (revised by arpi)
alex
parents:
8026
diff
changeset
|
288 ftype == 1) |
f8f3f8b4e0d7
DTS support by Peter Schuller <peterschueller@telemed.de> (revised by arpi)
alex
parents:
8026
diff
changeset
|
289 { |
10948
aebf939834c3
10l found by Dominik 'Rathann' Mierzejewski <dominik@rangers.eu.org>
alex
parents:
10012
diff
changeset
|
290 mp_msg(MSGT_DECAUDIO, MSGL_ERR, "DTS: nblks %d not valid for normal frame, REPORT BUG\n", *nblks); |
10012
f8f3f8b4e0d7
DTS support by Peter Schuller <peterschueller@telemed.de> (revised by arpi)
alex
parents:
8026
diff
changeset
|
291 return -1; |
f8f3f8b4e0d7
DTS support by Peter Schuller <peterschueller@telemed.de> (revised by arpi)
alex
parents:
8026
diff
changeset
|
292 } |
f8f3f8b4e0d7
DTS support by Peter Schuller <peterschueller@telemed.de> (revised by arpi)
alex
parents:
8026
diff
changeset
|
293 |
f8f3f8b4e0d7
DTS support by Peter Schuller <peterschueller@telemed.de> (revised by arpi)
alex
parents:
8026
diff
changeset
|
294 return fsize; |
f8f3f8b4e0d7
DTS support by Peter Schuller <peterschueller@telemed.de> (revised by arpi)
alex
parents:
8026
diff
changeset
|
295 } |
5370 | 296 |
10012
f8f3f8b4e0d7
DTS support by Peter Schuller <peterschueller@telemed.de> (revised by arpi)
alex
parents:
8026
diff
changeset
|
297 static int dts_syncinfo(uint8_t *indata_ptr, int *flags, int *sample_rate, int *bit_rate) |
f8f3f8b4e0d7
DTS support by Peter Schuller <peterschueller@telemed.de> (revised by arpi)
alex
parents:
8026
diff
changeset
|
298 { |
f8f3f8b4e0d7
DTS support by Peter Schuller <peterschueller@telemed.de> (revised by arpi)
alex
parents:
8026
diff
changeset
|
299 int nblks; |
f8f3f8b4e0d7
DTS support by Peter Schuller <peterschueller@telemed.de> (revised by arpi)
alex
parents:
8026
diff
changeset
|
300 int fsize; |
f8f3f8b4e0d7
DTS support by Peter Schuller <peterschueller@telemed.de> (revised by arpi)
alex
parents:
8026
diff
changeset
|
301 int rate; |
f8f3f8b4e0d7
DTS support by Peter Schuller <peterschueller@telemed.de> (revised by arpi)
alex
parents:
8026
diff
changeset
|
302 int sfreq; |
f8f3f8b4e0d7
DTS support by Peter Schuller <peterschueller@telemed.de> (revised by arpi)
alex
parents:
8026
diff
changeset
|
303 |
f8f3f8b4e0d7
DTS support by Peter Schuller <peterschueller@telemed.de> (revised by arpi)
alex
parents:
8026
diff
changeset
|
304 fsize = dts_decode_header(indata_ptr, &rate, &nblks, &sfreq); |
f8f3f8b4e0d7
DTS support by Peter Schuller <peterschueller@telemed.de> (revised by arpi)
alex
parents:
8026
diff
changeset
|
305 if(fsize >= 0) |
f8f3f8b4e0d7
DTS support by Peter Schuller <peterschueller@telemed.de> (revised by arpi)
alex
parents:
8026
diff
changeset
|
306 { |
f8f3f8b4e0d7
DTS support by Peter Schuller <peterschueller@telemed.de> (revised by arpi)
alex
parents:
8026
diff
changeset
|
307 if(rate >= 0 && rate <= 29) |
f8f3f8b4e0d7
DTS support by Peter Schuller <peterschueller@telemed.de> (revised by arpi)
alex
parents:
8026
diff
changeset
|
308 *bit_rate = DTS_BITRATES[rate]; |
f8f3f8b4e0d7
DTS support by Peter Schuller <peterschueller@telemed.de> (revised by arpi)
alex
parents:
8026
diff
changeset
|
309 else |
f8f3f8b4e0d7
DTS support by Peter Schuller <peterschueller@telemed.de> (revised by arpi)
alex
parents:
8026
diff
changeset
|
310 *bit_rate = 0; |
f8f3f8b4e0d7
DTS support by Peter Schuller <peterschueller@telemed.de> (revised by arpi)
alex
parents:
8026
diff
changeset
|
311 if(sfreq >= 1 && sfreq <= 15) |
f8f3f8b4e0d7
DTS support by Peter Schuller <peterschueller@telemed.de> (revised by arpi)
alex
parents:
8026
diff
changeset
|
312 *sample_rate = DTS_SAMPLEFREQS[sfreq]; |
f8f3f8b4e0d7
DTS support by Peter Schuller <peterschueller@telemed.de> (revised by arpi)
alex
parents:
8026
diff
changeset
|
313 else |
f8f3f8b4e0d7
DTS support by Peter Schuller <peterschueller@telemed.de> (revised by arpi)
alex
parents:
8026
diff
changeset
|
314 *sample_rate = 0; |
f8f3f8b4e0d7
DTS support by Peter Schuller <peterschueller@telemed.de> (revised by arpi)
alex
parents:
8026
diff
changeset
|
315 } |
f8f3f8b4e0d7
DTS support by Peter Schuller <peterschueller@telemed.de> (revised by arpi)
alex
parents:
8026
diff
changeset
|
316 return fsize; |
f8f3f8b4e0d7
DTS support by Peter Schuller <peterschueller@telemed.de> (revised by arpi)
alex
parents:
8026
diff
changeset
|
317 } |
f8f3f8b4e0d7
DTS support by Peter Schuller <peterschueller@telemed.de> (revised by arpi)
alex
parents:
8026
diff
changeset
|
318 |
f8f3f8b4e0d7
DTS support by Peter Schuller <peterschueller@telemed.de> (revised by arpi)
alex
parents:
8026
diff
changeset
|
319 |
f8f3f8b4e0d7
DTS support by Peter Schuller <peterschueller@telemed.de> (revised by arpi)
alex
parents:
8026
diff
changeset
|
320 static int decode_audio_dts(unsigned char *indata_ptr, int len, unsigned char *buf) |
f8f3f8b4e0d7
DTS support by Peter Schuller <peterschueller@telemed.de> (revised by arpi)
alex
parents:
8026
diff
changeset
|
321 { |
f8f3f8b4e0d7
DTS support by Peter Schuller <peterschueller@telemed.de> (revised by arpi)
alex
parents:
8026
diff
changeset
|
322 int nblks; |
f8f3f8b4e0d7
DTS support by Peter Schuller <peterschueller@telemed.de> (revised by arpi)
alex
parents:
8026
diff
changeset
|
323 int fsize; |
f8f3f8b4e0d7
DTS support by Peter Schuller <peterschueller@telemed.de> (revised by arpi)
alex
parents:
8026
diff
changeset
|
324 int rate; |
f8f3f8b4e0d7
DTS support by Peter Schuller <peterschueller@telemed.de> (revised by arpi)
alex
parents:
8026
diff
changeset
|
325 int sfreq; |
f8f3f8b4e0d7
DTS support by Peter Schuller <peterschueller@telemed.de> (revised by arpi)
alex
parents:
8026
diff
changeset
|
326 int burst_len; |
f8f3f8b4e0d7
DTS support by Peter Schuller <peterschueller@telemed.de> (revised by arpi)
alex
parents:
8026
diff
changeset
|
327 int nr_samples; |
f8f3f8b4e0d7
DTS support by Peter Schuller <peterschueller@telemed.de> (revised by arpi)
alex
parents:
8026
diff
changeset
|
328 |
f8f3f8b4e0d7
DTS support by Peter Schuller <peterschueller@telemed.de> (revised by arpi)
alex
parents:
8026
diff
changeset
|
329 fsize = dts_decode_header(indata_ptr, &rate, &nblks, &sfreq); |
f8f3f8b4e0d7
DTS support by Peter Schuller <peterschueller@telemed.de> (revised by arpi)
alex
parents:
8026
diff
changeset
|
330 if(fsize < 0) |
f8f3f8b4e0d7
DTS support by Peter Schuller <peterschueller@telemed.de> (revised by arpi)
alex
parents:
8026
diff
changeset
|
331 return -1; |
f8f3f8b4e0d7
DTS support by Peter Schuller <peterschueller@telemed.de> (revised by arpi)
alex
parents:
8026
diff
changeset
|
332 |
f8f3f8b4e0d7
DTS support by Peter Schuller <peterschueller@telemed.de> (revised by arpi)
alex
parents:
8026
diff
changeset
|
333 burst_len = fsize * 8; |
f8f3f8b4e0d7
DTS support by Peter Schuller <peterschueller@telemed.de> (revised by arpi)
alex
parents:
8026
diff
changeset
|
334 nr_samples = nblks * 32; |
f8f3f8b4e0d7
DTS support by Peter Schuller <peterschueller@telemed.de> (revised by arpi)
alex
parents:
8026
diff
changeset
|
335 |
f8f3f8b4e0d7
DTS support by Peter Schuller <peterschueller@telemed.de> (revised by arpi)
alex
parents:
8026
diff
changeset
|
336 buf[0] = 0x72; buf[1] = 0xf8; /* iec 61937 */ |
f8f3f8b4e0d7
DTS support by Peter Schuller <peterschueller@telemed.de> (revised by arpi)
alex
parents:
8026
diff
changeset
|
337 buf[2] = 0x1f; buf[3] = 0x4e; /* syncword */ |
f8f3f8b4e0d7
DTS support by Peter Schuller <peterschueller@telemed.de> (revised by arpi)
alex
parents:
8026
diff
changeset
|
338 switch(nr_samples) |
f8f3f8b4e0d7
DTS support by Peter Schuller <peterschueller@telemed.de> (revised by arpi)
alex
parents:
8026
diff
changeset
|
339 { |
f8f3f8b4e0d7
DTS support by Peter Schuller <peterschueller@telemed.de> (revised by arpi)
alex
parents:
8026
diff
changeset
|
340 case 512: |
f8f3f8b4e0d7
DTS support by Peter Schuller <peterschueller@telemed.de> (revised by arpi)
alex
parents:
8026
diff
changeset
|
341 buf[4] = 0x0b; /* DTS-1 (512-sample bursts) */ |
f8f3f8b4e0d7
DTS support by Peter Schuller <peterschueller@telemed.de> (revised by arpi)
alex
parents:
8026
diff
changeset
|
342 break; |
f8f3f8b4e0d7
DTS support by Peter Schuller <peterschueller@telemed.de> (revised by arpi)
alex
parents:
8026
diff
changeset
|
343 case 1024: |
f8f3f8b4e0d7
DTS support by Peter Schuller <peterschueller@telemed.de> (revised by arpi)
alex
parents:
8026
diff
changeset
|
344 buf[4] = 0x0c; /* DTS-2 (1024-sample bursts) */ |
f8f3f8b4e0d7
DTS support by Peter Schuller <peterschueller@telemed.de> (revised by arpi)
alex
parents:
8026
diff
changeset
|
345 break; |
f8f3f8b4e0d7
DTS support by Peter Schuller <peterschueller@telemed.de> (revised by arpi)
alex
parents:
8026
diff
changeset
|
346 case 2048: |
f8f3f8b4e0d7
DTS support by Peter Schuller <peterschueller@telemed.de> (revised by arpi)
alex
parents:
8026
diff
changeset
|
347 buf[4] = 0x0d; /* DTS-3 (2048-sample bursts) */ |
f8f3f8b4e0d7
DTS support by Peter Schuller <peterschueller@telemed.de> (revised by arpi)
alex
parents:
8026
diff
changeset
|
348 break; |
f8f3f8b4e0d7
DTS support by Peter Schuller <peterschueller@telemed.de> (revised by arpi)
alex
parents:
8026
diff
changeset
|
349 default: |
f8f3f8b4e0d7
DTS support by Peter Schuller <peterschueller@telemed.de> (revised by arpi)
alex
parents:
8026
diff
changeset
|
350 mp_msg(MSGT_DECAUDIO, MSGL_ERR, "DTS: %d-sample bursts not supported\n", nr_samples); |
f8f3f8b4e0d7
DTS support by Peter Schuller <peterschueller@telemed.de> (revised by arpi)
alex
parents:
8026
diff
changeset
|
351 buf[4] = 0x00; |
f8f3f8b4e0d7
DTS support by Peter Schuller <peterschueller@telemed.de> (revised by arpi)
alex
parents:
8026
diff
changeset
|
352 break; |
f8f3f8b4e0d7
DTS support by Peter Schuller <peterschueller@telemed.de> (revised by arpi)
alex
parents:
8026
diff
changeset
|
353 } |
f8f3f8b4e0d7
DTS support by Peter Schuller <peterschueller@telemed.de> (revised by arpi)
alex
parents:
8026
diff
changeset
|
354 buf[5] = 0; /* ?? */ |
f8f3f8b4e0d7
DTS support by Peter Schuller <peterschueller@telemed.de> (revised by arpi)
alex
parents:
8026
diff
changeset
|
355 buf[6] = (burst_len) & 0xff; |
f8f3f8b4e0d7
DTS support by Peter Schuller <peterschueller@telemed.de> (revised by arpi)
alex
parents:
8026
diff
changeset
|
356 buf[7] = (burst_len >> 8) & 0xff; |
f8f3f8b4e0d7
DTS support by Peter Schuller <peterschueller@telemed.de> (revised by arpi)
alex
parents:
8026
diff
changeset
|
357 |
f8f3f8b4e0d7
DTS support by Peter Schuller <peterschueller@telemed.de> (revised by arpi)
alex
parents:
8026
diff
changeset
|
358 if(fsize + 8 > nr_samples * 2 * 2) |
f8f3f8b4e0d7
DTS support by Peter Schuller <peterschueller@telemed.de> (revised by arpi)
alex
parents:
8026
diff
changeset
|
359 { |
f8f3f8b4e0d7
DTS support by Peter Schuller <peterschueller@telemed.de> (revised by arpi)
alex
parents:
8026
diff
changeset
|
360 mp_msg(MSGT_DECAUDIO, MSGL_ERR, "DTS: more data than fits\n"); |
f8f3f8b4e0d7
DTS support by Peter Schuller <peterschueller@telemed.de> (revised by arpi)
alex
parents:
8026
diff
changeset
|
361 } |
f8f3f8b4e0d7
DTS support by Peter Schuller <peterschueller@telemed.de> (revised by arpi)
alex
parents:
8026
diff
changeset
|
362 #ifdef WORDS_BIGENDIAN |
f8f3f8b4e0d7
DTS support by Peter Schuller <peterschueller@telemed.de> (revised by arpi)
alex
parents:
8026
diff
changeset
|
363 memcpy(&buf[8], indata_ptr, fsize); // untested |
f8f3f8b4e0d7
DTS support by Peter Schuller <peterschueller@telemed.de> (revised by arpi)
alex
parents:
8026
diff
changeset
|
364 #else |
f8f3f8b4e0d7
DTS support by Peter Schuller <peterschueller@telemed.de> (revised by arpi)
alex
parents:
8026
diff
changeset
|
365 //TODO if fzise is odd, swab doesn't copy the last byte |
f8f3f8b4e0d7
DTS support by Peter Schuller <peterschueller@telemed.de> (revised by arpi)
alex
parents:
8026
diff
changeset
|
366 swab(indata_ptr, &buf[8], fsize); |
f8f3f8b4e0d7
DTS support by Peter Schuller <peterschueller@telemed.de> (revised by arpi)
alex
parents:
8026
diff
changeset
|
367 #endif |
f8f3f8b4e0d7
DTS support by Peter Schuller <peterschueller@telemed.de> (revised by arpi)
alex
parents:
8026
diff
changeset
|
368 memset(&buf[fsize + 8], 0, nr_samples * 2 * 2 - (fsize + 8)); |
f8f3f8b4e0d7
DTS support by Peter Schuller <peterschueller@telemed.de> (revised by arpi)
alex
parents:
8026
diff
changeset
|
369 |
f8f3f8b4e0d7
DTS support by Peter Schuller <peterschueller@telemed.de> (revised by arpi)
alex
parents:
8026
diff
changeset
|
370 return nr_samples * 2 * 2; |
5340
0f12fb7c1c5d
imported from MPlayerXP, dlopen() hack removed, some bugs fixed, interface functions changed to static, info->author field added
arpi
parents:
diff
changeset
|
371 } |
8026
b465ba5897a3
usage of libmpeg2, liba52, mp3lib & svq1 can be disabled
arpi
parents:
7405
diff
changeset
|
372 #endif |