2 * Copyright (c) 2010 The WebM project authors. All Rights Reserved.
4 * Use of this source code is governed by a BSD-style license
5 * that can be found in the LICENSE file in the root of the source
6 * tree. An additional intellectual property rights grant can be found
7 * in the file PATENTS. All contributing project authors may
8 * be found in the AUTHORS file in the root of the source tree.
12 #include "vpx_config.h"
13 #include "vp8/common/idct.h"
15 #include "vp8/common/reconintra.h"
16 #include "vp8/common/reconintra4x4.h"
18 #include "vp8/common/invtrans.h"
19 #include "vp8/common/recon.h"
21 #include "vp8/common/g_common.h"
22 #include "encodeintra.h"
25 #if CONFIG_RUNTIME_CPU_DETECT
26 #define IF_RTCD(x) (x)
28 #define IF_RTCD(x) NULL
31 int vp8_encode_intra(VP8_COMP *cpi, MACROBLOCK *x, int use_dc_pred)
35 int intra_pred_var = 0;
40 const VP8_ENCODER_RTCD *rtcd = IF_RTCD(&cpi->rtcd);
42 x->e_mbd.mode_info_context->mbmi.mode = DC_PRED;
43 x->e_mbd.mode_info_context->mbmi.uv_mode = DC_PRED;
44 x->e_mbd.mode_info_context->mbmi.ref_frame = INTRA_FRAME;
46 vp8_encode_intra16x16mby(rtcd, x);
48 vp8_inverse_transform_mby(IF_RTCD(&rtcd->common->idct), &x->e_mbd);
52 for (i = 0; i < 16; i++)
54 x->e_mbd.block[i].bmi.as_mode = B_DC_PRED;
55 vp8_encode_intra4x4block(IF_RTCD(&cpi->rtcd), x, i);
59 intra_pred_var = VARIANCE_INVOKE(&cpi->rtcd.variance, getmbss)(x->src_diff);
61 return intra_pred_var;
64 void vp8_encode_intra4x4block(const VP8_ENCODER_RTCD *rtcd,
65 MACROBLOCK *x, int ib)
67 BLOCKD *b = &x->e_mbd.block[ib];
68 BLOCK *be = &x->block[ib];
70 RECON_INVOKE(&rtcd->common->recon, intra4x4_predict)
71 (*(b->base_dst) + b->dst, b->dst_stride,
72 b->bmi.as_mode, b->predictor, 16);
74 ENCODEMB_INVOKE(&rtcd->encodemb, subb)(be, b, 16);
76 x->vp8_short_fdct4x4(be->src_diff, be->coeff, 32);
80 vp8_inverse_transform_b(IF_RTCD(&rtcd->common->idct), b, 16);
84 void vp8_encode_intra4x4mby(const VP8_ENCODER_RTCD *rtcd, MACROBLOCK *mb)
88 MACROBLOCKD *x = &mb->e_mbd;
89 vp8_intra_prediction_down_copy(x);
91 for (i = 0; i < 16; i++)
92 vp8_encode_intra4x4block(rtcd, mb, i);
96 void vp8_encode_intra16x16mby(const VP8_ENCODER_RTCD *rtcd, MACROBLOCK *x)
98 BLOCK *b = &x->block[0];
100 RECON_INVOKE(&rtcd->common->recon, build_intra_predictors_mby)(&x->e_mbd);
102 ENCODEMB_INVOKE(&rtcd->encodemb, submby)(x->src_diff, *(b->base_src),
103 x->e_mbd.predictor, b->src_stride);
105 vp8_transform_intra_mby(x);
110 vp8_optimize_mby(x, rtcd);
114 void vp8_encode_intra16x16mbuv(const VP8_ENCODER_RTCD *rtcd, MACROBLOCK *x)
116 RECON_INVOKE(&rtcd->common->recon, build_intra_predictors_mbuv)(&x->e_mbd);
118 ENCODEMB_INVOKE(&rtcd->encodemb, submbuv)(x->src_diff, x->src.u_buffer, x->src.v_buffer, x->e_mbd.predictor, x->src.uv_stride);
120 vp8_transform_mbuv(x);
122 vp8_quantize_mbuv(x);
125 vp8_optimize_mbuv(x, rtcd);