1 /*
2 * RTP packetization for H.264 (RFC3984)
3 * Copyright (c) 2008 Luca Abeni
4 *
5 * This file is part of FFmpeg.
6 *
7 * FFmpeg is free software; you can redistribute it and/or
8 * modify it under the terms of the GNU Lesser General Public
9 * License as published by the Free Software Foundation; either
10 * version 2.1 of the License, or (at your option) any later version.
11 *
12 * FFmpeg is distributed in the hope that it will be useful,
13 * but WITHOUT ANY WARRANTY; without even the implied warranty of
14 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
15 * Lesser General Public License for more details.
16 *
17 * You should have received a copy of the GNU Lesser General Public
18 * License along with FFmpeg; if not, write to the Free Software
19 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
20 */
21
22 /**
23 * @file
24 * @brief H.264 packetization
25 * @author Luca Abeni <lucabe72@email.it>
26 */
27
31
33 {
35
36 if (end - start < nal_length_size)
37 return NULL;
38 while (nal_length_size--)
39 res = (res << 8) | *start++;
40
41 if (res > end - start)
42 return NULL;
43
45 }
46
48 {
50
51 av_log(s1,
AV_LOG_DEBUG,
"Sending NAL %x of len %d M=%d\n", buf[0] & 0x1F, size, last);
52 if (size <= s->max_payload_size) {
54 } else {
57
60 "NAL size %d > %d, try -slice-max-size %d\n", size,
62 return;
63 }
65 s->
buf[0] = 28;
/* FU Indicator; Type = 28 ---> FU-A */
69 buf += 1;
70 size -= 1;
76 s->
buf[1] &= ~(1 << 7);
77 }
79 memcpy(&s->
buf[2], buf, size);
81 }
82 }
83
85 {
88
92 else
94 while (r < end) {
96
99 if (!r1)
102 } else {
103 while (!*(r++));
105 }
107 r = r1;
108 }
109 }