31 const uint8_t *qtables[4] = {
NULL };
39 int default_huffman_tables = 0;
42 s->timestamp =
s->cur_timestamp;
53 if (buf[
i + 1] ==
DQT) {
55 if (buf[
i + 4] & 0xF0)
57 "Only 8-bit precision is supported.\n");
65 if (nb_qtables +
tables > 4) {
70 for (j = 0; j <
tables; j++)
71 qtables[nb_qtables + j] = buf +
i + 5 + j * 65;
73 }
else if (buf[
i + 1] ==
SOF0) {
74 if (buf[
i + 14] != 17 || buf[
i + 17] != 17) {
76 "Only 1x1 chroma blocks are supported. Aborted!\n");
87 if (buf[
i + 11] == 33) {
90 }
else if (buf[
i + 11] == 34) {
96 }
else if (buf[
i + 1] ==
DHT) {
98 default_huffman_tables |= 1 << 4;
101 if (
i + dht_size >=
size)
104 switch (buf[
i + 1]) {
109 default_huffman_tables |= 1;
121 default_huffman_tables |= 1 << 1;
133 default_huffman_tables |= 1 << 2;
145 default_huffman_tables |= 1 << 3;
158 }
else if (buf[
i + 1] ==
SOS) {
163 "Insufficient data. Aborted!\n");
173 "Invalid RTP/JPEG type\n");
177 if (default_huffman_tables && default_huffman_tables != 31) {
179 "RFC 2435 requires standard Huffman tables for jpeg\n");
182 if (nb_qtables && nb_qtables != 2)
184 "RFC 2435 suggests two quantization tables, %d provided\n",
191 for (
i =
size - 2;
i >= 0;
i--) {
192 if (buf[
i] == 0xff && buf[
i + 1] ==
EOI) {
203 if (off == 0 && nb_qtables)
204 hdr_size += 4 + 64 * nb_qtables;
210 bytestream_put_byte(&p, 0);
211 bytestream_put_be24(&p, off);
212 bytestream_put_byte(&p,
type);
213 bytestream_put_byte(&p, 255);
214 bytestream_put_byte(&p,
w);
215 bytestream_put_byte(&p,
h);
217 if (off == 0 && nb_qtables) {
219 bytestream_put_byte(&p, 0);
220 bytestream_put_byte(&p, 0);
221 bytestream_put_be16(&p, 64 * nb_qtables);
223 for (
i = 0;
i < nb_qtables;
i++)