1 /*
2  * Copyright (c) 2011 Intel Corporation. All Rights Reserved.
3  * Copyright (c) Imagination Technologies Limited, UK
4  *
5  * Permission is hereby granted, free of charge, to any person obtaining a
6  * copy of this software and associated documentation files (the
7  * "Software"), to deal in the Software without restriction, including
8  * without limitation the rights to use, copy, modify, merge, publish,
9  * distribute, sub license, and/or sell copies of the Software, and to
10  * permit persons to whom the Software is furnished to do so, subject to
11  * the following conditions:
12  *
13  * The above copyright notice and this permission notice (including the
14  * next paragraph) shall be included in all copies or substantial portions
15  * of the Software.
16  *
17  * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
18  * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
19  * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT.
20  * IN NO EVENT SHALL PRECISION INSIGHT AND/OR ITS SUPPLIERS BE LIABLE FOR
21  * ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
22  * TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
23  * SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
24  */
25 
26 /*
27  * Authors:
28  *    Li Zeng <li.zeng@intel.com>
29  */
30 #include "psb_cmdbuf.h"
31 #include "psb_surface.h"
32 #include "tng_yuv_processor.h"
33 #include "tng_ved_scaling.h"
34 
35 struct context_DEC_s {
36     object_context_p obj_context; /* back reference */
37 
38     uint32_t *cmd_params;
39     uint32_t *p_range_mapping_base0;
40     uint32_t *p_range_mapping_base1;
41     uint32_t *p_slice_params; /* pointer to ui32SliceParams in CMD_HEADER */
42     uint32_t *slice_first_pic_last;
43     uint32_t *alt_output_flags;
44 
45     struct psb_buffer_s aux_line_buffer_vld;
46     psb_buffer_p preload_buffer;
47     psb_buffer_p slice_data_buffer;
48 
49 
50     /* Split buffers */
51     int split_buffer_pending;
52 
53     /* List of VASliceParameterBuffers */
54     object_buffer_p *slice_param_list;
55     int slice_param_list_size;
56     int slice_param_list_idx;
57 
58     unsigned int bits_offset;
59     unsigned int SR_flags;
60 
61     void (*begin_slice)(struct context_DEC_s *, VASliceParameterBufferBase *);
62     void (*process_slice)(struct context_DEC_s *, VASliceParameterBufferBase *);
63     void (*end_slice)(struct context_DEC_s *);
64     VAStatus (*process_buffer)(struct context_DEC_s *, object_buffer_p);
65 
66     struct psb_buffer_s *colocated_buffers;
67     int colocated_buffers_size;
68     int colocated_buffers_idx;
69     context_yuv_processor_p yuv_ctx;
70 #ifdef SLICE_HEADER_PARSING
71     uint32_t parse_enabled;
72     uint32_t parse_key;
73 #endif
74     /* scaling coeff reg */
75     uint32_t scaler_coeff_reg[2][2][4];
76     uint32_t h_scaler_ctrl;
77     uint32_t v_scaler_ctrl;
78 };
79 
80 typedef struct context_DEC_s *context_DEC_p;
81 
82 void vld_dec_FE_state(object_context_p, psb_buffer_p);
83 void vld_dec_setup_alternative_frame(object_context_p);
84 VAStatus vld_dec_process_slice_data(context_DEC_p, object_buffer_p);
85 VAStatus vld_dec_add_slice_param(context_DEC_p, object_buffer_p);
86 VAStatus vld_dec_allocate_colocated_buffer(context_DEC_p, object_surface_p, uint32_t);
87 VAStatus vld_dec_CreateContext(context_DEC_p, object_context_p);
88 void vld_dec_DestroyContext(context_DEC_p);
89 psb_buffer_p vld_dec_lookup_colocated_buffer(context_DEC_p, psb_surface_p);
90 void vld_dec_write_kick(object_context_p);
91 VAStatus vld_dec_RenderPicture( object_context_p, object_buffer_p *, int);
92 
93 #define AUX_LINE_BUFFER_VLD_SIZE        (1024*152)
94 
95 void vld_dec_yuv_rotate(object_context_p);
96 
97 VAStatus vld_dec_process_slice(context_DEC_p ctx,
98                                         void *vld_slice_param,
99                                         object_buffer_p obj_buffer);
100 
101