Mercurial > libavcodec.hg
comparison mpegvideo.c @ 396:fce0a2520551 libavcodec
removed useless header includes - use av memory functions
author | glantau |
---|---|
date | Sat, 18 May 2002 23:03:29 +0000 |
parents | ba9c3b8088c0 |
children | 718a22dc121f |
comparison
equal
deleted
inserted
replaced
395:80518daaab05 | 396:fce0a2520551 |
---|---|
16 * along with this program; if not, write to the Free Software | 16 * along with this program; if not, write to the Free Software |
17 * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. | 17 * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. |
18 * | 18 * |
19 * 4MV & hq & b-frame encoding stuff by Michael Niedermayer <michaelni@gmx.at> | 19 * 4MV & hq & b-frame encoding stuff by Michael Niedermayer <michaelni@gmx.at> |
20 */ | 20 */ |
21 #include <stdlib.h> | |
22 #include <stdio.h> | |
23 #include <math.h> | |
24 #include <string.h> | |
25 #include "avcodec.h" | 21 #include "avcodec.h" |
26 #include "dsputil.h" | 22 #include "dsputil.h" |
27 #include "mpegvideo.h" | 23 #include "mpegvideo.h" |
28 | 24 |
29 #ifdef USE_FASTMEMCPY | 25 #ifdef USE_FASTMEMCPY |
262 | 258 |
263 if (s->out_format == FMT_H263 || s->encoding) { | 259 if (s->out_format == FMT_H263 || s->encoding) { |
264 int size; | 260 int size; |
265 /* MV prediction */ | 261 /* MV prediction */ |
266 size = (2 * s->mb_width + 2) * (2 * s->mb_height + 2); | 262 size = (2 * s->mb_width + 2) * (2 * s->mb_height + 2); |
267 s->motion_val = malloc(size * 2 * sizeof(INT16)); | 263 s->motion_val = av_malloc(size * 2 * sizeof(INT16)); |
268 if (s->motion_val == NULL) | 264 if (s->motion_val == NULL) |
269 goto fail; | 265 goto fail; |
270 memset(s->motion_val, 0, size * 2 * sizeof(INT16)); | 266 memset(s->motion_val, 0, size * 2 * sizeof(INT16)); |
271 } | 267 } |
272 | 268 |
276 /* dc values */ | 272 /* dc values */ |
277 | 273 |
278 y_size = (2 * s->mb_width + 2) * (2 * s->mb_height + 2); | 274 y_size = (2 * s->mb_width + 2) * (2 * s->mb_height + 2); |
279 c_size = (s->mb_width + 2) * (s->mb_height + 2); | 275 c_size = (s->mb_width + 2) * (s->mb_height + 2); |
280 size = y_size + 2 * c_size; | 276 size = y_size + 2 * c_size; |
281 s->dc_val[0] = malloc(size * sizeof(INT16)); | 277 s->dc_val[0] = av_malloc(size * sizeof(INT16)); |
282 if (s->dc_val[0] == NULL) | 278 if (s->dc_val[0] == NULL) |
283 goto fail; | 279 goto fail; |
284 s->dc_val[1] = s->dc_val[0] + y_size; | 280 s->dc_val[1] = s->dc_val[0] + y_size; |
285 s->dc_val[2] = s->dc_val[1] + c_size; | 281 s->dc_val[2] = s->dc_val[1] + c_size; |
286 for(i=0;i<size;i++) | 282 for(i=0;i<size;i++) |
324 fail: | 320 fail: |
325 MPV_common_end(s); | 321 MPV_common_end(s); |
326 return -1; | 322 return -1; |
327 } | 323 } |
328 | 324 |
329 #define CHECK_FREE(p)\ | |
330 {\ | |
331 if(p) free(p);\ | |
332 p= NULL;\ | |
333 } | |
334 | |
335 /* init common structure for both encoder and decoder */ | 325 /* init common structure for both encoder and decoder */ |
336 void MPV_common_end(MpegEncContext *s) | 326 void MPV_common_end(MpegEncContext *s) |
337 { | 327 { |
338 int i; | 328 int i; |
339 | 329 |
340 CHECK_FREE(s->mb_type); | 330 av_freep(&s->mb_type); |
341 CHECK_FREE(s->mb_var); | 331 av_freep(&s->mb_var); |
342 CHECK_FREE(s->p_mv_table); | 332 av_freep(&s->p_mv_table); |
343 CHECK_FREE(s->last_p_mv_table); | 333 av_freep(&s->last_p_mv_table); |
344 CHECK_FREE(s->b_forw_mv_table); | 334 av_freep(&s->b_forw_mv_table); |
345 CHECK_FREE(s->b_back_mv_table); | 335 av_freep(&s->b_back_mv_table); |
346 CHECK_FREE(s->b_bidir_forw_mv_table); | 336 av_freep(&s->b_bidir_forw_mv_table); |
347 CHECK_FREE(s->b_bidir_back_mv_table); | 337 av_freep(&s->b_bidir_back_mv_table); |
348 CHECK_FREE(s->b_direct_forw_mv_table); | 338 av_freep(&s->b_direct_forw_mv_table); |
349 CHECK_FREE(s->b_direct_back_mv_table); | 339 av_freep(&s->b_direct_back_mv_table); |
350 CHECK_FREE(s->b_direct_mv_table); | 340 av_freep(&s->b_direct_mv_table); |
351 CHECK_FREE(s->motion_val); | 341 av_freep(&s->motion_val); |
352 CHECK_FREE(s->dc_val[0]); | 342 av_freep(&s->dc_val[0]); |
353 CHECK_FREE(s->ac_val[0]); | 343 av_freep(&s->ac_val[0]); |
354 CHECK_FREE(s->coded_block); | 344 av_freep(&s->coded_block); |
355 CHECK_FREE(s->mbintra_table); | 345 av_freep(&s->mbintra_table); |
356 CHECK_FREE(s->me_scratchpad); | 346 av_freep(&s->me_scratchpad); |
357 | 347 |
358 CHECK_FREE(s->mbskip_table); | 348 av_freep(&s->mbskip_table); |
359 CHECK_FREE(s->bitstream_buffer); | 349 av_freep(&s->bitstream_buffer); |
360 for(i=0;i<3;i++) { | 350 for(i=0;i<3;i++) { |
361 int j; | 351 int j; |
362 CHECK_FREE(s->last_picture_base[i]); | 352 av_freep(&s->last_picture_base[i]); |
363 CHECK_FREE(s->next_picture_base[i]); | 353 av_freep(&s->next_picture_base[i]); |
364 CHECK_FREE(s->aux_picture_base[i]); | 354 av_freep(&s->aux_picture_base[i]); |
365 for(j=0; j<REORDER_BUFFER_SIZE; j++){ | 355 for(j=0; j<REORDER_BUFFER_SIZE; j++){ |
366 CHECK_FREE(s->picture_buffer[j][i]); | 356 av_freep(&s->picture_buffer[j][i]); |
367 } | 357 } |
368 } | 358 } |
369 s->context_initialized = 0; | 359 s->context_initialized = 0; |
370 } | 360 } |
371 | 361 |