diff options
author | reimar <reimar@b3059339-0415-0410-9bf9-f77b7e298cf2> | 2010-07-10 10:22:28 +0000 |
---|---|---|
committer | Uoti Urpala <uau@glyph.nonexistent.invalid> | 2010-11-02 04:14:37 +0200 |
commit | dd70420bb85b4f6969e6486e9a5865494b0054ea (patch) | |
tree | a3de4c6003d63876161b455ba02325c8e72bcda9 /spudec.c | |
parent | 8200a8d5325412e526a7e85b1fa79056a0be4d35 (diff) | |
download | mpv-dd70420bb85b4f6969e6486e9a5865494b0054ea.tar.bz2 mpv-dd70420bb85b4f6969e6486e9a5865494b0054ea.tar.xz |
spudec.c: Extract image allocation code to a separate function
git-svn-id: svn://svn.mplayerhq.hu/mplayer/trunk@31659 b3059339-0415-0410-9bf9-f77b7e298cf2
Diffstat (limited to 'spudec.c')
-rw-r--r-- | spudec.c | 34 |
1 files changed, 22 insertions, 12 deletions
@@ -224,6 +224,27 @@ static inline void spudec_cut_image(spudec_handle_t *this) } } + +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 @@ static void spudec_process_data(spudec_handle_t *this, packet_t *packet) } } - 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. */ |