summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--libavcodec/h264.h17
-rw-r--r--libavcodec/h264_cabac.c30
-rw-r--r--libavcodec/h264_cavlc.c34
-rw-r--r--libavcodec/h264_direct.c18
-rw-r--r--libavcodec/h264_mb.c2
-rw-r--r--libavcodec/h264_mc_template.c2
6 files changed, 51 insertions, 52 deletions
diff --git a/libavcodec/h264.h b/libavcodec/h264.h
index c94b818156..6cd30e8663 100644
--- a/libavcodec/h264.h
+++ b/libavcodec/h264.h
@@ -366,6 +366,8 @@ typedef struct H264SliceContext {
*/
DECLARE_ALIGNED(16, int16_t, mv_cache)[2][5 * 8][2];
DECLARE_ALIGNED(8, int8_t, ref_cache)[2][5 * 8];
+
+ DECLARE_ALIGNED(8, uint16_t, sub_mb_type)[4];
} H264SliceContext;
/**
@@ -438,9 +440,6 @@ typedef struct H264Context {
int picture_structure;
int first_field;
- DECLARE_ALIGNED(8, uint16_t, sub_mb_type)[4];
-
-
int direct_spatial_mv_pred;
int col_parity;
int col_fieldoff;
@@ -1027,21 +1026,21 @@ static av_always_inline void write_back_motion(H264Context *h,
if (sl->slice_type_nos == AV_PICTURE_TYPE_B && CABAC(h)) {
if (IS_8X8(mb_type)) {
uint8_t *direct_table = &h->direct_table[4 * h->mb_xy];
- direct_table[1] = h->sub_mb_type[1] >> 1;
- direct_table[2] = h->sub_mb_type[2] >> 1;
- direct_table[3] = h->sub_mb_type[3] >> 1;
+ direct_table[1] = sl->sub_mb_type[1] >> 1;
+ direct_table[2] = sl->sub_mb_type[2] >> 1;
+ direct_table[3] = sl->sub_mb_type[3] >> 1;
}
}
}
-static av_always_inline int get_dct8x8_allowed(H264Context *h)
+static av_always_inline int get_dct8x8_allowed(H264Context *h, H264SliceContext *sl)
{
if (h->sps.direct_8x8_inference_flag)
- return !(AV_RN64A(h->sub_mb_type) &
+ return !(AV_RN64A(sl->sub_mb_type) &
((MB_TYPE_16x8 | MB_TYPE_8x16 | MB_TYPE_8x8) *
0x0001000100010001ULL));
else
- return !(AV_RN64A(h->sub_mb_type) &
+ return !(AV_RN64A(sl->sub_mb_type) &
((MB_TYPE_16x8 | MB_TYPE_8x16 | MB_TYPE_8x8 | MB_TYPE_DIRECT2) *
0x0001000100010001ULL));
}
diff --git a/libavcodec/h264_cabac.c b/libavcodec/h264_cabac.c
index e604c455b5..711b3de0dc 100644
--- a/libavcodec/h264_cabac.c
+++ b/libavcodec/h264_cabac.c
@@ -2090,32 +2090,32 @@ decode_intra_mb:
if (sl->slice_type_nos == AV_PICTURE_TYPE_B ) {
for( i = 0; i < 4; i++ ) {
- h->sub_mb_type[i] = decode_cabac_b_mb_sub_type( h );
- sub_partition_count[i]= b_sub_mb_type_info[ h->sub_mb_type[i] ].partition_count;
- h->sub_mb_type[i]= b_sub_mb_type_info[ h->sub_mb_type[i] ].type;
+ sl->sub_mb_type[i] = decode_cabac_b_mb_sub_type( h );
+ sub_partition_count[i] = b_sub_mb_type_info[sl->sub_mb_type[i]].partition_count;
+ sl->sub_mb_type[i] = b_sub_mb_type_info[sl->sub_mb_type[i]].type;
}
- if( IS_DIRECT(h->sub_mb_type[0] | h->sub_mb_type[1] |
- h->sub_mb_type[2] | h->sub_mb_type[3]) ) {
+ if (IS_DIRECT(sl->sub_mb_type[0] | sl->sub_mb_type[1] |
+ sl->sub_mb_type[2] | sl->sub_mb_type[3])) {
ff_h264_pred_direct_motion(h, sl, &mb_type);
sl->ref_cache[0][scan8[4]] =
sl->ref_cache[1][scan8[4]] =
sl->ref_cache[0][scan8[12]] =
sl->ref_cache[1][scan8[12]] = PART_NOT_AVAILABLE;
for( i = 0; i < 4; i++ )
- fill_rectangle( &h->direct_cache[scan8[4*i]], 2, 2, 8, (h->sub_mb_type[i]>>1)&0xFF, 1 );
+ fill_rectangle(&h->direct_cache[scan8[4*i]], 2, 2, 8, (sl->sub_mb_type[i] >> 1) & 0xFF, 1);
}
} else {
for( i = 0; i < 4; i++ ) {
- h->sub_mb_type[i] = decode_cabac_p_mb_sub_type( h );
- sub_partition_count[i]= p_sub_mb_type_info[ h->sub_mb_type[i] ].partition_count;
- h->sub_mb_type[i]= p_sub_mb_type_info[ h->sub_mb_type[i] ].type;
+ sl->sub_mb_type[i] = decode_cabac_p_mb_sub_type(h);
+ sub_partition_count[i] = p_sub_mb_type_info[sl->sub_mb_type[i]].partition_count;
+ sl->sub_mb_type[i] = p_sub_mb_type_info[sl->sub_mb_type[i]].type;
}
}
for( list = 0; list < h->list_count; list++ ) {
for( i = 0; i < 4; i++ ) {
- if(IS_DIRECT(h->sub_mb_type[i])) continue;
- if(IS_DIR(h->sub_mb_type[i], 0, list)){
+ if(IS_DIRECT(sl->sub_mb_type[i])) continue;
+ if(IS_DIR(sl->sub_mb_type[i], 0, list)){
int rc = h->ref_count[list] << MB_MBAFF(h);
if (rc > 1) {
ref[list][i] = decode_cabac_mb_ref(h, sl, list, 4 * i);
@@ -2134,18 +2134,18 @@ decode_intra_mb:
}
if(dct8x8_allowed)
- dct8x8_allowed = get_dct8x8_allowed(h);
+ dct8x8_allowed = get_dct8x8_allowed(h, sl);
for(list=0; list<h->list_count; list++){
for(i=0; i<4; i++){
sl->ref_cache[list][scan8[4 * i]] = sl->ref_cache[list][scan8[4 * i] + 1];
- if(IS_DIRECT(h->sub_mb_type[i])){
+ if(IS_DIRECT(sl->sub_mb_type[i])){
fill_rectangle(h->mvd_cache[list][scan8[4*i]], 2, 2, 8, 0, 2);
continue;
}
- if(IS_DIR(h->sub_mb_type[i], 0, list) && !IS_DIRECT(h->sub_mb_type[i])){
- const int sub_mb_type= h->sub_mb_type[i];
+ if(IS_DIR(sl->sub_mb_type[i], 0, list) && !IS_DIRECT(sl->sub_mb_type[i])){
+ const int sub_mb_type= sl->sub_mb_type[i];
const int block_width= (sub_mb_type & (MB_TYPE_16x16|MB_TYPE_16x8)) ? 2 : 1;
for(j=0; j<sub_partition_count[i]; j++){
int mpx, mpy;
diff --git a/libavcodec/h264_cavlc.c b/libavcodec/h264_cavlc.c
index 3ccd756544..98a20e16c1 100644
--- a/libavcodec/h264_cavlc.c
+++ b/libavcodec/h264_cavlc.c
@@ -836,15 +836,15 @@ decode_intra_mb:
if (sl->slice_type_nos == AV_PICTURE_TYPE_B) {
for(i=0; i<4; i++){
- h->sub_mb_type[i]= get_ue_golomb_31(&h->gb);
- if(h->sub_mb_type[i] >=13){
- av_log(h->avctx, AV_LOG_ERROR, "B sub_mb_type %u out of range at %d %d\n", h->sub_mb_type[i], h->mb_x, h->mb_y);
+ sl->sub_mb_type[i]= get_ue_golomb_31(&h->gb);
+ if(sl->sub_mb_type[i] >=13){
+ av_log(h->avctx, AV_LOG_ERROR, "B sub_mb_type %u out of range at %d %d\n", sl->sub_mb_type[i], h->mb_x, h->mb_y);
return -1;
}
- sub_partition_count[i]= b_sub_mb_type_info[ h->sub_mb_type[i] ].partition_count;
- h->sub_mb_type[i]= b_sub_mb_type_info[ h->sub_mb_type[i] ].type;
+ sub_partition_count[i]= b_sub_mb_type_info[ sl->sub_mb_type[i] ].partition_count;
+ sl->sub_mb_type[i]= b_sub_mb_type_info[ sl->sub_mb_type[i] ].type;
}
- if( IS_DIRECT(h->sub_mb_type[0]|h->sub_mb_type[1]|h->sub_mb_type[2]|h->sub_mb_type[3])) {
+ if( IS_DIRECT(sl->sub_mb_type[0]|sl->sub_mb_type[1]|sl->sub_mb_type[2]|sl->sub_mb_type[3])) {
ff_h264_pred_direct_motion(h, sl, &mb_type);
sl->ref_cache[0][scan8[4]] =
sl->ref_cache[1][scan8[4]] =
@@ -854,21 +854,21 @@ decode_intra_mb:
}else{
assert(sl->slice_type_nos == AV_PICTURE_TYPE_P); //FIXME SP correct ?
for(i=0; i<4; i++){
- h->sub_mb_type[i]= get_ue_golomb_31(&h->gb);
- if(h->sub_mb_type[i] >=4){
- av_log(h->avctx, AV_LOG_ERROR, "P sub_mb_type %u out of range at %d %d\n", h->sub_mb_type[i], h->mb_x, h->mb_y);
+ sl->sub_mb_type[i]= get_ue_golomb_31(&h->gb);
+ if(sl->sub_mb_type[i] >=4){
+ av_log(h->avctx, AV_LOG_ERROR, "P sub_mb_type %u out of range at %d %d\n", sl->sub_mb_type[i], h->mb_x, h->mb_y);
return -1;
}
- sub_partition_count[i]= p_sub_mb_type_info[ h->sub_mb_type[i] ].partition_count;
- h->sub_mb_type[i]= p_sub_mb_type_info[ h->sub_mb_type[i] ].type;
+ sub_partition_count[i]= p_sub_mb_type_info[ sl->sub_mb_type[i] ].partition_count;
+ sl->sub_mb_type[i]= p_sub_mb_type_info[ sl->sub_mb_type[i] ].type;
}
}
for(list=0; list<h->list_count; list++){
int ref_count = IS_REF0(mb_type) ? 1 : h->ref_count[list] << MB_MBAFF(h);
for(i=0; i<4; i++){
- if(IS_DIRECT(h->sub_mb_type[i])) continue;
- if(IS_DIR(h->sub_mb_type[i], 0, list)){
+ if(IS_DIRECT(sl->sub_mb_type[i])) continue;
+ if(IS_DIR(sl->sub_mb_type[i], 0, list)){
unsigned int tmp;
if(ref_count == 1){
tmp= 0;
@@ -890,19 +890,19 @@ decode_intra_mb:
}
if(dct8x8_allowed)
- dct8x8_allowed = get_dct8x8_allowed(h);
+ dct8x8_allowed = get_dct8x8_allowed(h, sl);
for(list=0; list<h->list_count; list++){
for(i=0; i<4; i++){
- if(IS_DIRECT(h->sub_mb_type[i])) {
+ if(IS_DIRECT(sl->sub_mb_type[i])) {
sl->ref_cache[list][ scan8[4*i] ] = sl->ref_cache[list][ scan8[4*i]+1 ];
continue;
}
sl->ref_cache[list][ scan8[4*i] ]=sl->ref_cache[list][ scan8[4*i]+1 ]=
sl->ref_cache[list][ scan8[4*i]+8 ]=sl->ref_cache[list][ scan8[4*i]+9 ]= ref[list][i];
- if(IS_DIR(h->sub_mb_type[i], 0, list)){
- const int sub_mb_type= h->sub_mb_type[i];
+ if(IS_DIR(sl->sub_mb_type[i], 0, list)){
+ const int sub_mb_type= sl->sub_mb_type[i];
const int block_width= (sub_mb_type & (MB_TYPE_16x16|MB_TYPE_16x8)) ? 2 : 1;
for(j=0; j<sub_partition_count[i]; j++){
int mx, my;
diff --git a/libavcodec/h264_direct.c b/libavcodec/h264_direct.c
index 0700724dd3..f94469522d 100644
--- a/libavcodec/h264_direct.c
+++ b/libavcodec/h264_direct.c
@@ -337,9 +337,9 @@ single_col:
int xy4 = x8 * 3 + y8 * b4_stride;
int a, b;
- if (is_b8x8 && !IS_DIRECT(h->sub_mb_type[i8]))
+ if (is_b8x8 && !IS_DIRECT(sl->sub_mb_type[i8]))
continue;
- h->sub_mb_type[i8] = sub_mb_type;
+ sl->sub_mb_type[i8] = sub_mb_type;
fill_rectangle(&sl->ref_cache[0][scan8[i8 * 4]], 2, 2, 8,
(uint8_t)ref[0], 1);
@@ -401,9 +401,9 @@ single_col:
const int x8 = i8 & 1;
const int y8 = i8 >> 1;
- if (is_b8x8 && !IS_DIRECT(h->sub_mb_type[i8]))
+ if (is_b8x8 && !IS_DIRECT(sl->sub_mb_type[i8]))
continue;
- h->sub_mb_type[i8] = sub_mb_type;
+ sl->sub_mb_type[i8] = sub_mb_type;
fill_rectangle(&sl->mv_cache[0][scan8[i8 * 4]], 2, 2, 8, mv[0], 4);
fill_rectangle(&sl->mv_cache[1][scan8[i8 * 4]], 2, 2, 8, mv[1], 4);
@@ -445,7 +445,7 @@ single_col:
}
}
if (!(m & 3))
- h->sub_mb_type[i8] += MB_TYPE_16x16 - MB_TYPE_8x8;
+ sl->sub_mb_type[i8] += MB_TYPE_16x16 - MB_TYPE_8x8;
n += m;
}
}
@@ -575,9 +575,9 @@ single_col:
int ref0, scale;
const int16_t (*l1mv)[2] = l1mv0;
- if (is_b8x8 && !IS_DIRECT(h->sub_mb_type[i8]))
+ if (is_b8x8 && !IS_DIRECT(sl->sub_mb_type[i8]))
continue;
- h->sub_mb_type[i8] = sub_mb_type;
+ sl->sub_mb_type[i8] = sub_mb_type;
fill_rectangle(&sl->ref_cache[1][scan8[i8 * 4]], 2, 2, 8, 0, 1);
if (IS_INTRA(mb_type_col[y8])) {
@@ -643,9 +643,9 @@ single_col:
int ref0, scale;
const int16_t (*l1mv)[2] = l1mv0;
- if (is_b8x8 && !IS_DIRECT(h->sub_mb_type[i8]))
+ if (is_b8x8 && !IS_DIRECT(sl->sub_mb_type[i8]))
continue;
- h->sub_mb_type[i8] = sub_mb_type;
+ sl->sub_mb_type[i8] = sub_mb_type;
fill_rectangle(&sl->ref_cache[1][scan8[i8 * 4]], 2, 2, 8, 0, 1);
if (IS_INTRA(mb_type_col[0])) {
fill_rectangle(&sl->ref_cache[0][scan8[i8 * 4]], 2, 2, 8, 0, 1);
diff --git a/libavcodec/h264_mb.c b/libavcodec/h264_mb.c
index 9657b5ce53..8d811a0028 100644
--- a/libavcodec/h264_mb.c
+++ b/libavcodec/h264_mb.c
@@ -123,7 +123,7 @@ static void await_references(H264Context *h, H264SliceContext *sl)
assert(IS_8X8(mb_type));
for (i = 0; i < 4; i++) {
- const int sub_mb_type = h->sub_mb_type[i];
+ const int sub_mb_type = sl->sub_mb_type[i];
const int n = 4 * i;
int y_offset = (i & 2) << 2;
diff --git a/libavcodec/h264_mc_template.c b/libavcodec/h264_mc_template.c
index 27e62f0728..beee7111ed 100644
--- a/libavcodec/h264_mc_template.c
+++ b/libavcodec/h264_mc_template.c
@@ -109,7 +109,7 @@ static void MCFUNC(hl_motion)(H264Context *h, H264SliceContext *sl,
assert(IS_8X8(mb_type));
for (i = 0; i < 4; i++) {
- const int sub_mb_type = h->sub_mb_type[i];
+ const int sub_mb_type = sl->sub_mb_type[i];
const int n = 4 * i;
int x_offset = (i & 1) << 2;
int y_offset = (i & 2) << 1;