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
77 if((
abs(mvP->
x - mvQ->
x) >= 4) ||
78 (
abs(mvP->
y - mvQ->
y) >= 4) ||
84 if((
abs(mvP->
x - mvQ->
x) >= 4) ||
85 (
abs(mvP->
y - mvQ->
y) >= 4) ||
93 alpha = alpha_tab[av_clip_uintp2(qp_avg + h->alpha_offset, 6)]; \
94 beta = beta_tab[av_clip_uintp2(qp_avg + h->beta_offset, 6)]; \
95 tc = tc_tab[av_clip_uintp2(qp_avg + h->alpha_offset, 6)];
111 int qp_avg,
alpha, beta, tc;
115 h->topleft_border_y =
h->top_border_y[
h->mbx * 16 + 15];
116 h->topleft_border_u =
h->top_border_u[
h->mbx * 10 + 8];
117 h->topleft_border_v =
h->top_border_v[
h->mbx * 10 + 8];
118 memcpy(&
h->top_border_y[
h->mbx * 16],
h->cy + 15 *
h->l_stride, 16);
119 memcpy(&
h->top_border_u[
h->mbx * 10 + 1],
h->cu + 7 *
h->c_stride, 8);
120 memcpy(&
h->top_border_v[
h->mbx * 10 + 1],
h->cv + 7 *
h->c_stride, 8);
121 for (
i = 0;
i < 8;
i++) {
122 h->left_border_y[
i * 2 + 1] = *(
h->cy + 15 + (
i * 2 + 0) *
h->l_stride);
123 h->left_border_y[
i * 2 + 2] = *(
h->cy + 15 + (
i * 2 + 1) *
h->l_stride);
124 h->left_border_u[
i + 1] = *(
h->cu + 7 +
i *
h->c_stride);
125 h->left_border_v[
i + 1] = *(
h->cv + 7 +
i *
h->c_stride);
127 if (!
h->loop_filter_disable) {
129 if (mb_type ==
I_8X8)
148 qp_avg = (
h->qp +
h->left_qp + 1) >> 1;
150 h->cdsp.cavs_filter_lv(
h->cy,
h->l_stride,
alpha, beta, tc, bs[0], bs[1]);
153 h->cdsp.cavs_filter_cv(
h->cu,
h->c_stride,
alpha, beta, tc, bs[0], bs[1]);
154 h->cdsp.cavs_filter_cv(
h->cv,
h->c_stride,
alpha, beta, tc, bs[0], bs[1]);
158 h->cdsp.cavs_filter_lv(
h->cy + 8,
h->l_stride,
alpha, beta, tc, bs[2], bs[3]);
159 h->cdsp.cavs_filter_lh(
h->cy + 8 *
h->l_stride,
h->l_stride,
alpha, beta, tc, bs[6], bs[7]);
162 qp_avg = (
h->qp +
h->top_qp[
h->mbx] + 1) >> 1;
164 h->cdsp.cavs_filter_lh(
h->cy,
h->l_stride,
alpha, beta, tc, bs[4], bs[5]);
167 h->cdsp.cavs_filter_ch(
h->cu,
h->c_stride,
alpha, beta, tc, bs[4], bs[5]);
168 h->cdsp.cavs_filter_ch(
h->cv,
h->c_stride,
alpha, beta, tc, bs[4], bs[5]);
173 h->top_qp[
h->mbx] =
h->qp;
191 *
left =
h->left_border_y;
192 h->left_border_y[0] =
h->left_border_y[1];
193 memset(&
h->left_border_y[17],
h->left_border_y[16], 9);
194 memcpy(&top[1], &
h->top_border_y[
h->mbx * 16], 16);
198 h->left_border_y[0] = top[0] =
h->topleft_border_y;
201 *
left =
h->intern_border_y;
202 for (
i = 0;
i < 8;
i++)
203 h->intern_border_y[
i + 1] = *(
h->cy + 7 +
i *
h->l_stride);
204 memset(&
h->intern_border_y[9],
h->intern_border_y[8], 9);
205 h->intern_border_y[0] =
h->intern_border_y[1];
206 memcpy(&top[1], &
h->top_border_y[
h->mbx * 16 + 8], 8);
208 memcpy(&top[9], &
h->top_border_y[(
h->mbx + 1) * 16], 8);
210 memset(&top[9], top[8], 9);
214 h->intern_border_y[0] = top[0] =
h->top_border_y[
h->mbx * 16 + 7];
217 *
left = &
h->left_border_y[8];
218 memcpy(&top[1],
h->cy + 7 *
h->l_stride, 16);
222 top[0] =
h->left_border_y[8];
225 *
left = &
h->intern_border_y[8];
226 for (
i = 0;
i < 8;
i++)
227 h->intern_border_y[
i + 9] = *(
h->cy + 7 + (
i + 8) *
h->l_stride);
228 memset(&
h->intern_border_y[17],
h->intern_border_y[16], 9);
229 memcpy(&top[0],
h->cy + 7 + 7 *
h->l_stride, 9);
230 memset(&top[9], top[8], 9);
238 h->left_border_u[9] =
h->left_border_u[8];
239 h->left_border_v[9] =
h->left_border_v[8];
241 h->top_border_u[
h->mbx*10 + 9] =
h->top_border_u[
h->mbx*10 + 11];
242 h->top_border_v[
h->mbx*10 + 9] =
h->top_border_v[
h->mbx*10 + 11];
244 h->top_border_u[
h->mbx * 10 + 9] =
h->top_border_u[
h->mbx * 10 + 8];
245 h->top_border_v[
h->mbx * 10 + 9] =
h->top_border_v[
h->mbx * 10 + 8];
248 h->top_border_u[
h->mbx * 10] =
h->left_border_u[0] =
h->topleft_border_u;
249 h->top_border_v[
h->mbx * 10] =
h->left_border_v[0] =
h->topleft_border_v;
251 h->left_border_u[0] =
h->left_border_u[1];
252 h->left_border_v[0] =
h->left_border_v[1];
253 h->top_border_u[
h->mbx * 10] =
h->top_border_u[
h->mbx * 10 + 1];
254 h->top_border_v[
h->mbx * 10] =
h->top_border_v[
h->mbx * 10 + 1];
262 for (y = 0; y < 8; y++)
263 *((uint64_t *)(d + y *
stride)) =
a;
270 for (y = 0; y < 8; y++) {
271 a =
left[y + 1] * 0x0101010101010101ULL;
272 *((uint64_t *)(d + y *
stride)) =
a;
279 uint64_t
a = 0x8080808080808080ULL;
280 for (y = 0; y < 8; y++)
281 *((uint64_t *)(d + y *
stride)) =
a;
291 for (x = 0; x < 4; x++) {
292 ih += (x + 1) * (top[5 + x] - top[3 - x]);
293 iv += (x + 1) * (
left[5 + x] -
left[3 - x]);
295 ia = (top[8] +
left[8]) << 4;
296 ih = (17 * ih + 16) >> 5;
297 iv = (17 * iv + 16) >> 5;
298 for (y = 0; y < 8; y++)
299 for (x = 0; x < 8; x++)
300 d[y *
stride + x] =
cm[(ia + (x - 3) * ih + (y - 3) * iv + 16) >> 5];
303#define LOWPASS(ARRAY, INDEX) \
304 ((ARRAY[(INDEX) - 1] + 2 * ARRAY[(INDEX)] + ARRAY[(INDEX) + 1] + 2) >> 2)
309 for (y = 0; y < 8; y++)
310 for (x = 0; x < 8; x++)
317 for (y = 0; y < 8; y++)
318 for (x = 0; x < 8; x++)
325 for (y = 0; y < 8; y++)
326 for (x = 0; x < 8; x++)
328 d[y *
stride + x] = (
left[1] + 2 * top[0] + top[1] + 2) >> 2;
338 for (y = 0; y < 8; y++)
339 for (x = 0; x < 8; x++)
346 for (y = 0; y < 8; y++)
347 for (x = 0; x < 8; x++)
365 h->pred_mode_Y[3] =
h->pred_mode_Y[5];
366 h->pred_mode_Y[6] =
h->pred_mode_Y[8];
367 h->top_pred_Y[
h->mbx * 2 + 0] =
h->pred_mode_Y[7];
368 h->top_pred_Y[
h->mbx * 2 + 1] =
h->pred_mode_Y[8];
390 int list, uint8_t *dest_y,
391 uint8_t *dest_cb, uint8_t *dest_cr,
392 int src_x_offset,
int src_y_offset,
396 const int mx =
mv->x + src_x_offset * 8;
397 const int my =
mv->y + src_y_offset * 8;
398 const int luma_xy = (
mx & 3) + ((
my & 3) << 2);
399 uint8_t *src_y = pic->
data[0] + (
mx >> 2) + (
my >> 2) *
h->l_stride;
400 uint8_t *src_cb = pic->
data[1] + (
mx >> 3) + (
my >> 3) *
h->c_stride;
401 uint8_t *src_cr = pic->
data[2] + (
mx >> 3) + (
my >> 3) *
h->c_stride;
403 int extra_height = extra_width;
404 const int full_mx =
mx >> 2;
405 const int full_my =
my >> 2;
406 const int pic_width = 16 *
h->mb_width;
407 const int pic_height = 16 *
h->mb_height;
417 if (full_mx < 0 - extra_width ||
418 full_my < 0 - extra_height ||
419 full_mx + 16 > pic_width + extra_width ||
420 full_my + 16 > pic_height + extra_height) {
421 h->vdsp.emulated_edge_mc(
h->edge_emu_buffer,
422 src_y - 2 - 2 *
h->l_stride,
423 h->l_stride,
h->l_stride,
425 full_mx - 2, full_my - 2,
426 pic_width, pic_height);
427 src_y =
h->edge_emu_buffer + 2 + 2 *
h->l_stride;
432 qpix_op[luma_xy](dest_y, src_y,
h->l_stride);
435 h->vdsp.emulated_edge_mc(
h->edge_emu_buffer, src_cb,
436 h->c_stride,
h->c_stride,
439 pic_width >> 1, pic_height >> 1);
440 src_cb =
h->edge_emu_buffer;
442 chroma_op(dest_cb, src_cb,
h->c_stride, chroma_height,
mx & 7,
my & 7);
445 h->vdsp.emulated_edge_mc(
h->edge_emu_buffer, src_cr,
446 h->c_stride,
h->c_stride,
449 pic_width >> 1, pic_height >> 1);
450 src_cr =
h->edge_emu_buffer;
452 chroma_op(dest_cr, src_cr,
h->c_stride, chroma_height,
mx & 7,
my & 7);
459 int x_offset,
int y_offset,
469 dest_y += x_offset * 2 + y_offset *
h->l_stride * 2;
470 dest_cb += x_offset + y_offset *
h->c_stride;
471 dest_cr += x_offset + y_offset *
h->c_stride;
472 x_offset += 8 *
h->mbx;
473 y_offset += 8 *
h->mby;
478 dest_y, dest_cb, dest_cr, x_offset, y_offset,
479 qpix_op, chroma_op,
mv);
482 chroma_op = chroma_avg;
488 dest_y, dest_cb, dest_cr, x_offset, y_offset,
497 h->cdsp.put_cavs_qpel_pixels_tab[0],
498 h->h264chroma.put_h264_chroma_pixels_tab[0],
499 h->cdsp.avg_cavs_qpel_pixels_tab[0],
500 h->h264chroma.avg_h264_chroma_pixels_tab[0],
504 h->cdsp.put_cavs_qpel_pixels_tab[1],
505 h->h264chroma.put_h264_chroma_pixels_tab[1],
506 h->cdsp.avg_cavs_qpel_pixels_tab[1],
507 h->h264chroma.avg_h264_chroma_pixels_tab[1],
510 h->cdsp.put_cavs_qpel_pixels_tab[1],
511 h->h264chroma.put_h264_chroma_pixels_tab[1],
512 h->cdsp.avg_cavs_qpel_pixels_tab[1],
513 h->h264chroma.avg_h264_chroma_pixels_tab[1],
516 h->cdsp.put_cavs_qpel_pixels_tab[1],
517 h->h264chroma.put_h264_chroma_pixels_tab[1],
518 h->cdsp.avg_cavs_qpel_pixels_tab[1],
519 h->h264chroma.avg_h264_chroma_pixels_tab[1],
522 h->cdsp.put_cavs_qpel_pixels_tab[1],
523 h->h264chroma.put_h264_chroma_pixels_tab[1],
524 h->cdsp.avg_cavs_qpel_pixels_tab[1],
525 h->h264chroma.avg_h264_chroma_pixels_tab[1],
550 int ax, ay, bx, by, cx, cy;
551 int len_ab, len_bc, len_ca, len_mid;
558 len_ab =
abs(ax - bx) +
abs(ay - by);
559 len_bc =
abs(bx - cx) +
abs(by - cy);
560 len_ca =
abs(cx - ax) +
abs(cy - ay);
561 len_mid =
mid_pred(len_ab, len_bc, len_ca);
562 if (len_mid == len_ab) {
565 }
else if (len_mid == len_bc) {
586 mvC = &
h->mv[nP - 5];
590 (mvA->
x | mvA->
y | mvA->
ref) == 0 ||
591 (mvB->
x | mvB->
y | mvB->
ref) == 0)) {
594 }
else if (mvA->
ref >= 0 && mvB->
ref < 0 && mvC->
ref < 0) {
596 }
else if (mvA->
ref < 0 && mvB->
ref >= 0 && mvC->
ref < 0) {
598 }
else if (mvA->
ref < 0 && mvB->
ref < 0 && mvC->
ref >= 0) {
617 if (
mx != (int16_t)
mx ||
my != (int16_t)
my) {
641 for (
i = 0;
i < 3;
i++) {
645 h->pred_mode_Y[1] =
h->top_pred_Y[
h->mbx * 2 + 0];
646 h->pred_mode_Y[2] =
h->top_pred_Y[
h->mbx * 2 + 1];
658 if (
h->mbx ==
h->mb_width - 1)
686 for (
i = 0;
i <= 20;
i += 4)
687 h->mv[
i] =
h->mv[
i + 2];
696 if (
h->mbx ==
h->mb_width) {
701 for (
i = 0;
i <= 20;
i += 4)
706 h->cy =
h->cur.f->data[0] +
h->mby * 16 *
h->l_stride;
707 h->cu =
h->cur.f->data[1] +
h->mby * 8 *
h->c_stride;
708 h->cv =
h->cur.f->data[2] +
h->mby * 8 *
h->c_stride;
709 if (
h->mby ==
h->mb_height) {
727 for (
i = 0;
i <= 20;
i += 4)
734 h->cy =
h->cur.f->data[0];
735 h->cu =
h->cur.f->data[1];
736 h->cv =
h->cur.f->data[2];
737 h->l_stride =
h->cur.f->linesize[0];
738 h->c_stride =
h->cur.f->linesize[1];
739 h->luma_scan[2] = 8 *
h->l_stride;
740 h->luma_scan[3] = 8 *
h->l_stride + 8;
741 h->mbx =
h->mby =
h->mbidx = 0;
764 h->top_pred_Y =
av_calloc(
h->mb_width * 2,
sizeof(*
h->top_pred_Y));
771 4 *
sizeof(*
h->col_mv));
774 if (!
h->top_qp || !
h->top_mv[0] || !
h->top_mv[1] || !
h->top_pred_Y ||
775 !
h->top_border_y || !
h->top_border_u || !
h->top_border_v ||
776 !
h->col_mv || !
h->col_type_base) {
794 uint8_t permutation[64];
809 if (!
h->cur.f || !
h->DPB[0].f || !
h->DPB[1].f)
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)
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 const uint8_t beta_tab[64]
static const uint8_t alpha_tab[64]
static void mc_dir_part(AVSContext *h, AVFrame *pic, 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)
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 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_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)
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.
static int ref[MAX_W *MAX_W]