Commit abe9d19a authored by Hans Verkuil's avatar Hans Verkuil Committed by Mauro Carvalho Chehab

media: vicodec: improve handling of uncompressable planes

Exit the loop immediately once it is clear that the plane
cannot be compressed. Also clear the PCODED bit and fix the
PCODED check (it should check for the bit) in the caller code.
Signed-off-by: default avatarHans Verkuil <hans.verkuil@cisco.com>
Signed-off-by: default avatarMauro Carvalho Chehab <mchehab+samsung@kernel.org>
parent 98efd552
...@@ -685,9 +685,6 @@ static u32 encode_plane(u8 *input, u8 *refp, __be16 **rlco, __be16 *rlco_max, ...@@ -685,9 +685,6 @@ static u32 encode_plane(u8 *input, u8 *refp, __be16 **rlco, __be16 *rlco_max,
input += 8 * input_step; input += 8 * input_step;
refp += 8 * 8; refp += 8 * 8;
if (encoding & FRAME_UNENCODED)
continue;
size = rlc(cf->coeffs, *rlco, blocktype); size = rlc(cf->coeffs, *rlco, blocktype);
if (last_size == size && if (last_size == size &&
!memcmp(*rlco + 1, *rlco - size + 1, 2 * size - 2)) { !memcmp(*rlco + 1, *rlco - size + 1, 2 * size - 2)) {
...@@ -702,12 +699,16 @@ static u32 encode_plane(u8 *input, u8 *refp, __be16 **rlco, __be16 *rlco_max, ...@@ -702,12 +699,16 @@ static u32 encode_plane(u8 *input, u8 *refp, __be16 **rlco, __be16 *rlco_max,
} else { } else {
*rlco += size; *rlco += size;
} }
if (*rlco >= rlco_max) if (*rlco >= rlco_max) {
encoding |= FRAME_UNENCODED; encoding |= FRAME_UNENCODED;
goto exit_loop;
}
last_size = size; last_size = size;
} }
input += width * 7 * input_step; input += width * 7 * input_step;
} }
exit_loop:
if (encoding & FRAME_UNENCODED) { if (encoding & FRAME_UNENCODED) {
u8 *out = (u8 *)rlco_start; u8 *out = (u8 *)rlco_start;
...@@ -721,6 +722,7 @@ static u32 encode_plane(u8 *input, u8 *refp, __be16 **rlco, __be16 *rlco_max, ...@@ -721,6 +722,7 @@ static u32 encode_plane(u8 *input, u8 *refp, __be16 **rlco, __be16 *rlco_max,
for (i = 0; i < height * width; i++, input += input_step) for (i = 0; i < height * width; i++, input += input_step)
*out++ = (*input == 0xff) ? 0xfe : *input; *out++ = (*input == 0xff) ? 0xfe : *input;
*rlco = (__be16 *)out; *rlco = (__be16 *)out;
encoding &= ~FRAME_PCODED;
} }
return encoding; return encoding;
} }
......
...@@ -281,7 +281,7 @@ static void encode(struct vicodec_ctx *ctx, ...@@ -281,7 +281,7 @@ static void encode(struct vicodec_ctx *ctx,
encoding = encode_frame(&rf, &ctx->ref_frame, &cf, !ctx->gop_cnt, encoding = encode_frame(&rf, &ctx->ref_frame, &cf, !ctx->gop_cnt,
ctx->gop_cnt == ctx->gop_size - 1); ctx->gop_cnt == ctx->gop_size - 1);
if (encoding != FRAME_PCODED) if (!(encoding & FRAME_PCODED))
ctx->gop_cnt = 0; ctx->gop_cnt = 0;
if (++ctx->gop_cnt >= ctx->gop_size) if (++ctx->gop_cnt >= ctx->gop_size)
ctx->gop_cnt = 0; ctx->gop_cnt = 0;
......
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