Commit 69f34e5b authored by Michael Niedermayer's avatar Michael Niedermayer

simplify

Originally committed as revision 5694 to svn://svn.ffmpeg.org/ffmpeg/trunk
parent e148c6e1
...@@ -104,26 +104,18 @@ typedef struct { ...@@ -104,26 +104,18 @@ typedef struct {
* *
****************************************************************************/ ****************************************************************************/
static inline int get_bs_p(vector_t *mvP, vector_t *mvQ) { static inline int get_bs(vector_t *mvP, vector_t *mvQ, int b) {
if((mvP->ref == REF_INTRA) || (mvQ->ref == REF_INTRA)) if((mvP->ref == REF_INTRA) || (mvQ->ref == REF_INTRA))
return 2; return 2;
if(mvP->ref != mvQ->ref) if( (abs(mvP->x - mvQ->x) >= 4) || (abs(mvP->y - mvQ->y) >= 4) )
return 1; return 1;
if(b){
mvP += MV_BWD_OFFS;
mvQ += MV_BWD_OFFS;
if( (abs(mvP->x - mvQ->x) >= 4) || (abs(mvP->y - mvQ->y) >= 4) ) if( (abs(mvP->x - mvQ->x) >= 4) || (abs(mvP->y - mvQ->y) >= 4) )
return 1; return 1;
return 0; }else{
} if(mvP->ref != mvQ->ref)
static inline int get_bs_b(vector_t *mvP, vector_t *mvQ) {
if((mvP->ref == REF_INTRA) || (mvQ->ref == REF_INTRA)) {
return 2;
} else {
vector_t *mvPbw = mvP + MV_BWD_OFFS;
vector_t *mvQbw = mvQ + MV_BWD_OFFS;
if( (abs( mvP->x - mvQ->x) >= 4) ||
(abs( mvP->y - mvQ->y) >= 4) ||
(abs(mvPbw->x - mvQbw->x) >= 4) ||
(abs(mvPbw->y - mvQbw->y) >= 4) )
return 1; return 1;
} }
return 0; return 0;
...@@ -165,52 +157,23 @@ static void filter_mb(AVSContext *h, enum mb_t mb_type) { ...@@ -165,52 +157,23 @@ static void filter_mb(AVSContext *h, enum mb_t mb_type) {
h->left_border_v[i+1] = *(h->cv + 7 + i*h->c_stride); h->left_border_v[i+1] = *(h->cv + 7 + i*h->c_stride);
} }
if(!h->loop_filter_disable) { if(!h->loop_filter_disable) {
/* clear bs */
*((uint64_t *)bs) = 0;
/* determine bs */ /* determine bs */
switch(mb_type) { if(mb_type == I_8X8)
case I_8X8:
*((uint64_t *)bs) = 0x0202020202020202ULL; *((uint64_t *)bs) = 0x0202020202020202ULL;
break; else{
case P_8X8: *((uint64_t *)bs) = 0;
case P_8X16: if(partition_flags[mb_type] & SPLITV){
bs[2] = get_bs_p(&h->mv[MV_FWD_X0], &h->mv[MV_FWD_X1]); bs[2] = get_bs(&h->mv[MV_FWD_X0], &h->mv[MV_FWD_X1], mb_type > P_8X8);
bs[3] = get_bs_p(&h->mv[MV_FWD_X2], &h->mv[MV_FWD_X3]); bs[3] = get_bs(&h->mv[MV_FWD_X2], &h->mv[MV_FWD_X3], mb_type > P_8X8);
case P_16X8: }
bs[6] = get_bs_p(&h->mv[MV_FWD_X0], &h->mv[MV_FWD_X2]); if(partition_flags[mb_type] & SPLITH){
bs[7] = get_bs_p(&h->mv[MV_FWD_X1], &h->mv[MV_FWD_X3]); bs[6] = get_bs(&h->mv[MV_FWD_X0], &h->mv[MV_FWD_X2], mb_type > P_8X8);
case P_16X16: bs[7] = get_bs(&h->mv[MV_FWD_X1], &h->mv[MV_FWD_X3], mb_type > P_8X8);
case P_SKIP:
bs[0] = get_bs_p(&h->mv[MV_FWD_A1], &h->mv[MV_FWD_X0]);
bs[1] = get_bs_p(&h->mv[MV_FWD_A3], &h->mv[MV_FWD_X2]);
bs[4] = get_bs_p(&h->mv[MV_FWD_B2], &h->mv[MV_FWD_X0]);
bs[5] = get_bs_p(&h->mv[MV_FWD_B3], &h->mv[MV_FWD_X1]);
break;
case B_SKIP:
case B_DIRECT:
case B_8X8:
bs[2] = get_bs_b(&h->mv[MV_FWD_X0], &h->mv[MV_FWD_X1]);
bs[3] = get_bs_b(&h->mv[MV_FWD_X2], &h->mv[MV_FWD_X3]);
bs[6] = get_bs_b(&h->mv[MV_FWD_X0], &h->mv[MV_FWD_X2]);
bs[7] = get_bs_b(&h->mv[MV_FWD_X1], &h->mv[MV_FWD_X3]);
case B_FWD_16X16:
case B_BWD_16X16:
case B_SYM_16X16:
bs[0] = get_bs_b(&h->mv[MV_FWD_A1], &h->mv[MV_FWD_X0]);
bs[1] = get_bs_b(&h->mv[MV_FWD_A3], &h->mv[MV_FWD_X2]);
bs[4] = get_bs_b(&h->mv[MV_FWD_B2], &h->mv[MV_FWD_X0]);
bs[5] = get_bs_b(&h->mv[MV_FWD_B3], &h->mv[MV_FWD_X1]);
break;
default:
if(mb_type & 1) { //16X8
bs[6] = bs[7] = get_bs_b(&h->mv[MV_FWD_X0], &h->mv[MV_FWD_X2]);
} else { //8X16
bs[2] = bs[3] = get_bs_b(&h->mv[MV_FWD_X0], &h->mv[MV_FWD_X1]);
} }
bs[0] = get_bs_b(&h->mv[MV_FWD_A1], &h->mv[MV_FWD_X0]); bs[0] = get_bs(&h->mv[MV_FWD_A1], &h->mv[MV_FWD_X0], mb_type > P_8X8);
bs[1] = get_bs_b(&h->mv[MV_FWD_A3], &h->mv[MV_FWD_X2]); bs[1] = get_bs(&h->mv[MV_FWD_A3], &h->mv[MV_FWD_X2], mb_type > P_8X8);
bs[4] = get_bs_b(&h->mv[MV_FWD_B2], &h->mv[MV_FWD_X0]); bs[4] = get_bs(&h->mv[MV_FWD_B2], &h->mv[MV_FWD_X0], mb_type > P_8X8);
bs[5] = get_bs_b(&h->mv[MV_FWD_B3], &h->mv[MV_FWD_X1]); bs[5] = get_bs(&h->mv[MV_FWD_B3], &h->mv[MV_FWD_X1], mb_type > P_8X8);
} }
if( *((uint64_t *)bs) ) { if( *((uint64_t *)bs) ) {
if(h->flags & A_AVAIL) { if(h->flags & A_AVAIL) {
...@@ -486,19 +449,13 @@ static inline void mc_part_std(AVSContext *h,int square,int chroma_height,int de ...@@ -486,19 +449,13 @@ static inline void mc_part_std(AVSContext *h,int square,int chroma_height,int de
} }
static void inter_pred(AVSContext *h, enum mb_t mb_type) { static void inter_pred(AVSContext *h, enum mb_t mb_type) {
switch(mb_type) { if(partition_flags[mb_type] == 0){ // 16x16
case P_SKIP:
case P_16X16:
case B_FWD_16X16:
case B_BWD_16X16:
case B_SYM_16X16:
mc_part_std(h, 1, 8, 0, h->cy, h->cu, h->cv, 0, 0, mc_part_std(h, 1, 8, 0, h->cy, h->cu, h->cv, 0, 0,
h->s.dsp.put_cavs_qpel_pixels_tab[0], h->s.dsp.put_cavs_qpel_pixels_tab[0],
h->s.dsp.put_h264_chroma_pixels_tab[0], h->s.dsp.put_h264_chroma_pixels_tab[0],
h->s.dsp.avg_cavs_qpel_pixels_tab[0], h->s.dsp.avg_cavs_qpel_pixels_tab[0],
h->s.dsp.avg_h264_chroma_pixels_tab[0],&h->mv[MV_FWD_X0]); h->s.dsp.avg_h264_chroma_pixels_tab[0],&h->mv[MV_FWD_X0]);
break; }else{
default:
mc_part_std(h, 1, 4, 0, h->cy, h->cu, h->cv, 0, 0, mc_part_std(h, 1, 4, 0, h->cy, h->cu, h->cv, 0, 0,
h->s.dsp.put_cavs_qpel_pixels_tab[1], h->s.dsp.put_cavs_qpel_pixels_tab[1],
h->s.dsp.put_h264_chroma_pixels_tab[1], h->s.dsp.put_h264_chroma_pixels_tab[1],
...@@ -519,7 +476,6 @@ static void inter_pred(AVSContext *h, enum mb_t mb_type) { ...@@ -519,7 +476,6 @@ static void inter_pred(AVSContext *h, enum mb_t mb_type) {
h->s.dsp.put_h264_chroma_pixels_tab[1], h->s.dsp.put_h264_chroma_pixels_tab[1],
h->s.dsp.avg_cavs_qpel_pixels_tab[1], h->s.dsp.avg_cavs_qpel_pixels_tab[1],
h->s.dsp.avg_h264_chroma_pixels_tab[1],&h->mv[MV_FWD_X3]); h->s.dsp.avg_h264_chroma_pixels_tab[1],&h->mv[MV_FWD_X3]);
break;
} }
/* set intra prediction modes to default values */ /* set intra prediction modes to default values */
h->pred_mode_Y[3] = h->pred_mode_Y[6] = INTRA_L_LP; h->pred_mode_Y[3] = h->pred_mode_Y[6] = INTRA_L_LP;
...@@ -1102,7 +1058,7 @@ static void decode_mb_b(AVSContext *h, enum mb_t mb_type) { ...@@ -1102,7 +1058,7 @@ static void decode_mb_b(AVSContext *h, enum mb_t mb_type) {
break; break;
default: default:
assert((mb_type > B_SYM_16X16) && (mb_type < B_8X8)); assert((mb_type > B_SYM_16X16) && (mb_type < B_8X8));
flags = b_partition_flags[(mb_type-1)>>1]; flags = partition_flags[mb_type];
if(mb_type & 1) { /* 16x8 macroblock types */ if(mb_type & 1) { /* 16x8 macroblock types */
if(flags & FWD0) if(flags & FWD0)
mv_pred(h, MV_FWD_X0, MV_FWD_C2, MV_PRED_TOP, BLK_16X8, 1); mv_pred(h, MV_FWD_X0, MV_FWD_C2, MV_PRED_TOP, BLK_16X8, 1);
......
...@@ -41,6 +41,8 @@ ...@@ -41,6 +41,8 @@
#define BWD1 0x08 #define BWD1 0x08
#define SYM0 0x10 #define SYM0 0x10
#define SYM1 0x20 #define SYM1 0x20
#define SPLITH 0x40
#define SPLITV 0x80
#define MV_BWD_OFFS 12 #define MV_BWD_OFFS 12
#define MV_STRIDE 4 #define MV_STRIDE 4
...@@ -127,17 +129,37 @@ enum mv_loc_t { ...@@ -127,17 +129,37 @@ enum mv_loc_t {
MV_BWD_X3 MV_BWD_X3
}; };
static const uint8_t b_partition_flags[14] = { static const uint8_t partition_flags[30] = {
0,0,0,0,0, 0, //I_8X8
FWD0|FWD1, 0, //P_SKIP
BWD0|BWD1, 0, //P_16X16
FWD0|BWD1, SPLITH, //P_16X8
BWD0|FWD1, SPLITV,//P_8X16
FWD0|SYM1, SPLITH|SPLITV,//P_8X8
BWD0|SYM1, SPLITH|SPLITV,//B_SKIP
SYM0|FWD1, SPLITH|SPLITV,//B_DIRECT
SYM0|BWD1, 0, //B_FWD_16X16
SYM0|SYM1 0, //B_BWD_16X16
0, //B_SYM_16X16
FWD0|FWD1|SPLITH,
FWD0|FWD1 |SPLITV,
BWD0|BWD1|SPLITH,
BWD0|BWD1 |SPLITV,
FWD0|BWD1|SPLITH,
FWD0|BWD1 |SPLITV,
BWD0|FWD1|SPLITH,
BWD0|FWD1 |SPLITV,
FWD0|SYM1|SPLITH,
FWD0|SYM1 |SPLITV,
BWD0|SYM1|SPLITH,
BWD0|SYM1 |SPLITV,
SYM0|FWD1|SPLITH,
SYM0|FWD1 |SPLITV,
SYM0|BWD1|SPLITH,
SYM0|BWD1 |SPLITV,
SYM0|SYM1|SPLITH,
SYM0|SYM1 |SPLITV,
SPLITH|SPLITV,//B_8X8 = 29
}; };
static const uint8_t scan3x3[4] = {4,5,7,8}; static const uint8_t scan3x3[4] = {4,5,7,8};
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment