Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- diff --git a/libavcodec/sgidec.c b/libavcodec/sgidec.c
- index e5b3c59..f6af1c1 100644
- --- a/libavcodec/sgidec.c
- +++ b/libavcodec/sgidec.c
- @@ -123,26 +123,33 @@ static int read_rle_sgi(unsigned char* out_buf, const uin$
- * @return 0 if read success, otherwise return -1.
- */
- static int read_uncompressed_sgi(unsigned char* out_buf, uint8_t* out_end,
- - const uint8_t *in_buf, const uint8_t *in_end, SgiState* s)
- + GetByteContext *g, SgiState* s)
- {
- int x, y, z;
- - const uint8_t *ptr;
- unsigned int offset = s->height * s->width * s->bytes_per_channel;
- + GetByteContext gp[4];
- /* Test buffer size. */
- - if (offset * s->depth > in_end - in_buf) {
- + if (offset * s->depth > bytestream2_get_bytes_left(g)) {
- return -1;
- }
- + for (z = 0; z < s->depth; z++) {
- + gp[z] = *g;
- + bytestream2_skip(&gp[z], z * offset);
- + }
- +
- for (y = s->height - 1; y >= 0; y--) {
- out_end = out_buf + (y * s->linesize);
- - for (x = s->width; x > 0; x--) {
- - ptr = in_buf += s->bytes_per_channel;
- - for(z = 0; z < s->depth; z ++) {
- - memcpy(out_end, ptr, s->bytes_per_channel);
- - out_end += s->bytes_per_channel;
- - ptr += offset;
- - }
- + if (s->bytes_per_channel == 1) {
- + for (x = s->width; x > 0; x--)
- + for (z = 0; z < s->depth; z++)
- + *out_end++ = bytestream2_get_byte(&gp[z]);
- + } else {
- + uint16_t *out_line = (uint16_t *)out_end;
- + for (x = s->width; x > 0; x--)
- + for (z = 0; z < s->depth; z++)
- + *out_line++ = bytestream2_get_be16(&gp[z]);
- }
- }
- return 0;
- @@ -228,7 +235,9 @@ static int decode_frame(AVCodecContext *avctx,
- if (rle) {
- ret = read_rle_sgi(out_end, in_buf, in_end, s);
- } else {
- - ret = read_uncompressed_sgi(out_buf, out_end, in_buf, in_end, s);
- + GetByteContext g;
- + bytestream2_init(&g, in_buf, in_end - in_buf);
- + ret = read_uncompressed_sgi(out_buf, out_end, &g, s);
- }
- if (ret == 0) {
Add Comment
Please, Sign In to add comment