1 /*
2 * copyright (c) 2008 Paul Kendall <paul@kcbbs.gen.nz>
3 *
4 * This file is part of FFmpeg.
5 *
6 * FFmpeg is free software; you can redistribute it and/or
7 * modify it under the terms of the GNU Lesser General Public
8 * License as published by the Free Software Foundation; either
9 * version 2.1 of the License, or (at your option) any later version.
10 *
11 * FFmpeg is distributed in the hope that it will be useful,
12 * but WITHOUT ANY WARRANTY; without even the implied warranty of
13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
14 * Lesser General Public License for more details.
15 *
16 * You should have received a copy of the GNU Lesser General Public
17 * License along with FFmpeg; if not, write to the Free Software
18 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
19 */
20
21 /**
22 * @file
23 * AAC LATM parser
24 */
25
26 #include <stdint.h>
28
29 #define LATM_HEADER 0x56e000 // 0x2b7 (11 bits)
30 #define LATM_MASK 0xFFE000 // top 11 bits
31 #define LATM_SIZE_MASK 0x001FFF // bottom 13 bits
32
37
38 /**
39 * Find the end of the current frame in the bitstream.
40 * @return the position of the first byte of the next frame, or -1
41 */
43 int buf_size)
44 {
49
52
53 if (!pic_found) {
54 for (
i = 0;
i < buf_size;
i++) {
59 pic_found = 1;
60 break;
61 }
62 }
63 }
64
65 if (pic_found) {
66 /* EOF considered as end of frame */
67 if (buf_size == 0)
68 return 0;
73 }
74 }
75
79
81 }
82
84 const uint8_t **poutbuf, int *poutbuf_size,
85 const uint8_t *buf, int buf_size)
86 {
89 int next;
90
92 next = buf_size;
93 } else {
95
98 *poutbuf_size = 0;
99 return buf_size;
100 }
101 }
102 *poutbuf = buf;
103 *poutbuf_size = buf_size;
104 return next;
105 }
106
112 };