Mercurial > mplayer.hg
annotate libmpcodecs/ad_hwac3.c @ 36775:666757381a27
Avoid pointer cast warnings.
Fixes "cast from pointer to integer of different size" warnings.
This is corresponding to r36858.
author | ib |
---|---|
date | Mon, 17 Feb 2014 01:28:05 +0000 |
parents | d13733fdf789 |
children | 7ee92e6f4d61 |
rev | line source |
---|---|
30421
bbb6ebec87a0
Add missing license headers to all files in the libmpcodecs directory.
diego
parents:
30248
diff
changeset
|
1 /* |
bbb6ebec87a0
Add missing license headers to all files in the libmpcodecs directory.
diego
parents:
30248
diff
changeset
|
2 * DTS code based on "ac3/decode_dts.c" and "ac3/conversion.c" from "ogle 0.9" |
bbb6ebec87a0
Add missing license headers to all files in the libmpcodecs directory.
diego
parents:
30248
diff
changeset
|
3 * (see http://www.dtek.chalmers.se/~dvd/) |
bbb6ebec87a0
Add missing license headers to all files in the libmpcodecs directory.
diego
parents:
30248
diff
changeset
|
4 * Reference: DOCS/tech/hwac3.txt !!!!! |
bbb6ebec87a0
Add missing license headers to all files in the libmpcodecs directory.
diego
parents:
30248
diff
changeset
|
5 * |
bbb6ebec87a0
Add missing license headers to all files in the libmpcodecs directory.
diego
parents:
30248
diff
changeset
|
6 * This file is part of MPlayer. |
bbb6ebec87a0
Add missing license headers to all files in the libmpcodecs directory.
diego
parents:
30248
diff
changeset
|
7 * |
bbb6ebec87a0
Add missing license headers to all files in the libmpcodecs directory.
diego
parents:
30248
diff
changeset
|
8 * MPlayer is free software; you can redistribute it and/or modify |
bbb6ebec87a0
Add missing license headers to all files in the libmpcodecs directory.
diego
parents:
30248
diff
changeset
|
9 * it under the terms of the GNU General Public License as published by |
bbb6ebec87a0
Add missing license headers to all files in the libmpcodecs directory.
diego
parents:
30248
diff
changeset
|
10 * the Free Software Foundation; either version 2 of the License, or |
bbb6ebec87a0
Add missing license headers to all files in the libmpcodecs directory.
diego
parents:
30248
diff
changeset
|
11 * (at your option) any later version. |
bbb6ebec87a0
Add missing license headers to all files in the libmpcodecs directory.
diego
parents:
30248
diff
changeset
|
12 * |
bbb6ebec87a0
Add missing license headers to all files in the libmpcodecs directory.
diego
parents:
30248
diff
changeset
|
13 * MPlayer is distributed in the hope that it will be useful, |
bbb6ebec87a0
Add missing license headers to all files in the libmpcodecs directory.
diego
parents:
30248
diff
changeset
|
14 * but WITHOUT ANY WARRANTY; without even the implied warranty of |
bbb6ebec87a0
Add missing license headers to all files in the libmpcodecs directory.
diego
parents:
30248
diff
changeset
|
15 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
bbb6ebec87a0
Add missing license headers to all files in the libmpcodecs directory.
diego
parents:
30248
diff
changeset
|
16 * GNU General Public License for more details. |
bbb6ebec87a0
Add missing license headers to all files in the libmpcodecs directory.
diego
parents:
30248
diff
changeset
|
17 * |
bbb6ebec87a0
Add missing license headers to all files in the libmpcodecs directory.
diego
parents:
30248
diff
changeset
|
18 * You should have received a copy of the GNU General Public License along |
bbb6ebec87a0
Add missing license headers to all files in the libmpcodecs directory.
diego
parents:
30248
diff
changeset
|
19 * with MPlayer; if not, write to the Free Software Foundation, Inc., |
bbb6ebec87a0
Add missing license headers to all files in the libmpcodecs directory.
diego
parents:
30248
diff
changeset
|
20 * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. |
bbb6ebec87a0
Add missing license headers to all files in the libmpcodecs directory.
diego
parents:
30248
diff
changeset
|
21 */ |
10012
f8f3f8b4e0d7
DTS support by Peter Schuller <peterschueller@telemed.de> (revised by arpi)
alex
parents:
8026
diff
changeset
|
22 |
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 #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
|
24 #include <stdlib.h> |
5370 | 25 #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
|
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 #include "config.h" |
0f12fb7c1c5d
imported from MPlayerXP, dlopen() hack removed, some bugs fixed, interface functions changed to static, info->author field added
arpi
parents:
diff
changeset
|
28 #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
|
29 #include "help_mp.h" |
23638
a81e246e3b38
Make sure we always have a swab() prototype when we use it,
reimar
parents:
18512
diff
changeset
|
30 #include "mpbswap.h" |
30238
faed63286179
Make ad_hwac3 independent of liba52. Needs a minor amount of code duplication,
reimar
parents:
29401
diff
changeset
|
31 #include "libavutil/common.h" |
30243
05f085c36d5b
Let the format filter do the AC3 endianness conversion instead of duplicating
reimar
parents:
30241
diff
changeset
|
32 #include "libavutil/intreadwrite.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
|
33 |
0f12fb7c1c5d
imported from MPlayerXP, dlopen() hack removed, some bugs fixed, interface functions changed to static, info->author field added
arpi
parents:
diff
changeset
|
34 #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
|
35 |
10012
f8f3f8b4e0d7
DTS support by Peter Schuller <peterschueller@telemed.de> (revised by arpi)
alex
parents:
8026
diff
changeset
|
36 |
f8f3f8b4e0d7
DTS support by Peter Schuller <peterschueller@telemed.de> (revised by arpi)
alex
parents:
8026
diff
changeset
|
37 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
|
38 |
30504
cc27da5d7286
Mark all ad_info_t/vd_info_t structure declarations as const.
diego
parents:
30421
diff
changeset
|
39 static const ad_info_t info = |
5340
0f12fb7c1c5d
imported from MPlayerXP, dlopen() hack removed, some bugs fixed, interface functions changed to static, info->author field added
arpi
parents:
diff
changeset
|
40 { |
14710 | 41 "AC3/DTS pass-through S/PDIF", |
10012
f8f3f8b4e0d7
DTS support by Peter Schuller <peterschueller@telemed.de> (revised by arpi)
alex
parents:
8026
diff
changeset
|
42 "hwac3", |
23734 | 43 "Nick Kurshev/Peter Schüller", |
10012
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 "" |
5340
0f12fb7c1c5d
imported from MPlayerXP, dlopen() hack removed, some bugs fixed, interface functions changed to static, info->author field added
arpi
parents:
diff
changeset
|
46 }; |
0f12fb7c1c5d
imported from MPlayerXP, dlopen() hack removed, some bugs fixed, interface functions changed to static, info->author field added
arpi
parents:
diff
changeset
|
47 |
0f12fb7c1c5d
imported from MPlayerXP, dlopen() hack removed, some bugs fixed, interface functions changed to static, info->author field added
arpi
parents:
diff
changeset
|
48 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
|
49 |
10012
f8f3f8b4e0d7
DTS support by Peter Schuller <peterschueller@telemed.de> (revised by arpi)
alex
parents:
8026
diff
changeset
|
50 |
f8f3f8b4e0d7
DTS support by Peter Schuller <peterschueller@telemed.de> (revised by arpi)
alex
parents:
8026
diff
changeset
|
51 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
|
52 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
|
53 |
f8f3f8b4e0d7
DTS support by Peter Schuller <peterschueller@telemed.de> (revised by arpi)
alex
parents:
8026
diff
changeset
|
54 |
30238
faed63286179
Make ad_hwac3 independent of liba52. Needs a minor amount of code duplication,
reimar
parents:
29401
diff
changeset
|
55 static int a52_syncinfo (uint8_t *buf, int *sample_rate, int *bit_rate) |
faed63286179
Make ad_hwac3 independent of liba52. Needs a minor amount of code duplication,
reimar
parents:
29401
diff
changeset
|
56 { |
faed63286179
Make ad_hwac3 independent of liba52. Needs a minor amount of code duplication,
reimar
parents:
29401
diff
changeset
|
57 static const uint16_t rate[] = { 32, 40, 48, 56, 64, 80, 96, 112, |
faed63286179
Make ad_hwac3 independent of liba52. Needs a minor amount of code duplication,
reimar
parents:
29401
diff
changeset
|
58 128, 160, 192, 224, 256, 320, 384, 448, |
faed63286179
Make ad_hwac3 independent of liba52. Needs a minor amount of code duplication,
reimar
parents:
29401
diff
changeset
|
59 512, 576, 640}; |
faed63286179
Make ad_hwac3 independent of liba52. Needs a minor amount of code duplication,
reimar
parents:
29401
diff
changeset
|
60 int frmsizecod; |
faed63286179
Make ad_hwac3 independent of liba52. Needs a minor amount of code duplication,
reimar
parents:
29401
diff
changeset
|
61 int bitrate; |
faed63286179
Make ad_hwac3 independent of liba52. Needs a minor amount of code duplication,
reimar
parents:
29401
diff
changeset
|
62 int half; |
faed63286179
Make ad_hwac3 independent of liba52. Needs a minor amount of code duplication,
reimar
parents:
29401
diff
changeset
|
63 |
faed63286179
Make ad_hwac3 independent of liba52. Needs a minor amount of code duplication,
reimar
parents:
29401
diff
changeset
|
64 if (buf[0] != 0x0b || buf[1] != 0x77) /* syncword */ |
faed63286179
Make ad_hwac3 independent of liba52. Needs a minor amount of code duplication,
reimar
parents:
29401
diff
changeset
|
65 return 0; |
faed63286179
Make ad_hwac3 independent of liba52. Needs a minor amount of code duplication,
reimar
parents:
29401
diff
changeset
|
66 |
faed63286179
Make ad_hwac3 independent of liba52. Needs a minor amount of code duplication,
reimar
parents:
29401
diff
changeset
|
67 if (buf[5] >= 0x60) /* bsid >= 12 */ |
faed63286179
Make ad_hwac3 independent of liba52. Needs a minor amount of code duplication,
reimar
parents:
29401
diff
changeset
|
68 return 0; |
faed63286179
Make ad_hwac3 independent of liba52. Needs a minor amount of code duplication,
reimar
parents:
29401
diff
changeset
|
69 half = buf[5] >> 3; |
faed63286179
Make ad_hwac3 independent of liba52. Needs a minor amount of code duplication,
reimar
parents:
29401
diff
changeset
|
70 half = FFMAX(half - 8, 0); |
faed63286179
Make ad_hwac3 independent of liba52. Needs a minor amount of code duplication,
reimar
parents:
29401
diff
changeset
|
71 |
faed63286179
Make ad_hwac3 independent of liba52. Needs a minor amount of code duplication,
reimar
parents:
29401
diff
changeset
|
72 frmsizecod = buf[4] & 63; |
faed63286179
Make ad_hwac3 independent of liba52. Needs a minor amount of code duplication,
reimar
parents:
29401
diff
changeset
|
73 if (frmsizecod >= 38) |
faed63286179
Make ad_hwac3 independent of liba52. Needs a minor amount of code duplication,
reimar
parents:
29401
diff
changeset
|
74 return 0; |
faed63286179
Make ad_hwac3 independent of liba52. Needs a minor amount of code duplication,
reimar
parents:
29401
diff
changeset
|
75 bitrate = rate[frmsizecod >> 1]; |
faed63286179
Make ad_hwac3 independent of liba52. Needs a minor amount of code duplication,
reimar
parents:
29401
diff
changeset
|
76 *bit_rate = (bitrate * 1000) >> half; |
faed63286179
Make ad_hwac3 independent of liba52. Needs a minor amount of code duplication,
reimar
parents:
29401
diff
changeset
|
77 |
faed63286179
Make ad_hwac3 independent of liba52. Needs a minor amount of code duplication,
reimar
parents:
29401
diff
changeset
|
78 switch (buf[4] & 0xc0) { |
faed63286179
Make ad_hwac3 independent of liba52. Needs a minor amount of code duplication,
reimar
parents:
29401
diff
changeset
|
79 case 0: |
faed63286179
Make ad_hwac3 independent of liba52. Needs a minor amount of code duplication,
reimar
parents:
29401
diff
changeset
|
80 *sample_rate = 48000 >> half; |
faed63286179
Make ad_hwac3 independent of liba52. Needs a minor amount of code duplication,
reimar
parents:
29401
diff
changeset
|
81 return 4 * bitrate; |
faed63286179
Make ad_hwac3 independent of liba52. Needs a minor amount of code duplication,
reimar
parents:
29401
diff
changeset
|
82 case 0x40: |
faed63286179
Make ad_hwac3 independent of liba52. Needs a minor amount of code duplication,
reimar
parents:
29401
diff
changeset
|
83 *sample_rate = 44100 >> half; |
faed63286179
Make ad_hwac3 independent of liba52. Needs a minor amount of code duplication,
reimar
parents:
29401
diff
changeset
|
84 return 2 * (320 * bitrate / 147 + (frmsizecod & 1)); |
faed63286179
Make ad_hwac3 independent of liba52. Needs a minor amount of code duplication,
reimar
parents:
29401
diff
changeset
|
85 case 0x80: |
faed63286179
Make ad_hwac3 independent of liba52. Needs a minor amount of code duplication,
reimar
parents:
29401
diff
changeset
|
86 *sample_rate = 32000 >> half; |
faed63286179
Make ad_hwac3 independent of liba52. Needs a minor amount of code duplication,
reimar
parents:
29401
diff
changeset
|
87 return 6 * bitrate; |
faed63286179
Make ad_hwac3 independent of liba52. Needs a minor amount of code duplication,
reimar
parents:
29401
diff
changeset
|
88 default: |
faed63286179
Make ad_hwac3 independent of liba52. Needs a minor amount of code duplication,
reimar
parents:
29401
diff
changeset
|
89 return 0; |
faed63286179
Make ad_hwac3 independent of liba52. Needs a minor amount of code duplication,
reimar
parents:
29401
diff
changeset
|
90 } |
faed63286179
Make ad_hwac3 independent of liba52. Needs a minor amount of code duplication,
reimar
parents:
29401
diff
changeset
|
91 } |
faed63286179
Make ad_hwac3 independent of liba52. Needs a minor amount of code duplication,
reimar
parents:
29401
diff
changeset
|
92 |
10012
f8f3f8b4e0d7
DTS support by Peter Schuller <peterschueller@telemed.de> (revised by arpi)
alex
parents:
8026
diff
changeset
|
93 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
|
94 { |
f8f3f8b4e0d7
DTS support by Peter Schuller <peterschueller@telemed.de> (revised by arpi)
alex
parents:
8026
diff
changeset
|
95 int length = 0; |
f8f3f8b4e0d7
DTS support by Peter Schuller <peterschueller@telemed.de> (revised by arpi)
alex
parents:
8026
diff
changeset
|
96 int flags = 0; |
f8f3f8b4e0d7
DTS support by Peter Schuller <peterschueller@telemed.de> (revised by arpi)
alex
parents:
8026
diff
changeset
|
97 int sample_rate = 0; |
f8f3f8b4e0d7
DTS support by Peter Schuller <peterschueller@telemed.de> (revised by arpi)
alex
parents:
8026
diff
changeset
|
98 int bit_rate = 0; |
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 sh_audio->a_in_buffer_len = 0; |
f8f3f8b4e0d7
DTS support by Peter Schuller <peterschueller@telemed.de> (revised by arpi)
alex
parents:
8026
diff
changeset
|
101 /* sync frame:*/ |
f8f3f8b4e0d7
DTS support by Peter Schuller <peterschueller@telemed.de> (revised by arpi)
alex
parents:
8026
diff
changeset
|
102 while(1) |
f8f3f8b4e0d7
DTS support by Peter Schuller <peterschueller@telemed.de> (revised by arpi)
alex
parents:
8026
diff
changeset
|
103 { |
25102
55d8b87b62da
Make hwdts support more dts format identification, 14bits or 16bits, LE or BE.
ulion
parents:
24509
diff
changeset
|
104 // Original code DTS has a 10 bytes header. |
55d8b87b62da
Make hwdts support more dts format identification, 14bits or 16bits, LE or BE.
ulion
parents:
24509
diff
changeset
|
105 // Now max 12 bytes for 14 bits DTS header. |
55d8b87b62da
Make hwdts support more dts format identification, 14bits or 16bits, LE or BE.
ulion
parents:
24509
diff
changeset
|
106 while(sh_audio->a_in_buffer_len < 12) |
10012
f8f3f8b4e0d7
DTS support by Peter Schuller <peterschueller@telemed.de> (revised by arpi)
alex
parents:
8026
diff
changeset
|
107 { |
f8f3f8b4e0d7
DTS support by Peter Schuller <peterschueller@telemed.de> (revised by arpi)
alex
parents:
8026
diff
changeset
|
108 int c = demux_getc(sh_audio->ds); |
f8f3f8b4e0d7
DTS support by Peter Schuller <peterschueller@telemed.de> (revised by arpi)
alex
parents:
8026
diff
changeset
|
109 if(c<0) |
f8f3f8b4e0d7
DTS support by Peter Schuller <peterschueller@telemed.de> (revised by arpi)
alex
parents:
8026
diff
changeset
|
110 return -1; /* EOF*/ |
f8f3f8b4e0d7
DTS support by Peter Schuller <peterschueller@telemed.de> (revised by arpi)
alex
parents:
8026
diff
changeset
|
111 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
|
112 } |
f8f3f8b4e0d7
DTS support by Peter Schuller <peterschueller@telemed.de> (revised by arpi)
alex
parents:
8026
diff
changeset
|
113 |
26661 | 114 if (sh_audio->format == 0x2001) |
115 { | |
26662 | 116 length = dts_syncinfo(sh_audio->a_in_buffer, &flags, &sample_rate, &bit_rate); |
117 if(length >= 12) | |
10012
f8f3f8b4e0d7
DTS support by Peter Schuller <peterschueller@telemed.de> (revised by arpi)
alex
parents:
8026
diff
changeset
|
118 { |
26662 | 119 if(isdts != 1) |
120 { | |
121 mp_msg(MSGT_DECAUDIO, MSGL_STATUS, "hwac3: switched to DTS, %d bps, %d Hz\n", bit_rate, sample_rate); | |
122 isdts = 1; | |
123 } | |
124 break; | |
10012
f8f3f8b4e0d7
DTS support by Peter Schuller <peterschueller@telemed.de> (revised by arpi)
alex
parents:
8026
diff
changeset
|
125 } |
26661 | 126 } |
127 else | |
128 { | |
30238
faed63286179
Make ad_hwac3 independent of liba52. Needs a minor amount of code duplication,
reimar
parents:
29401
diff
changeset
|
129 length = a52_syncinfo(sh_audio->a_in_buffer, &sample_rate, &bit_rate); |
29263
0f1b5b68af32
whitespace cosmetics: Remove all trailing whitespace.
diego
parents:
28445
diff
changeset
|
130 if(length >= 7 && length <= 3840) |
10012
f8f3f8b4e0d7
DTS support by Peter Schuller <peterschueller@telemed.de> (revised by arpi)
alex
parents:
8026
diff
changeset
|
131 { |
26662 | 132 if(isdts != 0) |
133 { | |
134 mp_msg(MSGT_DECAUDIO, MSGL_STATUS, "hwac3: switched to AC3, %d bps, %d Hz\n", bit_rate, sample_rate); | |
135 isdts = 0; | |
136 } | |
137 break; /* we're done.*/ | |
10012
f8f3f8b4e0d7
DTS support by Peter Schuller <peterschueller@telemed.de> (revised by arpi)
alex
parents:
8026
diff
changeset
|
138 } |
26661 | 139 } |
10012
f8f3f8b4e0d7
DTS support by Peter Schuller <peterschueller@telemed.de> (revised by arpi)
alex
parents:
8026
diff
changeset
|
140 /* bad file => resync*/ |
25102
55d8b87b62da
Make hwdts support more dts format identification, 14bits or 16bits, LE or BE.
ulion
parents:
24509
diff
changeset
|
141 memcpy(sh_audio->a_in_buffer, sh_audio->a_in_buffer + 1, 11); |
10012
f8f3f8b4e0d7
DTS support by Peter Schuller <peterschueller@telemed.de> (revised by arpi)
alex
parents:
8026
diff
changeset
|
142 --sh_audio->a_in_buffer_len; |
f8f3f8b4e0d7
DTS support by Peter Schuller <peterschueller@telemed.de> (revised by arpi)
alex
parents:
8026
diff
changeset
|
143 } |
f8f3f8b4e0d7
DTS support by Peter Schuller <peterschueller@telemed.de> (revised by arpi)
alex
parents:
8026
diff
changeset
|
144 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
|
145 |
f8f3f8b4e0d7
DTS support by Peter Schuller <peterschueller@telemed.de> (revised by arpi)
alex
parents:
8026
diff
changeset
|
146 sh_audio->samplerate = sample_rate; |
f8f3f8b4e0d7
DTS support by Peter Schuller <peterschueller@telemed.de> (revised by arpi)
alex
parents:
8026
diff
changeset
|
147 sh_audio->i_bps = bit_rate / 8; |
25102
55d8b87b62da
Make hwdts support more dts format identification, 14bits or 16bits, LE or BE.
ulion
parents:
24509
diff
changeset
|
148 demux_read_data(sh_audio->ds, sh_audio->a_in_buffer + 12, length - 12); |
10012
f8f3f8b4e0d7
DTS support by Peter Schuller <peterschueller@telemed.de> (revised by arpi)
alex
parents:
8026
diff
changeset
|
149 sh_audio->a_in_buffer_len = length; |
29263
0f1b5b68af32
whitespace cosmetics: Remove all trailing whitespace.
diego
parents:
28445
diff
changeset
|
150 |
10012
f8f3f8b4e0d7
DTS support by Peter Schuller <peterschueller@telemed.de> (revised by arpi)
alex
parents:
8026
diff
changeset
|
151 return length; |
f8f3f8b4e0d7
DTS support by Peter Schuller <peterschueller@telemed.de> (revised by arpi)
alex
parents:
8026
diff
changeset
|
152 } |
f8f3f8b4e0d7
DTS support by Peter Schuller <peterschueller@telemed.de> (revised by arpi)
alex
parents:
8026
diff
changeset
|
153 |
f8f3f8b4e0d7
DTS support by Peter Schuller <peterschueller@telemed.de> (revised by arpi)
alex
parents:
8026
diff
changeset
|
154 |
5340
0f12fb7c1c5d
imported from MPlayerXP, dlopen() hack removed, some bugs fixed, interface functions changed to static, info->author field added
arpi
parents:
diff
changeset
|
155 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
|
156 { |
0f12fb7c1c5d
imported from MPlayerXP, dlopen() hack removed, some bugs fixed, interface functions changed to static, info->author field added
arpi
parents:
diff
changeset
|
157 /* Dolby AC3 audio: */ |
10012
f8f3f8b4e0d7
DTS support by Peter Schuller <peterschueller@telemed.de> (revised by arpi)
alex
parents:
8026
diff
changeset
|
158 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
|
159 sh->audio_in_minsize = 8192; |
f8f3f8b4e0d7
DTS support by Peter Schuller <peterschueller@telemed.de> (revised by arpi)
alex
parents:
8026
diff
changeset
|
160 sh->channels = 2; |
f8f3f8b4e0d7
DTS support by Peter Schuller <peterschueller@telemed.de> (revised by arpi)
alex
parents:
8026
diff
changeset
|
161 sh->samplesize = 2; |
30243
05f085c36d5b
Let the format filter do the AC3 endianness conversion instead of duplicating
reimar
parents:
30241
diff
changeset
|
162 sh->sample_format = AF_FORMAT_AC3_BE; |
30246 | 163 // HACK for DTS where useless swapping can't easily be removed |
30248
cb820f087ce0
100l, fix typo that caused ad_hwac3 to fail to compile.
reimar
parents:
30246
diff
changeset
|
164 if (sh->format == 0x2001) |
30246 | 165 sh->sample_format = AF_FORMAT_AC3_NE; |
5340
0f12fb7c1c5d
imported from MPlayerXP, dlopen() hack removed, some bugs fixed, interface functions changed to static, info->author field added
arpi
parents:
diff
changeset
|
166 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
|
167 } |
0f12fb7c1c5d
imported from MPlayerXP, dlopen() hack removed, some bugs fixed, interface functions changed to static, info->author field added
arpi
parents:
diff
changeset
|
168 |
0f12fb7c1c5d
imported from MPlayerXP, dlopen() hack removed, some bugs fixed, interface functions changed to static, info->author field added
arpi
parents:
diff
changeset
|
169 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
|
170 { |
0f12fb7c1c5d
imported from MPlayerXP, dlopen() hack removed, some bugs fixed, interface functions changed to static, info->author field added
arpi
parents:
diff
changeset
|
171 /* Dolby AC3 passthrough:*/ |
10012
f8f3f8b4e0d7
DTS support by Peter Schuller <peterschueller@telemed.de> (revised by arpi)
alex
parents:
8026
diff
changeset
|
172 if(ac3dts_fillbuff(sh_audio) < 0) |
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 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
|
175 return 0; |
f8f3f8b4e0d7
DTS support by Peter Schuller <peterschueller@telemed.de> (revised by arpi)
alex
parents:
8026
diff
changeset
|
176 } |
5340
0f12fb7c1c5d
imported from MPlayerXP, dlopen() hack removed, some bugs fixed, interface functions changed to static, info->author field added
arpi
parents:
diff
changeset
|
177 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
|
178 } |
0f12fb7c1c5d
imported from MPlayerXP, dlopen() hack removed, some bugs fixed, interface functions changed to static, info->author field added
arpi
parents:
diff
changeset
|
179 |
0f12fb7c1c5d
imported from MPlayerXP, dlopen() hack removed, some bugs fixed, interface functions changed to static, info->author field added
arpi
parents:
diff
changeset
|
180 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
|
181 { |
0f12fb7c1c5d
imported from MPlayerXP, dlopen() hack removed, some bugs fixed, interface functions changed to static, info->author field added
arpi
parents:
diff
changeset
|
182 } |
0f12fb7c1c5d
imported from MPlayerXP, dlopen() hack removed, some bugs fixed, interface functions changed to static, info->author field added
arpi
parents:
diff
changeset
|
183 |
0f12fb7c1c5d
imported from MPlayerXP, dlopen() hack removed, some bugs fixed, interface functions changed to static, info->author field added
arpi
parents:
diff
changeset
|
184 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
|
185 { |
10012
f8f3f8b4e0d7
DTS support by Peter Schuller <peterschueller@telemed.de> (revised by arpi)
alex
parents:
8026
diff
changeset
|
186 switch(cmd) |
f8f3f8b4e0d7
DTS support by Peter Schuller <peterschueller@telemed.de> (revised by arpi)
alex
parents:
8026
diff
changeset
|
187 { |
15558 | 188 case ADCTRL_RESYNC_STREAM: |
10012
f8f3f8b4e0d7
DTS support by Peter Schuller <peterschueller@telemed.de> (revised by arpi)
alex
parents:
8026
diff
changeset
|
189 case ADCTRL_SKIP_FRAME: |
15558 | 190 ac3dts_fillbuff(sh); |
10012
f8f3f8b4e0d7
DTS support by Peter Schuller <peterschueller@telemed.de> (revised by arpi)
alex
parents:
8026
diff
changeset
|
191 return CONTROL_TRUE; |
f8f3f8b4e0d7
DTS support by Peter Schuller <peterschueller@telemed.de> (revised by arpi)
alex
parents:
8026
diff
changeset
|
192 } |
5340
0f12fb7c1c5d
imported from MPlayerXP, dlopen() hack removed, some bugs fixed, interface functions changed to static, info->author field added
arpi
parents:
diff
changeset
|
193 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
|
194 } |
0f12fb7c1c5d
imported from MPlayerXP, dlopen() hack removed, some bugs fixed, interface functions changed to static, info->author field added
arpi
parents:
diff
changeset
|
195 |
10012
f8f3f8b4e0d7
DTS support by Peter Schuller <peterschueller@telemed.de> (revised by arpi)
alex
parents:
8026
diff
changeset
|
196 |
5340
0f12fb7c1c5d
imported from MPlayerXP, dlopen() hack removed, some bugs fixed, interface functions changed to static, info->author field added
arpi
parents:
diff
changeset
|
197 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
|
198 { |
10012
f8f3f8b4e0d7
DTS support by Peter Schuller <peterschueller@telemed.de> (revised by arpi)
alex
parents:
8026
diff
changeset
|
199 int len = sh_audio->a_in_buffer_len; |
29263
0f1b5b68af32
whitespace cosmetics: Remove all trailing whitespace.
diego
parents:
28445
diff
changeset
|
200 |
10012
f8f3f8b4e0d7
DTS support by Peter Schuller <peterschueller@telemed.de> (revised by arpi)
alex
parents:
8026
diff
changeset
|
201 if(len <= 0) |
f8f3f8b4e0d7
DTS support by Peter Schuller <peterschueller@telemed.de> (revised by arpi)
alex
parents:
8026
diff
changeset
|
202 if((len = ac3dts_fillbuff(sh_audio)) <= 0) |
f8f3f8b4e0d7
DTS support by Peter Schuller <peterschueller@telemed.de> (revised by arpi)
alex
parents:
8026
diff
changeset
|
203 return len; /*EOF*/ |
f8f3f8b4e0d7
DTS support by Peter Schuller <peterschueller@telemed.de> (revised by arpi)
alex
parents:
8026
diff
changeset
|
204 sh_audio->a_in_buffer_len = 0; |
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 if(isdts == 1) |
f8f3f8b4e0d7
DTS support by Peter Schuller <peterschueller@telemed.de> (revised by arpi)
alex
parents:
8026
diff
changeset
|
207 { |
f8f3f8b4e0d7
DTS support by Peter Schuller <peterschueller@telemed.de> (revised by arpi)
alex
parents:
8026
diff
changeset
|
208 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
|
209 } |
f8f3f8b4e0d7
DTS support by Peter Schuller <peterschueller@telemed.de> (revised by arpi)
alex
parents:
8026
diff
changeset
|
210 else if(isdts == 0) |
f8f3f8b4e0d7
DTS support by Peter Schuller <peterschueller@telemed.de> (revised by arpi)
alex
parents:
8026
diff
changeset
|
211 { |
30243
05f085c36d5b
Let the format filter do the AC3 endianness conversion instead of duplicating
reimar
parents:
30241
diff
changeset
|
212 AV_WB16(buf, 0xF872); // iec 61937 syncword 1 |
05f085c36d5b
Let the format filter do the AC3 endianness conversion instead of duplicating
reimar
parents:
30241
diff
changeset
|
213 AV_WB16(buf + 2, 0x4E1F); // iec 61937 syncword 2 |
05f085c36d5b
Let the format filter do the AC3 endianness conversion instead of duplicating
reimar
parents:
30241
diff
changeset
|
214 buf[4] = sh_audio->a_in_buffer[5] & 0x7; // bsmod |
05f085c36d5b
Let the format filter do the AC3 endianness conversion instead of duplicating
reimar
parents:
30241
diff
changeset
|
215 buf[5] = 0x01; // data-type ac3 |
05f085c36d5b
Let the format filter do the AC3 endianness conversion instead of duplicating
reimar
parents:
30241
diff
changeset
|
216 AV_WB16(buf + 6, len << 3); // number of bits in payload |
24433
435b37266f1e
Improved comments, based on patches by Ulion [ulion2002 gmail com]
reimar
parents:
24432
diff
changeset
|
217 memcpy(buf + 8, sh_audio->a_in_buffer, len); |
10012
f8f3f8b4e0d7
DTS support by Peter Schuller <peterschueller@telemed.de> (revised by arpi)
alex
parents:
8026
diff
changeset
|
218 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
|
219 |
f8f3f8b4e0d7
DTS support by Peter Schuller <peterschueller@telemed.de> (revised by arpi)
alex
parents:
8026
diff
changeset
|
220 return 6144; |
f8f3f8b4e0d7
DTS support by Peter Schuller <peterschueller@telemed.de> (revised by arpi)
alex
parents:
8026
diff
changeset
|
221 } |
f8f3f8b4e0d7
DTS support by Peter Schuller <peterschueller@telemed.de> (revised by arpi)
alex
parents:
8026
diff
changeset
|
222 else |
f8f3f8b4e0d7
DTS support by Peter Schuller <peterschueller@telemed.de> (revised by arpi)
alex
parents:
8026
diff
changeset
|
223 return -1; |
f8f3f8b4e0d7
DTS support by Peter Schuller <peterschueller@telemed.de> (revised by arpi)
alex
parents:
8026
diff
changeset
|
224 } |
f8f3f8b4e0d7
DTS support by Peter Schuller <peterschueller@telemed.de> (revised by arpi)
alex
parents:
8026
diff
changeset
|
225 |
f8f3f8b4e0d7
DTS support by Peter Schuller <peterschueller@telemed.de> (revised by arpi)
alex
parents:
8026
diff
changeset
|
226 |
24435 | 227 static const int DTS_SAMPLEFREQS[16] = |
10012
f8f3f8b4e0d7
DTS support by Peter Schuller <peterschueller@telemed.de> (revised by arpi)
alex
parents:
8026
diff
changeset
|
228 { |
f8f3f8b4e0d7
DTS support by Peter Schuller <peterschueller@telemed.de> (revised by arpi)
alex
parents:
8026
diff
changeset
|
229 0, |
f8f3f8b4e0d7
DTS support by Peter Schuller <peterschueller@telemed.de> (revised by arpi)
alex
parents:
8026
diff
changeset
|
230 8000, |
f8f3f8b4e0d7
DTS support by Peter Schuller <peterschueller@telemed.de> (revised by arpi)
alex
parents:
8026
diff
changeset
|
231 16000, |
f8f3f8b4e0d7
DTS support by Peter Schuller <peterschueller@telemed.de> (revised by arpi)
alex
parents:
8026
diff
changeset
|
232 32000, |
f8f3f8b4e0d7
DTS support by Peter Schuller <peterschueller@telemed.de> (revised by arpi)
alex
parents:
8026
diff
changeset
|
233 64000, |
f8f3f8b4e0d7
DTS support by Peter Schuller <peterschueller@telemed.de> (revised by arpi)
alex
parents:
8026
diff
changeset
|
234 128000, |
f8f3f8b4e0d7
DTS support by Peter Schuller <peterschueller@telemed.de> (revised by arpi)
alex
parents:
8026
diff
changeset
|
235 11025, |
f8f3f8b4e0d7
DTS support by Peter Schuller <peterschueller@telemed.de> (revised by arpi)
alex
parents:
8026
diff
changeset
|
236 22050, |
f8f3f8b4e0d7
DTS support by Peter Schuller <peterschueller@telemed.de> (revised by arpi)
alex
parents:
8026
diff
changeset
|
237 44100, |
f8f3f8b4e0d7
DTS support by Peter Schuller <peterschueller@telemed.de> (revised by arpi)
alex
parents:
8026
diff
changeset
|
238 88200, |
f8f3f8b4e0d7
DTS support by Peter Schuller <peterschueller@telemed.de> (revised by arpi)
alex
parents:
8026
diff
changeset
|
239 176400, |
f8f3f8b4e0d7
DTS support by Peter Schuller <peterschueller@telemed.de> (revised by arpi)
alex
parents:
8026
diff
changeset
|
240 12000, |
f8f3f8b4e0d7
DTS support by Peter Schuller <peterschueller@telemed.de> (revised by arpi)
alex
parents:
8026
diff
changeset
|
241 24000, |
f8f3f8b4e0d7
DTS support by Peter Schuller <peterschueller@telemed.de> (revised by arpi)
alex
parents:
8026
diff
changeset
|
242 48000, |
f8f3f8b4e0d7
DTS support by Peter Schuller <peterschueller@telemed.de> (revised by arpi)
alex
parents:
8026
diff
changeset
|
243 96000, |
f8f3f8b4e0d7
DTS support by Peter Schuller <peterschueller@telemed.de> (revised by arpi)
alex
parents:
8026
diff
changeset
|
244 192000 |
f8f3f8b4e0d7
DTS support by Peter Schuller <peterschueller@telemed.de> (revised by arpi)
alex
parents:
8026
diff
changeset
|
245 }; |
5370 | 246 |
24435 | 247 static const int DTS_BITRATES[30] = |
10012
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 32000, |
f8f3f8b4e0d7
DTS support by Peter Schuller <peterschueller@telemed.de> (revised by arpi)
alex
parents:
8026
diff
changeset
|
250 56000, |
f8f3f8b4e0d7
DTS support by Peter Schuller <peterschueller@telemed.de> (revised by arpi)
alex
parents:
8026
diff
changeset
|
251 64000, |
f8f3f8b4e0d7
DTS support by Peter Schuller <peterschueller@telemed.de> (revised by arpi)
alex
parents:
8026
diff
changeset
|
252 96000, |
f8f3f8b4e0d7
DTS support by Peter Schuller <peterschueller@telemed.de> (revised by arpi)
alex
parents:
8026
diff
changeset
|
253 112000, |
f8f3f8b4e0d7
DTS support by Peter Schuller <peterschueller@telemed.de> (revised by arpi)
alex
parents:
8026
diff
changeset
|
254 128000, |
f8f3f8b4e0d7
DTS support by Peter Schuller <peterschueller@telemed.de> (revised by arpi)
alex
parents:
8026
diff
changeset
|
255 192000, |
f8f3f8b4e0d7
DTS support by Peter Schuller <peterschueller@telemed.de> (revised by arpi)
alex
parents:
8026
diff
changeset
|
256 224000, |
f8f3f8b4e0d7
DTS support by Peter Schuller <peterschueller@telemed.de> (revised by arpi)
alex
parents:
8026
diff
changeset
|
257 256000, |
f8f3f8b4e0d7
DTS support by Peter Schuller <peterschueller@telemed.de> (revised by arpi)
alex
parents:
8026
diff
changeset
|
258 320000, |
f8f3f8b4e0d7
DTS support by Peter Schuller <peterschueller@telemed.de> (revised by arpi)
alex
parents:
8026
diff
changeset
|
259 384000, |
f8f3f8b4e0d7
DTS support by Peter Schuller <peterschueller@telemed.de> (revised by arpi)
alex
parents:
8026
diff
changeset
|
260 448000, |
f8f3f8b4e0d7
DTS support by Peter Schuller <peterschueller@telemed.de> (revised by arpi)
alex
parents:
8026
diff
changeset
|
261 512000, |
f8f3f8b4e0d7
DTS support by Peter Schuller <peterschueller@telemed.de> (revised by arpi)
alex
parents:
8026
diff
changeset
|
262 576000, |
f8f3f8b4e0d7
DTS support by Peter Schuller <peterschueller@telemed.de> (revised by arpi)
alex
parents:
8026
diff
changeset
|
263 640000, |
f8f3f8b4e0d7
DTS support by Peter Schuller <peterschueller@telemed.de> (revised by arpi)
alex
parents:
8026
diff
changeset
|
264 768000, |
f8f3f8b4e0d7
DTS support by Peter Schuller <peterschueller@telemed.de> (revised by arpi)
alex
parents:
8026
diff
changeset
|
265 896000, |
f8f3f8b4e0d7
DTS support by Peter Schuller <peterschueller@telemed.de> (revised by arpi)
alex
parents:
8026
diff
changeset
|
266 1024000, |
f8f3f8b4e0d7
DTS support by Peter Schuller <peterschueller@telemed.de> (revised by arpi)
alex
parents:
8026
diff
changeset
|
267 1152000, |
f8f3f8b4e0d7
DTS support by Peter Schuller <peterschueller@telemed.de> (revised by arpi)
alex
parents:
8026
diff
changeset
|
268 1280000, |
f8f3f8b4e0d7
DTS support by Peter Schuller <peterschueller@telemed.de> (revised by arpi)
alex
parents:
8026
diff
changeset
|
269 1344000, |
f8f3f8b4e0d7
DTS support by Peter Schuller <peterschueller@telemed.de> (revised by arpi)
alex
parents:
8026
diff
changeset
|
270 1408000, |
f8f3f8b4e0d7
DTS support by Peter Schuller <peterschueller@telemed.de> (revised by arpi)
alex
parents:
8026
diff
changeset
|
271 1411200, |
f8f3f8b4e0d7
DTS support by Peter Schuller <peterschueller@telemed.de> (revised by arpi)
alex
parents:
8026
diff
changeset
|
272 1472000, |
f8f3f8b4e0d7
DTS support by Peter Schuller <peterschueller@telemed.de> (revised by arpi)
alex
parents:
8026
diff
changeset
|
273 1536000, |
f8f3f8b4e0d7
DTS support by Peter Schuller <peterschueller@telemed.de> (revised by arpi)
alex
parents:
8026
diff
changeset
|
274 1920000, |
f8f3f8b4e0d7
DTS support by Peter Schuller <peterschueller@telemed.de> (revised by arpi)
alex
parents:
8026
diff
changeset
|
275 2048000, |
f8f3f8b4e0d7
DTS support by Peter Schuller <peterschueller@telemed.de> (revised by arpi)
alex
parents:
8026
diff
changeset
|
276 3072000, |
f8f3f8b4e0d7
DTS support by Peter Schuller <peterschueller@telemed.de> (revised by arpi)
alex
parents:
8026
diff
changeset
|
277 3840000, |
f8f3f8b4e0d7
DTS support by Peter Schuller <peterschueller@telemed.de> (revised by arpi)
alex
parents:
8026
diff
changeset
|
278 4096000 |
f8f3f8b4e0d7
DTS support by Peter Schuller <peterschueller@telemed.de> (revised by arpi)
alex
parents:
8026
diff
changeset
|
279 }; |
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 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
|
282 { |
f8f3f8b4e0d7
DTS support by Peter Schuller <peterschueller@telemed.de> (revised by arpi)
alex
parents:
8026
diff
changeset
|
283 int ftype; |
f8f3f8b4e0d7
DTS support by Peter Schuller <peterschueller@telemed.de> (revised by arpi)
alex
parents:
8026
diff
changeset
|
284 int surp; |
f8f3f8b4e0d7
DTS support by Peter Schuller <peterschueller@telemed.de> (revised by arpi)
alex
parents:
8026
diff
changeset
|
285 int unknown_bit; |
f8f3f8b4e0d7
DTS support by Peter Schuller <peterschueller@telemed.de> (revised by arpi)
alex
parents:
8026
diff
changeset
|
286 int fsize; |
f8f3f8b4e0d7
DTS support by Peter Schuller <peterschueller@telemed.de> (revised by arpi)
alex
parents:
8026
diff
changeset
|
287 int amode; |
f8f3f8b4e0d7
DTS support by Peter Schuller <peterschueller@telemed.de> (revised by arpi)
alex
parents:
8026
diff
changeset
|
288 |
25102
55d8b87b62da
Make hwdts support more dts format identification, 14bits or 16bits, LE or BE.
ulion
parents:
24509
diff
changeset
|
289 int word_mode; |
55d8b87b62da
Make hwdts support more dts format identification, 14bits or 16bits, LE or BE.
ulion
parents:
24509
diff
changeset
|
290 int le_mode; |
10012
f8f3f8b4e0d7
DTS support by Peter Schuller <peterschueller@telemed.de> (revised by arpi)
alex
parents:
8026
diff
changeset
|
291 |
25102
55d8b87b62da
Make hwdts support more dts format identification, 14bits or 16bits, LE or BE.
ulion
parents:
24509
diff
changeset
|
292 unsigned int first4bytes = indata_ptr[0] << 24 | indata_ptr[1] << 16 |
55d8b87b62da
Make hwdts support more dts format identification, 14bits or 16bits, LE or BE.
ulion
parents:
24509
diff
changeset
|
293 | indata_ptr[2] << 8 | indata_ptr[3]; |
10012
f8f3f8b4e0d7
DTS support by Peter Schuller <peterschueller@telemed.de> (revised by arpi)
alex
parents:
8026
diff
changeset
|
294 |
25102
55d8b87b62da
Make hwdts support more dts format identification, 14bits or 16bits, LE or BE.
ulion
parents:
24509
diff
changeset
|
295 switch(first4bytes) |
55d8b87b62da
Make hwdts support more dts format identification, 14bits or 16bits, LE or BE.
ulion
parents:
24509
diff
changeset
|
296 { |
55d8b87b62da
Make hwdts support more dts format identification, 14bits or 16bits, LE or BE.
ulion
parents:
24509
diff
changeset
|
297 /* 14 bits LE */ |
55d8b87b62da
Make hwdts support more dts format identification, 14bits or 16bits, LE or BE.
ulion
parents:
24509
diff
changeset
|
298 case 0xff1f00e8: |
55d8b87b62da
Make hwdts support more dts format identification, 14bits or 16bits, LE or BE.
ulion
parents:
24509
diff
changeset
|
299 /* Also make sure frame type is 1. */ |
55d8b87b62da
Make hwdts support more dts format identification, 14bits or 16bits, LE or BE.
ulion
parents:
24509
diff
changeset
|
300 if ((indata_ptr[4]&0xf0) != 0xf0 || indata_ptr[5] != 0x07) |
55d8b87b62da
Make hwdts support more dts format identification, 14bits or 16bits, LE or BE.
ulion
parents:
24509
diff
changeset
|
301 return -1; |
55d8b87b62da
Make hwdts support more dts format identification, 14bits or 16bits, LE or BE.
ulion
parents:
24509
diff
changeset
|
302 word_mode = 0; |
55d8b87b62da
Make hwdts support more dts format identification, 14bits or 16bits, LE or BE.
ulion
parents:
24509
diff
changeset
|
303 le_mode = 1; |
55d8b87b62da
Make hwdts support more dts format identification, 14bits or 16bits, LE or BE.
ulion
parents:
24509
diff
changeset
|
304 break; |
55d8b87b62da
Make hwdts support more dts format identification, 14bits or 16bits, LE or BE.
ulion
parents:
24509
diff
changeset
|
305 /* 14 bits BE */ |
55d8b87b62da
Make hwdts support more dts format identification, 14bits or 16bits, LE or BE.
ulion
parents:
24509
diff
changeset
|
306 case 0x1fffe800: |
55d8b87b62da
Make hwdts support more dts format identification, 14bits or 16bits, LE or BE.
ulion
parents:
24509
diff
changeset
|
307 /* Also make sure frame type is 1. */ |
55d8b87b62da
Make hwdts support more dts format identification, 14bits or 16bits, LE or BE.
ulion
parents:
24509
diff
changeset
|
308 if (indata_ptr[4] != 0x07 || (indata_ptr[5]&0xf0) != 0xf0) |
55d8b87b62da
Make hwdts support more dts format identification, 14bits or 16bits, LE or BE.
ulion
parents:
24509
diff
changeset
|
309 return -1; |
55d8b87b62da
Make hwdts support more dts format identification, 14bits or 16bits, LE or BE.
ulion
parents:
24509
diff
changeset
|
310 word_mode = 0; |
55d8b87b62da
Make hwdts support more dts format identification, 14bits or 16bits, LE or BE.
ulion
parents:
24509
diff
changeset
|
311 le_mode = 0; |
55d8b87b62da
Make hwdts support more dts format identification, 14bits or 16bits, LE or BE.
ulion
parents:
24509
diff
changeset
|
312 break; |
55d8b87b62da
Make hwdts support more dts format identification, 14bits or 16bits, LE or BE.
ulion
parents:
24509
diff
changeset
|
313 /* 16 bits LE */ |
55d8b87b62da
Make hwdts support more dts format identification, 14bits or 16bits, LE or BE.
ulion
parents:
24509
diff
changeset
|
314 case 0xfe7f0180: |
55d8b87b62da
Make hwdts support more dts format identification, 14bits or 16bits, LE or BE.
ulion
parents:
24509
diff
changeset
|
315 word_mode = 1; |
55d8b87b62da
Make hwdts support more dts format identification, 14bits or 16bits, LE or BE.
ulion
parents:
24509
diff
changeset
|
316 le_mode = 1; |
55d8b87b62da
Make hwdts support more dts format identification, 14bits or 16bits, LE or BE.
ulion
parents:
24509
diff
changeset
|
317 break; |
55d8b87b62da
Make hwdts support more dts format identification, 14bits or 16bits, LE or BE.
ulion
parents:
24509
diff
changeset
|
318 /* 16 bits BE */ |
55d8b87b62da
Make hwdts support more dts format identification, 14bits or 16bits, LE or BE.
ulion
parents:
24509
diff
changeset
|
319 case 0x7ffe8001: |
55d8b87b62da
Make hwdts support more dts format identification, 14bits or 16bits, LE or BE.
ulion
parents:
24509
diff
changeset
|
320 word_mode = 1; |
55d8b87b62da
Make hwdts support more dts format identification, 14bits or 16bits, LE or BE.
ulion
parents:
24509
diff
changeset
|
321 le_mode = 0; |
55d8b87b62da
Make hwdts support more dts format identification, 14bits or 16bits, LE or BE.
ulion
parents:
24509
diff
changeset
|
322 break; |
55d8b87b62da
Make hwdts support more dts format identification, 14bits or 16bits, LE or BE.
ulion
parents:
24509
diff
changeset
|
323 default: |
55d8b87b62da
Make hwdts support more dts format identification, 14bits or 16bits, LE or BE.
ulion
parents:
24509
diff
changeset
|
324 return -1; |
55d8b87b62da
Make hwdts support more dts format identification, 14bits or 16bits, LE or BE.
ulion
parents:
24509
diff
changeset
|
325 } |
5370 | 326 |
25102
55d8b87b62da
Make hwdts support more dts format identification, 14bits or 16bits, LE or BE.
ulion
parents:
24509
diff
changeset
|
327 if(word_mode) |
55d8b87b62da
Make hwdts support more dts format identification, 14bits or 16bits, LE or BE.
ulion
parents:
24509
diff
changeset
|
328 { |
55d8b87b62da
Make hwdts support more dts format identification, 14bits or 16bits, LE or BE.
ulion
parents:
24509
diff
changeset
|
329 /* First bit after first 32 bits: |
55d8b87b62da
Make hwdts support more dts format identification, 14bits or 16bits, LE or BE.
ulion
parents:
24509
diff
changeset
|
330 Frame type ( 1: Normal frame; 0: Termination frame ) */ |
55d8b87b62da
Make hwdts support more dts format identification, 14bits or 16bits, LE or BE.
ulion
parents:
24509
diff
changeset
|
331 ftype = indata_ptr[4+le_mode] >> 7; |
55d8b87b62da
Make hwdts support more dts format identification, 14bits or 16bits, LE or BE.
ulion
parents:
24509
diff
changeset
|
332 |
29263
0f1b5b68af32
whitespace cosmetics: Remove all trailing whitespace.
diego
parents:
28445
diff
changeset
|
333 if(ftype != 1) |
10012
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 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
|
336 return -1; |
f8f3f8b4e0d7
DTS support by Peter Schuller <peterschueller@telemed.de> (revised by arpi)
alex
parents:
8026
diff
changeset
|
337 } |
25102
55d8b87b62da
Make hwdts support more dts format identification, 14bits or 16bits, LE or BE.
ulion
parents:
24509
diff
changeset
|
338 /* Next 5 bits: Surplus Sample Count V SURP 5 bits */ |
55d8b87b62da
Make hwdts support more dts format identification, 14bits or 16bits, LE or BE.
ulion
parents:
24509
diff
changeset
|
339 surp = indata_ptr[4+le_mode] >> 2 & 0x1f; |
55d8b87b62da
Make hwdts support more dts format identification, 14bits or 16bits, LE or BE.
ulion
parents:
24509
diff
changeset
|
340 /* Number of surplus samples */ |
55d8b87b62da
Make hwdts support more dts format identification, 14bits or 16bits, LE or BE.
ulion
parents:
24509
diff
changeset
|
341 surp = (surp + 1) % 32; |
55d8b87b62da
Make hwdts support more dts format identification, 14bits or 16bits, LE or BE.
ulion
parents:
24509
diff
changeset
|
342 |
55d8b87b62da
Make hwdts support more dts format identification, 14bits or 16bits, LE or BE.
ulion
parents:
24509
diff
changeset
|
343 /* One unknown bit, crc? */ |
55d8b87b62da
Make hwdts support more dts format identification, 14bits or 16bits, LE or BE.
ulion
parents:
24509
diff
changeset
|
344 unknown_bit = indata_ptr[4+le_mode] >> 1 & 0x01; |
55d8b87b62da
Make hwdts support more dts format identification, 14bits or 16bits, LE or BE.
ulion
parents:
24509
diff
changeset
|
345 |
55d8b87b62da
Make hwdts support more dts format identification, 14bits or 16bits, LE or BE.
ulion
parents:
24509
diff
changeset
|
346 /* NBLKS 7 bits: Valid Range=5-127, Invalid Range=0-4 */ |
55d8b87b62da
Make hwdts support more dts format identification, 14bits or 16bits, LE or BE.
ulion
parents:
24509
diff
changeset
|
347 *nblks = (indata_ptr[4+le_mode] & 0x01) << 6 | indata_ptr[5-le_mode] >> 2; |
55d8b87b62da
Make hwdts support more dts format identification, 14bits or 16bits, LE or BE.
ulion
parents:
24509
diff
changeset
|
348 /* NBLKS+1 indicates the number of 32 sample PCM audio blocks per channel |
55d8b87b62da
Make hwdts support more dts format identification, 14bits or 16bits, LE or BE.
ulion
parents:
24509
diff
changeset
|
349 encoded in the current frame per channel. */ |
55d8b87b62da
Make hwdts support more dts format identification, 14bits or 16bits, LE or BE.
ulion
parents:
24509
diff
changeset
|
350 ++(*nblks); |
55d8b87b62da
Make hwdts support more dts format identification, 14bits or 16bits, LE or BE.
ulion
parents:
24509
diff
changeset
|
351 |
55d8b87b62da
Make hwdts support more dts format identification, 14bits or 16bits, LE or BE.
ulion
parents:
24509
diff
changeset
|
352 /* Frame Byte Size V FSIZE 14 bits: 0-94=Invalid, 95-8191=Valid range-1 |
55d8b87b62da
Make hwdts support more dts format identification, 14bits or 16bits, LE or BE.
ulion
parents:
24509
diff
changeset
|
353 (ie. 96 bytes to 8192 bytes), 8192-16383=Invalid |
55d8b87b62da
Make hwdts support more dts format identification, 14bits or 16bits, LE or BE.
ulion
parents:
24509
diff
changeset
|
354 FSIZE defines the byte size of the current audio frame. */ |
55d8b87b62da
Make hwdts support more dts format identification, 14bits or 16bits, LE or BE.
ulion
parents:
24509
diff
changeset
|
355 fsize = (indata_ptr[5-le_mode] & 0x03) << 12 | indata_ptr[6+le_mode] << 4 |
55d8b87b62da
Make hwdts support more dts format identification, 14bits or 16bits, LE or BE.
ulion
parents:
24509
diff
changeset
|
356 | indata_ptr[7-le_mode] >> 4; |
55d8b87b62da
Make hwdts support more dts format identification, 14bits or 16bits, LE or BE.
ulion
parents:
24509
diff
changeset
|
357 ++fsize; |
55d8b87b62da
Make hwdts support more dts format identification, 14bits or 16bits, LE or BE.
ulion
parents:
24509
diff
changeset
|
358 |
55d8b87b62da
Make hwdts support more dts format identification, 14bits or 16bits, LE or BE.
ulion
parents:
24509
diff
changeset
|
359 /* Audio Channel Arrangement ACC AMODE 6 bits */ |
55d8b87b62da
Make hwdts support more dts format identification, 14bits or 16bits, LE or BE.
ulion
parents:
24509
diff
changeset
|
360 amode = (indata_ptr[7-le_mode] & 0x0f) << 2 | indata_ptr[8+le_mode] >> 6; |
55d8b87b62da
Make hwdts support more dts format identification, 14bits or 16bits, LE or BE.
ulion
parents:
24509
diff
changeset
|
361 |
55d8b87b62da
Make hwdts support more dts format identification, 14bits or 16bits, LE or BE.
ulion
parents:
24509
diff
changeset
|
362 /* Source Sampling rate ACC SFREQ 4 bits */ |
55d8b87b62da
Make hwdts support more dts format identification, 14bits or 16bits, LE or BE.
ulion
parents:
24509
diff
changeset
|
363 *sfreq = indata_ptr[8+le_mode] >> 2 & 0x0f; |
55d8b87b62da
Make hwdts support more dts format identification, 14bits or 16bits, LE or BE.
ulion
parents:
24509
diff
changeset
|
364 /* Transmission Bit Rate ACC RATE 5 bits */ |
55d8b87b62da
Make hwdts support more dts format identification, 14bits or 16bits, LE or BE.
ulion
parents:
24509
diff
changeset
|
365 *rate = (indata_ptr[8+le_mode] & 0x03) << 3 |
55d8b87b62da
Make hwdts support more dts format identification, 14bits or 16bits, LE or BE.
ulion
parents:
24509
diff
changeset
|
366 | (indata_ptr[9-le_mode] >> 5 & 0x07); |
55d8b87b62da
Make hwdts support more dts format identification, 14bits or 16bits, LE or BE.
ulion
parents:
24509
diff
changeset
|
367 } |
55d8b87b62da
Make hwdts support more dts format identification, 14bits or 16bits, LE or BE.
ulion
parents:
24509
diff
changeset
|
368 else |
55d8b87b62da
Make hwdts support more dts format identification, 14bits or 16bits, LE or BE.
ulion
parents:
24509
diff
changeset
|
369 { |
55d8b87b62da
Make hwdts support more dts format identification, 14bits or 16bits, LE or BE.
ulion
parents:
24509
diff
changeset
|
370 /* in the case judgement, we assure this */ |
55d8b87b62da
Make hwdts support more dts format identification, 14bits or 16bits, LE or BE.
ulion
parents:
24509
diff
changeset
|
371 ftype = 1; |
55d8b87b62da
Make hwdts support more dts format identification, 14bits or 16bits, LE or BE.
ulion
parents:
24509
diff
changeset
|
372 surp = 0; |
55d8b87b62da
Make hwdts support more dts format identification, 14bits or 16bits, LE or BE.
ulion
parents:
24509
diff
changeset
|
373 /* 14 bits support, every 2 bytes, & 0x3fff, got used 14 bits */ |
55d8b87b62da
Make hwdts support more dts format identification, 14bits or 16bits, LE or BE.
ulion
parents:
24509
diff
changeset
|
374 /* Bits usage: |
55d8b87b62da
Make hwdts support more dts format identification, 14bits or 16bits, LE or BE.
ulion
parents:
24509
diff
changeset
|
375 32 bits: Sync code (28 + 4) 1th and 2th word, 4 bits in 3th word |
55d8b87b62da
Make hwdts support more dts format identification, 14bits or 16bits, LE or BE.
ulion
parents:
24509
diff
changeset
|
376 1 bits: Frame type 1 bits in 3th word |
55d8b87b62da
Make hwdts support more dts format identification, 14bits or 16bits, LE or BE.
ulion
parents:
24509
diff
changeset
|
377 5 bits: SURP 5 bits in 3th word |
55d8b87b62da
Make hwdts support more dts format identification, 14bits or 16bits, LE or BE.
ulion
parents:
24509
diff
changeset
|
378 1 bits: crc? 1 bits in 3th word |
55d8b87b62da
Make hwdts support more dts format identification, 14bits or 16bits, LE or BE.
ulion
parents:
24509
diff
changeset
|
379 7 bits: NBLKS 3 bits in 3th word, 4 bits in 4th word |
55d8b87b62da
Make hwdts support more dts format identification, 14bits or 16bits, LE or BE.
ulion
parents:
24509
diff
changeset
|
380 14 bits: FSIZE 10 bits in 4th word, 4 bits in 5th word |
55d8b87b62da
Make hwdts support more dts format identification, 14bits or 16bits, LE or BE.
ulion
parents:
24509
diff
changeset
|
381 in 14 bits mode, FSIZE = FSIZE*8/14*2 |
55d8b87b62da
Make hwdts support more dts format identification, 14bits or 16bits, LE or BE.
ulion
parents:
24509
diff
changeset
|
382 6 bits: AMODE 6 bits in 5th word |
55d8b87b62da
Make hwdts support more dts format identification, 14bits or 16bits, LE or BE.
ulion
parents:
24509
diff
changeset
|
383 4 bits: SFREQ 4 bits in 5th word |
55d8b87b62da
Make hwdts support more dts format identification, 14bits or 16bits, LE or BE.
ulion
parents:
24509
diff
changeset
|
384 5 bits: RATE 5 bits in 6th word |
55d8b87b62da
Make hwdts support more dts format identification, 14bits or 16bits, LE or BE.
ulion
parents:
24509
diff
changeset
|
385 total bits: 75 bits */ |
55d8b87b62da
Make hwdts support more dts format identification, 14bits or 16bits, LE or BE.
ulion
parents:
24509
diff
changeset
|
386 |
55d8b87b62da
Make hwdts support more dts format identification, 14bits or 16bits, LE or BE.
ulion
parents:
24509
diff
changeset
|
387 /* NBLKS 7 bits: Valid Range=5-127, Invalid Range=0-4 */ |
55d8b87b62da
Make hwdts support more dts format identification, 14bits or 16bits, LE or BE.
ulion
parents:
24509
diff
changeset
|
388 *nblks = (indata_ptr[5-le_mode] & 0x07) << 4 |
55d8b87b62da
Make hwdts support more dts format identification, 14bits or 16bits, LE or BE.
ulion
parents:
24509
diff
changeset
|
389 | (indata_ptr[6+le_mode] & 0x3f) >> 2; |
55d8b87b62da
Make hwdts support more dts format identification, 14bits or 16bits, LE or BE.
ulion
parents:
24509
diff
changeset
|
390 /* NBLKS+1 indicates the number of 32 sample PCM audio blocks per channel |
55d8b87b62da
Make hwdts support more dts format identification, 14bits or 16bits, LE or BE.
ulion
parents:
24509
diff
changeset
|
391 encoded in the current frame per channel. */ |
55d8b87b62da
Make hwdts support more dts format identification, 14bits or 16bits, LE or BE.
ulion
parents:
24509
diff
changeset
|
392 ++(*nblks); |
55d8b87b62da
Make hwdts support more dts format identification, 14bits or 16bits, LE or BE.
ulion
parents:
24509
diff
changeset
|
393 |
55d8b87b62da
Make hwdts support more dts format identification, 14bits or 16bits, LE or BE.
ulion
parents:
24509
diff
changeset
|
394 /* Frame Byte Size V FSIZE 14 bits: 0-94=Invalid, 95-8191=Valid range-1 |
55d8b87b62da
Make hwdts support more dts format identification, 14bits or 16bits, LE or BE.
ulion
parents:
24509
diff
changeset
|
395 (ie. 96 bytes to 8192 bytes), 8192-16383=Invalid |
55d8b87b62da
Make hwdts support more dts format identification, 14bits or 16bits, LE or BE.
ulion
parents:
24509
diff
changeset
|
396 FSIZE defines the byte size of the current audio frame. */ |
55d8b87b62da
Make hwdts support more dts format identification, 14bits or 16bits, LE or BE.
ulion
parents:
24509
diff
changeset
|
397 fsize = (indata_ptr[6+le_mode] & 0x03) << 12 | indata_ptr[7-le_mode] << 4 |
55d8b87b62da
Make hwdts support more dts format identification, 14bits or 16bits, LE or BE.
ulion
parents:
24509
diff
changeset
|
398 | (indata_ptr[8+le_mode] & 0x3f) >> 2; |
55d8b87b62da
Make hwdts support more dts format identification, 14bits or 16bits, LE or BE.
ulion
parents:
24509
diff
changeset
|
399 ++fsize; |
55d8b87b62da
Make hwdts support more dts format identification, 14bits or 16bits, LE or BE.
ulion
parents:
24509
diff
changeset
|
400 fsize = fsize * 8 / 14 * 2; |
55d8b87b62da
Make hwdts support more dts format identification, 14bits or 16bits, LE or BE.
ulion
parents:
24509
diff
changeset
|
401 |
55d8b87b62da
Make hwdts support more dts format identification, 14bits or 16bits, LE or BE.
ulion
parents:
24509
diff
changeset
|
402 /* Audio Channel Arrangement ACC AMODE 6 bits */ |
55d8b87b62da
Make hwdts support more dts format identification, 14bits or 16bits, LE or BE.
ulion
parents:
24509
diff
changeset
|
403 amode = (indata_ptr[8+le_mode] & 0x03) << 4 |
55d8b87b62da
Make hwdts support more dts format identification, 14bits or 16bits, LE or BE.
ulion
parents:
24509
diff
changeset
|
404 | (indata_ptr[9-le_mode] & 0xf0) >> 4; |
55d8b87b62da
Make hwdts support more dts format identification, 14bits or 16bits, LE or BE.
ulion
parents:
24509
diff
changeset
|
405 |
55d8b87b62da
Make hwdts support more dts format identification, 14bits or 16bits, LE or BE.
ulion
parents:
24509
diff
changeset
|
406 /* Source Sampling rate ACC SFREQ 4 bits */ |
55d8b87b62da
Make hwdts support more dts format identification, 14bits or 16bits, LE or BE.
ulion
parents:
24509
diff
changeset
|
407 *sfreq = indata_ptr[9-le_mode] & 0x0f; |
55d8b87b62da
Make hwdts support more dts format identification, 14bits or 16bits, LE or BE.
ulion
parents:
24509
diff
changeset
|
408 /* Transmission Bit Rate ACC RATE 5 bits */ |
55d8b87b62da
Make hwdts support more dts format identification, 14bits or 16bits, LE or BE.
ulion
parents:
24509
diff
changeset
|
409 *rate = (indata_ptr[10+le_mode] & 0x3f) >> 1; |
55d8b87b62da
Make hwdts support more dts format identification, 14bits or 16bits, LE or BE.
ulion
parents:
24509
diff
changeset
|
410 } |
25124
8809817b2266
Support convert 14-bit DTS stream into 16-bit stream if needed,
ulion
parents:
25102
diff
changeset
|
411 #if 0 |
29263
0f1b5b68af32
whitespace cosmetics: Remove all trailing whitespace.
diego
parents:
28445
diff
changeset
|
412 if(*sfreq != 13) |
10012
f8f3f8b4e0d7
DTS support by Peter Schuller <peterschueller@telemed.de> (revised by arpi)
alex
parents:
8026
diff
changeset
|
413 { |
f8f3f8b4e0d7
DTS support by Peter Schuller <peterschueller@telemed.de> (revised by arpi)
alex
parents:
8026
diff
changeset
|
414 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
|
415 return -1; |
f8f3f8b4e0d7
DTS support by Peter Schuller <peterschueller@telemed.de> (revised by arpi)
alex
parents:
8026
diff
changeset
|
416 } |
25124
8809817b2266
Support convert 14-bit DTS stream into 16-bit stream if needed,
ulion
parents:
25102
diff
changeset
|
417 #endif |
29263
0f1b5b68af32
whitespace cosmetics: Remove all trailing whitespace.
diego
parents:
28445
diff
changeset
|
418 if((fsize > 8192) || (fsize < 96)) |
10012
f8f3f8b4e0d7
DTS support by Peter Schuller <peterschueller@telemed.de> (revised by arpi)
alex
parents:
8026
diff
changeset
|
419 { |
f8f3f8b4e0d7
DTS support by Peter Schuller <peterschueller@telemed.de> (revised by arpi)
alex
parents:
8026
diff
changeset
|
420 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
|
421 return -1; |
f8f3f8b4e0d7
DTS support by Peter Schuller <peterschueller@telemed.de> (revised by arpi)
alex
parents:
8026
diff
changeset
|
422 } |
29263
0f1b5b68af32
whitespace cosmetics: Remove all trailing whitespace.
diego
parents:
28445
diff
changeset
|
423 |
10012
f8f3f8b4e0d7
DTS support by Peter Schuller <peterschueller@telemed.de> (revised by arpi)
alex
parents:
8026
diff
changeset
|
424 if(*nblks != 8 && |
f8f3f8b4e0d7
DTS support by Peter Schuller <peterschueller@telemed.de> (revised by arpi)
alex
parents:
8026
diff
changeset
|
425 *nblks != 16 && |
f8f3f8b4e0d7
DTS support by Peter Schuller <peterschueller@telemed.de> (revised by arpi)
alex
parents:
8026
diff
changeset
|
426 *nblks != 32 && |
f8f3f8b4e0d7
DTS support by Peter Schuller <peterschueller@telemed.de> (revised by arpi)
alex
parents:
8026
diff
changeset
|
427 *nblks != 64 && |
f8f3f8b4e0d7
DTS support by Peter Schuller <peterschueller@telemed.de> (revised by arpi)
alex
parents:
8026
diff
changeset
|
428 *nblks != 128 && |
29263
0f1b5b68af32
whitespace cosmetics: Remove all trailing whitespace.
diego
parents:
28445
diff
changeset
|
429 ftype == 1) |
10012
f8f3f8b4e0d7
DTS support by Peter Schuller <peterschueller@telemed.de> (revised by arpi)
alex
parents:
8026
diff
changeset
|
430 { |
10948
aebf939834c3
10l found by Dominik 'Rathann' Mierzejewski <dominik@rangers.eu.org>
alex
parents:
10012
diff
changeset
|
431 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
|
432 return -1; |
f8f3f8b4e0d7
DTS support by Peter Schuller <peterschueller@telemed.de> (revised by arpi)
alex
parents:
8026
diff
changeset
|
433 } |
29263
0f1b5b68af32
whitespace cosmetics: Remove all trailing whitespace.
diego
parents:
28445
diff
changeset
|
434 |
10012
f8f3f8b4e0d7
DTS support by Peter Schuller <peterschueller@telemed.de> (revised by arpi)
alex
parents:
8026
diff
changeset
|
435 return fsize; |
f8f3f8b4e0d7
DTS support by Peter Schuller <peterschueller@telemed.de> (revised by arpi)
alex
parents:
8026
diff
changeset
|
436 } |
5370 | 437 |
10012
f8f3f8b4e0d7
DTS support by Peter Schuller <peterschueller@telemed.de> (revised by arpi)
alex
parents:
8026
diff
changeset
|
438 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
|
439 { |
f8f3f8b4e0d7
DTS support by Peter Schuller <peterschueller@telemed.de> (revised by arpi)
alex
parents:
8026
diff
changeset
|
440 int nblks; |
f8f3f8b4e0d7
DTS support by Peter Schuller <peterschueller@telemed.de> (revised by arpi)
alex
parents:
8026
diff
changeset
|
441 int fsize; |
f8f3f8b4e0d7
DTS support by Peter Schuller <peterschueller@telemed.de> (revised by arpi)
alex
parents:
8026
diff
changeset
|
442 int rate; |
f8f3f8b4e0d7
DTS support by Peter Schuller <peterschueller@telemed.de> (revised by arpi)
alex
parents:
8026
diff
changeset
|
443 int sfreq; |
29263
0f1b5b68af32
whitespace cosmetics: Remove all trailing whitespace.
diego
parents:
28445
diff
changeset
|
444 |
10012
f8f3f8b4e0d7
DTS support by Peter Schuller <peterschueller@telemed.de> (revised by arpi)
alex
parents:
8026
diff
changeset
|
445 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
|
446 if(fsize >= 0) |
f8f3f8b4e0d7
DTS support by Peter Schuller <peterschueller@telemed.de> (revised by arpi)
alex
parents:
8026
diff
changeset
|
447 { |
f8f3f8b4e0d7
DTS support by Peter Schuller <peterschueller@telemed.de> (revised by arpi)
alex
parents:
8026
diff
changeset
|
448 if(rate >= 0 && rate <= 29) |
f8f3f8b4e0d7
DTS support by Peter Schuller <peterschueller@telemed.de> (revised by arpi)
alex
parents:
8026
diff
changeset
|
449 *bit_rate = DTS_BITRATES[rate]; |
f8f3f8b4e0d7
DTS support by Peter Schuller <peterschueller@telemed.de> (revised by arpi)
alex
parents:
8026
diff
changeset
|
450 else |
f8f3f8b4e0d7
DTS support by Peter Schuller <peterschueller@telemed.de> (revised by arpi)
alex
parents:
8026
diff
changeset
|
451 *bit_rate = 0; |
f8f3f8b4e0d7
DTS support by Peter Schuller <peterschueller@telemed.de> (revised by arpi)
alex
parents:
8026
diff
changeset
|
452 if(sfreq >= 1 && sfreq <= 15) |
f8f3f8b4e0d7
DTS support by Peter Schuller <peterschueller@telemed.de> (revised by arpi)
alex
parents:
8026
diff
changeset
|
453 *sample_rate = DTS_SAMPLEFREQS[sfreq]; |
f8f3f8b4e0d7
DTS support by Peter Schuller <peterschueller@telemed.de> (revised by arpi)
alex
parents:
8026
diff
changeset
|
454 else |
f8f3f8b4e0d7
DTS support by Peter Schuller <peterschueller@telemed.de> (revised by arpi)
alex
parents:
8026
diff
changeset
|
455 *sample_rate = 0; |
f8f3f8b4e0d7
DTS support by Peter Schuller <peterschueller@telemed.de> (revised by arpi)
alex
parents:
8026
diff
changeset
|
456 } |
f8f3f8b4e0d7
DTS support by Peter Schuller <peterschueller@telemed.de> (revised by arpi)
alex
parents:
8026
diff
changeset
|
457 return fsize; |
f8f3f8b4e0d7
DTS support by Peter Schuller <peterschueller@telemed.de> (revised by arpi)
alex
parents:
8026
diff
changeset
|
458 } |
f8f3f8b4e0d7
DTS support by Peter Schuller <peterschueller@telemed.de> (revised by arpi)
alex
parents:
8026
diff
changeset
|
459 |
25124
8809817b2266
Support convert 14-bit DTS stream into 16-bit stream if needed,
ulion
parents:
25102
diff
changeset
|
460 static int convert_14bits_to_16bits(const unsigned char *src, |
8809817b2266
Support convert 14-bit DTS stream into 16-bit stream if needed,
ulion
parents:
25102
diff
changeset
|
461 unsigned char *dest, |
8809817b2266
Support convert 14-bit DTS stream into 16-bit stream if needed,
ulion
parents:
25102
diff
changeset
|
462 int len, |
8809817b2266
Support convert 14-bit DTS stream into 16-bit stream if needed,
ulion
parents:
25102
diff
changeset
|
463 int is_le) |
8809817b2266
Support convert 14-bit DTS stream into 16-bit stream if needed,
ulion
parents:
25102
diff
changeset
|
464 { |
8809817b2266
Support convert 14-bit DTS stream into 16-bit stream if needed,
ulion
parents:
25102
diff
changeset
|
465 uint16_t *p = (uint16_t *)dest; |
25139
94e618df1dea
Simplify convert_14bits_to_16bits function in ad_hwac3
reimar
parents:
25124
diff
changeset
|
466 uint16_t buf = 0; |
25124
8809817b2266
Support convert 14-bit DTS stream into 16-bit stream if needed,
ulion
parents:
25102
diff
changeset
|
467 int spacebits = 16; |
25139
94e618df1dea
Simplify convert_14bits_to_16bits function in ad_hwac3
reimar
parents:
25124
diff
changeset
|
468 if (len <= 0) return 0; |
25124
8809817b2266
Support convert 14-bit DTS stream into 16-bit stream if needed,
ulion
parents:
25102
diff
changeset
|
469 while (len > 0) { |
8809817b2266
Support convert 14-bit DTS stream into 16-bit stream if needed,
ulion
parents:
25102
diff
changeset
|
470 uint16_t v; |
8809817b2266
Support convert 14-bit DTS stream into 16-bit stream if needed,
ulion
parents:
25102
diff
changeset
|
471 if (len == 1) |
8809817b2266
Support convert 14-bit DTS stream into 16-bit stream if needed,
ulion
parents:
25102
diff
changeset
|
472 v = is_le ? src[0] : src[0] << 8; |
8809817b2266
Support convert 14-bit DTS stream into 16-bit stream if needed,
ulion
parents:
25102
diff
changeset
|
473 else |
8809817b2266
Support convert 14-bit DTS stream into 16-bit stream if needed,
ulion
parents:
25102
diff
changeset
|
474 v = is_le ? src[1] << 8 | src[0] : src[0] << 8 | src[1]; |
25139
94e618df1dea
Simplify convert_14bits_to_16bits function in ad_hwac3
reimar
parents:
25124
diff
changeset
|
475 v <<= 2; |
25124
8809817b2266
Support convert 14-bit DTS stream into 16-bit stream if needed,
ulion
parents:
25102
diff
changeset
|
476 src += 2; |
8809817b2266
Support convert 14-bit DTS stream into 16-bit stream if needed,
ulion
parents:
25102
diff
changeset
|
477 len -= 2; |
25139
94e618df1dea
Simplify convert_14bits_to_16bits function in ad_hwac3
reimar
parents:
25124
diff
changeset
|
478 buf |= v >> (16 - spacebits); |
94e618df1dea
Simplify convert_14bits_to_16bits function in ad_hwac3
reimar
parents:
25124
diff
changeset
|
479 spacebits -= 14; |
94e618df1dea
Simplify convert_14bits_to_16bits function in ad_hwac3
reimar
parents:
25124
diff
changeset
|
480 if (spacebits < 0) { |
94e618df1dea
Simplify convert_14bits_to_16bits function in ad_hwac3
reimar
parents:
25124
diff
changeset
|
481 *p++ = buf; |
94e618df1dea
Simplify convert_14bits_to_16bits function in ad_hwac3
reimar
parents:
25124
diff
changeset
|
482 spacebits += 16; |
94e618df1dea
Simplify convert_14bits_to_16bits function in ad_hwac3
reimar
parents:
25124
diff
changeset
|
483 buf = v << (spacebits - 2); |
25124
8809817b2266
Support convert 14-bit DTS stream into 16-bit stream if needed,
ulion
parents:
25102
diff
changeset
|
484 } |
8809817b2266
Support convert 14-bit DTS stream into 16-bit stream if needed,
ulion
parents:
25102
diff
changeset
|
485 } |
25139
94e618df1dea
Simplify convert_14bits_to_16bits function in ad_hwac3
reimar
parents:
25124
diff
changeset
|
486 *p++ = buf; |
25124
8809817b2266
Support convert 14-bit DTS stream into 16-bit stream if needed,
ulion
parents:
25102
diff
changeset
|
487 return (unsigned char *)p - dest; |
8809817b2266
Support convert 14-bit DTS stream into 16-bit stream if needed,
ulion
parents:
25102
diff
changeset
|
488 } |
10012
f8f3f8b4e0d7
DTS support by Peter Schuller <peterschueller@telemed.de> (revised by arpi)
alex
parents:
8026
diff
changeset
|
489 |
f8f3f8b4e0d7
DTS support by Peter Schuller <peterschueller@telemed.de> (revised by arpi)
alex
parents:
8026
diff
changeset
|
490 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
|
491 { |
f8f3f8b4e0d7
DTS support by Peter Schuller <peterschueller@telemed.de> (revised by arpi)
alex
parents:
8026
diff
changeset
|
492 int nblks; |
f8f3f8b4e0d7
DTS support by Peter Schuller <peterschueller@telemed.de> (revised by arpi)
alex
parents:
8026
diff
changeset
|
493 int fsize; |
f8f3f8b4e0d7
DTS support by Peter Schuller <peterschueller@telemed.de> (revised by arpi)
alex
parents:
8026
diff
changeset
|
494 int rate; |
f8f3f8b4e0d7
DTS support by Peter Schuller <peterschueller@telemed.de> (revised by arpi)
alex
parents:
8026
diff
changeset
|
495 int sfreq; |
f8f3f8b4e0d7
DTS support by Peter Schuller <peterschueller@telemed.de> (revised by arpi)
alex
parents:
8026
diff
changeset
|
496 int nr_samples; |
25124
8809817b2266
Support convert 14-bit DTS stream into 16-bit stream if needed,
ulion
parents:
25102
diff
changeset
|
497 int convert_16bits = 0; |
24432
79fcacd73f9b
Simplify and fix big-endian hwac3 header generation code.
reimar
parents:
23734
diff
changeset
|
498 uint16_t *buf16 = (uint16_t *)buf; |
10012
f8f3f8b4e0d7
DTS support by Peter Schuller <peterschueller@telemed.de> (revised by arpi)
alex
parents:
8026
diff
changeset
|
499 |
f8f3f8b4e0d7
DTS support by Peter Schuller <peterschueller@telemed.de> (revised by arpi)
alex
parents:
8026
diff
changeset
|
500 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
|
501 if(fsize < 0) |
f8f3f8b4e0d7
DTS support by Peter Schuller <peterschueller@telemed.de> (revised by arpi)
alex
parents:
8026
diff
changeset
|
502 return -1; |
f8f3f8b4e0d7
DTS support by Peter Schuller <peterschueller@telemed.de> (revised by arpi)
alex
parents:
8026
diff
changeset
|
503 nr_samples = nblks * 32; |
f8f3f8b4e0d7
DTS support by Peter Schuller <peterschueller@telemed.de> (revised by arpi)
alex
parents:
8026
diff
changeset
|
504 |
24432
79fcacd73f9b
Simplify and fix big-endian hwac3 header generation code.
reimar
parents:
23734
diff
changeset
|
505 buf16[0] = 0xf872; /* iec 61937 */ |
24434 | 506 buf16[1] = 0x4e1f; /* syncword */ |
29263
0f1b5b68af32
whitespace cosmetics: Remove all trailing whitespace.
diego
parents:
28445
diff
changeset
|
507 switch(nr_samples) |
10012
f8f3f8b4e0d7
DTS support by Peter Schuller <peterschueller@telemed.de> (revised by arpi)
alex
parents:
8026
diff
changeset
|
508 { |
f8f3f8b4e0d7
DTS support by Peter Schuller <peterschueller@telemed.de> (revised by arpi)
alex
parents:
8026
diff
changeset
|
509 case 512: |
24432
79fcacd73f9b
Simplify and fix big-endian hwac3 header generation code.
reimar
parents:
23734
diff
changeset
|
510 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
|
511 break; |
f8f3f8b4e0d7
DTS support by Peter Schuller <peterschueller@telemed.de> (revised by arpi)
alex
parents:
8026
diff
changeset
|
512 case 1024: |
24432
79fcacd73f9b
Simplify and fix big-endian hwac3 header generation code.
reimar
parents:
23734
diff
changeset
|
513 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
|
514 break; |
f8f3f8b4e0d7
DTS support by Peter Schuller <peterschueller@telemed.de> (revised by arpi)
alex
parents:
8026
diff
changeset
|
515 case 2048: |
24432
79fcacd73f9b
Simplify and fix big-endian hwac3 header generation code.
reimar
parents:
23734
diff
changeset
|
516 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
|
517 break; |
f8f3f8b4e0d7
DTS support by Peter Schuller <peterschueller@telemed.de> (revised by arpi)
alex
parents:
8026
diff
changeset
|
518 default: |
f8f3f8b4e0d7
DTS support by Peter Schuller <peterschueller@telemed.de> (revised by arpi)
alex
parents:
8026
diff
changeset
|
519 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
|
520 buf16[2] = 0x0000; |
10012
f8f3f8b4e0d7
DTS support by Peter Schuller <peterschueller@telemed.de> (revised by arpi)
alex
parents:
8026
diff
changeset
|
521 break; |
f8f3f8b4e0d7
DTS support by Peter Schuller <peterschueller@telemed.de> (revised by arpi)
alex
parents:
8026
diff
changeset
|
522 } |
29263
0f1b5b68af32
whitespace cosmetics: Remove all trailing whitespace.
diego
parents:
28445
diff
changeset
|
523 |
10012
f8f3f8b4e0d7
DTS support by Peter Schuller <peterschueller@telemed.de> (revised by arpi)
alex
parents:
8026
diff
changeset
|
524 if(fsize + 8 > nr_samples * 2 * 2) |
f8f3f8b4e0d7
DTS support by Peter Schuller <peterschueller@telemed.de> (revised by arpi)
alex
parents:
8026
diff
changeset
|
525 { |
25124
8809817b2266
Support convert 14-bit DTS stream into 16-bit stream if needed,
ulion
parents:
25102
diff
changeset
|
526 // dts wav (14bits LE) match this condition, one way to passthrough |
8809817b2266
Support convert 14-bit DTS stream into 16-bit stream if needed,
ulion
parents:
25102
diff
changeset
|
527 // is not add iec 61937 header, decoders will notice the dts header |
8809817b2266
Support convert 14-bit DTS stream into 16-bit stream if needed,
ulion
parents:
25102
diff
changeset
|
528 // and identify the dts stream. Another way here is convert |
8809817b2266
Support convert 14-bit DTS stream into 16-bit stream if needed,
ulion
parents:
25102
diff
changeset
|
529 // the stream from 14 bits to 16 bits. |
8809817b2266
Support convert 14-bit DTS stream into 16-bit stream if needed,
ulion
parents:
25102
diff
changeset
|
530 if ((indata_ptr[0] == 0xff || indata_ptr[0] == 0x1f) |
8809817b2266
Support convert 14-bit DTS stream into 16-bit stream if needed,
ulion
parents:
25102
diff
changeset
|
531 && fsize * 14 / 16 + 8 <= nr_samples * 2 * 2) { |
8809817b2266
Support convert 14-bit DTS stream into 16-bit stream if needed,
ulion
parents:
25102
diff
changeset
|
532 // The input stream is 14 bits, we can shrink it to 16 bits |
8809817b2266
Support convert 14-bit DTS stream into 16-bit stream if needed,
ulion
parents:
25102
diff
changeset
|
533 // to save space for add the 61937 header |
25149 | 534 fsize = convert_14bits_to_16bits(indata_ptr, |
535 &buf[8], | |
25124
8809817b2266
Support convert 14-bit DTS stream into 16-bit stream if needed,
ulion
parents:
25102
diff
changeset
|
536 fsize, |
8809817b2266
Support convert 14-bit DTS stream into 16-bit stream if needed,
ulion
parents:
25102
diff
changeset
|
537 indata_ptr[0] == 0xff /* is LE */ |
8809817b2266
Support convert 14-bit DTS stream into 16-bit stream if needed,
ulion
parents:
25102
diff
changeset
|
538 ); |
8809817b2266
Support convert 14-bit DTS stream into 16-bit stream if needed,
ulion
parents:
25102
diff
changeset
|
539 mp_msg(MSGT_DECAUDIO, MSGL_DBG3, "DTS: shrink 14 bits stream to " |
8809817b2266
Support convert 14-bit DTS stream into 16-bit stream if needed,
ulion
parents:
25102
diff
changeset
|
540 "16 bits %02x%02x%02x%02x => %02x%02x%02x%02x, new size %d.\n", |
8809817b2266
Support convert 14-bit DTS stream into 16-bit stream if needed,
ulion
parents:
25102
diff
changeset
|
541 indata_ptr[0], indata_ptr[1], indata_ptr[2], indata_ptr[3], |
8809817b2266
Support convert 14-bit DTS stream into 16-bit stream if needed,
ulion
parents:
25102
diff
changeset
|
542 buf[8], buf[9], buf[10], buf[11], fsize); |
8809817b2266
Support convert 14-bit DTS stream into 16-bit stream if needed,
ulion
parents:
25102
diff
changeset
|
543 convert_16bits = 1; |
8809817b2266
Support convert 14-bit DTS stream into 16-bit stream if needed,
ulion
parents:
25102
diff
changeset
|
544 } |
8809817b2266
Support convert 14-bit DTS stream into 16-bit stream if needed,
ulion
parents:
25102
diff
changeset
|
545 else |
10012
f8f3f8b4e0d7
DTS support by Peter Schuller <peterschueller@telemed.de> (revised by arpi)
alex
parents:
8026
diff
changeset
|
546 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
|
547 } |
25124
8809817b2266
Support convert 14-bit DTS stream into 16-bit stream if needed,
ulion
parents:
25102
diff
changeset
|
548 |
8809817b2266
Support convert 14-bit DTS stream into 16-bit stream if needed,
ulion
parents:
25102
diff
changeset
|
549 buf16[3] = fsize << 3; |
8809817b2266
Support convert 14-bit DTS stream into 16-bit stream if needed,
ulion
parents:
25102
diff
changeset
|
550 |
8809817b2266
Support convert 14-bit DTS stream into 16-bit stream if needed,
ulion
parents:
25102
diff
changeset
|
551 if (!convert_16bits) { |
36162 | 552 int be_stream = indata_ptr[0] == 0x1f || indata_ptr[0] == 0x7f; |
553 if (be_stream == HAVE_BIGENDIAN) | |
554 memcpy(&buf[8], indata_ptr, fsize); | |
555 else | |
556 { | |
36163 | 557 int i = fsize >> 1; |
558 uint16_t *d = buf16 + 4; | |
559 uint8_t *s = indata_ptr; | |
560 while (i--) { | |
561 *d++ = HAVE_BIGENDIAN ? AV_RL16(s) : AV_RB16(s); | |
562 s += 2; | |
563 } | |
36162 | 564 if (fsize & 1) { |
36163 | 565 // treat as if there was an additional 0 |
566 *d++ = HAVE_BIGENDIAN ? *s : *s << 8; | |
36162 | 567 fsize++; |
568 } | |
569 } | |
25124
8809817b2266
Support convert 14-bit DTS stream into 16-bit stream if needed,
ulion
parents:
25102
diff
changeset
|
570 } |
10012
f8f3f8b4e0d7
DTS support by Peter Schuller <peterschueller@telemed.de> (revised by arpi)
alex
parents:
8026
diff
changeset
|
571 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
|
572 |
f8f3f8b4e0d7
DTS support by Peter Schuller <peterschueller@telemed.de> (revised by arpi)
alex
parents:
8026
diff
changeset
|
573 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
|
574 } |