MCPcopy Create free account
hub / github.com/FFmpeg/FFmpeg / old_codec23

Function old_codec23

libavcodec/sanm.c:772–836  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

770}
771
772static int old_codec23(SANMVideoContext *ctx, GetByteContext *gb, int top, int left,
773 int width, int height, uint8_t param, uint16_t param2)
774{
775 const uint16_t mx = ctx->width, my = ctx->height, p = ctx->pitch;
776 uint8_t c, lut[256], *dst = (uint8_t *)ctx->fbuf;
777 int sk, i, j, ls, pc, y;
778
779 if (ctx->subversion < 2) {
780 /* Rebel Assault 1: constant offset + 0xd0 */
781 for (i = 0; i < 256; i++)
782 lut[i] = (i + param + 0xd0) & 0xff;
783 } else if (param2 == 256) {
784 if (bytestream2_get_bytes_left(gb) < 256)
785 return AVERROR_INVALIDDATA;
786 bytestream2_get_bufferu(gb, ctx->c23lut, 256);
787 } else if (param2 < 256) {
788 for (i = 0; i < 256; i++)
789 lut[i] = (i + param2) & 0xff;
790 } else {
791 memcpy(lut, ctx->c23lut, 256);
792 }
793 if (bytestream2_get_bytes_left(gb) < 1)
794 return 0; /* some c23 frames just set up the LUT */
795
796 if (((top + height) < 0) || (top >= my) || (left + width < 0) || (left >= mx))
797 return 0;
798
799 if (top < 0) {
800 y = -top;
801 while (y-- && bytestream2_get_bytes_left(gb) > 1) {
802 ls = bytestream2_get_le16u(gb);
803 if (bytestream2_get_bytes_left(gb) < ls)
804 return AVERROR_INVALIDDATA;
805 bytestream2_skip(gb, ls);
806 }
807 height += top;
808 top = 0;
809 }
810
811 y = top;
812 for (; (bytestream2_get_bytes_left(gb) > 1) && (height > 0) && (y < my); height--, y++) {
813 ls = bytestream2_get_le16u(gb);
814 sk = 1;
815 pc = left;
816 while ((bytestream2_get_bytes_left(gb) > 0) && (ls > 0) && (pc <= (width + left))) {
817 j = bytestream2_get_byteu(gb);
818 ls--;
819 if (!sk) {
820 while (j--) {
821 if ((pc >= 0) && (pc < mx)) {
822 c = *(dst + (y * p) + pc);
823 *(dst + (y * p) + pc) = lut[c];
824 }
825 if (pc < mx)
826 pc++;
827 }
828 } else {
829 if (pc < mx)

Callers 1

process_frame_objFunction · 0.85

Calls 3

bytestream2_get_bufferuFunction · 0.85
bytestream2_skipFunction · 0.85

Tested by

no test coverage detected