|
|
@ -296,13 +296,13 @@ static int flashsv_decode_frame(AVCodecContext *avctx, void *data, |
|
|
|
/* the block size could change between frames, make sure the buffer
|
|
|
|
/* the block size could change between frames, make sure the buffer
|
|
|
|
* is large enough, if not, get a larger one */ |
|
|
|
* is large enough, if not, get a larger one */ |
|
|
|
if (s->block_size < s->block_width * s->block_height) { |
|
|
|
if (s->block_size < s->block_width * s->block_height) { |
|
|
|
int tmpblock_size = 3 * s->block_width * s->block_height; |
|
|
|
int tmpblock_size = 3 * s->block_width * s->block_height, err; |
|
|
|
|
|
|
|
|
|
|
|
s->tmpblock = av_realloc(s->tmpblock, tmpblock_size); |
|
|
|
if ((err = av_reallocp(&s->tmpblock, tmpblock_size)) < 0) { |
|
|
|
if (!s->tmpblock) { |
|
|
|
s->block_size = 0; |
|
|
|
av_log(avctx, AV_LOG_ERROR, |
|
|
|
av_log(avctx, AV_LOG_ERROR, |
|
|
|
"Cannot allocate decompression buffer.\n"); |
|
|
|
"Cannot allocate decompression buffer.\n"); |
|
|
|
return AVERROR(ENOMEM); |
|
|
|
return err; |
|
|
|
} |
|
|
|
} |
|
|
|
if (s->ver == 2) { |
|
|
|
if (s->ver == 2) { |
|
|
|
s->deflate_block_size = calc_deflate_block_size(tmpblock_size); |
|
|
|
s->deflate_block_size = calc_deflate_block_size(tmpblock_size); |
|
|
@ -311,12 +311,10 @@ static int flashsv_decode_frame(AVCodecContext *avctx, void *data, |
|
|
|
"Cannot determine deflate buffer size.\n"); |
|
|
|
"Cannot determine deflate buffer size.\n"); |
|
|
|
return -1; |
|
|
|
return -1; |
|
|
|
} |
|
|
|
} |
|
|
|
s->deflate_block = av_realloc(s->deflate_block, |
|
|
|
if ((err = av_reallocp(&s->deflate_block, s->deflate_block_size)) < 0) { |
|
|
|
s->deflate_block_size); |
|
|
|
s->block_size = 0; |
|
|
|
if (!s->deflate_block) { |
|
|
|
av_log(avctx, AV_LOG_ERROR, "Cannot allocate deflate buffer.\n"); |
|
|
|
av_log(avctx, AV_LOG_ERROR, |
|
|
|
return err; |
|
|
|
"Cannot allocate deflate buffer.\n"); |
|
|
|
|
|
|
|
return AVERROR(ENOMEM); |
|
|
|
|
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
@ -340,11 +338,13 @@ static int flashsv_decode_frame(AVCodecContext *avctx, void *data, |
|
|
|
/* we care for keyframes only in Screen Video v2 */ |
|
|
|
/* we care for keyframes only in Screen Video v2 */ |
|
|
|
s->is_keyframe = (avpkt->flags & AV_PKT_FLAG_KEY) && (s->ver == 2); |
|
|
|
s->is_keyframe = (avpkt->flags & AV_PKT_FLAG_KEY) && (s->ver == 2); |
|
|
|
if (s->is_keyframe) { |
|
|
|
if (s->is_keyframe) { |
|
|
|
s->keyframedata = av_realloc(s->keyframedata, avpkt->size); |
|
|
|
int err; |
|
|
|
|
|
|
|
if ((err = av_reallocp(&s->keyframedata, avpkt->size)) < 0) |
|
|
|
|
|
|
|
return err; |
|
|
|
memcpy(s->keyframedata, avpkt->data, avpkt->size); |
|
|
|
memcpy(s->keyframedata, avpkt->data, avpkt->size); |
|
|
|
s->blocks = av_realloc(s->blocks, |
|
|
|
if ((err = av_reallocp(&s->blocks, (v_blocks + !!v_part) * |
|
|
|
(v_blocks + !!v_part) * (h_blocks + !!h_part) * |
|
|
|
(h_blocks + !!h_part) * sizeof(s->blocks[0]))) < 0) |
|
|
|
sizeof(s->blocks[0])); |
|
|
|
return err; |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
av_dlog(avctx, "image: %dx%d block: %dx%d num: %dx%d part: %dx%d\n", |
|
|
|
av_dlog(avctx, "image: %dx%d block: %dx%d num: %dx%d part: %dx%d\n", |
|
|
|