History

avcodec/sanm: codec21 decoder

similar to codec23, this one alternatingly skips and writes bytes.

Manuel Lauss committed 1 year ago

Commit e1fd6bc1 parent 77b5a0c1 file · +45 −0Browse files

Unified · Split

libavcodec/sanm.c+45−0
@@ -614,6 +614,49 @@ static int old_codec23(SANMVideoContext *ctx, int top, int left, int width, · 613 unmodified lines
614 return 0;614 return 0;
615}615}
616 616
617static int old_codec21(SANMVideoContext *ctx, int top, int left, int width,
618 int height)
619{
620 const uint32_t maxpxo = ctx->height * ctx->pitch;
621 uint8_t *dst = (uint8_t *)ctx->frm0, c;
622 int i, j, k, pc, sk, pxoff;
623
624 dst = (uint8_t *)ctx->frm0;
625 for (i = 0; i < height; i++) {
626 if (bytestream2_get_bytes_left(&ctx->gb) < 2)
627 return 0;
628 pxoff = left + ((top + i) * ctx->pitch);
629 k = bytestream2_get_le16u(&ctx->gb);
630 sk = 1;
631 pc = 0;
632 while (k > 0 && pc <= width) {
633 if (bytestream2_get_bytes_left(&ctx->gb) < 2)
634 return AVERROR_INVALIDDATA;
635 j = bytestream2_get_le16u(&ctx->gb);
636 k -= 2;
637 if (sk) {
638 pxoff += j;
639 pc += j;
640 } else {
641 if (bytestream2_get_bytes_left(&ctx->gb) < (j + 1))
642 return AVERROR_INVALIDDATA;
643 do {
644 c = bytestream2_get_byteu(&ctx->gb);
645 if (pxoff >=0 && pxoff < maxpxo) {
646 *(dst + pxoff) = c;
647 }
648 pxoff++;
649 pc++;
650 j--;
651 k--;
652 } while (j > -1);
653 }
654 sk ^= 1;
655 }
656 }
657 return 0;
658}
659
617static int old_codec1(SANMVideoContext *ctx, int top,660static int old_codec1(SANMVideoContext *ctx, int top,
618 int left, int width, int height, int opaque)661 int left, int width, int height, int opaque)
619{662{
@@ -1393,6 +1436,8 @@ static int process_frame_obj(SANMVideoContext *ctx) · 773 unmodified lines
1393 return old_codec1(ctx, top, left, w, h, codec == 3);1436 return old_codec1(ctx, top, left, w, h, codec == 3);
1394 case 2:1437 case 2:
1395 return old_codec2(ctx, top, left, w, h);1438 return old_codec2(ctx, top, left, w, h);
1439 case 21:
1440 return old_codec21(ctx, top, left, w, h);
1396 case 23:1441 case 23:
1397 return old_codec23(ctx, top, left, w, h, param, parm2);1442 return old_codec23(ctx, top, left, w, h, param, parm2);
1398 case 37:1443 case 37:

Keyboard shortcuts

General

Show keyboard shortcuts
?
Focus the current search
/

Issues and pull requests

Open filters
f

Issues, pull requests and Inbox

Select next item
j↓
Select previous item
k↑
Open selected item
Enter
Dismiss filters or clear selection
Esc

Repository code

Go to file
t