Re: [PATCH v6 8/9] media: Avoid parsing quantization and huffman tables
From: Philipp Zabel
Date: Mon Jan 04 2021 - 12:02:02 EST
On Tue, 2020-12-15 at 13:18 +0200, Mirela Rabulea (OSS) wrote:
> From: Mirela Rabulea <mirela.rabulea@xxxxxxx>
>
> 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@xxxxxxx>
> ---
> Changes in v6:
> Call jpeg_skip_segment() instead of jpeg_parse_quantization_table()/jpeg_parse_huffman_tables(),
> when quantization/huffman tables are not requested by user.
> Remove the NULL pointer check in the lower-level function.
> Thanks Philipp & Hans for feedback
>
> drivers/media/v4l2-core/v4l2-jpeg.c | 8 ++++++++
> 1 file changed, 8 insertions(+)
>
> diff --git a/drivers/media/v4l2-core/v4l2-jpeg.c b/drivers/media/v4l2-core/v4l2-jpeg.c
> index dc9def4c2648..f3d03d39defb 100644
> --- a/drivers/media/v4l2-core/v4l2-jpeg.c
> +++ b/drivers/media/v4l2-core/v4l2-jpeg.c
> @@ -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);
Reviewed-by: Philipp Zabel <p.zabel@xxxxxxxxxxxxxx>
regards
Philipp