/src/libvpx/vp8/encoder/encodeintra.c
Line  | Count  | Source (jump to first uncovered line)  | 
1  |  | /*  | 
2  |  |  *  Copyright (c) 2010 The WebM project authors. All Rights Reserved.  | 
3  |  |  *  | 
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.  | 
9  |  |  */  | 
10  |  |  | 
11  |  | #include "vpx_config.h"  | 
12  |  | #include "vp8_rtcd.h"  | 
13  |  | #include "./vpx_dsp_rtcd.h"  | 
14  |  | #include "vp8/encoder/quantize.h"  | 
15  |  | #include "vp8/common/reconintra.h"  | 
16  |  | #include "vp8/common/reconintra4x4.h"  | 
17  |  | #include "encodemb.h"  | 
18  |  | #include "vp8/common/invtrans.h"  | 
19  |  | #include "encodeintra.h"  | 
20  |  |  | 
21  | 0  | int vp8_encode_intra(MACROBLOCK *x, int use_dc_pred) { | 
22  | 0  |   int i;  | 
23  | 0  |   int intra_pred_var = 0;  | 
24  |  | 
  | 
25  | 0  |   if (use_dc_pred) { | 
26  | 0  |     x->e_mbd.mode_info_context->mbmi.mode = DC_PRED;  | 
27  | 0  |     x->e_mbd.mode_info_context->mbmi.uv_mode = DC_PRED;  | 
28  | 0  |     x->e_mbd.mode_info_context->mbmi.ref_frame = INTRA_FRAME;  | 
29  |  | 
  | 
30  | 0  |     vp8_encode_intra16x16mby(x);  | 
31  |  | 
  | 
32  | 0  |     vp8_inverse_transform_mby(&x->e_mbd);  | 
33  | 0  |   } else { | 
34  | 0  |     for (i = 0; i < 16; ++i) { | 
35  | 0  |       x->e_mbd.block[i].bmi.as_mode = B_DC_PRED;  | 
36  | 0  |       vp8_encode_intra4x4block(x, i);  | 
37  | 0  |     }  | 
38  | 0  |   }  | 
39  |  | 
  | 
40  | 0  |   intra_pred_var = vpx_get_mb_ss(x->src_diff);  | 
41  |  | 
  | 
42  | 0  |   return intra_pred_var;  | 
43  | 0  | }  | 
44  |  |  | 
45  | 24.5M  | void vp8_encode_intra4x4block(MACROBLOCK *x, int ib) { | 
46  | 24.5M  |   BLOCKD *b = &x->e_mbd.block[ib];  | 
47  | 24.5M  |   BLOCK *be = &x->block[ib];  | 
48  | 24.5M  |   int dst_stride = x->e_mbd.dst.y_stride;  | 
49  | 24.5M  |   unsigned char *dst = x->e_mbd.dst.y_buffer + b->offset;  | 
50  | 24.5M  |   unsigned char *Above = dst - dst_stride;  | 
51  | 24.5M  |   unsigned char *yleft = dst - 1;  | 
52  | 24.5M  |   unsigned char top_left = Above[-1];  | 
53  |  |  | 
54  | 24.5M  |   vp8_intra4x4_predict(Above, yleft, dst_stride, b->bmi.as_mode, b->predictor,  | 
55  | 24.5M  |                        16, top_left);  | 
56  |  |  | 
57  | 24.5M  |   vp8_subtract_b(be, b, 16);  | 
58  |  |  | 
59  | 24.5M  |   x->short_fdct4x4(be->src_diff, be->coeff, 32);  | 
60  |  |  | 
61  | 24.5M  |   x->quantize_b(be, b);  | 
62  |  |  | 
63  | 24.5M  |   if (*b->eob > 1) { | 
64  | 17.9M  |     vp8_short_idct4x4llm(b->dqcoeff, b->predictor, 16, dst, dst_stride);  | 
65  | 17.9M  |   } else { | 
66  | 6.54M  |     vp8_dc_only_idct_add(b->dqcoeff[0], b->predictor, 16, dst, dst_stride);  | 
67  | 6.54M  |   }  | 
68  | 24.5M  | }  | 
69  |  |  | 
70  | 793k  | void vp8_encode_intra4x4mby(MACROBLOCK *mb) { | 
71  | 793k  |   int i;  | 
72  |  |  | 
73  | 793k  |   MACROBLOCKD *xd = &mb->e_mbd;  | 
74  | 793k  |   intra_prediction_down_copy(xd, xd->dst.y_buffer - xd->dst.y_stride + 16);  | 
75  |  |  | 
76  | 13.4M  |   for (i = 0; i < 16; ++i) vp8_encode_intra4x4block(mb, i);  | 
77  | 793k  |   return;  | 
78  | 793k  | }  | 
79  |  |  | 
80  | 860k  | void vp8_encode_intra16x16mby(MACROBLOCK *x) { | 
81  | 860k  |   BLOCK *b = &x->block[0];  | 
82  | 860k  |   MACROBLOCKD *xd = &x->e_mbd;  | 
83  |  |  | 
84  | 860k  |   vp8_build_intra_predictors_mby_s(xd, xd->dst.y_buffer - xd->dst.y_stride,  | 
85  | 860k  |                                    xd->dst.y_buffer - 1, xd->dst.y_stride,  | 
86  | 860k  |                                    xd->dst.y_buffer, xd->dst.y_stride);  | 
87  |  |  | 
88  | 860k  |   vp8_subtract_mby(x->src_diff, *(b->base_src), b->src_stride, xd->dst.y_buffer,  | 
89  | 860k  |                    xd->dst.y_stride);  | 
90  |  |  | 
91  | 860k  |   vp8_transform_intra_mby(x);  | 
92  |  |  | 
93  | 860k  |   vp8_quantize_mby(x);  | 
94  |  |  | 
95  | 860k  |   if (x->optimize) vp8_optimize_mby(x);  | 
96  | 860k  | }  | 
97  |  |  | 
98  | 1.65M  | void vp8_encode_intra16x16mbuv(MACROBLOCK *x) { | 
99  | 1.65M  |   MACROBLOCKD *xd = &x->e_mbd;  | 
100  |  |  | 
101  | 1.65M  |   vp8_build_intra_predictors_mbuv_s(xd, xd->dst.u_buffer - xd->dst.uv_stride,  | 
102  | 1.65M  |                                     xd->dst.v_buffer - xd->dst.uv_stride,  | 
103  | 1.65M  |                                     xd->dst.u_buffer - 1, xd->dst.v_buffer - 1,  | 
104  | 1.65M  |                                     xd->dst.uv_stride, xd->dst.u_buffer,  | 
105  | 1.65M  |                                     xd->dst.v_buffer, xd->dst.uv_stride);  | 
106  |  |  | 
107  | 1.65M  |   vp8_subtract_mbuv(x->src_diff, x->src.u_buffer, x->src.v_buffer,  | 
108  | 1.65M  |                     x->src.uv_stride, xd->dst.u_buffer, xd->dst.v_buffer,  | 
109  | 1.65M  |                     xd->dst.uv_stride);  | 
110  |  |  | 
111  | 1.65M  |   vp8_transform_mbuv(x);  | 
112  |  |  | 
113  | 1.65M  |   vp8_quantize_mbuv(x);  | 
114  |  |  | 
115  | 1.65M  |   if (x->optimize) vp8_optimize_mbuv(x);  | 
116  | 1.65M  | }  |