mirror of
https://github.com/FFmpeg/FFmpeg.git
synced 2024-12-23 12:43:46 +02:00
avcodec/bink: Combine allocations of arrays into one
Saves allocations, checks for the allocations as well as frees. Reviewed-by: Paul B Mahol <onemda@gmail.com> Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@gmail.com>
This commit is contained in:
parent
4f67288948
commit
ceeba2ac2b
@ -178,17 +178,20 @@ static void init_lengths(BinkContext *c, int width, int bw)
|
|||||||
static av_cold int init_bundles(BinkContext *c)
|
static av_cold int init_bundles(BinkContext *c)
|
||||||
{
|
{
|
||||||
int bw, bh, blocks;
|
int bw, bh, blocks;
|
||||||
|
uint8_t *tmp;
|
||||||
int i;
|
int i;
|
||||||
|
|
||||||
bw = (c->avctx->width + 7) >> 3;
|
bw = (c->avctx->width + 7) >> 3;
|
||||||
bh = (c->avctx->height + 7) >> 3;
|
bh = (c->avctx->height + 7) >> 3;
|
||||||
blocks = bw * bh;
|
blocks = bw * bh;
|
||||||
|
|
||||||
|
tmp = av_calloc(blocks, 64 * BINKB_NB_SRC);
|
||||||
|
if (!tmp)
|
||||||
|
return AVERROR(ENOMEM);
|
||||||
for (i = 0; i < BINKB_NB_SRC; i++) {
|
for (i = 0; i < BINKB_NB_SRC; i++) {
|
||||||
c->bundle[i].data = av_mallocz(blocks * 64);
|
c->bundle[i].data = tmp;
|
||||||
if (!c->bundle[i].data)
|
tmp += blocks * 64;
|
||||||
return AVERROR(ENOMEM);
|
c->bundle[i].data_end = tmp;
|
||||||
c->bundle[i].data_end = c->bundle[i].data + blocks * 64;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
return 0;
|
return 0;
|
||||||
@ -201,9 +204,7 @@ static av_cold int init_bundles(BinkContext *c)
|
|||||||
*/
|
*/
|
||||||
static av_cold void free_bundles(BinkContext *c)
|
static av_cold void free_bundles(BinkContext *c)
|
||||||
{
|
{
|
||||||
int i;
|
av_freep(&c->bundle[0].data);
|
||||||
for (i = 0; i < BINKB_NB_SRC; i++)
|
|
||||||
av_freep(&c->bundle[i].data);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
Loading…
Reference in New Issue
Block a user