OSDN Git Service

ba31364f27406f13bf38095a5ba431bf48938b56
[android-x86/hardware-intel-common-vaapi.git] / src / i965_encoder.h
1 /*
2  * Copyright © 2010 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  *
27  */
28
29 #ifndef _I965_ENCODER_H_
30 #define _I965_ENCODER_H_
31
32 #include <drm.h>
33 #include <i915_drm.h>
34 #include <intel_bufmgr.h>
35
36 #include "i965_structs.h"
37 #include "i965_drv_video.h"
38
39 #define I965_BRC_NONE                   0
40 #define I965_BRC_CBR                    1
41 #define I965_BRC_VBR                    2
42 #define I965_BRC_CQP                    3
43
44 #define WIDTH_IN_MACROBLOCKS(width)     (ALIGN(width, 16) >> 4)
45 #define HEIGHT_IN_MACROBLOCKS(height)   (ALIGN(height, 16) >> 4)
46 #define MAX_TEMPORAL_LAYERS             4
47
48 struct intel_roi
49 {
50     short left;
51     short right;
52     short top;
53     short bottom;
54
55     char  value;
56 };
57
58 struct intel_encoder_context
59 {
60     struct hw_context base;
61     int codec;
62     VASurfaceID input_yuv_surface;
63     unsigned int rate_control_mode;
64     unsigned int quality_level;
65     unsigned int quality_range;
66     unsigned int num_frames_in_sequence;
67     unsigned int frame_width_in_pixel;
68     unsigned int frame_height_in_pixel;
69
70     struct {
71         unsigned int num_layers;
72         unsigned int size_frame_layer_ids;
73         unsigned int frame_layer_ids[32];
74         unsigned int curr_frame_layer_id;
75     } layer;
76
77     struct {
78         unsigned short gop_size;
79         unsigned short num_iframes_in_gop;
80         unsigned short num_pframes_in_gop;
81         unsigned short num_bframes_in_gop;
82         unsigned int bits_per_second[MAX_TEMPORAL_LAYERS];
83         unsigned int framerate_per_100s[MAX_TEMPORAL_LAYERS];
84         unsigned int hrd_buffer_size;
85         unsigned int hrd_initial_buffer_fullness;
86         unsigned int need_reset;
87     } brc;
88
89     void *vme_context;
90     void *mfc_context;
91     void *enc_priv_state;
92
93     unsigned int is_tmp_id:1;
94     unsigned int low_power_mode:1;
95     unsigned int soft_batch_force:1;
96     unsigned int context_roi:1;
97     unsigned int is_new_sequence:1; /* Currently only valid for H.264, TODO for other codecs */
98
99     void (*vme_context_destroy)(void *vme_context);
100     VAStatus (*vme_pipeline)(VADriverContextP ctx,
101                              VAProfile profile,
102                              struct encode_state *encode_state,
103                              struct intel_encoder_context *encoder_context);
104     void (*mfc_context_destroy)(void *mfc_context);
105     VAStatus (*mfc_pipeline)(VADriverContextP ctx,
106                              VAProfile profile,
107                              struct encode_state *encode_state,
108                              struct intel_encoder_context *encoder_context);
109     void (*mfc_brc_prepare)(struct encode_state *encode_state,
110                             struct intel_encoder_context *encoder_context);
111
112     VAStatus (*get_status)(VADriverContextP ctx,
113                            struct intel_encoder_context *encoder_context,
114                            struct i965_coded_buffer_segment *coded_buffer_segment);
115 };
116
117 extern struct hw_context *
118 gen75_enc_hw_context_init(VADriverContextP ctx, struct object_config *obj_config);
119
120 extern struct hw_context *
121 gen8_enc_hw_context_init(VADriverContextP ctx, struct object_config *obj_config);
122
123 extern struct hw_context *
124 gen9_enc_hw_context_init(VADriverContextP ctx, struct object_config *obj_config);
125 #endif  /* _I965_ENCODER_H_ */
126
127