39 int default_huffman_tables = 0;
42 s->timestamp =
s->cur_timestamp;
69 if (
buf[
i + 4] & 0xF0)
71 "Only 8-bit precision is supported.\n");
79 if (nb_qtables +
tables > 4) {
84 for (j = 0; j <
tables; j++)
85 qtables[nb_qtables + j] =
buf +
i + 5 + j * 65;
88 if (
buf[
i + 14] != 17 ||
buf[
i + 17] != 17) {
90 "Only 1x1 chroma blocks are supported. Aborted!\n");
95 default_huffman_tables |= 1 << 4;
98 if (
i + dht_size >=
size)
101 switch (
buf[
i + 1]) {
106 default_huffman_tables |= 1;
118 default_huffman_tables |= 1 << 1;
130 default_huffman_tables |= 1 << 2;
142 default_huffman_tables |= 1 << 3;
155 }
else if (
buf[
i + 1] ==
SOS) {
160 "Insufficient data. Aborted!\n");
166 if (default_huffman_tables && default_huffman_tables != 31) {
168 "RFC 2435 requires standard Huffman tables for jpeg\n");
171 if (nb_qtables && nb_qtables != 2)
173 "RFC 2435 suggests two quantization tables, %d provided\n",
180 for (
i =
size - 2;
i >= 0;
i--) {
192 if (off == 0 && nb_qtables)
193 hdr_size += 4 + 64 * nb_qtables;
199 bytestream_put_byte(&p, 0);
200 bytestream_put_be24(&p, off);
201 bytestream_put_byte(&p,
type);
202 bytestream_put_byte(&p, 255);
203 bytestream_put_byte(&p,
w);
204 bytestream_put_byte(&p,
h);
206 if (off == 0 && nb_qtables) {
208 bytestream_put_byte(&p, 0);
209 bytestream_put_byte(&p, 0);
210 bytestream_put_be16(&p, 64 * nb_qtables);
212 for (
i = 0;
i < nb_qtables;
i++)