2 * Copyright © 2011 Intel Corporation
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:
12 * The above copyright notice and this permission notice (including the
13 * next paragraph) shall be included in all copies or substantial portions
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.
25 * Li Xiaowei <xiaowei.a.li@intel.com>
32 #include "intel_batchbuffer.h"
33 #include "intel_driver.h"
34 #include "i965_defines.h"
35 #include "i965_structs.h"
37 #include "i965_drv_video.h"
38 #include "i965_post_processing.h"
39 #include "gen75_picture_process.h"
42 i965_proc_picture(VADriverContextP ctx,
44 union codec_state *codec_state,
45 struct hw_context *hw_context);
48 gen75_vpp_fmt_cvt(VADriverContextP ctx,
50 union codec_state *codec_state,
51 struct hw_context *hw_context)
53 VAStatus va_status = VA_STATUS_SUCCESS;
54 struct intel_video_process_context *proc_ctx =
55 (struct intel_video_process_context *)hw_context;
57 /* implicity surface format coversion and scaling */
58 if(proc_ctx->vpp_fmt_cvt_ctx == NULL){
59 proc_ctx->vpp_fmt_cvt_ctx = i965_proc_context_init(ctx, NULL);
62 i965_proc_picture(ctx, profile, codec_state,
63 (struct hw_context *) proc_ctx->vpp_fmt_cvt_ctx);
69 gen75_vpp_vebox(VADriverContextP ctx,
70 struct intel_video_process_context* proc_ctx)
72 VAStatus va_status = VA_STATUS_SUCCESS;
73 VAProcPipelineParameterBuffer* pipeline_param = proc_ctx->pipeline_param;
75 /* vpp features based on VEBox fixed function */
76 if(proc_ctx->vpp_vebox_ctx == NULL) {
77 proc_ctx->vpp_vebox_ctx = gen75_vebox_context_init(ctx);
80 proc_ctx->vpp_vebox_ctx->pipeline_param = pipeline_param;
81 proc_ctx->vpp_vebox_ctx->surface_input = pipeline_param->surface;
82 proc_ctx->vpp_vebox_ctx->surface_output = proc_ctx->surface_render_output;
84 va_status = gen75_vebox_process_picture(ctx, proc_ctx->vpp_vebox_ctx);
90 gen75_vpp_gpe(VADriverContextP ctx,
91 struct intel_video_process_context* proc_ctx)
93 VAStatus va_status = VA_STATUS_SUCCESS;
95 if(proc_ctx->vpp_gpe_ctx == NULL){
96 proc_ctx->vpp_gpe_ctx = gen75_gpe_context_init(ctx);
99 proc_ctx->vpp_gpe_ctx->pipeline_param = proc_ctx->pipeline_param;
100 proc_ctx->vpp_gpe_ctx->surface_output = proc_ctx->surface_render_output;
102 va_status = gen75_gpe_process_picture(ctx, proc_ctx->vpp_gpe_ctx);
108 gen75_proc_picture(VADriverContextP ctx,
110 union codec_state *codec_state,
111 struct hw_context *hw_context)
113 struct i965_driver_data *i965 = i965_driver_data(ctx);
114 struct proc_state* proc_st = &(codec_state->proc);
115 struct intel_video_process_context *proc_ctx =
116 (struct intel_video_process_context *)hw_context;
117 VAProcPipelineParameterBuffer *pipeline_param =
118 (VAProcPipelineParameterBuffer *)proc_st->pipeline_param->buffer;
120 proc_ctx->pipeline_param = pipeline_param;
121 proc_ctx->surface_render_output = proc_st->current_render_target;
123 assert(proc_ctx->surface_render_output != VA_INVALID_SURFACE);
125 struct object_surface * obj_dst_surf = SURFACE(proc_ctx->surface_render_output);
126 if(!obj_dst_surf->bo){
127 unsigned int is_tiled = 0;
128 unsigned int fourcc = VA_FOURCC('N','V','1','2');
129 int sampling = SUBSAMPLE_YUV420;
130 i965_check_alloc_surface_bo(ctx, obj_dst_surf, is_tiled, fourcc, sampling);
133 assert(pipeline_param->num_filters <= 4);
135 VABufferID *filter_id = (VABufferID*) pipeline_param->filters;
137 if(pipeline_param->num_filters == 0 || pipeline_param->filters == NULL ){
138 /* implicity surface format coversion and scaling */
139 gen75_vpp_fmt_cvt(ctx, profile, codec_state, hw_context);
140 }else if(pipeline_param->num_filters == 1) {
141 struct object_buffer * obj_buf = BUFFER((*filter_id) + 0);
142 VAProcFilterParameterBuffer* filter =
143 (VAProcFilterParameterBuffer*)obj_buf-> buffer_store->buffer;
145 if(filter->type == VAProcFilterNone){
146 gen75_vpp_fmt_cvt(ctx, profile, codec_state, hw_context);
147 } else if(filter->type == VAProcFilterNoiseReduction ||
148 filter->type == VAProcFilterDeinterlacing ||
149 filter->type == VAProcFilterColorBalance){
150 gen75_vpp_vebox(ctx, proc_ctx);
151 }else if(filter->type == VAProcFilterSharpening){
152 struct object_surface *obj_src_surf = SURFACE(proc_ctx->pipeline_param->surface);
153 assert(obj_src_surf->fourcc == VA_FOURCC('N','V','1','2') &&
154 obj_dst_surf->fourcc == VA_FOURCC('N','V','1','2'));
155 gen75_vpp_gpe(ctx, proc_ctx);
157 }else if (pipeline_param->num_filters >= 2) {
159 for (i = 0; i < pipeline_param->num_filters; i++){
160 struct object_buffer * obj_buf = BUFFER(pipeline_param->filters[i]);
161 VAProcFilterParameterBuffer* filter =
162 (VAProcFilterParameterBuffer*)obj_buf-> buffer_store->buffer;
164 if (filter->type != VAProcFilterNoiseReduction &&
165 filter->type != VAProcFilterDeinterlacing &&
166 filter->type != VAProcFilterColorBalance &&
167 filter->type != VAProcFilterNone ){
168 printf("Do not support multiply filters outside vebox pipeline \n");
172 gen75_vpp_vebox(ctx, proc_ctx);
177 gen75_proc_context_destroy(void *hw_context)
179 struct intel_video_process_context *proc_ctx =
180 (struct intel_video_process_context *)hw_context;
181 VADriverContextP ctx = (VADriverContextP)(proc_ctx->driver_context);
183 if(proc_ctx->vpp_fmt_cvt_ctx){
184 proc_ctx->vpp_fmt_cvt_ctx->base.destroy(proc_ctx->vpp_fmt_cvt_ctx);
185 proc_ctx->vpp_fmt_cvt_ctx = NULL;
188 if(proc_ctx->vpp_vebox_ctx){
189 gen75_vebox_context_destroy(ctx,proc_ctx->vpp_vebox_ctx);
190 proc_ctx->vpp_vebox_ctx = NULL;
193 if(proc_ctx->vpp_gpe_ctx){
194 gen75_gpe_context_destroy(ctx,proc_ctx->vpp_gpe_ctx);
195 proc_ctx->vpp_gpe_ctx = NULL;
202 gen75_proc_context_init(VADriverContextP ctx,
203 struct object_config *obj_config)
205 struct intel_video_process_context *proc_context
206 = calloc(1, sizeof(struct intel_video_process_context));
208 proc_context->base.destroy = gen75_proc_context_destroy;
209 proc_context->base.run = gen75_proc_picture;
211 proc_context->vpp_vebox_ctx = NULL;
212 proc_context->vpp_gpe_ctx = NULL;
213 proc_context->vpp_fmt_cvt_ctx = NULL;
215 proc_context->driver_context = ctx;
217 return (struct hw_context *)proc_context;