Replace literally hardcoded max slice number by named constant.

Originally committed as revision 15736 to svn://svn.ffmpeg.org/ffmpeg/trunk
pull/126/head
Michael Niedermayer 16 years ago
parent d5b3a86393
commit b735aeead8
  1. 25
      libavcodec/h264.c
  2. 12
      libavcodec/h264.h

@ -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;

@ -59,6 +59,12 @@
#define ALLOW_NOCHROMA
/**
* The maximum number of slices supported by the decoder.
* must be a power of 2
*/
#define MAX_SLICES 16
#ifdef ALLOW_INTERLACE
#define MB_MBAFF h->mb_mbaff
#define MB_FIELD h->mb_field_decoding_flag
@ -296,8 +302,8 @@ typedef struct H264Context{
int dequant_coeff_pps; ///< reinit tables when pps changes
int slice_num;
uint8_t *slice_table_base;
uint8_t *slice_table; ///< slice_table_base + 2*mb_stride + 1
uint16_t *slice_table_base;
uint16_t *slice_table; ///< slice_table_base + 2*mb_stride + 1
int slice_type;
int slice_type_nos; ///< S free slice type (SI/SP are remapped to I/P)
int slice_type_fixed;
@ -366,7 +372,7 @@ typedef struct H264Context{
Picture ref_list[2][48]; /**< 0..15: frame refs, 16..47: mbaff field refs.
Reordered version of default_ref_list
according to picture reordering in slice header */
int ref2frm[16][2][64]; ///< reference to frame number lists, used in the loop filter, the first 2 are for -2,-1
int ref2frm[MAX_SLICES][2][64]; ///< reference to frame number lists, used in the loop filter, the first 2 are for -2,-1
Picture *delayed_pic[MAX_DELAYED_PIC_COUNT+2]; //FIXME size?
int outputed_poc;

Loading…
Cancel
Save