Mercurial > mplayer.hg
changeset 31593:22272cbfaf28
Extract spudec image allocation code to a separate function.
author | reimar |
---|---|
date | Sat, 10 Jul 2010 10:22:28 +0000 |
parents | a4ceb52caa30 |
children | 8f8d3775d564 |
files | spudec.c |
diffstat | 1 files changed, 22 insertions(+), 12 deletions(-) [+] |
line wrap: on
line diff
--- a/spudec.c Sat Jul 10 08:07:27 2010 +0000 +++ b/spudec.c Sat Jul 10 10:22:28 2010 +0000 @@ -224,6 +224,27 @@ } } + +static int spudec_alloc_image(spudec_handle_t *this, int stride, int height) +{ + if (this->width > stride) // just a safeguard + this->width = stride; + this->stride = stride; + this->height = height; + if (this->image_size < this->stride * this->height) { + if (this->image != NULL) { + free(this->image); + this->image_size = 0; + } + this->image = malloc(2 * this->stride * this->height); + if (this->image) { + this->image_size = this->stride * this->height; + this->aimage = this->image + this->image_size; + } + } + return this->image != NULL; +} + static void spudec_process_data(spudec_handle_t *this, packet_t *packet) { unsigned int cmap[4], alpha[4]; @@ -256,18 +277,7 @@ } } - if (this->image_size < this->stride * this->height) { - if (this->image != NULL) { - free(this->image); - this->image_size = 0; - } - this->image = malloc(2 * this->stride * this->height); - if (this->image) { - this->image_size = this->stride * this->height; - this->aimage = this->image + this->image_size; - } - } - if (this->image == NULL) + if (!spudec_alloc_image(this, this->stride, this->height)) return; /* Kludge: draw_alpha needs width multiple of 8. */