| OLD | NEW | 
|---|
| 1 /* | 1 /* | 
| 2  *  Copyright (c) 2010 The WebM project authors. All Rights Reserved. | 2  *  Copyright (c) 2010 The WebM project authors. All Rights Reserved. | 
| 3  * | 3  * | 
| 4  *  Use of this source code is governed by a BSD-style license | 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 | 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 | 6  *  tree. An additional intellectual property rights grant can be found | 
| 7  *  in the file PATENTS.  All contributing project authors may | 7  *  in the file PATENTS.  All contributing project authors may | 
| 8  *  be found in the AUTHORS file in the root of the source tree. | 8  *  be found in the AUTHORS file in the root of the source tree. | 
| 9  */ | 9  */ | 
| 10 | 10 | 
| 11 | 11 | 
| 12 #include "vpx_ports/config.h" | 12 #include "vpx_ports/config.h" | 
| 13 #include "vp8/common/idct.h" | 13 #include "vp8/common/idct.h" | 
| 14 #include "quantize.h" | 14 #include "quantize.h" | 
| 15 #include "vp8/common/reconintra.h" | 15 #include "vp8/common/reconintra.h" | 
| 16 #include "vp8/common/reconintra4x4.h" | 16 #include "vp8/common/reconintra4x4.h" | 
| 17 #include "encodemb.h" | 17 #include "encodemb.h" | 
| 18 #include "vp8/common/invtrans.h" | 18 #include "vp8/common/invtrans.h" | 
| 19 #include "vp8/common/recon.h" | 19 #include "vp8/common/recon.h" | 
| 20 #include "dct.h" | 20 #include "dct.h" | 
| 21 #include "vp8/common/g_common.h" | 21 #include "vp8/common/g_common.h" | 
| 22 #include "encodeintra.h" | 22 #include "encodeintra.h" | 
| 23 | 23 | 
| 24 #define intra4x4ibias_rate    128 |  | 
| 25 #define intra4x4pbias_rate    256 |  | 
| 26 |  | 
| 27 | 24 | 
| 28 #if CONFIG_RUNTIME_CPU_DETECT | 25 #if CONFIG_RUNTIME_CPU_DETECT | 
| 29 #define IF_RTCD(x) (x) | 26 #define IF_RTCD(x) (x) | 
| 30 #else | 27 #else | 
| 31 #define IF_RTCD(x) NULL | 28 #define IF_RTCD(x) NULL | 
| 32 #endif | 29 #endif | 
| 33 void vp8_encode_intra4x4block(const VP8_ENCODER_RTCD *rtcd, MACROBLOCK *x, BLOCK
      *be, BLOCKD *b, int best_mode) | 30 | 
|  | 31 int vp8_encode_intra(VP8_COMP *cpi, MACROBLOCK *x, int use_dc_pred) | 
| 34 { | 32 { | 
| 35     vp8_predict_intra4x4(b, best_mode, b->predictor); | 33 | 
|  | 34     int i; | 
|  | 35     int intra_pred_var = 0; | 
|  | 36     (void) cpi; | 
|  | 37 | 
|  | 38     if (use_dc_pred) | 
|  | 39     { | 
|  | 40         x->e_mbd.mode_info_context->mbmi.mode = DC_PRED; | 
|  | 41         x->e_mbd.mode_info_context->mbmi.uv_mode = DC_PRED; | 
|  | 42         x->e_mbd.mode_info_context->mbmi.ref_frame = INTRA_FRAME; | 
|  | 43 | 
|  | 44         vp8_encode_intra16x16mby(IF_RTCD(&cpi->rtcd), x); | 
|  | 45     } | 
|  | 46     else | 
|  | 47     { | 
|  | 48         for (i = 0; i < 16; i++) | 
|  | 49         { | 
|  | 50             x->e_mbd.block[i].bmi.as_mode = B_DC_PRED; | 
|  | 51             vp8_encode_intra4x4block(IF_RTCD(&cpi->rtcd), x, i); | 
|  | 52         } | 
|  | 53     } | 
|  | 54 | 
|  | 55     intra_pred_var = VARIANCE_INVOKE(&cpi->rtcd.variance, getmbss)(x->src_diff); | 
|  | 56 | 
|  | 57     return intra_pred_var; | 
|  | 58 } | 
|  | 59 | 
|  | 60 void vp8_encode_intra4x4block(const VP8_ENCODER_RTCD *rtcd, | 
|  | 61                               MACROBLOCK *x, int ib) | 
|  | 62 { | 
|  | 63     BLOCKD *b = &x->e_mbd.block[ib]; | 
|  | 64     BLOCK *be = &x->block[ib]; | 
|  | 65 | 
|  | 66     RECON_INVOKE(&rtcd->common->recon, intra4x4_predict) | 
|  | 67                 (b, b->bmi.as_mode, b->predictor); | 
| 36 | 68 | 
| 37     ENCODEMB_INVOKE(&rtcd->encodemb, subb)(be, b, 16); | 69     ENCODEMB_INVOKE(&rtcd->encodemb, subb)(be, b, 16); | 
| 38 | 70 | 
| 39     x->vp8_short_fdct4x4(be->src_diff, be->coeff, 32); | 71     x->vp8_short_fdct4x4(be->src_diff, be->coeff, 32); | 
| 40 | 72 | 
| 41     x->quantize_b(be, b); | 73     x->quantize_b(be, b); | 
| 42 | 74 | 
| 43     vp8_inverse_transform_b(IF_RTCD(&rtcd->common->idct), b, 32); | 75     vp8_inverse_transform_b(IF_RTCD(&rtcd->common->idct), b, 32); | 
| 44 | 76 | 
| 45     RECON_INVOKE(&rtcd->common->recon, recon)(b->predictor, b->diff, *(b->base_d
     st) + b->dst, b->dst_stride); | 77     RECON_INVOKE(&rtcd->common->recon, recon)(b->predictor, b->diff, *(b->base_d
     st) + b->dst, b->dst_stride); | 
| 46 } | 78 } | 
| 47 | 79 | 
| 48 void vp8_encode_intra4x4mby(const VP8_ENCODER_RTCD *rtcd, MACROBLOCK *mb) | 80 void vp8_encode_intra4x4mby(const VP8_ENCODER_RTCD *rtcd, MACROBLOCK *mb) | 
| 49 { | 81 { | 
| 50     int i; | 82     int i; | 
| 51 | 83 | 
| 52     MACROBLOCKD *x = &mb->e_mbd; | 84     MACROBLOCKD *x = &mb->e_mbd; | 
| 53     vp8_intra_prediction_down_copy(x); | 85     vp8_intra_prediction_down_copy(x); | 
| 54 | 86 | 
| 55     for (i = 0; i < 16; i++) | 87     for (i = 0; i < 16; i++) | 
| 56     { | 88         vp8_encode_intra4x4block(rtcd, mb, i); | 
| 57         BLOCK *be = &mb->block[i]; |  | 
| 58         BLOCKD *b = &x->block[i]; |  | 
| 59 |  | 
| 60         vp8_encode_intra4x4block(rtcd, mb, be, b, b->bmi.mode); |  | 
| 61     } |  | 
| 62 |  | 
| 63     return; | 89     return; | 
| 64 } | 90 } | 
| 65 | 91 | 
| 66 void vp8_encode_intra16x16mby(const VP8_ENCODER_RTCD *rtcd, MACROBLOCK *x) | 92 void vp8_encode_intra16x16mby(const VP8_ENCODER_RTCD *rtcd, MACROBLOCK *x) | 
| 67 { | 93 { | 
| 68     int b; | 94     BLOCK *b = &x->block[0]; | 
| 69 | 95 | 
| 70     RECON_INVOKE(&rtcd->common->recon, build_intra_predictors_mby)(&x->e_mbd); | 96     RECON_INVOKE(&rtcd->common->recon, build_intra_predictors_mby)(&x->e_mbd); | 
| 71 | 97 | 
| 72     ENCODEMB_INVOKE(&rtcd->encodemb, submby)(x->src_diff, x->src.y_buffer, x->e_
     mbd.predictor, x->src.y_stride); | 98     ENCODEMB_INVOKE(&rtcd->encodemb, submby)(x->src_diff, *(b->base_src), x->e_m
     bd.predictor, b->src_stride); | 
| 73 | 99 | 
| 74     vp8_transform_intra_mby(x); | 100     vp8_transform_intra_mby(x); | 
| 75 | 101 | 
| 76     vp8_quantize_mby(x); | 102     vp8_quantize_mby(x); | 
| 77 | 103 | 
| 78 #if !(CONFIG_REALTIME_ONLY) |  | 
| 79 #if 1 |  | 
| 80     if (x->optimize) | 104     if (x->optimize) | 
| 81         vp8_optimize_mby(x, rtcd); | 105         vp8_optimize_mby(x, rtcd); | 
| 82 | 106 | 
| 83 #endif |  | 
| 84 #endif |  | 
| 85 |  | 
| 86     vp8_inverse_transform_mby(IF_RTCD(&rtcd->common->idct), &x->e_mbd); | 107     vp8_inverse_transform_mby(IF_RTCD(&rtcd->common->idct), &x->e_mbd); | 
| 87 | 108 | 
| 88     RECON_INVOKE(&rtcd->common->recon, recon_mby) | 109     RECON_INVOKE(&rtcd->common->recon, recon_mby) | 
| 89         (IF_RTCD(&rtcd->common->recon), &x->e_mbd); | 110         (IF_RTCD(&rtcd->common->recon), &x->e_mbd); | 
| 90 | 111 | 
| 91     // make sure block modes are set the way we want them for context updates |  | 
| 92     for (b = 0; b < 16; b++) |  | 
| 93     { |  | 
| 94         BLOCKD *d = &x->e_mbd.block[b]; |  | 
| 95 |  | 
| 96         switch (x->e_mbd.mode_info_context->mbmi.mode) |  | 
| 97         { |  | 
| 98 |  | 
| 99         case DC_PRED: |  | 
| 100             d->bmi.mode = B_DC_PRED; |  | 
| 101             break; |  | 
| 102         case V_PRED: |  | 
| 103             d->bmi.mode = B_VE_PRED; |  | 
| 104             break; |  | 
| 105         case H_PRED: |  | 
| 106             d->bmi.mode = B_HE_PRED; |  | 
| 107             break; |  | 
| 108         case TM_PRED: |  | 
| 109             d->bmi.mode = B_TM_PRED; |  | 
| 110             break; |  | 
| 111         default: |  | 
| 112             d->bmi.mode = B_DC_PRED; |  | 
| 113             break; |  | 
| 114 |  | 
| 115         } |  | 
| 116     } |  | 
| 117 } | 112 } | 
| 118 | 113 | 
| 119 void vp8_encode_intra16x16mbuv(const VP8_ENCODER_RTCD *rtcd, MACROBLOCK *x) | 114 void vp8_encode_intra16x16mbuv(const VP8_ENCODER_RTCD *rtcd, MACROBLOCK *x) | 
| 120 { | 115 { | 
| 121     vp8_build_intra_predictors_mbuv(&x->e_mbd); | 116     RECON_INVOKE(&rtcd->common->recon, build_intra_predictors_mbuv)(&x->e_mbd); | 
| 122 | 117 | 
| 123     ENCODEMB_INVOKE(&rtcd->encodemb, submbuv)(x->src_diff, x->src.u_buffer, x->s
     rc.v_buffer, x->e_mbd.predictor, x->src.uv_stride); | 118     ENCODEMB_INVOKE(&rtcd->encodemb, submbuv)(x->src_diff, x->src.u_buffer, x->s
     rc.v_buffer, x->e_mbd.predictor, x->src.uv_stride); | 
| 124 | 119 | 
| 125     vp8_transform_mbuv(x); | 120     vp8_transform_mbuv(x); | 
| 126 | 121 | 
| 127     vp8_quantize_mbuv(x); | 122     vp8_quantize_mbuv(x); | 
| 128 | 123 | 
| 129 #if !(CONFIG_REALTIME_ONLY) | 124     if (x->optimize) | 
| 130 #if 1 |  | 
| 131 |  | 
| 132     if (x->optimize==2 ||(x->optimize && x->rddiv > 1)) |  | 
| 133         vp8_optimize_mbuv(x, rtcd); | 125         vp8_optimize_mbuv(x, rtcd); | 
| 134 | 126 | 
| 135 #endif |  | 
| 136 #endif |  | 
| 137 |  | 
| 138     vp8_inverse_transform_mbuv(IF_RTCD(&rtcd->common->idct), &x->e_mbd); | 127     vp8_inverse_transform_mbuv(IF_RTCD(&rtcd->common->idct), &x->e_mbd); | 
| 139 | 128 | 
| 140     vp8_recon_intra_mbuv(IF_RTCD(&rtcd->common->recon), &x->e_mbd); | 129     vp8_recon_intra_mbuv(IF_RTCD(&rtcd->common->recon), &x->e_mbd); | 
| 141 } | 130 } | 
| 142 |  | 
| OLD | NEW | 
|---|