Commit 819f3ea5 authored by Mirela Rabulea's avatar Mirela Rabulea Committed by Mauro Carvalho Chehab

media: Avoid parsing quantization and huffman tables

These are optional in struct v4l2_jpeg_header, so skip DHT/DQT segment
parsing if huffman_tables/quantization_tables were not requested by user,
to save time.
However, do count them (num_dht/num_dqt).
Signed-off-by: default avatarMirela Rabulea <mirela.rabulea@nxp.com>
Reviewed-by: default avatarPhilipp Zabel <p.zabel@pengutronix.de>
Signed-off-by: default avatarHans Verkuil <hverkuil-cisco@xs4all.nl>
Signed-off-by: default avatarMauro Carvalho Chehab <mchehab+huawei@kernel.org>
parent ccbea178
......@@ -537,6 +537,10 @@ int v4l2_jpeg_parse_header(void *buf, size_t len, struct v4l2_jpeg_header *out)
&out->dht[out->num_dht++ % 4]);
if (ret < 0)
return ret;
if (!out->huffman_tables) {
ret = jpeg_skip_segment(&stream);
break;
}
ret = jpeg_parse_huffman_tables(&stream,
out->huffman_tables);
break;
......@@ -545,6 +549,10 @@ int v4l2_jpeg_parse_header(void *buf, size_t len, struct v4l2_jpeg_header *out)
&out->dqt[out->num_dqt++ % 4]);
if (ret < 0)
return ret;
if (!out->quantization_tables) {
ret = jpeg_skip_segment(&stream);
break;
}
ret = jpeg_parse_quantization_tables(&stream,
out->frame.precision,
out->quantization_tables);
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment