00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
00024
00025
00026 #ifndef AVCODEC_VP8_H
00027 #define AVCODEC_VP8_H
00028
00029 #include "vp56.h"
00030 #include "vp56data.h"
00031 #include "vp8dsp.h"
00032 #include "h264pred.h"
00033 #if HAVE_PTHREADS
00034 #include <pthread.h>
00035 #elif HAVE_W32THREADS
00036 #include "w32pthreads.h"
00037 #endif
00038
00039 #define VP8_MAX_QUANT 127
00040
00041 enum dct_token {
00042 DCT_0,
00043 DCT_1,
00044 DCT_2,
00045 DCT_3,
00046 DCT_4,
00047 DCT_CAT1,
00048 DCT_CAT2,
00049 DCT_CAT3,
00050 DCT_CAT4,
00051 DCT_CAT5,
00052 DCT_CAT6,
00053 DCT_EOB,
00054
00055 NUM_DCT_TOKENS
00056 };
00057
00058
00059 #define MODE_I4x4 4
00060
00061 enum inter_mvmode {
00062 VP8_MVMODE_ZERO = MODE_I4x4 + 1,
00063 VP8_MVMODE_MV,
00064 VP8_MVMODE_SPLIT
00065 };
00066
00067 enum inter_splitmvmode {
00068 VP8_SPLITMVMODE_16x8 = 0,
00069 VP8_SPLITMVMODE_8x16,
00070 VP8_SPLITMVMODE_8x8,
00071 VP8_SPLITMVMODE_4x4,
00072 VP8_SPLITMVMODE_NONE,
00073 };
00074
00075 typedef struct {
00076 uint8_t filter_level;
00077 uint8_t inner_limit;
00078 uint8_t inner_filter;
00079 } VP8FilterStrength;
00080
00081 typedef struct {
00082 uint8_t skip;
00083
00084
00085 uint8_t mode;
00086 uint8_t ref_frame;
00087 uint8_t partitioning;
00088 uint8_t chroma_pred_mode;
00089 uint8_t segment;
00090 uint8_t intra4x4_pred_mode_mb[16];
00091 uint8_t intra4x4_pred_mode_top[4];
00092 VP56mv mv;
00093 VP56mv bmv[16];
00094 } VP8Macroblock;
00095
00096 typedef struct {
00097 DECLARE_ALIGNED(16, DCTELEM, block)[6][4][16];
00098 DECLARE_ALIGNED(16, DCTELEM, block_dc)[16];
00106 DECLARE_ALIGNED(16, uint8_t, non_zero_count_cache)[6][4];
00113 DECLARE_ALIGNED(8, uint8_t, left_nnz)[9];
00114 int thread_nr;
00115 #if HAVE_THREADS
00116 pthread_mutex_t lock;
00117 pthread_cond_t cond;
00118 #endif
00119 int thread_mb_pos;
00120 int wait_mb_pos;
00121 uint8_t *edge_emu_buffer;
00122 VP8FilterStrength *filter_strength;
00123 } VP8ThreadData;
00124
00125 #define MAX_THREADS 8
00126 typedef struct {
00127 VP8ThreadData *thread_data;
00128 AVCodecContext *avctx;
00129 AVFrame *framep[4];
00130 AVFrame *next_framep[4];
00131 AVFrame *curframe;
00132 AVFrame *prev_frame;
00133
00134 uint16_t mb_width;
00135 uint16_t mb_height;
00136 int linesize;
00137 int uvlinesize;
00138
00139 uint8_t keyframe;
00140 uint8_t deblock_filter;
00141 uint8_t mbskip_enabled;
00142 uint8_t profile;
00143 VP56mv mv_min;
00144 VP56mv mv_max;
00145
00146 int8_t sign_bias[4];
00147 int ref_count[3];
00148
00154 struct {
00155 uint8_t enabled;
00156 uint8_t absolute_vals;
00157 uint8_t update_map;
00158 int8_t base_quant[4];
00159 int8_t filter_level[4];
00160 } segmentation;
00161
00162 struct {
00163 uint8_t simple;
00164 uint8_t level;
00165 uint8_t sharpness;
00166 } filter;
00167
00168 VP8Macroblock *macroblocks;
00169
00170 uint8_t *intra4x4_pred_mode_top;
00171 uint8_t intra4x4_pred_mode_left[4];
00172
00178 struct {
00179
00180 int16_t luma_qmul[2];
00181 int16_t luma_dc_qmul[2];
00182 int16_t chroma_qmul[2];
00183 } qmat[4];
00184
00185 struct {
00186 uint8_t enabled;
00187
00197 int8_t mode[VP8_MVMODE_SPLIT+1];
00198
00206 int8_t ref[4];
00207 } lf_delta;
00208
00209 uint8_t (*top_border)[16+8+8];
00210 uint8_t (*top_nnz)[9];
00211
00212 VP56RangeCoder c;
00213
00220 struct {
00221 uint8_t segmentid[3];
00222 uint8_t mbskip;
00223 uint8_t intra;
00224 uint8_t last;
00225 uint8_t golden;
00226 uint8_t pred16x16[4];
00227 uint8_t pred8x8c[3];
00228 uint8_t token[4][16][3][NUM_DCT_TOKENS-1];
00229 uint8_t mvc[2][19];
00230 } prob[2];
00231
00232 VP8Macroblock *macroblocks_base;
00233 int invisible;
00234 int update_last;
00235 int update_golden;
00236 int update_altref;
00237
00242 int update_probabilities;
00243
00248 int num_coeff_partitions;
00249 VP56RangeCoder coeff_partition[8];
00250 DSPContext dsp;
00251 VP8DSPContext vp8dsp;
00252 H264PredContext hpc;
00253 vp8_mc_func put_pixels_tab[3][3][3];
00254 AVFrame frames[5];
00255
00262 uint8_t *segmentation_maps[5];
00263 int num_maps_to_be_freed;
00264 int maps_are_invalid;
00265 int num_jobs;
00271 int mb_layout;
00272 } VP8Context;
00273
00274 #endif