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

Function rle_uncompress

libavcodec/mscc.c:46–136  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

44} MSCCContext;
45
46static int rle_uncompress(AVCodecContext *avctx, GetByteContext *gb, PutByteContext *pb)
47{
48 MSCCContext *s = avctx->priv_data;
49 unsigned x = 0, y = 0;
50
51 while (bytestream2_get_bytes_left(gb) > 0) {
52 uint32_t fill;
53 int j;
54 unsigned run = bytestream2_get_byte(gb);
55
56 if (run) {
57 if (bytestream2_get_bytes_left_p(pb) < run * s->bpp)
58 return AVERROR_INVALIDDATA;
59
60 switch (avctx->bits_per_coded_sample) {
61 case 8:
62 fill = bytestream2_get_byte(gb);
63 break;
64 case 16:
65 fill = bytestream2_get_le16(gb);
66 break;
67 case 24:
68 fill = bytestream2_get_le24(gb);
69 break;
70 case 32:
71 fill = bytestream2_get_le32(gb);
72 break;
73 }
74
75 for (j = 0; j < run; j++) {
76 switch (avctx->bits_per_coded_sample) {
77 case 8:
78 bytestream2_put_byte(pb, fill);
79 break;
80 case 16:
81 bytestream2_put_le16(pb, fill);
82 break;
83 case 24:
84 bytestream2_put_le24(pb, fill);
85 break;
86 case 32:
87 bytestream2_put_le32(pb, fill);
88 break;
89 }
90 }
91 x += run;
92 } else {
93 unsigned copy = bytestream2_get_byte(gb);
94
95 if (copy == 0) {
96 x = 0;
97 y++;
98 bytestream2_seek_p(pb, y * avctx->width * s->bpp, SEEK_SET);
99 } else if (copy == 1) {
100 return 0;
101 } else if (copy == 2) {
102
103 x += bytestream2_get_byte(gb);

Callers 1

decode_frameFunction · 0.70

Calls 4

bytestream2_seek_pFunction · 0.85
bytestream2_skipFunction · 0.85

Tested by

no test coverage detected