Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

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: Hans Verkuil <hans.verkuil@cisco.com>
Signed-off-by: Mauro Carvalho Chehab <mchehab+samsung@kernel.org>

authored by

Hans Verkuil and committed by
Mauro Carvalho Chehab
abe9d19a 98efd552

+7 -5
+6 -4
drivers/media/platform/vicodec/vicodec-codec.c
··· 685 685 input += 8 * input_step; 686 686 refp += 8 * 8; 687 687 688 - if (encoding & FRAME_UNENCODED) 689 - continue; 690 - 691 688 size = rlc(cf->coeffs, *rlco, blocktype); 692 689 if (last_size == size && 693 690 !memcmp(*rlco + 1, *rlco - size + 1, 2 * size - 2)) { ··· 699 702 } else { 700 703 *rlco += size; 701 704 } 702 - if (*rlco >= rlco_max) 705 + if (*rlco >= rlco_max) { 703 706 encoding |= FRAME_UNENCODED; 707 + goto exit_loop; 708 + } 704 709 last_size = size; 705 710 } 706 711 input += width * 7 * input_step; 707 712 } 713 + 714 + exit_loop: 708 715 if (encoding & FRAME_UNENCODED) { 709 716 u8 *out = (u8 *)rlco_start; 710 717 ··· 722 721 for (i = 0; i < height * width; i++, input += input_step) 723 722 *out++ = (*input == 0xff) ? 0xfe : *input; 724 723 *rlco = (__be16 *)out; 724 + encoding &= ~FRAME_PCODED; 725 725 } 726 726 return encoding; 727 727 }
+1 -1
drivers/media/platform/vicodec/vicodec-core.c
··· 281 281 282 282 encoding = encode_frame(&rf, &ctx->ref_frame, &cf, !ctx->gop_cnt, 283 283 ctx->gop_cnt == ctx->gop_size - 1); 284 - if (encoding != FRAME_PCODED) 284 + if (!(encoding & FRAME_PCODED)) 285 285 ctx->gop_cnt = 0; 286 286 if (++ctx->gop_cnt >= ctx->gop_size) 287 287 ctx->gop_cnt = 0;