Mercurial > mplayer.hg
annotate libmpdemux/aac_hdr.c @ 36802:621b61818a0f
configure: add -Zhigh-mem linker flag for OS/2
x264 encoder crashes due to memory allocation failure. This fixes the problem.
author | komh |
---|---|
date | Thu, 20 Feb 2014 13:59:34 +0000 |
parents | e5fc26f7067a |
children |
rev | line source |
---|---|
26327
fa91545f01bb
Split the aac header parsing out of aac demuxer to allow using libmpmux
albeu
parents:
diff
changeset
|
1 /* |
fa91545f01bb
Split the aac header parsing out of aac demuxer to allow using libmpmux
albeu
parents:
diff
changeset
|
2 * Copyright (C) 2005 Nico Sabbi |
fa91545f01bb
Split the aac header parsing out of aac demuxer to allow using libmpmux
albeu
parents:
diff
changeset
|
3 * |
fa91545f01bb
Split the aac header parsing out of aac demuxer to allow using libmpmux
albeu
parents:
diff
changeset
|
4 * This file is part of MPlayer. |
fa91545f01bb
Split the aac header parsing out of aac demuxer to allow using libmpmux
albeu
parents:
diff
changeset
|
5 * |
fa91545f01bb
Split the aac header parsing out of aac demuxer to allow using libmpmux
albeu
parents:
diff
changeset
|
6 * MPlayer is free software; you can redistribute it and/or modify |
fa91545f01bb
Split the aac header parsing out of aac demuxer to allow using libmpmux
albeu
parents:
diff
changeset
|
7 * it under the terms of the GNU General Public License as published by |
fa91545f01bb
Split the aac header parsing out of aac demuxer to allow using libmpmux
albeu
parents:
diff
changeset
|
8 * the Free Software Foundation; either version 2 of the License, or |
fa91545f01bb
Split the aac header parsing out of aac demuxer to allow using libmpmux
albeu
parents:
diff
changeset
|
9 * (at your option) any later version. |
fa91545f01bb
Split the aac header parsing out of aac demuxer to allow using libmpmux
albeu
parents:
diff
changeset
|
10 * |
fa91545f01bb
Split the aac header parsing out of aac demuxer to allow using libmpmux
albeu
parents:
diff
changeset
|
11 * MPlayer is distributed in the hope that it will be useful, |
fa91545f01bb
Split the aac header parsing out of aac demuxer to allow using libmpmux
albeu
parents:
diff
changeset
|
12 * but WITHOUT ANY WARRANTY; without even the implied warranty of |
fa91545f01bb
Split the aac header parsing out of aac demuxer to allow using libmpmux
albeu
parents:
diff
changeset
|
13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
fa91545f01bb
Split the aac header parsing out of aac demuxer to allow using libmpmux
albeu
parents:
diff
changeset
|
14 * GNU General Public License for more details. |
fa91545f01bb
Split the aac header parsing out of aac demuxer to allow using libmpmux
albeu
parents:
diff
changeset
|
15 * |
fa91545f01bb
Split the aac header parsing out of aac demuxer to allow using libmpmux
albeu
parents:
diff
changeset
|
16 * You should have received a copy of the GNU General Public License along |
fa91545f01bb
Split the aac header parsing out of aac demuxer to allow using libmpmux
albeu
parents:
diff
changeset
|
17 * with MPlayer; if not, write to the Free Software Foundation, Inc., |
fa91545f01bb
Split the aac header parsing out of aac demuxer to allow using libmpmux
albeu
parents:
diff
changeset
|
18 * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. |
fa91545f01bb
Split the aac header parsing out of aac demuxer to allow using libmpmux
albeu
parents:
diff
changeset
|
19 */ |
fa91545f01bb
Split the aac header parsing out of aac demuxer to allow using libmpmux
albeu
parents:
diff
changeset
|
20 |
30548
cbbbe3d58f4c
Remove pointless header #includes; #include only required header stdint.h.
diego
parents:
29263
diff
changeset
|
21 #include <stdint.h> |
30574
928359c13d93
Add separate header for aac_parse_frame(); avoids forward declarations.
diego
parents:
30548
diff
changeset
|
22 #include "aac_hdr.h" |
26327
fa91545f01bb
Split the aac header parsing out of aac demuxer to allow using libmpmux
albeu
parents:
diff
changeset
|
23 |
fa91545f01bb
Split the aac header parsing out of aac demuxer to allow using libmpmux
albeu
parents:
diff
changeset
|
24 /// \param srate (out) sample rate |
fa91545f01bb
Split the aac header parsing out of aac demuxer to allow using libmpmux
albeu
parents:
diff
changeset
|
25 /// \param num (out) number of audio frames in this ADTS frame |
fa91545f01bb
Split the aac header parsing out of aac demuxer to allow using libmpmux
albeu
parents:
diff
changeset
|
26 /// \return size of the ADTS frame in bytes |
fa91545f01bb
Split the aac header parsing out of aac demuxer to allow using libmpmux
albeu
parents:
diff
changeset
|
27 /// aac_parse_frames needs a buffer at least 8 bytes long |
fa91545f01bb
Split the aac header parsing out of aac demuxer to allow using libmpmux
albeu
parents:
diff
changeset
|
28 int aac_parse_frame(uint8_t *buf, int *srate, int *num) |
fa91545f01bb
Split the aac header parsing out of aac demuxer to allow using libmpmux
albeu
parents:
diff
changeset
|
29 { |
36796
e5fc26f7067a
aac_hdr: remove variable to fix warning, add const.
reimar
parents:
30574
diff
changeset
|
30 int i = 0, sr, fl = 0; |
e5fc26f7067a
aac_hdr: remove variable to fix warning, add const.
reimar
parents:
30574
diff
changeset
|
31 static const int srates[] = {96000, 88200, 64000, 48000, 44100, 32000, 24000, 22050, 16000, 12000, 11025, 8000, 0, 0, 0}; |
29263
0f1b5b68af32
whitespace cosmetics: Remove all trailing whitespace.
diego
parents:
26327
diff
changeset
|
32 |
26327
fa91545f01bb
Split the aac header parsing out of aac demuxer to allow using libmpmux
albeu
parents:
diff
changeset
|
33 if((buf[i] != 0xFF) || ((buf[i+1] & 0xF6) != 0xF0)) |
fa91545f01bb
Split the aac header parsing out of aac demuxer to allow using libmpmux
albeu
parents:
diff
changeset
|
34 return 0; |
29263
0f1b5b68af32
whitespace cosmetics: Remove all trailing whitespace.
diego
parents:
26327
diff
changeset
|
35 |
26327
fa91545f01bb
Split the aac header parsing out of aac demuxer to allow using libmpmux
albeu
parents:
diff
changeset
|
36 sr = (buf[i+2] >> 2) & 0x0F; |
fa91545f01bb
Split the aac header parsing out of aac demuxer to allow using libmpmux
albeu
parents:
diff
changeset
|
37 if(sr > 11) |
fa91545f01bb
Split the aac header parsing out of aac demuxer to allow using libmpmux
albeu
parents:
diff
changeset
|
38 return 0; |
fa91545f01bb
Split the aac header parsing out of aac demuxer to allow using libmpmux
albeu
parents:
diff
changeset
|
39 *srate = srates[sr]; |
fa91545f01bb
Split the aac header parsing out of aac demuxer to allow using libmpmux
albeu
parents:
diff
changeset
|
40 |
fa91545f01bb
Split the aac header parsing out of aac demuxer to allow using libmpmux
albeu
parents:
diff
changeset
|
41 fl = ((buf[i+3] & 0x03) << 11) | (buf[i+4] << 3) | ((buf[i+5] >> 5) & 0x07); |
fa91545f01bb
Split the aac header parsing out of aac demuxer to allow using libmpmux
albeu
parents:
diff
changeset
|
42 *num = (buf[i+6] & 0x02) + 1; |
fa91545f01bb
Split the aac header parsing out of aac demuxer to allow using libmpmux
albeu
parents:
diff
changeset
|
43 |
fa91545f01bb
Split the aac header parsing out of aac demuxer to allow using libmpmux
albeu
parents:
diff
changeset
|
44 return fl; |
fa91545f01bb
Split the aac header parsing out of aac demuxer to allow using libmpmux
albeu
parents:
diff
changeset
|
45 } |