1 /*
2 * RTP packetization for H.263 video
3 * Copyright (c) 2009 Luca Abeni
4 * Copyright (c) 2009 Martin Storsjo
5 *
6 * This file is part of FFmpeg.
7 *
8 * FFmpeg is free software; you can redistribute it and/or
9 * modify it under the terms of the GNU Lesser General Public
10 * License as published by the Free Software Foundation; either
11 * version 2.1 of the License, or (at your option) any later version.
12 *
13 * FFmpeg is distributed in the hope that it will be useful,
14 * but WITHOUT ANY WARRANTY; without even the implied warranty of
15 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
16 * Lesser General Public License for more details.
17 *
18 * You should have received a copy of the GNU Lesser General Public
19 * License along with FFmpeg; if not, write to the Free Software
20 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
21 */
22
25
27 const uint8_t *restrict end)
28 {
29 const uint8_t *
p = end - 1;
30 start += 1; /* Make sure we never return the original start. */
31 for (;
p > start;
p -= 2) {
33 if (!
p[ 1] &&
p[2])
return p;
34 else if (!
p[-1] &&
p[1])
return p - 1;
35 }
36 }
37 return end;
38 }
39
40 /**
41 * Packetize H.263 frames into RTP packets according to RFC 4629
42 */
44 {
46 int len, max_packet_size;
47 uint8_t *q;
48
49 max_packet_size =
s->max_payload_size;
50
53 if (
size >= 2 && (buf1[0] == 0) && (buf1[1] == 0)) {
54 *q++ = 0x04;
55 buf1 += 2;
57 } else {
58 *q++ = 0;
59 }
60 *q++ = 0;
61
63
64 /* Look for a better place to split the frame into packets. */
69 }
70
73
74 /* 90 KHz time stamp */
75 s->timestamp =
s->cur_timestamp;
77
80 }
81 }