media/libvpx/vp8/encoder/rdopt.h

changeset 0
6474c204b198
     1.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
     1.2 +++ b/media/libvpx/vp8/encoder/rdopt.h	Wed Dec 31 06:09:35 2014 +0100
     1.3 @@ -0,0 +1,133 @@
     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 +#ifndef __INC_RDOPT_H
    1.16 +#define __INC_RDOPT_H
    1.17 +
    1.18 +#define RDCOST(RM,DM,R,D) ( ((128+(R)*(RM)) >> 8) + (DM)*(D) )
    1.19 +
    1.20 +static void insertsortmv(int arr[], int len)
    1.21 +{
    1.22 +    int i, j, k;
    1.23 +
    1.24 +    for ( i = 1 ; i <= len-1 ; i++ )
    1.25 +    {
    1.26 +        for ( j = 0 ; j < i ; j++ )
    1.27 +        {
    1.28 +            if ( arr[j] > arr[i] )
    1.29 +            {
    1.30 +                int temp;
    1.31 +
    1.32 +                temp = arr[i];
    1.33 +
    1.34 +                for ( k = i; k >j; k--)
    1.35 +                    arr[k] = arr[k - 1] ;
    1.36 +
    1.37 +                arr[j] = temp ;
    1.38 +            }
    1.39 +        }
    1.40 +    }
    1.41 +}
    1.42 +
    1.43 +static void insertsortsad(int arr[],int idx[], int len)
    1.44 +{
    1.45 +    int i, j, k;
    1.46 +
    1.47 +    for ( i = 1 ; i <= len-1 ; i++ )
    1.48 +    {
    1.49 +        for ( j = 0 ; j < i ; j++ )
    1.50 +        {
    1.51 +            if ( arr[j] > arr[i] )
    1.52 +            {
    1.53 +                int temp, tempi;
    1.54 +
    1.55 +                temp = arr[i];
    1.56 +                tempi = idx[i];
    1.57 +
    1.58 +                for ( k = i; k >j; k--)
    1.59 +                {
    1.60 +                    arr[k] = arr[k - 1] ;
    1.61 +                    idx[k] = idx[k - 1];
    1.62 +                }
    1.63 +
    1.64 +                arr[j] = temp ;
    1.65 +                idx[j] = tempi;
    1.66 +            }
    1.67 +        }
    1.68 +    }
    1.69 +}
    1.70 +
    1.71 +extern void vp8_initialize_rd_consts(VP8_COMP *cpi, MACROBLOCK *x, int Qvalue);
    1.72 +extern void vp8_rd_pick_inter_mode(VP8_COMP *cpi, MACROBLOCK *x, int recon_yoffset, int recon_uvoffset, int *returnrate, int *returndistortion, int *returnintra);
    1.73 +extern void vp8_rd_pick_intra_mode(MACROBLOCK *x, int *rate);
    1.74 +
    1.75 +
    1.76 +static void get_plane_pointers(const YV12_BUFFER_CONFIG *fb,
    1.77 +                               unsigned char            *plane[3],
    1.78 +                               unsigned int              recon_yoffset,
    1.79 +                               unsigned int              recon_uvoffset)
    1.80 +{
    1.81 +    plane[0] = fb->y_buffer + recon_yoffset;
    1.82 +    plane[1] = fb->u_buffer + recon_uvoffset;
    1.83 +    plane[2] = fb->v_buffer + recon_uvoffset;
    1.84 +}
    1.85 +
    1.86 +
    1.87 +static void get_predictor_pointers(const VP8_COMP *cpi,
    1.88 +                                       unsigned char  *plane[4][3],
    1.89 +                                       unsigned int    recon_yoffset,
    1.90 +                                       unsigned int    recon_uvoffset)
    1.91 +{
    1.92 +    if (cpi->ref_frame_flags & VP8_LAST_FRAME)
    1.93 +        get_plane_pointers(&cpi->common.yv12_fb[cpi->common.lst_fb_idx],
    1.94 +                           plane[LAST_FRAME], recon_yoffset, recon_uvoffset);
    1.95 +
    1.96 +    if (cpi->ref_frame_flags & VP8_GOLD_FRAME)
    1.97 +        get_plane_pointers(&cpi->common.yv12_fb[cpi->common.gld_fb_idx],
    1.98 +                           plane[GOLDEN_FRAME], recon_yoffset, recon_uvoffset);
    1.99 +
   1.100 +    if (cpi->ref_frame_flags & VP8_ALTR_FRAME)
   1.101 +        get_plane_pointers(&cpi->common.yv12_fb[cpi->common.alt_fb_idx],
   1.102 +                           plane[ALTREF_FRAME], recon_yoffset, recon_uvoffset);
   1.103 +}
   1.104 +
   1.105 +
   1.106 +static void get_reference_search_order(const VP8_COMP *cpi,
   1.107 +                                           int             ref_frame_map[4])
   1.108 +{
   1.109 +    int i=0;
   1.110 +
   1.111 +    ref_frame_map[i++] = INTRA_FRAME;
   1.112 +    if (cpi->ref_frame_flags & VP8_LAST_FRAME)
   1.113 +        ref_frame_map[i++] = LAST_FRAME;
   1.114 +    if (cpi->ref_frame_flags & VP8_GOLD_FRAME)
   1.115 +        ref_frame_map[i++] = GOLDEN_FRAME;
   1.116 +    if (cpi->ref_frame_flags & VP8_ALTR_FRAME)
   1.117 +        ref_frame_map[i++] = ALTREF_FRAME;
   1.118 +    for(; i<4; i++)
   1.119 +        ref_frame_map[i] = -1;
   1.120 +}
   1.121 +
   1.122 +
   1.123 +extern void vp8_mv_pred
   1.124 +(
   1.125 +    VP8_COMP *cpi,
   1.126 +    MACROBLOCKD *xd,
   1.127 +    const MODE_INFO *here,
   1.128 +    int_mv *mvp,
   1.129 +    int refframe,
   1.130 +    int *ref_frame_sign_bias,
   1.131 +    int *sr,
   1.132 +    int near_sadidx[]
   1.133 +);
   1.134 +void vp8_cal_sad(VP8_COMP *cpi, MACROBLOCKD *xd, MACROBLOCK *x, int recon_yoffset, int near_sadidx[]);
   1.135 +
   1.136 +#endif

mercurial