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: Mirela Rabulea <mirela.rabulea@nxp.com>
Reviewed-by: Philipp Zabel <p.zabel@pengutronix.de>
Signed-off-by: Hans Verkuil <hverkuil-cisco@xs4all.nl>
Signed-off-by: Mauro Carvalho Chehab <mchehab+huawei@kernel.org>
This commit is contained in:
Mirela Rabulea 2021-03-11 01:28:51 +01:00 committed by Mauro Carvalho Chehab
parent ccbea178db
commit 819f3ea51d

View File

@ -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);