Mercurial > mplayer.hg
annotate libmpdemux/aac_hdr.c @ 28511:db19e31a2c7c
Add a calc_src_dst_rects that calculates from window size, panscan etc.
which part of the video source must be scaled onto which part of the window.
Direct3D and (future) VDPAU need this, for XvMC it makes it easier to add
cropping support and Xv is changed to keep the diff to XvMC small.
author | reimar |
---|---|
date | Thu, 12 Feb 2009 17:40:53 +0000 |
parents | fa91545f01bb |
children | 0f1b5b68af32 |
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 |
fa91545f01bb
Split the aac header parsing out of aac demuxer to allow using libmpmux
albeu
parents:
diff
changeset
|
21 #include <stdlib.h> |
fa91545f01bb
Split the aac header parsing out of aac demuxer to allow using libmpmux
albeu
parents:
diff
changeset
|
22 #include <inttypes.h> |
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 #include "config.h" |
fa91545f01bb
Split the aac header parsing out of aac demuxer to allow using libmpmux
albeu
parents:
diff
changeset
|
25 |
fa91545f01bb
Split the aac header parsing out of aac demuxer to allow using libmpmux
albeu
parents:
diff
changeset
|
26 /// \param srate (out) sample rate |
fa91545f01bb
Split the aac header parsing out of aac demuxer to allow using libmpmux
albeu
parents:
diff
changeset
|
27 /// \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
|
28 /// \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
|
29 /// 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
|
30 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
|
31 { |
fa91545f01bb
Split the aac header parsing out of aac demuxer to allow using libmpmux
albeu
parents:
diff
changeset
|
32 int i = 0, sr, fl = 0, id; |
fa91545f01bb
Split the aac header parsing out of aac demuxer to allow using libmpmux
albeu
parents:
diff
changeset
|
33 static int srates[] = {96000, 88200, 64000, 48000, 44100, 32000, 24000, 22050, 16000, 12000, 11025, 8000, 0, 0, 0}; |
fa91545f01bb
Split the aac header parsing out of aac demuxer to allow using libmpmux
albeu
parents:
diff
changeset
|
34 |
fa91545f01bb
Split the aac header parsing out of aac demuxer to allow using libmpmux
albeu
parents:
diff
changeset
|
35 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
|
36 return 0; |
fa91545f01bb
Split the aac header parsing out of aac demuxer to allow using libmpmux
albeu
parents:
diff
changeset
|
37 |
fa91545f01bb
Split the aac header parsing out of aac demuxer to allow using libmpmux
albeu
parents:
diff
changeset
|
38 id = (buf[i+1] >> 3) & 0x01; //id=1 mpeg2, 0: mpeg4 |
fa91545f01bb
Split the aac header parsing out of aac demuxer to allow using libmpmux
albeu
parents:
diff
changeset
|
39 sr = (buf[i+2] >> 2) & 0x0F; |
fa91545f01bb
Split the aac header parsing out of aac demuxer to allow using libmpmux
albeu
parents:
diff
changeset
|
40 if(sr > 11) |
fa91545f01bb
Split the aac header parsing out of aac demuxer to allow using libmpmux
albeu
parents:
diff
changeset
|
41 return 0; |
fa91545f01bb
Split the aac header parsing out of aac demuxer to allow using libmpmux
albeu
parents:
diff
changeset
|
42 *srate = srates[sr]; |
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 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
|
45 *num = (buf[i+6] & 0x02) + 1; |
fa91545f01bb
Split the aac header parsing out of aac demuxer to allow using libmpmux
albeu
parents:
diff
changeset
|
46 |
fa91545f01bb
Split the aac header parsing out of aac demuxer to allow using libmpmux
albeu
parents:
diff
changeset
|
47 return fl; |
fa91545f01bb
Split the aac header parsing out of aac demuxer to allow using libmpmux
albeu
parents:
diff
changeset
|
48 } |