1 /*
2 * copyright (c) 2007 Luca Abeni
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
23
24
26 {
28 int len, max_packet_size;
32
33 /* skip ADTS header, if present */
35 size -= 7;
36 buff += 7;
37 }
39
40 /* test if the packet must be sent */
44
45 p = s->
buf + max_au_headers_size - au_size - 2;
47 memmove(p + 2, s->
buf + 2, au_size);
48 }
49 /* Write the AU header size */
50 p[0] = au_size >> 5;
51 p[1] = (au_size & 0x1F) << 3;
52
54
56 }
60 }
61
62 if (size <= max_packet_size) {
64 *p++ = size >> 5;
65 *p = (size & 0x1F) << 3;
68 } else {
70
73 p[0] = 0;
74 p[1] = 16;
75 while (size > 0) {
76 len =
FFMIN(size, max_packet_size);
77 p[2] = au_size >> 5;
78 p[3] = (au_size & 0x1F) << 3;
79 memcpy(p + 4, buff, len);
83 }
84 }
85 }