[MPlayer-cvslog] r31659 - trunk/spudec.c
reimar
subversion at mplayerhq.hu
Sat Jul 10 12:22:28 CEST 2010
Author: reimar
Date: Sat Jul 10 12:22:28 2010
New Revision: 31659
Log:
Extract spudec image allocation code to a separate function.
Modified:
trunk/spudec.c
Modified: trunk/spudec.c
==============================================================================
--- trunk/spudec.c Sat Jul 10 10:07:27 2010 (r31658)
+++ trunk/spudec.c Sat Jul 10 12:22:28 2010 (r31659)
@@ -224,6 +224,27 @@ static inline void spudec_cut_image(spud
}
}
+
+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_h
}
}
- 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. */
More information about the MPlayer-cvslog
mailing list