Synced gen7 with gen6 for HRD.
[profile/ivi/vaapi-intel-driver.git] / src / gen7_mfc.h
1 /*
2  * Copyright © 2011 Intel Corporation
3  *
4  * Permission is hereby granted, free of charge, to any person obtaining a
5  * copy of this software and associated documentation files (the
6  * "Software"), to deal in the Software without restriction, including
7  * without limitation the rights to use, copy, modify, merge, publish,
8  * distribute, sub license, and/or sell copies of the Software, and to
9  * permit persons to whom the Software is furnished to do so, subject to
10  * the following conditions:
11  *
12  * The above copyright notice and this permission notice (including the
13  * next paragraph) shall be included in all copies or substantial portions
14  * of the Software.
15  *
16  * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
17  * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
18  * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT.
19  * IN NO EVENT SHALL PRECISION INSIGHT AND/OR ITS SUPPLIERS BE LIABLE FOR
20  * ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
21  * TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
22  * SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
23  *
24  * Authors:
25  *    Zhou Chang <chang.zhou@intel.com>
26  *    Xiang, Haihao <haihao.xiang@intel.com>
27  *
28  */
29
30 #ifndef _GEN7_MFC_H_
31 #define _GEN7_MFC_H_
32
33 #include <drm.h>
34 #include <i915_drm.h>
35 #include <intel_bufmgr.h>
36
37 struct encode_state;
38
39 #define MAX_MFC_REFERENCE_SURFACES      16
40 #define NUM_MFC_DMV_BUFFERS             34
41
42 struct gen7_mfc_avc_surface_aux
43 {
44     dri_bo *dmv_top;
45     dri_bo *dmv_bottom;
46 };
47
48 struct gen7_mfc_context
49 {
50     struct {
51         unsigned int width;
52         unsigned int height;
53         unsigned int w_pitch;
54         unsigned int h_pitch;
55     } surface_state;
56
57     //MFX_PIPE_BUF_ADDR_STATE
58     struct {
59         dri_bo *bo;                             
60     } post_deblocking_output;           //OUTPUT: reconstructed picture                           
61     
62     struct {  
63         dri_bo *bo;                                                             
64     } pre_deblocking_output;            //OUTPUT: reconstructed picture with deblocked                           
65
66     struct {
67         dri_bo *bo;
68     } uncompressed_picture_source;      //INPUT: original compressed image
69
70     struct {
71         dri_bo *bo;                                                             
72     } intra_row_store_scratch_buffer;   //INTERNAL:
73
74     struct {
75         dri_bo *bo;
76     } macroblock_status_buffer;         //INTERNAL:
77
78     struct {
79         dri_bo *bo;                                                             
80     } deblocking_filter_row_store_scratch_buffer;       //INTERNAL:
81
82     struct {                                    
83         dri_bo *bo; 
84     } reference_surfaces[MAX_MFC_REFERENCE_SURFACES];   //INTERNAL: refrence surfaces
85
86     //MFX_IND_OBJ_BASE_ADDR_STATE
87     struct{
88         dri_bo *bo;
89     } mfc_indirect_mv_object;           //INPUT: the blocks' mv info
90
91     struct {
92         dri_bo *bo;
93         int offset;
94         int end_offset;
95     } mfc_indirect_pak_bse_object;      //OUTPUT: the compressed bitstream 
96
97     //MFX_BSP_BUF_BASE_ADDR_STATE
98     struct {
99         dri_bo *bo;
100     } bsd_mpc_row_store_scratch_buffer; //INTERNAL:
101         
102     //MFX_AVC_DIRECTMODE_STATE
103     struct {
104         dri_bo *bo;
105     } direct_mv_buffers[NUM_MFC_DMV_BUFFERS];   //INTERNAL: 0-31 as input,32 and 33 as output
106
107     //Bit rate tracking context
108     struct {
109         unsigned int QpPrimeY;
110         unsigned int MaxQpNegModifier;
111         unsigned int MaxQpPosModifier;
112         unsigned char MaxSizeInWord;
113         unsigned char TargetSizeInWord;
114         unsigned char Correct[6];
115         unsigned char GrowInit;
116         unsigned char GrowResistance;
117         unsigned char ShrinkInit;
118         unsigned char ShrinkResistance; 
119
120         unsigned int target_mb_size;
121         unsigned int target_frame_size;
122     } bit_rate_control_context[2];      //INTERNAL: 0 for intra frames, 1 for inter frames.
123
124     //HRD control context
125     struct {
126         int i_bit_rate_value;
127         int i_cpb_size_value;
128
129         int i_initial_cpb_removal_delay;
130         int i_cpb_removal_delay;
131
132         int i_frame_number;
133
134         int i_initial_cpb_removal_delay_length;
135         int i_cpb_removal_delay_length;
136         int i_dpb_output_delay_length;
137     }vui_hrd;
138
139 };
140
141 #endif  /* _GEN7_MFC_BCS_H_ */