annotate h264_mvpred.h @ 10864:e3f5eb016712 libavcodec

Split motion vector prediction off h264.c/h.
author michael
date Tue, 12 Jan 2010 21:36:26 +0000
parents h264.c@974ac220c93a
children 5d34ab807e91
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
1168
5af9aeadbdc3 H264 decoder & demuxer
michaelni
parents:
diff changeset
1 /*
10864
e3f5eb016712 Split motion vector prediction off h264.c/h.
michael
parents: 10863
diff changeset
2 * H.26L/H.264/AVC/JVT/14496-10/... motion vector predicion
1168
5af9aeadbdc3 H264 decoder & demuxer
michaelni
parents:
diff changeset
3 * Copyright (c) 2003 Michael Niedermayer <michaelni@gmx.at>
5af9aeadbdc3 H264 decoder & demuxer
michaelni
parents:
diff changeset
4 *
3947
c8c591fe26f8 Change license headers to say 'FFmpeg' instead of 'this program/this library'
diego
parents: 3927
diff changeset
5 * This file is part of FFmpeg.
c8c591fe26f8 Change license headers to say 'FFmpeg' instead of 'this program/this library'
diego
parents: 3927
diff changeset
6 *
c8c591fe26f8 Change license headers to say 'FFmpeg' instead of 'this program/this library'
diego
parents: 3927
diff changeset
7 * FFmpeg is free software; you can redistribute it and/or
1168
5af9aeadbdc3 H264 decoder & demuxer
michaelni
parents:
diff changeset
8 * modify it under the terms of the GNU Lesser General Public
5af9aeadbdc3 H264 decoder & demuxer
michaelni
parents:
diff changeset
9 * License as published by the Free Software Foundation; either
3947
c8c591fe26f8 Change license headers to say 'FFmpeg' instead of 'this program/this library'
diego
parents: 3927
diff changeset
10 * version 2.1 of the License, or (at your option) any later version.
1168
5af9aeadbdc3 H264 decoder & demuxer
michaelni
parents:
diff changeset
11 *
3947
c8c591fe26f8 Change license headers to say 'FFmpeg' instead of 'this program/this library'
diego
parents: 3927
diff changeset
12 * FFmpeg is distributed in the hope that it will be useful,
1168
5af9aeadbdc3 H264 decoder & demuxer
michaelni
parents:
diff changeset
13 * but WITHOUT ANY WARRANTY; without even the implied warranty of
5af9aeadbdc3 H264 decoder & demuxer
michaelni
parents:
diff changeset
14 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
5af9aeadbdc3 H264 decoder & demuxer
michaelni
parents:
diff changeset
15 * Lesser General Public License for more details.
5af9aeadbdc3 H264 decoder & demuxer
michaelni
parents:
diff changeset
16 *
5af9aeadbdc3 H264 decoder & demuxer
michaelni
parents:
diff changeset
17 * You should have received a copy of the GNU Lesser General Public
3947
c8c591fe26f8 Change license headers to say 'FFmpeg' instead of 'this program/this library'
diego
parents: 3927
diff changeset
18 * License along with FFmpeg; if not, write to the Free Software
3036
0b546eab515d Update licensing information: The FSF changed postal address.
diego
parents: 3029
diff changeset
19 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
1168
5af9aeadbdc3 H264 decoder & demuxer
michaelni
parents:
diff changeset
20 */
2967
ef2149182f1c COSMETICS: Remove all trailing whitespace.
diego
parents: 2962
diff changeset
21
1168
5af9aeadbdc3 H264 decoder & demuxer
michaelni
parents:
diff changeset
22 /**
10864
e3f5eb016712 Split motion vector prediction off h264.c/h.
michael
parents: 10863
diff changeset
23 * @file libavcodec/h264_mvpred.h
e3f5eb016712 Split motion vector prediction off h264.c/h.
michael
parents: 10863
diff changeset
24 * H.264 / AVC / MPEG4 part10 motion vector predicion.
1168
5af9aeadbdc3 H264 decoder & demuxer
michaelni
parents:
diff changeset
25 * @author Michael Niedermayer <michaelni@gmx.at>
5af9aeadbdc3 H264 decoder & demuxer
michaelni
parents:
diff changeset
26 */
5af9aeadbdc3 H264 decoder & demuxer
michaelni
parents:
diff changeset
27
9012
15a3df8c01fd More approved hunks for VAAPI & our new and cleaner hwaccel API.
michael
parents: 9004
diff changeset
28 #include "internal.h"
1168
5af9aeadbdc3 H264 decoder & demuxer
michaelni
parents:
diff changeset
29 #include "avcodec.h"
4975
9a6a0818e93f split h264.c to move parser in its own file
aurel
parents: 4931
diff changeset
30 #include "h264.h"
1908
e20fd60b215c h264 - progressive I frame CABAC support patch by (Laurent Aimar <fenrir at via dot ecp dot fr>)
michael
parents: 1899
diff changeset
31
3284
a224d9752912 don't force asserts in release builds. 2% faster h264.
lorenm
parents: 3219
diff changeset
32 //#undef NDEBUG
1168
5af9aeadbdc3 H264 decoder & demuxer
michaelni
parents:
diff changeset
33 #include <assert.h>
5af9aeadbdc3 H264 decoder & demuxer
michaelni
parents:
diff changeset
34
10864
e3f5eb016712 Split motion vector prediction off h264.c/h.
michael
parents: 10863
diff changeset
35 static inline int fetch_diagonal_mv(H264Context *h, const int16_t **C, int i, int list, int part_width){
e3f5eb016712 Split motion vector prediction off h264.c/h.
michael
parents: 10863
diff changeset
36 const int topright_ref= h->ref_cache[list][ i - 8 + part_width ];
e3f5eb016712 Split motion vector prediction off h264.c/h.
michael
parents: 10863
diff changeset
37 MpegEncContext *s = &h->s;
7481
ca205cc57734 Fix static leaks in h264.c.
cehoyos
parents: 7480
diff changeset
38
10864
e3f5eb016712 Split motion vector prediction off h264.c/h.
michael
parents: 10863
diff changeset
39 /* there is no consistent mapping of mvs to neighboring locations that will
e3f5eb016712 Split motion vector prediction off h264.c/h.
michael
parents: 10863
diff changeset
40 * make mbaff happy, so we can't move all this logic to fill_caches */
e3f5eb016712 Split motion vector prediction off h264.c/h.
michael
parents: 10863
diff changeset
41 if(FRAME_MBAFF){
e3f5eb016712 Split motion vector prediction off h264.c/h.
michael
parents: 10863
diff changeset
42 const uint32_t *mb_types = s->current_picture_ptr->mb_type;
e3f5eb016712 Split motion vector prediction off h264.c/h.
michael
parents: 10863
diff changeset
43 const int16_t *mv;
e3f5eb016712 Split motion vector prediction off h264.c/h.
michael
parents: 10863
diff changeset
44 *(uint32_t*)h->mv_cache[list][scan8[0]-2] = 0;
e3f5eb016712 Split motion vector prediction off h264.c/h.
michael
parents: 10863
diff changeset
45 *C = h->mv_cache[list][scan8[0]-2];
8443
cf81cdbf8ca9 unified CAVLC level decoding LUT.
michael
parents: 8441
diff changeset
46
10864
e3f5eb016712 Split motion vector prediction off h264.c/h.
michael
parents: 10863
diff changeset
47 if(!MB_FIELD
e3f5eb016712 Split motion vector prediction off h264.c/h.
michael
parents: 10863
diff changeset
48 && (s->mb_y&1) && i < scan8[0]+8 && topright_ref != PART_NOT_AVAILABLE){
e3f5eb016712 Split motion vector prediction off h264.c/h.
michael
parents: 10863
diff changeset
49 int topright_xy = s->mb_x + (s->mb_y-1)*s->mb_stride + (i == scan8[0]+3);
e3f5eb016712 Split motion vector prediction off h264.c/h.
michael
parents: 10863
diff changeset
50 if(IS_INTERLACED(mb_types[topright_xy])){
e3f5eb016712 Split motion vector prediction off h264.c/h.
michael
parents: 10863
diff changeset
51 #define SET_DIAG_MV(MV_OP, REF_OP, X4, Y4)\
e3f5eb016712 Split motion vector prediction off h264.c/h.
michael
parents: 10863
diff changeset
52 const int x4 = X4, y4 = Y4;\
e3f5eb016712 Split motion vector prediction off h264.c/h.
michael
parents: 10863
diff changeset
53 const int mb_type = mb_types[(x4>>2)+(y4>>2)*s->mb_stride];\
e3f5eb016712 Split motion vector prediction off h264.c/h.
michael
parents: 10863
diff changeset
54 if(!USES_LIST(mb_type,list))\
e3f5eb016712 Split motion vector prediction off h264.c/h.
michael
parents: 10863
diff changeset
55 return LIST_NOT_USED;\
e3f5eb016712 Split motion vector prediction off h264.c/h.
michael
parents: 10863
diff changeset
56 mv = s->current_picture_ptr->motion_val[list][x4 + y4*h->b_stride];\
e3f5eb016712 Split motion vector prediction off h264.c/h.
michael
parents: 10863
diff changeset
57 h->mv_cache[list][scan8[0]-2][0] = mv[0];\
e3f5eb016712 Split motion vector prediction off h264.c/h.
michael
parents: 10863
diff changeset
58 h->mv_cache[list][scan8[0]-2][1] = mv[1] MV_OP;\
e3f5eb016712 Split motion vector prediction off h264.c/h.
michael
parents: 10863
diff changeset
59 return s->current_picture_ptr->ref_index[list][(x4>>1) + (y4>>1)*h->b8_stride] REF_OP;
2967
ef2149182f1c COSMETICS: Remove all trailing whitespace.
diego
parents: 2962
diff changeset
60
10864
e3f5eb016712 Split motion vector prediction off h264.c/h.
michael
parents: 10863
diff changeset
61 SET_DIAG_MV(*2, >>1, s->mb_x*4+(i&7)-4+part_width, s->mb_y*4-1);
e3f5eb016712 Split motion vector prediction off h264.c/h.
michael
parents: 10863
diff changeset
62 }
2551
615995277bc5 MBAFF I slice no deblocking patch by (Loic >>lll+ffmpeg m4x org<<)
michael
parents: 2548
diff changeset
63 }
10864
e3f5eb016712 Split motion vector prediction off h264.c/h.
michael
parents: 10863
diff changeset
64 if(topright_ref == PART_NOT_AVAILABLE
e3f5eb016712 Split motion vector prediction off h264.c/h.
michael
parents: 10863
diff changeset
65 && ((s->mb_y&1) || i >= scan8[0]+8) && (i&7)==4
e3f5eb016712 Split motion vector prediction off h264.c/h.
michael
parents: 10863
diff changeset
66 && h->ref_cache[list][scan8[0]-1] != PART_NOT_AVAILABLE){
e3f5eb016712 Split motion vector prediction off h264.c/h.
michael
parents: 10863
diff changeset
67 if(!MB_FIELD
e3f5eb016712 Split motion vector prediction off h264.c/h.
michael
parents: 10863
diff changeset
68 && IS_INTERLACED(mb_types[h->left_mb_xy[0]])){
e3f5eb016712 Split motion vector prediction off h264.c/h.
michael
parents: 10863
diff changeset
69 SET_DIAG_MV(*2, >>1, s->mb_x*4-1, (s->mb_y|1)*4+(s->mb_y&1)*2+(i>>4)-1);
e3f5eb016712 Split motion vector prediction off h264.c/h.
michael
parents: 10863
diff changeset
70 }
e3f5eb016712 Split motion vector prediction off h264.c/h.
michael
parents: 10863
diff changeset
71 if(MB_FIELD
e3f5eb016712 Split motion vector prediction off h264.c/h.
michael
parents: 10863
diff changeset
72 && !IS_INTERLACED(mb_types[h->left_mb_xy[0]])
e3f5eb016712 Split motion vector prediction off h264.c/h.
michael
parents: 10863
diff changeset
73 && i >= scan8[0]+8){
e3f5eb016712 Split motion vector prediction off h264.c/h.
michael
parents: 10863
diff changeset
74 // left shift will turn LIST_NOT_USED into PART_NOT_AVAILABLE, but that's OK.
e3f5eb016712 Split motion vector prediction off h264.c/h.
michael
parents: 10863
diff changeset
75 SET_DIAG_MV(/2, <<1, s->mb_x*4-1, (s->mb_y&~1)*4 - 1 + ((i-scan8[0])>>3)*2);
2551
615995277bc5 MBAFF I slice no deblocking patch by (Loic >>lll+ffmpeg m4x org<<)
michael
parents: 2548
diff changeset
76 }
615995277bc5 MBAFF I slice no deblocking patch by (Loic >>lll+ffmpeg m4x org<<)
michael
parents: 2548
diff changeset
77 }
10864
e3f5eb016712 Split motion vector prediction off h264.c/h.
michael
parents: 10863
diff changeset
78 #undef SET_DIAG_MV
1168
5af9aeadbdc3 H264 decoder & demuxer
michaelni
parents:
diff changeset
79 }
5af9aeadbdc3 H264 decoder & demuxer
michaelni
parents:
diff changeset
80
10864
e3f5eb016712 Split motion vector prediction off h264.c/h.
michael
parents: 10863
diff changeset
81 if(topright_ref != PART_NOT_AVAILABLE){
e3f5eb016712 Split motion vector prediction off h264.c/h.
michael
parents: 10863
diff changeset
82 *C= h->mv_cache[list][ i - 8 + part_width ];
e3f5eb016712 Split motion vector prediction off h264.c/h.
michael
parents: 10863
diff changeset
83 return topright_ref;
e3f5eb016712 Split motion vector prediction off h264.c/h.
michael
parents: 10863
diff changeset
84 }else{
e3f5eb016712 Split motion vector prediction off h264.c/h.
michael
parents: 10863
diff changeset
85 tprintf(s->avctx, "topright MV not available\n");
e3f5eb016712 Split motion vector prediction off h264.c/h.
michael
parents: 10863
diff changeset
86
e3f5eb016712 Split motion vector prediction off h264.c/h.
michael
parents: 10863
diff changeset
87 *C= h->mv_cache[list][ i - 8 - 1 ];
e3f5eb016712 Split motion vector prediction off h264.c/h.
michael
parents: 10863
diff changeset
88 return h->ref_cache[list][ i - 8 - 1 ];
e3f5eb016712 Split motion vector prediction off h264.c/h.
michael
parents: 10863
diff changeset
89 }
e3f5eb016712 Split motion vector prediction off h264.c/h.
michael
parents: 10863
diff changeset
90 }
e3f5eb016712 Split motion vector prediction off h264.c/h.
michael
parents: 10863
diff changeset
91
e3f5eb016712 Split motion vector prediction off h264.c/h.
michael
parents: 10863
diff changeset
92 /**
e3f5eb016712 Split motion vector prediction off h264.c/h.
michael
parents: 10863
diff changeset
93 * gets the predicted MV.
e3f5eb016712 Split motion vector prediction off h264.c/h.
michael
parents: 10863
diff changeset
94 * @param n the block index
e3f5eb016712 Split motion vector prediction off h264.c/h.
michael
parents: 10863
diff changeset
95 * @param part_width the width of the partition (4, 8,16) -> (1, 2, 4)
e3f5eb016712 Split motion vector prediction off h264.c/h.
michael
parents: 10863
diff changeset
96 * @param mx the x component of the predicted motion vector
e3f5eb016712 Split motion vector prediction off h264.c/h.
michael
parents: 10863
diff changeset
97 * @param my the y component of the predicted motion vector
e3f5eb016712 Split motion vector prediction off h264.c/h.
michael
parents: 10863
diff changeset
98 */
e3f5eb016712 Split motion vector prediction off h264.c/h.
michael
parents: 10863
diff changeset
99 static inline void pred_motion(H264Context * const h, int n, int part_width, int list, int ref, int * const mx, int * const my){
e3f5eb016712 Split motion vector prediction off h264.c/h.
michael
parents: 10863
diff changeset
100 const int index8= scan8[n];
e3f5eb016712 Split motion vector prediction off h264.c/h.
michael
parents: 10863
diff changeset
101 const int top_ref= h->ref_cache[list][ index8 - 8 ];
e3f5eb016712 Split motion vector prediction off h264.c/h.
michael
parents: 10863
diff changeset
102 const int left_ref= h->ref_cache[list][ index8 - 1 ];
e3f5eb016712 Split motion vector prediction off h264.c/h.
michael
parents: 10863
diff changeset
103 const int16_t * const A= h->mv_cache[list][ index8 - 1 ];
e3f5eb016712 Split motion vector prediction off h264.c/h.
michael
parents: 10863
diff changeset
104 const int16_t * const B= h->mv_cache[list][ index8 - 8 ];
e3f5eb016712 Split motion vector prediction off h264.c/h.
michael
parents: 10863
diff changeset
105 const int16_t * C;
e3f5eb016712 Split motion vector prediction off h264.c/h.
michael
parents: 10863
diff changeset
106 int diagonal_ref, match_count;
3316
7278f730af27 h264: MBAFF interlaced decoding
lorenm
parents: 3315
diff changeset
107
10864
e3f5eb016712 Split motion vector prediction off h264.c/h.
michael
parents: 10863
diff changeset
108 assert(part_width==1 || part_width==2 || part_width==4);
e3f5eb016712 Split motion vector prediction off h264.c/h.
michael
parents: 10863
diff changeset
109
e3f5eb016712 Split motion vector prediction off h264.c/h.
michael
parents: 10863
diff changeset
110 /* mv_cache
e3f5eb016712 Split motion vector prediction off h264.c/h.
michael
parents: 10863
diff changeset
111 B . . A T T T T
e3f5eb016712 Split motion vector prediction off h264.c/h.
michael
parents: 10863
diff changeset
112 U . . L . . , .
e3f5eb016712 Split motion vector prediction off h264.c/h.
michael
parents: 10863
diff changeset
113 U . . L . . . .
e3f5eb016712 Split motion vector prediction off h264.c/h.
michael
parents: 10863
diff changeset
114 U . . L . . , .
e3f5eb016712 Split motion vector prediction off h264.c/h.
michael
parents: 10863
diff changeset
115 . . . L . . . .
e3f5eb016712 Split motion vector prediction off h264.c/h.
michael
parents: 10863
diff changeset
116 */
e3f5eb016712 Split motion vector prediction off h264.c/h.
michael
parents: 10863
diff changeset
117
e3f5eb016712 Split motion vector prediction off h264.c/h.
michael
parents: 10863
diff changeset
118 diagonal_ref= fetch_diagonal_mv(h, &C, index8, list, part_width);
e3f5eb016712 Split motion vector prediction off h264.c/h.
michael
parents: 10863
diff changeset
119 match_count= (diagonal_ref==ref) + (top_ref==ref) + (left_ref==ref);
e3f5eb016712 Split motion vector prediction off h264.c/h.
michael
parents: 10863
diff changeset
120 tprintf(h->s.avctx, "pred_motion match_count=%d\n", match_count);
e3f5eb016712 Split motion vector prediction off h264.c/h.
michael
parents: 10863
diff changeset
121 if(match_count > 1){ //most common
e3f5eb016712 Split motion vector prediction off h264.c/h.
michael
parents: 10863
diff changeset
122 *mx= mid_pred(A[0], B[0], C[0]);
e3f5eb016712 Split motion vector prediction off h264.c/h.
michael
parents: 10863
diff changeset
123 *my= mid_pred(A[1], B[1], C[1]);
e3f5eb016712 Split motion vector prediction off h264.c/h.
michael
parents: 10863
diff changeset
124 }else if(match_count==1){
e3f5eb016712 Split motion vector prediction off h264.c/h.
michael
parents: 10863
diff changeset
125 if(left_ref==ref){
e3f5eb016712 Split motion vector prediction off h264.c/h.
michael
parents: 10863
diff changeset
126 *mx= A[0];
e3f5eb016712 Split motion vector prediction off h264.c/h.
michael
parents: 10863
diff changeset
127 *my= A[1];
e3f5eb016712 Split motion vector prediction off h264.c/h.
michael
parents: 10863
diff changeset
128 }else if(top_ref==ref){
e3f5eb016712 Split motion vector prediction off h264.c/h.
michael
parents: 10863
diff changeset
129 *mx= B[0];
e3f5eb016712 Split motion vector prediction off h264.c/h.
michael
parents: 10863
diff changeset
130 *my= B[1];
e3f5eb016712 Split motion vector prediction off h264.c/h.
michael
parents: 10863
diff changeset
131 }else{
e3f5eb016712 Split motion vector prediction off h264.c/h.
michael
parents: 10863
diff changeset
132 *mx= C[0];
e3f5eb016712 Split motion vector prediction off h264.c/h.
michael
parents: 10863
diff changeset
133 *my= C[1];
3316
7278f730af27 h264: MBAFF interlaced decoding
lorenm
parents: 3315
diff changeset
134 }
2449
6f719184e2b9 simplify deblock
michael
parents: 2447
diff changeset
135 }else{
10864
e3f5eb016712 Split motion vector prediction off h264.c/h.
michael
parents: 10863
diff changeset
136 if(top_ref == PART_NOT_AVAILABLE && diagonal_ref == PART_NOT_AVAILABLE && left_ref != PART_NOT_AVAILABLE){
e3f5eb016712 Split motion vector prediction off h264.c/h.
michael
parents: 10863
diff changeset
137 *mx= A[0];
e3f5eb016712 Split motion vector prediction off h264.c/h.
michael
parents: 10863
diff changeset
138 *my= A[1];
7532
c4de4b187b4f Support MBAFF + constrained intra prediction.
michael
parents: 7528
diff changeset
139 }else{
10864
e3f5eb016712 Split motion vector prediction off h264.c/h.
michael
parents: 10863
diff changeset
140 *mx= mid_pred(A[0], B[0], C[0]);
e3f5eb016712 Split motion vector prediction off h264.c/h.
michael
parents: 10863
diff changeset
141 *my= mid_pred(A[1], B[1], C[1]);
2551
615995277bc5 MBAFF I slice no deblocking patch by (Loic >>lll+ffmpeg m4x org<<)
michael
parents: 2548
diff changeset
142 }
615995277bc5 MBAFF I slice no deblocking patch by (Loic >>lll+ffmpeg m4x org<<)
michael
parents: 2548
diff changeset
143 }
615995277bc5 MBAFF I slice no deblocking patch by (Loic >>lll+ffmpeg m4x org<<)
michael
parents: 2548
diff changeset
144
10864
e3f5eb016712 Split motion vector prediction off h264.c/h.
michael
parents: 10863
diff changeset
145 tprintf(h->s.avctx, "pred_motion (%2d %2d %2d) (%2d %2d %2d) (%2d %2d %2d) -> (%2d %2d %2d) at %2d %2d %d list %d\n", top_ref, B[0], B[1], diagonal_ref, C[0], C[1], left_ref, A[0], A[1], ref, *mx, *my, h->s.mb_x, h->s.mb_y, n, list);
1168
5af9aeadbdc3 H264 decoder & demuxer
michaelni
parents:
diff changeset
146 }
5af9aeadbdc3 H264 decoder & demuxer
michaelni
parents:
diff changeset
147
5af9aeadbdc3 H264 decoder & demuxer
michaelni
parents:
diff changeset
148 /**
5af9aeadbdc3 H264 decoder & demuxer
michaelni
parents:
diff changeset
149 * gets the directionally predicted 16x8 MV.
5af9aeadbdc3 H264 decoder & demuxer
michaelni
parents:
diff changeset
150 * @param n the block index
5af9aeadbdc3 H264 decoder & demuxer
michaelni
parents:
diff changeset
151 * @param mx the x component of the predicted motion vector
5af9aeadbdc3 H264 decoder & demuxer
michaelni
parents:
diff changeset
152 * @param my the y component of the predicted motion vector
5af9aeadbdc3 H264 decoder & demuxer
michaelni
parents:
diff changeset
153 */
5af9aeadbdc3 H264 decoder & demuxer
michaelni
parents:
diff changeset
154 static inline void pred_16x8_motion(H264Context * const h, int n, int list, int ref, int * const mx, int * const my){
5af9aeadbdc3 H264 decoder & demuxer
michaelni
parents:
diff changeset
155 if(n==0){
5af9aeadbdc3 H264 decoder & demuxer
michaelni
parents:
diff changeset
156 const int top_ref= h->ref_cache[list][ scan8[0] - 8 ];
5af9aeadbdc3 H264 decoder & demuxer
michaelni
parents:
diff changeset
157 const int16_t * const B= h->mv_cache[list][ scan8[0] - 8 ];
5af9aeadbdc3 H264 decoder & demuxer
michaelni
parents:
diff changeset
158
4600
6ac364a4ce2b Supply context to tprintf
mbardiaux
parents: 4594
diff changeset
159 tprintf(h->s.avctx, "pred_16x8: (%2d %2d %2d) at %2d %2d %d list %d\n", top_ref, B[0], B[1], h->s.mb_x, h->s.mb_y, n, list);
2967
ef2149182f1c COSMETICS: Remove all trailing whitespace.
diego
parents: 2962
diff changeset
160
1168
5af9aeadbdc3 H264 decoder & demuxer
michaelni
parents:
diff changeset
161 if(top_ref == ref){
5af9aeadbdc3 H264 decoder & demuxer
michaelni
parents:
diff changeset
162 *mx= B[0];
5af9aeadbdc3 H264 decoder & demuxer
michaelni
parents:
diff changeset
163 *my= B[1];
5af9aeadbdc3 H264 decoder & demuxer
michaelni
parents:
diff changeset
164 return;
5af9aeadbdc3 H264 decoder & demuxer
michaelni
parents:
diff changeset
165 }
5af9aeadbdc3 H264 decoder & demuxer
michaelni
parents:
diff changeset
166 }else{
5af9aeadbdc3 H264 decoder & demuxer
michaelni
parents:
diff changeset
167 const int left_ref= h->ref_cache[list][ scan8[8] - 1 ];
5af9aeadbdc3 H264 decoder & demuxer
michaelni
parents:
diff changeset
168 const int16_t * const A= h->mv_cache[list][ scan8[8] - 1 ];
2967
ef2149182f1c COSMETICS: Remove all trailing whitespace.
diego
parents: 2962
diff changeset
169
4600
6ac364a4ce2b Supply context to tprintf
mbardiaux
parents: 4594
diff changeset
170 tprintf(h->s.avctx, "pred_16x8: (%2d %2d %2d) at %2d %2d %d list %d\n", left_ref, A[0], A[1], h->s.mb_x, h->s.mb_y, n, list);
1168
5af9aeadbdc3 H264 decoder & demuxer
michaelni
parents:
diff changeset
171
5af9aeadbdc3 H264 decoder & demuxer
michaelni
parents:
diff changeset
172 if(left_ref == ref){
5af9aeadbdc3 H264 decoder & demuxer
michaelni
parents:
diff changeset
173 *mx= A[0];
5af9aeadbdc3 H264 decoder & demuxer
michaelni
parents:
diff changeset
174 *my= A[1];
5af9aeadbdc3 H264 decoder & demuxer
michaelni
parents:
diff changeset
175 return;
5af9aeadbdc3 H264 decoder & demuxer
michaelni
parents:
diff changeset
176 }
5af9aeadbdc3 H264 decoder & demuxer
michaelni
parents:
diff changeset
177 }
5af9aeadbdc3 H264 decoder & demuxer
michaelni
parents:
diff changeset
178
5af9aeadbdc3 H264 decoder & demuxer
michaelni
parents:
diff changeset
179 //RARE
5af9aeadbdc3 H264 decoder & demuxer
michaelni
parents:
diff changeset
180 pred_motion(h, n, 4, list, ref, mx, my);
5af9aeadbdc3 H264 decoder & demuxer
michaelni
parents:
diff changeset
181 }
5af9aeadbdc3 H264 decoder & demuxer
michaelni
parents:
diff changeset
182
5af9aeadbdc3 H264 decoder & demuxer
michaelni
parents:
diff changeset
183 /**
5af9aeadbdc3 H264 decoder & demuxer
michaelni
parents:
diff changeset
184 * gets the directionally predicted 8x16 MV.
5af9aeadbdc3 H264 decoder & demuxer
michaelni
parents:
diff changeset
185 * @param n the block index
5af9aeadbdc3 H264 decoder & demuxer
michaelni
parents:
diff changeset
186 * @param mx the x component of the predicted motion vector
5af9aeadbdc3 H264 decoder & demuxer
michaelni
parents:
diff changeset
187 * @param my the y component of the predicted motion vector
5af9aeadbdc3 H264 decoder & demuxer
michaelni
parents:
diff changeset
188 */
5af9aeadbdc3 H264 decoder & demuxer
michaelni
parents:
diff changeset
189 static inline void pred_8x16_motion(H264Context * const h, int n, int list, int ref, int * const mx, int * const my){
5af9aeadbdc3 H264 decoder & demuxer
michaelni
parents:
diff changeset
190 if(n==0){
5af9aeadbdc3 H264 decoder & demuxer
michaelni
parents:
diff changeset
191 const int left_ref= h->ref_cache[list][ scan8[0] - 1 ];
5af9aeadbdc3 H264 decoder & demuxer
michaelni
parents:
diff changeset
192 const int16_t * const A= h->mv_cache[list][ scan8[0] - 1 ];
2967
ef2149182f1c COSMETICS: Remove all trailing whitespace.
diego
parents: 2962
diff changeset
193
4600
6ac364a4ce2b Supply context to tprintf
mbardiaux
parents: 4594
diff changeset
194 tprintf(h->s.avctx, "pred_8x16: (%2d %2d %2d) at %2d %2d %d list %d\n", left_ref, A[0], A[1], h->s.mb_x, h->s.mb_y, n, list);
1168
5af9aeadbdc3 H264 decoder & demuxer
michaelni
parents:
diff changeset
195
5af9aeadbdc3 H264 decoder & demuxer
michaelni
parents:
diff changeset
196 if(left_ref == ref){
5af9aeadbdc3 H264 decoder & demuxer
michaelni
parents:
diff changeset
197 *mx= A[0];
5af9aeadbdc3 H264 decoder & demuxer
michaelni
parents:
diff changeset
198 *my= A[1];
5af9aeadbdc3 H264 decoder & demuxer
michaelni
parents:
diff changeset
199 return;
5af9aeadbdc3 H264 decoder & demuxer
michaelni
parents:
diff changeset
200 }
5af9aeadbdc3 H264 decoder & demuxer
michaelni
parents:
diff changeset
201 }else{
1169
4e891257d3e2 multiple reference frames support
michaelni
parents: 1168
diff changeset
202 const int16_t * C;
4e891257d3e2 multiple reference frames support
michaelni
parents: 1168
diff changeset
203 int diagonal_ref;
4e891257d3e2 multiple reference frames support
michaelni
parents: 1168
diff changeset
204
4e891257d3e2 multiple reference frames support
michaelni
parents: 1168
diff changeset
205 diagonal_ref= fetch_diagonal_mv(h, &C, scan8[4], list, 2);
2967
ef2149182f1c COSMETICS: Remove all trailing whitespace.
diego
parents: 2962
diff changeset
206
4600
6ac364a4ce2b Supply context to tprintf
mbardiaux
parents: 4594
diff changeset
207 tprintf(h->s.avctx, "pred_8x16: (%2d %2d %2d) at %2d %2d %d list %d\n", diagonal_ref, C[0], C[1], h->s.mb_x, h->s.mb_y, n, list);
1168
5af9aeadbdc3 H264 decoder & demuxer
michaelni
parents:
diff changeset
208
2967
ef2149182f1c COSMETICS: Remove all trailing whitespace.
diego
parents: 2962
diff changeset
209 if(diagonal_ref == ref){
1168
5af9aeadbdc3 H264 decoder & demuxer
michaelni
parents:
diff changeset
210 *mx= C[0];
5af9aeadbdc3 H264 decoder & demuxer
michaelni
parents:
diff changeset
211 *my= C[1];
5af9aeadbdc3 H264 decoder & demuxer
michaelni
parents:
diff changeset
212 return;
5af9aeadbdc3 H264 decoder & demuxer
michaelni
parents:
diff changeset
213 }
5af9aeadbdc3 H264 decoder & demuxer
michaelni
parents:
diff changeset
214 }
5af9aeadbdc3 H264 decoder & demuxer
michaelni
parents:
diff changeset
215
5af9aeadbdc3 H264 decoder & demuxer
michaelni
parents:
diff changeset
216 //RARE
5af9aeadbdc3 H264 decoder & demuxer
michaelni
parents:
diff changeset
217 pred_motion(h, n, 2, list, ref, mx, my);
5af9aeadbdc3 H264 decoder & demuxer
michaelni
parents:
diff changeset
218 }
5af9aeadbdc3 H264 decoder & demuxer
michaelni
parents:
diff changeset
219
5af9aeadbdc3 H264 decoder & demuxer
michaelni
parents:
diff changeset
220 static inline void pred_pskip_motion(H264Context * const h, int * const mx, int * const my){
5af9aeadbdc3 H264 decoder & demuxer
michaelni
parents:
diff changeset
221 const int top_ref = h->ref_cache[0][ scan8[0] - 8 ];
5af9aeadbdc3 H264 decoder & demuxer
michaelni
parents:
diff changeset
222 const int left_ref= h->ref_cache[0][ scan8[0] - 1 ];
5af9aeadbdc3 H264 decoder & demuxer
michaelni
parents:
diff changeset
223
4600
6ac364a4ce2b Supply context to tprintf
mbardiaux
parents: 4594
diff changeset
224 tprintf(h->s.avctx, "pred_pskip: (%d) (%d) at %2d %2d\n", top_ref, left_ref, h->s.mb_x, h->s.mb_y);
1168
5af9aeadbdc3 H264 decoder & demuxer
michaelni
parents:
diff changeset
225
5af9aeadbdc3 H264 decoder & demuxer
michaelni
parents:
diff changeset
226 if(top_ref == PART_NOT_AVAILABLE || left_ref == PART_NOT_AVAILABLE
8454
bc5f446ed4a8 Optimize pred_pskip_motion()
michael
parents: 8453
diff changeset
227 || !( top_ref | *(uint32_t*)h->mv_cache[0][ scan8[0] - 8 ])
bc5f446ed4a8 Optimize pred_pskip_motion()
michael
parents: 8453
diff changeset
228 || !(left_ref | *(uint32_t*)h->mv_cache[0][ scan8[0] - 1 ])){
2967
ef2149182f1c COSMETICS: Remove all trailing whitespace.
diego
parents: 2962
diff changeset
229
1168
5af9aeadbdc3 H264 decoder & demuxer
michaelni
parents:
diff changeset
230 *mx = *my = 0;
5af9aeadbdc3 H264 decoder & demuxer
michaelni
parents:
diff changeset
231 return;
5af9aeadbdc3 H264 decoder & demuxer
michaelni
parents:
diff changeset
232 }
2967
ef2149182f1c COSMETICS: Remove all trailing whitespace.
diego
parents: 2962
diff changeset
233
1168
5af9aeadbdc3 H264 decoder & demuxer
michaelni
parents:
diff changeset
234 pred_motion(h, 0, 4, 0, 0, mx, my);
5af9aeadbdc3 H264 decoder & demuxer
michaelni
parents:
diff changeset
235
5af9aeadbdc3 H264 decoder & demuxer
michaelni
parents:
diff changeset
236 return;
5af9aeadbdc3 H264 decoder & demuxer
michaelni
parents:
diff changeset
237 }