1bf215546Sopenharmony_ci/**************************************************************************
2bf215546Sopenharmony_ci *
3bf215546Sopenharmony_ci * Copyright 2009 Younes Manton.
4bf215546Sopenharmony_ci * All Rights Reserved.
5bf215546Sopenharmony_ci *
6bf215546Sopenharmony_ci * Permission is hereby granted, free of charge, to any person obtaining a
7bf215546Sopenharmony_ci * copy of this software and associated documentation files (the
8bf215546Sopenharmony_ci * "Software"), to deal in the Software without restriction, including
9bf215546Sopenharmony_ci * without limitation the rights to use, copy, modify, merge, publish,
10bf215546Sopenharmony_ci * distribute, sub license, and/or sell copies of the Software, and to
11bf215546Sopenharmony_ci * permit persons to whom the Software is furnished to do so, subject to
12bf215546Sopenharmony_ci * the following conditions:
13bf215546Sopenharmony_ci *
14bf215546Sopenharmony_ci * The above copyright notice and this permission notice (including the
15bf215546Sopenharmony_ci * next paragraph) shall be included in all copies or substantial portions
16bf215546Sopenharmony_ci * of the Software.
17bf215546Sopenharmony_ci *
18bf215546Sopenharmony_ci * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
19bf215546Sopenharmony_ci * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
20bf215546Sopenharmony_ci * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT.
21bf215546Sopenharmony_ci * IN NO EVENT SHALL VMWARE AND/OR ITS SUPPLIERS BE LIABLE FOR
22bf215546Sopenharmony_ci * ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
23bf215546Sopenharmony_ci * TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
24bf215546Sopenharmony_ci * SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
25bf215546Sopenharmony_ci *
26bf215546Sopenharmony_ci **************************************************************************/
27bf215546Sopenharmony_ci
28bf215546Sopenharmony_ci#ifndef PIPE_VIDEO_CONTEXT_H
29bf215546Sopenharmony_ci#define PIPE_VIDEO_CONTEXT_H
30bf215546Sopenharmony_ci
31bf215546Sopenharmony_ci#include "pipe/p_video_state.h"
32bf215546Sopenharmony_ci
33bf215546Sopenharmony_ci#ifdef __cplusplus
34bf215546Sopenharmony_ciextern "C" {
35bf215546Sopenharmony_ci#endif
36bf215546Sopenharmony_ci
37bf215546Sopenharmony_cistruct pipe_screen;
38bf215546Sopenharmony_cistruct pipe_surface;
39bf215546Sopenharmony_cistruct pipe_macroblock;
40bf215546Sopenharmony_cistruct pipe_picture_desc;
41bf215546Sopenharmony_cistruct pipe_fence_handle;
42bf215546Sopenharmony_ci
43bf215546Sopenharmony_ci/**
44bf215546Sopenharmony_ci * Gallium video codec for a specific format/profile
45bf215546Sopenharmony_ci */
46bf215546Sopenharmony_cistruct pipe_video_codec
47bf215546Sopenharmony_ci{
48bf215546Sopenharmony_ci   struct pipe_context *context;
49bf215546Sopenharmony_ci
50bf215546Sopenharmony_ci   enum pipe_video_profile profile;
51bf215546Sopenharmony_ci   unsigned level;
52bf215546Sopenharmony_ci   enum pipe_video_entrypoint entrypoint;
53bf215546Sopenharmony_ci   enum pipe_video_chroma_format chroma_format;
54bf215546Sopenharmony_ci   unsigned width;
55bf215546Sopenharmony_ci   unsigned height;
56bf215546Sopenharmony_ci   unsigned max_references;
57bf215546Sopenharmony_ci   bool expect_chunked_decode;
58bf215546Sopenharmony_ci
59bf215546Sopenharmony_ci   /**
60bf215546Sopenharmony_ci    * destroy this video decoder
61bf215546Sopenharmony_ci    */
62bf215546Sopenharmony_ci   void (*destroy)(struct pipe_video_codec *codec);
63bf215546Sopenharmony_ci
64bf215546Sopenharmony_ci   /**
65bf215546Sopenharmony_ci    * start decoding of a new frame
66bf215546Sopenharmony_ci    */
67bf215546Sopenharmony_ci   void (*begin_frame)(struct pipe_video_codec *codec,
68bf215546Sopenharmony_ci                       struct pipe_video_buffer *target,
69bf215546Sopenharmony_ci                       struct pipe_picture_desc *picture);
70bf215546Sopenharmony_ci
71bf215546Sopenharmony_ci   /**
72bf215546Sopenharmony_ci    * decode a macroblock
73bf215546Sopenharmony_ci    */
74bf215546Sopenharmony_ci   void (*decode_macroblock)(struct pipe_video_codec *codec,
75bf215546Sopenharmony_ci                             struct pipe_video_buffer *target,
76bf215546Sopenharmony_ci                             struct pipe_picture_desc *picture,
77bf215546Sopenharmony_ci                             const struct pipe_macroblock *macroblocks,
78bf215546Sopenharmony_ci                             unsigned num_macroblocks);
79bf215546Sopenharmony_ci
80bf215546Sopenharmony_ci   /**
81bf215546Sopenharmony_ci    * decode a bitstream
82bf215546Sopenharmony_ci    */
83bf215546Sopenharmony_ci   void (*decode_bitstream)(struct pipe_video_codec *codec,
84bf215546Sopenharmony_ci                            struct pipe_video_buffer *target,
85bf215546Sopenharmony_ci                            struct pipe_picture_desc *picture,
86bf215546Sopenharmony_ci                            unsigned num_buffers,
87bf215546Sopenharmony_ci                            const void * const *buffers,
88bf215546Sopenharmony_ci                            const unsigned *sizes);
89bf215546Sopenharmony_ci
90bf215546Sopenharmony_ci   /**
91bf215546Sopenharmony_ci    * encode to a bitstream
92bf215546Sopenharmony_ci    */
93bf215546Sopenharmony_ci   void (*encode_bitstream)(struct pipe_video_codec *codec,
94bf215546Sopenharmony_ci                            struct pipe_video_buffer *source,
95bf215546Sopenharmony_ci                            struct pipe_resource *destination,
96bf215546Sopenharmony_ci                            void **feedback);
97bf215546Sopenharmony_ci
98bf215546Sopenharmony_ci   /**
99bf215546Sopenharmony_ci    * Perform post-process effect
100bf215546Sopenharmony_ci    */
101bf215546Sopenharmony_ci   void (*process_frame)(struct pipe_video_codec *codec,
102bf215546Sopenharmony_ci                         struct pipe_video_buffer *source,
103bf215546Sopenharmony_ci                         const struct pipe_vpp_desc *process_properties);
104bf215546Sopenharmony_ci
105bf215546Sopenharmony_ci   /**
106bf215546Sopenharmony_ci    * end decoding of the current frame
107bf215546Sopenharmony_ci    */
108bf215546Sopenharmony_ci   void (*end_frame)(struct pipe_video_codec *codec,
109bf215546Sopenharmony_ci                     struct pipe_video_buffer *target,
110bf215546Sopenharmony_ci                     struct pipe_picture_desc *picture);
111bf215546Sopenharmony_ci
112bf215546Sopenharmony_ci   /**
113bf215546Sopenharmony_ci    * flush any outstanding command buffers to the hardware
114bf215546Sopenharmony_ci    * should be called before a video_buffer is acessed by the gallium frontend again
115bf215546Sopenharmony_ci    */
116bf215546Sopenharmony_ci   void (*flush)(struct pipe_video_codec *codec);
117bf215546Sopenharmony_ci
118bf215546Sopenharmony_ci   /**
119bf215546Sopenharmony_ci    * get encoder feedback
120bf215546Sopenharmony_ci    */
121bf215546Sopenharmony_ci   void (*get_feedback)(struct pipe_video_codec *codec, void *feedback, unsigned *size);
122bf215546Sopenharmony_ci};
123bf215546Sopenharmony_ci
124bf215546Sopenharmony_ci/**
125bf215546Sopenharmony_ci * output for decoding / input for displaying
126bf215546Sopenharmony_ci */
127bf215546Sopenharmony_cistruct pipe_video_buffer
128bf215546Sopenharmony_ci{
129bf215546Sopenharmony_ci   struct pipe_context *context;
130bf215546Sopenharmony_ci
131bf215546Sopenharmony_ci   enum pipe_format buffer_format;
132bf215546Sopenharmony_ci   unsigned width;
133bf215546Sopenharmony_ci   unsigned height;
134bf215546Sopenharmony_ci   bool interlaced;
135bf215546Sopenharmony_ci   unsigned bind;
136bf215546Sopenharmony_ci
137bf215546Sopenharmony_ci   /**
138bf215546Sopenharmony_ci    * destroy this video buffer
139bf215546Sopenharmony_ci    */
140bf215546Sopenharmony_ci   void (*destroy)(struct pipe_video_buffer *buffer);
141bf215546Sopenharmony_ci
142bf215546Sopenharmony_ci   /**
143bf215546Sopenharmony_ci    * get an individual sampler view for each plane
144bf215546Sopenharmony_ci    */
145bf215546Sopenharmony_ci   struct pipe_sampler_view **(*get_sampler_view_planes)(struct pipe_video_buffer *buffer);
146bf215546Sopenharmony_ci
147bf215546Sopenharmony_ci   /**
148bf215546Sopenharmony_ci    * get an individual sampler view for each component
149bf215546Sopenharmony_ci    */
150bf215546Sopenharmony_ci   struct pipe_sampler_view **(*get_sampler_view_components)(struct pipe_video_buffer *buffer);
151bf215546Sopenharmony_ci
152bf215546Sopenharmony_ci   /**
153bf215546Sopenharmony_ci    * get an individual surfaces for each plane
154bf215546Sopenharmony_ci    */
155bf215546Sopenharmony_ci   struct pipe_surface **(*get_surfaces)(struct pipe_video_buffer *buffer);
156bf215546Sopenharmony_ci
157bf215546Sopenharmony_ci   /*
158bf215546Sopenharmony_ci    * auxiliary associated data
159bf215546Sopenharmony_ci    */
160bf215546Sopenharmony_ci   void *associated_data;
161bf215546Sopenharmony_ci
162bf215546Sopenharmony_ci   /*
163bf215546Sopenharmony_ci    * codec where the associated data came from
164bf215546Sopenharmony_ci    */
165bf215546Sopenharmony_ci   struct pipe_video_codec *codec;
166bf215546Sopenharmony_ci
167bf215546Sopenharmony_ci   /*
168bf215546Sopenharmony_ci    * destroy the associated data
169bf215546Sopenharmony_ci    */
170bf215546Sopenharmony_ci   void (*destroy_associated_data)(void *associated_data);
171bf215546Sopenharmony_ci};
172bf215546Sopenharmony_ci
173bf215546Sopenharmony_ci#ifdef __cplusplus
174bf215546Sopenharmony_ci}
175bf215546Sopenharmony_ci#endif
176bf215546Sopenharmony_ci
177bf215546Sopenharmony_ci#endif /* PIPE_VIDEO_CONTEXT_H */
178