---
 libavcodec/h264.c |   44 ++++++++++++++++++++++----------------------
 1 files changed, 22 insertions(+), 22 deletions(-)
diff --git a/libavcodec/h264.c b/libavcodec/h264.c
index ba435fa..95a5aed 100644
--- a/libavcodec/h264.c
+++ b/libavcodec/h264.c
@@ -1638,16 +1638,16 @@ static inline int quantize_c(DCTELEM *block, uint8_t *scantable, int qscale, int
     return last_non_zero;
 }
 
-static inline int mc_dir_part_y(H264Context *h, Picture *pic, int n, int delta, int list,
-                                 int src_y_offset){
+static inline int mc_dir_part_y(H264Context *h, Picture *pic, int n, int height,
+                                 int y_offset, int list){
     MpegEncContext * const s = &h->s;
-    int my= h->mv_cache[list][ scan8[n] ][1] + src_y_offset*8;
+    int my= h->mv_cache[list][ scan8[n] ][1] + 4*y_offset;
     int filter_height= 6;
     int extra_height= h->emu_edge_height;
     const int full_my= my>>2;
 
     if(!pic->data[0]) return -1;
-    if(pic->reference != PICT_FRAME) return 16*s->mb_height-1;
+    if((pic->reference&3) != PICT_FRAME) return 16*s->mb_height-1;
 
     if(full_my < (extra_height + filter_height)){
         my = abs(my) + extra_height*4;
@@ -1663,21 +1663,21 @@ static inline int mc_dir_part_y(H264Context *h, Picture *pic, int n, int delta,
         }
     }*/
 
-    return (my + delta * 4 + filter_height * 4 + 1) >> 2;
+    return (my + height * 4 + filter_height * 4 + 1) >> 2;
 }
 
-static inline void mc_part_y(H264Context *h, int refs[2][48], int n, int delta,
+static inline void mc_part_y(H264Context *h, int refs[2][48], int n, int height,
                                int y_offset, int list0, int list1){
     MpegEncContext * const s = &h->s;
     int my;
 
-    y_offset += 8*(s->mb_y >> MB_FIELD);
+    y_offset += 16*(s->mb_y >> MB_FIELD);
 
     if(list0){
         int ref_n = h->ref_cache[0][ scan8[n] ], my;
         Picture *ref= &h->ref_list[0][ref_n];
         if(ref->thread_opaque != s->current_picture_ptr->thread_opaque){
-            my = mc_dir_part_y(h, ref, n, delta, 0, y_offset);
+            my = mc_dir_part_y(h, ref, n, height, y_offset, 0);
             refs[0][ref_n] = FFMAX(refs[0][ref_n], my);
         }
     }
@@ -1686,7 +1686,7 @@ static inline void mc_part_y(H264Context *h, int refs[2][48], int n, int delta,
         int ref_n = h->ref_cache[1][ scan8[n] ];
         Picture *ref= &h->ref_list[1][ref_n];
         if(ref->thread_opaque != s->current_picture_ptr->thread_opaque){
-            my = mc_dir_part_y(h, ref, n, delta, 1, y_offset);
+            my = mc_dir_part_y(h, ref, n, height, y_offset, 1);
             refs[1][ref_n] = FFMAX(refs[1][ref_n], my);
         }
     }
@@ -1708,17 +1708,17 @@ static void avail_motion(H264Context *h){
     memset(refs, -1, sizeof(refs));
 
     if(IS_16X16(mb_type)){
-        mc_part_y(h, refs, 0, 0, 0,
+        mc_part_y(h, refs, 0, 16, 0,
                   IS_DIR(mb_type, 0, 0), IS_DIR(mb_type, 0, 1));
     }else if(IS_16X8(mb_type)){
-        mc_part_y(h, refs, 0, 0, 0,
+        mc_part_y(h, refs, 0, 8, 0,
                   IS_DIR(mb_type, 0, 0), IS_DIR(mb_type, 0, 1));
-        mc_part_y(h, refs, 8, 0, 4,
+        mc_part_y(h, refs, 8, 8, 8,
                   IS_DIR(mb_type, 1, 0), IS_DIR(mb_type, 1, 1));
     }else if(IS_8X16(mb_type)){
-        mc_part_y(h, refs, 0, 8, 0,
+        mc_part_y(h, refs, 0, 16, 0,
                   IS_DIR(mb_type, 0, 0), IS_DIR(mb_type, 0, 1));
-        mc_part_y(h, refs, 4, 8, 0,
+        mc_part_y(h, refs, 4, 16, 0,
                   IS_DIR(mb_type, 1, 0), IS_DIR(mb_type, 1, 1));
     }else{
         int i;
@@ -1728,27 +1728,27 @@ static void avail_motion(H264Context *h){
         for(i=0; i<4; i++){
             const int sub_mb_type= h->sub_mb_type[i];
             const int n= 4*i;
-            int y_offset= (i&2)<<1;
+            int y_offset= (i&2)<<2;
 
             if(IS_SUB_8X8(sub_mb_type)){
-                mc_part_y(h, refs, n  , 0, y_offset,
+                mc_part_y(h, refs, n  , 8, y_offset,
                           IS_DIR(sub_mb_type, 0, 0), IS_DIR(sub_mb_type, 0, 1));
             }else if(IS_SUB_8X4(sub_mb_type)){
-                mc_part_y(h, refs, n  , 0, y_offset,
+                mc_part_y(h, refs, n  , 4, y_offset,
                           IS_DIR(sub_mb_type, 0, 0), IS_DIR(sub_mb_type, 0, 1));
-                mc_part_y(h, refs, n+2, 0, y_offset+2,
+                mc_part_y(h, refs, n+2, 4, y_offset+4,
                           IS_DIR(sub_mb_type, 0, 0), IS_DIR(sub_mb_type, 0, 1));
             }else if(IS_SUB_4X8(sub_mb_type)){
-                mc_part_y(h, refs, n  , 4, y_offset,
+                mc_part_y(h, refs, n  , 8, y_offset,
                           IS_DIR(sub_mb_type, 0, 0), IS_DIR(sub_mb_type, 0, 1));
-                mc_part_y(h, refs, n+1, 4, y_offset,
+                mc_part_y(h, refs, n+1, 8, y_offset,
                           IS_DIR(sub_mb_type, 0, 0), IS_DIR(sub_mb_type, 0, 1));
             }else{
                 int j;
                 assert(IS_SUB_4X4(sub_mb_type));
                 for(j=0; j<4; j++){
-                    int sub_y_offset= y_offset +   (j&2);
-                    mc_part_y(h, refs, n+j, 0, sub_y_offset,
+                    int sub_y_offset= y_offset + 2*(j&2);
+                    mc_part_y(h, refs, n+j, 4, sub_y_offset,
                               IS_DIR(sub_mb_type, 0, 0), IS_DIR(sub_mb_type, 0, 1));
                 }
             }
_______________________________________________
FFmpeg-soc mailing list
[email protected]
https://lists.mplayerhq.hu/mailman/listinfo/ffmpeg-soc

Reply via email to