38 0, 0, 0, 0, 0, 0, 1, 1, 1, 1, 1, 2, 2, 2, 3, 3,
39 4, 4, 5, 5, 6, 7, 8, 9, 10, 11, 12, 13, 15, 16, 18, 20,
40 22, 24, 26, 28, 30, 33, 33, 35, 35, 36, 37, 37, 39, 39, 42, 44,
41 46, 48, 50, 52, 53, 54, 55, 56, 57, 58, 59, 60, 61, 62, 63, 64
45 0, 0, 0, 0, 0, 0, 1, 1, 1, 1, 1, 1, 1, 2, 2, 2,
46 2, 2, 3, 3, 3, 3, 4, 4, 4, 4, 5, 5, 5, 5, 6, 6,
47 6, 7, 7, 7, 8, 8, 8, 9, 9, 10, 10, 11, 11, 12, 13, 14,
48 15, 16, 17, 18, 19, 20, 21, 22, 23, 23, 24, 24, 25, 25, 26, 27
52 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
53 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 2, 2,
54 2, 2, 2, 2, 2, 2, 3, 3, 3, 3, 3, 3, 3, 4, 4, 4,
55 5, 5, 5, 6, 6, 6, 7, 7, 7, 7, 8, 8, 8, 9, 9, 9
67 0, 8, 16, 1, 24, 32, 9, 17, 40, 48, 25, 2, 10, 56, 33, 18,
68 3, 41, 49, 26, 11, 19, 4, 57, 34, 12, 42, 27, 20, 50, 35, 28,
69 5, 13, 58, 43, 36, 21, 6, 29, 51, 44, 14, 22, 37, 59, 52, 30,
70 45, 60, 38, 53, 46, 61, 54, 7, 62, 15, 23, 31, 39, 47, 55, 63,
88 if((
abs(mvP->
x - mvQ->
x) >= 4) ||
89 (
abs(mvP->
y - mvQ->
y) >= 4) ||
95 if((
abs(mvP->
x - mvQ->
x) >= 4) ||
96 (
abs(mvP->
y - mvQ->
y) >= 4) ||
104 alpha = alpha_tab[av_clip_uintp2(qp_avg + h->alpha_offset, 6)]; \
105 beta = beta_tab[av_clip_uintp2(qp_avg + h->beta_offset, 6)]; \
106 tc = tc_tab[av_clip_uintp2(qp_avg + h->alpha_offset, 6)];
122 int qp_avg,
alpha, beta, tc;
126 h->topleft_border_y =
h->top_border_y[
h->mbx * 16 + 15];
127 h->topleft_border_u =
h->top_border_u[
h->mbx * 10 + 8];
128 h->topleft_border_v =
h->top_border_v[
h->mbx * 10 + 8];
129 memcpy(&
h->top_border_y[
h->mbx * 16],
h->cy + 15 *
h->l_stride, 16);
130 memcpy(&
h->top_border_u[
h->mbx * 10 + 1],
h->cu + 7 *
h->c_stride, 8);
131 memcpy(&
h->top_border_v[
h->mbx * 10 + 1],
h->cv + 7 *
h->c_stride, 8);
132 for (
i = 0;
i < 8;
i++) {
133 h->left_border_y[
i * 2 + 1] = *(
h->cy + 15 + (
i * 2 + 0) *
h->l_stride);
134 h->left_border_y[
i * 2 + 2] = *(
h->cy + 15 + (
i * 2 + 1) *
h->l_stride);
135 h->left_border_u[
i + 1] = *(
h->cu + 7 +
i *
h->c_stride);
136 h->left_border_v[
i + 1] = *(
h->cv + 7 +
i *
h->c_stride);
138 if (!
h->loop_filter_disable) {
140 if (mb_type ==
I_8X8)
159 qp_avg = (
h->qp +
h->left_qp + 1) >> 1;
161 h->cdsp.cavs_filter_lv(
h->cy,
h->l_stride,
alpha, beta, tc, bs[0], bs[1]);
164 h->cdsp.cavs_filter_cv(
h->cu,
h->c_stride,
alpha, beta, tc, bs[0], bs[1]);
165 h->cdsp.cavs_filter_cv(
h->cv,
h->c_stride,
alpha, beta, tc, bs[0], bs[1]);
169 h->cdsp.cavs_filter_lv(
h->cy + 8,
h->l_stride,
alpha, beta, tc, bs[2], bs[3]);
170 h->cdsp.cavs_filter_lh(
h->cy + 8 *
h->l_stride,
h->l_stride,
alpha, beta, tc, bs[6], bs[7]);
173 qp_avg = (
h->qp +
h->top_qp[
h->mbx] + 1) >> 1;
175 h->cdsp.cavs_filter_lh(
h->cy,
h->l_stride,
alpha, beta, tc, bs[4], bs[5]);
178 h->cdsp.cavs_filter_ch(
h->cu,
h->c_stride,
alpha, beta, tc, bs[4], bs[5]);
179 h->cdsp.cavs_filter_ch(
h->cv,
h->c_stride,
alpha, beta, tc, bs[4], bs[5]);
184 h->top_qp[
h->mbx] =
h->qp;
202 *
left =
h->left_border_y;
203 h->left_border_y[0] =
h->left_border_y[1];
204 memset(&
h->left_border_y[17],
h->left_border_y[16], 9);
205 memcpy(&top[1], &
h->top_border_y[
h->mbx * 16], 16);
209 h->left_border_y[0] = top[0] =
h->topleft_border_y;
212 *
left =
h->intern_border_y;
213 for (
i = 0;
i < 8;
i++)
214 h->intern_border_y[
i + 1] = *(
h->cy + 7 +
i *
h->l_stride);
215 memset(&
h->intern_border_y[9],
h->intern_border_y[8], 9);
216 h->intern_border_y[0] =
h->intern_border_y[1];
217 memcpy(&top[1], &
h->top_border_y[
h->mbx * 16 + 8], 8);
219 memcpy(&top[9], &
h->top_border_y[(
h->mbx + 1) * 16], 8);
221 memset(&top[9], top[8], 9);
225 h->intern_border_y[0] = top[0] =
h->top_border_y[
h->mbx * 16 + 7];
228 *
left = &
h->left_border_y[8];
229 memcpy(&top[1],
h->cy + 7 *
h->l_stride, 16);
233 top[0] =
h->left_border_y[8];
236 *
left = &
h->intern_border_y[8];
237 for (
i = 0;
i < 8;
i++)
238 h->intern_border_y[
i + 9] = *(
h->cy + 7 + (
i + 8) *
h->l_stride);
239 memset(&
h->intern_border_y[17],
h->intern_border_y[16], 9);
240 memcpy(&top[0],
h->cy + 7 + 7 *
h->l_stride, 9);
241 memset(&top[9], top[8], 9);
249 h->left_border_u[9] =
h->left_border_u[8];
250 h->left_border_v[9] =
h->left_border_v[8];
252 h->top_border_u[
h->mbx*10 + 9] =
h->top_border_u[
h->mbx*10 + 11];
253 h->top_border_v[
h->mbx*10 + 9] =
h->top_border_v[
h->mbx*10 + 11];
255 h->top_border_u[
h->mbx * 10 + 9] =
h->top_border_u[
h->mbx * 10 + 8];
256 h->top_border_v[
h->mbx * 10 + 9] =
h->top_border_v[
h->mbx * 10 + 8];
259 h->top_border_u[
h->mbx * 10] =
h->left_border_u[0] =
h->topleft_border_u;
260 h->top_border_v[
h->mbx * 10] =
h->left_border_v[0] =
h->topleft_border_v;
262 h->left_border_u[0] =
h->left_border_u[1];
263 h->left_border_v[0] =
h->left_border_v[1];
264 h->top_border_u[
h->mbx * 10] =
h->top_border_u[
h->mbx * 10 + 1];
265 h->top_border_v[
h->mbx * 10] =
h->top_border_v[
h->mbx * 10 + 1];
273 for (y = 0; y < 8; y++)
274 *((uint64_t *)(d + y *
stride)) =
a;
281 for (y = 0; y < 8; y++) {
282 a =
left[y + 1] * 0x0101010101010101ULL;
283 *((uint64_t *)(d + y *
stride)) =
a;
290 uint64_t
a = 0x8080808080808080ULL;
291 for (y = 0; y < 8; y++)
292 *((uint64_t *)(d + y *
stride)) =
a;
302 for (x = 0; x < 4; x++) {
303 ih += (x + 1) * (top[5 + x] - top[3 - x]);
304 iv += (x + 1) * (
left[5 + x] -
left[3 - x]);
306 ia = (top[8] +
left[8]) << 4;
307 ih = (17 * ih + 16) >> 5;
308 iv = (17 * iv + 16) >> 5;
309 for (y = 0; y < 8; y++)
310 for (x = 0; x < 8; x++)
311 d[y *
stride + x] =
cm[(ia + (x - 3) * ih + (y - 3) * iv + 16) >> 5];
314#define LOWPASS(ARRAY, INDEX) \
315 ((ARRAY[(INDEX) - 1] + 2 * ARRAY[(INDEX)] + ARRAY[(INDEX) + 1] + 2) >> 2)
320 for (y = 0; y < 8; y++)
321 for (x = 0; x < 8; x++)
328 for (y = 0; y < 8; y++)
329 for (x = 0; x < 8; x++)
336 for (y = 0; y < 8; y++)
337 for (x = 0; x < 8; x++)
339 d[y *
stride + x] = (
left[1] + 2 * top[0] + top[1] + 2) >> 2;
349 for (y = 0; y < 8; y++)
350 for (x = 0; x < 8; x++)
357 for (y = 0; y < 8; y++)
358 for (x = 0; x < 8; x++)
376 h->pred_mode_Y[3] =
h->pred_mode_Y[5];
377 h->pred_mode_Y[6] =
h->pred_mode_Y[8];
378 h->top_pred_Y[
h->mbx * 2 + 0] =
h->pred_mode_Y[7];
379 h->top_pred_Y[
h->mbx * 2 + 1] =
h->pred_mode_Y[8];
402 int list, uint8_t *dest_y,
403 uint8_t *dest_cb, uint8_t *dest_cr,
404 int src_x_offset,
int src_y_offset,
411 const int mx =
mv->x + src_x_offset * 8;
412 const int my =
mv->y + src_y_offset * 8;
413 const int luma_xy = (
mx & 3) + ((
my & 3) << 2);
415 (
mx >> 2) + (
my >> 2) *
h->l_stride;
417 (
mx >> 3) + (
my >> 3) *
h->c_stride;
419 (
mx >> 3) + (
my >> 3) *
h->c_stride;
421 int extra_height = extra_width;
422 const int full_mx =
mx >> 2;
423 const int full_my =
my >> 2;
424 const int pic_width = 16 *
h->mb_width;
426 const int pic_height =
h->pic_structure ? 16 *
h->mb_height
435 if (full_mx < 0 - extra_width ||
436 full_my < 0 - extra_height ||
437 full_mx + 16 > pic_width + extra_width ||
438 full_my + 16 > pic_height + extra_height) {
439 h->vdsp.emulated_edge_mc(
h->edge_emu_buffer,
440 src_y - 2 - 2 *
h->l_stride,
441 h->l_stride,
h->l_stride,
443 full_mx - 2, full_my - 2,
444 pic_width, pic_height);
445 src_y =
h->edge_emu_buffer + 2 + 2 *
h->l_stride;
450 qpix_op[luma_xy](dest_y, src_y,
h->l_stride);
453 h->vdsp.emulated_edge_mc(
h->edge_emu_buffer, src_cb,
454 h->c_stride,
h->c_stride,
457 pic_width >> 1, pic_height >> 1);
458 src_cb =
h->edge_emu_buffer;
460 chroma_op(dest_cb, src_cb,
h->c_stride, chroma_height,
mx & 7,
my & 7);
463 h->vdsp.emulated_edge_mc(
h->edge_emu_buffer, src_cr,
464 h->c_stride,
h->c_stride,
467 pic_width >> 1, pic_height >> 1);
468 src_cr =
h->edge_emu_buffer;
470 chroma_op(dest_cr, src_cr,
h->c_stride, chroma_height,
mx & 7,
my & 7);
477 int x_offset,
int y_offset,
487 dest_y += x_offset * 2 + y_offset *
h->l_stride * 2;
488 dest_cb += x_offset + y_offset *
h->c_stride;
489 dest_cr += x_offset + y_offset *
h->c_stride;
490 x_offset += 8 *
h->mbx;
492 y_offset += 8 *
h->field_mby;
497 dest_y, dest_cb, dest_cr, x_offset, y_offset,
498 qpix_op, chroma_op,
mv);
501 chroma_op = chroma_avg;
508 dest_y, dest_cb, dest_cr, x_offset, y_offset,
509 qpix_op, chroma_op,
mv);
517 h->cdsp.put_cavs_qpel_pixels_tab[0],
518 h->h264chroma.put_h264_chroma_pixels_tab[0],
519 h->cdsp.avg_cavs_qpel_pixels_tab[0],
520 h->h264chroma.avg_h264_chroma_pixels_tab[0],
524 h->cdsp.put_cavs_qpel_pixels_tab[1],
525 h->h264chroma.put_h264_chroma_pixels_tab[1],
526 h->cdsp.avg_cavs_qpel_pixels_tab[1],
527 h->h264chroma.avg_h264_chroma_pixels_tab[1],
530 h->cdsp.put_cavs_qpel_pixels_tab[1],
531 h->h264chroma.put_h264_chroma_pixels_tab[1],
532 h->cdsp.avg_cavs_qpel_pixels_tab[1],
533 h->h264chroma.avg_h264_chroma_pixels_tab[1],
536 h->cdsp.put_cavs_qpel_pixels_tab[1],
537 h->h264chroma.put_h264_chroma_pixels_tab[1],
538 h->cdsp.avg_cavs_qpel_pixels_tab[1],
539 h->h264chroma.avg_h264_chroma_pixels_tab[1],
542 h->cdsp.put_cavs_qpel_pixels_tab[1],
543 h->h264chroma.put_h264_chroma_pixels_tab[1],
544 h->cdsp.avg_cavs_qpel_pixels_tab[1],
545 h->h264chroma.avg_h264_chroma_pixels_tab[1],
570 int ax, ay, bx, by, cx, cy;
571 int len_ab, len_bc, len_ca, len_mid;
578 len_ab =
abs(ax - bx) +
abs(ay - by);
579 len_bc =
abs(bx - cx) +
abs(by - cy);
580 len_ca =
abs(cx - ax) +
abs(cy - ay);
581 len_mid =
mid_pred(len_ab, len_bc, len_ca);
582 if (len_mid == len_ab) {
585 }
else if (len_mid == len_bc) {
609 mvC = &
h->mv[nP - 5];
613 (mvA->
x | mvA->
y | mvA->
ref) == 0 ||
614 (mvB->
x | mvB->
y | mvB->
ref) == 0)) {
617 }
else if (mvA->
ref >= 0 && mvB->
ref < 0 && mvC->
ref < 0) {
619 }
else if (mvA->
ref < 0 && mvB->
ref >= 0 && mvC->
ref < 0) {
621 }
else if (mvA->
ref < 0 && mvB->
ref < 0 && mvC->
ref >= 0) {
649 mx = dx + (unsigned)mvP->
x;
650 my = dy + (unsigned)mvP->
y;
652 if (
mx != (int16_t)
mx ||
my != (int16_t)
my) {
677 h->field = !
h->pic_structure &&
h->mby >=
h->mb_height / 2;
678 h->field_mby =
h->mby -
h->field * (
h->mb_height / 2);
682 if (!
h->pic_structure)
683 parity =
h->field ^ !
h->top_field_first;
685 h->cy =
h->cur.f->data[0] +
parity *
h->cur.f->linesize[0] +
686 h->field_mby * 16 *
h->l_stride;
687 h->cu =
h->cur.f->data[1] +
parity *
h->cur.f->linesize[1] +
688 h->field_mby * 8 *
h->c_stride;
689 h->cv =
h->cur.f->data[2] +
parity *
h->cur.f->linesize[2] +
690 h->field_mby * 8 *
h->c_stride;
706 for (
i = 0;
i < 3;
i++) {
710 h->pred_mode_Y[1] =
h->top_pred_Y[
h->mbx * 2 + 0];
711 h->pred_mode_Y[2] =
h->top_pred_Y[
h->mbx * 2 + 1];
723 if (
h->mbx ==
h->mb_width - 1)
751 for (
i = 0;
i <= 20;
i += 4) {
752 h->mv[
i] =
h->mv[
i + 2];
753 memcpy(
h->mvd[
i],
h->mvd[
i + 2],
sizeof(*
h->mvd));
763 if (
h->mbx ==
h->mb_width) {
768 for (
i = 0;
i <= 20;
i += 4) {
770 memset(
h->mvd[
i], 0,
sizeof(*
h->mvd));
774 if (
h->mby ==
h->mb_height) {
794 for (
i = 0;
i <= 20;
i += 4) {
796 memset(
h->mvd[
i], 0,
sizeof(*
h->mvd));
804 h->l_stride =
h->cur.f->linesize[0] << !
h->pic_structure;
805 h->c_stride =
h->cur.f->linesize[1] << !
h->pic_structure;
806 h->luma_scan[2] = 8 *
h->l_stride;
807 h->luma_scan[3] = 8 *
h->l_stride + 8;
808 h->mbx =
h->mby =
h->mbidx = 0;
832 h->top_pred_Y =
av_calloc(
h->mb_width * 2,
sizeof(*
h->top_pred_Y));
839 4 *
sizeof(*
h->col_mv));
846 if (!
h->top_qp || !
h->top_mv[0] || !
h->top_mv[1] || !
h->top_pred_Y ||
847 !
h->top_cbp || !
h->top_c_pred_mode || !
h->top_mb_type ||
848 !
h->top_border_y || !
h->top_border_u || !
h->top_border_v ||
849 !
h->col_mv || !
h->col_type_base) {
870 uint8_t permutation[64];
880 h->scantable =
h->permutated_scantable;
888 if (!
h->cur.f || !
h->DPB[0].f || !
h->DPB[1].f)
911 h->direct_den[
i] =
i ? 16384 /
i : 0;
937 h->deemulated_buf_size = 0;
939 h->stc_offset_size = 0;
uint8_t ptrdiff_t const uint8_t ptrdiff_t int intptr_t intptr_t my
uint8_t ptrdiff_t const uint8_t ptrdiff_t int intptr_t mx
Libavcodec external API header.
static int BS_FUNC left(const BSCTX *bc)
Return the number of the bits left in a buffer.
static const uint8_t tc_tab[64]
int ff_cavs_init_pic(AVSContext *h)
void ff_cavs_set_mb_row(AVSContext *h)
Point the macroblock sample pointers at macroblock row h->mby, addressed inside the macroblock's own ...
int ff_cavs_next_mb(AVSContext *h)
save predictors for later macroblocks and increase macroblock address
void ff_cavs_load_intra_pred_chroma(AVSContext *h)
static void mc_dir_part(AVSContext *h, AVFrame *pic, int parity, int chroma_height, 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, cavs_vector *mv)
static const uint8_t beta_tab[64]
static const uint8_t alpha_tab[64]
void ff_cavs_load_intra_pred_luma(AVSContext *h, uint8_t *top, uint8_t **left, int block)
av_cold int ff_cavs_end(AVCodecContext *avctx)
void ff_cavs_mv(AVSContext *h, enum cavs_mv_loc nP, enum cavs_mv_loc nC, enum cavs_mv_pred mode, enum cavs_block size, int ref)
av_cold int ff_cavs_init(AVCodecContext *avctx)
static void intra_pred_horiz(uint8_t *d, uint8_t *top, uint8_t *left, ptrdiff_t stride)
#define LOWPASS(ARRAY, INDEX)
static const int8_t left_modifier_c[7]
void ff_cavs_inter(AVSContext *h, enum cavs_mb mb_type)
static void modify_pred(const int8_t *mod_table, int *mode)
static const int8_t top_modifier_c[7]
static void mc_part_std(AVSContext *h, int chroma_height, 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, cavs_vector *mv)
static void intra_pred_lp_left(uint8_t *d, uint8_t *top, uint8_t *left, ptrdiff_t stride)
static void intra_pred_lp_top(uint8_t *d, uint8_t *top, uint8_t *left, ptrdiff_t stride)
void ff_cavs_modify_mb_i(AVSContext *h, int *pred_mode_uv)
static void intra_pred_down_left(uint8_t *d, uint8_t *top, uint8_t *left, ptrdiff_t stride)
static const int8_t left_modifier_l[8]
static const int8_t top_modifier_l[8]
int ff_cavs_init_top_lines(AVSContext *h)
some predictions require data from the top-neighbouring macroblock.
static void intra_pred_dc_128(uint8_t *d, uint8_t *top, uint8_t *left, ptrdiff_t stride)
static const uint8_t cavs_scan_field[64]
Inverse block scan method 2 (clause 9.5.3 c), figure 23), for field coded pictures,...
static void mv_pred_median(AVSContext *h, cavs_vector *mvP, cavs_vector *mvA, cavs_vector *mvB, cavs_vector *mvC)
static void intra_pred_down_right(uint8_t *d, uint8_t *top, uint8_t *left, ptrdiff_t stride)
static int get_bs(cavs_vector *mvP, cavs_vector *mvQ, int b)
static const cavs_vector un_mv
mark block as unavailable, i.e.
void ff_cavs_init_mb(AVSContext *h)
initialise predictors for motion vectors and intra prediction
void ff_cavs_filter(AVSContext *h, enum cavs_mb mb_type)
in-loop deblocking filter for a single macroblock
static void intra_pred_vert(uint8_t *d, uint8_t *top, uint8_t *left, ptrdiff_t stride)
static void intra_pred_lp(uint8_t *d, uint8_t *top, uint8_t *left, ptrdiff_t stride)
static void intra_pred_plane(uint8_t *d, uint8_t *top, uint8_t *left, ptrdiff_t stride)
const uint8_t ff_cavs_chroma_qp[64]
static void set_mvds(int16_t(*mvd)[2], enum cavs_block size)
replicate one partition's mv_diff over the 8x8 blocks it covers
static void set_mvs(cavs_vector *mv, enum cavs_block size)
const uint8_t ff_cavs_partition_flags[30]
#define CAVS_DIR_MV
mark block as using intra prediction
#define i(width, name, range_min, range_max)
static int get_se_golomb(GetBitContext *gb)
read signed exp golomb code.
void av_frame_free(AVFrame **frame)
Free the frame and any dynamically allocated objects in it, e.g.
AVFrame * av_frame_alloc(void)
Allocate an AVFrame and set its fields to default values.
#define AV_LOG_ERROR
Something went wrong and cannot losslessly be recovered.
void(* h264_chroma_mc_func)(uint8_t *dst, const uint8_t *src, ptrdiff_t srcStride, int h, int x, int y)
static const int16_t alpha[]
static const int8_t mv[256][2]
av_cold void ff_blockdsp_init(BlockDSPContext *c)
av_cold void ff_cavsdsp_init(CAVSDSPContext *c)
av_cold void ff_h264chroma_init(H264ChromaContext *c, int bit_depth)
av_cold void ff_init_scantable_permutation(uint8_t *idct_permutation, enum idct_permutation_type perm_type)
av_cold void ff_permute_scantable(uint8_t dst[64], const uint8_t src[64], const uint8_t permutation[64])
av_cold void ff_videodsp_init(VideoDSPContext *ctx, int bpc)
const uint8_t ff_zigzag_direct[64]
void * av_calloc(size_t nmemb, size_t size)
Memory handling functions.
@ AV_PIX_FMT_YUV420P
planar YUV 4:2:0, 12bpp, (1 Cr & Cb sample per 2x2 Y samples)
void(* qpel_mc_func)(uint8_t *dst, const uint8_t *src, ptrdiff_t stride)
#define FF_ARRAY_ELEMS(a)
main external API structure.
enum AVPixelFormat pix_fmt
Pixel format, see AV_PIX_FMT_xxx.
This structure describes decoded (raw) audio or video data.
uint8_t * data[AV_NUM_DATA_POINTERS]
pointer to the picture/channel planes.
int linesize[AV_NUM_DATA_POINTERS]
For video, a positive or negative value, which is typically indicating the size in bytes of each pict...
int16_t ref_idx
mb_reference_index of the block, 0 when it codes none (clause 9.4.5); ref above is where the referenc...
static int ref[MAX_W *MAX_W]