History

h264: K&R formatting cosmetics for header files (part II/II)

Diego Biurrun committed 14 years ago

Commit 1de53d01 parent be545b82 files · +590 −513Browse files

Unified · Split

2 files
  1. libavcodec/h264_mvpred.h +525 −482
  2. libavcodec/h264dsp.h +65 −31
libavcodec/h264_mvpred.h+525−482
@@ -35,53 +35,53 @@ · 34 unmodified lines
35//#undef NDEBUG35//#undef NDEBUG
36#include <assert.h>36#include <assert.h>
37 37
38static av_always_inline int fetch_diagonal_mv(H264Context *h, const int16_t **C, int i, int list, int part_width){38static av_always_inline int fetch_diagonal_mv(H264Context *h, const int16_t **C,
39 const int topright_ref= h->ref_cache[list][ i - 8 + part_width ];39 int i, int list, int part_width)
40 MpegEncContext *s = &h->s;40{
41 const int topright_ref = h->ref_cache[list][i - 8 + part_width];
42 MpegEncContext *s = &h->s;
41 43
42 /* there is no consistent mapping of mvs to neighboring locations that will44 /* 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 */45 * make mbaff happy, so we can't move all this logic to fill_caches */
44 if(FRAME_MBAFF){46 if (FRAME_MBAFF) {
45 47#define SET_DIAG_MV(MV_OP, REF_OP, XY, Y4) \
46#define SET_DIAG_MV(MV_OP, REF_OP, XY, Y4)\48 const int xy = XY, y4 = Y4; \
47 const int xy = XY, y4 = Y4;\49 const int mb_type = mb_types[xy + (y4 >> 2) * s->mb_stride]; \
48 const int mb_type = mb_types[xy+(y4>>2)*s->mb_stride];\50 if (!USES_LIST(mb_type, list)) \
49 if(!USES_LIST(mb_type,list))\51 return LIST_NOT_USED; \
50 return LIST_NOT_USED;\52 mv = s->current_picture_ptr->f.motion_val[list][h->mb2b_xy[xy] + 3 + y4 * h->b_stride]; \
51 mv = s->current_picture_ptr->f.motion_val[list][h->mb2b_xy[xy] + 3 + y4*h->b_stride];\53 h->mv_cache[list][scan8[0] - 2][0] = mv[0]; \
52 h->mv_cache[list][scan8[0]-2][0] = mv[0];\54 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;\55 return s->current_picture_ptr->f.ref_index[list][4 * xy + 1 + (y4 & ~1)] REF_OP;
54 return s->current_picture_ptr->f.ref_index[list][4*xy + 1 + (y4 & ~1)] REF_OP;56
55 57 if (topright_ref == PART_NOT_AVAILABLE
56 if(topright_ref == PART_NOT_AVAILABLE58 && i >= scan8[0] + 8 && (i & 7) == 4
57 && i >= scan8[0]+8 && (i&7)==459 && 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->f.mb_type;60 const uint32_t *mb_types = s->current_picture_ptr->f.mb_type;
60 const int16_t *mv;61 const int16_t *mv;
61 AV_ZERO32(h->mv_cache[list][scan8[0]-2]);62 AV_ZERO32(h->mv_cache[list][scan8[0] - 2]);
62 *C = h->mv_cache[list][scan8[0]-2];63 *C = h->mv_cache[list][scan8[0] - 2];
63 64
64 if(!MB_FIELD65 if (!MB_FIELD && IS_INTERLACED(h->left_type[0])) {
65 && IS_INTERLACED(h->left_type[0])){66 SET_DIAG_MV(* 2, >> 1, h->left_mb_xy[0] + s->mb_stride,
66 SET_DIAG_MV(*2, >>1, h->left_mb_xy[0]+s->mb_stride, (s->mb_y&1)*2+(i>>5));67 (s->mb_y & 1) * 2 + (i >> 5));
67 }68 }
68 if(MB_FIELD69 if (MB_FIELD && !IS_INTERLACED(h->left_type[0])) {
69 && !IS_INTERLACED(h->left_type[0])){
70 // left shift will turn LIST_NOT_USED into PART_NOT_AVAILABLE, but that's OK.70 // left shift will turn LIST_NOT_USED into PART_NOT_AVAILABLE, but that's OK.
71 SET_DIAG_MV(/2, <<1, h->left_mb_xy[i>=36], ((i>>2))&3);71 SET_DIAG_MV(/ 2, << 1, h->left_mb_xy[i >= 36], ((i >> 2)) & 3);
72 }72 }
73 }73 }
74#undef SET_DIAG_MV74#undef SET_DIAG_MV
75 }75 }
76 76
77 if(topright_ref != PART_NOT_AVAILABLE){77 if (topright_ref != PART_NOT_AVAILABLE) {
78 *C= h->mv_cache[list][ i - 8 + part_width ];78 *C = h->mv_cache[list][i - 8 + part_width];
79 return topright_ref;79 return topright_ref;
80 }else{80 } else {
81 tprintf(s->avctx, "topright MV not available\n");81 tprintf(s->avctx, "topright MV not available\n");
82 82
83 *C= h->mv_cache[list][ i - 8 - 1 ];83 *C = h->mv_cache[list][i - 8 - 1];
84 return h->ref_cache[list][ i - 8 - 1 ];84 return h->ref_cache[list][i - 8 - 1];
85 }85 }
86}86}
87 87
@@ -92,53 +92,61 @@ static av_always_inline int fetch_diagonal_mv(H264Context *h, const int16_t **C, · 4 unmodified lines
92 * @param mx the x component of the predicted motion vector92 * @param mx the x component of the predicted motion vector
93 * @param my the y component of the predicted motion vector93 * @param my the y component of the predicted motion vector
94 */94 */
95static av_always_inline void pred_motion(H264Context * const h, int n, int part_width, int list, int ref, int * const mx, int * const my){95static av_always_inline void pred_motion(H264Context *const h, int n,
96 const int index8= scan8[n];96 int part_width, int list, int ref,
97 const int top_ref= h->ref_cache[list][ index8 - 8 ];97 int *const mx, int *const my)
98 const int left_ref= h->ref_cache[list][ index8 - 1 ];98{
99 const int16_t * const A= h->mv_cache[list][ index8 - 1 ];99 const int index8 = scan8[n];
100 const int16_t * const B= h->mv_cache[list][ index8 - 8 ];100 const int top_ref = h->ref_cache[list][index8 - 8];
101 const int16_t * C;101 const int left_ref = h->ref_cache[list][index8 - 1];
102 const int16_t *const A = h->mv_cache[list][index8 - 1];
103 const int16_t *const B = h->mv_cache[list][index8 - 8];
104 const int16_t *C;
102 int diagonal_ref, match_count;105 int diagonal_ref, match_count;
103 106
104 assert(part_width==1 || part_width==2 || part_width==4);107 assert(part_width == 1 || part_width == 2 || part_width == 4);
105 108
106/* mv_cache109/* mv_cache
107 B . . A T T T T110 * B . . A T T T T
108 U . . L . . , .111 * U . . L . . , .
109 U . . L . . . .112 * U . . L . . . .
110 U . . L . . , .113 * U . . L . . , .
111 . . . L . . . .114 * . . . L . . . .
112*/115 */
113 116
114 diagonal_ref= fetch_diagonal_mv(h, &C, index8, list, part_width);117 diagonal_ref = fetch_diagonal_mv(h, &C, index8, list, part_width);
115 match_count= (diagonal_ref==ref) + (top_ref==ref) + (left_ref==ref);118 match_count = (diagonal_ref == ref) + (top_ref == ref) + (left_ref == ref);
116 tprintf(h->s.avctx, "pred_motion match_count=%d\n", match_count);119 tprintf(h->s.avctx, "pred_motion match_count=%d\n", match_count);
117 if(match_count > 1){ //most common120 if (match_count > 1) { //most common
118 *mx= mid_pred(A[0], B[0], C[0]);121 *mx = mid_pred(A[0], B[0], C[0]);
119 *my= mid_pred(A[1], B[1], C[1]);122 *my = mid_pred(A[1], B[1], C[1]);
120 }else if(match_count==1){123 } else if (match_count == 1) {
121 if(left_ref==ref){124 if (left_ref == ref) {
122 *mx= A[0];125 *mx = A[0];
123 *my= A[1];126 *my = A[1];
124 }else if(top_ref==ref){127 } else if (top_ref == ref) {
125 *mx= B[0];128 *mx = B[0];
126 *my= B[1];129 *my = B[1];
127 }else{130 } else {
128 *mx= C[0];131 *mx = C[0];
129 *my= C[1];132 *my = C[1];
130 }133 }
131 }else{134 } else {
132 if(top_ref == PART_NOT_AVAILABLE && diagonal_ref == PART_NOT_AVAILABLE && left_ref != PART_NOT_AVAILABLE){135 if (top_ref == PART_NOT_AVAILABLE &&
133 *mx= A[0];136 diagonal_ref == PART_NOT_AVAILABLE &&
134 *my= A[1];137 left_ref != PART_NOT_AVAILABLE) {
135 }else{138 *mx = A[0];
136 *mx= mid_pred(A[0], B[0], C[0]);139 *my = A[1];
137 *my= mid_pred(A[1], B[1], C[1]);140 } else {
141 *mx = mid_pred(A[0], B[0], C[0]);
142 *my = mid_pred(A[1], B[1], C[1]);
138 }143 }
139 }144 }
140 145
141 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);146 tprintf(h->s.avctx,
147 "pred_motion (%2d %2d %2d) (%2d %2d %2d) (%2d %2d %2d) -> (%2d %2d %2d) at %2d %2d %d list %d\n",
148 top_ref, B[0], B[1], diagonal_ref, C[0], C[1], left_ref,
149 A[0], A[1], ref, *mx, *my, h->s.mb_x, h->s.mb_y, n, list);
142}150}
143 151
144/**152/**
@@ -147,27 +155,32 @@ static av_always_inline void pred_motion(H264Context * const h, int n, int part_ · 2 unmodified lines
147 * @param mx the x component of the predicted motion vector155 * @param mx the x component of the predicted motion vector
148 * @param my the y component of the predicted motion vector156 * @param my the y component of the predicted motion vector
149 */157 */
150static av_always_inline void pred_16x8_motion(H264Context * const h, int n, int list, int ref, int * const mx, int * const my){158static av_always_inline void pred_16x8_motion(H264Context *const h,
151 if(n==0){159 int n, int list, int ref,
152 const int top_ref= h->ref_cache[list][ scan8[0] - 8 ];160 int *const mx, int *const my)
153 const int16_t * const B= h->mv_cache[list][ scan8[0] - 8 ];161{
154 162 if (n == 0) {
155 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);163 const int top_ref = h->ref_cache[list][scan8[0] - 8];
156 164 const int16_t *const B = h->mv_cache[list][scan8[0] - 8];
157 if(top_ref == ref){165
158 *mx= B[0];166 tprintf(h->s.avctx, "pred_16x8: (%2d %2d %2d) at %2d %2d %d list %d\n",
159 *my= B[1];167 top_ref, B[0], B[1], h->s.mb_x, h->s.mb_y, n, list);
168
169 if (top_ref == ref) {
170 *mx = B[0];
171 *my = B[1];
160 return;172 return;
161 }173 }
162 }else{174 } else {
163 const int left_ref= h->ref_cache[list][ scan8[8] - 1 ];175 const int left_ref = h->ref_cache[list][scan8[8] - 1];
164 const int16_t * const A= h->mv_cache[list][ scan8[8] - 1 ];176 const int16_t *const A = h->mv_cache[list][scan8[8] - 1];
165 177
166 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);178 tprintf(h->s.avctx, "pred_16x8: (%2d %2d %2d) at %2d %2d %d list %d\n",
179 left_ref, A[0], A[1], h->s.mb_x, h->s.mb_y, n, list);
167 180
168 if(left_ref == ref){181 if (left_ref == ref) {
169 *mx= A[0];182 *mx = A[0];
170 *my= A[1];183 *my = A[1];
171 return;184 return;
172 }185 }
173 }186 }
@@ -182,29 +195,34 @@ static av_always_inline void pred_16x8_motion(H264Context * const h, int n, int · 8 unmodified lines
182 * @param mx the x component of the predicted motion vector195 * @param mx the x component of the predicted motion vector
183 * @param my the y component of the predicted motion vector196 * @param my the y component of the predicted motion vector
184 */197 */
185static av_always_inline void pred_8x16_motion(H264Context * const h, int n, int list, int ref, int * const mx, int * const my){198static av_always_inline void pred_8x16_motion(H264Context *const h,
186 if(n==0){199 int n, int list, int ref,
187 const int left_ref= h->ref_cache[list][ scan8[0] - 1 ];200 int *const mx, int *const my)
188 const int16_t * const A= h->mv_cache[list][ scan8[0] - 1 ];201{
189 202 if (n == 0) {
190 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);203 const int left_ref = h->ref_cache[list][scan8[0] - 1];
191 204 const int16_t *const A = h->mv_cache[list][scan8[0] - 1];
192 if(left_ref == ref){205
193 *mx= A[0];206 tprintf(h->s.avctx, "pred_8x16: (%2d %2d %2d) at %2d %2d %d list %d\n",
194 *my= A[1];207 left_ref, A[0], A[1], h->s.mb_x, h->s.mb_y, n, list);
208
209 if (left_ref == ref) {
210 *mx = A[0];
211 *my = A[1];
195 return;212 return;
196 }213 }
197 }else{214 } else {
198 const int16_t * C;215 const int16_t *C;
199 int diagonal_ref;216 int diagonal_ref;
200 217
201 diagonal_ref= fetch_diagonal_mv(h, &C, scan8[4], list, 2);218 diagonal_ref = fetch_diagonal_mv(h, &C, scan8[4], list, 2);
202 219
203 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);220 tprintf(h->s.avctx, "pred_8x16: (%2d %2d %2d) at %2d %2d %d list %d\n",
221 diagonal_ref, C[0], C[1], h->s.mb_x, h->s.mb_y, n, list);
204 222
205 if(diagonal_ref == ref){223 if (diagonal_ref == ref) {
206 *mx= C[0];224 *mx = C[0];
207 *my= C[1];225 *my = C[1];
208 return;226 return;
209 }227 }
210 }228 }
@@ -213,168 +231,174 @@ static av_always_inline void pred_8x16_motion(H264Context * const h, int n, int · 2 unmodified lines
213 pred_motion(h, n, 2, list, ref, mx, my);231 pred_motion(h, n, 2, list, ref, mx, my);
214}232}
215 233
216#define FIX_MV_MBAFF(type, refn, mvn, idx)\234#define FIX_MV_MBAFF(type, refn, mvn, idx) \
217 if(FRAME_MBAFF){\235 if (FRAME_MBAFF) { \
218 if(MB_FIELD){\236 if (MB_FIELD) { \
219 if(!IS_INTERLACED(type)){\237 if (!IS_INTERLACED(type)) { \
220 refn <<= 1;\238 refn <<= 1; \
221 AV_COPY32(mvbuf[idx], mvn);\239 AV_COPY32(mvbuf[idx], mvn); \
222 mvbuf[idx][1] /= 2;\240 mvbuf[idx][1] /= 2; \
223 mvn = mvbuf[idx];\241 mvn = mvbuf[idx]; \
224 }\242 } \
225 }else{\243 } else { \
226 if(IS_INTERLACED(type)){\244 if (IS_INTERLACED(type)) { \
227 refn >>= 1;\245 refn >>= 1; \
228 AV_COPY32(mvbuf[idx], mvn);\246 AV_COPY32(mvbuf[idx], mvn); \
229 mvbuf[idx][1] <<= 1;\247 mvbuf[idx][1] <<= 1; \
230 mvn = mvbuf[idx];\248 mvn = mvbuf[idx]; \
231 }\249 } \
232 }\250 } \
233 }251 }
234 252
235static av_always_inline void pred_pskip_motion(H264Context * const h){253static av_always_inline void pred_pskip_motion(H264Context *const h)
236 DECLARE_ALIGNED(4, static const int16_t, zeromv)[2] = {0};254{
255 DECLARE_ALIGNED(4, static const int16_t, zeromv)[2] = { 0 };
237 DECLARE_ALIGNED(4, int16_t, mvbuf)[3][2];256 DECLARE_ALIGNED(4, int16_t, mvbuf)[3][2];
238 MpegEncContext * const s = &h->s;257 MpegEncContext *const s = &h->s;
239 int8_t *ref = s->current_picture.f.ref_index[0];258 int8_t *ref = s->current_picture.f.ref_index[0];
240 int16_t (*mv)[2] = s->current_picture.f.motion_val[0];259 int16_t(*mv)[2] = s->current_picture.f.motion_val[0];
241 int top_ref, left_ref, diagonal_ref, match_count, mx, my;260 int top_ref, left_ref, diagonal_ref, match_count, mx, my;
242 const int16_t *A, *B, *C;261 const int16_t *A, *B, *C;
243 int b_stride = h->b_stride;262 int b_stride = h->b_stride;
244 263
245 fill_rectangle(&h->ref_cache[0][scan8[0]], 4, 4, 8, 0, 1);264 fill_rectangle(&h->ref_cache[0][scan8[0]], 4, 4, 8, 0, 1);
246 265
247 /* To avoid doing an entire fill_decode_caches, we inline the relevant parts here.266 /* To avoid doing an entire fill_decode_caches, we inline the relevant
248 * FIXME: this is a partial duplicate of the logic in fill_decode_caches, but it's267 * parts here.
249 * faster this way. Is there a way to avoid this duplication?268 * FIXME: this is a partial duplicate of the logic in fill_decode_caches,
269 * but it's faster this way. Is there a way to avoid this duplication?
250 */270 */
251 if(USES_LIST(h->left_type[LTOP], 0)){271 if (USES_LIST(h->left_type[LTOP], 0)) {
252 left_ref = ref[4*h->left_mb_xy[LTOP] + 1 + (h->left_block[0]&~1)];272 left_ref = ref[4 * h->left_mb_xy[LTOP] + 1 + (h->left_block[0] & ~1)];
253 A = mv[h->mb2b_xy[h->left_mb_xy[LTOP]] + 3 + b_stride*h->left_block[0]];273 A = mv[h->mb2b_xy[h->left_mb_xy[LTOP]] + 3 + b_stride * h->left_block[0]];
254 FIX_MV_MBAFF(h->left_type[LTOP], left_ref, A, 0);274 FIX_MV_MBAFF(h->left_type[LTOP], left_ref, A, 0);
255 if(!(left_ref | AV_RN32A(A))){275 if (!(left_ref | AV_RN32A(A)))
256 goto zeromv;276 goto zeromv;
257 }277 } else if (h->left_type[LTOP]) {
258 }else if(h->left_type[LTOP]){
259 left_ref = LIST_NOT_USED;278 left_ref = LIST_NOT_USED;
260 A = zeromv;279 A = zeromv;
261 }else{280 } else {
262 goto zeromv;281 goto zeromv;
263 }282 }
264 283
265 if(USES_LIST(h->top_type, 0)){284 if (USES_LIST(h->top_type, 0)) {
266 top_ref = ref[4*h->top_mb_xy + 2];285 top_ref = ref[4 * h->top_mb_xy + 2];
267 B = mv[h->mb2b_xy[h->top_mb_xy] + 3*b_stride];286 B = mv[h->mb2b_xy[h->top_mb_xy] + 3 * b_stride];
268 FIX_MV_MBAFF(h->top_type, top_ref, B, 1);287 FIX_MV_MBAFF(h->top_type, top_ref, B, 1);
269 if(!(top_ref | AV_RN32A(B))){288 if (!(top_ref | AV_RN32A(B)))
270 goto zeromv;289 goto zeromv;
271 }290 } else if (h->top_type) {
272 }else if(h->top_type){
273 top_ref = LIST_NOT_USED;291 top_ref = LIST_NOT_USED;
274 B = zeromv;292 B = zeromv;
275 }else{293 } else {
276 goto zeromv;294 goto zeromv;
277 }295 }
278 296
279 tprintf(h->s.avctx, "pred_pskip: (%d) (%d) at %2d %2d\n", top_ref, left_ref, h->s.mb_x, h->s.mb_y);297 tprintf(h->s.avctx, "pred_pskip: (%d) (%d) at %2d %2d\n",
298 top_ref, left_ref, h->s.mb_x, h->s.mb_y);
280 299
281 if(USES_LIST(h->topright_type, 0)){300 if (USES_LIST(h->topright_type, 0)) {
282 diagonal_ref = ref[4*h->topright_mb_xy + 2];301 diagonal_ref = ref[4 * h->topright_mb_xy + 2];
283 C = mv[h->mb2b_xy[h->topright_mb_xy] + 3*b_stride];302 C = mv[h->mb2b_xy[h->topright_mb_xy] + 3 * b_stride];
284 FIX_MV_MBAFF(h->topright_type, diagonal_ref, C, 2);303 FIX_MV_MBAFF(h->topright_type, diagonal_ref, C, 2);
285 }else if(h->topright_type){304 } else if (h->topright_type) {
286 diagonal_ref = LIST_NOT_USED;305 diagonal_ref = LIST_NOT_USED;
287 C = zeromv;306 C = zeromv;
288 }else{307 } else {
289 if(USES_LIST(h->topleft_type, 0)){308 if (USES_LIST(h->topleft_type, 0)) {
290 diagonal_ref = ref[4*h->topleft_mb_xy + 1 + (h->topleft_partition & 2)];309 diagonal_ref = ref[4 * h->topleft_mb_xy + 1 +
291 C = mv[h->mb2b_xy[h->topleft_mb_xy] + 3 + b_stride + (h->topleft_partition & 2*b_stride)];310 (h->topleft_partition & 2)];
311 C = mv[h->mb2b_xy[h->topleft_mb_xy] + 3 + b_stride +
312 (h->topleft_partition & 2 * b_stride)];
292 FIX_MV_MBAFF(h->topleft_type, diagonal_ref, C, 2);313 FIX_MV_MBAFF(h->topleft_type, diagonal_ref, C, 2);
293 }else if(h->topleft_type){314 } else if (h->topleft_type) {
294 diagonal_ref = LIST_NOT_USED;315 diagonal_ref = LIST_NOT_USED;
295 C = zeromv;316 C = zeromv;
296 }else{317 } else {
297 diagonal_ref = PART_NOT_AVAILABLE;318 diagonal_ref = PART_NOT_AVAILABLE;
298 C = zeromv;319 C = zeromv;
299 }320 }
300 }321 }
301 322
302 match_count= !diagonal_ref + !top_ref + !left_ref;323 match_count = !diagonal_ref + !top_ref + !left_ref;
303 tprintf(h->s.avctx, "pred_pskip_motion match_count=%d\n", match_count);324 tprintf(h->s.avctx, "pred_pskip_motion match_count=%d\n", match_count);
304 if(match_count > 1){325 if (match_count > 1) {
305 mx = mid_pred(A[0], B[0], C[0]);326 mx = mid_pred(A[0], B[0], C[0]);
306 my = mid_pred(A[1], B[1], C[1]);327 my = mid_pred(A[1], B[1], C[1]);
307 }else if(match_count==1){328 } else if (match_count == 1) {
308 if(!left_ref){329 if (!left_ref) {
309 mx = A[0];330 mx = A[0];
310 my = A[1];331 my = A[1];
311 }else if(!top_ref){332 } else if (!top_ref) {
312 mx = B[0];333 mx = B[0];
313 my = B[1];334 my = B[1];
314 }else{335 } else {
315 mx = C[0];336 mx = C[0];
316 my = C[1];337 my = C[1];
317 }338 }
318 }else{339 } else {
319 mx = mid_pred(A[0], B[0], C[0]);340 mx = mid_pred(A[0], B[0], C[0]);
320 my = mid_pred(A[1], B[1], C[1]);341 my = mid_pred(A[1], B[1], C[1]);
321 }342 }
322 343
323 fill_rectangle( h->mv_cache[0][scan8[0]], 4, 4, 8, pack16to32(mx,my), 4);344 fill_rectangle(h->mv_cache[0][scan8[0]], 4, 4, 8, pack16to32(mx, my), 4);
324 return;345 return;
346
325zeromv:347zeromv:
326 fill_rectangle( h->mv_cache[0][scan8[0]], 4, 4, 8, 0, 4);348 fill_rectangle(h->mv_cache[0][scan8[0]], 4, 4, 8, 0, 4);
327 return;349 return;
328}350}
329 351
330static void fill_decode_neighbors(H264Context *h, int mb_type){352static void fill_decode_neighbors(H264Context *h, int mb_type)
331 MpegEncContext * const s = &h->s;353{
332 const int mb_xy= h->mb_xy;354 MpegEncContext *const s = &h->s;
355 const int mb_xy = h->mb_xy;
333 int topleft_xy, top_xy, topright_xy, left_xy[LEFT_MBS];356 int topleft_xy, top_xy, topright_xy, left_xy[LEFT_MBS];
334 static const uint8_t left_block_options[4][32]={357 static const uint8_t left_block_options[4][32] = {
335 {0,1,2,3,7,10,8,11,3+0*4, 3+1*4, 3+2*4, 3+3*4, 1+4*4, 1+8*4, 1+5*4, 1+9*4},358 { 0, 1, 2, 3, 7, 10, 8, 11, 3 + 0 * 4, 3 + 1 * 4, 3 + 2 * 4, 3 + 3 * 4, 1 + 4 * 4, 1 + 8 * 4, 1 + 5 * 4, 1 + 9 * 4 },
336 {2,2,3,3,8,11,8,11,3+2*4, 3+2*4, 3+3*4, 3+3*4, 1+5*4, 1+9*4, 1+5*4, 1+9*4},359 { 2, 2, 3, 3, 8, 11, 8, 11, 3 + 2 * 4, 3 + 2 * 4, 3 + 3 * 4, 3 + 3 * 4, 1 + 5 * 4, 1 + 9 * 4, 1 + 5 * 4, 1 + 9 * 4 },
337 {0,0,1,1,7,10,7,10,3+0*4, 3+0*4, 3+1*4, 3+1*4, 1+4*4, 1+8*4, 1+4*4, 1+8*4},360 { 0, 0, 1, 1, 7, 10, 7, 10, 3 + 0 * 4, 3 + 0 * 4, 3 + 1 * 4, 3 + 1 * 4, 1 + 4 * 4, 1 + 8 * 4, 1 + 4 * 4, 1 + 8 * 4 },
338 {0,2,0,2,7,10,7,10,3+0*4, 3+2*4, 3+0*4, 3+2*4, 1+4*4, 1+8*4, 1+4*4, 1+8*4}361 { 0, 2, 0, 2, 7, 10, 7, 10, 3 + 0 * 4, 3 + 2 * 4, 3 + 0 * 4, 3 + 2 * 4, 1 + 4 * 4, 1 + 8 * 4, 1 + 4 * 4, 1 + 8 * 4 }
339 };362 };
340 363
341 h->topleft_partition= -1;364 h->topleft_partition = -1;
342 365
343 top_xy = mb_xy - (s->mb_stride << MB_FIELD);366 top_xy = mb_xy - (s->mb_stride << MB_FIELD);
344 367
345 /* Wow, what a mess, why didn't they simplify the interlacing & intra368 /* Wow, what a mess, why didn't they simplify the interlacing & intra
346 * stuff, I can't imagine that these complex rules are worth it. */369 * stuff, I can't imagine that these complex rules are worth it. */
347 370
348 topleft_xy = top_xy - 1;371 topleft_xy = top_xy - 1;
349 topright_xy= top_xy + 1;372 topright_xy = top_xy + 1;
350 left_xy[LBOT] = left_xy[LTOP] = mb_xy-1;373 left_xy[LBOT] = left_xy[LTOP] = mb_xy - 1;
351 h->left_block = left_block_options[0];374 h->left_block = left_block_options[0];
352 if(FRAME_MBAFF){375 if (FRAME_MBAFF) {
353 const int left_mb_field_flag = IS_INTERLACED(s->current_picture.f.mb_type[mb_xy - 1]);376 const int left_mb_field_flag = IS_INTERLACED(s->current_picture.f.mb_type[mb_xy - 1]);
354 const int curr_mb_field_flag = IS_INTERLACED(mb_type);377 const int curr_mb_field_flag = IS_INTERLACED(mb_type);
355 if(s->mb_y&1){378 if (s->mb_y & 1) {
356 if (left_mb_field_flag != curr_mb_field_flag) {379 if (left_mb_field_flag != curr_mb_field_flag) {
357 left_xy[LBOT] = left_xy[LTOP] = mb_xy - s->mb_stride - 1;380 left_xy[LBOT] = left_xy[LTOP] = mb_xy - s->mb_stride - 1;
358 if (curr_mb_field_flag) {381 if (curr_mb_field_flag) {
359 left_xy[LBOT] += s->mb_stride;382 left_xy[LBOT] += s->mb_stride;
360 h->left_block = left_block_options[3];383 h->left_block = left_block_options[3];
361 } else {384 } else {
362 topleft_xy += s->mb_stride;385 topleft_xy += s->mb_stride;
363 // take top left mv from the middle of the mb, as opposed to all other modes which use the bottom right partition386 /* take top left mv from the middle of the mb, as opposed
387 * to all other modes which use the bottom right partition */
364 h->topleft_partition = 0;388 h->topleft_partition = 0;
365 h->left_block = left_block_options[1];389 h->left_block = left_block_options[1];
366 }390 }
367 }391 }
368 }else{392 } else {
369 if(curr_mb_field_flag){393 if (curr_mb_field_flag) {
370 topleft_xy += s->mb_stride & (((s->current_picture.f.mb_type[top_xy - 1] >> 7) & 1) - 1);394 topleft_xy += s->mb_stride & (((s->current_picture.f.mb_type[top_xy - 1] >> 7) & 1) - 1);
371 topright_xy += s->mb_stride & (((s->current_picture.f.mb_type[top_xy + 1] >> 7) & 1) - 1);395 topright_xy += s->mb_stride & (((s->current_picture.f.mb_type[top_xy + 1] >> 7) & 1) - 1);
372 top_xy += s->mb_stride & (((s->current_picture.f.mb_type[top_xy ] >> 7) & 1) - 1);396 top_xy += s->mb_stride & (((s->current_picture.f.mb_type[top_xy] >> 7) & 1) - 1);
373 }397 }
374 if (left_mb_field_flag != curr_mb_field_flag) {398 if (left_mb_field_flag != curr_mb_field_flag) {
375 if (curr_mb_field_flag) {399 if (curr_mb_field_flag) {
376 left_xy[LBOT] += s->mb_stride;400 left_xy[LBOT] += s->mb_stride;
377 h->left_block = left_block_options[3];401 h->left_block = left_block_options[3];
378 } else {402 } else {
379 h->left_block = left_block_options[2];403 h->left_block = left_block_options[2];
380 }404 }
@@ -382,9 +406,9 @@ static void fill_decode_neighbors(H264Context *h, int mb_type){ · 1 unmodified line
382 }406 }
383 }407 }
384 408
385 h->topleft_mb_xy = topleft_xy;409 h->topleft_mb_xy = topleft_xy;
386 h->top_mb_xy = top_xy;410 h->top_mb_xy = top_xy;
387 h->topright_mb_xy= topright_xy;411 h->topright_mb_xy = topright_xy;
388 h->left_mb_xy[LTOP] = left_xy[LTOP];412 h->left_mb_xy[LTOP] = left_xy[LTOP];
389 h->left_mb_xy[LBOT] = left_xy[LBOT];413 h->left_mb_xy[LBOT] = left_xy[LBOT];
390 //FIXME do we need all in the context?414 //FIXME do we need all in the context?
@@ -395,351 +419,372 @@ static void fill_decode_neighbors(H264Context *h, int mb_type){ · 4 unmodified lines
395 h->left_type[LTOP] = s->current_picture.f.mb_type[left_xy[LTOP]];419 h->left_type[LTOP] = s->current_picture.f.mb_type[left_xy[LTOP]];
396 h->left_type[LBOT] = s->current_picture.f.mb_type[left_xy[LBOT]];420 h->left_type[LBOT] = s->current_picture.f.mb_type[left_xy[LBOT]];
397 421
398 if(FMO){422 if (FMO) {
399 if(h->slice_table[topleft_xy ] != h->slice_num) h->topleft_type = 0;423 if (h->slice_table[topleft_xy] != h->slice_num)
400 if(h->slice_table[top_xy ] != h->slice_num) h->top_type = 0;424 h->topleft_type = 0;
401 if(h->slice_table[left_xy[LTOP] ] != h->slice_num) h->left_type[LTOP] = h->left_type[LBOT] = 0;425 if (h->slice_table[top_xy] != h->slice_num)
402 }else{426 h->top_type = 0;
403 if(h->slice_table[topleft_xy ] != h->slice_num){427 if (h->slice_table[left_xy[LTOP]] != h->slice_num)
428 h->left_type[LTOP] = h->left_type[LBOT] = 0;
429 } else {
430 if (h->slice_table[topleft_xy] != h->slice_num) {
404 h->topleft_type = 0;431 h->topleft_type = 0;
405 if(h->slice_table[top_xy ] != h->slice_num) h->top_type = 0;432 if (h->slice_table[top_xy] != h->slice_num)
406 if(h->slice_table[left_xy[LTOP] ] != h->slice_num) h->left_type[LTOP] = h->left_type[LBOT] = 0;433 h->top_type = 0;
434 if (h->slice_table[left_xy[LTOP]] != h->slice_num)
435 h->left_type[LTOP] = h->left_type[LBOT] = 0;
407 }436 }
408 }437 }
409 if(h->slice_table[topright_xy] != h->slice_num) h->topright_type= 0;438 if (h->slice_table[topright_xy] != h->slice_num)
439 h->topright_type = 0;
410}440}
411 441
412static void fill_decode_caches(H264Context *h, int mb_type){442static void fill_decode_caches(H264Context *h, int mb_type)
413 MpegEncContext * const s = &h->s;443{
444 MpegEncContext *const s = &h->s;
414 int topleft_xy, top_xy, topright_xy, left_xy[LEFT_MBS];445 int topleft_xy, top_xy, topright_xy, left_xy[LEFT_MBS];
415 int topleft_type, top_type, topright_type, left_type[LEFT_MBS];446 int topleft_type, top_type, topright_type, left_type[LEFT_MBS];
416 const uint8_t * left_block= h->left_block;447 const uint8_t *left_block = h->left_block;
417 int i;448 int i;
418 uint8_t *nnz;449 uint8_t *nnz;
419 uint8_t *nnz_cache;450 uint8_t *nnz_cache;
420 451
421 topleft_xy = h->topleft_mb_xy;452 topleft_xy = h->topleft_mb_xy;
422 top_xy = h->top_mb_xy;453 top_xy = h->top_mb_xy;
423 topright_xy = h->topright_mb_xy;454 topright_xy = h->topright_mb_xy;
424 left_xy[LTOP] = h->left_mb_xy[LTOP];455 left_xy[LTOP] = h->left_mb_xy[LTOP];
425 left_xy[LBOT] = h->left_mb_xy[LBOT];456 left_xy[LBOT] = h->left_mb_xy[LBOT];
426 topleft_type = h->topleft_type;457 topleft_type = h->topleft_type;
427 top_type = h->top_type;458 top_type = h->top_type;
428 topright_type = h->topright_type;459 topright_type = h->topright_type;
429 left_type[LTOP]= h->left_type[LTOP];460 left_type[LTOP] = h->left_type[LTOP];
430 left_type[LBOT]= h->left_type[LBOT];461 left_type[LBOT] = h->left_type[LBOT];
431 462
432 if(!IS_SKIP(mb_type)){463 if (!IS_SKIP(mb_type)) {
433 if(IS_INTRA(mb_type)){464 if (IS_INTRA(mb_type)) {
434 int type_mask= h->pps.constrained_intra_pred ? IS_INTRA(-1) : -1;465 int type_mask = h->pps.constrained_intra_pred ? IS_INTRA(-1) : -1;
435 h->topleft_samples_available=466 h->topleft_samples_available =
436 h->top_samples_available=467 h->top_samples_available =
437 h->left_samples_available= 0xFFFF;468 h->left_samples_available = 0xFFFF;
438 h->topright_samples_available= 0xEEEA;469 h->topright_samples_available = 0xEEEA;
439 470
440 if(!(top_type & type_mask)){471 if (!(top_type & type_mask)) {
441 h->topleft_samples_available= 0xB3FF;472 h->topleft_samples_available = 0xB3FF;
442 h->top_samples_available= 0x33FF;473 h->top_samples_available = 0x33FF;
443 h->topright_samples_available= 0x26EA;474 h->topright_samples_available = 0x26EA;
444 }475 }
445 if(IS_INTERLACED(mb_type) != IS_INTERLACED(left_type[LTOP])){476 if (IS_INTERLACED(mb_type) != IS_INTERLACED(left_type[LTOP])) {
446 if(IS_INTERLACED(mb_type)){477 if (IS_INTERLACED(mb_type)) {
447 if(!(left_type[LTOP] & type_mask)){478 if (!(left_type[LTOP] & type_mask)) {
448 h->topleft_samples_available&= 0xDFFF;479 h->topleft_samples_available &= 0xDFFF;
449 h->left_samples_available&= 0x5FFF;480 h->left_samples_available &= 0x5FFF;
450 }481 }
451 if(!(left_type[LBOT] & type_mask)){482 if (!(left_type[LBOT] & type_mask)) {
452 h->topleft_samples_available&= 0xFF5F;483 h->topleft_samples_available &= 0xFF5F;
453 h->left_samples_available&= 0xFF5F;484 h->left_samples_available &= 0xFF5F;
454 }485 }
455 }else{486 } else {
456 int left_typei = s->current_picture.f.mb_type[left_xy[LTOP] + s->mb_stride];487 int left_typei = s->current_picture.f.mb_type[left_xy[LTOP] + s->mb_stride];
457 488
458 assert(left_xy[LTOP] == left_xy[LBOT]);489 assert(left_xy[LTOP] == left_xy[LBOT]);
459 if(!((left_typei & type_mask) && (left_type[LTOP] & type_mask))){490 if (!((left_typei & type_mask) && (left_type[LTOP] & type_mask))) {
460 h->topleft_samples_available&= 0xDF5F;491 h->topleft_samples_available &= 0xDF5F;
461 h->left_samples_available&= 0x5F5F;492 h->left_samples_available &= 0x5F5F;
462 }493 }
463 }494 }
464 }else{495 } else {
465 if(!(left_type[LTOP] & type_mask)){496 if (!(left_type[LTOP] & type_mask)) {
466 h->topleft_samples_available&= 0xDF5F;497 h->topleft_samples_available &= 0xDF5F;
467 h->left_samples_available&= 0x5F5F;498 h->left_samples_available &= 0x5F5F;
468 }499 }
469 }500 }
470 501
471 if(!(topleft_type & type_mask))502 if (!(topleft_type & type_mask))
472 h->topleft_samples_available&= 0x7FFF;503 h->topleft_samples_available &= 0x7FFF;
473 504
474 if(!(topright_type & type_mask))505 if (!(topright_type & type_mask))
475 h->topright_samples_available&= 0xFBFF;506 h->topright_samples_available &= 0xFBFF;
476 507
477 if(IS_INTRA4x4(mb_type)){508 if (IS_INTRA4x4(mb_type)) {
478 if(IS_INTRA4x4(top_type)){509 if (IS_INTRA4x4(top_type)) {
479 AV_COPY32(h->intra4x4_pred_mode_cache+4+8*0, h->intra4x4_pred_mode + h->mb2br_xy[top_xy]);510 AV_COPY32(h->intra4x4_pred_mode_cache + 4 + 8 * 0, h->intra4x4_pred_mode + h->mb2br_xy[top_xy]);
480 }else{511 } else {
481 h->intra4x4_pred_mode_cache[4+8*0]=512 h->intra4x4_pred_mode_cache[4 + 8 * 0] =
482 h->intra4x4_pred_mode_cache[5+8*0]=513 h->intra4x4_pred_mode_cache[5 + 8 * 0] =
483 h->intra4x4_pred_mode_cache[6+8*0]=514 h->intra4x4_pred_mode_cache[6 + 8 * 0] =
484 h->intra4x4_pred_mode_cache[7+8*0]= 2 - 3*!(top_type & type_mask);515 h->intra4x4_pred_mode_cache[7 + 8 * 0] = 2 - 3 * !(top_type & type_mask);
485 }516 }
486 for(i=0; i<2; i++){517 for (i = 0; i < 2; i++) {
487 if(IS_INTRA4x4(left_type[LEFT(i)])){518 if (IS_INTRA4x4(left_type[LEFT(i)])) {
488 int8_t *mode= h->intra4x4_pred_mode + h->mb2br_xy[left_xy[LEFT(i)]];519 int8_t *mode = h->intra4x4_pred_mode + h->mb2br_xy[left_xy[LEFT(i)]];
489 h->intra4x4_pred_mode_cache[3+8*1 + 2*8*i]= mode[6-left_block[0+2*i]];520 h->intra4x4_pred_mode_cache[3 + 8 * 1 + 2 * 8 * i] = mode[6 - left_block[0 + 2 * i]];
490 h->intra4x4_pred_mode_cache[3+8*2 + 2*8*i]= mode[6-left_block[1+2*i]];521 h->intra4x4_pred_mode_cache[3 + 8 * 2 + 2 * 8 * i] = mode[6 - left_block[1 + 2 * i]];
491 }else{522 } else {
492 h->intra4x4_pred_mode_cache[3+8*1 + 2*8*i]=523 h->intra4x4_pred_mode_cache[3 + 8 * 1 + 2 * 8 * i] =
493 h->intra4x4_pred_mode_cache[3+8*2 + 2*8*i]= 2 - 3*!(left_type[LEFT(i)] & type_mask);524 h->intra4x4_pred_mode_cache[3 + 8 * 2 + 2 * 8 * i] = 2 - 3 * !(left_type[LEFT(i)] & type_mask);
494 }525 }
495 }526 }
496 }527 }
497 }528 }
498 529
499 530 /*
500/*531 * 0 . T T. T T T T
5010 . T T. T T T T532 * 1 L . .L . . . .
5021 L . .L . . . .533 * 2 L . .L . . . .
5032 L . .L . . . .534 * 3 . T TL . . . .
5043 . T TL . . . .535 * 4 L . .L . . . .
5054 L . .L . . . .536 * 5 L . .. . . . .
5065 L . .. . . . .537 */
507*/538 /* FIXME: constraint_intra_pred & partitioning & nnz
508//FIXME constraint_intra_pred & partitioning & nnz (let us hope this is just a typo in the spec)539 * (let us hope this is just a typo in the spec) */
509 nnz_cache = h->non_zero_count_cache;540 nnz_cache = h->non_zero_count_cache;
510 if(top_type){541 if (top_type) {
511 nnz = h->non_zero_count[top_xy];542 nnz = h->non_zero_count[top_xy];
512 AV_COPY32(&nnz_cache[4+8* 0], &nnz[4*3]);543 AV_COPY32(&nnz_cache[4 + 8 * 0], &nnz[4 * 3]);
513 if(!s->chroma_y_shift){544 if (!s->chroma_y_shift) {
514 AV_COPY32(&nnz_cache[4+8* 5], &nnz[4* 7]);545 AV_COPY32(&nnz_cache[4 + 8 * 5], &nnz[4 * 7]);
515 AV_COPY32(&nnz_cache[4+8*10], &nnz[4*11]);546 AV_COPY32(&nnz_cache[4 + 8 * 10], &nnz[4 * 11]);
516 }else{547 } else {
517 AV_COPY32(&nnz_cache[4+8* 5], &nnz[4* 5]);548 AV_COPY32(&nnz_cache[4 + 8 * 5], &nnz[4 * 5]);
518 AV_COPY32(&nnz_cache[4+8*10], &nnz[4* 9]);549 AV_COPY32(&nnz_cache[4 + 8 * 10], &nnz[4 * 9]);
550 }
551 } else {
552 uint32_t top_empty = CABAC && !IS_INTRA(mb_type) ? 0 : 0x40404040;
553 AV_WN32A(&nnz_cache[4 + 8 * 0], top_empty);
554 AV_WN32A(&nnz_cache[4 + 8 * 5], top_empty);
555 AV_WN32A(&nnz_cache[4 + 8 * 10], top_empty);
519 }556 }
520 }else{
521 uint32_t top_empty = CABAC && !IS_INTRA(mb_type) ? 0 : 0x40404040;
522 AV_WN32A(&nnz_cache[4+8* 0], top_empty);
523 AV_WN32A(&nnz_cache[4+8* 5], top_empty);
524 AV_WN32A(&nnz_cache[4+8*10], top_empty);
525 }
526 557
527 for (i=0; i<2; i++) {558 for (i = 0; i < 2; i++) {
528 if(left_type[LEFT(i)]){559 if (left_type[LEFT(i)]) {
529 nnz = h->non_zero_count[left_xy[LEFT(i)]];560 nnz = h->non_zero_count[left_xy[LEFT(i)]];
530 nnz_cache[3+8* 1 + 2*8*i]= nnz[left_block[8+0+2*i]];561 nnz_cache[3 + 8 * 1 + 2 * 8 * i] = nnz[left_block[8 + 0 + 2 * i]];
531 nnz_cache[3+8* 2 + 2*8*i]= nnz[left_block[8+1+2*i]];562 nnz_cache[3 + 8 * 2 + 2 * 8 * i] = nnz[left_block[8 + 1 + 2 * i]];
532 if(CHROMA444){563 if (CHROMA444) {
533 nnz_cache[3+8* 6 + 2*8*i]= nnz[left_block[8+0+2*i]+4*4];564 nnz_cache[3 + 8 * 6 + 2 * 8 * i] = nnz[left_block[8 + 0 + 2 * i] + 4 * 4];
534 nnz_cache[3+8* 7 + 2*8*i]= nnz[left_block[8+1+2*i]+4*4];565 nnz_cache[3 + 8 * 7 + 2 * 8 * i] = nnz[left_block[8 + 1 + 2 * i] + 4 * 4];
535 nnz_cache[3+8*11 + 2*8*i]= nnz[left_block[8+0+2*i]+8*4];566 nnz_cache[3 + 8 * 11 + 2 * 8 * i] = nnz[left_block[8 + 0 + 2 * i] + 8 * 4];
536 nnz_cache[3+8*12 + 2*8*i]= nnz[left_block[8+1+2*i]+8*4];567 nnz_cache[3 + 8 * 12 + 2 * 8 * i] = nnz[left_block[8 + 1 + 2 * i] + 8 * 4];
537 }else if(CHROMA422) {568 } else if (CHROMA422) {
538 nnz_cache[3+8* 6 + 2*8*i]= nnz[left_block[8+0+2*i]-2+4*4];569 nnz_cache[3 + 8 * 6 + 2 * 8 * i] = nnz[left_block[8 + 0 + 2 * i] - 2 + 4 * 4];
539 nnz_cache[3+8* 7 + 2*8*i]= nnz[left_block[8+1+2*i]-2+4*4];570 nnz_cache[3 + 8 * 7 + 2 * 8 * i] = nnz[left_block[8 + 1 + 2 * i] - 2 + 4 * 4];
540 nnz_cache[3+8*11 + 2*8*i]= nnz[left_block[8+0+2*i]-2+8*4];571 nnz_cache[3 + 8 * 11 + 2 * 8 * i] = nnz[left_block[8 + 0 + 2 * i] - 2 + 8 * 4];
541 nnz_cache[3+8*12 + 2*8*i]= nnz[left_block[8+1+2*i]-2+8*4];572 nnz_cache[3 + 8 * 12 + 2 * 8 * i] = nnz[left_block[8 + 1 + 2 * i] - 2 + 8 * 4];
542 }else{573 } else {
543 nnz_cache[3+8* 6 + 8*i]= nnz[left_block[8+4+2*i]];574 nnz_cache[3 + 8 * 6 + 8 * i] = nnz[left_block[8 + 4 + 2 * i]];
544 nnz_cache[3+8*11 + 8*i]= nnz[left_block[8+5+2*i]];575 nnz_cache[3 + 8 * 11 + 8 * i] = nnz[left_block[8 + 5 + 2 * i]];
576 }
577 } else {
578 nnz_cache[3 + 8 * 1 + 2 * 8 * i] =
579 nnz_cache[3 + 8 * 2 + 2 * 8 * i] =
580 nnz_cache[3 + 8 * 6 + 2 * 8 * i] =
581 nnz_cache[3 + 8 * 7 + 2 * 8 * i] =
582 nnz_cache[3 + 8 * 11 + 2 * 8 * i] =
583 nnz_cache[3 + 8 * 12 + 2 * 8 * i] = CABAC && !IS_INTRA(mb_type) ? 0 : 64;
545 }584 }
546 }else{
547 nnz_cache[3+8* 1 + 2*8*i]=
548 nnz_cache[3+8* 2 + 2*8*i]=
549 nnz_cache[3+8* 6 + 2*8*i]=
550 nnz_cache[3+8* 7 + 2*8*i]=
551 nnz_cache[3+8*11 + 2*8*i]=
552 nnz_cache[3+8*12 + 2*8*i]= CABAC && !IS_INTRA(mb_type) ? 0 : 64;
553 }585 }
554 }
555 586
556 if( CABAC ) {587 if (CABAC) {
557 // top_cbp588 // top_cbp
558 if(top_type) {589 if (top_type)
559 h->top_cbp = h->cbp_table[top_xy];590 h->top_cbp = h->cbp_table[top_xy];
560 } else {591 else
561 h->top_cbp = IS_INTRA(mb_type) ? 0x7CF : 0x00F;592 h->top_cbp = IS_INTRA(mb_type) ? 0x7CF : 0x00F;
562 }593 // left_cbp
563 // left_cbp594 if (left_type[LTOP]) {
564 if (left_type[LTOP]) {595 h->left_cbp = (h->cbp_table[left_xy[LTOP]] & 0x7F0) |
565 h->left_cbp = (h->cbp_table[left_xy[LTOP]] & 0x7F0)596 ((h->cbp_table[left_xy[LTOP]] >> (left_block[0] & (~1))) & 2) |
566 | ((h->cbp_table[left_xy[LTOP]]>>(left_block[0]&(~1)))&2)597 (((h->cbp_table[left_xy[LBOT]] >> (left_block[2] & (~1))) & 2) << 2);
567 | (((h->cbp_table[left_xy[LBOT]]>>(left_block[2]&(~1)))&2) << 2);598 } else {
568 } else {599 h->left_cbp = IS_INTRA(mb_type) ? 0x7CF : 0x00F;
569 h->left_cbp = IS_INTRA(mb_type) ? 0x7CF : 0x00F;600 }
570 }601 }
571 }602 }
572 }
573 603
574 if(IS_INTER(mb_type) || (IS_DIRECT(mb_type) && h->direct_spatial_mv_pred)){604 if (IS_INTER(mb_type) || (IS_DIRECT(mb_type) && h->direct_spatial_mv_pred)) {
575 int list;605 int list;
576 int b_stride = h->b_stride;606 int b_stride = h->b_stride;
577 for(list=0; list<h->list_count; list++){607 for (list = 0; list < h->list_count; list++) {
578 int8_t *ref_cache = &h->ref_cache[list][scan8[0]];608 int8_t *ref_cache = &h->ref_cache[list][scan8[0]];
579 int8_t *ref = s->current_picture.f.ref_index[list];609 int8_t *ref = s->current_picture.f.ref_index[list];
580 int16_t (*mv_cache)[2] = &h->mv_cache[list][scan8[0]];610 int16_t(*mv_cache)[2] = &h->mv_cache[list][scan8[0]];
581 int16_t (*mv)[2] = s->current_picture.f.motion_val[list];611 int16_t(*mv)[2] = s->current_picture.f.motion_val[list];
582 if(!USES_LIST(mb_type, list)){612 if (!USES_LIST(mb_type, list))
583 continue;613 continue;
584 }
585 assert(!(IS_DIRECT(mb_type) && !h->direct_spatial_mv_pred));614 assert(!(IS_DIRECT(mb_type) && !h->direct_spatial_mv_pred));
586 615
587 if(USES_LIST(top_type, list)){616 if (USES_LIST(top_type, list)) {
588 const int b_xy= h->mb2b_xy[top_xy] + 3*b_stride;617 const int b_xy = h->mb2b_xy[top_xy] + 3 * b_stride;
589 AV_COPY128(mv_cache[0 - 1*8], mv[b_xy + 0]);618 AV_COPY128(mv_cache[0 - 1 * 8], mv[b_xy + 0]);
590 ref_cache[0 - 1*8]=619 ref_cache[0 - 1 * 8] =
591 ref_cache[1 - 1*8]= ref[4*top_xy + 2];620 ref_cache[1 - 1 * 8] = ref[4 * top_xy + 2];
592 ref_cache[2 - 1*8]=621 ref_cache[2 - 1 * 8] =
593 ref_cache[3 - 1*8]= ref[4*top_xy + 3];622 ref_cache[3 - 1 * 8] = ref[4 * top_xy + 3];
594 }else{623 } else {
595 AV_ZERO128(mv_cache[0 - 1*8]);624 AV_ZERO128(mv_cache[0 - 1 * 8]);
596 AV_WN32A(&ref_cache[0 - 1*8], ((top_type ? LIST_NOT_USED : PART_NOT_AVAILABLE)&0xFF)*0x01010101u);625 AV_WN32A(&ref_cache[0 - 1 * 8],
626 ((top_type ? LIST_NOT_USED : PART_NOT_AVAILABLE) & 0xFF) * 0x01010101u);
597 }627 }
598 628
599 if(mb_type & (MB_TYPE_16x8|MB_TYPE_8x8)){629 if (mb_type & (MB_TYPE_16x8 | MB_TYPE_8x8)) {
600 for(i=0; i<2; i++){630 for (i = 0; i < 2; i++) {
601 int cache_idx = -1 + i*2*8;631 int cache_idx = -1 + i * 2 * 8;
602 if(USES_LIST(left_type[LEFT(i)], list)){632 if (USES_LIST(left_type[LEFT(i)], list)) {
603 const int b_xy= h->mb2b_xy[left_xy[LEFT(i)]] + 3;633 const int b_xy = h->mb2b_xy[left_xy[LEFT(i)]] + 3;
604 const int b8_xy= 4*left_xy[LEFT(i)] + 1;634 const int b8_xy = 4 * left_xy[LEFT(i)] + 1;
605 AV_COPY32(mv_cache[cache_idx ], mv[b_xy + b_stride*left_block[0+i*2]]);635 AV_COPY32(mv_cache[cache_idx],
606 AV_COPY32(mv_cache[cache_idx+8], mv[b_xy + b_stride*left_block[1+i*2]]);636 mv[b_xy + b_stride * left_block[0 + i * 2]]);
607 ref_cache[cache_idx ]= ref[b8_xy + (left_block[0+i*2]&~1)];637 AV_COPY32(mv_cache[cache_idx + 8],
608 ref_cache[cache_idx+8]= ref[b8_xy + (left_block[1+i*2]&~1)];638 mv[b_xy + b_stride * left_block[1 + i * 2]]);
609 }else{639 ref_cache[cache_idx] = ref[b8_xy + (left_block[0 + i * 2] & ~1)];
610 AV_ZERO32(mv_cache[cache_idx ]);640 ref_cache[cache_idx + 8] = ref[b8_xy + (left_block[1 + i * 2] & ~1)];
611 AV_ZERO32(mv_cache[cache_idx+8]);641 } else {
612 ref_cache[cache_idx ]=642 AV_ZERO32(mv_cache[cache_idx]);
613 ref_cache[cache_idx+8]= (left_type[LEFT(i)]) ? LIST_NOT_USED : PART_NOT_AVAILABLE;643 AV_ZERO32(mv_cache[cache_idx + 8]);
644 ref_cache[cache_idx] =
645 ref_cache[cache_idx + 8] = (left_type[LEFT(i)]) ? LIST_NOT_USED
646 : PART_NOT_AVAILABLE;
647 }
614 }648 }
615 }649 } else {
616 }else{650 if (USES_LIST(left_type[LTOP], list)) {
617 if(USES_LIST(left_type[LTOP], list)){651 const int b_xy = h->mb2b_xy[left_xy[LTOP]] + 3;
618 const int b_xy= h->mb2b_xy[left_xy[LTOP]] + 3;652 const int b8_xy = 4 * left_xy[LTOP] + 1;
619 const int b8_xy= 4*left_xy[LTOP] + 1;653 AV_COPY32(mv_cache[-1], mv[b_xy + b_stride * left_block[0]]);
620 AV_COPY32(mv_cache[-1], mv[b_xy + b_stride*left_block[0]]);654 ref_cache[-1] = ref[b8_xy + (left_block[0] & ~1)];
621 ref_cache[-1]= ref[b8_xy + (left_block[0]&~1)];655 } else {
622 }else{
623 AV_ZERO32(mv_cache[-1]);656 AV_ZERO32(mv_cache[-1]);
624 ref_cache[-1]= left_type[LTOP] ? LIST_NOT_USED : PART_NOT_AVAILABLE;657 ref_cache[-1] = left_type[LTOP] ? LIST_NOT_USED
658 : PART_NOT_AVAILABLE;
625 }659 }
626 }660 }
627 661
628 if(USES_LIST(topright_type, list)){662 if (USES_LIST(topright_type, list)) {
629 const int b_xy= h->mb2b_xy[topright_xy] + 3*b_stride;663 const int b_xy = h->mb2b_xy[topright_xy] + 3 * b_stride;
630 AV_COPY32(mv_cache[4 - 1*8], mv[b_xy]);664 AV_COPY32(mv_cache[4 - 1 * 8], mv[b_xy]);
631 ref_cache[4 - 1*8]= ref[4*topright_xy + 2];665 ref_cache[4 - 1 * 8] = ref[4 * topright_xy + 2];
632 }else{666 } else {
633 AV_ZERO32(mv_cache[4 - 1*8]);667 AV_ZERO32(mv_cache[4 - 1 * 8]);
634 ref_cache[4 - 1*8]= topright_type ? LIST_NOT_USED : PART_NOT_AVAILABLE;668 ref_cache[4 - 1 * 8] = topright_type ? LIST_NOT_USED
669 : PART_NOT_AVAILABLE;
635 }670 }
636 if(ref_cache[4 - 1*8] < 0){671 if (ref_cache[4 - 1 * 8] < 0) {
637 if(USES_LIST(topleft_type, list)){672 if (USES_LIST(topleft_type, list)) {
638 const int b_xy = h->mb2b_xy[topleft_xy] + 3 + b_stride + (h->topleft_partition & 2*b_stride);673 const int b_xy = h->mb2b_xy[topleft_xy] + 3 + b_stride +
639 const int b8_xy= 4*topleft_xy + 1 + (h->topleft_partition & 2);674 (h->topleft_partition & 2 * b_stride);
640 AV_COPY32(mv_cache[-1 - 1*8], mv[b_xy]);675 const int b8_xy = 4 * topleft_xy + 1 + (h->topleft_partition & 2);
641 ref_cache[-1 - 1*8]= ref[b8_xy];676 AV_COPY32(mv_cache[-1 - 1 * 8], mv[b_xy]);
642 }else{677 ref_cache[-1 - 1 * 8] = ref[b8_xy];
643 AV_ZERO32(mv_cache[-1 - 1*8]);678 } else {
644 ref_cache[-1 - 1*8]= topleft_type ? LIST_NOT_USED : PART_NOT_AVAILABLE;679 AV_ZERO32(mv_cache[-1 - 1 * 8]);
680 ref_cache[-1 - 1 * 8] = topleft_type ? LIST_NOT_USED
681 : PART_NOT_AVAILABLE;
645 }682 }
646 }683 }
647 684
648 if((mb_type&(MB_TYPE_SKIP|MB_TYPE_DIRECT2)) && !FRAME_MBAFF)685 if ((mb_type & (MB_TYPE_SKIP | MB_TYPE_DIRECT2)) && !FRAME_MBAFF)
649 continue;686 continue;
650 687
651 if(!(mb_type&(MB_TYPE_SKIP|MB_TYPE_DIRECT2))){688 if (!(mb_type & (MB_TYPE_SKIP | MB_TYPE_DIRECT2))) {
652 uint8_t (*mvd_cache)[2] = &h->mvd_cache[list][scan8[0]];689 uint8_t(*mvd_cache)[2] = &h->mvd_cache[list][scan8[0]];
653 uint8_t (*mvd)[2] = h->mvd_table[list];690 uint8_t(*mvd)[2] = h->mvd_table[list];
654 ref_cache[2+8*0] =691 ref_cache[2 + 8 * 0] =
655 ref_cache[2+8*2] = PART_NOT_AVAILABLE;692 ref_cache[2 + 8 * 2] = PART_NOT_AVAILABLE;
656 AV_ZERO32(mv_cache[2+8*0]);693 AV_ZERO32(mv_cache[2 + 8 * 0]);
657 AV_ZERO32(mv_cache[2+8*2]);694 AV_ZERO32(mv_cache[2 + 8 * 2]);
658 695
659 if( CABAC ) {696 if (CABAC) {
660 if(USES_LIST(top_type, list)){697 if (USES_LIST(top_type, list)) {
661 const int b_xy= h->mb2br_xy[top_xy];698 const int b_xy = h->mb2br_xy[top_xy];
662 AV_COPY64(mvd_cache[0 - 1*8], mvd[b_xy + 0]);699 AV_COPY64(mvd_cache[0 - 1 * 8], mvd[b_xy + 0]);
663 }else{700 } else {
664 AV_ZERO64(mvd_cache[0 - 1*8]);701 AV_ZERO64(mvd_cache[0 - 1 * 8]);
665 }702 }
666 if(USES_LIST(left_type[LTOP], list)){703 if (USES_LIST(left_type[LTOP], list)) {
667 const int b_xy= h->mb2br_xy[left_xy[LTOP]] + 6;704 const int b_xy = h->mb2br_xy[left_xy[LTOP]] + 6;
668 AV_COPY16(mvd_cache[-1 + 0*8], mvd[b_xy - left_block[0]]);705 AV_COPY16(mvd_cache[-1 + 0 * 8], mvd[b_xy - left_block[0]]);
669 AV_COPY16(mvd_cache[-1 + 1*8], mvd[b_xy - left_block[1]]);706 AV_COPY16(mvd_cache[-1 + 1 * 8], mvd[b_xy - left_block[1]]);
670 }else{707 } else {
671 AV_ZERO16(mvd_cache[-1 + 0*8]);708 AV_ZERO16(mvd_cache[-1 + 0 * 8]);
672 AV_ZERO16(mvd_cache[-1 + 1*8]);709 AV_ZERO16(mvd_cache[-1 + 1 * 8]);
673 }710 }
674 if(USES_LIST(left_type[LBOT], list)){711 if (USES_LIST(left_type[LBOT], list)) {
675 const int b_xy= h->mb2br_xy[left_xy[LBOT]] + 6;712 const int b_xy = h->mb2br_xy[left_xy[LBOT]] + 6;
676 AV_COPY16(mvd_cache[-1 + 2*8], mvd[b_xy - left_block[2]]);713 AV_COPY16(mvd_cache[-1 + 2 * 8], mvd[b_xy - left_block[2]]);
677 AV_COPY16(mvd_cache[-1 + 3*8], mvd[b_xy - left_block[3]]);714 AV_COPY16(mvd_cache[-1 + 3 * 8], mvd[b_xy - left_block[3]]);
678 }else{715 } else {
679 AV_ZERO16(mvd_cache[-1 + 2*8]);716 AV_ZERO16(mvd_cache[-1 + 2 * 8]);
680 AV_ZERO16(mvd_cache[-1 + 3*8]);717 AV_ZERO16(mvd_cache[-1 + 3 * 8]);
681 }718 }
682 AV_ZERO16(mvd_cache[2+8*0]);719 AV_ZERO16(mvd_cache[2 + 8 * 0]);
683 AV_ZERO16(mvd_cache[2+8*2]);720 AV_ZERO16(mvd_cache[2 + 8 * 2]);
684 if(h->slice_type_nos == AV_PICTURE_TYPE_B){721 if (h->slice_type_nos == AV_PICTURE_TYPE_B) {
685 uint8_t *direct_cache = &h->direct_cache[scan8[0]];722 uint8_t *direct_cache = &h->direct_cache[scan8[0]];
686 uint8_t *direct_table = h->direct_table;723 uint8_t *direct_table = h->direct_table;
687 fill_rectangle(direct_cache, 4, 4, 8, MB_TYPE_16x16>>1, 1);724 fill_rectangle(direct_cache, 4, 4, 8, MB_TYPE_16x16 >> 1, 1);
688 725
689 if(IS_DIRECT(top_type)){726 if (IS_DIRECT(top_type)) {
690 AV_WN32A(&direct_cache[-1*8], 0x01010101u*(MB_TYPE_DIRECT2>>1));727 AV_WN32A(&direct_cache[-1 * 8],
691 }else if(IS_8X8(top_type)){728 0x01010101u * (MB_TYPE_DIRECT2 >> 1));
692 int b8_xy = 4*top_xy;729 } else if (IS_8X8(top_type)) {
693 direct_cache[0 - 1*8]= direct_table[b8_xy + 2];730 int b8_xy = 4 * top_xy;
694 direct_cache[2 - 1*8]= direct_table[b8_xy + 3];731 direct_cache[0 - 1 * 8] = direct_table[b8_xy + 2];
695 }else{732 direct_cache[2 - 1 * 8] = direct_table[b8_xy + 3];
696 AV_WN32A(&direct_cache[-1*8], 0x01010101*(MB_TYPE_16x16>>1));733 } else {
734 AV_WN32A(&direct_cache[-1 * 8],
735 0x01010101 * (MB_TYPE_16x16 >> 1));
697 }736 }
698 737
699 if(IS_DIRECT(left_type[LTOP]))738 if (IS_DIRECT(left_type[LTOP]))
700 direct_cache[-1 + 0*8]= MB_TYPE_DIRECT2>>1;739 direct_cache[-1 + 0 * 8] = MB_TYPE_DIRECT2 >> 1;
701 else if(IS_8X8(left_type[LTOP]))740 else if (IS_8X8(left_type[LTOP]))
702 direct_cache[-1 + 0*8]= direct_table[4*left_xy[LTOP] + 1 + (left_block[0]&~1)];741 direct_cache[-1 + 0 * 8] = direct_table[4 * left_xy[LTOP] + 1 + (left_block[0] & ~1)];
703 else742 else
704 direct_cache[-1 + 0*8]= MB_TYPE_16x16>>1;743 direct_cache[-1 + 0 * 8] = MB_TYPE_16x16 >> 1;
705 744
706 if(IS_DIRECT(left_type[LBOT]))745 if (IS_DIRECT(left_type[LBOT]))
707 direct_cache[-1 + 2*8]= MB_TYPE_DIRECT2>>1;746 direct_cache[-1 + 2 * 8] = MB_TYPE_DIRECT2 >> 1;
708 else if(IS_8X8(left_type[LBOT]))747 else if (IS_8X8(left_type[LBOT]))
709 direct_cache[-1 + 2*8]= direct_table[4*left_xy[LBOT] + 1 + (left_block[2]&~1)];748 direct_cache[-1 + 2 * 8] = direct_table[4 * left_xy[LBOT] + 1 + (left_block[2] & ~1)];
710 else749 else
711 direct_cache[-1 + 2*8]= MB_TYPE_16x16>>1;750 direct_cache[-1 + 2 * 8] = MB_TYPE_16x16 >> 1;
712 }751 }
713 }752 }
714 }753 }
715 if(FRAME_MBAFF){754
716#define MAP_MVS\755#define MAP_MVS \
717 MAP_F2F(scan8[0] - 1 - 1*8, topleft_type)\756 MAP_F2F(scan8[0] - 1 - 1 * 8, topleft_type) \
718 MAP_F2F(scan8[0] + 0 - 1*8, top_type)\757 MAP_F2F(scan8[0] + 0 - 1 * 8, top_type) \
719 MAP_F2F(scan8[0] + 1 - 1*8, top_type)\758 MAP_F2F(scan8[0] + 1 - 1 * 8, top_type) \
720 MAP_F2F(scan8[0] + 2 - 1*8, top_type)\759 MAP_F2F(scan8[0] + 2 - 1 * 8, top_type) \
721 MAP_F2F(scan8[0] + 3 - 1*8, top_type)\760 MAP_F2F(scan8[0] + 3 - 1 * 8, top_type) \
722 MAP_F2F(scan8[0] + 4 - 1*8, topright_type)\761 MAP_F2F(scan8[0] + 4 - 1 * 8, topright_type) \
723 MAP_F2F(scan8[0] - 1 + 0*8, left_type[LTOP])\762 MAP_F2F(scan8[0] - 1 + 0 * 8, left_type[LTOP]) \
724 MAP_F2F(scan8[0] - 1 + 1*8, left_type[LTOP])\763 MAP_F2F(scan8[0] - 1 + 1 * 8, left_type[LTOP]) \
725 MAP_F2F(scan8[0] - 1 + 2*8, left_type[LBOT])\764 MAP_F2F(scan8[0] - 1 + 2 * 8, left_type[LBOT]) \
726 MAP_F2F(scan8[0] - 1 + 3*8, left_type[LBOT])765 MAP_F2F(scan8[0] - 1 + 3 * 8, left_type[LBOT])
727 if(MB_FIELD){766
728#define MAP_F2F(idx, mb_type)\767 if (FRAME_MBAFF) {
729 if(!IS_INTERLACED(mb_type) && h->ref_cache[list][idx] >= 0){\768 if (MB_FIELD) {
730 h->ref_cache[list][idx] <<= 1;\769
731 h->mv_cache[list][idx][1] /= 2;\770#define MAP_F2F(idx, mb_type) \
732 h->mvd_cache[list][idx][1] >>=1;\771 if (!IS_INTERLACED(mb_type) && h->ref_cache[list][idx] >= 0) { \
733 }772 h->ref_cache[list][idx] <<= 1; \
773 h->mv_cache[list][idx][1] /= 2; \
774 h->mvd_cache[list][idx][1] >>= 1; \
775 }
776
734 MAP_MVS777 MAP_MVS
778 } else {
779
735#undef MAP_F2F780#undef MAP_F2F
736 }else{781#define MAP_F2F(idx, mb_type) \
737#define MAP_F2F(idx, mb_type)\782 if (IS_INTERLACED(mb_type) && h->ref_cache[list][idx] >= 0) { \
738 if(IS_INTERLACED(mb_type) && h->ref_cache[list][idx] >= 0){\783 h->ref_cache[list][idx] >>= 1; \
739 h->ref_cache[list][idx] >>= 1;\784 h->mv_cache[list][idx][1] <<= 1; \
740 h->mv_cache[list][idx][1] <<= 1;\785 h->mvd_cache[list][idx][1] <<= 1; \
741 h->mvd_cache[list][idx][1] <<= 1;\786 }
742 }787
743 MAP_MVS788 MAP_MVS
744#undef MAP_F2F789#undef MAP_F2F
745 }790 }
@@ -747,36 +792,34 @@ static void fill_decode_caches(H264Context *h, int mb_type){ · 1 unmodified line
747 }792 }
748 }793 }
749 794
750 h->neighbor_transform_size= !!IS_8x8DCT(top_type) + !!IS_8x8DCT(left_type[LTOP]);795 h->neighbor_transform_size = !!IS_8x8DCT(top_type) + !!IS_8x8DCT(left_type[LTOP]);
751}796}
752 797
753/**798/**
754 * decodes a P_SKIP or B_SKIP macroblock799 * decodes a P_SKIP or B_SKIP macroblock
755 */800 */
756static void av_unused decode_mb_skip(H264Context *h){801static void av_unused decode_mb_skip(H264Context *h)
757 MpegEncContext * const s = &h->s;802{
758 const int mb_xy= h->mb_xy;803 MpegEncContext *const s = &h->s;
759 int mb_type=0;804 const int mb_xy = h->mb_xy;
805 int mb_type = 0;
760 806
761 memset(h->non_zero_count[mb_xy], 0, 48);807 memset(h->non_zero_count[mb_xy], 0, 48);
762 808
763 if(MB_FIELD)809 if (MB_FIELD)
764 mb_type|= MB_TYPE_INTERLACED;810 mb_type |= MB_TYPE_INTERLACED;
765 811
766 if( h->slice_type_nos == AV_PICTURE_TYPE_B )812 if (h->slice_type_nos == AV_PICTURE_TYPE_B) {
767 {
768 // just for fill_caches. pred_direct_motion will set the real mb_type813 // just for fill_caches. pred_direct_motion will set the real mb_type
769 mb_type|= MB_TYPE_L0L1|MB_TYPE_DIRECT2|MB_TYPE_SKIP;814 mb_type |= MB_TYPE_L0L1 | MB_TYPE_DIRECT2 | MB_TYPE_SKIP;
770 if(h->direct_spatial_mv_pred){815 if (h->direct_spatial_mv_pred) {
771 fill_decode_neighbors(h, mb_type);816 fill_decode_neighbors(h, mb_type);
772 fill_decode_caches(h, mb_type); //FIXME check what is needed and what not ...817 fill_decode_caches(h, mb_type); //FIXME check what is needed and what not ...
773 }818 }
774 ff_h264_pred_direct_motion(h, &mb_type);819 ff_h264_pred_direct_motion(h, &mb_type);
775 mb_type|= MB_TYPE_SKIP;820 mb_type |= MB_TYPE_SKIP;
776 }821 } else {
777 else822 mb_type |= MB_TYPE_16x16 | MB_TYPE_P0L0 | MB_TYPE_P1L0 | MB_TYPE_SKIP;
778 {
779 mb_type|= MB_TYPE_16x16|MB_TYPE_P0L0|MB_TYPE_P1L0|MB_TYPE_SKIP;
780 823
781 fill_decode_neighbors(h, mb_type);824 fill_decode_neighbors(h, mb_type);
782 pred_pskip_motion(h);825 pred_pskip_motion(h);
@@ -785,8 +828,8 @@ static void av_unused decode_mb_skip(H264Context *h){ · 2 unmodified lines
785 write_back_motion(h, mb_type);828 write_back_motion(h, mb_type);
786 s->current_picture.f.mb_type[mb_xy] = mb_type;829 s->current_picture.f.mb_type[mb_xy] = mb_type;
787 s->current_picture.f.qscale_table[mb_xy] = s->qscale;830 s->current_picture.f.qscale_table[mb_xy] = s->qscale;
788 h->slice_table[ mb_xy ]= h->slice_num;831 h->slice_table[mb_xy] = h->slice_num;
789 h->prev_mb_skipped= 1;832 h->prev_mb_skipped = 1;
790}833}
791 834
792#endif /* AVCODEC_H264_MVPRED_H */835#endif /* AVCODEC_H264_MVPRED_H */
libavcodec/h264dsp.h+65−31
@@ -28,56 +28,90 @@ · 27 unmodified lines
28#define AVCODEC_H264DSP_H28#define AVCODEC_H264DSP_H
29 29
30#include <stdint.h>30#include <stdint.h>
31
31#include "dsputil.h"32#include "dsputil.h"
32 33
33typedef void (*h264_weight_func)(uint8_t *block, int stride, int height,34typedef void (*h264_weight_func)(uint8_t *block, int stride, int height,
34 int log2_denom, int weight, int offset);35 int log2_denom, int weight, int offset);
35typedef void (*h264_biweight_func)(uint8_t *dst, uint8_t *src, int stride, int height,36typedef void (*h264_biweight_func)(uint8_t *dst, uint8_t *src,
36 int log2_denom, int weightd, int weights, int offset);37 int stride, int height, int log2_denom,
38 int weightd, int weights, int offset);
37 39
38/**40/**
39 * Context for storing H.264 DSP functions41 * Context for storing H.264 DSP functions
40 */42 */
41typedef struct H264DSPContext{43typedef struct H264DSPContext {
42 /* weighted MC */44 /* weighted MC */
43 h264_weight_func weight_h264_pixels_tab[4];45 h264_weight_func weight_h264_pixels_tab[4];
44 h264_biweight_func biweight_h264_pixels_tab[4];46 h264_biweight_func biweight_h264_pixels_tab[4];
45 47
46 /* loop filter */48 /* loop filter */
47 void (*h264_v_loop_filter_luma)(uint8_t *pix/*align 16*/, int stride, int alpha, int beta, int8_t *tc0);49 void (*h264_v_loop_filter_luma)(uint8_t *pix /*align 16*/, int stride,
48 void (*h264_h_loop_filter_luma)(uint8_t *pix/*align 4 */, int stride, int alpha, int beta, int8_t *tc0);50 int alpha, int beta, int8_t *tc0);
49 void (*h264_h_loop_filter_luma_mbaff)(uint8_t *pix/*align 16*/, int stride, int alpha, int beta, int8_t *tc0);51 void (*h264_h_loop_filter_luma)(uint8_t *pix /*align 4 */, int stride,
52 int alpha, int beta, int8_t *tc0);
53 void (*h264_h_loop_filter_luma_mbaff)(uint8_t *pix /*align 16*/, int stride,
54 int alpha, int beta, int8_t *tc0);
50 /* v/h_loop_filter_luma_intra: align 16 */55 /* v/h_loop_filter_luma_intra: align 16 */
51 void (*h264_v_loop_filter_luma_intra)(uint8_t *pix, int stride, int alpha, int beta);56 void (*h264_v_loop_filter_luma_intra)(uint8_t *pix, int stride,
52 void (*h264_h_loop_filter_luma_intra)(uint8_t *pix, int stride, int alpha, int beta);57 int alpha, int beta);
53 void (*h264_h_loop_filter_luma_mbaff_intra)(uint8_t *pix/*align 16*/, int stride, int alpha, int beta);58 void (*h264_h_loop_filter_luma_intra)(uint8_t *pix, int stride,
54 void (*h264_v_loop_filter_chroma)(uint8_t *pix/*align 8*/, int stride, int alpha, int beta, int8_t *tc0);59 int alpha, int beta);
55 void (*h264_h_loop_filter_chroma)(uint8_t *pix/*align 4*/, int stride, int alpha, int beta, int8_t *tc0);60 void (*h264_h_loop_filter_luma_mbaff_intra)(uint8_t *pix /*align 16*/,
56 void (*h264_h_loop_filter_chroma_mbaff)(uint8_t *pix/*align 8*/, int stride, int alpha, int beta, int8_t *tc0);61 int stride, int alpha, int beta);
57 void (*h264_v_loop_filter_chroma_intra)(uint8_t *pix/*align 8*/, int stride, int alpha, int beta);62 void (*h264_v_loop_filter_chroma)(uint8_t *pix /*align 8*/, int stride,
58 void (*h264_h_loop_filter_chroma_intra)(uint8_t *pix/*align 8*/, int stride, int alpha, int beta);63 int alpha, int beta, int8_t *tc0);
59 void (*h264_h_loop_filter_chroma_mbaff_intra)(uint8_t *pix/*align 8*/, int stride, int alpha, int beta);64 void (*h264_h_loop_filter_chroma)(uint8_t *pix /*align 4*/, int stride,
65 int alpha, int beta, int8_t *tc0);
66 void (*h264_h_loop_filter_chroma_mbaff)(uint8_t *pix /*align 8*/,
67 int stride, int alpha, int beta,
68 int8_t *tc0);
69 void (*h264_v_loop_filter_chroma_intra)(uint8_t *pix /*align 8*/,
70 int stride, int alpha, int beta);
71 void (*h264_h_loop_filter_chroma_intra)(uint8_t *pix /*align 8*/,
72 int stride, int alpha, int beta);
73 void (*h264_h_loop_filter_chroma_mbaff_intra)(uint8_t *pix /*align 8*/,
74 int stride, int alpha, int beta);
60 // h264_loop_filter_strength: simd only. the C version is inlined in h264.c75 // h264_loop_filter_strength: simd only. the C version is inlined in h264.c
61 void (*h264_loop_filter_strength)(int16_t bS[2][4][4], uint8_t nnz[40], int8_t ref[2][40], int16_t mv[2][40][2],76 void (*h264_loop_filter_strength)(int16_t bS[2][4][4], uint8_t nnz[40],
62 int bidir, int edges, int step, int mask_mv0, int mask_mv1, int field);77 int8_t ref[2][40], int16_t mv[2][40][2],
78 int bidir, int edges, int step,
79 int mask_mv0, int mask_mv1, int field);
63 80
64 /* IDCT */81 /* IDCT */
65 void (*h264_idct_add)(uint8_t *dst/*align 4*/, DCTELEM *block/*align 16*/, int stride);82 void (*h264_idct_add)(uint8_t *dst /*align 4*/,
66 void (*h264_idct8_add)(uint8_t *dst/*align 8*/, DCTELEM *block/*align 16*/, int stride);83 DCTELEM *block /*align 16*/, int stride);
67 void (*h264_idct_dc_add)(uint8_t *dst/*align 4*/, DCTELEM *block/*align 16*/, int stride);84 void (*h264_idct8_add)(uint8_t *dst /*align 8*/,
68 void (*h264_idct8_dc_add)(uint8_t *dst/*align 8*/, DCTELEM *block/*align 16*/, int stride);85 DCTELEM *block /*align 16*/, int stride);
86 void (*h264_idct_dc_add)(uint8_t *dst /*align 4*/,
87 DCTELEM *block /*align 16*/, int stride);
88 void (*h264_idct8_dc_add)(uint8_t *dst /*align 8*/,
89 DCTELEM *block /*align 16*/, int stride);
69 90
70 void (*h264_idct_add16)(uint8_t *dst/*align 16*/, const int *blockoffset, DCTELEM *block/*align 16*/, int stride, const uint8_t nnzc[15*8]);91 void (*h264_idct_add16)(uint8_t *dst /*align 16*/, const int *blockoffset,
71 void (*h264_idct8_add4)(uint8_t *dst/*align 16*/, const int *blockoffset, DCTELEM *block/*align 16*/, int stride, const uint8_t nnzc[15*8]);92 DCTELEM *block /*align 16*/, int stride,
72 void (*h264_idct_add8)(uint8_t **dst/*align 16*/, const int *blockoffset, DCTELEM *block/*align 16*/, int stride, const uint8_t nnzc[15*8]);93 const uint8_t nnzc[15 * 8]);
73 void (*h264_idct_add16intra)(uint8_t *dst/*align 16*/, const int *blockoffset, DCTELEM *block/*align 16*/, int stride, const uint8_t nnzc[15*8]);94 void (*h264_idct8_add4)(uint8_t *dst /*align 16*/, const int *blockoffset,
74 void (*h264_luma_dc_dequant_idct)(DCTELEM *output, DCTELEM *input/*align 16*/, int qmul);95 DCTELEM *block /*align 16*/, int stride,
96 const uint8_t nnzc[15 * 8]);
97 void (*h264_idct_add8)(uint8_t **dst /*align 16*/, const int *blockoffset,
98 DCTELEM *block /*align 16*/, int stride,
99 const uint8_t nnzc[15 * 8]);
100 void (*h264_idct_add16intra)(uint8_t *dst /*align 16*/, const int *blockoffset,
101 DCTELEM *block /*align 16*/,
102 int stride, const uint8_t nnzc[15 * 8]);
103 void (*h264_luma_dc_dequant_idct)(DCTELEM *output,
104 DCTELEM *input /*align 16*/, int qmul);
75 void (*h264_chroma_dc_dequant_idct)(DCTELEM *block, int qmul);105 void (*h264_chroma_dc_dequant_idct)(DCTELEM *block, int qmul);
76}H264DSPContext;106} H264DSPContext;
77 107
78void ff_h264dsp_init(H264DSPContext *c, const int bit_depth, const int chroma_format_idc);108void ff_h264dsp_init(H264DSPContext *c, const int bit_depth,
79void ff_h264dsp_init_arm(H264DSPContext *c, const int bit_depth, const int chroma_format_idc);109 const int chroma_format_idc);
80void ff_h264dsp_init_ppc(H264DSPContext *c, const int bit_depth, const int chroma_format_idc);110void ff_h264dsp_init_arm(H264DSPContext *c, const int bit_depth,
81void ff_h264dsp_init_x86(H264DSPContext *c, const int bit_depth, const int chroma_format_idc);111 const int chroma_format_idc);
112void ff_h264dsp_init_ppc(H264DSPContext *c, const int bit_depth,
113 const int chroma_format_idc);
114void ff_h264dsp_init_x86(H264DSPContext *c, const int bit_depth,
115 const int chroma_format_idc);
82 116
83#endif /* AVCODEC_H264DSP_H */117#endif /* AVCODEC_H264DSP_H */

Keyboard shortcuts

General

Show keyboard shortcuts
?
Focus the current search
/

Issues and pull requests

Open filters
f

Issues, pull requests and Inbox

Select next item
j↓
Select previous item
k↑
Open selected item
Enter
Dismiss filters or clear selection
Esc

Repository code

Go to file
t