annotate libmpcodecs/ad_hwac3.c @ 24173:49aa1cef1867

Fix warning: In file included from layer3.c:1171, from sr1.c:391: decod386.c:106: warning: redundant redeclaration of 'synth_1to1_MMX' mpg123.h:120: warning: previous declaration of 'synth_1to1_MMX' was here
author diego
date Sat, 25 Aug 2007 17:05:02 +0000
parents acfe034e5386
children 79fcacd73f9b
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
5370
bb1d63fea638 ac3_iec958_build_burst moved from ac3-iec958.c
arpi
parents: 5340
diff changeset
1
bb1d63fea638 ac3_iec958_build_burst moved from ac3-iec958.c
arpi
parents: 5340
diff changeset
2 // Reference: DOCS/tech/hwac3.txt !!!!!
bb1d63fea638 ac3_iec958_build_burst moved from ac3-iec958.c
arpi
parents: 5340
diff changeset
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
bb1d63fea638 ac3_iec958_build_burst moved from ac3-iec958.c
arpi
parents: 5340
diff changeset
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"
23638
a81e246e3b38 Make sure we always have a swab() prototype when we use it,
reimar
parents: 18512
diff changeset
18 #include "mpbswap.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
19
0f12fb7c1c5d imported from MPlayerXP, dlopen() hack removed, some bugs fixed, interface functions changed to static, info->author field added
arpi
parents:
diff changeset
20 #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
21
17012
6ff3379a0862 Unify include path handling, -I.. is in CFLAGS.
diego
parents: 15558
diff changeset
22 #include "liba52/a52.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
23
10012
f8f3f8b4e0d7 DTS support by Peter Schuller <peterschueller@telemed.de> (revised by arpi)
alex
parents: 8026
diff changeset
24
f8f3f8b4e0d7 DTS support by Peter Schuller <peterschueller@telemed.de> (revised by arpi)
alex
parents: 8026
diff changeset
25 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
26
0f12fb7c1c5d imported from MPlayerXP, dlopen() hack removed, some bugs fixed, interface functions changed to static, info->author field added
arpi
parents:
diff changeset
27 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
28 {
14710
diego
parents: 14245
diff changeset
29 "AC3/DTS pass-through S/PDIF",
10012
f8f3f8b4e0d7 DTS support by Peter Schuller <peterschueller@telemed.de> (revised by arpi)
alex
parents: 8026
diff changeset
30 "hwac3",
23734
acfe034e5386 ISO8859-1 --> UTF-8
diego
parents: 23638
diff changeset
31 "Nick Kurshev/Peter Schüller",
10012
f8f3f8b4e0d7 DTS support by Peter Schuller <peterschueller@telemed.de> (revised by arpi)
alex
parents: 8026
diff changeset
32 "???",
f8f3f8b4e0d7 DTS support by Peter Schuller <peterschueller@telemed.de> (revised by arpi)
alex
parents: 8026
diff changeset
33 ""
5340
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
0f12fb7c1c5d imported from MPlayerXP, dlopen() hack removed, some bugs fixed, interface functions changed to static, info->author field added
arpi
parents:
diff changeset
36 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
37
10012
f8f3f8b4e0d7 DTS support by Peter Schuller <peterschueller@telemed.de> (revised by arpi)
alex
parents: 8026
diff changeset
38
f8f3f8b4e0d7 DTS support by Peter Schuller <peterschueller@telemed.de> (revised by arpi)
alex
parents: 8026
diff changeset
39 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
40 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
41
f8f3f8b4e0d7 DTS support by Peter Schuller <peterschueller@telemed.de> (revised by arpi)
alex
parents: 8026
diff changeset
42
f8f3f8b4e0d7 DTS support by Peter Schuller <peterschueller@telemed.de> (revised by arpi)
alex
parents: 8026
diff changeset
43 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
44 {
f8f3f8b4e0d7 DTS support by Peter Schuller <peterschueller@telemed.de> (revised by arpi)
alex
parents: 8026
diff changeset
45 int length = 0;
f8f3f8b4e0d7 DTS support by Peter Schuller <peterschueller@telemed.de> (revised by arpi)
alex
parents: 8026
diff changeset
46 int flags = 0;
f8f3f8b4e0d7 DTS support by Peter Schuller <peterschueller@telemed.de> (revised by arpi)
alex
parents: 8026
diff changeset
47 int sample_rate = 0;
f8f3f8b4e0d7 DTS support by Peter Schuller <peterschueller@telemed.de> (revised by arpi)
alex
parents: 8026
diff changeset
48 int bit_rate = 0;
f8f3f8b4e0d7 DTS support by Peter Schuller <peterschueller@telemed.de> (revised by arpi)
alex
parents: 8026
diff changeset
49
f8f3f8b4e0d7 DTS support by Peter Schuller <peterschueller@telemed.de> (revised by arpi)
alex
parents: 8026
diff changeset
50 sh_audio->a_in_buffer_len = 0;
f8f3f8b4e0d7 DTS support by Peter Schuller <peterschueller@telemed.de> (revised by arpi)
alex
parents: 8026
diff changeset
51 /* sync frame:*/
f8f3f8b4e0d7 DTS support by Peter Schuller <peterschueller@telemed.de> (revised by arpi)
alex
parents: 8026
diff changeset
52 while(1)
f8f3f8b4e0d7 DTS support by Peter Schuller <peterschueller@telemed.de> (revised by arpi)
alex
parents: 8026
diff changeset
53 {
f8f3f8b4e0d7 DTS support by Peter Schuller <peterschueller@telemed.de> (revised by arpi)
alex
parents: 8026
diff changeset
54 // DTS has a 10 byte header
f8f3f8b4e0d7 DTS support by Peter Schuller <peterschueller@telemed.de> (revised by arpi)
alex
parents: 8026
diff changeset
55 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
56 {
f8f3f8b4e0d7 DTS support by Peter Schuller <peterschueller@telemed.de> (revised by arpi)
alex
parents: 8026
diff changeset
57 int c = demux_getc(sh_audio->ds);
f8f3f8b4e0d7 DTS support by Peter Schuller <peterschueller@telemed.de> (revised by arpi)
alex
parents: 8026
diff changeset
58 if(c<0)
f8f3f8b4e0d7 DTS support by Peter Schuller <peterschueller@telemed.de> (revised by arpi)
alex
parents: 8026
diff changeset
59 return -1; /* EOF*/
f8f3f8b4e0d7 DTS support by Peter Schuller <peterschueller@telemed.de> (revised by arpi)
alex
parents: 8026
diff changeset
60 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
61 }
f8f3f8b4e0d7 DTS support by Peter Schuller <peterschueller@telemed.de> (revised by arpi)
alex
parents: 8026
diff changeset
62
f8f3f8b4e0d7 DTS support by Peter Schuller <peterschueller@telemed.de> (revised by arpi)
alex
parents: 8026
diff changeset
63 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
64 if(length >= 10)
f8f3f8b4e0d7 DTS support by Peter Schuller <peterschueller@telemed.de> (revised by arpi)
alex
parents: 8026
diff changeset
65 {
f8f3f8b4e0d7 DTS support by Peter Schuller <peterschueller@telemed.de> (revised by arpi)
alex
parents: 8026
diff changeset
66 if(isdts != 1)
f8f3f8b4e0d7 DTS support by Peter Schuller <peterschueller@telemed.de> (revised by arpi)
alex
parents: 8026
diff changeset
67 {
f8f3f8b4e0d7 DTS support by Peter Schuller <peterschueller@telemed.de> (revised by arpi)
alex
parents: 8026
diff changeset
68 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
69 isdts = 1;
f8f3f8b4e0d7 DTS support by Peter Schuller <peterschueller@telemed.de> (revised by arpi)
alex
parents: 8026
diff changeset
70 }
f8f3f8b4e0d7 DTS support by Peter Schuller <peterschueller@telemed.de> (revised by arpi)
alex
parents: 8026
diff changeset
71 break;
f8f3f8b4e0d7 DTS support by Peter Schuller <peterschueller@telemed.de> (revised by arpi)
alex
parents: 8026
diff changeset
72 }
f8f3f8b4e0d7 DTS support by Peter Schuller <peterschueller@telemed.de> (revised by arpi)
alex
parents: 8026
diff changeset
73 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
74 if(length >= 7 && length <= 3840)
f8f3f8b4e0d7 DTS support by Peter Schuller <peterschueller@telemed.de> (revised by arpi)
alex
parents: 8026
diff changeset
75 {
f8f3f8b4e0d7 DTS support by Peter Schuller <peterschueller@telemed.de> (revised by arpi)
alex
parents: 8026
diff changeset
76 if(isdts != 0)
f8f3f8b4e0d7 DTS support by Peter Schuller <peterschueller@telemed.de> (revised by arpi)
alex
parents: 8026
diff changeset
77 {
f8f3f8b4e0d7 DTS support by Peter Schuller <peterschueller@telemed.de> (revised by arpi)
alex
parents: 8026
diff changeset
78 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
79 isdts = 0;
f8f3f8b4e0d7 DTS support by Peter Schuller <peterschueller@telemed.de> (revised by arpi)
alex
parents: 8026
diff changeset
80 }
f8f3f8b4e0d7 DTS support by Peter Schuller <peterschueller@telemed.de> (revised by arpi)
alex
parents: 8026
diff changeset
81 break; /* we're done.*/
f8f3f8b4e0d7 DTS support by Peter Schuller <peterschueller@telemed.de> (revised by arpi)
alex
parents: 8026
diff changeset
82 }
f8f3f8b4e0d7 DTS support by Peter Schuller <peterschueller@telemed.de> (revised by arpi)
alex
parents: 8026
diff changeset
83 /* bad file => resync*/
f8f3f8b4e0d7 DTS support by Peter Schuller <peterschueller@telemed.de> (revised by arpi)
alex
parents: 8026
diff changeset
84 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
85 --sh_audio->a_in_buffer_len;
f8f3f8b4e0d7 DTS support by Peter Schuller <peterschueller@telemed.de> (revised by arpi)
alex
parents: 8026
diff changeset
86 }
f8f3f8b4e0d7 DTS support by Peter Schuller <peterschueller@telemed.de> (revised by arpi)
alex
parents: 8026
diff changeset
87 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
88
f8f3f8b4e0d7 DTS support by Peter Schuller <peterschueller@telemed.de> (revised by arpi)
alex
parents: 8026
diff changeset
89 sh_audio->samplerate = sample_rate;
f8f3f8b4e0d7 DTS support by Peter Schuller <peterschueller@telemed.de> (revised by arpi)
alex
parents: 8026
diff changeset
90 sh_audio->i_bps = bit_rate / 8;
f8f3f8b4e0d7 DTS support by Peter Schuller <peterschueller@telemed.de> (revised by arpi)
alex
parents: 8026
diff changeset
91 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
92 sh_audio->a_in_buffer_len = length;
f8f3f8b4e0d7 DTS support by Peter Schuller <peterschueller@telemed.de> (revised by arpi)
alex
parents: 8026
diff changeset
93
f8f3f8b4e0d7 DTS support by Peter Schuller <peterschueller@telemed.de> (revised by arpi)
alex
parents: 8026
diff changeset
94 // TODO: is DTS also checksummed?
f8f3f8b4e0d7 DTS support by Peter Schuller <peterschueller@telemed.de> (revised by arpi)
alex
parents: 8026
diff changeset
95 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
96 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
97
f8f3f8b4e0d7 DTS support by Peter Schuller <peterschueller@telemed.de> (revised by arpi)
alex
parents: 8026
diff changeset
98 return length;
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
f8f3f8b4e0d7 DTS support by Peter Schuller <peterschueller@telemed.de> (revised by arpi)
alex
parents: 8026
diff changeset
101
5340
0f12fb7c1c5d imported from MPlayerXP, dlopen() hack removed, some bugs fixed, interface functions changed to static, info->author field added
arpi
parents:
diff changeset
102 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
103 {
0f12fb7c1c5d imported from MPlayerXP, dlopen() hack removed, some bugs fixed, interface functions changed to static, info->author field added
arpi
parents:
diff changeset
104 /* Dolby AC3 audio: */
10012
f8f3f8b4e0d7 DTS support by Peter Schuller <peterschueller@telemed.de> (revised by arpi)
alex
parents: 8026
diff changeset
105 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
106 sh->audio_in_minsize = 8192;
f8f3f8b4e0d7 DTS support by Peter Schuller <peterschueller@telemed.de> (revised by arpi)
alex
parents: 8026
diff changeset
107 sh->channels = 2;
f8f3f8b4e0d7 DTS support by Peter Schuller <peterschueller@telemed.de> (revised by arpi)
alex
parents: 8026
diff changeset
108 sh->samplesize = 2;
14245
815f03b7cee5 removing AFMT_ dependancy
alex
parents: 14187
diff changeset
109 sh->sample_format = AF_FORMAT_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
110 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
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
0f12fb7c1c5d imported from MPlayerXP, dlopen() hack removed, some bugs fixed, interface functions changed to static, info->author field added
arpi
parents:
diff changeset
113 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
114 {
0f12fb7c1c5d imported from MPlayerXP, dlopen() hack removed, some bugs fixed, interface functions changed to static, info->author field added
arpi
parents:
diff changeset
115 /* Dolby AC3 passthrough:*/
18512
rathann
parents: 17012
diff changeset
116 a52_state_t *a52_state = a52_init(0);
rathann
parents: 17012
diff changeset
117 if(a52_state == NULL)
10012
f8f3f8b4e0d7 DTS support by Peter Schuller <peterschueller@telemed.de> (revised by arpi)
alex
parents: 8026
diff changeset
118 {
f8f3f8b4e0d7 DTS support by Peter Schuller <peterschueller@telemed.de> (revised by arpi)
alex
parents: 8026
diff changeset
119 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
120 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
121 }
10012
f8f3f8b4e0d7 DTS support by Peter Schuller <peterschueller@telemed.de> (revised by arpi)
alex
parents: 8026
diff changeset
122 if(ac3dts_fillbuff(sh_audio) < 0)
f8f3f8b4e0d7 DTS support by Peter Schuller <peterschueller@telemed.de> (revised by arpi)
alex
parents: 8026
diff changeset
123 {
f8f3f8b4e0d7 DTS support by Peter Schuller <peterschueller@telemed.de> (revised by arpi)
alex
parents: 8026
diff changeset
124 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
125 return 0;
f8f3f8b4e0d7 DTS support by Peter Schuller <peterschueller@telemed.de> (revised by arpi)
alex
parents: 8026
diff changeset
126 }
5340
0f12fb7c1c5d imported from MPlayerXP, dlopen() hack removed, some bugs fixed, interface functions changed to static, info->author field added
arpi
parents:
diff changeset
127 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
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
0f12fb7c1c5d imported from MPlayerXP, dlopen() hack removed, some bugs fixed, interface functions changed to static, info->author field added
arpi
parents:
diff changeset
130 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
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
0f12fb7c1c5d imported from MPlayerXP, dlopen() hack removed, some bugs fixed, interface functions changed to static, info->author field added
arpi
parents:
diff changeset
134 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
135 {
10012
f8f3f8b4e0d7 DTS support by Peter Schuller <peterschueller@telemed.de> (revised by arpi)
alex
parents: 8026
diff changeset
136 switch(cmd)
f8f3f8b4e0d7 DTS support by Peter Schuller <peterschueller@telemed.de> (revised by arpi)
alex
parents: 8026
diff changeset
137 {
15558
3aee7daaa8e5 Fix ADCTRL_SKIP_FRAME and add ADCTRL_RESYNC_STREAM
hzoli
parents: 14710
diff changeset
138 case ADCTRL_RESYNC_STREAM:
10012
f8f3f8b4e0d7 DTS support by Peter Schuller <peterschueller@telemed.de> (revised by arpi)
alex
parents: 8026
diff changeset
139 case ADCTRL_SKIP_FRAME:
15558
3aee7daaa8e5 Fix ADCTRL_SKIP_FRAME and add ADCTRL_RESYNC_STREAM
hzoli
parents: 14710
diff changeset
140 ac3dts_fillbuff(sh);
10012
f8f3f8b4e0d7 DTS support by Peter Schuller <peterschueller@telemed.de> (revised by arpi)
alex
parents: 8026
diff changeset
141 return CONTROL_TRUE;
f8f3f8b4e0d7 DTS support by Peter Schuller <peterschueller@telemed.de> (revised by arpi)
alex
parents: 8026
diff changeset
142 }
5340
0f12fb7c1c5d imported from MPlayerXP, dlopen() hack removed, some bugs fixed, interface functions changed to static, info->author field added
arpi
parents:
diff changeset
143 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
144 }
0f12fb7c1c5d imported from MPlayerXP, dlopen() hack removed, some bugs fixed, interface functions changed to static, info->author field added
arpi
parents:
diff changeset
145
10012
f8f3f8b4e0d7 DTS support by Peter Schuller <peterschueller@telemed.de> (revised by arpi)
alex
parents: 8026
diff changeset
146
5340
0f12fb7c1c5d imported from MPlayerXP, dlopen() hack removed, some bugs fixed, interface functions changed to static, info->author field added
arpi
parents:
diff changeset
147 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
148 {
10012
f8f3f8b4e0d7 DTS support by Peter Schuller <peterschueller@telemed.de> (revised by arpi)
alex
parents: 8026
diff changeset
149 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
150
f8f3f8b4e0d7 DTS support by Peter Schuller <peterschueller@telemed.de> (revised by arpi)
alex
parents: 8026
diff changeset
151 if(len <= 0)
f8f3f8b4e0d7 DTS support by Peter Schuller <peterschueller@telemed.de> (revised by arpi)
alex
parents: 8026
diff changeset
152 if((len = ac3dts_fillbuff(sh_audio)) <= 0)
f8f3f8b4e0d7 DTS support by Peter Schuller <peterschueller@telemed.de> (revised by arpi)
alex
parents: 8026
diff changeset
153 return len; /*EOF*/
f8f3f8b4e0d7 DTS support by Peter Schuller <peterschueller@telemed.de> (revised by arpi)
alex
parents: 8026
diff changeset
154 sh_audio->a_in_buffer_len = 0;
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 if(isdts == 1)
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 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
159 }
f8f3f8b4e0d7 DTS support by Peter Schuller <peterschueller@telemed.de> (revised by arpi)
alex
parents: 8026
diff changeset
160 else if(isdts == 0)
f8f3f8b4e0d7 DTS support by Peter Schuller <peterschueller@telemed.de> (revised by arpi)
alex
parents: 8026
diff changeset
161 {
f8f3f8b4e0d7 DTS support by Peter Schuller <peterschueller@telemed.de> (revised by arpi)
alex
parents: 8026
diff changeset
162 buf[0] = 0x72;
f8f3f8b4e0d7 DTS support by Peter Schuller <peterschueller@telemed.de> (revised by arpi)
alex
parents: 8026
diff changeset
163 buf[1] = 0xF8;
f8f3f8b4e0d7 DTS support by Peter Schuller <peterschueller@telemed.de> (revised by arpi)
alex
parents: 8026
diff changeset
164 buf[2] = 0x1F;
f8f3f8b4e0d7 DTS support by Peter Schuller <peterschueller@telemed.de> (revised by arpi)
alex
parents: 8026
diff changeset
165 buf[3] = 0x4E;
f8f3f8b4e0d7 DTS support by Peter Schuller <peterschueller@telemed.de> (revised by arpi)
alex
parents: 8026
diff changeset
166 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
167 buf[5] = 0x00;
f8f3f8b4e0d7 DTS support by Peter Schuller <peterschueller@telemed.de> (revised by arpi)
alex
parents: 8026
diff changeset
168 buf[6] = (len << 3) & 0xFF;
f8f3f8b4e0d7 DTS support by Peter Schuller <peterschueller@telemed.de> (revised by arpi)
alex
parents: 8026
diff changeset
169 buf[7] = (len >> 5) & 0xFF;
f8f3f8b4e0d7 DTS support by Peter Schuller <peterschueller@telemed.de> (revised by arpi)
alex
parents: 8026
diff changeset
170 #ifdef WORDS_BIGENDIAN
f8f3f8b4e0d7 DTS support by Peter Schuller <peterschueller@telemed.de> (revised by arpi)
alex
parents: 8026
diff changeset
171 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
172 #else
f8f3f8b4e0d7 DTS support by Peter Schuller <peterschueller@telemed.de> (revised by arpi)
alex
parents: 8026
diff changeset
173 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
174 #endif
f8f3f8b4e0d7 DTS support by Peter Schuller <peterschueller@telemed.de> (revised by arpi)
alex
parents: 8026
diff changeset
175 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
176
f8f3f8b4e0d7 DTS support by Peter Schuller <peterschueller@telemed.de> (revised by arpi)
alex
parents: 8026
diff changeset
177 return 6144;
f8f3f8b4e0d7 DTS support by Peter Schuller <peterschueller@telemed.de> (revised by arpi)
alex
parents: 8026
diff changeset
178 }
f8f3f8b4e0d7 DTS support by Peter Schuller <peterschueller@telemed.de> (revised by arpi)
alex
parents: 8026
diff changeset
179 else
f8f3f8b4e0d7 DTS support by Peter Schuller <peterschueller@telemed.de> (revised by arpi)
alex
parents: 8026
diff changeset
180 return -1;
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
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 static int DTS_SAMPLEFREQS[16] =
f8f3f8b4e0d7 DTS support by Peter Schuller <peterschueller@telemed.de> (revised by arpi)
alex
parents: 8026
diff changeset
185 {
f8f3f8b4e0d7 DTS support by Peter Schuller <peterschueller@telemed.de> (revised by arpi)
alex
parents: 8026
diff changeset
186 0,
f8f3f8b4e0d7 DTS support by Peter Schuller <peterschueller@telemed.de> (revised by arpi)
alex
parents: 8026
diff changeset
187 8000,
f8f3f8b4e0d7 DTS support by Peter Schuller <peterschueller@telemed.de> (revised by arpi)
alex
parents: 8026
diff changeset
188 16000,
f8f3f8b4e0d7 DTS support by Peter Schuller <peterschueller@telemed.de> (revised by arpi)
alex
parents: 8026
diff changeset
189 32000,
f8f3f8b4e0d7 DTS support by Peter Schuller <peterschueller@telemed.de> (revised by arpi)
alex
parents: 8026
diff changeset
190 64000,
f8f3f8b4e0d7 DTS support by Peter Schuller <peterschueller@telemed.de> (revised by arpi)
alex
parents: 8026
diff changeset
191 128000,
f8f3f8b4e0d7 DTS support by Peter Schuller <peterschueller@telemed.de> (revised by arpi)
alex
parents: 8026
diff changeset
192 11025,
f8f3f8b4e0d7 DTS support by Peter Schuller <peterschueller@telemed.de> (revised by arpi)
alex
parents: 8026
diff changeset
193 22050,
f8f3f8b4e0d7 DTS support by Peter Schuller <peterschueller@telemed.de> (revised by arpi)
alex
parents: 8026
diff changeset
194 44100,
f8f3f8b4e0d7 DTS support by Peter Schuller <peterschueller@telemed.de> (revised by arpi)
alex
parents: 8026
diff changeset
195 88200,
f8f3f8b4e0d7 DTS support by Peter Schuller <peterschueller@telemed.de> (revised by arpi)
alex
parents: 8026
diff changeset
196 176400,
f8f3f8b4e0d7 DTS support by Peter Schuller <peterschueller@telemed.de> (revised by arpi)
alex
parents: 8026
diff changeset
197 12000,
f8f3f8b4e0d7 DTS support by Peter Schuller <peterschueller@telemed.de> (revised by arpi)
alex
parents: 8026
diff changeset
198 24000,
f8f3f8b4e0d7 DTS support by Peter Schuller <peterschueller@telemed.de> (revised by arpi)
alex
parents: 8026
diff changeset
199 48000,
f8f3f8b4e0d7 DTS support by Peter Schuller <peterschueller@telemed.de> (revised by arpi)
alex
parents: 8026
diff changeset
200 96000,
f8f3f8b4e0d7 DTS support by Peter Schuller <peterschueller@telemed.de> (revised by arpi)
alex
parents: 8026
diff changeset
201 192000
f8f3f8b4e0d7 DTS support by Peter Schuller <peterschueller@telemed.de> (revised by arpi)
alex
parents: 8026
diff changeset
202 };
5370
bb1d63fea638 ac3_iec958_build_burst moved from ac3-iec958.c
arpi
parents: 5340
diff changeset
203
10012
f8f3f8b4e0d7 DTS support by Peter Schuller <peterschueller@telemed.de> (revised by arpi)
alex
parents: 8026
diff changeset
204 static int DTS_BITRATES[30] =
f8f3f8b4e0d7 DTS support by Peter Schuller <peterschueller@telemed.de> (revised by arpi)
alex
parents: 8026
diff changeset
205 {
f8f3f8b4e0d7 DTS support by Peter Schuller <peterschueller@telemed.de> (revised by arpi)
alex
parents: 8026
diff changeset
206 32000,
f8f3f8b4e0d7 DTS support by Peter Schuller <peterschueller@telemed.de> (revised by arpi)
alex
parents: 8026
diff changeset
207 56000,
f8f3f8b4e0d7 DTS support by Peter Schuller <peterschueller@telemed.de> (revised by arpi)
alex
parents: 8026
diff changeset
208 64000,
f8f3f8b4e0d7 DTS support by Peter Schuller <peterschueller@telemed.de> (revised by arpi)
alex
parents: 8026
diff changeset
209 96000,
f8f3f8b4e0d7 DTS support by Peter Schuller <peterschueller@telemed.de> (revised by arpi)
alex
parents: 8026
diff changeset
210 112000,
f8f3f8b4e0d7 DTS support by Peter Schuller <peterschueller@telemed.de> (revised by arpi)
alex
parents: 8026
diff changeset
211 128000,
f8f3f8b4e0d7 DTS support by Peter Schuller <peterschueller@telemed.de> (revised by arpi)
alex
parents: 8026
diff changeset
212 192000,
f8f3f8b4e0d7 DTS support by Peter Schuller <peterschueller@telemed.de> (revised by arpi)
alex
parents: 8026
diff changeset
213 224000,
f8f3f8b4e0d7 DTS support by Peter Schuller <peterschueller@telemed.de> (revised by arpi)
alex
parents: 8026
diff changeset
214 256000,
f8f3f8b4e0d7 DTS support by Peter Schuller <peterschueller@telemed.de> (revised by arpi)
alex
parents: 8026
diff changeset
215 320000,
f8f3f8b4e0d7 DTS support by Peter Schuller <peterschueller@telemed.de> (revised by arpi)
alex
parents: 8026
diff changeset
216 384000,
f8f3f8b4e0d7 DTS support by Peter Schuller <peterschueller@telemed.de> (revised by arpi)
alex
parents: 8026
diff changeset
217 448000,
f8f3f8b4e0d7 DTS support by Peter Schuller <peterschueller@telemed.de> (revised by arpi)
alex
parents: 8026
diff changeset
218 512000,
f8f3f8b4e0d7 DTS support by Peter Schuller <peterschueller@telemed.de> (revised by arpi)
alex
parents: 8026
diff changeset
219 576000,
f8f3f8b4e0d7 DTS support by Peter Schuller <peterschueller@telemed.de> (revised by arpi)
alex
parents: 8026
diff changeset
220 640000,
f8f3f8b4e0d7 DTS support by Peter Schuller <peterschueller@telemed.de> (revised by arpi)
alex
parents: 8026
diff changeset
221 768000,
f8f3f8b4e0d7 DTS support by Peter Schuller <peterschueller@telemed.de> (revised by arpi)
alex
parents: 8026
diff changeset
222 896000,
f8f3f8b4e0d7 DTS support by Peter Schuller <peterschueller@telemed.de> (revised by arpi)
alex
parents: 8026
diff changeset
223 1024000,
f8f3f8b4e0d7 DTS support by Peter Schuller <peterschueller@telemed.de> (revised by arpi)
alex
parents: 8026
diff changeset
224 1152000,
f8f3f8b4e0d7 DTS support by Peter Schuller <peterschueller@telemed.de> (revised by arpi)
alex
parents: 8026
diff changeset
225 1280000,
f8f3f8b4e0d7 DTS support by Peter Schuller <peterschueller@telemed.de> (revised by arpi)
alex
parents: 8026
diff changeset
226 1344000,
f8f3f8b4e0d7 DTS support by Peter Schuller <peterschueller@telemed.de> (revised by arpi)
alex
parents: 8026
diff changeset
227 1408000,
f8f3f8b4e0d7 DTS support by Peter Schuller <peterschueller@telemed.de> (revised by arpi)
alex
parents: 8026
diff changeset
228 1411200,
f8f3f8b4e0d7 DTS support by Peter Schuller <peterschueller@telemed.de> (revised by arpi)
alex
parents: 8026
diff changeset
229 1472000,
f8f3f8b4e0d7 DTS support by Peter Schuller <peterschueller@telemed.de> (revised by arpi)
alex
parents: 8026
diff changeset
230 1536000,
f8f3f8b4e0d7 DTS support by Peter Schuller <peterschueller@telemed.de> (revised by arpi)
alex
parents: 8026
diff changeset
231 1920000,
f8f3f8b4e0d7 DTS support by Peter Schuller <peterschueller@telemed.de> (revised by arpi)
alex
parents: 8026
diff changeset
232 2048000,
f8f3f8b4e0d7 DTS support by Peter Schuller <peterschueller@telemed.de> (revised by arpi)
alex
parents: 8026
diff changeset
233 3072000,
f8f3f8b4e0d7 DTS support by Peter Schuller <peterschueller@telemed.de> (revised by arpi)
alex
parents: 8026
diff changeset
234 3840000,
f8f3f8b4e0d7 DTS support by Peter Schuller <peterschueller@telemed.de> (revised by arpi)
alex
parents: 8026
diff changeset
235 4096000
f8f3f8b4e0d7 DTS support by Peter Schuller <peterschueller@telemed.de> (revised by arpi)
alex
parents: 8026
diff changeset
236 };
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 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
239 {
f8f3f8b4e0d7 DTS support by Peter Schuller <peterschueller@telemed.de> (revised by arpi)
alex
parents: 8026
diff changeset
240 int ftype;
f8f3f8b4e0d7 DTS support by Peter Schuller <peterschueller@telemed.de> (revised by arpi)
alex
parents: 8026
diff changeset
241 int surp;
f8f3f8b4e0d7 DTS support by Peter Schuller <peterschueller@telemed.de> (revised by arpi)
alex
parents: 8026
diff changeset
242 int unknown_bit;
f8f3f8b4e0d7 DTS support by Peter Schuller <peterschueller@telemed.de> (revised by arpi)
alex
parents: 8026
diff changeset
243 int fsize;
f8f3f8b4e0d7 DTS support by Peter Schuller <peterschueller@telemed.de> (revised by arpi)
alex
parents: 8026
diff changeset
244 int amode;
f8f3f8b4e0d7 DTS support by Peter Schuller <peterschueller@telemed.de> (revised by arpi)
alex
parents: 8026
diff changeset
245
f8f3f8b4e0d7 DTS support by Peter Schuller <peterschueller@telemed.de> (revised by arpi)
alex
parents: 8026
diff changeset
246 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
247 | (indata_ptr[3])) != 0x7ffe8001)
f8f3f8b4e0d7 DTS support by Peter Schuller <peterschueller@telemed.de> (revised by arpi)
alex
parents: 8026
diff changeset
248 return -1;
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 ftype = indata_ptr[4] >> 7;
f8f3f8b4e0d7 DTS support by Peter Schuller <peterschueller@telemed.de> (revised by arpi)
alex
parents: 8026
diff changeset
251
f8f3f8b4e0d7 DTS support by Peter Schuller <peterschueller@telemed.de> (revised by arpi)
alex
parents: 8026
diff changeset
252 surp = (indata_ptr[4] >> 2) & 0x1f;
f8f3f8b4e0d7 DTS support by Peter Schuller <peterschueller@telemed.de> (revised by arpi)
alex
parents: 8026
diff changeset
253 surp = (surp + 1) % 32;
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 unknown_bit = (indata_ptr[4] >> 1) & 0x01;
f8f3f8b4e0d7 DTS support by Peter Schuller <peterschueller@telemed.de> (revised by arpi)
alex
parents: 8026
diff changeset
256
f8f3f8b4e0d7 DTS support by Peter Schuller <peterschueller@telemed.de> (revised by arpi)
alex
parents: 8026
diff changeset
257 *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
258 *nblks = *nblks + 1;
5370
bb1d63fea638 ac3_iec958_build_burst moved from ac3-iec958.c
arpi
parents: 5340
diff changeset
259
10012
f8f3f8b4e0d7 DTS support by Peter Schuller <peterschueller@telemed.de> (revised by arpi)
alex
parents: 8026
diff changeset
260 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
261 fsize = fsize + 1;
f8f3f8b4e0d7 DTS support by Peter Schuller <peterschueller@telemed.de> (revised by arpi)
alex
parents: 8026
diff changeset
262
f8f3f8b4e0d7 DTS support by Peter Schuller <peterschueller@telemed.de> (revised by arpi)
alex
parents: 8026
diff changeset
263 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
264 *sfreq = (indata_ptr[8] >> 2) & 0x0f;
f8f3f8b4e0d7 DTS support by Peter Schuller <peterschueller@telemed.de> (revised by arpi)
alex
parents: 8026
diff changeset
265 *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
266
f8f3f8b4e0d7 DTS support by Peter Schuller <peterschueller@telemed.de> (revised by arpi)
alex
parents: 8026
diff changeset
267 if(ftype != 1)
f8f3f8b4e0d7 DTS support by Peter Schuller <peterschueller@telemed.de> (revised by arpi)
alex
parents: 8026
diff changeset
268 {
f8f3f8b4e0d7 DTS support by Peter Schuller <peterschueller@telemed.de> (revised by arpi)
alex
parents: 8026
diff changeset
269 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
270 return -1;
f8f3f8b4e0d7 DTS support by Peter Schuller <peterschueller@telemed.de> (revised by arpi)
alex
parents: 8026
diff changeset
271 }
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 if(*sfreq != 13)
f8f3f8b4e0d7 DTS support by Peter Schuller <peterschueller@telemed.de> (revised by arpi)
alex
parents: 8026
diff changeset
274 {
f8f3f8b4e0d7 DTS support by Peter Schuller <peterschueller@telemed.de> (revised by arpi)
alex
parents: 8026
diff changeset
275 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
276 return -1;
f8f3f8b4e0d7 DTS support by Peter Schuller <peterschueller@telemed.de> (revised by arpi)
alex
parents: 8026
diff changeset
277 }
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 if((fsize > 8192) || (fsize < 96))
f8f3f8b4e0d7 DTS support by Peter Schuller <peterschueller@telemed.de> (revised by arpi)
alex
parents: 8026
diff changeset
280 {
f8f3f8b4e0d7 DTS support by Peter Schuller <peterschueller@telemed.de> (revised by arpi)
alex
parents: 8026
diff changeset
281 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
282 return -1;
f8f3f8b4e0d7 DTS support by Peter Schuller <peterschueller@telemed.de> (revised by arpi)
alex
parents: 8026
diff changeset
283 }
f8f3f8b4e0d7 DTS support by Peter Schuller <peterschueller@telemed.de> (revised by arpi)
alex
parents: 8026
diff changeset
284
f8f3f8b4e0d7 DTS support by Peter Schuller <peterschueller@telemed.de> (revised by arpi)
alex
parents: 8026
diff changeset
285 if(*nblks != 8 &&
f8f3f8b4e0d7 DTS support by Peter Schuller <peterschueller@telemed.de> (revised by arpi)
alex
parents: 8026
diff changeset
286 *nblks != 16 &&
f8f3f8b4e0d7 DTS support by Peter Schuller <peterschueller@telemed.de> (revised by arpi)
alex
parents: 8026
diff changeset
287 *nblks != 32 &&
f8f3f8b4e0d7 DTS support by Peter Schuller <peterschueller@telemed.de> (revised by arpi)
alex
parents: 8026
diff changeset
288 *nblks != 64 &&
f8f3f8b4e0d7 DTS support by Peter Schuller <peterschueller@telemed.de> (revised by arpi)
alex
parents: 8026
diff changeset
289 *nblks != 128 &&
f8f3f8b4e0d7 DTS support by Peter Schuller <peterschueller@telemed.de> (revised by arpi)
alex
parents: 8026
diff changeset
290 ftype == 1)
f8f3f8b4e0d7 DTS support by Peter Schuller <peterschueller@telemed.de> (revised by arpi)
alex
parents: 8026
diff changeset
291 {
10948
aebf939834c3 10l found by Dominik 'Rathann' Mierzejewski <dominik@rangers.eu.org>
alex
parents: 10012
diff changeset
292 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
293 return -1;
f8f3f8b4e0d7 DTS support by Peter Schuller <peterschueller@telemed.de> (revised by arpi)
alex
parents: 8026
diff changeset
294 }
f8f3f8b4e0d7 DTS support by Peter Schuller <peterschueller@telemed.de> (revised by arpi)
alex
parents: 8026
diff changeset
295
f8f3f8b4e0d7 DTS support by Peter Schuller <peterschueller@telemed.de> (revised by arpi)
alex
parents: 8026
diff changeset
296 return fsize;
f8f3f8b4e0d7 DTS support by Peter Schuller <peterschueller@telemed.de> (revised by arpi)
alex
parents: 8026
diff changeset
297 }
5370
bb1d63fea638 ac3_iec958_build_burst moved from ac3-iec958.c
arpi
parents: 5340
diff changeset
298
10012
f8f3f8b4e0d7 DTS support by Peter Schuller <peterschueller@telemed.de> (revised by arpi)
alex
parents: 8026
diff changeset
299 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
300 {
f8f3f8b4e0d7 DTS support by Peter Schuller <peterschueller@telemed.de> (revised by arpi)
alex
parents: 8026
diff changeset
301 int nblks;
f8f3f8b4e0d7 DTS support by Peter Schuller <peterschueller@telemed.de> (revised by arpi)
alex
parents: 8026
diff changeset
302 int fsize;
f8f3f8b4e0d7 DTS support by Peter Schuller <peterschueller@telemed.de> (revised by arpi)
alex
parents: 8026
diff changeset
303 int rate;
f8f3f8b4e0d7 DTS support by Peter Schuller <peterschueller@telemed.de> (revised by arpi)
alex
parents: 8026
diff changeset
304 int sfreq;
f8f3f8b4e0d7 DTS support by Peter Schuller <peterschueller@telemed.de> (revised by arpi)
alex
parents: 8026
diff changeset
305
f8f3f8b4e0d7 DTS support by Peter Schuller <peterschueller@telemed.de> (revised by arpi)
alex
parents: 8026
diff changeset
306 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
307 if(fsize >= 0)
f8f3f8b4e0d7 DTS support by Peter Schuller <peterschueller@telemed.de> (revised by arpi)
alex
parents: 8026
diff changeset
308 {
f8f3f8b4e0d7 DTS support by Peter Schuller <peterschueller@telemed.de> (revised by arpi)
alex
parents: 8026
diff changeset
309 if(rate >= 0 && rate <= 29)
f8f3f8b4e0d7 DTS support by Peter Schuller <peterschueller@telemed.de> (revised by arpi)
alex
parents: 8026
diff changeset
310 *bit_rate = DTS_BITRATES[rate];
f8f3f8b4e0d7 DTS support by Peter Schuller <peterschueller@telemed.de> (revised by arpi)
alex
parents: 8026
diff changeset
311 else
f8f3f8b4e0d7 DTS support by Peter Schuller <peterschueller@telemed.de> (revised by arpi)
alex
parents: 8026
diff changeset
312 *bit_rate = 0;
f8f3f8b4e0d7 DTS support by Peter Schuller <peterschueller@telemed.de> (revised by arpi)
alex
parents: 8026
diff changeset
313 if(sfreq >= 1 && sfreq <= 15)
f8f3f8b4e0d7 DTS support by Peter Schuller <peterschueller@telemed.de> (revised by arpi)
alex
parents: 8026
diff changeset
314 *sample_rate = DTS_SAMPLEFREQS[sfreq];
f8f3f8b4e0d7 DTS support by Peter Schuller <peterschueller@telemed.de> (revised by arpi)
alex
parents: 8026
diff changeset
315 else
f8f3f8b4e0d7 DTS support by Peter Schuller <peterschueller@telemed.de> (revised by arpi)
alex
parents: 8026
diff changeset
316 *sample_rate = 0;
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 return fsize;
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
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 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
323 {
f8f3f8b4e0d7 DTS support by Peter Schuller <peterschueller@telemed.de> (revised by arpi)
alex
parents: 8026
diff changeset
324 int nblks;
f8f3f8b4e0d7 DTS support by Peter Schuller <peterschueller@telemed.de> (revised by arpi)
alex
parents: 8026
diff changeset
325 int fsize;
f8f3f8b4e0d7 DTS support by Peter Schuller <peterschueller@telemed.de> (revised by arpi)
alex
parents: 8026
diff changeset
326 int rate;
f8f3f8b4e0d7 DTS support by Peter Schuller <peterschueller@telemed.de> (revised by arpi)
alex
parents: 8026
diff changeset
327 int sfreq;
f8f3f8b4e0d7 DTS support by Peter Schuller <peterschueller@telemed.de> (revised by arpi)
alex
parents: 8026
diff changeset
328 int burst_len;
f8f3f8b4e0d7 DTS support by Peter Schuller <peterschueller@telemed.de> (revised by arpi)
alex
parents: 8026
diff changeset
329 int nr_samples;
f8f3f8b4e0d7 DTS support by Peter Schuller <peterschueller@telemed.de> (revised by arpi)
alex
parents: 8026
diff changeset
330
f8f3f8b4e0d7 DTS support by Peter Schuller <peterschueller@telemed.de> (revised by arpi)
alex
parents: 8026
diff changeset
331 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
332 if(fsize < 0)
f8f3f8b4e0d7 DTS support by Peter Schuller <peterschueller@telemed.de> (revised by arpi)
alex
parents: 8026
diff changeset
333 return -1;
f8f3f8b4e0d7 DTS support by Peter Schuller <peterschueller@telemed.de> (revised by arpi)
alex
parents: 8026
diff changeset
334
f8f3f8b4e0d7 DTS support by Peter Schuller <peterschueller@telemed.de> (revised by arpi)
alex
parents: 8026
diff changeset
335 burst_len = fsize * 8;
f8f3f8b4e0d7 DTS support by Peter Schuller <peterschueller@telemed.de> (revised by arpi)
alex
parents: 8026
diff changeset
336 nr_samples = nblks * 32;
f8f3f8b4e0d7 DTS support by Peter Schuller <peterschueller@telemed.de> (revised by arpi)
alex
parents: 8026
diff changeset
337
f8f3f8b4e0d7 DTS support by Peter Schuller <peterschueller@telemed.de> (revised by arpi)
alex
parents: 8026
diff changeset
338 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
339 buf[2] = 0x1f; buf[3] = 0x4e; /* syncword */
f8f3f8b4e0d7 DTS support by Peter Schuller <peterschueller@telemed.de> (revised by arpi)
alex
parents: 8026
diff changeset
340 switch(nr_samples)
f8f3f8b4e0d7 DTS support by Peter Schuller <peterschueller@telemed.de> (revised by arpi)
alex
parents: 8026
diff changeset
341 {
f8f3f8b4e0d7 DTS support by Peter Schuller <peterschueller@telemed.de> (revised by arpi)
alex
parents: 8026
diff changeset
342 case 512:
f8f3f8b4e0d7 DTS support by Peter Schuller <peterschueller@telemed.de> (revised by arpi)
alex
parents: 8026
diff changeset
343 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
344 break;
f8f3f8b4e0d7 DTS support by Peter Schuller <peterschueller@telemed.de> (revised by arpi)
alex
parents: 8026
diff changeset
345 case 1024:
f8f3f8b4e0d7 DTS support by Peter Schuller <peterschueller@telemed.de> (revised by arpi)
alex
parents: 8026
diff changeset
346 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
347 break;
f8f3f8b4e0d7 DTS support by Peter Schuller <peterschueller@telemed.de> (revised by arpi)
alex
parents: 8026
diff changeset
348 case 2048:
f8f3f8b4e0d7 DTS support by Peter Schuller <peterschueller@telemed.de> (revised by arpi)
alex
parents: 8026
diff changeset
349 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
350 break;
f8f3f8b4e0d7 DTS support by Peter Schuller <peterschueller@telemed.de> (revised by arpi)
alex
parents: 8026
diff changeset
351 default:
f8f3f8b4e0d7 DTS support by Peter Schuller <peterschueller@telemed.de> (revised by arpi)
alex
parents: 8026
diff changeset
352 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
353 buf[4] = 0x00;
f8f3f8b4e0d7 DTS support by Peter Schuller <peterschueller@telemed.de> (revised by arpi)
alex
parents: 8026
diff changeset
354 break;
f8f3f8b4e0d7 DTS support by Peter Schuller <peterschueller@telemed.de> (revised by arpi)
alex
parents: 8026
diff changeset
355 }
f8f3f8b4e0d7 DTS support by Peter Schuller <peterschueller@telemed.de> (revised by arpi)
alex
parents: 8026
diff changeset
356 buf[5] = 0; /* ?? */
f8f3f8b4e0d7 DTS support by Peter Schuller <peterschueller@telemed.de> (revised by arpi)
alex
parents: 8026
diff changeset
357 buf[6] = (burst_len) & 0xff;
f8f3f8b4e0d7 DTS support by Peter Schuller <peterschueller@telemed.de> (revised by arpi)
alex
parents: 8026
diff changeset
358 buf[7] = (burst_len >> 8) & 0xff;
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 if(fsize + 8 > nr_samples * 2 * 2)
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 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
363 }
f8f3f8b4e0d7 DTS support by Peter Schuller <peterschueller@telemed.de> (revised by arpi)
alex
parents: 8026
diff changeset
364 #ifdef WORDS_BIGENDIAN
f8f3f8b4e0d7 DTS support by Peter Schuller <peterschueller@telemed.de> (revised by arpi)
alex
parents: 8026
diff changeset
365 memcpy(&buf[8], indata_ptr, fsize); // untested
f8f3f8b4e0d7 DTS support by Peter Schuller <peterschueller@telemed.de> (revised by arpi)
alex
parents: 8026
diff changeset
366 #else
f8f3f8b4e0d7 DTS support by Peter Schuller <peterschueller@telemed.de> (revised by arpi)
alex
parents: 8026
diff changeset
367 //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
368 swab(indata_ptr, &buf[8], fsize);
14187
19589e978000 10l fix I hope, reverse if not
alex
parents: 10948
diff changeset
369 if (fsize & 1)
19589e978000 10l fix I hope, reverse if not
alex
parents: 10948
diff changeset
370 buf[8+fsize] = indata_ptr[fsize];
10012
f8f3f8b4e0d7 DTS support by Peter Schuller <peterschueller@telemed.de> (revised by arpi)
alex
parents: 8026
diff changeset
371 #endif
f8f3f8b4e0d7 DTS support by Peter Schuller <peterschueller@telemed.de> (revised by arpi)
alex
parents: 8026
diff changeset
372 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
373
f8f3f8b4e0d7 DTS support by Peter Schuller <peterschueller@telemed.de> (revised by arpi)
alex
parents: 8026
diff changeset
374 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
375 }
8026
b465ba5897a3 usage of libmpeg2, liba52, mp3lib & svq1 can be disabled
arpi
parents: 7405
diff changeset
376 #endif