media: coda: add SPS fixup code for frame sizes that are not multiples of 16

The CODA7541 firmware does not set the SPS frame cropping fields to
properly describe coded h.264 streams with frame sizes that are not a
multiple of the macroblock size.
This adds RBSP parsing code and a SPS fixup routine to manually replace
the cropping information in the headers produced by the firmware with
the correct values.

Signed-off-by: Philipp Zabel <p.zabel@pengutronix.de>
[hans.verkuil@cisco.com: added explanation of SPS RBSP to comment]
Signed-off-by: Hans Verkuil <hans.verkuil@cisco.com>
Signed-off-by: Mauro Carvalho Chehab <mchehab+samsung@kernel.org>
This commit is contained in:
Philipp Zabel
2018-07-19 06:45:10 -04:00
کامیت شده توسط Mauro Carvalho Chehab
والد 7988b2532a
کامیت 0dff710d1f
3فایلهای تغییر یافته به همراه339 افزوده شده و 0 حذف شده

مشاهده پرونده

@@ -1215,6 +1215,27 @@ static int coda_start_encoding(struct coda_ctx *ctx)
if (ret < 0)
goto out;
/*
* If visible width or height are not aligned to macroblock
* size, the crop_right and crop_bottom SPS fields must be set
* to the difference between visible and coded size. This is
* only supported by CODA960 firmware. All others do not allow
* writing frame cropping parameters, so we have to manually
* fix up the SPS RBSP (Sequence Parameter Set Raw Byte
* Sequence Payload) ourselves.
*/
if (ctx->dev->devtype->product != CODA_960 &&
((q_data_src->rect.width % 16) ||
(q_data_src->rect.height % 16))) {
ret = coda_h264_sps_fixup(ctx, q_data_src->rect.width,
q_data_src->rect.height,
&ctx->vpu_header[0][0],
&ctx->vpu_header_size[0],
sizeof(ctx->vpu_header[0]));
if (ret < 0)
goto out;
}
/*
* Get PPS in the first frame and copy it to an
* intermediate buffer.