Mercurial > mplayer.hg
comparison spudec.c @ 31725:8e850ff84b27
Allocate memory for paletted image data separately to avoid
issues with e.g. the "cut" function.
author | reimar |
---|---|
date | Sat, 24 Jul 2010 21:40:06 +0000 |
parents | 2e98a0ed97c8 |
children | 8adcdb0b8ef6 |
comparison
equal
deleted
inserted
replaced
31724:2e98a0ed97c8 | 31725:8e850ff84b27 |
---|---|
226 this->stride = stride; | 226 this->stride = stride; |
227 this->height = height; | 227 this->height = height; |
228 if (this->image_size < this->stride * this->height) { | 228 if (this->image_size < this->stride * this->height) { |
229 if (this->image != NULL) { | 229 if (this->image != NULL) { |
230 free(this->image); | 230 free(this->image); |
231 free(this->pal_image); | |
231 this->image_size = 0; | 232 this->image_size = 0; |
232 } | 233 } |
233 this->image = malloc(3 * this->stride * this->height); | 234 this->image = malloc(2 * this->stride * this->height); |
234 if (this->image) { | 235 if (this->image) { |
235 this->image_size = this->stride * this->height; | 236 this->image_size = this->stride * this->height; |
236 this->aimage = this->image + this->image_size; | 237 this->aimage = this->image + this->image_size; |
237 this->pal_image = this->aimage + this->image_size; | 238 // use stride here as well to simplify reallocation checks |
239 this->pal_image = malloc(this->stride * this->height); | |
238 } | 240 } |
239 } | 241 } |
240 return this->image != NULL; | 242 return this->image != NULL; |
241 } | 243 } |
242 | 244 |
1267 free(spu->packet); | 1269 free(spu->packet); |
1268 if (spu->scaled_image) | 1270 if (spu->scaled_image) |
1269 free(spu->scaled_image); | 1271 free(spu->scaled_image); |
1270 if (spu->image) | 1272 if (spu->image) |
1271 free(spu->image); | 1273 free(spu->image); |
1274 free(spu->pal_image); | |
1272 free(spu); | 1275 free(spu); |
1273 } | 1276 } |
1274 } | 1277 } |
1275 | 1278 |
1276 void spudec_set_hw_spu(void *this, const vo_functions_t *hw_spu) | 1279 void spudec_set_hw_spu(void *this, const vo_functions_t *hw_spu) |