Mercurial > mplayer.hg
annotate libmpcodecs/ad_hwac3.c @ 24432:79fcacd73f9b
Simplify and fix big-endian hwac3 header generation code.
author | reimar |
---|---|
date | Fri, 14 Sep 2007 08:54:06 +0000 |
parents | acfe034e5386 |
children | 435b37266f1e |
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" |
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 | 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 | 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 | 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 | 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 | 116 a52_state_t *a52_state = a52_init(0); |
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 | 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 | 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 { |
24432
79fcacd73f9b
Simplify and fix big-endian hwac3 header generation code.
reimar
parents:
23734
diff
changeset
|
162 uint16_t *buf16 = (uint16_t *)buf; |
79fcacd73f9b
Simplify and fix big-endian hwac3 header generation code.
reimar
parents:
23734
diff
changeset
|
163 buf16[0] = 0xF872; |
79fcacd73f9b
Simplify and fix big-endian hwac3 header generation code.
reimar
parents:
23734
diff
changeset
|
164 buf16[1] = 0x4E1F; |
79fcacd73f9b
Simplify and fix big-endian hwac3 header generation code.
reimar
parents:
23734
diff
changeset
|
165 buf16[2] = 0x0001; |
79fcacd73f9b
Simplify and fix big-endian hwac3 header generation code.
reimar
parents:
23734
diff
changeset
|
166 buf16[3] = len << 3; |
10012
f8f3f8b4e0d7
DTS support by Peter Schuller <peterschueller@telemed.de> (revised by arpi)
alex
parents:
8026
diff
changeset
|
167 #ifdef WORDS_BIGENDIAN |
f8f3f8b4e0d7
DTS support by Peter Schuller <peterschueller@telemed.de> (revised by arpi)
alex
parents:
8026
diff
changeset
|
168 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
|
169 #else |
f8f3f8b4e0d7
DTS support by Peter Schuller <peterschueller@telemed.de> (revised by arpi)
alex
parents:
8026
diff
changeset
|
170 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
|
171 #endif |
f8f3f8b4e0d7
DTS support by Peter Schuller <peterschueller@telemed.de> (revised by arpi)
alex
parents:
8026
diff
changeset
|
172 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
|
173 |
f8f3f8b4e0d7
DTS support by Peter Schuller <peterschueller@telemed.de> (revised by arpi)
alex
parents:
8026
diff
changeset
|
174 return 6144; |
f8f3f8b4e0d7
DTS support by Peter Schuller <peterschueller@telemed.de> (revised by arpi)
alex
parents:
8026
diff
changeset
|
175 } |
f8f3f8b4e0d7
DTS support by Peter Schuller <peterschueller@telemed.de> (revised by arpi)
alex
parents:
8026
diff
changeset
|
176 else |
f8f3f8b4e0d7
DTS support by Peter Schuller <peterschueller@telemed.de> (revised by arpi)
alex
parents:
8026
diff
changeset
|
177 return -1; |
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 |
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 static int DTS_SAMPLEFREQS[16] = |
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 0, |
f8f3f8b4e0d7
DTS support by Peter Schuller <peterschueller@telemed.de> (revised by arpi)
alex
parents:
8026
diff
changeset
|
184 8000, |
f8f3f8b4e0d7
DTS support by Peter Schuller <peterschueller@telemed.de> (revised by arpi)
alex
parents:
8026
diff
changeset
|
185 16000, |
f8f3f8b4e0d7
DTS support by Peter Schuller <peterschueller@telemed.de> (revised by arpi)
alex
parents:
8026
diff
changeset
|
186 32000, |
f8f3f8b4e0d7
DTS support by Peter Schuller <peterschueller@telemed.de> (revised by arpi)
alex
parents:
8026
diff
changeset
|
187 64000, |
f8f3f8b4e0d7
DTS support by Peter Schuller <peterschueller@telemed.de> (revised by arpi)
alex
parents:
8026
diff
changeset
|
188 128000, |
f8f3f8b4e0d7
DTS support by Peter Schuller <peterschueller@telemed.de> (revised by arpi)
alex
parents:
8026
diff
changeset
|
189 11025, |
f8f3f8b4e0d7
DTS support by Peter Schuller <peterschueller@telemed.de> (revised by arpi)
alex
parents:
8026
diff
changeset
|
190 22050, |
f8f3f8b4e0d7
DTS support by Peter Schuller <peterschueller@telemed.de> (revised by arpi)
alex
parents:
8026
diff
changeset
|
191 44100, |
f8f3f8b4e0d7
DTS support by Peter Schuller <peterschueller@telemed.de> (revised by arpi)
alex
parents:
8026
diff
changeset
|
192 88200, |
f8f3f8b4e0d7
DTS support by Peter Schuller <peterschueller@telemed.de> (revised by arpi)
alex
parents:
8026
diff
changeset
|
193 176400, |
f8f3f8b4e0d7
DTS support by Peter Schuller <peterschueller@telemed.de> (revised by arpi)
alex
parents:
8026
diff
changeset
|
194 12000, |
f8f3f8b4e0d7
DTS support by Peter Schuller <peterschueller@telemed.de> (revised by arpi)
alex
parents:
8026
diff
changeset
|
195 24000, |
f8f3f8b4e0d7
DTS support by Peter Schuller <peterschueller@telemed.de> (revised by arpi)
alex
parents:
8026
diff
changeset
|
196 48000, |
f8f3f8b4e0d7
DTS support by Peter Schuller <peterschueller@telemed.de> (revised by arpi)
alex
parents:
8026
diff
changeset
|
197 96000, |
f8f3f8b4e0d7
DTS support by Peter Schuller <peterschueller@telemed.de> (revised by arpi)
alex
parents:
8026
diff
changeset
|
198 192000 |
f8f3f8b4e0d7
DTS support by Peter Schuller <peterschueller@telemed.de> (revised by arpi)
alex
parents:
8026
diff
changeset
|
199 }; |
5370 | 200 |
10012
f8f3f8b4e0d7
DTS support by Peter Schuller <peterschueller@telemed.de> (revised by arpi)
alex
parents:
8026
diff
changeset
|
201 static int DTS_BITRATES[30] = |
f8f3f8b4e0d7
DTS support by Peter Schuller <peterschueller@telemed.de> (revised by arpi)
alex
parents:
8026
diff
changeset
|
202 { |
f8f3f8b4e0d7
DTS support by Peter Schuller <peterschueller@telemed.de> (revised by arpi)
alex
parents:
8026
diff
changeset
|
203 32000, |
f8f3f8b4e0d7
DTS support by Peter Schuller <peterschueller@telemed.de> (revised by arpi)
alex
parents:
8026
diff
changeset
|
204 56000, |
f8f3f8b4e0d7
DTS support by Peter Schuller <peterschueller@telemed.de> (revised by arpi)
alex
parents:
8026
diff
changeset
|
205 64000, |
f8f3f8b4e0d7
DTS support by Peter Schuller <peterschueller@telemed.de> (revised by arpi)
alex
parents:
8026
diff
changeset
|
206 96000, |
f8f3f8b4e0d7
DTS support by Peter Schuller <peterschueller@telemed.de> (revised by arpi)
alex
parents:
8026
diff
changeset
|
207 112000, |
f8f3f8b4e0d7
DTS support by Peter Schuller <peterschueller@telemed.de> (revised by arpi)
alex
parents:
8026
diff
changeset
|
208 128000, |
f8f3f8b4e0d7
DTS support by Peter Schuller <peterschueller@telemed.de> (revised by arpi)
alex
parents:
8026
diff
changeset
|
209 192000, |
f8f3f8b4e0d7
DTS support by Peter Schuller <peterschueller@telemed.de> (revised by arpi)
alex
parents:
8026
diff
changeset
|
210 224000, |
f8f3f8b4e0d7
DTS support by Peter Schuller <peterschueller@telemed.de> (revised by arpi)
alex
parents:
8026
diff
changeset
|
211 256000, |
f8f3f8b4e0d7
DTS support by Peter Schuller <peterschueller@telemed.de> (revised by arpi)
alex
parents:
8026
diff
changeset
|
212 320000, |
f8f3f8b4e0d7
DTS support by Peter Schuller <peterschueller@telemed.de> (revised by arpi)
alex
parents:
8026
diff
changeset
|
213 384000, |
f8f3f8b4e0d7
DTS support by Peter Schuller <peterschueller@telemed.de> (revised by arpi)
alex
parents:
8026
diff
changeset
|
214 448000, |
f8f3f8b4e0d7
DTS support by Peter Schuller <peterschueller@telemed.de> (revised by arpi)
alex
parents:
8026
diff
changeset
|
215 512000, |
f8f3f8b4e0d7
DTS support by Peter Schuller <peterschueller@telemed.de> (revised by arpi)
alex
parents:
8026
diff
changeset
|
216 576000, |
f8f3f8b4e0d7
DTS support by Peter Schuller <peterschueller@telemed.de> (revised by arpi)
alex
parents:
8026
diff
changeset
|
217 640000, |
f8f3f8b4e0d7
DTS support by Peter Schuller <peterschueller@telemed.de> (revised by arpi)
alex
parents:
8026
diff
changeset
|
218 768000, |
f8f3f8b4e0d7
DTS support by Peter Schuller <peterschueller@telemed.de> (revised by arpi)
alex
parents:
8026
diff
changeset
|
219 896000, |
f8f3f8b4e0d7
DTS support by Peter Schuller <peterschueller@telemed.de> (revised by arpi)
alex
parents:
8026
diff
changeset
|
220 1024000, |
f8f3f8b4e0d7
DTS support by Peter Schuller <peterschueller@telemed.de> (revised by arpi)
alex
parents:
8026
diff
changeset
|
221 1152000, |
f8f3f8b4e0d7
DTS support by Peter Schuller <peterschueller@telemed.de> (revised by arpi)
alex
parents:
8026
diff
changeset
|
222 1280000, |
f8f3f8b4e0d7
DTS support by Peter Schuller <peterschueller@telemed.de> (revised by arpi)
alex
parents:
8026
diff
changeset
|
223 1344000, |
f8f3f8b4e0d7
DTS support by Peter Schuller <peterschueller@telemed.de> (revised by arpi)
alex
parents:
8026
diff
changeset
|
224 1408000, |
f8f3f8b4e0d7
DTS support by Peter Schuller <peterschueller@telemed.de> (revised by arpi)
alex
parents:
8026
diff
changeset
|
225 1411200, |
f8f3f8b4e0d7
DTS support by Peter Schuller <peterschueller@telemed.de> (revised by arpi)
alex
parents:
8026
diff
changeset
|
226 1472000, |
f8f3f8b4e0d7
DTS support by Peter Schuller <peterschueller@telemed.de> (revised by arpi)
alex
parents:
8026
diff
changeset
|
227 1536000, |
f8f3f8b4e0d7
DTS support by Peter Schuller <peterschueller@telemed.de> (revised by arpi)
alex
parents:
8026
diff
changeset
|
228 1920000, |
f8f3f8b4e0d7
DTS support by Peter Schuller <peterschueller@telemed.de> (revised by arpi)
alex
parents:
8026
diff
changeset
|
229 2048000, |
f8f3f8b4e0d7
DTS support by Peter Schuller <peterschueller@telemed.de> (revised by arpi)
alex
parents:
8026
diff
changeset
|
230 3072000, |
f8f3f8b4e0d7
DTS support by Peter Schuller <peterschueller@telemed.de> (revised by arpi)
alex
parents:
8026
diff
changeset
|
231 3840000, |
f8f3f8b4e0d7
DTS support by Peter Schuller <peterschueller@telemed.de> (revised by arpi)
alex
parents:
8026
diff
changeset
|
232 4096000 |
f8f3f8b4e0d7
DTS support by Peter Schuller <peterschueller@telemed.de> (revised by arpi)
alex
parents:
8026
diff
changeset
|
233 }; |
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 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
|
236 { |
f8f3f8b4e0d7
DTS support by Peter Schuller <peterschueller@telemed.de> (revised by arpi)
alex
parents:
8026
diff
changeset
|
237 int ftype; |
f8f3f8b4e0d7
DTS support by Peter Schuller <peterschueller@telemed.de> (revised by arpi)
alex
parents:
8026
diff
changeset
|
238 int surp; |
f8f3f8b4e0d7
DTS support by Peter Schuller <peterschueller@telemed.de> (revised by arpi)
alex
parents:
8026
diff
changeset
|
239 int unknown_bit; |
f8f3f8b4e0d7
DTS support by Peter Schuller <peterschueller@telemed.de> (revised by arpi)
alex
parents:
8026
diff
changeset
|
240 int fsize; |
f8f3f8b4e0d7
DTS support by Peter Schuller <peterschueller@telemed.de> (revised by arpi)
alex
parents:
8026
diff
changeset
|
241 int amode; |
f8f3f8b4e0d7
DTS support by Peter Schuller <peterschueller@telemed.de> (revised by arpi)
alex
parents:
8026
diff
changeset
|
242 |
f8f3f8b4e0d7
DTS support by Peter Schuller <peterschueller@telemed.de> (revised by arpi)
alex
parents:
8026
diff
changeset
|
243 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
|
244 | (indata_ptr[3])) != 0x7ffe8001) |
f8f3f8b4e0d7
DTS support by Peter Schuller <peterschueller@telemed.de> (revised by arpi)
alex
parents:
8026
diff
changeset
|
245 return -1; |
f8f3f8b4e0d7
DTS support by Peter Schuller <peterschueller@telemed.de> (revised by arpi)
alex
parents:
8026
diff
changeset
|
246 |
f8f3f8b4e0d7
DTS support by Peter Schuller <peterschueller@telemed.de> (revised by arpi)
alex
parents:
8026
diff
changeset
|
247 ftype = indata_ptr[4] >> 7; |
f8f3f8b4e0d7
DTS support by Peter Schuller <peterschueller@telemed.de> (revised by arpi)
alex
parents:
8026
diff
changeset
|
248 |
f8f3f8b4e0d7
DTS support by Peter Schuller <peterschueller@telemed.de> (revised by arpi)
alex
parents:
8026
diff
changeset
|
249 surp = (indata_ptr[4] >> 2) & 0x1f; |
f8f3f8b4e0d7
DTS support by Peter Schuller <peterschueller@telemed.de> (revised by arpi)
alex
parents:
8026
diff
changeset
|
250 surp = (surp + 1) % 32; |
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 unknown_bit = (indata_ptr[4] >> 1) & 0x01; |
f8f3f8b4e0d7
DTS support by Peter Schuller <peterschueller@telemed.de> (revised by arpi)
alex
parents:
8026
diff
changeset
|
253 |
f8f3f8b4e0d7
DTS support by Peter Schuller <peterschueller@telemed.de> (revised by arpi)
alex
parents:
8026
diff
changeset
|
254 *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
|
255 *nblks = *nblks + 1; |
5370 | 256 |
10012
f8f3f8b4e0d7
DTS support by Peter Schuller <peterschueller@telemed.de> (revised by arpi)
alex
parents:
8026
diff
changeset
|
257 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
|
258 fsize = fsize + 1; |
f8f3f8b4e0d7
DTS support by Peter Schuller <peterschueller@telemed.de> (revised by arpi)
alex
parents:
8026
diff
changeset
|
259 |
f8f3f8b4e0d7
DTS support by Peter Schuller <peterschueller@telemed.de> (revised by arpi)
alex
parents:
8026
diff
changeset
|
260 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
|
261 *sfreq = (indata_ptr[8] >> 2) & 0x0f; |
f8f3f8b4e0d7
DTS support by Peter Schuller <peterschueller@telemed.de> (revised by arpi)
alex
parents:
8026
diff
changeset
|
262 *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
|
263 |
f8f3f8b4e0d7
DTS support by Peter Schuller <peterschueller@telemed.de> (revised by arpi)
alex
parents:
8026
diff
changeset
|
264 if(ftype != 1) |
f8f3f8b4e0d7
DTS support by Peter Schuller <peterschueller@telemed.de> (revised by arpi)
alex
parents:
8026
diff
changeset
|
265 { |
f8f3f8b4e0d7
DTS support by Peter Schuller <peterschueller@telemed.de> (revised by arpi)
alex
parents:
8026
diff
changeset
|
266 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
|
267 return -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 |
f8f3f8b4e0d7
DTS support by Peter Schuller <peterschueller@telemed.de> (revised by arpi)
alex
parents:
8026
diff
changeset
|
270 if(*sfreq != 13) |
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 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
|
273 return -1; |
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 |
f8f3f8b4e0d7
DTS support by Peter Schuller <peterschueller@telemed.de> (revised by arpi)
alex
parents:
8026
diff
changeset
|
276 if((fsize > 8192) || (fsize < 96)) |
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 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
|
279 return -1; |
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 |
f8f3f8b4e0d7
DTS support by Peter Schuller <peterschueller@telemed.de> (revised by arpi)
alex
parents:
8026
diff
changeset
|
282 if(*nblks != 8 && |
f8f3f8b4e0d7
DTS support by Peter Schuller <peterschueller@telemed.de> (revised by arpi)
alex
parents:
8026
diff
changeset
|
283 *nblks != 16 && |
f8f3f8b4e0d7
DTS support by Peter Schuller <peterschueller@telemed.de> (revised by arpi)
alex
parents:
8026
diff
changeset
|
284 *nblks != 32 && |
f8f3f8b4e0d7
DTS support by Peter Schuller <peterschueller@telemed.de> (revised by arpi)
alex
parents:
8026
diff
changeset
|
285 *nblks != 64 && |
f8f3f8b4e0d7
DTS support by Peter Schuller <peterschueller@telemed.de> (revised by arpi)
alex
parents:
8026
diff
changeset
|
286 *nblks != 128 && |
f8f3f8b4e0d7
DTS support by Peter Schuller <peterschueller@telemed.de> (revised by arpi)
alex
parents:
8026
diff
changeset
|
287 ftype == 1) |
f8f3f8b4e0d7
DTS support by Peter Schuller <peterschueller@telemed.de> (revised by arpi)
alex
parents:
8026
diff
changeset
|
288 { |
10948
aebf939834c3
10l found by Dominik 'Rathann' Mierzejewski <dominik@rangers.eu.org>
alex
parents:
10012
diff
changeset
|
289 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
|
290 return -1; |
f8f3f8b4e0d7
DTS support by Peter Schuller <peterschueller@telemed.de> (revised by arpi)
alex
parents:
8026
diff
changeset
|
291 } |
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 return fsize; |
f8f3f8b4e0d7
DTS support by Peter Schuller <peterschueller@telemed.de> (revised by arpi)
alex
parents:
8026
diff
changeset
|
294 } |
5370 | 295 |
10012
f8f3f8b4e0d7
DTS support by Peter Schuller <peterschueller@telemed.de> (revised by arpi)
alex
parents:
8026
diff
changeset
|
296 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
|
297 { |
f8f3f8b4e0d7
DTS support by Peter Schuller <peterschueller@telemed.de> (revised by arpi)
alex
parents:
8026
diff
changeset
|
298 int nblks; |
f8f3f8b4e0d7
DTS support by Peter Schuller <peterschueller@telemed.de> (revised by arpi)
alex
parents:
8026
diff
changeset
|
299 int fsize; |
f8f3f8b4e0d7
DTS support by Peter Schuller <peterschueller@telemed.de> (revised by arpi)
alex
parents:
8026
diff
changeset
|
300 int rate; |
f8f3f8b4e0d7
DTS support by Peter Schuller <peterschueller@telemed.de> (revised by arpi)
alex
parents:
8026
diff
changeset
|
301 int sfreq; |
f8f3f8b4e0d7
DTS support by Peter Schuller <peterschueller@telemed.de> (revised by arpi)
alex
parents:
8026
diff
changeset
|
302 |
f8f3f8b4e0d7
DTS support by Peter Schuller <peterschueller@telemed.de> (revised by arpi)
alex
parents:
8026
diff
changeset
|
303 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
|
304 if(fsize >= 0) |
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 if(rate >= 0 && rate <= 29) |
f8f3f8b4e0d7
DTS support by Peter Schuller <peterschueller@telemed.de> (revised by arpi)
alex
parents:
8026
diff
changeset
|
307 *bit_rate = DTS_BITRATES[rate]; |
f8f3f8b4e0d7
DTS support by Peter Schuller <peterschueller@telemed.de> (revised by arpi)
alex
parents:
8026
diff
changeset
|
308 else |
f8f3f8b4e0d7
DTS support by Peter Schuller <peterschueller@telemed.de> (revised by arpi)
alex
parents:
8026
diff
changeset
|
309 *bit_rate = 0; |
f8f3f8b4e0d7
DTS support by Peter Schuller <peterschueller@telemed.de> (revised by arpi)
alex
parents:
8026
diff
changeset
|
310 if(sfreq >= 1 && sfreq <= 15) |
f8f3f8b4e0d7
DTS support by Peter Schuller <peterschueller@telemed.de> (revised by arpi)
alex
parents:
8026
diff
changeset
|
311 *sample_rate = DTS_SAMPLEFREQS[sfreq]; |
f8f3f8b4e0d7
DTS support by Peter Schuller <peterschueller@telemed.de> (revised by arpi)
alex
parents:
8026
diff
changeset
|
312 else |
f8f3f8b4e0d7
DTS support by Peter Schuller <peterschueller@telemed.de> (revised by arpi)
alex
parents:
8026
diff
changeset
|
313 *sample_rate = 0; |
f8f3f8b4e0d7
DTS support by Peter Schuller <peterschueller@telemed.de> (revised by arpi)
alex
parents:
8026
diff
changeset
|
314 } |
f8f3f8b4e0d7
DTS support by Peter Schuller <peterschueller@telemed.de> (revised by arpi)
alex
parents:
8026
diff
changeset
|
315 return fsize; |
f8f3f8b4e0d7
DTS support by Peter Schuller <peterschueller@telemed.de> (revised by arpi)
alex
parents:
8026
diff
changeset
|
316 } |
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 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
|
320 { |
f8f3f8b4e0d7
DTS support by Peter Schuller <peterschueller@telemed.de> (revised by arpi)
alex
parents:
8026
diff
changeset
|
321 int nblks; |
f8f3f8b4e0d7
DTS support by Peter Schuller <peterschueller@telemed.de> (revised by arpi)
alex
parents:
8026
diff
changeset
|
322 int fsize; |
f8f3f8b4e0d7
DTS support by Peter Schuller <peterschueller@telemed.de> (revised by arpi)
alex
parents:
8026
diff
changeset
|
323 int rate; |
f8f3f8b4e0d7
DTS support by Peter Schuller <peterschueller@telemed.de> (revised by arpi)
alex
parents:
8026
diff
changeset
|
324 int sfreq; |
f8f3f8b4e0d7
DTS support by Peter Schuller <peterschueller@telemed.de> (revised by arpi)
alex
parents:
8026
diff
changeset
|
325 int burst_len; |
f8f3f8b4e0d7
DTS support by Peter Schuller <peterschueller@telemed.de> (revised by arpi)
alex
parents:
8026
diff
changeset
|
326 int nr_samples; |
24432
79fcacd73f9b
Simplify and fix big-endian hwac3 header generation code.
reimar
parents:
23734
diff
changeset
|
327 uint16_t *buf16 = (uint16_t *)buf; |
10012
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 |
24432
79fcacd73f9b
Simplify and fix big-endian hwac3 header generation code.
reimar
parents:
23734
diff
changeset
|
336 buf16[0] = 0xf872; /* iec 61937 */ |
79fcacd73f9b
Simplify and fix big-endian hwac3 header generation code.
reimar
parents:
23734
diff
changeset
|
337 buf16[1] = 0x431f; /* syncword */ |
10012
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: |
24432
79fcacd73f9b
Simplify and fix big-endian hwac3 header generation code.
reimar
parents:
23734
diff
changeset
|
341 buf16[2] = 0x000b; /* DTS-1 (512-sample bursts) */ |
10012
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: |
24432
79fcacd73f9b
Simplify and fix big-endian hwac3 header generation code.
reimar
parents:
23734
diff
changeset
|
344 buf16[2] = 0x000c; /* DTS-2 (1024-sample bursts) */ |
10012
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: |
24432
79fcacd73f9b
Simplify and fix big-endian hwac3 header generation code.
reimar
parents:
23734
diff
changeset
|
347 buf16[2] = 0x000d; /* DTS-3 (2048-sample bursts) */ |
10012
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); |
24432
79fcacd73f9b
Simplify and fix big-endian hwac3 header generation code.
reimar
parents:
23734
diff
changeset
|
351 buf16[2] = 0x0000; |
10012
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 } |
24432
79fcacd73f9b
Simplify and fix big-endian hwac3 header generation code.
reimar
parents:
23734
diff
changeset
|
354 buf16[3] = burst_len; |
10012
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 if(fsize + 8 > nr_samples * 2 * 2) |
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 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
|
359 } |
f8f3f8b4e0d7
DTS support by Peter Schuller <peterschueller@telemed.de> (revised by arpi)
alex
parents:
8026
diff
changeset
|
360 #ifdef WORDS_BIGENDIAN |
f8f3f8b4e0d7
DTS support by Peter Schuller <peterschueller@telemed.de> (revised by arpi)
alex
parents:
8026
diff
changeset
|
361 memcpy(&buf[8], indata_ptr, fsize); // untested |
f8f3f8b4e0d7
DTS support by Peter Schuller <peterschueller@telemed.de> (revised by arpi)
alex
parents:
8026
diff
changeset
|
362 #else |
f8f3f8b4e0d7
DTS support by Peter Schuller <peterschueller@telemed.de> (revised by arpi)
alex
parents:
8026
diff
changeset
|
363 //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
|
364 swab(indata_ptr, &buf[8], fsize); |
14187 | 365 if (fsize & 1) |
366 buf[8+fsize] = indata_ptr[fsize]; | |
10012
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 |