media/libvpx/vp8/encoder/encodeintra.c

Thu, 15 Jan 2015 15:59:08 +0100

author
Michael Schloh von Bennewitz <michael@schloh.com>
date
Thu, 15 Jan 2015 15:59:08 +0100
branch
TOR_BUG_9701
changeset 10
ac0c01689b40
permissions
-rw-r--r--

Implement a real Private Browsing Mode condition by changing the API/ABI;
This solves Tor bug #9701, complying with disk avoidance documented in
https://www.torproject.org/projects/torbrowser/design/#disk-avoidance.

     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  */
    12 #include "vpx_config.h"
    13 #include "vp8_rtcd.h"
    14 #include "quantize.h"
    15 #include "vp8/common/reconintra4x4.h"
    16 #include "encodemb.h"
    17 #include "vp8/common/invtrans.h"
    18 #include "encodeintra.h"
    21 int vp8_encode_intra(VP8_COMP *cpi, MACROBLOCK *x, int use_dc_pred)
    22 {
    24     int i;
    25     int intra_pred_var = 0;
    26     (void) cpi;
    28     if (use_dc_pred)
    29     {
    30         x->e_mbd.mode_info_context->mbmi.mode = DC_PRED;
    31         x->e_mbd.mode_info_context->mbmi.uv_mode = DC_PRED;
    32         x->e_mbd.mode_info_context->mbmi.ref_frame = INTRA_FRAME;
    34         vp8_encode_intra16x16mby(x);
    36         vp8_inverse_transform_mby(&x->e_mbd);
    37     }
    38     else
    39     {
    40         for (i = 0; i < 16; i++)
    41         {
    42             x->e_mbd.block[i].bmi.as_mode = B_DC_PRED;
    43             vp8_encode_intra4x4block(x, i);
    44         }
    45     }
    47     intra_pred_var = vp8_get_mb_ss(x->src_diff);
    49     return intra_pred_var;
    50 }
    52 void vp8_encode_intra4x4block(MACROBLOCK *x, int ib)
    53 {
    54     BLOCKD *b = &x->e_mbd.block[ib];
    55     BLOCK *be = &x->block[ib];
    56     int dst_stride = x->e_mbd.dst.y_stride;
    57     unsigned char *dst = x->e_mbd.dst.y_buffer + b->offset;
    58     unsigned char *Above = dst - dst_stride;
    59     unsigned char *yleft = dst - 1;
    60     unsigned char top_left = Above[-1];
    62     vp8_intra4x4_predict(Above, yleft, dst_stride, b->bmi.as_mode,
    63                          b->predictor, 16, top_left);
    65     vp8_subtract_b(be, b, 16);
    67     x->short_fdct4x4(be->src_diff, be->coeff, 32);
    69     x->quantize_b(be, b);
    71     if (*b->eob > 1)
    72     {
    73       vp8_short_idct4x4llm(b->dqcoeff, b->predictor, 16, dst, dst_stride);
    74     }
    75     else
    76     {
    77       vp8_dc_only_idct_add(b->dqcoeff[0], b->predictor, 16, dst, dst_stride);
    78     }
    79 }
    81 void vp8_encode_intra4x4mby(MACROBLOCK *mb)
    82 {
    83     int i;
    85     MACROBLOCKD *xd = &mb->e_mbd;
    86     intra_prediction_down_copy(xd, xd->dst.y_buffer - xd->dst.y_stride + 16);
    88     for (i = 0; i < 16; i++)
    89         vp8_encode_intra4x4block(mb, i);
    90     return;
    91 }
    93 void vp8_encode_intra16x16mby(MACROBLOCK *x)
    94 {
    95     BLOCK *b = &x->block[0];
    96     MACROBLOCKD *xd = &x->e_mbd;
    98     vp8_build_intra_predictors_mby_s(xd,
    99                                          xd->dst.y_buffer - xd->dst.y_stride,
   100                                          xd->dst.y_buffer - 1,
   101                                          xd->dst.y_stride,
   102                                          xd->dst.y_buffer,
   103                                          xd->dst.y_stride);
   105     vp8_subtract_mby(x->src_diff, *(b->base_src),
   106         b->src_stride, xd->dst.y_buffer, xd->dst.y_stride);
   108     vp8_transform_intra_mby(x);
   110     vp8_quantize_mby(x);
   112     if (x->optimize)
   113         vp8_optimize_mby(x);
   114 }
   116 void vp8_encode_intra16x16mbuv(MACROBLOCK *x)
   117 {
   118     MACROBLOCKD *xd = &x->e_mbd;
   120     vp8_build_intra_predictors_mbuv_s(xd, xd->dst.u_buffer - xd->dst.uv_stride,
   121                                       xd->dst.v_buffer - xd->dst.uv_stride,
   122                                       xd->dst.u_buffer - 1,
   123                                       xd->dst.v_buffer - 1,
   124                                       xd->dst.uv_stride,
   125                                       xd->dst.u_buffer, xd->dst.v_buffer,
   126                                       xd->dst.uv_stride);
   128     vp8_subtract_mbuv(x->src_diff, x->src.u_buffer,
   129         x->src.v_buffer, x->src.uv_stride, xd->dst.u_buffer,
   130         xd->dst.v_buffer, xd->dst.uv_stride);
   132     vp8_transform_mbuv(x);
   134     vp8_quantize_mbuv(x);
   136     if (x->optimize)
   137         vp8_optimize_mbuv(x);
   138 }

mercurial