summaryrefslogtreecommitdiff
path: root/va/va_enc_vp8.h
blob: 56dda848a5257046d91bb2b043e1b84227bb43e4 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
/*
 * Copyright (c) 2007-2012 Intel Corporation. All Rights Reserved.
 *
 * Permission is hereby granted, free of charge, to any person obtaining a
 * copy of this software and associated documentation files (the
 * "Software"), to deal in the Software without restriction, including
 * without limitation the rights to use, copy, modify, merge, publish,
 * distribute, sub license, and/or sell copies of the Software, and to
 * permit persons to whom the Software is furnished to do so, subject to
 * the following conditions:
 *
 * The above copyright notice and this permission notice (including the
 * next paragraph) shall be included in all copies or substantial portions
 * of the Software.
 *
 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
 * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
 * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT.
 * IN NO EVENT SHALL INTEL AND/OR ITS SUPPLIERS BE LIABLE FOR
 * ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
 * TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
 * SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
 */

/**
 * \file va_enc_vp8.h
 * \brief VP8 encoding API
 *
 * This file contains the \ref api_enc_vp8 "VP8 encoding API".
 */

#ifndef VA_ENC_VP8_H
#define VA_ENC_VP8_H

#ifdef __cplusplus
extern "C" {
#endif

/**
 * \defgroup api_enc_vp8 VP8 encoding API
 *
 * @{
 */

/**
 * \brief VP8 Encoding Sequence Parameter Buffer Structure
 *
 * This structure conveys sequence level parameters.
 *
 */
typedef struct  _VAEncSequenceParameterBufferVP8
{
    /* frame width in pixels */
    unsigned int frame_width;
    /* frame height in pixels */
    unsigned int frame_height;
    /* horizontal scale */
    unsigned int frame_width_scale;
    /* vertical scale */
    unsigned int frame_height_scale;

    /* whether to enable error resilience features */
    unsigned int error_resilient;
    /* auto keyframe placement, non-zero means enable auto keyframe placement */
    unsigned int kf_auto;
    /* keyframe minimum interval */
    unsigned int kf_min_dist;
    /* keyframe maximum interval */
    unsigned int kf_max_dist;


    /* RC related fields. RC modes are set with VAConfigAttribRateControl */
    /* For VP8, CBR implies HRD conformance and VBR implies no HRD conformance */

    /**
     * Initial bitrate set for this sequence in CBR or VBR modes.
     *
     * This field represents the initial bitrate value for this
     * sequence if CBR or VBR mode is used, i.e. if the encoder
     * pipeline was created with a #VAConfigAttribRateControl
     * attribute set to either \ref VA_RC_CBR or \ref VA_RC_VBR.
     *
     * The bitrate can be modified later on through
     * #VAEncMiscParameterRateControl buffers.
     */
    unsigned int bits_per_second;
    /* Period between I frames. */
    unsigned int intra_period;

    /* reference and reconstructed frame buffers
     * Used for driver auto reference management when configured through 
     * VAConfigAttribEncAutoReference. 
     */
    VASurfaceID reference_frames[4];

} VAEncSequenceParameterBufferVP8;


/**
 * \brief VP8 Encoding Picture Parameter Buffer Structure
 *
 * This structure conveys picture level parameters.
 *
 */
typedef struct  _VAEncPictureParameterBufferVP8
{
    /* surface to store reconstructed frame  */
    VASurfaceID reconstructed_frame;

    /* 
     * surfaces to store reference frames in non auto reference mode
     * VA_INVALID_SURFACE can be used to denote an invalid reference frame. 
     */
    VASurfaceID ref_last_frame;
    VASurfaceID ref_gf_frame;
    VASurfaceID ref_arf_frame;

    /* buffer to store coded data */
    VABufferID coded_buf;

    union {
        struct {
            /* force this frame to be a keyframe */
            unsigned int force_kf                       : 1;
            /* don't reference the last frame */
            unsigned int no_ref_last                    : 1;
            /* don't reference the golden frame */
            unsigned int no_ref_gf                      : 1;
            /* don't reference the alternate reference frame */
            unsigned int no_ref_arf                     : 1;
            unsigned int reserved                       : 28;
        } bits;
        unsigned int value;
    } ref_flags;

    union {
        struct {
            /* version */
            unsigned int version                        : 3;
            /* show_frame */
            unsigned int show_frame                     : 1;
            /* color_space */						   
            unsigned int color_space                    : 1;
            /*  0: bicubic, 1: bilinear, other: none */
            unsigned int recon_filter_type              : 2;
            /*  0: no loop fitler, 1: simple loop filter */
            unsigned int loop_filter_type               : 2;
            /* 0: disabled, 1: normal, 2: simple */
            unsigned int auto_partitions                : 1;
            /* number of token partitions */
            unsigned int num_token_partitions           : 2;

            /** 
             * The following fields correspond to the same VP8 syntax elements 
             * in the frame header.
             */
	    /**
             * 0: clamping of reconstruction pixels is disabled,
             * 1: clamping enabled.
             */
            unsigned int clamping_type                  : 1;
            /* indicate segmentation is enabled for the current frame. */
            unsigned int segmentation_enabled           : 1;
            /**
             * Determines if the MB segmentation map is updated in the current 
             * frame.
             */
            unsigned int update_mb_segmentation_map     : 1;
            /**
             * Indicates if the segment feature data is updated in the current 
             * frame.
             */
            unsigned int update_segment_feature_data    : 1;
            /**
             * indicates if the MB level loop filter adjustment is enabled for 
             * the current frame (0 off, 1 on).  
             */
	    unsigned int loop_filter_adj_enable         : 1;
            /**
             * Determines whether updated token probabilities are used only for 
             * this frame or until further update. 
             * It may be used by application to enable error resilient mode. 
             * In this mode probability updates are allowed only at Key Frames.
             */
            unsigned int refresh_entropy_probs          : 1;
            /**
             * Determines if the current decoded frame refreshes the golden frame.
             */
            unsigned int refresh_golden_frame           : 1;
            /** 
             * Determines if the current decoded frame refreshes the alternate 
             * reference frame.
             */
            unsigned int refresh_alternate_frame        : 1;
            /**
             * Determines if the current decoded frame refreshes the last frame 
             * reference buffer.
             */
            unsigned int refresh_last                   : 1;
            /**
             * Determines if the golden reference is replaced by another reference.
             */
            unsigned int copy_buffer_to_golden          : 2;
            /**
             * Determines if the alternate reference is replaced by another reference.
             */
            unsigned int copy_buffer_to_alternate       : 2;
            /** 
             * Controls the sign of motion vectors when the golden frame is referenced.  
             */
            unsigned int sign_bias_golden               : 1;
            /**
             * Controls the sign of motion vectors when the alternate frame is 
             * referenced. 
             */
	    unsigned int sign_bias_alternate            : 1;
            /**
             * Enables or disables the skipping of macroblocks containing no 
             * non-zero coefficients. 
             */
	    unsigned int mb_no_coeff_skip               : 1;
            /** 
             * Enforces unconditional per-MB loop filter delta update setting frame 
             * header flags mode_ref_lf_delta_update, all mb_mode_delta_update_flag[4], 
             * and all ref_frame_delta_update_flag[4] to 1. 
	     * Since loop filter deltas are not automatically refreshed to default 
             * values at key frames, dropped frame with delta update may prevent 
             * correct decoding from the next key frame. 
	     * Encoder application is advised to set this flag to 1 at key frames.
	     */
            unsigned int forced_lf_adjustment           : 1;
	    unsigned int reserved                       : 3;
        } bits;
        unsigned int value;
    } pic_flags;

    /**
     * Contains a list of 4 loop filter level values (updated value if applicable)
     * controlling the deblocking filter strength. Each entry represents a segment.
     * When segmentation is disabled, use entry 0. 
     * When loop_filter_level is 0, loop filter shall be disabled. 
     */
    char loop_filter_level[4];

    /** 
     * Contains a list of 4 delta values for reference frame based MB-level 
     * loop filter adjustment.  
     * If no update, then set to 0.
     */
    char ref_lf_delta[4];

    /**
     * Contains a list of 4 delta values for coding mode based MB-level loop
     * filter adjustment.  
     * If no update, then set to 0. 
     */
    char mode_lf_delta[4];
	
    /**
     * Controls the deblocking filter sensitivity. 
     * Corresponds to the same VP8 syntax element in frame header.
     */
    unsigned char sharpness_level;
	
    /** 
     * Application supplied maximum clamp value for Qindex used in quantization.  
     * Qindex will not be allowed to exceed this value.  
     * It has a valid range [0..127] inclusive.  
     */
    unsigned char clamp_qindex_high;
	
    /**
     * Application supplied minimum clamp value for Qindex used in quantization.  
     * Qindex will not be allowed to be lower than this value.  
     * It has a valid range [0..127] inclusive.  
     * Condition clamp_qindex_low <= clamp_qindex_high must be guaranteed, 
     * otherwise they are ignored. 
     */
    unsigned char clamp_qindex_low;
	
} VAEncPictureParameterBufferVP8;


/**
 * \brief VP8 MB Segmentation ID Buffer
 *
 * application provides buffer containing the initial segmentation id for each 
 * MB, in raster scan order. Rate control may reassign it.
 * For an 640x480 video, the buffer has 1200 entries. 
 * the value of each entry should be in the range [0..3], inclusive.
 * If segmentation is not enabled, application does not need to provide it. 
 */
typedef struct _VAEncMBMapBufferVP8
{
    /** 
     * number of MBs in the frame.
     * It is also the number of entries of mb_segment_id[];
     */
    unsigned int num_mbs;
    /**
     * per MB Segmentation ID Buffer
     */
    unsigned char *mb_segment_id;
} VAEncMBMapBufferVP8;


/**
 * \brief VP8 Quantization Matrix Buffer Structure
 *
 * Contains quantization index for yac(0-3) for each segment and quantization 
 * index deltas, ydc(0), y2dc(1), y2ac(2), uvdc(3), uvac(4) that are applied 
 * to all segments.  When segmentation is disabled, only quantization_index[0] 
 * will be used. This structure is sent once per frame.
 */
typedef struct _VAQMatrixBufferVP8
{
    unsigned short quantization_index[4];
    short quantization_index_delta[5];
} VAQMatrixBufferVP8;



/**@}*/

#ifdef __cplusplus
}
#endif

#endif /* VA_ENC_VP8_H */