comparison h264.c @ 10137:9a670cfd1941 libavcodec

Rename CHECKED_ALLOC(Z) to FF_ALLOC(Z)_OR_GOTO and add context and label parameters.
author ramiro
date Sun, 06 Sep 2009 00:08:19 +0000
parents 266bf83f634d
children c2fc56bdee95
comparison
equal deleted inserted replaced
10136:399b5d6b5439 10137:9a670cfd1941
2075 static int alloc_tables(H264Context *h){ 2075 static int alloc_tables(H264Context *h){
2076 MpegEncContext * const s = &h->s; 2076 MpegEncContext * const s = &h->s;
2077 const int big_mb_num= s->mb_stride * (s->mb_height+1); 2077 const int big_mb_num= s->mb_stride * (s->mb_height+1);
2078 int x,y; 2078 int x,y;
2079 2079
2080 CHECKED_ALLOCZ(h->intra4x4_pred_mode, big_mb_num * 8 * sizeof(uint8_t)) 2080 FF_ALLOCZ_OR_GOTO(h->s.avctx, h->intra4x4_pred_mode, big_mb_num * 8 * sizeof(uint8_t), fail)
2081 2081
2082 CHECKED_ALLOCZ(h->non_zero_count , big_mb_num * 16 * sizeof(uint8_t)) 2082 FF_ALLOCZ_OR_GOTO(h->s.avctx, h->non_zero_count , big_mb_num * 16 * sizeof(uint8_t), fail)
2083 CHECKED_ALLOCZ(h->slice_table_base , (big_mb_num+s->mb_stride) * sizeof(*h->slice_table_base)) 2083 FF_ALLOCZ_OR_GOTO(h->s.avctx, h->slice_table_base , (big_mb_num+s->mb_stride) * sizeof(*h->slice_table_base), fail)
2084 CHECKED_ALLOCZ(h->cbp_table, big_mb_num * sizeof(uint16_t)) 2084 FF_ALLOCZ_OR_GOTO(h->s.avctx, h->cbp_table, big_mb_num * sizeof(uint16_t), fail)
2085 2085
2086 CHECKED_ALLOCZ(h->chroma_pred_mode_table, big_mb_num * sizeof(uint8_t)) 2086 FF_ALLOCZ_OR_GOTO(h->s.avctx, h->chroma_pred_mode_table, big_mb_num * sizeof(uint8_t), fail)
2087 CHECKED_ALLOCZ(h->mvd_table[0], 32*big_mb_num * sizeof(uint16_t)); 2087 FF_ALLOCZ_OR_GOTO(h->s.avctx, h->mvd_table[0], 32*big_mb_num * sizeof(uint16_t), fail);
2088 CHECKED_ALLOCZ(h->mvd_table[1], 32*big_mb_num * sizeof(uint16_t)); 2088 FF_ALLOCZ_OR_GOTO(h->s.avctx, h->mvd_table[1], 32*big_mb_num * sizeof(uint16_t), fail);
2089 CHECKED_ALLOCZ(h->direct_table, 32*big_mb_num * sizeof(uint8_t)); 2089 FF_ALLOCZ_OR_GOTO(h->s.avctx, h->direct_table, 32*big_mb_num * sizeof(uint8_t) , fail);
2090 2090
2091 memset(h->slice_table_base, -1, (big_mb_num+s->mb_stride) * sizeof(*h->slice_table_base)); 2091 memset(h->slice_table_base, -1, (big_mb_num+s->mb_stride) * sizeof(*h->slice_table_base));
2092 h->slice_table= h->slice_table_base + s->mb_stride*2 + 1; 2092 h->slice_table= h->slice_table_base + s->mb_stride*2 + 1;
2093 2093
2094 CHECKED_ALLOCZ(h->mb2b_xy , big_mb_num * sizeof(uint32_t)); 2094 FF_ALLOCZ_OR_GOTO(h->s.avctx, h->mb2b_xy , big_mb_num * sizeof(uint32_t), fail);
2095 CHECKED_ALLOCZ(h->mb2b8_xy , big_mb_num * sizeof(uint32_t)); 2095 FF_ALLOCZ_OR_GOTO(h->s.avctx, h->mb2b8_xy , big_mb_num * sizeof(uint32_t), fail);
2096 for(y=0; y<s->mb_height; y++){ 2096 for(y=0; y<s->mb_height; y++){
2097 for(x=0; x<s->mb_width; x++){ 2097 for(x=0; x<s->mb_width; x++){
2098 const int mb_xy= x + y*s->mb_stride; 2098 const int mb_xy= x + y*s->mb_stride;
2099 const int b_xy = 4*x + 4*y*h->b_stride; 2099 const int b_xy = 4*x + 4*y*h->b_stride;
2100 const int b8_xy= 2*x + 2*y*h->b8_stride; 2100 const int b8_xy= 2*x + 2*y*h->b8_stride;
2137 /** 2137 /**
2138 * Init context 2138 * Init context
2139 * Allocate buffers which are not shared amongst multiple threads. 2139 * Allocate buffers which are not shared amongst multiple threads.
2140 */ 2140 */
2141 static int context_init(H264Context *h){ 2141 static int context_init(H264Context *h){
2142 CHECKED_ALLOCZ(h->top_borders[0], h->s.mb_width * (16+8+8) * sizeof(uint8_t)) 2142 FF_ALLOCZ_OR_GOTO(h->s.avctx, h->top_borders[0], h->s.mb_width * (16+8+8) * sizeof(uint8_t), fail)
2143 CHECKED_ALLOCZ(h->top_borders[1], h->s.mb_width * (16+8+8) * sizeof(uint8_t)) 2143 FF_ALLOCZ_OR_GOTO(h->s.avctx, h->top_borders[1], h->s.mb_width * (16+8+8) * sizeof(uint8_t), fail)
2144 2144
2145 return 0; 2145 return 0;
2146 fail: 2146 fail:
2147 return -1; // free_tables will clean up for us 2147 return -1; // free_tables will clean up for us
2148 } 2148 }