Home | History | Annotate | Download | only in common
      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 
     12 #ifndef __INC_VP8C_INT_H
     13 #define __INC_VP8C_INT_H
     14 
     15 #include "vpx_config.h"
     16 #include "vpx_rtcd.h"
     17 #include "vpx/internal/vpx_codec_internal.h"
     18 #include "loopfilter.h"
     19 #include "entropymv.h"
     20 #include "entropy.h"
     21 #if CONFIG_POSTPROC
     22 #include "postproc.h"
     23 #endif
     24 
     25 /*#ifdef PACKET_TESTING*/
     26 #include "header.h"
     27 /*#endif*/
     28 
     29 #define MINQ 0
     30 #define MAXQ 127
     31 #define QINDEX_RANGE (MAXQ + 1)
     32 
     33 #define NUM_YV12_BUFFERS 4
     34 
     35 #define MAX_PARTITIONS 9
     36 
     37 typedef struct frame_contexts
     38 {
     39     vp8_prob bmode_prob [VP8_BINTRAMODES-1];
     40     vp8_prob ymode_prob [VP8_YMODES-1];   /* interframe intra mode probs */
     41     vp8_prob uv_mode_prob [VP8_UV_MODES-1];
     42     vp8_prob sub_mv_ref_prob [VP8_SUBMVREFS-1];
     43     vp8_prob coef_probs [BLOCK_TYPES] [COEF_BANDS] [PREV_COEF_CONTEXTS] [ENTROPY_NODES];
     44     MV_CONTEXT mvc[2];
     45 } FRAME_CONTEXT;
     46 
     47 typedef enum
     48 {
     49     ONE_PARTITION  = 0,
     50     TWO_PARTITION  = 1,
     51     FOUR_PARTITION = 2,
     52     EIGHT_PARTITION = 3
     53 } TOKEN_PARTITION;
     54 
     55 typedef enum
     56 {
     57     RECON_CLAMP_REQUIRED        = 0,
     58     RECON_CLAMP_NOTREQUIRED     = 1
     59 } CLAMP_TYPE;
     60 
     61 typedef struct VP8Common
     62 
     63 {
     64     struct vpx_internal_error_info  error;
     65 
     66     DECLARE_ALIGNED(16, short, Y1dequant[QINDEX_RANGE][2]);
     67     DECLARE_ALIGNED(16, short, Y2dequant[QINDEX_RANGE][2]);
     68     DECLARE_ALIGNED(16, short, UVdequant[QINDEX_RANGE][2]);
     69 
     70     int Width;
     71     int Height;
     72     int horiz_scale;
     73     int vert_scale;
     74 
     75     YUV_TYPE clr_type;
     76     CLAMP_TYPE  clamp_type;
     77 
     78     YV12_BUFFER_CONFIG *frame_to_show;
     79 
     80     YV12_BUFFER_CONFIG yv12_fb[NUM_YV12_BUFFERS];
     81     int fb_idx_ref_cnt[NUM_YV12_BUFFERS];
     82     int new_fb_idx, lst_fb_idx, gld_fb_idx, alt_fb_idx;
     83 
     84     YV12_BUFFER_CONFIG temp_scale_frame;
     85 
     86 #if CONFIG_POSTPROC
     87     YV12_BUFFER_CONFIG post_proc_buffer;
     88     YV12_BUFFER_CONFIG post_proc_buffer_int;
     89     int post_proc_buffer_int_used;
     90     unsigned char *pp_limits_buffer;   /* post-processing filter coefficients */
     91 #endif
     92 
     93     FRAME_TYPE last_frame_type;  /* Save last frame's frame type for motion search. */
     94     FRAME_TYPE frame_type;
     95 
     96     int show_frame;
     97 
     98     int frame_flags;
     99     int MBs;
    100     int mb_rows;
    101     int mb_cols;
    102     int mode_info_stride;
    103 
    104     /* profile settings */
    105     int mb_no_coeff_skip;
    106     int no_lpf;
    107     int use_bilinear_mc_filter;
    108     int full_pixel;
    109 
    110     int base_qindex;
    111 
    112     int y1dc_delta_q;
    113     int y2dc_delta_q;
    114     int y2ac_delta_q;
    115     int uvdc_delta_q;
    116     int uvac_delta_q;
    117 
    118     unsigned int frames_since_golden;
    119     unsigned int frames_till_alt_ref_frame;
    120 
    121     /* We allocate a MODE_INFO struct for each macroblock, together with
    122        an extra row on top and column on the left to simplify prediction. */
    123 
    124     MODE_INFO *mip; /* Base of allocated array */
    125     MODE_INFO *mi;  /* Corresponds to upper left visible macroblock */
    126 #if CONFIG_ERROR_CONCEALMENT
    127     MODE_INFO *prev_mip; /* MODE_INFO array 'mip' from last decoded frame */
    128     MODE_INFO *prev_mi;  /* 'mi' from last frame (points into prev_mip) */
    129 #endif
    130 
    131     LOOPFILTERTYPE filter_type;
    132 
    133     loop_filter_info_n lf_info;
    134 
    135     int filter_level;
    136     int last_sharpness_level;
    137     int sharpness_level;
    138 
    139     int refresh_last_frame;       /* Two state 0 = NO, 1 = YES */
    140     int refresh_golden_frame;     /* Two state 0 = NO, 1 = YES */
    141     int refresh_alt_ref_frame;     /* Two state 0 = NO, 1 = YES */
    142 
    143     int copy_buffer_to_gf;         /* 0 none, 1 Last to GF, 2 ARF to GF */
    144     int copy_buffer_to_arf;        /* 0 none, 1 Last to ARF, 2 GF to ARF */
    145 
    146     int refresh_entropy_probs;    /* Two state 0 = NO, 1 = YES */
    147 
    148     int ref_frame_sign_bias[MAX_REF_FRAMES];    /* Two state 0, 1 */
    149 
    150     /* Y,U,V,Y2 */
    151     ENTROPY_CONTEXT_PLANES *above_context;   /* row of context for each plane */
    152     ENTROPY_CONTEXT_PLANES left_context;  /* (up to) 4 contexts "" */
    153 
    154     FRAME_CONTEXT lfc; /* last frame entropy */
    155     FRAME_CONTEXT fc;  /* this frame entropy */
    156 
    157     unsigned int current_video_frame;
    158 
    159     int near_boffset[3];
    160     int version;
    161 
    162     TOKEN_PARTITION multi_token_partition;
    163 
    164 #ifdef PACKET_TESTING
    165     VP8_HEADER oh;
    166 #endif
    167     double bitrate;
    168     double framerate;
    169 
    170 #if CONFIG_MULTITHREAD
    171     int processor_core_count;
    172 #endif
    173 #if CONFIG_POSTPROC
    174     struct postproc_state  postproc_state;
    175 #endif
    176     int cpu_caps;
    177 } VP8_COMMON;
    178 
    179 #endif
    180