1 /*
2 * RTP H.263 Depacketizer, RFC 4629
3 * Copyright (c) 2010 Martin Storsjo
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
26
29 {
30 if (st_index < 0)
31 return 0;
33 return 0;
34 }
35
39 {
42 int startcode, vrc, picture_header;
43
44 if (len < 2) {
47 }
48
49 /* Decode the 16 bit H.263+ payload header, as described in section
50 * 5.1 of RFC 4629. The fields of this header are:
51 * - 5 reserved bits, should be ignored.
52 * - One bit (P, startcode), indicating a picture start, picture segment
53 * start or video sequence end. If set, two zero bytes should be
54 * prepended to the payload.
55 * - One bit (V, vrc), indicating the presence of an 8 bit Video
56 * Redundancy Coding field after this 16 bit header.
57 * - 6 bits (PLEN, picture_header), the length (in bytes) of an extra
58 * picture header, following the VRC field.
59 * - 3 bits (PEBIT), the number of bits to ignore of the last byte
60 * of the extra picture header. (Not used at the moment.)
61 */
63 startcode = (header & 0x0400) >> 9;
64 vrc = header & 0x0200;
65 picture_header = (header & 0x01f8) >> 3;
66 buf += 2;
67 len -= 2;
68
69 if (vrc) {
70 /* Skip VRC header if present, not used at the moment. */
71 buf += 1;
72 len -= 1;
73 }
74 if (picture_header) {
75 /* Skip extra picture header if present, not used at the moment. */
76 buf += picture_header;
77 len -= picture_header;
78 }
79
80 if (len < 0) {
83 }
84
88 }
91
92 if (startcode) {
93 *ptr++ = 0;
94 *ptr++ = 0;
95 }
96 memcpy(ptr, buf, len);
97
98 return 0;
99 }
100
107 };
108
115 };