31 const uint8_t *qtables[4] = {
NULL };
39 int default_huffman_tables = 0;
42 s->timestamp =
s->cur_timestamp;
58 if (buf[
i + 1] ==
DQT) {
60 if (buf[
i + 4] & 0xF0)
62 "Only 8-bit precision is supported.\n");
70 if (nb_qtables +
tables > 4) {
75 for (j = 0; j <
tables; j++)
76 qtables[nb_qtables + j] = buf +
i + 5 + j * 65;
78 }
else if (buf[
i + 1] ==
SOF0) {
79 if (buf[
i + 14] != 17 || buf[
i + 17] != 17) {
81 "Only 1x1 chroma blocks are supported. Aborted!\n");
92 if (buf[
i + 11] == 33) {
95 }
else if (buf[
i + 11] == 34) {
101 }
else if (buf[
i + 1] ==
DHT) {
102 int dht_size =
AV_RB16(&buf[
i + 2]);
103 default_huffman_tables |= 1 << 4;
106 if (
i + dht_size >=
size)
109 switch (buf[
i + 1]) {
114 default_huffman_tables |= 1;
126 default_huffman_tables |= 1 << 1;
138 default_huffman_tables |= 1 << 2;
150 default_huffman_tables |= 1 << 3;
163 }
else if (buf[
i + 1] ==
SOS) {
168 "Insufficient data. Aborted!\n");
178 "Invalid RTP/JPEG type\n");
182 if (default_huffman_tables && default_huffman_tables != 31) {
184 "RFC 2435 requires standard Huffman tables for jpeg\n");
187 if (nb_qtables && nb_qtables != 2)
189 "RFC 2435 suggests two quantization tables, %d provided\n",
196 for (
i =
size - 2;
i >= 0;
i--) {
197 if (buf[
i] == 0xff && buf[
i + 1] ==
EOI) {
208 if (off == 0 && nb_qtables)
209 hdr_size += 4 + 64 * nb_qtables;
215 bytestream_put_byte(&p, 0);
216 bytestream_put_be24(&p, off);
217 bytestream_put_byte(&p,
type);
218 bytestream_put_byte(&p, 255);
219 bytestream_put_byte(&p,
w);
220 bytestream_put_byte(&p,
h);
222 if (off == 0 && nb_qtables) {
224 bytestream_put_byte(&p, 0);
225 bytestream_put_byte(&p, 0);
226 bytestream_put_be16(&p, 64 * nb_qtables);
228 for (
i = 0;
i < nb_qtables;
i++)
static av_always_inline void bytestream_put_buffer(uint8_t **b, const uint8_t *src, unsigned int size)
#define i(width, name, range_min, range_max)
#define AV_CEIL_RSHIFT(a, b)
#define EOI
End Of Image marker.
#define AV_LOG_WARNING
Something somehow does not look correct.
#define AV_LOG_ERROR
Something went wrong and cannot losslessly be recovered.
FF_VISIBILITY_PUSH_HIDDEN const uint8_t ff_mjpeg_bits_dc_luminance[]
const uint8_t ff_mjpeg_val_ac_chrominance[]
const uint8_t ff_mjpeg_bits_ac_luminance[]
const uint8_t ff_mjpeg_bits_dc_chrominance[]
const uint8_t ff_mjpeg_bits_ac_chrominance[]
const uint8_t ff_mjpeg_val_dc[]
const uint8_t ff_mjpeg_val_ac_luminance[]
MJPEG encoder and decoder.
void ff_rtp_send_data(AVFormatContext *s1, const uint8_t *buf1, int len, int m)
void ff_rtp_send_jpeg(AVFormatContext *s1, const uint8_t *buf, int size)
int height
The height of the video frame in pixels.
int width
The width of the video frame in pixels.
void * priv_data
Format private data.
AVStream ** streams
A list of all streams in the file.
AVCodecParameters * codecpar
Codec parameters associated with this stream.
static const uint8_t *const tables[]