mirror of
https://github.com/FFmpeg/FFmpeg.git
synced 2024-12-23 12:43:46 +02:00
Factorize common code from the top of decode_cabac_mb_mvd()
10-15 cpu cycles faster. Originally committed as revision 22029 to svn://svn.ffmpeg.org/ffmpeg/trunk
This commit is contained in:
parent
6164842300
commit
01b35be14a
@ -909,10 +909,7 @@ static int decode_cabac_mb_ref( H264Context *h, int list, int n ) {
|
|||||||
return ref;
|
return ref;
|
||||||
}
|
}
|
||||||
|
|
||||||
static int decode_cabac_mb_mvd( H264Context *h, int list, int n, int l ) {
|
static int decode_cabac_mb_mvd( H264Context *h, int ctxbase, int amvd ) {
|
||||||
int amvd = h->mvd_cache[list][scan8[n] - 1][l] +
|
|
||||||
h->mvd_cache[list][scan8[n] - 8][l];
|
|
||||||
int ctxbase = (l == 0) ? 40 : 47;
|
|
||||||
int mvd;
|
int mvd;
|
||||||
|
|
||||||
if(!get_cabac(&h->cabac, &h->cabac_state[ctxbase+FFMIN(((amvd+28)*17)>>9,2)]))
|
if(!get_cabac(&h->cabac, &h->cabac_state[ctxbase+FFMIN(((amvd+28)*17)>>9,2)]))
|
||||||
@ -943,6 +940,17 @@ static int decode_cabac_mb_mvd( H264Context *h, int list, int n, int l ) {
|
|||||||
return get_cabac_bypass_sign( &h->cabac, -mvd );
|
return get_cabac_bypass_sign( &h->cabac, -mvd );
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#define DECODE_CABAC_MB_MVD( h, list, n )\
|
||||||
|
{\
|
||||||
|
int amvd0 = h->mvd_cache[list][scan8[n] - 1][0] +\
|
||||||
|
h->mvd_cache[list][scan8[n] - 8][0];\
|
||||||
|
int amvd1 = h->mvd_cache[list][scan8[n] - 1][1] +\
|
||||||
|
h->mvd_cache[list][scan8[n] - 8][1];\
|
||||||
|
\
|
||||||
|
mx = mpx + decode_cabac_mb_mvd( h, 40, amvd0 );\
|
||||||
|
my = mpy + decode_cabac_mb_mvd( h, 47, amvd1 );\
|
||||||
|
}
|
||||||
|
|
||||||
static av_always_inline int get_cabac_cbf_ctx( H264Context *h, int cat, int idx, int is_dc ) {
|
static av_always_inline int get_cabac_cbf_ctx( H264Context *h, int cat, int idx, int is_dc ) {
|
||||||
int nza, nzb;
|
int nza, nzb;
|
||||||
int ctx = 0;
|
int ctx = 0;
|
||||||
@ -1433,8 +1441,7 @@ decode_intra_mb:
|
|||||||
int16_t (* mvd_cache)[2]= &h->mvd_cache[list][ scan8[index] ];
|
int16_t (* mvd_cache)[2]= &h->mvd_cache[list][ scan8[index] ];
|
||||||
pred_motion(h, index, block_width, list, h->ref_cache[list][ scan8[index] ], &mpx, &mpy);
|
pred_motion(h, index, block_width, list, h->ref_cache[list][ scan8[index] ], &mpx, &mpy);
|
||||||
|
|
||||||
mx = mpx + decode_cabac_mb_mvd( h, list, index, 0 );
|
DECODE_CABAC_MB_MVD( h, list, index)
|
||||||
my = mpy + decode_cabac_mb_mvd( h, list, index, 1 );
|
|
||||||
tprintf(s->avctx, "final mv:%d %d\n", mx, my);
|
tprintf(s->avctx, "final mv:%d %d\n", mx, my);
|
||||||
|
|
||||||
mpx= abs(mpx-mx);
|
mpx= abs(mpx-mx);
|
||||||
@ -1500,9 +1507,7 @@ decode_intra_mb:
|
|||||||
for(list=0; list<h->list_count; list++){
|
for(list=0; list<h->list_count; list++){
|
||||||
if(IS_DIR(mb_type, 0, list)){
|
if(IS_DIR(mb_type, 0, list)){
|
||||||
pred_motion(h, 0, 4, list, h->ref_cache[list][ scan8[0] ], &mpx, &mpy);
|
pred_motion(h, 0, 4, list, h->ref_cache[list][ scan8[0] ], &mpx, &mpy);
|
||||||
|
DECODE_CABAC_MB_MVD( h, list, 0)
|
||||||
mx = mpx + decode_cabac_mb_mvd( h, list, 0, 0 );
|
|
||||||
my = mpy + decode_cabac_mb_mvd( h, list, 0, 1 );
|
|
||||||
tprintf(s->avctx, "final mv:%d %d\n", mx, my);
|
tprintf(s->avctx, "final mv:%d %d\n", mx, my);
|
||||||
|
|
||||||
fill_rectangle(h->mvd_cache[list][ scan8[0] ], 4, 4, 8, pack16to32(abs(mx-mpx),abs(my-mpy)), 4);
|
fill_rectangle(h->mvd_cache[list][ scan8[0] ], 4, 4, 8, pack16to32(abs(mx-mpx),abs(my-mpy)), 4);
|
||||||
@ -1533,8 +1538,7 @@ decode_intra_mb:
|
|||||||
for(i=0; i<2; i++){
|
for(i=0; i<2; i++){
|
||||||
if(IS_DIR(mb_type, i, list)){
|
if(IS_DIR(mb_type, i, list)){
|
||||||
pred_16x8_motion(h, 8*i, list, h->ref_cache[list][scan8[0] + 16*i], &mpx, &mpy);
|
pred_16x8_motion(h, 8*i, list, h->ref_cache[list][scan8[0] + 16*i], &mpx, &mpy);
|
||||||
mx = mpx + decode_cabac_mb_mvd( h, list, 8*i, 0 );
|
DECODE_CABAC_MB_MVD( h, list, 8*i)
|
||||||
my = mpy + decode_cabac_mb_mvd( h, list, 8*i, 1 );
|
|
||||||
tprintf(s->avctx, "final mv:%d %d\n", mx, my);
|
tprintf(s->avctx, "final mv:%d %d\n", mx, my);
|
||||||
|
|
||||||
fill_rectangle(h->mvd_cache[list][ scan8[0] + 16*i ], 4, 2, 8, pack16to32(abs(mx-mpx),abs(my-mpy)), 4);
|
fill_rectangle(h->mvd_cache[list][ scan8[0] + 16*i ], 4, 2, 8, pack16to32(abs(mx-mpx),abs(my-mpy)), 4);
|
||||||
@ -1568,8 +1572,7 @@ decode_intra_mb:
|
|||||||
for(i=0; i<2; i++){
|
for(i=0; i<2; i++){
|
||||||
if(IS_DIR(mb_type, i, list)){
|
if(IS_DIR(mb_type, i, list)){
|
||||||
pred_8x16_motion(h, i*4, list, h->ref_cache[list][ scan8[0] + 2*i ], &mpx, &mpy);
|
pred_8x16_motion(h, i*4, list, h->ref_cache[list][ scan8[0] + 2*i ], &mpx, &mpy);
|
||||||
mx = mpx + decode_cabac_mb_mvd( h, list, 4*i, 0 );
|
DECODE_CABAC_MB_MVD( h, list, 4*i)
|
||||||
my = mpy + decode_cabac_mb_mvd( h, list, 4*i, 1 );
|
|
||||||
|
|
||||||
tprintf(s->avctx, "final mv:%d %d\n", mx, my);
|
tprintf(s->avctx, "final mv:%d %d\n", mx, my);
|
||||||
fill_rectangle(h->mvd_cache[list][ scan8[0] + 2*i ], 2, 4, 8, pack16to32(abs(mx-mpx),abs(my-mpy)), 4);
|
fill_rectangle(h->mvd_cache[list][ scan8[0] + 2*i ], 2, 4, 8, pack16to32(abs(mx-mpx),abs(my-mpy)), 4);
|
||||||
|
Loading…
Reference in New Issue
Block a user