40 int height,
int y_offset,
int list)
43 int filter_height_up = (raw_my & 3) ? 2 : 0;
44 int filter_height_down = (raw_my & 3) ? 3 : 0;
45 int full_my = (raw_my >> 2) + y_offset;
46 int top = full_my - filter_height_up;
47 int bottom = full_my + filter_height_down +
height;
49 return FFMAX(abs(top), bottom);
53 int height,
int y_offset,
int list0,
54 int list1,
int *nrefs)
70 if (refs[0][ref_n] < 0)
72 refs[0][ref_n] =
FFMAX(refs[0][ref_n], my);
83 if (refs[1][ref_n] < 0)
85 refs[1][ref_n] =
FFMAX(refs[1][ref_n], my);
100 int nrefs[2] = { 0 };
103 memset(refs, -1,
sizeof(refs));
123 for (i = 0; i < 4; i++) {
126 int y_offset = (i & 2) << 2;
130 IS_DIR(sub_mb_type, 0, 0),
131 IS_DIR(sub_mb_type, 0, 1),
135 IS_DIR(sub_mb_type, 0, 0),
136 IS_DIR(sub_mb_type, 0, 1),
139 IS_DIR(sub_mb_type, 0, 0),
140 IS_DIR(sub_mb_type, 0, 1),
144 IS_DIR(sub_mb_type, 0, 0),
145 IS_DIR(sub_mb_type, 0, 1),
148 IS_DIR(sub_mb_type, 0, 0),
149 IS_DIR(sub_mb_type, 0, 1),
154 for (j = 0; j < 4; j++) {
155 int sub_y_offset = y_offset + 2 * (j & 2);
157 IS_DIR(sub_mb_type, 0, 0),
158 IS_DIR(sub_mb_type, 0, 1),
165 for (list = h->
list_count - 1; list >= 0; list--)
166 for (ref = 0; ref < 48 && nrefs[list]; ref++) {
167 int row = refs[list][ref];
172 int pic_height = 16 * h->
mb_height >> ref_field_picture;
179 FFMIN((row >> 1) - !(row & 1),
183 FFMIN((row >> 1), pic_height - 1),
187 FFMIN(row * 2 + ref_field,
192 FFMIN(row, pic_height - 1),
196 FFMIN(row, pic_height - 1),
208 int src_x_offset,
int src_y_offset,
213 const int mx = h->
mv_cache[list][
scan8[n]][0] + src_x_offset * 8;
215 const int luma_xy = (mx & 3) + ((my & 3) << 2);
216 ptrdiff_t offset = ((mx >> 2) << pixel_shift) + (my >> 2) * h->
mb_linesize;
220 int extra_height = 0;
222 const int full_mx = mx >> 2;
223 const int full_my = my >> 2;
224 const int pic_width = 16 * h->
mb_width;
233 if (full_mx < 0 - extra_width ||
234 full_my < 0 - extra_height ||
235 full_mx + 16 > pic_width + extra_width ||
236 full_my + 16 > pic_height + extra_height) {
240 16 + 5, 16 + 5 , full_mx - 2,
241 full_my - 2, pic_width, pic_height);
253 if (chroma_idc == 3 ) {
254 src_cb = pic->
f.
data[1] + offset;
260 full_mx - 2, full_my - 2,
261 pic_width, pic_height);
268 src_cr = pic->
f.
data[2] + offset;
274 full_mx - 2, full_my - 2,
275 pic_width, pic_height);
284 ysh = 3 - (chroma_idc == 2 );
285 if (chroma_idc == 1 &&
MB_FIELD(h)) {
288 emu |= (my >> 3) < 0 || (my >> 3) + 8 >= (pic_height >> 1);
291 src_cb = pic->
f.
data[1] + ((mx >> 3) << pixel_shift) +
299 9, 8 * chroma_idc + 1, (mx >> 3), (my >> ysh),
300 pic_width >> 1, pic_height >> (chroma_idc == 1 ));
304 height >> (chroma_idc == 1 ),
305 mx & 7, (my << (chroma_idc == 2 )) & 7);
310 9, 8 * chroma_idc + 1, (mx >> 3), (my >> ysh),
311 pic_width >> 1, pic_height >> (chroma_idc == 1 ));
314 chroma_op(dest_cr, src_cr, h->
mb_uvlinesize, height >> (chroma_idc == 1 ),
315 mx & 7, (my << (chroma_idc == 2 )) & 7);
322 int x_offset,
int y_offset,
327 int list0,
int list1,
334 if (chroma_idc == 3 ) {
336 dest_cr += (2 * x_offset << pixel_shift) + 2 * y_offset * h->
mb_linesize;
337 }
else if (chroma_idc == 2 ) {
339 dest_cr += (x_offset << pixel_shift) + 2 * y_offset * h->
mb_uvlinesize;
342 dest_cr += (x_offset << pixel_shift) + y_offset * h->
mb_uvlinesize;
344 x_offset += 8 * h->
mb_x;
350 dest_y, dest_cb, dest_cr, x_offset, y_offset,
351 qpix_op, chroma_op, pixel_shift, chroma_idc);
354 chroma_op = chroma_avg;
360 dest_y, dest_cb, dest_cr, x_offset, y_offset,
361 qpix_op, chroma_op, pixel_shift, chroma_idc);
369 int x_offset,
int y_offset,
376 int list0,
int list1,
382 if (chroma_idc == 3 ) {
384 chroma_weight_avg = luma_weight_avg;
385 chroma_weight_op = luma_weight_op;
387 dest_cr += (2 * x_offset << pixel_shift) + 2 * y_offset * h->
mb_linesize;
388 }
else if (chroma_idc == 2 ) {
391 dest_cr += (x_offset << pixel_shift) + 2 * y_offset * h->
mb_uvlinesize;
393 chroma_height = height >> 1;
395 dest_cr += (x_offset << pixel_shift) + y_offset * h->
mb_uvlinesize;
397 x_offset += 8 * h->
mb_x;
400 if (list0 && list1) {
410 dest_y, dest_cb, dest_cr,
411 x_offset, y_offset, qpix_put, chroma_put,
412 pixel_shift, chroma_idc);
414 tmp_y, tmp_cb, tmp_cr,
415 x_offset, y_offset, qpix_put, chroma_put,
416 pixel_shift, chroma_idc);
420 int weight1 = 64 - weight0;
422 height, 5, weight0, weight1, 0);
424 chroma_height, 5, weight0, weight1, 0);
426 chroma_height, 5, weight0, weight1, 0);
428 luma_weight_avg(dest_y, tmp_y, h->
mb_linesize, height,
434 chroma_weight_avg(dest_cb, tmp_cb, h->
mb_uvlinesize, chroma_height,
440 chroma_weight_avg(dest_cr, tmp_cr, h->
mb_uvlinesize, chroma_height,
448 int list = list1 ? 1 : 0;
451 mc_dir_part(h, ref, n, square, height, delta, list,
452 dest_y, dest_cb, dest_cr, x_offset, y_offset,
453 qpix_put, chroma_put, pixel_shift, chroma_idc);
486 if (chroma_idc == 3 ) {
490 off = ((mx >> 1) << pixel_shift) +
501 int xchg,
int chroma444,
523 deblock_topleft = (h->
mb_x > 0);
534 #define XCHG(a, b, xchg) \
537 AV_SWAP64(b + 0, a + 0); \
538 AV_SWAP64(b + 8, a + 8); \
548 if (deblock_topleft) {
549 XCHG(top_border_m1 + (8 << pixel_shift),
550 src_y - (7 << pixel_shift), 1);
552 XCHG(top_border + (0 << pixel_shift), src_y + (1 << pixel_shift), xchg);
553 XCHG(top_border + (8 << pixel_shift), src_y + (9 << pixel_shift), 1);
556 src_y + (17 << pixel_shift), 1);
562 if (deblock_topleft) {
563 XCHG(top_border_m1 + (24 << pixel_shift), src_cb - (7 << pixel_shift), 1);
564 XCHG(top_border_m1 + (40 << pixel_shift), src_cr - (7 << pixel_shift), 1);
566 XCHG(top_border + (16 << pixel_shift), src_cb + (1 << pixel_shift), xchg);
567 XCHG(top_border + (24 << pixel_shift), src_cb + (9 << pixel_shift), 1);
568 XCHG(top_border + (32 << pixel_shift), src_cr + (1 << pixel_shift), xchg);
569 XCHG(top_border + (40 << pixel_shift), src_cr + (9 << pixel_shift), 1);
571 XCHG(h->
top_borders[top_idx][h->
mb_x + 1] + (16 << pixel_shift), src_cb + (17 << pixel_shift), 1);
572 XCHG(h->
top_borders[top_idx][h->
mb_x + 1] + (32 << pixel_shift), src_cr + (17 << pixel_shift), 1);
577 if (deblock_topleft) {
578 XCHG(top_border_m1 + (16 << pixel_shift), src_cb - (7 << pixel_shift), 1);
579 XCHG(top_border_m1 + (24 << pixel_shift), src_cr - (7 << pixel_shift), 1);
581 XCHG(top_border + (16 << pixel_shift), src_cb + 1 + pixel_shift, 1);
582 XCHG(top_border + (24 << pixel_shift), src_cr + 1 + pixel_shift, 1);
591 if (high_bit_depth) {
598 int index,
int value)
600 if (high_bit_depth) {
607 int mb_type,
int is_h264,
609 int transform_bypass,
619 block_offset += 16 * p;
622 if (transform_bypass) {
629 for (i = 0; i < 16; i += 4) {
630 uint8_t *
const ptr = dest_y + block_offset[i];
639 if (nnz == 1 &&
dctcoef_get(h->
mb, pixel_shift, i * 16 + p * 256))
640 idct_dc_add(ptr, h->
mb + (i * 16 + p * 256 << pixel_shift),
linesize);
642 idct_add(ptr, h->
mb + (i * 16 + p * 256 << pixel_shift), linesize);
647 if (transform_bypass) {
654 for (i = 0; i < 16; i++) {
655 uint8_t *
const ptr = dest_y + block_offset[i];
666 assert(h->
mb_y || linesize <= block_offset[i]);
667 if (!topright_avail) {
669 tr_high = ((uint16_t *)ptr)[3 - linesize / 2] * 0x0001000100010001ULL;
670 topright = (
uint8_t *)&tr_high;
672 tr = ptr[3 -
linesize] * 0x01010101u;
684 if (nnz == 1 &&
dctcoef_get(h->
mb, pixel_shift, i * 16 + p * 256))
685 idct_dc_add(ptr, h->
mb + (i * 16 + p * 256 << pixel_shift),
linesize);
687 idct_add(ptr, h->
mb + (i * 16 + p * 256 << pixel_shift), linesize);
698 if (!transform_bypass)
703 static const uint8_t dc_mapping[16] = {
704 0 * 16, 1 * 16, 4 * 16, 5 * 16,
705 2 * 16, 3 * 16, 6 * 16, 7 * 16,
706 8 * 16, 9 * 16, 12 * 16, 13 * 16,
707 10 * 16, 11 * 16, 14 * 16, 15 * 16
709 for (i = 0; i < 16; i++)
711 pixel_shift, dc_mapping[i],
723 int is_h264,
int simple,
724 int transform_bypass,
732 block_offset += 16 * p;
736 if (transform_bypass) {
744 for (i = 0; i < 16; i++)
748 h->
mb + (i * 16 + p * 256 << pixel_shift),
753 h->
mb + (p * 256 << pixel_shift),
757 }
else if (h->
cbp & 15) {
758 if (transform_bypass) {
759 const int di =
IS_8x8DCT(mb_type) ? 4 : 1;
762 for (i = 0; i < 16; i += di)
764 idct_add(dest_y + block_offset[i],
765 h->
mb + (i * 16 + p * 256 << pixel_shift),
770 h->
mb + (p * 256 << pixel_shift),
775 h->
mb + (p * 256 << pixel_shift),
781 for (i = 0; i < 16; i++)
784 uint8_t *
const ptr = dest_y + block_offset[i];
813 hl_decode_mb_444_complex(h);
815 hl_decode_mb_444_simple_8(h);
816 }
else if (is_complex) {
817 hl_decode_mb_complex(h);
819 hl_decode_mb_simple_16(h);
821 hl_decode_mb_simple_8(h);
void(* h264_idct_add)(uint8_t *dst, int16_t *block, int stride)
uint8_t * edge_emu_buffer
void(* prefetch)(uint8_t *buf, ptrdiff_t stride, int h)
Prefetch memory into cache (if supported by hardware).
unsigned int topleft_samples_available
void(* pred8x8l_add[2])(uint8_t *pix, int16_t *block, ptrdiff_t stride)
static av_always_inline void xchg_mb_border(H264Context *h, 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)
void ff_h264_hl_decode_mb(H264Context *h)
void(* qpel_mc_func)(uint8_t *dst, const uint8_t *src, ptrdiff_t stride)
int16_t mv_cache[2][5 *8][2]
Motion vector cache.
void ff_thread_await_progress(ThreadFrame *f, int n, int field)
Wait for earlier decoding threads to finish reference pictures.
void(* h264_add_pixels4_clear)(uint8_t *dst, int16_t *block, int stride)
void(* pred16x16_add[3])(uint8_t *pix, const int *block_offset, int16_t *block, ptrdiff_t stride)
void(* h264_idct_add16)(uint8_t *dst, const int *blockoffset, int16_t *block, int stride, const uint8_t nnzc[15 *8])
uint32_t(*[6] dequant4_coeff)[16]
int luma_weight[48][2][2]
int field_picture
whether or not picture was encoded in separate fields
Multithreading support functions.
#define LUMA_DC_BLOCK_INDEX
#define IS_DIR(a, part, list)
void(* h264_add_pixels8_clear)(uint8_t *dst, int16_t *block, int stride)
void(* pred4x4[9+3+3])(uint8_t *src, const uint8_t *topright, ptrdiff_t stride)
int luma_log2_weight_denom
int chroma_weight[48][2][2][2]
H.264 / AVC / MPEG4 part10 codec.
int16_t mb_luma_dc[3][16 *2]
void(* h264_biweight_func)(uint8_t *dst, uint8_t *src, int stride, int height, int log2_denom, int weightd, int weights, int offset)
static av_always_inline void hl_decode_mb_idct_luma(H264Context *h, int mb_type, int is_h264, int simple, int transform_bypass, int pixel_shift, int *block_offset, int linesize, uint8_t *dest_y, int p)
static av_always_inline void mc_dir_part(H264Context *h, H264Picture *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, qpel_mc_func *qpix_op, h264_chroma_mc_func chroma_op, int pixel_shift, int chroma_idc)
void(* h264_idct8_add)(uint8_t *dst, int16_t *block, int stride)
void(* h264_luma_dc_dequant_idct)(int16_t *output, int16_t *input, int qmul)
static void await_references(H264Context *h)
Wait until all reference frames are available for MC operations.
static const uint8_t scan8[16 *3+3]
void ff_svq3_add_idct_c(uint8_t *dst, int16_t *block, int stride, int qp, int dc)
uint16_t * slice_table
slice_table_base + 2*mb_stride + 1
void ff_svq3_luma_dc_dequant_idct_c(int16_t *output, int16_t *input, int qp)
void(* h264_idct_dc_add)(uint8_t *dst, int16_t *block, int stride)
H264Picture ref_list[2][48]
0..15: frame refs, 16..47: mbaff field refs.
int8_t intra4x4_pred_mode_cache[5 *8]
uint8_t * bipred_scratchpad
void(* pred4x4_add[2])(uint8_t *pix, int16_t *block, ptrdiff_t stride)
unsigned int topright_samples_available
if(ac->has_optimized_func)
static av_always_inline void dctcoef_set(int16_t *mb, int high_bit_depth, int index, int value)
int chroma_log2_weight_denom
Libavcodec external API header.
int implicit_weight[48][48][2]
static void(WINAPI *cond_broadcast)(pthread_cond_t *cond)
uint8_t * data
The data buffer.
int16_t mb[16 *48 *2]
as a dct coeffecient is int32_t in high depth, we need to reserve twice the space.
static av_always_inline int dctcoef_get(int16_t *mb, int high_bit_depth, int index)
void(* pred16x16[4+3+2])(uint8_t *src, ptrdiff_t stride)
void(* h264_idct8_add4)(uint8_t *dst, const int *blockoffset, int16_t *block, int stride, const uint8_t nnzc[15 *8])
static av_always_inline void hl_decode_mb_predict_luma(H264Context *h, int mb_type, int is_h264, int simple, int transform_bypass, int pixel_shift, int *block_offset, int linesize, uint8_t *dest_y, int p)
int pixel_shift
0 for 8-bit H264, 1 for high-bit-depth H264
static av_always_inline void prefetch_motion(H264Context *h, int list, int pixel_shift, int chroma_idc)
void(* h264_weight_func)(uint8_t *block, int stride, int height, int log2_denom, int weight, int offset)
static void get_lowest_part_y(H264Context *h, int refs[2][48], int n, int height, int y_offset, int list0, int list1, int *nrefs)
static av_always_inline void mc_part_std(H264Context *h, 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, qpel_mc_func *qpix_put, h264_chroma_mc_func chroma_put, qpel_mc_func *qpix_avg, h264_chroma_mc_func chroma_avg, int list0, int list1, int pixel_shift, int chroma_idc)
void(* h264_idct8_dc_add)(uint8_t *dst, int16_t *block, int stride)
int block_offset[2 *(16 *3)]
block_offset[ 0..23] for frame macroblocks block_offset[24..47] for field macroblocks ...
uint8_t * data[AV_NUM_DATA_POINTERS]
pointer to the picture/channel planes.
void(* h264_chroma_mc_func)(uint8_t *dst, uint8_t *src, int srcStride, int h, int x, int y)
common internal and external API header
#define CODEC_FLAG_GRAY
Only decode/encode grayscale.
ptrdiff_t mb_linesize
may be equal to s->linesize or s->linesize * 2, for mbaff
static av_always_inline void mc_part_weighted(H264Context *h, 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, 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)
void(* h264_idct_add16intra)(uint8_t *dst, const int *blockoffset, int16_t *block, int stride, const uint8_t nnzc[15 *8])
uint8_t non_zero_count_cache[15 *8]
non zero coeff count cache.
uint8_t(*[2] top_borders)[(16 *3)*2]
static int get_lowest_part_list_y(H264Context *h, H264Picture *pic, int n, int height, int y_offset, int list)
int deblocking_filter
disable_deblocking_filter_idc with 1 <-> 0
void(* emulated_edge_mc)(uint8_t *buf, const uint8_t *src, ptrdiff_t buf_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...
void(* pred8x8l[9+3])(uint8_t *src, int topleft, int topright, ptrdiff_t stride)
int8_t ref_cache[2][5 *8]