1 /*
2 * RTP packetizer 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
26
29
30 #define RTP_VC2HQ_PL_HEADER_SIZE 4
31
32 #define DIRAC_DATA_UNIT_HEADER_SIZE 13
33 #define DIRAC_PIC_NR_SIZE 4
34 #define DIRAC_RTP_PCODE_HQ_PIC_FRAGMENT 0xEC
35
37 {
39
40 AV_WB16(&rtp_ctx->
buf[0], 0);
/* extended sequence number */
41 AV_WB8 (&rtp_ctx->
buf[2],
i ? (
f ? (0x03) : (0x02)) : 0x00);
/* flags: interlaced, second field */
44 memcpy(&rtp_ctx->
buf[4 + info_hdr_size], buf,
size);
46 }
47
49 {
52 int lvl, second_field;
53 uint32_t pic_nr, wavelet_depth, prefix_bytes, size_scaler;
54 uint16_t frag_len;
55 char *info_hdr = &rtp_ctx->
buf[4];
56
61
69 /* pass the quantization matrices */
71 for(lvl = 0; lvl < wavelet_depth; lvl++)
72 {
76 }
77
78 frag_len = (
get_bits_count(&gc) + 7) / 8;
/* length of transform parameters */
79
81 AV_WB16(&info_hdr[ 4], prefix_bytes);
82 AV_WB16(&info_hdr[ 6], size_scaler);
83 AV_WB16(&info_hdr[ 8], frag_len);
84 AV_WB16(&info_hdr[10], 0
/* nr. of slices */);
86 buf += frag_len;
88
91 AV_WB16(&info_hdr[ 8], frag_len);
92 AV_WB16(&info_hdr[10], 1
/* nr. of slices */);
93 AV_WB16(&info_hdr[12], 0
/* slice x */);
94 AV_WB16(&info_hdr[14], 0
/* slice y */);
95
98 buf += frag_len;
99 }
100 }
101
103 {
105 const uint8_t *unit = frame_buf;
106 uint8_t parse_code;
107 uint32_t unit_size;
108
109 while (unit < end) {
110 parse_code = unit[4];
112
113 switch (parse_code) {
114 /* sequence header */
115 /* end of sequence */
119 break;
120 /* HQ picture */
123 break;
124 /* parse codes without specification */
127 break;
128 default:
130 break;
131 }
132 unit += unit_size;
133 }
134 }