diff options
author | Michael Niedermayer <michaelni@gmx.at> | 2008-10-28 22:50:16 +0000 |
---|---|---|
committer | Michael Niedermayer <michaelni@gmx.at> | 2008-10-28 22:50:16 +0000 |
commit | b735aeead8a6222c9164300fc3999989a312fcab (patch) | |
tree | d3bbe5ae94d5535633bea7c237ec2a652cd2d43e /libavcodec/h264.c | |
parent | d5b3a86393197606faa8d0afea5841d97de11cb4 (diff) | |
download | ffmpeg-b735aeead8a6222c9164300fc3999989a312fcab.tar.gz |
Replace literally hardcoded max slice number by named constant.
Originally committed as revision 15736 to svn://svn.ffmpeg.org/ffmpeg/trunk
Diffstat (limited to 'libavcodec/h264.c')
-rw-r--r-- | libavcodec/h264.c | 25 |
1 files changed, 14 insertions, 11 deletions
diff --git a/libavcodec/h264.c b/libavcodec/h264.c index ecd4fc742a..5debc491ab 100644 --- a/libavcodec/h264.c +++ b/libavcodec/h264.c @@ -178,9 +178,9 @@ static void fill_caches(H264Context *h, int mb_type, int for_deblock){ if(for_deblock){ topleft_type = 0; topright_type = 0; - top_type = h->slice_table[top_xy ] < 255 ? s->current_picture.mb_type[top_xy] : 0; - left_type[0] = h->slice_table[left_xy[0] ] < 255 ? s->current_picture.mb_type[left_xy[0]] : 0; - left_type[1] = h->slice_table[left_xy[1] ] < 255 ? s->current_picture.mb_type[left_xy[1]] : 0; + top_type = h->slice_table[top_xy ] < 0xFFFF ? s->current_picture.mb_type[top_xy] : 0; + left_type[0] = h->slice_table[left_xy[0] ] < 0xFFFF ? s->current_picture.mb_type[left_xy[0]] : 0; + left_type[1] = h->slice_table[left_xy[1] ] < 0xFFFF ? s->current_picture.mb_type[left_xy[1]] : 0; if(MB_MBAFF && !IS_INTRA(mb_type)){ int list; @@ -2120,7 +2120,7 @@ static int alloc_tables(H264Context *h){ CHECKED_ALLOCZ(h->intra4x4_pred_mode, big_mb_num * 8 * sizeof(uint8_t)) CHECKED_ALLOCZ(h->non_zero_count , big_mb_num * 16 * sizeof(uint8_t)) - CHECKED_ALLOCZ(h->slice_table_base , (big_mb_num+s->mb_stride) * sizeof(uint8_t)) + CHECKED_ALLOCZ(h->slice_table_base , (big_mb_num+s->mb_stride) * sizeof(*h->slice_table_base)) CHECKED_ALLOCZ(h->cbp_table, big_mb_num * sizeof(uint16_t)) CHECKED_ALLOCZ(h->chroma_pred_mode_table, big_mb_num * sizeof(uint8_t)) @@ -2128,7 +2128,7 @@ static int alloc_tables(H264Context *h){ CHECKED_ALLOCZ(h->mvd_table[1], 32*big_mb_num * sizeof(uint16_t)); CHECKED_ALLOCZ(h->direct_table, 32*big_mb_num * sizeof(uint8_t)); - memset(h->slice_table_base, -1, (big_mb_num+s->mb_stride) * sizeof(uint8_t)); + memset(h->slice_table_base, -1, (big_mb_num+s->mb_stride) * sizeof(*h->slice_table_base)); h->slice_table= h->slice_table_base + s->mb_stride*2 + 1; CHECKED_ALLOCZ(h->mb2b_xy , big_mb_num * sizeof(uint32_t)); @@ -2278,7 +2278,7 @@ static int frame_start(H264Context *h){ /* some macroblocks will be accessed before they're available */ if(FRAME_MBAFF || s->avctx->thread_count > 1) - memset(h->slice_table, -1, (s->mb_height*s->mb_stride-1) * sizeof(uint8_t)); + memset(h->slice_table, -1, (s->mb_height*s->mb_stride-1) * sizeof(*h->slice_table)); // s->decode= (s->flags&CODEC_FLAG_PSNR) || !s->encoding || s->current_picture.reference /*|| h->contains_intra*/ || 1; @@ -4020,9 +4020,12 @@ static int decode_slice_header(H264Context *h, H264Context *h0){ h0->last_slice_type = slice_type; h->slice_num = ++h0->current_slice; + if(h->slice_num >= MAX_SLICES){ + av_log(s->avctx, AV_LOG_ERROR, "Too many slices, increase MAX_SLICES and recompile\n"); + } for(j=0; j<2; j++){ - int *ref2frm= h->ref2frm[h->slice_num&15][j]; + int *ref2frm= h->ref2frm[h->slice_num&(MAX_SLICES-1)][j]; ref2frm[0]= ref2frm[1]= -1; for(i=0; i<16; i++) @@ -6359,7 +6362,7 @@ static void filter_mb( H264Context *h, int mb_x, int mb_y, uint8_t *img_y, uint8 if (FRAME_MBAFF // left mb is in picture - && h->slice_table[mb_xy-1] != 255 + && h->slice_table[mb_xy-1] != 0xFFFF // and current and left pair do not have the same interlaced type && (IS_INTERLACED(mb_type) != IS_INTERLACED(s->current_picture.mb_type[mb_xy-1])) // and left mb is in the same slice if deblocking_filter == 2 @@ -6423,9 +6426,9 @@ static void filter_mb( H264Context *h, int mb_x, int mb_y, uint8_t *img_y, uint8 int edge; const int mbm_xy = dir == 0 ? mb_xy -1 : h->top_mb_xy; const int mbm_type = s->current_picture.mb_type[mbm_xy]; - int (*ref2frm) [64] = h->ref2frm[ h->slice_num &15 ][0] + (MB_MBAFF ? 20 : 2); - int (*ref2frmm)[64] = h->ref2frm[ h->slice_table[mbm_xy]&15 ][0] + (MB_MBAFF ? 20 : 2); - int start = h->slice_table[mbm_xy] == 255 ? 1 : 0; + int (*ref2frm) [64] = h->ref2frm[ h->slice_num &(MAX_SLICES-1) ][0] + (MB_MBAFF ? 20 : 2); + int (*ref2frmm)[64] = h->ref2frm[ h->slice_table[mbm_xy]&(MAX_SLICES-1) ][0] + (MB_MBAFF ? 20 : 2); + int start = h->slice_table[mbm_xy] == 0xFFFF ? 1 : 0; const int edges = (mb_type & (MB_TYPE_16x16|MB_TYPE_SKIP)) == (MB_TYPE_16x16|MB_TYPE_SKIP) ? 1 : 4; |