aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorMichael Niedermayer <michael@niedermayer.cc>2018-12-16 19:04:56 +0100
committerMichael Niedermayer <michael@niedermayer.cc>2019-03-24 10:38:51 +0100
commit3ca0a8e077fc2281165f3d343b4f7a26f02a080a (patch)
treeb975e8846000fa937f884b97e83f65dbf1cc4132
parent4556f7c8a2106ad514c84576b28e05249e1b6862 (diff)
downloadffmpeg-3ca0a8e077fc2281165f3d343b4f7a26f02a080a.tar.gz
avcodec/rpza: Move frame allocation to a later point
This will allow performing some fast checks before the slow allocation Signed-off-by: Michael Niedermayer <michael@niedermayer.cc> (cherry picked from commit 8a708aa99cb0e8d76e52117b1fd89d221f0055e9) Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
-rw-r--r--libavcodec/rpza.c14
1 files changed, 8 insertions, 6 deletions
diff --git a/libavcodec/rpza.c b/libavcodec/rpza.c
index b71ebd1cbe..cffbfe4416 100644
--- a/libavcodec/rpza.c
+++ b/libavcodec/rpza.c
@@ -73,13 +73,12 @@ typedef struct RpzaContext {
static int rpza_decode_stream(RpzaContext *s)
{
int width = s->avctx->width;
- int stride = s->frame->linesize[0] / 2;
- int row_inc = stride - 4;
+ int stride, row_inc, ret;
int chunk_size;
uint16_t colorA = 0, colorB;
uint16_t color4[4];
uint16_t ta, tb;
- uint16_t *pixels = (uint16_t *)s->frame->data[0];
+ uint16_t *pixels;
int row_ptr = 0;
int pixel_ptr = 0;
@@ -106,6 +105,12 @@ static int rpza_decode_stream(RpzaContext *s)
/* Number of 4x4 blocks in frame. */
total_blocks = ((s->avctx->width + 3) / 4) * ((s->avctx->height + 3) / 4);
+ if ((ret = ff_reget_buffer(s->avctx, s->frame)) < 0)
+ return ret;
+ pixels = (uint16_t *)s->frame->data[0];
+ stride = s->frame->linesize[0] / 2;
+ row_inc = stride - 4;
+
/* Process chunk data */
while (bytestream2_get_bytes_left(&s->gb)) {
uint8_t opcode = bytestream2_get_byte(&s->gb); /* Get opcode */
@@ -256,9 +261,6 @@ static int rpza_decode_frame(AVCodecContext *avctx,
bytestream2_init(&s->gb, avpkt->data, avpkt->size);
- if ((ret = ff_reget_buffer(avctx, s->frame)) < 0)
- return ret;
-
ret = rpza_decode_stream(s);
if (ret < 0)
return ret;