Commit f018ee78 authored by kostya's avatar kostya

Optimizations suggested by Michael Niedermayer


git-svn-id: file:///var/local/repositories/ffmpeg/trunk@5607 9553f0bf-9b14-0410-a0b8-cfaf0461ba5b
parent 17adfb68
...@@ -1019,20 +1019,15 @@ static void vc1_mc_4mv_luma(VC1Context *v, int n) ...@@ -1019,20 +1019,15 @@ static void vc1_mc_4mv_luma(VC1Context *v, int n)
} }
} }
#define SETMAXMIN(var) \
if(var > ma) ma = var; \
if(var < mi) mi = var;
static inline int median4(int a, int b, int c, int d) static inline int median4(int a, int b, int c, int d)
{ {
int ma, mi; if(a < b) {
if(c < d) return (FFMIN(b, d) + FFMAX(a, c)) >> 1;
ma = mi = a; else return (FFMIN(b, c) + FFMAX(a, d)) >> 1;
SETMAXMIN(b); } else {
SETMAXMIN(c); if(c < d) return (FFMIN(a, d) + FFMAX(b, c)) >> 1;
SETMAXMIN(d); else return (FFMIN(a, c) + FFMAX(b, d)) >> 1;
}
return (a + b + c + d - ma - mi) >> 1;
} }
...@@ -1408,6 +1403,7 @@ static int vc1_parse_frame_header(VC1Context *v, GetBitContext* gb) ...@@ -1408,6 +1403,7 @@ static int vc1_parse_frame_header(VC1Context *v, GetBitContext* gb)
#define GET_MQUANT() \ #define GET_MQUANT() \
if (v->dquantfrm) \ if (v->dquantfrm) \
{ \ { \
int edges = 0; \
if (v->dqprofile == DQPROFILE_ALL_MBS) \ if (v->dqprofile == DQPROFILE_ALL_MBS) \
{ \ { \
if (v->dqbilevel) \ if (v->dqbilevel) \
...@@ -1421,49 +1417,21 @@ static int vc1_parse_frame_header(VC1Context *v, GetBitContext* gb) ...@@ -1421,49 +1417,21 @@ static int vc1_parse_frame_header(VC1Context *v, GetBitContext* gb)
else mquant = get_bits(gb, 5); \ else mquant = get_bits(gb, 5); \
} \ } \
} \ } \
else if(v->dqprofile == DQPROFILE_SINGLE_EDGE) \ if(v->dqprofile == DQPROFILE_SINGLE_EDGE) \
{ \ edges = 1 << v->dqsbedge; \
switch(v->dqsbedge){ \
case 0: /* left */ \
mquant = (s->mb_x) ? v->pq : v->altpq; \
break; \
case 1: /* top */ \
mquant = (s->mb_y) ? v->pq : v->altpq; \
break; \
case 2: /* right */ \
mquant = (s->mb_x != (s->mb_width - 1)) ? v->pq : v->altpq; \
break; \
case 3: /* bottom */ \
mquant = (s->mb_y != (s->mb_height-1)) ? v->pq : v->altpq; \
break; \
default: \
mquant = v->pq; \
} \
} \
else if(v->dqprofile == DQPROFILE_DOUBLE_EDGES) \ else if(v->dqprofile == DQPROFILE_DOUBLE_EDGES) \
{ \ edges = (3 << v->dqsbedge) % 15; \
switch(v->dqsbedge){ \
case 0: /* left and top */ \
mquant = (s->mb_x && s->mb_y) ? v->pq : v->altpq; \
break; \
case 1: /* top and right */ \
mquant = (s->mb_y && s->mb_x != (s->mb_width - 1)) ? v->pq : v->altpq; \
break; \
case 2: /* right and bottom */ \
mquant = (s->mb_x != (s->mb_width - 1) && s->mb_y != (s->mb_height-1)) ? v->pq : v->altpq; \
break; \
case 3: /* bottom and left */ \
mquant = (s->mb_x && s->mb_y != (s->mb_height-1)) ? v->pq : v->altpq; \
break; \
default: \
mquant = v->pq; \
} \
} \
else if(v->dqprofile == DQPROFILE_FOUR_EDGES) \ else if(v->dqprofile == DQPROFILE_FOUR_EDGES) \
{ \ edges = 15; \
mquant = (s->mb_x && s->mb_y && s->mb_x != (s->mb_width - 1) && s->mb_y != (s->mb_height-1)) ? v->pq : v->altpq; \ mquant = v->pq; \
} \ if((edges&1) && !s->mb_x) \
else mquant = v->pq; \ mquant = v->altpq; \
if((edges&2) && !s->mb_y) \
mquant = v->altpq; \
if((edges&4) && s->mb_x == (s->mb_width - 1)) \
mquant = v->altpq; \
if((edges&8) && s->mb_y == (s->mb_height - 1)) \
mquant = v->altpq; \
} }
/** /**
......
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