FFmpeg
 All Data Structures Namespaces Files Functions Variables Typedefs Enumerations Enumerator Macros Groups Pages
h264_mb.c
Go to the documentation of this file.
1 /*
2  * H.26L/H.264/AVC/JVT/14496-10/... decoder
3  * Copyright (c) 2003 Michael Niedermayer <michaelni@gmx.at>
4  *
5  * This file is part of FFmpeg.
6  *
7  * FFmpeg is free software; you can redistribute it and/or
8  * modify it under the terms of the GNU Lesser General Public
9  * License as published by the Free Software Foundation; either
10  * version 2.1 of the License, or (at your option) any later version.
11  *
12  * FFmpeg is distributed in the hope that it will be useful,
13  * but WITHOUT ANY WARRANTY; without even the implied warranty of
14  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
15  * Lesser General Public License for more details.
16  *
17  * You should have received a copy of the GNU Lesser General Public
18  * License along with FFmpeg; if not, write to the Free Software
19  * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
20  */
21 
22 /**
23  * @file
24  * H.264 / AVC / MPEG4 part10 macroblock decoding
25  */
26 
27 #include <stdint.h>
28 
29 #include "config.h"
30 
31 #include "libavutil/common.h"
32 #include "libavutil/intreadwrite.h"
33 #include "avcodec.h"
34 #include "h264.h"
35 #include "qpeldsp.h"
36 #include "svq3.h"
37 #include "thread.h"
38 
40  int n, int height, int y_offset, int list)
41 {
42  int raw_my = sl->mv_cache[list][scan8[n]][1];
43  int filter_height_down = (raw_my & 3) ? 3 : 0;
44  int full_my = (raw_my >> 2) + y_offset;
45  int bottom = full_my + filter_height_down + height;
46 
47  av_assert2(height >= 0);
48 
49  return FFMAX(0, bottom);
50 }
51 
52 static inline void get_lowest_part_y(const H264Context *h, H264SliceContext *sl,
53  int16_t refs[2][48], int n,
54  int height, int y_offset, int list0,
55  int list1, int *nrefs)
56 {
57  int my;
58 
59  y_offset += 16 * (sl->mb_y >> MB_FIELD(sl));
60 
61  if (list0) {
62  int ref_n = sl->ref_cache[0][scan8[n]];
63  H264Ref *ref = &sl->ref_list[0][ref_n];
64 
65  // Error resilience puts the current picture in the ref list.
66  // Don't try to wait on these as it will cause a deadlock.
67  // Fields can wait on each other, though.
68  if (ref->parent->tf.progress->data != h->cur_pic.tf.progress->data ||
69  (ref->reference & 3) != h->picture_structure) {
70  my = get_lowest_part_list_y(sl, n, height, y_offset, 0);
71  if (refs[0][ref_n] < 0)
72  nrefs[0] += 1;
73  refs[0][ref_n] = FFMAX(refs[0][ref_n], my);
74  }
75  }
76 
77  if (list1) {
78  int ref_n = sl->ref_cache[1][scan8[n]];
79  H264Ref *ref = &sl->ref_list[1][ref_n];
80 
81  if (ref->parent->tf.progress->data != h->cur_pic.tf.progress->data ||
82  (ref->reference & 3) != h->picture_structure) {
83  my = get_lowest_part_list_y(sl, n, height, y_offset, 1);
84  if (refs[1][ref_n] < 0)
85  nrefs[1] += 1;
86  refs[1][ref_n] = FFMAX(refs[1][ref_n], my);
87  }
88  }
89 }
90 
91 /**
92  * Wait until all reference frames are available for MC operations.
93  *
94  * @param h the H264 context
95  */
97 {
98  const int mb_xy = sl->mb_xy;
99  const int mb_type = h->cur_pic.mb_type[mb_xy];
100  int16_t refs[2][48];
101  int nrefs[2] = { 0 };
102  int ref, list;
103 
104  memset(refs, -1, sizeof(refs));
105 
106  if (IS_16X16(mb_type)) {
107  get_lowest_part_y(h, sl, refs, 0, 16, 0,
108  IS_DIR(mb_type, 0, 0), IS_DIR(mb_type, 0, 1), nrefs);
109  } else if (IS_16X8(mb_type)) {
110  get_lowest_part_y(h, sl, refs, 0, 8, 0,
111  IS_DIR(mb_type, 0, 0), IS_DIR(mb_type, 0, 1), nrefs);
112  get_lowest_part_y(h, sl, refs, 8, 8, 8,
113  IS_DIR(mb_type, 1, 0), IS_DIR(mb_type, 1, 1), nrefs);
114  } else if (IS_8X16(mb_type)) {
115  get_lowest_part_y(h, sl, refs, 0, 16, 0,
116  IS_DIR(mb_type, 0, 0), IS_DIR(mb_type, 0, 1), nrefs);
117  get_lowest_part_y(h, sl, refs, 4, 16, 0,
118  IS_DIR(mb_type, 1, 0), IS_DIR(mb_type, 1, 1), nrefs);
119  } else {
120  int i;
121 
122  av_assert2(IS_8X8(mb_type));
123 
124  for (i = 0; i < 4; i++) {
125  const int sub_mb_type = sl->sub_mb_type[i];
126  const int n = 4 * i;
127  int y_offset = (i & 2) << 2;
128 
129  if (IS_SUB_8X8(sub_mb_type)) {
130  get_lowest_part_y(h, sl, refs, n, 8, y_offset,
131  IS_DIR(sub_mb_type, 0, 0),
132  IS_DIR(sub_mb_type, 0, 1),
133  nrefs);
134  } else if (IS_SUB_8X4(sub_mb_type)) {
135  get_lowest_part_y(h, sl, refs, n, 4, y_offset,
136  IS_DIR(sub_mb_type, 0, 0),
137  IS_DIR(sub_mb_type, 0, 1),
138  nrefs);
139  get_lowest_part_y(h, sl, refs, n + 2, 4, y_offset + 4,
140  IS_DIR(sub_mb_type, 0, 0),
141  IS_DIR(sub_mb_type, 0, 1),
142  nrefs);
143  } else if (IS_SUB_4X8(sub_mb_type)) {
144  get_lowest_part_y(h, sl, refs, n, 8, y_offset,
145  IS_DIR(sub_mb_type, 0, 0),
146  IS_DIR(sub_mb_type, 0, 1),
147  nrefs);
148  get_lowest_part_y(h, sl, refs, n + 1, 8, y_offset,
149  IS_DIR(sub_mb_type, 0, 0),
150  IS_DIR(sub_mb_type, 0, 1),
151  nrefs);
152  } else {
153  int j;
154  av_assert2(IS_SUB_4X4(sub_mb_type));
155  for (j = 0; j < 4; j++) {
156  int sub_y_offset = y_offset + 2 * (j & 2);
157  get_lowest_part_y(h, sl, refs, n + j, 4, sub_y_offset,
158  IS_DIR(sub_mb_type, 0, 0),
159  IS_DIR(sub_mb_type, 0, 1),
160  nrefs);
161  }
162  }
163  }
164  }
165 
166  for (list = sl->list_count - 1; list >= 0; list--)
167  for (ref = 0; ref < 48 && nrefs[list]; ref++) {
168  int row = refs[list][ref];
169  if (row >= 0) {
170  H264Ref *ref_pic = &sl->ref_list[list][ref];
171  int ref_field = ref_pic->reference - 1;
172  int ref_field_picture = ref_pic->parent->field_picture;
173  int pic_height = 16 * h->mb_height >> ref_field_picture;
174 
175  row <<= MB_MBAFF(sl);
176  nrefs[list]--;
177 
178  if (!FIELD_PICTURE(h) && ref_field_picture) { // frame referencing two fields
179  av_assert2((ref_pic->parent->reference & 3) == 3);
181  FFMIN((row >> 1) - !(row & 1),
182  pic_height - 1),
183  1);
185  FFMIN((row >> 1), pic_height - 1),
186  0);
187  } else if (FIELD_PICTURE(h) && !ref_field_picture) { // field referencing one field of a frame
189  FFMIN(row * 2 + ref_field,
190  pic_height - 1),
191  0);
192  } else if (FIELD_PICTURE(h)) {
194  FFMIN(row, pic_height - 1),
195  ref_field);
196  } else {
198  FFMIN(row, pic_height - 1),
199  0);
200  }
201  }
202  }
203 }
204 
206  H264Ref *pic,
207  int n, int square, int height,
208  int delta, int list,
209  uint8_t *dest_y, uint8_t *dest_cb,
210  uint8_t *dest_cr,
211  int src_x_offset, int src_y_offset,
212  const qpel_mc_func *qpix_op,
213  h264_chroma_mc_func chroma_op,
214  int pixel_shift, int chroma_idc)
215 {
216  const int mx = sl->mv_cache[list][scan8[n]][0] + src_x_offset * 8;
217  int my = sl->mv_cache[list][scan8[n]][1] + src_y_offset * 8;
218  const int luma_xy = (mx & 3) + ((my & 3) << 2);
219  ptrdiff_t offset = (mx >> 2) * (1 << pixel_shift) + (my >> 2) * sl->mb_linesize;
220  uint8_t *src_y = pic->data[0] + offset;
221  uint8_t *src_cb, *src_cr;
222  int extra_width = 0;
223  int extra_height = 0;
224  int emu = 0;
225  const int full_mx = mx >> 2;
226  const int full_my = my >> 2;
227  const int pic_width = 16 * h->mb_width;
228  const int pic_height = 16 * h->mb_height >> MB_FIELD(sl);
229  int ysh;
230 
231  if (mx & 7)
232  extra_width -= 3;
233  if (my & 7)
234  extra_height -= 3;
235 
236  if (full_mx < 0 - extra_width ||
237  full_my < 0 - extra_height ||
238  full_mx + 16 /*FIXME*/ > pic_width + extra_width ||
239  full_my + 16 /*FIXME*/ > pic_height + extra_height) {
241  src_y - (2 << pixel_shift) - 2 * sl->mb_linesize,
242  sl->mb_linesize, sl->mb_linesize,
243  16 + 5, 16 + 5 /*FIXME*/, full_mx - 2,
244  full_my - 2, pic_width, pic_height);
245  src_y = sl->edge_emu_buffer + (2 << pixel_shift) + 2 * sl->mb_linesize;
246  emu = 1;
247  }
248 
249  qpix_op[luma_xy](dest_y, src_y, sl->mb_linesize); // FIXME try variable height perhaps?
250  if (!square)
251  qpix_op[luma_xy](dest_y + delta, src_y + delta, sl->mb_linesize);
252 
253  if (CONFIG_GRAY && h->flags & AV_CODEC_FLAG_GRAY)
254  return;
255 
256  if (chroma_idc == 3 /* yuv444 */) {
257  src_cb = pic->data[1] + offset;
258  if (emu) {
260  src_cb - (2 << pixel_shift) - 2 * sl->mb_linesize,
261  sl->mb_linesize, sl->mb_linesize,
262  16 + 5, 16 + 5 /*FIXME*/,
263  full_mx - 2, full_my - 2,
264  pic_width, pic_height);
265  src_cb = sl->edge_emu_buffer + (2 << pixel_shift) + 2 * sl->mb_linesize;
266  }
267  qpix_op[luma_xy](dest_cb, src_cb, sl->mb_linesize); // FIXME try variable height perhaps?
268  if (!square)
269  qpix_op[luma_xy](dest_cb + delta, src_cb + delta, sl->mb_linesize);
270 
271  src_cr = pic->data[2] + offset;
272  if (emu) {
274  src_cr - (2 << pixel_shift) - 2 * sl->mb_linesize,
275  sl->mb_linesize, sl->mb_linesize,
276  16 + 5, 16 + 5 /*FIXME*/,
277  full_mx - 2, full_my - 2,
278  pic_width, pic_height);
279  src_cr = sl->edge_emu_buffer + (2 << pixel_shift) + 2 * sl->mb_linesize;
280  }
281  qpix_op[luma_xy](dest_cr, src_cr, sl->mb_linesize); // FIXME try variable height perhaps?
282  if (!square)
283  qpix_op[luma_xy](dest_cr + delta, src_cr + delta, sl->mb_linesize);
284  return;
285  }
286 
287  ysh = 3 - (chroma_idc == 2 /* yuv422 */);
288  if (chroma_idc == 1 /* yuv420 */ && MB_FIELD(sl)) {
289  // chroma offset when predicting from a field of opposite parity
290  my += 2 * ((sl->mb_y & 1) - (pic->reference - 1));
291  emu |= (my >> 3) < 0 || (my >> 3) + 8 >= (pic_height >> 1);
292  }
293 
294  src_cb = pic->data[1] + ((mx >> 3) * (1 << pixel_shift)) +
295  (my >> ysh) * sl->mb_uvlinesize;
296  src_cr = pic->data[2] + ((mx >> 3) * (1 << pixel_shift)) +
297  (my >> ysh) * sl->mb_uvlinesize;
298 
299  if (emu) {
300  h->vdsp.emulated_edge_mc(sl->edge_emu_buffer, src_cb,
301  sl->mb_uvlinesize, sl->mb_uvlinesize,
302  9, 8 * chroma_idc + 1, (mx >> 3), (my >> ysh),
303  pic_width >> 1, pic_height >> (chroma_idc == 1 /* yuv420 */));
304  src_cb = sl->edge_emu_buffer;
305  }
306  chroma_op(dest_cb, src_cb, sl->mb_uvlinesize,
307  height >> (chroma_idc == 1 /* yuv420 */),
308  mx & 7, ((unsigned)my << (chroma_idc == 2 /* yuv422 */)) & 7);
309 
310  if (emu) {
311  h->vdsp.emulated_edge_mc(sl->edge_emu_buffer, src_cr,
312  sl->mb_uvlinesize, sl->mb_uvlinesize,
313  9, 8 * chroma_idc + 1, (mx >> 3), (my >> ysh),
314  pic_width >> 1, pic_height >> (chroma_idc == 1 /* yuv420 */));
315  src_cr = sl->edge_emu_buffer;
316  }
317  chroma_op(dest_cr, src_cr, sl->mb_uvlinesize, height >> (chroma_idc == 1 /* yuv420 */),
318  mx & 7, ((unsigned)my << (chroma_idc == 2 /* yuv422 */)) & 7);
319 }
320 
322  int n, int square,
323  int height, int delta,
324  uint8_t *dest_y, uint8_t *dest_cb,
325  uint8_t *dest_cr,
326  int x_offset, int y_offset,
327  const qpel_mc_func *qpix_put,
328  h264_chroma_mc_func chroma_put,
329  const qpel_mc_func *qpix_avg,
330  h264_chroma_mc_func chroma_avg,
331  int list0, int list1,
332  int pixel_shift, int chroma_idc)
333 {
334  const qpel_mc_func *qpix_op = qpix_put;
335  h264_chroma_mc_func chroma_op = chroma_put;
336 
337  dest_y += (2 * x_offset << pixel_shift) + 2 * y_offset * sl->mb_linesize;
338  if (chroma_idc == 3 /* yuv444 */) {
339  dest_cb += (2 * x_offset << pixel_shift) + 2 * y_offset * sl->mb_linesize;
340  dest_cr += (2 * x_offset << pixel_shift) + 2 * y_offset * sl->mb_linesize;
341  } else if (chroma_idc == 2 /* yuv422 */) {
342  dest_cb += (x_offset << pixel_shift) + 2 * y_offset * sl->mb_uvlinesize;
343  dest_cr += (x_offset << pixel_shift) + 2 * y_offset * sl->mb_uvlinesize;
344  } else { /* yuv420 */
345  dest_cb += (x_offset << pixel_shift) + y_offset * sl->mb_uvlinesize;
346  dest_cr += (x_offset << pixel_shift) + y_offset * sl->mb_uvlinesize;
347  }
348  x_offset += 8 * sl->mb_x;
349  y_offset += 8 * (sl->mb_y >> MB_FIELD(sl));
350 
351  if (list0) {
352  H264Ref *ref = &sl->ref_list[0][sl->ref_cache[0][scan8[n]]];
353  mc_dir_part(h, sl, ref, n, square, height, delta, 0,
354  dest_y, dest_cb, dest_cr, x_offset, y_offset,
355  qpix_op, chroma_op, pixel_shift, chroma_idc);
356 
357  qpix_op = qpix_avg;
358  chroma_op = chroma_avg;
359  }
360 
361  if (list1) {
362  H264Ref *ref = &sl->ref_list[1][sl->ref_cache[1][scan8[n]]];
363  mc_dir_part(h, sl, ref, n, square, height, delta, 1,
364  dest_y, dest_cb, dest_cr, x_offset, y_offset,
365  qpix_op, chroma_op, pixel_shift, chroma_idc);
366  }
367 }
368 
370  int n, int square,
371  int height, int delta,
372  uint8_t *dest_y, uint8_t *dest_cb,
373  uint8_t *dest_cr,
374  int x_offset, int y_offset,
375  const qpel_mc_func *qpix_put,
376  h264_chroma_mc_func chroma_put,
377  h264_weight_func luma_weight_op,
378  h264_weight_func chroma_weight_op,
379  h264_biweight_func luma_weight_avg,
380  h264_biweight_func chroma_weight_avg,
381  int list0, int list1,
382  int pixel_shift, int chroma_idc)
383 {
384  int chroma_height;
385 
386  dest_y += (2 * x_offset << pixel_shift) + 2 * y_offset * sl->mb_linesize;
387  if (chroma_idc == 3 /* yuv444 */) {
388  chroma_height = height;
389  chroma_weight_avg = luma_weight_avg;
390  chroma_weight_op = luma_weight_op;
391  dest_cb += (2 * x_offset << pixel_shift) + 2 * y_offset * sl->mb_linesize;
392  dest_cr += (2 * x_offset << pixel_shift) + 2 * y_offset * sl->mb_linesize;
393  } else if (chroma_idc == 2 /* yuv422 */) {
394  chroma_height = height;
395  dest_cb += (x_offset << pixel_shift) + 2 * y_offset * sl->mb_uvlinesize;
396  dest_cr += (x_offset << pixel_shift) + 2 * y_offset * sl->mb_uvlinesize;
397  } else { /* yuv420 */
398  chroma_height = height >> 1;
399  dest_cb += (x_offset << pixel_shift) + y_offset * sl->mb_uvlinesize;
400  dest_cr += (x_offset << pixel_shift) + y_offset * sl->mb_uvlinesize;
401  }
402  x_offset += 8 * sl->mb_x;
403  y_offset += 8 * (sl->mb_y >> MB_FIELD(sl));
404 
405  if (list0 && list1) {
406  /* don't optimize for luma-only case, since B-frames usually
407  * use implicit weights => chroma too. */
408  uint8_t *tmp_cb = sl->bipred_scratchpad;
409  uint8_t *tmp_cr = sl->bipred_scratchpad + (16 << pixel_shift);
410  uint8_t *tmp_y = sl->bipred_scratchpad + 16 * sl->mb_uvlinesize;
411  int refn0 = sl->ref_cache[0][scan8[n]];
412  int refn1 = sl->ref_cache[1][scan8[n]];
413 
414  mc_dir_part(h, sl, &sl->ref_list[0][refn0], n, square, height, delta, 0,
415  dest_y, dest_cb, dest_cr,
416  x_offset, y_offset, qpix_put, chroma_put,
417  pixel_shift, chroma_idc);
418  mc_dir_part(h, sl, &sl->ref_list[1][refn1], n, square, height, delta, 1,
419  tmp_y, tmp_cb, tmp_cr,
420  x_offset, y_offset, qpix_put, chroma_put,
421  pixel_shift, chroma_idc);
422 
423  if (sl->use_weight == 2) {
424  int weight0 = sl->implicit_weight[refn0][refn1][sl->mb_y & 1];
425  int weight1 = 64 - weight0;
426  luma_weight_avg(dest_y, tmp_y, sl->mb_linesize,
427  height, 5, weight0, weight1, 0);
428  if (!CONFIG_GRAY || !(h->flags & AV_CODEC_FLAG_GRAY)) {
429  chroma_weight_avg(dest_cb, tmp_cb, sl->mb_uvlinesize,
430  chroma_height, 5, weight0, weight1, 0);
431  chroma_weight_avg(dest_cr, tmp_cr, sl->mb_uvlinesize,
432  chroma_height, 5, weight0, weight1, 0);
433  }
434  } else {
435  luma_weight_avg(dest_y, tmp_y, sl->mb_linesize, height,
437  sl->luma_weight[refn0][0][0],
438  sl->luma_weight[refn1][1][0],
439  sl->luma_weight[refn0][0][1] +
440  sl->luma_weight[refn1][1][1]);
441  if (!CONFIG_GRAY || !(h->flags & AV_CODEC_FLAG_GRAY)) {
442  chroma_weight_avg(dest_cb, tmp_cb, sl->mb_uvlinesize, chroma_height,
444  sl->chroma_weight[refn0][0][0][0],
445  sl->chroma_weight[refn1][1][0][0],
446  sl->chroma_weight[refn0][0][0][1] +
447  sl->chroma_weight[refn1][1][0][1]);
448  chroma_weight_avg(dest_cr, tmp_cr, sl->mb_uvlinesize, chroma_height,
450  sl->chroma_weight[refn0][0][1][0],
451  sl->chroma_weight[refn1][1][1][0],
452  sl->chroma_weight[refn0][0][1][1] +
453  sl->chroma_weight[refn1][1][1][1]);
454  }
455  }
456  } else {
457  int list = list1 ? 1 : 0;
458  int refn = sl->ref_cache[list][scan8[n]];
459  H264Ref *ref = &sl->ref_list[list][refn];
460  mc_dir_part(h, sl, ref, n, square, height, delta, list,
461  dest_y, dest_cb, dest_cr, x_offset, y_offset,
462  qpix_put, chroma_put, pixel_shift, chroma_idc);
463 
464  luma_weight_op(dest_y, sl->mb_linesize, height,
466  sl->luma_weight[refn][list][0],
467  sl->luma_weight[refn][list][1]);
468  if (!CONFIG_GRAY || !(h->flags & AV_CODEC_FLAG_GRAY)) {
469  if (sl->use_weight_chroma) {
470  chroma_weight_op(dest_cb, sl->mb_uvlinesize, chroma_height,
472  sl->chroma_weight[refn][list][0][0],
473  sl->chroma_weight[refn][list][0][1]);
474  chroma_weight_op(dest_cr, sl->mb_uvlinesize, chroma_height,
476  sl->chroma_weight[refn][list][1][0],
477  sl->chroma_weight[refn][list][1][1]);
478  }
479  }
480  }
481 }
482 
484  int list, int pixel_shift,
485  int chroma_idc)
486 {
487  /* fetch pixels for estimated mv 4 macroblocks ahead
488  * optimized for 64byte cache lines */
489  const int refn = sl->ref_cache[list][scan8[0]];
490  if (refn >= 0) {
491  const int mx = (sl->mv_cache[list][scan8[0]][0] >> 2) + 16 * sl->mb_x + 8;
492  const int my = (sl->mv_cache[list][scan8[0]][1] >> 2) + 16 * sl->mb_y;
493  uint8_t **src = sl->ref_list[list][refn].data;
494  int off = mx * (1<< pixel_shift) +
495  (my + (sl->mb_x & 3) * 4) * sl->mb_linesize +
496  (64 << pixel_shift);
497  h->vdsp.prefetch(src[0] + off, sl->linesize, 4);
498  if (chroma_idc == 3 /* yuv444 */) {
499  h->vdsp.prefetch(src[1] + off, sl->linesize, 4);
500  h->vdsp.prefetch(src[2] + off, sl->linesize, 4);
501  } else {
502  off= ((mx>>1)+64) * (1<<pixel_shift) + ((my>>1) + (sl->mb_x&7))*sl->uvlinesize;
503  h->vdsp.prefetch(src[1] + off, src[2] - src[1], 2);
504  }
505  }
506 }
507 
509  uint8_t *src_y,
510  uint8_t *src_cb, uint8_t *src_cr,
511  int linesize, int uvlinesize,
512  int xchg, int chroma444,
513  int simple, int pixel_shift)
514 {
515  int deblock_topleft;
516  int deblock_top;
517  int top_idx = 1;
518  uint8_t *top_border_m1;
519  uint8_t *top_border;
520 
521  if (!simple && FRAME_MBAFF(h)) {
522  if (sl->mb_y & 1) {
523  if (!MB_MBAFF(sl))
524  return;
525  } else {
526  top_idx = MB_MBAFF(sl) ? 0 : 1;
527  }
528  }
529 
530  if (sl->deblocking_filter == 2) {
531  deblock_topleft = h->slice_table[sl->mb_xy - 1 - h->mb_stride] == sl->slice_num;
532  deblock_top = sl->top_type;
533  } else {
534  deblock_topleft = (sl->mb_x > 0);
535  deblock_top = (sl->mb_y > !!MB_FIELD(sl));
536  }
537 
538  src_y -= linesize + 1 + pixel_shift;
539  src_cb -= uvlinesize + 1 + pixel_shift;
540  src_cr -= uvlinesize + 1 + pixel_shift;
541 
542  top_border_m1 = sl->top_borders[top_idx][sl->mb_x - 1];
543  top_border = sl->top_borders[top_idx][sl->mb_x];
544 
545 #define XCHG(a, b, xchg) \
546  if (pixel_shift) { \
547  if (xchg) { \
548  AV_SWAP64(b + 0, a + 0); \
549  AV_SWAP64(b + 8, a + 8); \
550  } else { \
551  AV_COPY128(b, a); \
552  } \
553  } else if (xchg) \
554  AV_SWAP64(b, a); \
555  else \
556  AV_COPY64(b, a);
557 
558  if (deblock_top) {
559  if (deblock_topleft) {
560  XCHG(top_border_m1 + (8 << pixel_shift),
561  src_y - (7 << pixel_shift), 1);
562  }
563  XCHG(top_border + (0 << pixel_shift), src_y + (1 << pixel_shift), xchg);
564  XCHG(top_border + (8 << pixel_shift), src_y + (9 << pixel_shift), 1);
565  if (sl->mb_x + 1 < h->mb_width) {
566  XCHG(sl->top_borders[top_idx][sl->mb_x + 1],
567  src_y + (17 << pixel_shift), 1);
568  }
569  if (simple || !CONFIG_GRAY || !(h->flags & AV_CODEC_FLAG_GRAY)) {
570  if (chroma444) {
571  if (deblock_topleft) {
572  XCHG(top_border_m1 + (24 << pixel_shift), src_cb - (7 << pixel_shift), 1);
573  XCHG(top_border_m1 + (40 << pixel_shift), src_cr - (7 << pixel_shift), 1);
574  }
575  XCHG(top_border + (16 << pixel_shift), src_cb + (1 << pixel_shift), xchg);
576  XCHG(top_border + (24 << pixel_shift), src_cb + (9 << pixel_shift), 1);
577  XCHG(top_border + (32 << pixel_shift), src_cr + (1 << pixel_shift), xchg);
578  XCHG(top_border + (40 << pixel_shift), src_cr + (9 << pixel_shift), 1);
579  if (sl->mb_x + 1 < h->mb_width) {
580  XCHG(sl->top_borders[top_idx][sl->mb_x + 1] + (16 << pixel_shift), src_cb + (17 << pixel_shift), 1);
581  XCHG(sl->top_borders[top_idx][sl->mb_x + 1] + (32 << pixel_shift), src_cr + (17 << pixel_shift), 1);
582  }
583  } else {
584  if (deblock_topleft) {
585  XCHG(top_border_m1 + (16 << pixel_shift), src_cb - (7 << pixel_shift), 1);
586  XCHG(top_border_m1 + (24 << pixel_shift), src_cr - (7 << pixel_shift), 1);
587  }
588  XCHG(top_border + (16 << pixel_shift), src_cb + 1 + pixel_shift, 1);
589  XCHG(top_border + (24 << pixel_shift), src_cr + 1 + pixel_shift, 1);
590  }
591  }
592  }
593 }
594 
595 static av_always_inline int dctcoef_get(int16_t *mb, int high_bit_depth,
596  int index)
597 {
598  if (high_bit_depth) {
599  return AV_RN32A(((int32_t *)mb) + index);
600  } else
601  return AV_RN16A(mb + index);
602 }
603 
604 static av_always_inline void dctcoef_set(int16_t *mb, int high_bit_depth,
605  int index, int value)
606 {
607  if (high_bit_depth) {
608  AV_WN32A(((int32_t *)mb) + index, value);
609  } else
610  AV_WN16A(mb + index, value);
611 }
612 
614  H264SliceContext *sl,
615  int mb_type, int is_h264,
616  int simple,
617  int transform_bypass,
618  int pixel_shift,
619  const int *block_offset,
620  int linesize,
621  uint8_t *dest_y, int p)
622 {
623  void (*idct_add)(uint8_t *dst, int16_t *block, int stride);
624  void (*idct_dc_add)(uint8_t *dst, int16_t *block, int stride);
625  int i;
626  int qscale = p == 0 ? sl->qscale : sl->chroma_qp[p - 1];
627  block_offset += 16 * p;
628  if (IS_INTRA4x4(mb_type)) {
629  if (IS_8x8DCT(mb_type)) {
630  if (transform_bypass) {
631  idct_dc_add =
632  idct_add = h->h264dsp.h264_add_pixels8_clear;
633  } else {
634  idct_dc_add = h->h264dsp.h264_idct8_dc_add;
635  idct_add = h->h264dsp.h264_idct8_add;
636  }
637  for (i = 0; i < 16; i += 4) {
638  uint8_t *const ptr = dest_y + block_offset[i];
639  const int dir = sl->intra4x4_pred_mode_cache[scan8[i]];
640  if (transform_bypass && h->sps.profile_idc == 244 && dir <= 1) {
641  if (h->x264_build != -1) {
642  h->hpc.pred8x8l_add[dir](ptr, sl->mb + (i * 16 + p * 256 << pixel_shift), linesize);
643  } else
644  h->hpc.pred8x8l_filter_add[dir](ptr, sl->mb + (i * 16 + p * 256 << pixel_shift),
645  (sl-> topleft_samples_available << i) & 0x8000,
646  (sl->topright_samples_available << i) & 0x4000, linesize);
647  } else {
648  const int nnz = sl->non_zero_count_cache[scan8[i + p * 16]];
649  h->hpc.pred8x8l[dir](ptr, (sl->topleft_samples_available << i) & 0x8000,
650  (sl->topright_samples_available << i) & 0x4000, linesize);
651  if (nnz) {
652  if (nnz == 1 && dctcoef_get(sl->mb, pixel_shift, i * 16 + p * 256))
653  idct_dc_add(ptr, sl->mb + (i * 16 + p * 256 << pixel_shift), linesize);
654  else
655  idct_add(ptr, sl->mb + (i * 16 + p * 256 << pixel_shift), linesize);
656  }
657  }
658  }
659  } else {
660  if (transform_bypass) {
661  idct_dc_add =
662  idct_add = h->h264dsp.h264_add_pixels4_clear;
663  } else {
664  idct_dc_add = h->h264dsp.h264_idct_dc_add;
665  idct_add = h->h264dsp.h264_idct_add;
666  }
667  for (i = 0; i < 16; i++) {
668  uint8_t *const ptr = dest_y + block_offset[i];
669  const int dir = sl->intra4x4_pred_mode_cache[scan8[i]];
670 
671  if (transform_bypass && h->sps.profile_idc == 244 && dir <= 1) {
672  h->hpc.pred4x4_add[dir](ptr, sl->mb + (i * 16 + p * 256 << pixel_shift), linesize);
673  } else {
674  uint8_t *topright;
675  int nnz, tr;
676  uint64_t tr_high;
677  if (dir == DIAG_DOWN_LEFT_PRED || dir == VERT_LEFT_PRED) {
678  const int topright_avail = (sl->topright_samples_available << i) & 0x8000;
679  av_assert2(sl->mb_y || linesize <= block_offset[i]);
680  if (!topright_avail) {
681  if (pixel_shift) {
682  tr_high = ((uint16_t *)ptr)[3 - linesize / 2] * 0x0001000100010001ULL;
683  topright = (uint8_t *)&tr_high;
684  } else {
685  tr = ptr[3 - linesize] * 0x01010101u;
686  topright = (uint8_t *)&tr;
687  }
688  } else
689  topright = ptr + (4 << pixel_shift) - linesize;
690  } else
691  topright = NULL;
692 
693  h->hpc.pred4x4[dir](ptr, topright, linesize);
694  nnz = sl->non_zero_count_cache[scan8[i + p * 16]];
695  if (nnz) {
696  if (is_h264) {
697  if (nnz == 1 && dctcoef_get(sl->mb, pixel_shift, i * 16 + p * 256))
698  idct_dc_add(ptr, sl->mb + (i * 16 + p * 256 << pixel_shift), linesize);
699  else
700  idct_add(ptr, sl->mb + (i * 16 + p * 256 << pixel_shift), linesize);
701  } else if (CONFIG_SVQ3_DECODER)
702  ff_svq3_add_idct_c(ptr, sl->mb + i * 16 + p * 256, linesize, qscale, 0);
703  }
704  }
705  }
706  }
707  } else {
708  h->hpc.pred16x16[sl->intra16x16_pred_mode](dest_y, linesize);
709  if (is_h264) {
711  if (!transform_bypass)
712  h->h264dsp.h264_luma_dc_dequant_idct(sl->mb + (p * 256 << pixel_shift),
713  sl->mb_luma_dc[p],
714  h->dequant4_coeff[p][qscale][0]);
715  else {
716  static const uint8_t dc_mapping[16] = {
717  0 * 16, 1 * 16, 4 * 16, 5 * 16,
718  2 * 16, 3 * 16, 6 * 16, 7 * 16,
719  8 * 16, 9 * 16, 12 * 16, 13 * 16,
720  10 * 16, 11 * 16, 14 * 16, 15 * 16
721  };
722  for (i = 0; i < 16; i++)
723  dctcoef_set(sl->mb + (p * 256 << pixel_shift),
724  pixel_shift, dc_mapping[i],
725  dctcoef_get(sl->mb_luma_dc[p],
726  pixel_shift, i));
727  }
728  }
729  } else if (CONFIG_SVQ3_DECODER)
730  ff_svq3_luma_dc_dequant_idct_c(sl->mb + p * 256,
731  sl->mb_luma_dc[p], qscale);
732  }
733 }
734 
736  int mb_type,
737  int is_h264, int simple,
738  int transform_bypass,
739  int pixel_shift,
740  const int *block_offset,
741  int linesize,
742  uint8_t *dest_y, int p)
743 {
744  void (*idct_add)(uint8_t *dst, int16_t *block, int stride);
745  int i;
746  block_offset += 16 * p;
747  if (!IS_INTRA4x4(mb_type)) {
748  if (is_h264) {
749  if (IS_INTRA16x16(mb_type)) {
750  if (transform_bypass) {
751  if (h->sps.profile_idc == 244 &&
754  h->hpc.pred16x16_add[sl->intra16x16_pred_mode](dest_y, block_offset,
755  sl->mb + (p * 256 << pixel_shift),
756  linesize);
757  } else {
758  for (i = 0; i < 16; i++)
759  if (sl->non_zero_count_cache[scan8[i + p * 16]] ||
760  dctcoef_get(sl->mb, pixel_shift, i * 16 + p * 256))
761  h->h264dsp.h264_add_pixels4_clear(dest_y + block_offset[i],
762  sl->mb + (i * 16 + p * 256 << pixel_shift),
763  linesize);
764  }
765  } else {
766  h->h264dsp.h264_idct_add16intra(dest_y, block_offset,
767  sl->mb + (p * 256 << pixel_shift),
768  linesize,
769  sl->non_zero_count_cache + p * 5 * 8);
770  }
771  } else if (sl->cbp & 15) {
772  if (transform_bypass) {
773  const int di = IS_8x8DCT(mb_type) ? 4 : 1;
774  idct_add = IS_8x8DCT(mb_type) ? h->h264dsp.h264_add_pixels8_clear
776  for (i = 0; i < 16; i += di)
777  if (sl->non_zero_count_cache[scan8[i + p * 16]])
778  idct_add(dest_y + block_offset[i],
779  sl->mb + (i * 16 + p * 256 << pixel_shift),
780  linesize);
781  } else {
782  if (IS_8x8DCT(mb_type))
783  h->h264dsp.h264_idct8_add4(dest_y, block_offset,
784  sl->mb + (p * 256 << pixel_shift),
785  linesize,
786  sl->non_zero_count_cache + p * 5 * 8);
787  else
788  h->h264dsp.h264_idct_add16(dest_y, block_offset,
789  sl->mb + (p * 256 << pixel_shift),
790  linesize,
791  sl->non_zero_count_cache + p * 5 * 8);
792  }
793  }
794  } else if (CONFIG_SVQ3_DECODER) {
795  for (i = 0; i < 16; i++)
796  if (sl->non_zero_count_cache[scan8[i + p * 16]] || sl->mb[i * 16 + p * 256]) {
797  // FIXME benchmark weird rule, & below
798  uint8_t *const ptr = dest_y + block_offset[i];
799  ff_svq3_add_idct_c(ptr, sl->mb + i * 16 + p * 256, linesize,
800  sl->qscale, IS_INTRA(mb_type) ? 1 : 0);
801  }
802  }
803  }
804 }
805 
806 #define BITS 8
807 #define SIMPLE 1
808 #include "h264_mb_template.c"
809 
810 #undef BITS
811 #define BITS 16
812 #include "h264_mb_template.c"
813 
814 #undef SIMPLE
815 #define SIMPLE 0
816 #include "h264_mb_template.c"
817 
819 {
820  const int mb_xy = sl->mb_xy;
821  const int mb_type = h->cur_pic.mb_type[mb_xy];
822  int is_complex = CONFIG_SMALL || sl->is_complex ||
823  IS_INTRA_PCM(mb_type) || sl->qscale == 0;
824 
825  if (CHROMA444(h)) {
826  if (is_complex || h->pixel_shift)
827  hl_decode_mb_444_complex(h, sl);
828  else
829  hl_decode_mb_444_simple_8(h, sl);
830  } else if (is_complex) {
831  hl_decode_mb_complex(h, sl);
832  } else if (h->pixel_shift) {
833  hl_decode_mb_simple_16(h, sl);
834  } else
835  hl_decode_mb_simple_8(h, sl);
836 }
static void await_references(const H264Context *h, H264SliceContext *sl)
Wait until all reference frames are available for MC operations.
Definition: h264_mb.c:96
void(* h264_idct_add)(uint8_t *dst, int16_t *block, int stride)
Definition: h264dsp.h:80
#define VERT_PRED8x8
Definition: h264pred.h:70
#define NULL
Definition: coverity.c:32
void(* prefetch)(uint8_t *buf, ptrdiff_t stride, int h)
Prefetch memory into cache (if supported by hardware).
Definition: videodsp.h:76
static av_always_inline void hl_decode_mb_idct_luma(const H264Context *h, H264SliceContext *sl, int mb_type, int is_h264, int simple, int transform_bypass, int pixel_shift, const int *block_offset, int linesize, uint8_t *dest_y, int p)
Definition: h264_mb.c:735
int16_t mb[16 *48 *2]
Definition: h264.h:494
#define IS_SUB_4X4(a)
Definition: mpegutils.h:89
void(* pred8x8l_add[2])(uint8_t *pix, int16_t *block, ptrdiff_t stride)
Definition: h264pred.h:102
int16_t mv_cache[2][5 *8][2]
Motion vector cache.
Definition: h264.h:486
static av_always_inline void prefetch_motion(const H264Context *h, H264SliceContext *sl, int list, int pixel_shift, int chroma_idc)
Definition: h264_mb.c:483
#define CHROMA444(h)
Definition: h264.h:99
int luma_weight[48][2][2]
Definition: h264.h:390
static av_always_inline void hl_decode_mb_predict_luma(const H264Context *h, H264SliceContext *sl, int mb_type, int is_h264, int simple, int transform_bypass, int pixel_shift, const int *block_offset, int linesize, uint8_t *dest_y, int p)
Definition: h264_mb.c:613
unsigned int topleft_samples_available
Definition: h264.h:416
int flags
Definition: h264.h:553
int mb_height
Definition: h264.h:619
#define IS_SUB_8X8(a)
Definition: mpegutils.h:86
void(* qpel_mc_func)(uint8_t *dst, const uint8_t *src, ptrdiff_t stride)
Definition: qpeldsp.h:65
void(* pred8x8l_filter_add[2])(uint8_t *pix, int16_t *block, int topleft, int topright, ptrdiff_t stride)
Definition: h264pred.h:104
H264Context.
Definition: h264.h:517
void ff_thread_await_progress(ThreadFrame *f, int n, int field)
Wait for earlier decoding threads to finish reference pictures.
#define HOR_PRED8x8
Definition: h264pred.h:69
int picture_structure
Definition: h264.h:590
#define AV_WN32A(p, v)
Definition: intreadwrite.h:538
int profile_idc
Definition: h264.h:176
void(* h264_add_pixels4_clear)(uint8_t *dst, int16_t *block, int stride)
Definition: h264dsp.h:107
void(* pred16x16_add[3])(uint8_t *pix, const int *block_offset, int16_t *block, ptrdiff_t stride)
Definition: h264pred.h:109
#define AV_RN32A(p)
Definition: intreadwrite.h:526
void(* h264_idct_add16)(uint8_t *dst, const int *blockoffset, int16_t *block, int stride, const uint8_t nnzc[15 *8])
Definition: h264dsp.h:89
int is_complex
Definition: h264.h:432
#define IS_8x8DCT(a)
Definition: h264.h:106
void(* emulated_edge_mc)(uint8_t *dst, const uint8_t *src, ptrdiff_t dst_linesize, ptrdiff_t src_linesize, int block_w, int block_h, int src_x, int src_y, int w, int h)
Copy a rectangular area of samples to a temporary buffer and replicate the border samples...
Definition: videodsp.h:63
uint16_t sub_mb_type[4]
as a dct coefficient is int32_t in high depth, we need to reserve twice the space.
Definition: h264.h:491
#define MB_FIELD(sl)
Definition: h264.h:72
Definition: h264.h:351
uint32_t(*[6] dequant4_coeff)[16]
Definition: h264.h:583
uint8_t
#define mb
#define av_assert2(cond)
assert() equivalent, that does lie in speed critical code.
Definition: avassert.h:63
float delta
int field_picture
whether or not picture was encoded in separate fields
Definition: h264.h:339
void ff_h264_hl_decode_mb(const H264Context *h, H264SliceContext *sl)
Definition: h264_mb.c:818
Multithreading support functions.
#define LUMA_DC_BLOCK_INDEX
Definition: h264.h:1003
uint8_t(*[2] top_borders)[(16 *3)*2]
Definition: h264.h:472
#define IS_DIR(a, part, list)
Definition: mpegutils.h:92
quarterpel DSP functions
void(* h264_add_pixels8_clear)(uint8_t *dst, int16_t *block, int stride)
Definition: h264dsp.h:106
void(* pred4x4[9+3+3])(uint8_t *src, const uint8_t *topright, ptrdiff_t stride)
Definition: h264pred.h:93
H264Picture * parent
Definition: h264.h:359
static av_always_inline void mc_part_weighted(const H264Context *h, H264SliceContext *sl, int n, int square, int height, int delta, uint8_t *dest_y, uint8_t *dest_cb, uint8_t *dest_cr, int x_offset, int y_offset, const qpel_mc_func *qpix_put, h264_chroma_mc_func chroma_put, h264_weight_func luma_weight_op, h264_weight_func chroma_weight_op, h264_biweight_func luma_weight_avg, h264_biweight_func chroma_weight_avg, int list0, int list1, int pixel_shift, int chroma_idc)
Definition: h264_mb.c:369
#define AV_CODEC_FLAG_GRAY
Only decode/encode grayscale.
Definition: avcodec.h:763
int chroma_qp[2]
Definition: h264.h:373
H.264 / AVC / MPEG4 part10 codec.
int slice_num
Definition: h264.h:367
unsigned int topright_samples_available
Definition: h264.h:418
H264PredContext hpc
Definition: h264.h:557
void(* h264_biweight_func)(uint8_t *dst, uint8_t *src, int stride, int height, int log2_denom, int weightd, int weights, int offset)
Definition: h264dsp.h:34
int8_t intra4x4_pred_mode_cache[5 *8]
Definition: h264.h:400
void(* h264_idct8_add)(uint8_t *dst, int16_t *block, int stride)
Definition: h264dsp.h:82
int deblocking_filter
disable_deblocking_filter_idc with 1 <-> 0
Definition: h264.h:378
void(* h264_luma_dc_dequant_idct)(int16_t *output, int16_t *input, int qmul)
Definition: h264dsp.h:101
ThreadFrame tf
Definition: h264.h:311
static int square(int x)
Definition: roqvideoenc.c:113
static const uint8_t offset[127][2]
Definition: vf_spp.c:92
#define FFMAX(a, b)
Definition: common.h:79
Libavcodec external API header.
static const uint8_t scan8[16 *3+3]
Definition: h264.h:1007
int16_t mb_luma_dc[3][16 *2]
as mb is addressed by scantable[i] and scantable is uint8_t we can either check that i is not too lar...
Definition: h264.h:495
int use_weight
Definition: h264.h:383
void ff_svq3_add_idct_c(uint8_t *dst, int16_t *block, int stride, int qp, int dc)
Definition: svq3.c:202
uint8_t * data[3]
Definition: h264.h:352
#define IS_INTRA_PCM(a)
Definition: mpegutils.h:78
#define IS_16X8(a)
Definition: mpegutils.h:83
static av_always_inline void mc_part_std(const H264Context *h, H264SliceContext *sl, int n, int square, int height, int delta, uint8_t *dest_y, uint8_t *dest_cb, uint8_t *dest_cr, int x_offset, int y_offset, const qpel_mc_func *qpix_put, h264_chroma_mc_func chroma_put, const qpel_mc_func *qpix_avg, h264_chroma_mc_func chroma_avg, int list0, int list1, int pixel_shift, int chroma_idc)
Definition: h264_mb.c:321
int x264_build
Definition: h264.h:616
#define IS_SUB_4X8(a)
Definition: mpegutils.h:88
#define FFMIN(a, b)
Definition: common.h:81
uint16_t * slice_table
slice_table_base + 2*mb_stride + 1
Definition: h264.h:586
int reference
Definition: h264.h:341
#define FIELD_PICTURE(h)
Definition: h264.h:74
typedef void(APIENTRY *FF_PFNGLACTIVETEXTUREPROC)(GLenum texture)
GLsizei GLboolean const GLfloat * value
Definition: opengl_enc.c:109
void ff_svq3_luma_dc_dequant_idct_c(int16_t *output, int16_t *input, int qp)
Definition: svq3.c:167
void(* h264_idct_dc_add)(uint8_t *dst, int16_t *block, int stride)
Definition: h264dsp.h:84
uint32_t * mb_type
Definition: h264.h:320
SPS sps
current sps
Definition: h264.h:576
int32_t
float u
int n
Definition: avisynth_c.h:547
int reference
Definition: h264.h:355
void(* pred4x4_add[2])(uint8_t *pix, int16_t *block, ptrdiff_t stride)
Definition: h264pred.h:100
#define AV_WN16A(p, v)
Definition: intreadwrite.h:534
int chroma_log2_weight_denom
Definition: h264.h:386
#define MB_MBAFF(h)
Definition: h264.h:71
#define IS_INTRA16x16(a)
Definition: mpegutils.h:72
uint8_t * edge_emu_buffer
Definition: h264.h:471
int top_type
Definition: h264.h:409
static av_always_inline void dctcoef_set(int16_t *mb, int high_bit_depth, int index, int value)
Definition: h264_mb.c:604
AVBufferRef * progress
Definition: thread.h:40
VideoDSPContext vdsp
Definition: h264.h:520
int intra16x16_pred_mode
Definition: h264.h:398
int mb_stride
Definition: h264.h:620
#define IS_SUB_8X4(a)
Definition: mpegutils.h:87
AVS_Value src
Definition: avisynth_c.h:482
uint8_t * data
The data buffer.
Definition: buffer.h:89
static av_always_inline int dctcoef_get(int16_t *mb, int high_bit_depth, int index)
Definition: h264_mb.c:595
void(* pred16x16[4+3+2])(uint8_t *src, ptrdiff_t stride)
Definition: h264pred.h:98
BYTE int const BYTE int int int height
Definition: avisynth_c.h:676
void(* h264_idct8_add4)(uint8_t *dst, const int *blockoffset, int16_t *block, int stride, const uint8_t nnzc[15 *8])
Definition: h264dsp.h:92
#define IS_16X16(a)
Definition: mpegutils.h:82
uint8_t non_zero_count_cache[15 *8]
non zero coeff count cache.
Definition: h264.h:481
int index
Definition: gxfenc.c:89
#define IS_8X16(a)
Definition: mpegutils.h:84
int use_weight_chroma
Definition: h264.h:384
int pixel_shift
0 for 8-bit H264, 1 for high-bit-depth H264
Definition: h264.h:534
ptrdiff_t mb_uvlinesize
Definition: h264.h:423
void(* h264_weight_func)(uint8_t *block, int stride, int height, int log2_denom, int weight, int offset)
Definition: h264dsp.h:32
ptrdiff_t mb_linesize
may be equal to s->linesize or s->linesize * 2, for mbaff
Definition: h264.h:422
void(* h264_idct8_dc_add)(uint8_t *dst, int16_t *block, int stride)
Definition: h264dsp.h:86
ptrdiff_t linesize
Definition: h264.h:421
static int get_lowest_part_list_y(H264SliceContext *sl, int n, int height, int y_offset, int list)
Definition: h264_mb.c:39
ptrdiff_t uvlinesize
Definition: h264.h:421
static av_always_inline void xchg_mb_border(const H264Context *h, H264SliceContext *sl, uint8_t *src_y, uint8_t *src_cb, uint8_t *src_cr, int linesize, int uvlinesize, int xchg, int chroma444, int simple, int pixel_shift)
Definition: h264_mb.c:508
unsigned int list_count
Definition: h264.h:461
void(* h264_chroma_mc_func)(uint8_t *dst, uint8_t *src, int srcStride, int h, int x, int y)
Definition: h264chroma.h:24
common internal and external API header
if(ret< 0)
Definition: vf_mcdeint.c:280
static void get_lowest_part_y(const H264Context *h, H264SliceContext *sl, int16_t refs[2][48], int n, int height, int y_offset, int list0, int list1, int *nrefs)
Definition: h264_mb.c:52
int implicit_weight[48][48][2]
Definition: h264.h:392
#define IS_INTRA(x, y)
#define IS_INTRA4x4(a)
Definition: mpegutils.h:71
int8_t ref_cache[2][5 *8]
Definition: h264.h:487
#define IS_8X8(a)
Definition: mpegutils.h:85
void(* h264_idct_add16intra)(uint8_t *dst, const int *blockoffset, int16_t *block, int stride, const uint8_t nnzc[15 *8])
Definition: h264dsp.h:98
#define FRAME_MBAFF(h)
Definition: h264.h:73
int luma_log2_weight_denom
Definition: h264.h:385
int chroma_weight[48][2][2][2]
Definition: h264.h:391
H264Picture cur_pic
Definition: h264.h:528
int mb_width
Definition: h264.h:619
static av_always_inline void mc_dir_part(const H264Context *h, H264SliceContext *sl, H264Ref *pic, int n, int square, int height, int delta, int list, uint8_t *dest_y, uint8_t *dest_cb, uint8_t *dest_cr, int src_x_offset, int src_y_offset, const qpel_mc_func *qpix_op, h264_chroma_mc_func chroma_op, int pixel_shift, int chroma_idc)
Definition: h264_mb.c:205
#define AV_RN16A(p)
Definition: intreadwrite.h:522
H264Ref ref_list[2][48]
0..15: frame refs, 16..47: mbaff field refs.
Definition: h264.h:462
H264DSPContext h264dsp
Definition: h264.h:521
#define XCHG(a, b, xchg)
#define av_always_inline
Definition: attributes.h:37
#define stride
uint8_t * bipred_scratchpad
Definition: h264.h:470
void(* pred8x8l[9+3])(uint8_t *src, int topleft, int topright, ptrdiff_t stride)
Definition: h264pred.h:95
static int16_t block[64]
Definition: dct-test.c:110