OLD | NEW |
1 /* | 1 /* |
2 * H.26L/H.264/AVC/JVT/14496-10/... motion vector predicion | 2 * H.26L/H.264/AVC/JVT/14496-10/... motion vector predicion |
3 * Copyright (c) 2003 Michael Niedermayer <michaelni@gmx.at> | 3 * Copyright (c) 2003 Michael Niedermayer <michaelni@gmx.at> |
4 * | 4 * |
5 * This file is part of FFmpeg. | 5 * This file is part of FFmpeg. |
6 * | 6 * |
7 * FFmpeg is free software; you can redistribute it and/or | 7 * FFmpeg is free software; you can redistribute it and/or |
8 * modify it under the terms of the GNU Lesser General Public | 8 * modify it under the terms of the GNU Lesser General Public |
9 * License as published by the Free Software Foundation; either | 9 * License as published by the Free Software Foundation; either |
10 * version 2.1 of the License, or (at your option) any later version. | 10 * version 2.1 of the License, or (at your option) any later version. |
(...skipping 25 matching lines...) Expand all Loading... |
36 #include <assert.h> | 36 #include <assert.h> |
37 | 37 |
38 static inline int fetch_diagonal_mv(H264Context *h, const int16_t **C, int i, in
t list, int part_width){ | 38 static inline int fetch_diagonal_mv(H264Context *h, const int16_t **C, int i, in
t list, int part_width){ |
39 const int topright_ref= h->ref_cache[list][ i - 8 + part_width ]; | 39 const int topright_ref= h->ref_cache[list][ i - 8 + part_width ]; |
40 MpegEncContext *s = &h->s; | 40 MpegEncContext *s = &h->s; |
41 | 41 |
42 /* there is no consistent mapping of mvs to neighboring locations that will | 42 /* there is no consistent mapping of mvs to neighboring locations that will |
43 * make mbaff happy, so we can't move all this logic to fill_caches */ | 43 * make mbaff happy, so we can't move all this logic to fill_caches */ |
44 if(FRAME_MBAFF){ | 44 if(FRAME_MBAFF){ |
45 | 45 |
46 #define SET_DIAG_MV(MV_OP, REF_OP, X4, Y4)\ | 46 #define SET_DIAG_MV(MV_OP, REF_OP, XY, Y4)\ |
47 const int x4 = X4, y4 = Y4;\ | 47 const int xy = XY, y4 = Y4;\ |
48 const int mb_type = mb_types[(x4>>2)+(y4>>2)*s->mb_stride];\ | 48 const int mb_type = mb_types[xy+(y4>>2)*s->mb_stride];\ |
49 if(!USES_LIST(mb_type,list))\ | 49 if(!USES_LIST(mb_type,list))\ |
50 return LIST_NOT_USED;\ | 50 return LIST_NOT_USED;\ |
51 mv = s->current_picture_ptr->motion_val[list][x4 + y4*h->b_strid
e];\ | 51 mv = s->current_picture_ptr->motion_val[list][h->mb2b_xy[xy]+3 +
y4*h->b_stride];\ |
52 h->mv_cache[list][scan8[0]-2][0] = mv[0];\ | 52 h->mv_cache[list][scan8[0]-2][0] = mv[0];\ |
53 h->mv_cache[list][scan8[0]-2][1] = mv[1] MV_OP;\ | 53 h->mv_cache[list][scan8[0]-2][1] = mv[1] MV_OP;\ |
54 return s->current_picture_ptr->ref_index[list][(x4>>1) + (y4>>1)
*h->b8_stride] REF_OP; | 54 return s->current_picture_ptr->ref_index[list][4*xy+1 + (y4&~1)]
REF_OP; |
55 | 55 |
56 if(topright_ref == PART_NOT_AVAILABLE | 56 if(topright_ref == PART_NOT_AVAILABLE |
57 && i >= scan8[0]+8 && (i&7)==4 | 57 && i >= scan8[0]+8 && (i&7)==4 |
58 && h->ref_cache[list][scan8[0]-1] != PART_NOT_AVAILABLE){ | 58 && h->ref_cache[list][scan8[0]-1] != PART_NOT_AVAILABLE){ |
59 const uint32_t *mb_types = s->current_picture_ptr->mb_type; | 59 const uint32_t *mb_types = s->current_picture_ptr->mb_type; |
60 const int16_t *mv; | 60 const int16_t *mv; |
61 *(uint32_t*)h->mv_cache[list][scan8[0]-2] = 0; | 61 AV_ZERO32(h->mv_cache[list][scan8[0]-2]); |
62 *C = h->mv_cache[list][scan8[0]-2]; | 62 *C = h->mv_cache[list][scan8[0]-2]; |
63 | 63 |
64 if(!MB_FIELD | 64 if(!MB_FIELD |
65 && IS_INTERLACED(mb_types[h->left_mb_xy[0]])){ | 65 && IS_INTERLACED(h->left_type[0])){ |
66 SET_DIAG_MV(*2, >>1, s->mb_x*4-1, (s->mb_y|1)*4+(s->mb_y&1)*2+(i
>>4)-1); | 66 SET_DIAG_MV(*2, >>1, h->left_mb_xy[0]+s->mb_stride, (s->mb_y&1)*
2+(i>>5)); |
| 67 assert(h->left_mb_xy[0] == h->left_mb_xy[1]); |
67 } | 68 } |
68 if(MB_FIELD | 69 if(MB_FIELD |
69 && !IS_INTERLACED(mb_types[h->left_mb_xy[0]])){ | 70 && !IS_INTERLACED(h->left_type[0])){ |
70 // left shift will turn LIST_NOT_USED into PART_NOT_AVAILABLE, b
ut that's OK. | 71 // left shift will turn LIST_NOT_USED into PART_NOT_AVAILABLE, b
ut that's OK. |
71 SET_DIAG_MV(/2, <<1, s->mb_x*4-1, (s->mb_y&~1)*4 - 1 + ((i-scan8
[0])>>3)*2); | 72 SET_DIAG_MV(/2, <<1, h->left_mb_xy[i>=36], ((i>>2))&3); |
72 } | 73 } |
73 } | 74 } |
74 #undef SET_DIAG_MV | 75 #undef SET_DIAG_MV |
75 } | 76 } |
76 | 77 |
77 if(topright_ref != PART_NOT_AVAILABLE){ | 78 if(topright_ref != PART_NOT_AVAILABLE){ |
78 *C= h->mv_cache[list][ i - 8 + part_width ]; | 79 *C= h->mv_cache[list][ i - 8 + part_width ]; |
79 return topright_ref; | 80 return topright_ref; |
80 }else{ | 81 }else{ |
81 tprintf(s->avctx, "topright MV not available\n"); | 82 tprintf(s->avctx, "topright MV not available\n"); |
(...skipping 131 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
213 pred_motion(h, n, 2, list, ref, mx, my); | 214 pred_motion(h, n, 2, list, ref, mx, my); |
214 } | 215 } |
215 | 216 |
216 static inline void pred_pskip_motion(H264Context * const h, int * const mx, int
* const my){ | 217 static inline void pred_pskip_motion(H264Context * const h, int * const mx, int
* const my){ |
217 const int top_ref = h->ref_cache[0][ scan8[0] - 8 ]; | 218 const int top_ref = h->ref_cache[0][ scan8[0] - 8 ]; |
218 const int left_ref= h->ref_cache[0][ scan8[0] - 1 ]; | 219 const int left_ref= h->ref_cache[0][ scan8[0] - 1 ]; |
219 | 220 |
220 tprintf(h->s.avctx, "pred_pskip: (%d) (%d) at %2d %2d\n", top_ref, left_ref,
h->s.mb_x, h->s.mb_y); | 221 tprintf(h->s.avctx, "pred_pskip: (%d) (%d) at %2d %2d\n", top_ref, left_ref,
h->s.mb_x, h->s.mb_y); |
221 | 222 |
222 if(top_ref == PART_NOT_AVAILABLE || left_ref == PART_NOT_AVAILABLE | 223 if(top_ref == PART_NOT_AVAILABLE || left_ref == PART_NOT_AVAILABLE |
223 || !( top_ref | *(uint32_t*)h->mv_cache[0][ scan8[0] - 8 ]) | 224 || !( top_ref | AV_RN32A(h->mv_cache[0][ scan8[0] - 8 ])) |
224 || !(left_ref | *(uint32_t*)h->mv_cache[0][ scan8[0] - 1 ])){ | 225 || !(left_ref | AV_RN32A(h->mv_cache[0][ scan8[0] - 1 ]))){ |
225 | 226 |
226 *mx = *my = 0; | 227 *mx = *my = 0; |
227 return; | 228 return; |
228 } | 229 } |
229 | 230 |
230 pred_motion(h, 0, 4, 0, 0, mx, my); | 231 pred_motion(h, 0, 4, 0, 0, mx, my); |
231 | 232 |
232 return; | 233 return; |
233 } | 234 } |
234 | 235 |
235 #endif /* AVCODEC_H264_MVPRED_H */ | 236 #endif /* AVCODEC_H264_MVPRED_H */ |
OLD | NEW |