1.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000 1.2 +++ b/media/libvpx/vp8/encoder/encodeintra.c Wed Dec 31 06:09:35 2014 +0100 1.3 @@ -0,0 +1,138 @@ 1.4 +/* 1.5 + * Copyright (c) 2010 The WebM project authors. All Rights Reserved. 1.6 + * 1.7 + * Use of this source code is governed by a BSD-style license 1.8 + * that can be found in the LICENSE file in the root of the source 1.9 + * tree. An additional intellectual property rights grant can be found 1.10 + * in the file PATENTS. All contributing project authors may 1.11 + * be found in the AUTHORS file in the root of the source tree. 1.12 + */ 1.13 + 1.14 + 1.15 +#include "vpx_config.h" 1.16 +#include "vp8_rtcd.h" 1.17 +#include "quantize.h" 1.18 +#include "vp8/common/reconintra4x4.h" 1.19 +#include "encodemb.h" 1.20 +#include "vp8/common/invtrans.h" 1.21 +#include "encodeintra.h" 1.22 + 1.23 + 1.24 +int vp8_encode_intra(VP8_COMP *cpi, MACROBLOCK *x, int use_dc_pred) 1.25 +{ 1.26 + 1.27 + int i; 1.28 + int intra_pred_var = 0; 1.29 + (void) cpi; 1.30 + 1.31 + if (use_dc_pred) 1.32 + { 1.33 + x->e_mbd.mode_info_context->mbmi.mode = DC_PRED; 1.34 + x->e_mbd.mode_info_context->mbmi.uv_mode = DC_PRED; 1.35 + x->e_mbd.mode_info_context->mbmi.ref_frame = INTRA_FRAME; 1.36 + 1.37 + vp8_encode_intra16x16mby(x); 1.38 + 1.39 + vp8_inverse_transform_mby(&x->e_mbd); 1.40 + } 1.41 + else 1.42 + { 1.43 + for (i = 0; i < 16; i++) 1.44 + { 1.45 + x->e_mbd.block[i].bmi.as_mode = B_DC_PRED; 1.46 + vp8_encode_intra4x4block(x, i); 1.47 + } 1.48 + } 1.49 + 1.50 + intra_pred_var = vp8_get_mb_ss(x->src_diff); 1.51 + 1.52 + return intra_pred_var; 1.53 +} 1.54 + 1.55 +void vp8_encode_intra4x4block(MACROBLOCK *x, int ib) 1.56 +{ 1.57 + BLOCKD *b = &x->e_mbd.block[ib]; 1.58 + BLOCK *be = &x->block[ib]; 1.59 + int dst_stride = x->e_mbd.dst.y_stride; 1.60 + unsigned char *dst = x->e_mbd.dst.y_buffer + b->offset; 1.61 + unsigned char *Above = dst - dst_stride; 1.62 + unsigned char *yleft = dst - 1; 1.63 + unsigned char top_left = Above[-1]; 1.64 + 1.65 + vp8_intra4x4_predict(Above, yleft, dst_stride, b->bmi.as_mode, 1.66 + b->predictor, 16, top_left); 1.67 + 1.68 + vp8_subtract_b(be, b, 16); 1.69 + 1.70 + x->short_fdct4x4(be->src_diff, be->coeff, 32); 1.71 + 1.72 + x->quantize_b(be, b); 1.73 + 1.74 + if (*b->eob > 1) 1.75 + { 1.76 + vp8_short_idct4x4llm(b->dqcoeff, b->predictor, 16, dst, dst_stride); 1.77 + } 1.78 + else 1.79 + { 1.80 + vp8_dc_only_idct_add(b->dqcoeff[0], b->predictor, 16, dst, dst_stride); 1.81 + } 1.82 +} 1.83 + 1.84 +void vp8_encode_intra4x4mby(MACROBLOCK *mb) 1.85 +{ 1.86 + int i; 1.87 + 1.88 + MACROBLOCKD *xd = &mb->e_mbd; 1.89 + intra_prediction_down_copy(xd, xd->dst.y_buffer - xd->dst.y_stride + 16); 1.90 + 1.91 + for (i = 0; i < 16; i++) 1.92 + vp8_encode_intra4x4block(mb, i); 1.93 + return; 1.94 +} 1.95 + 1.96 +void vp8_encode_intra16x16mby(MACROBLOCK *x) 1.97 +{ 1.98 + BLOCK *b = &x->block[0]; 1.99 + MACROBLOCKD *xd = &x->e_mbd; 1.100 + 1.101 + vp8_build_intra_predictors_mby_s(xd, 1.102 + xd->dst.y_buffer - xd->dst.y_stride, 1.103 + xd->dst.y_buffer - 1, 1.104 + xd->dst.y_stride, 1.105 + xd->dst.y_buffer, 1.106 + xd->dst.y_stride); 1.107 + 1.108 + vp8_subtract_mby(x->src_diff, *(b->base_src), 1.109 + b->src_stride, xd->dst.y_buffer, xd->dst.y_stride); 1.110 + 1.111 + vp8_transform_intra_mby(x); 1.112 + 1.113 + vp8_quantize_mby(x); 1.114 + 1.115 + if (x->optimize) 1.116 + vp8_optimize_mby(x); 1.117 +} 1.118 + 1.119 +void vp8_encode_intra16x16mbuv(MACROBLOCK *x) 1.120 +{ 1.121 + MACROBLOCKD *xd = &x->e_mbd; 1.122 + 1.123 + vp8_build_intra_predictors_mbuv_s(xd, xd->dst.u_buffer - xd->dst.uv_stride, 1.124 + xd->dst.v_buffer - xd->dst.uv_stride, 1.125 + xd->dst.u_buffer - 1, 1.126 + xd->dst.v_buffer - 1, 1.127 + xd->dst.uv_stride, 1.128 + xd->dst.u_buffer, xd->dst.v_buffer, 1.129 + xd->dst.uv_stride); 1.130 + 1.131 + vp8_subtract_mbuv(x->src_diff, x->src.u_buffer, 1.132 + x->src.v_buffer, x->src.uv_stride, xd->dst.u_buffer, 1.133 + xd->dst.v_buffer, xd->dst.uv_stride); 1.134 + 1.135 + vp8_transform_mbuv(x); 1.136 + 1.137 + vp8_quantize_mbuv(x); 1.138 + 1.139 + if (x->optimize) 1.140 + vp8_optimize_mbuv(x); 1.141 +}