Lines Matching refs:sl
39 static inline int get_lowest_part_list_y(H264SliceContext *sl,
42 int raw_my = sl->mv_cache[list][scan8[n]][1];
52 static inline void get_lowest_part_y(const H264Context *h, H264SliceContext *sl,
59 y_offset += 16 * (sl->mb_y >> MB_FIELD(sl));
62 int ref_n = sl->ref_cache[0][scan8[n]];
63 H264Ref *ref = &sl->ref_list[0][ref_n];
70 my = get_lowest_part_list_y(sl, n, height, y_offset, 0);
78 int ref_n = sl->ref_cache[1][scan8[n]];
79 H264Ref *ref = &sl->ref_list[1][ref_n];
83 my = get_lowest_part_list_y(sl, n, height, y_offset, 1);
96 static void await_references(const H264Context *h, H264SliceContext *sl)
98 const int mb_xy = sl->mb_xy;
107 get_lowest_part_y(h, sl, refs, 0, 16, 0,
110 get_lowest_part_y(h, sl, refs, 0, 8, 0,
112 get_lowest_part_y(h, sl, refs, 8, 8, 8,
115 get_lowest_part_y(h, sl, refs, 0, 16, 0,
117 get_lowest_part_y(h, sl, refs, 4, 16, 0,
125 const int sub_mb_type = sl->sub_mb_type[i];
130 get_lowest_part_y(h, sl, refs, n, 8, y_offset,
135 get_lowest_part_y(h, sl, refs, n, 4, y_offset,
139 get_lowest_part_y(h, sl, refs, n + 2, 4, y_offset + 4,
144 get_lowest_part_y(h, sl, refs, n, 8, y_offset,
148 get_lowest_part_y(h, sl, refs, n + 1, 8, y_offset,
157 get_lowest_part_y(h, sl, refs, n + j, 4, sub_y_offset,
166 for (list = sl->list_count - 1; list >= 0; list--)
170 H264Ref *ref_pic = &sl->ref_list[list][ref];
175 row <<= MB_MBAFF(sl);
205 static av_always_inline void mc_dir_part(const H264Context *h, H264SliceContext *sl,
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;
219 ptrdiff_t offset = (mx >> 2) * (1 << pixel_shift) + (my >> 2) * sl->mb_linesize;
228 const int pic_height = 16 * h->mb_height >> MB_FIELD(sl);
240 h->vdsp.emulated_edge_mc(sl->edge_emu_buffer,
241 src_y - (2 << pixel_shift) - 2 * sl->mb_linesize,
242 sl->mb_linesize, sl->mb_linesize,
245 src_y = sl->edge_emu_buffer + (2 << pixel_shift) + 2 * sl->mb_linesize;
249 qpix_op[luma_xy](dest_y, src_y, sl->mb_linesize); // FIXME try variable height perhaps?
251 qpix_op[luma_xy](dest_y + delta, src_y + delta, sl->mb_linesize);
259 h->vdsp.emulated_edge_mc(sl->edge_emu_buffer,
260 src_cb - (2 << pixel_shift) - 2 * sl->mb_linesize,
261 sl->mb_linesize, sl->mb_linesize,
265 src_cb = sl->edge_emu_buffer + (2 << pixel_shift) + 2 * sl->mb_linesize;
267 qpix_op[luma_xy](dest_cb, src_cb, sl->mb_linesize); // FIXME try variable height perhaps?
269 qpix_op[luma_xy](dest_cb + delta, src_cb + delta, sl->mb_linesize);
273 h->vdsp.emulated_edge_mc(sl->edge_emu_buffer,
274 src_cr - (2 << pixel_shift) - 2 * sl->mb_linesize,
275 sl->mb_linesize, sl->mb_linesize,
279 src_cr = sl->edge_emu_buffer + (2 << pixel_shift) + 2 * sl->mb_linesize;
281 qpix_op[luma_xy](dest_cr, src_cr, sl->mb_linesize); // FIXME try variable height perhaps?
283 qpix_op[luma_xy](dest_cr + delta, src_cr + delta, sl->mb_linesize);
288 if (chroma_idc == 1 /* yuv420 */ && MB_FIELD(sl)) {
290 my += 2 * ((sl->mb_y & 1) - (pic->reference - 1));
295 (my >> ysh) * sl->mb_uvlinesize;
297 (my >> ysh) * sl->mb_uvlinesize;
300 h->vdsp.emulated_edge_mc(sl->edge_emu_buffer, src_cb,
301 sl->mb_uvlinesize, sl->mb_uvlinesize,
304 src_cb = sl->edge_emu_buffer;
306 chroma_op(dest_cb, src_cb, sl->mb_uvlinesize,
311 h->vdsp.emulated_edge_mc(sl->edge_emu_buffer, src_cr,
312 sl->mb_uvlinesize, sl->mb_uvlinesize,
315 src_cr = sl->edge_emu_buffer;
317 chroma_op(dest_cr, src_cr, sl->mb_uvlinesize, height >> (chroma_idc == 1 /* yuv420 */),
321 static av_always_inline void mc_part_std(const H264Context *h, H264SliceContext *sl,
337 dest_y += (2 * x_offset << pixel_shift) + 2 * y_offset * sl->mb_linesize;
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;
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;
345 dest_cb += (x_offset << pixel_shift) + y_offset * sl->mb_uvlinesize;
346 dest_cr += (x_offset << pixel_shift) + y_offset * sl->mb_uvlinesize;
348 x_offset += 8 * sl->mb_x;
349 y_offset += 8 * (sl->mb_y >> MB_FIELD(sl));
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,
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,
369 static av_always_inline void mc_part_weighted(const H264Context *h, H264SliceContext *sl,
386 dest_y += (2 * x_offset << pixel_shift) + 2 * y_offset * sl->mb_linesize;
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;
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;
399 dest_cb += (x_offset << pixel_shift) + y_offset * sl->mb_uvlinesize;
400 dest_cr += (x_offset << pixel_shift) + y_offset * sl->mb_uvlinesize;
402 x_offset += 8 * sl->mb_x;
403 y_offset += 8 * (sl->mb_y >> MB_FIELD(sl));
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]];
414 mc_dir_part(h, sl, &sl->ref_list[0][refn0], n, square, height, delta, 0,
418 mc_dir_part(h, sl, &sl->ref_list[1][refn1], n, square, height, delta, 1,
423 if (sl->pwt.use_weight == 2) {
424 int weight0 = sl->pwt.implicit_weight[refn0][refn1][sl->mb_y & 1];
426 luma_weight_avg(dest_y, tmp_y, sl->mb_linesize,
429 chroma_weight_avg(dest_cb, tmp_cb, sl->mb_uvlinesize,
431 chroma_weight_avg(dest_cr, tmp_cr, sl->mb_uvlinesize,
435 luma_weight_avg(dest_y, tmp_y, sl->mb_linesize, height,
436 sl->pwt.luma_log2_weight_denom,
437 sl->pwt.luma_weight[refn0][0][0],
438 sl->pwt.luma_weight[refn1][1][0],
439 sl->pwt.luma_weight[refn0][0][1] +
440 sl->pwt.luma_weight[refn1][1][1]);
442 chroma_weight_avg(dest_cb, tmp_cb, sl->mb_uvlinesize, chroma_height,
443 sl->pwt.chroma_log2_weight_denom,
444 sl->pwt.chroma_weight[refn0][0][0][0],
445 sl->pwt.chroma_weight[refn1][1][0][0],
446 sl->pwt.chroma_weight[refn0][0][0][1] +
447 sl->pwt.chroma_weight[refn1][1][0][1]);
448 chroma_weight_avg(dest_cr, tmp_cr, sl->mb_uvlinesize, chroma_height,
449 sl->pwt.chroma_log2_weight_denom,
450 sl->pwt.chroma_weight[refn0][0][1][0],
451 sl->pwt.chroma_weight[refn1][1][1][0],
452 sl->pwt.chroma_weight[refn0][0][1][1] +
453 sl->pwt.chroma_weight[refn1][1][1][1]);
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,
464 luma_weight_op(dest_y, sl->mb_linesize, height,
465 sl->pwt.luma_log2_weight_denom,
466 sl->pwt.luma_weight[refn][list][0],
467 sl->pwt.luma_weight[refn][list][1]);
469 if (sl->pwt.use_weight_chroma) {
470 chroma_weight_op(dest_cb, sl->mb_uvlinesize, chroma_height,
471 sl->pwt.chroma_log2_weight_denom,
472 sl->pwt.chroma_weight[refn][list][0][0],
473 sl->pwt.chroma_weight[refn][list][0][1]);
474 chroma_weight_op(dest_cr, sl->mb_uvlinesize, chroma_height,
475 sl->pwt.chroma_log2_weight_denom,
476 sl->pwt.chroma_weight[refn][list][1][0],
477 sl->pwt.chroma_weight[refn][list][1][1]);
483 static av_always_inline void prefetch_motion(const H264Context *h, H264SliceContext *sl,
489 const int refn = sl->ref_cache[list][scan8[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;
495 (my + (sl->mb_x & 3) * 4) * sl->mb_linesize +
497 h->vdsp.prefetch(src[0] + off, sl->linesize, 4);
499 h->vdsp.prefetch(src[1] + off, sl->linesize, 4);
500 h->vdsp.prefetch(src[2] + off, sl->linesize, 4);
502 off= ((mx>>1)+64) * (1<<pixel_shift) + ((my>>1) + (sl->mb_x&7))*sl->uvlinesize;
508 static av_always_inline void xchg_mb_border(const H264Context *h, H264SliceContext *sl,
522 if (sl->mb_y & 1) {
523 if (!MB_MBAFF(sl))
526 top_idx = MB_MBAFF(sl) ? 0 : 1;
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;
534 deblock_topleft = (sl->mb_x > 0);
535 deblock_top = (sl->mb_y > !!MB_FIELD(sl));
542 top_border_m1 = sl->top_borders[top_idx][sl->mb_x - 1];
543 top_border = sl->top_borders[top_idx][sl->mb_x];
565 if (sl->mb_x + 1 < h->mb_width) {
566 XCHG(sl->top_borders[top_idx][sl->mb_x + 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);
614 H264SliceContext *sl,
625 int qscale = p == 0 ? sl->qscale : sl->chroma_qp[p - 1];
638 const int dir = sl->intra4x4_pred_mode_cache[scan8[i]];
641 h->hpc.pred8x8l_add[dir](ptr, sl->mb + (i * 16 + p * 256 << pixel_shift), linesize);
643 h->hpc.pred8x8l_filter_add[dir](ptr, sl->mb + (i * 16 + p * 256 << pixel_shift),
644 (sl-> topleft_samples_available << i) & 0x8000,
645 (sl->topright_samples_available << i) & 0x4000, linesize);
647 const int nnz = sl->non_zero_count_cache[scan8[i + p * 16]];
648 h->hpc.pred8x8l[dir](ptr, (sl->topleft_samples_available << i) & 0x8000,
649 (sl->topright_samples_available << i) & 0x4000, linesize);
651 if (nnz == 1 && dctcoef_get(sl->mb, pixel_shift, i * 16 + p * 256))
652 idct_dc_add(ptr, sl->mb + (i * 16 + p * 256 << pixel_shift), linesize);
654 idct_add(ptr, sl->mb + (i * 16 + p * 256 << pixel_shift), linesize);
668 const int dir = sl->intra4x4_pred_mode_cache[scan8[i]];
671 h->hpc.pred4x4_add[dir](ptr, sl->mb + (i * 16 + p * 256 << pixel_shift), linesize);
677 const int topright_avail = (sl->topright_samples_available << i) & 0x8000;
678 av_assert2(sl->mb_y || linesize <= block_offset[i]);
693 nnz = sl->non_zero_count_cache[scan8[i + p * 16]];
695 if (nnz == 1 && dctcoef_get(sl->mb, pixel_shift, i * 16 + p * 256))
696 idct_dc_add(ptr, sl->mb + (i * 16 + p * 256 << pixel_shift), linesize);
698 idct_add(ptr, sl->mb + (i * 16 + p * 256 << pixel_shift), linesize);
704 h->hpc.pred16x16[sl->intra16x16_pred_mode](dest_y, linesize);
705 if (sl->non_zero_count_cache[scan8[LUMA_DC_BLOCK_INDEX + p]]) {
707 h->h264dsp.h264_luma_dc_dequant_idct(sl->mb + (p * 256 << pixel_shift),
708 sl->mb_luma_dc[p],
718 dctcoef_set(sl->mb + (p * 256 << pixel_shift),
720 dctcoef_get(sl->mb_luma_dc[p],
727 static av_always_inline void hl_decode_mb_idct_luma(const H264Context *h, H264SliceContext *sl,
742 (sl->intra16x16_pred_mode == VERT_PRED8x8 ||
743 sl->intra16x16_pred_mode == HOR_PRED8x8)) {
744 h->hpc.pred16x16_add[sl->intra16x16_pred_mode](dest_y, block_offset,
745 sl->mb + (p * 256 << pixel_shift),
749 if (sl->non_zero_count_cache[scan8[i + p * 16]] ||
750 dctcoef_get(sl->mb, pixel_shift, i * 16 + p * 256))
752 sl->mb + (i * 16 + p * 256 << pixel_shift),
757 sl->mb + (p * 256 << pixel_shift),
759 sl->non_zero_count_cache + p * 5 * 8);
761 } else if (sl->cbp & 15) {
767 if (sl->non_zero_count_cache[scan8[i + p * 16]])
769 sl->mb + (i * 16 + p * 256 << pixel_shift),
774 sl->mb + (p * 256 << pixel_shift),
776 sl->non_zero_count_cache + p * 5 * 8);
779 sl->mb + (p * 256 << pixel_shift),
781 sl->non_zero_count_cache + p * 5 * 8);
799 void ff_h264_hl_decode_mb(const H264Context *h, H264SliceContext *sl)
801 const int mb_xy = sl->mb_xy;
803 int is_complex = CONFIG_SMALL || sl->is_complex ||
804 IS_INTRA_PCM(mb_type) || sl->qscale == 0;
808 hl_decode_mb_444_complex(h, sl);
810 hl_decode_mb_444_simple_8(h, sl);
812 hl_decode_mb_complex(h, sl);
814 hl_decode_mb_simple_16(h, sl);
816 hl_decode_mb_simple_8(h, sl);