1 /*
2 * RTP parser for VC-2 HQ payload format (draft version 1) - experimental
3 * Copyright (c) 2016 Thomas Volkert <thomas@netzeal.de>
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
24
27
28 #define RTP_VC2HQ_PL_HEADER_SIZE 4
29
30 #define DIRAC_DATA_UNIT_HEADER_SIZE 13
31 #define DIRAC_PIC_NR_SIZE 4
32 #define DIRAC_RTP_PCODE_HQ_PIC_FRAGMENT 0xEC
33
41 };
42
44
46 uint8_t parse_code, uint32_t data_unit_size)
47 {
49 buf[4] = parse_code;
50 AV_WB32(&buf[5], data_unit_size);
52
54 }
55
57 const uint8_t *buf,
int len)
58 {
59 int res;
61
63 return res;
64
66 /* payload of seq. header */
69
71
72 return 0;
73 }
74
76 {
77 int res;
79
80 /* create A/V packet */
82 return res;
83
86
88
89 return 0;
90 }
91
95 {
96 int res;
97 uint32_t pic_nr;
98 uint16_t frag_len;
99 uint16_t no_slices;
100
101 /* sanity check for size of input packet: 16 bytes header in any case as minimum */
105 }
106
110
112 av_log(
ctx,
AV_LOG_WARNING,
"Dropping buffered RTP/VC2hq packet fragments - non-continuous picture numbers\n");
114 }
115
116 /* transform parameters? */
117 if (no_slices == 0) {
118 if (
len < frag_len + 16) {
121 }
122
123 /* start frame buffering with new dynamic buffer */
125
127 if (res < 0)
128 return res;
129
130 /* reserve memory for frame header */
132 if (res < 0)
133 return res;
134
138 }
139
140 avio_write(pl_ctx->
buf, buf + 16
/* skip pl header */, frag_len);
142
144 } else {
145 if (
len < frag_len + 20) {
148 }
149
150 /* transform parameters were missed, no buffer available */
153
154 avio_write(pl_ctx->
buf, buf + 20
/* skip pl header */, frag_len);
156
157 /* RTP marker bit means: last fragment of current frame was received;
158 otherwise, an additional fragment is needed for the current frame */
161 }
162
163 /* close frame buffering and create A/V packet */
165 if (res < 0)
166 return res;
167
170
172
173 return 0;
174 }
175
178 const uint8_t *buf,
int len, uint16_t seq,
180 {
181 uint8_t parse_code = 0;
182 int res = 0;
183
188 }
189
190 /* sanity check for size of input packet: needed header data as minimum */
194 }
195
196 parse_code = buf[3];
197
198 /* wait for next sequence header? */
200 switch(parse_code) {
201 /* sequence header */
204 break;
205 /* end of sequence */
208 break;
209 /* HQ picture fragment */
212 break;
213 }
214 }
215
216 return res;
217 }
218
225 };