summaryrefslogtreecommitdiff
path: root/libavcodec/h264_direct.c
diff options
context:
space:
mode:
authorMichael Niedermayer <michaelni@gmx.at>2010-02-08 02:09:27 +0000
committerMichael Niedermayer <michaelni@gmx.at>2010-02-08 02:09:27 +0000
commit35c8b9c094eebbbead9d818201bc20ea6a3258a2 (patch)
treefcfc5b3939b77f6763193ed18490a065646da1c7 /libavcodec/h264_direct.c
parentb317567cf437a515acf75abee2a3bb7a6b047938 (diff)
Replace call to pred_motion() in direct spatial mv pred by code
and simplify cases that cannot happen away. 8 cpu cycles faster Originally committed as revision 21683 to svn://svn.ffmpeg.org/ffmpeg/trunk
Diffstat (limited to 'libavcodec/h264_direct.c')
-rw-r--r--libavcodec/h264_direct.c34
1 files changed, 28 insertions, 6 deletions
diff --git a/libavcodec/h264_direct.c b/libavcodec/h264_direct.c
index e7e62d66c1..a70e041a69 100644
--- a/libavcodec/h264_direct.c
+++ b/libavcodec/h264_direct.c
@@ -30,7 +30,6 @@
#include "avcodec.h"
#include "mpegvideo.h"
#include "h264.h"
-#include "h264_mvpred.h"
#include "rectangle.h"
//#undef NDEBUG
@@ -225,14 +224,37 @@ single_col:
/* ref = min(neighbors) */
for(list=0; list<2; list++){
- int refa = h->ref_cache[list][scan8[0] - 1];
- int refb = h->ref_cache[list][scan8[0] - 8];
+ int left_ref = h->ref_cache[list][scan8[0] - 1];
+ int top_ref = h->ref_cache[list][scan8[0] - 8];
int refc = h->ref_cache[list][scan8[0] - 8 + 4];
- if(refc == PART_NOT_AVAILABLE)
+ const int16_t *C= h->mv_cache[list][ scan8[0] - 8 + 4];
+ if(refc == PART_NOT_AVAILABLE){
refc = h->ref_cache[list][scan8[0] - 8 - 1];
- ref[list] = FFMIN3((unsigned)refa, (unsigned)refb, (unsigned)refc);
+ C = h-> mv_cache[list][scan8[0] - 8 - 1];
+ }
+ ref[list] = FFMIN3((unsigned)left_ref, (unsigned)top_ref, (unsigned)refc);
if(ref[list] >= 0){
- pred_motion(h, 0, 4, list, ref[list], &mv[list][0], &mv[list][1]);
+ //this is just pred_motion() but with the cases removed that cannot happen for direct blocks
+ const int16_t * const A= h->mv_cache[list][ scan8[0] - 1 ];
+ const int16_t * const B= h->mv_cache[list][ scan8[0] - 8 ];
+
+ int match_count= (left_ref==ref[list]) + (top_ref==ref[list]) + (refc==ref[list]);
+ if(match_count > 1){ //most common
+ mv[list][0]= mid_pred(A[0], B[0], C[0]);
+ mv[list][1]= mid_pred(A[1], B[1], C[1]);
+ }else {
+ assert(match_count==1);
+ if(left_ref==ref[list]){
+ mv[list][0]= A[0];
+ mv[list][1]= A[1];
+ }else if(top_ref==ref[list]){
+ mv[list][0]= B[0];
+ mv[list][1]= B[1];
+ }else{
+ mv[list][0]= C[0];
+ mv[list][1]= C[1];
+ }
+ }
}else{
int mask= ~(MB_TYPE_L0 << (2*list));
mv[list][0] = mv[list][1] = 0;