|
|
@ -178,9 +178,9 @@ static void fill_caches(H264Context *h, int mb_type, int for_deblock){ |
|
|
|
if(for_deblock){ |
|
|
|
if(for_deblock){ |
|
|
|
topleft_type = 0; |
|
|
|
topleft_type = 0; |
|
|
|
topright_type = 0; |
|
|
|
topright_type = 0; |
|
|
|
top_type = h->slice_table[top_xy ] < 255 ? s->current_picture.mb_type[top_xy] : 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] ] < 255 ? s->current_picture.mb_type[left_xy[0]] : 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] ] < 255 ? s->current_picture.mb_type[left_xy[1]] : 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)){ |
|
|
|
if(MB_MBAFF && !IS_INTRA(mb_type)){ |
|
|
|
int list; |
|
|
|
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->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->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->cbp_table, big_mb_num * sizeof(uint16_t)) |
|
|
|
|
|
|
|
|
|
|
|
CHECKED_ALLOCZ(h->chroma_pred_mode_table, big_mb_num * sizeof(uint8_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->mvd_table[1], 32*big_mb_num * sizeof(uint16_t)); |
|
|
|
CHECKED_ALLOCZ(h->direct_table, 32*big_mb_num * sizeof(uint8_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; |
|
|
|
h->slice_table= h->slice_table_base + s->mb_stride*2 + 1; |
|
|
|
|
|
|
|
|
|
|
|
CHECKED_ALLOCZ(h->mb2b_xy , big_mb_num * sizeof(uint32_t)); |
|
|
|
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 */ |
|
|
|
/* some macroblocks will be accessed before they're available */ |
|
|
|
if(FRAME_MBAFF || s->avctx->thread_count > 1) |
|
|
|
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;
|
|
|
|
// 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; |
|
|
|
h0->last_slice_type = slice_type; |
|
|
|
h->slice_num = ++h0->current_slice; |
|
|
|
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++){ |
|
|
|
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[0]= |
|
|
|
ref2frm[1]= -1; |
|
|
|
ref2frm[1]= -1; |
|
|
|
for(i=0; i<16; i++) |
|
|
|
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 |
|
|
|
if (FRAME_MBAFF |
|
|
|
// left mb is in picture
|
|
|
|
// 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
|
|
|
|
// 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])) |
|
|
|
&& (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
|
|
|
|
// 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; |
|
|
|
int edge; |
|
|
|
const int mbm_xy = dir == 0 ? mb_xy -1 : h->top_mb_xy; |
|
|
|
const int mbm_xy = dir == 0 ? mb_xy -1 : h->top_mb_xy; |
|
|
|
const int mbm_type = s->current_picture.mb_type[mbm_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 (*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]&15 ][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] == 255 ? 1 : 0; |
|
|
|
int start = h->slice_table[mbm_xy] == 0xFFFF ? 1 : 0; |
|
|
|
|
|
|
|
|
|
|
|
const int edges = (mb_type & (MB_TYPE_16x16|MB_TYPE_SKIP)) |
|
|
|
const int edges = (mb_type & (MB_TYPE_16x16|MB_TYPE_SKIP)) |
|
|
|
== (MB_TYPE_16x16|MB_TYPE_SKIP) ? 1 : 4; |
|
|
|
== (MB_TYPE_16x16|MB_TYPE_SKIP) ? 1 : 4; |
|
|
|