diff options
Diffstat (limited to 'src/gallium/include')
-rw-r--r-- | src/gallium/include/pipe/p_defines.h | 34 | ||||
-rw-r--r-- | src/gallium/include/pipe/p_format.h | 18 | ||||
-rw-r--r-- | src/gallium/include/pipe/p_screen.h | 17 | ||||
-rw-r--r-- | src/gallium/include/pipe/p_video_context.h | 331 | ||||
-rw-r--r-- | src/gallium/include/pipe/p_video_state.h | 139 |
5 files changed, 531 insertions, 8 deletions
diff --git a/src/gallium/include/pipe/p_defines.h b/src/gallium/include/pipe/p_defines.h index c0c2a7c7fd2..6c6641588d3 100644 --- a/src/gallium/include/pipe/p_defines.h +++ b/src/gallium/include/pipe/p_defines.h @@ -494,6 +494,39 @@ enum pipe_shader_cap }; +enum pipe_video_codec +{ + PIPE_VIDEO_CODEC_UNKNOWN = 0, + PIPE_VIDEO_CODEC_MPEG12, /**< MPEG1, MPEG2 */ + PIPE_VIDEO_CODEC_MPEG4, /**< DIVX, XVID */ + PIPE_VIDEO_CODEC_VC1, /**< WMV */ + PIPE_VIDEO_CODEC_MPEG4_AVC /**< H.264 */ +}; + +enum pipe_video_profile +{ + PIPE_VIDEO_PROFILE_UNKNOWN, + PIPE_VIDEO_PROFILE_MPEG1, + PIPE_VIDEO_PROFILE_MPEG2_SIMPLE, + PIPE_VIDEO_PROFILE_MPEG2_MAIN, + PIPE_VIDEO_PROFILE_MPEG4_SIMPLE, + PIPE_VIDEO_PROFILE_MPEG4_ADVANCED_SIMPLE, + PIPE_VIDEO_PROFILE_VC1_SIMPLE, + PIPE_VIDEO_PROFILE_VC1_MAIN, + PIPE_VIDEO_PROFILE_VC1_ADVANCED, + PIPE_VIDEO_PROFILE_MPEG4_AVC_BASELINE, + PIPE_VIDEO_PROFILE_MPEG4_AVC_MAIN, + PIPE_VIDEO_PROFILE_MPEG4_AVC_HIGH +}; + +enum pipe_video_entrypoint +{ + PIPE_VIDEO_ENTRYPOINT_UNKNOWN, + PIPE_VIDEO_ENTRYPOINT_BITSTREAM, + PIPE_VIDEO_ENTRYPOINT_IDCT, + PIPE_VIDEO_ENTRYPOINT_MC +}; + /** * Composite query types */ @@ -508,6 +541,7 @@ struct pipe_query_data_timestamp_disjoint boolean disjoint; }; + #ifdef __cplusplus } #endif diff --git a/src/gallium/include/pipe/p_format.h b/src/gallium/include/pipe/p_format.h index 690e9344334..c9f75c019ef 100644 --- a/src/gallium/include/pipe/p_format.h +++ b/src/gallium/include/pipe/p_format.h @@ -229,9 +229,27 @@ enum pipe_format { PIPE_FORMAT_L32A32_FLOAT = 161, PIPE_FORMAT_I32_FLOAT = 162, + PIPE_FORMAT_YV12 = 163, + PIPE_FORMAT_YV16 = 164, + PIPE_FORMAT_IYUV = 165, /**< aka I420 */ + PIPE_FORMAT_NV12 = 166, + PIPE_FORMAT_NV21 = 167, + PIPE_FORMAT_AYUV = PIPE_FORMAT_A8R8G8B8_UNORM, + PIPE_FORMAT_VUYA = PIPE_FORMAT_B8G8R8A8_UNORM, + PIPE_FORMAT_XYUV = PIPE_FORMAT_X8R8G8B8_UNORM, + PIPE_FORMAT_VUYX = PIPE_FORMAT_B8G8R8X8_UNORM, + PIPE_FORMAT_IA44 = 168, + PIPE_FORMAT_AI44 = 169, + PIPE_FORMAT_COUNT }; +enum pipe_video_chroma_format +{ + PIPE_VIDEO_CHROMA_FORMAT_420, + PIPE_VIDEO_CHROMA_FORMAT_422, + PIPE_VIDEO_CHROMA_FORMAT_444 +}; #ifdef __cplusplus } diff --git a/src/gallium/include/pipe/p_screen.h b/src/gallium/include/pipe/p_screen.h index a7845dd24d9..4f95fa1b2e1 100644 --- a/src/gallium/include/pipe/p_screen.h +++ b/src/gallium/include/pipe/p_screen.h @@ -1,8 +1,8 @@ /************************************************************************** - * + * * Copyright 2007 Tungsten Graphics, Inc., Cedar Park, Texas. * All Rights Reserved. - * + * * Permission is hereby granted, free of charge, to any person obtaining a * copy of this software and associated documentation files (the * "Software"), to deal in the Software without restriction, including @@ -10,11 +10,11 @@ * distribute, sub license, and/or sell copies of the Software, and to * permit persons to whom the Software is furnished to do so, subject to * the following conditions: - * + * * The above copyright notice and this permission notice (including the * next paragraph) shall be included in all copies or substantial portions * of the Software. - * + * * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT. @@ -22,12 +22,12 @@ * ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, * TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE * SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. - * + * **************************************************************************/ /** * @file - * + * * Screen, Adapter or GPU * * These are driver functions/facilities that are context independent. @@ -92,8 +92,9 @@ struct pipe_screen { */ int (*get_shader_param)( struct pipe_screen *, unsigned shader, enum pipe_shader_cap param ); - struct pipe_context * (*context_create)( struct pipe_screen *, - void *priv ); + struct pipe_context * (*context_create)( struct pipe_screen *, void *priv ); + + struct pipe_video_context * (*video_context_create)( struct pipe_screen *screen, void *priv ); /** * Check if the given pipe_format is supported as a texture or diff --git a/src/gallium/include/pipe/p_video_context.h b/src/gallium/include/pipe/p_video_context.h new file mode 100644 index 00000000000..512b5b22d77 --- /dev/null +++ b/src/gallium/include/pipe/p_video_context.h @@ -0,0 +1,331 @@ +/************************************************************************** + * + * Copyright 2009 Younes Manton. + * All Rights Reserved. + * + * Permission is hereby granted, free of charge, to any person obtaining a + * copy of this software and associated documentation files (the + * "Software"), to deal in the Software without restriction, including + * without limitation the rights to use, copy, modify, merge, publish, + * distribute, sub license, and/or sell copies of the Software, and to + * permit persons to whom the Software is furnished to do so, subject to + * the following conditions: + * + * The above copyright notice and this permission notice (including the + * next paragraph) shall be included in all copies or substantial portions + * of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS + * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF + * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT. + * IN NO EVENT SHALL TUNGSTEN GRAPHICS AND/OR ITS SUPPLIERS BE LIABLE FOR + * ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, + * TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE + * SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. + * + **************************************************************************/ + +#ifndef PIPE_VIDEO_CONTEXT_H +#define PIPE_VIDEO_CONTEXT_H + +#ifdef __cplusplus +extern "C" { +#endif + +#include <pipe/p_video_state.h> + +struct pipe_screen; +struct pipe_surface; +struct pipe_macroblock; +struct pipe_picture_desc; +struct pipe_fence_handle; + +/** + * Gallium video rendering context + */ +struct pipe_video_context +{ + struct pipe_screen *screen; + + void *priv; /**< context private data (for DRI for example) */ + + /** + * destroy context, all objects created from this context + * (buffers, decoders, compositors etc...) must be freed before calling this + */ + void (*destroy)(struct pipe_video_context *context); + + /** + * Query an integer-valued capability/parameter/limit + * \param param one of PIPE_CAP_x + */ + int (*get_param)(struct pipe_video_context *context, int param); + + /** + * Check if the given pipe_format is supported as a texture or + * drawing surface. + */ + boolean (*is_format_supported)(struct pipe_video_context *context, + enum pipe_format format, + unsigned usage); + + /** + * create a surface of a texture + */ + struct pipe_surface *(*create_surface)(struct pipe_video_context *context, + struct pipe_resource *resource, + const struct pipe_surface *templ); + + /** + * sampler view handling, used for subpictures for example + */ + /*@{*/ + + /** + * create a sampler view of a texture, for subpictures for example + */ + struct pipe_sampler_view *(*create_sampler_view)(struct pipe_video_context *context, + struct pipe_resource *resource, + const struct pipe_sampler_view *templ); + + /** + * upload image data to a sampler + */ + void (*upload_sampler)(struct pipe_video_context *context, + struct pipe_sampler_view *dst, + const struct pipe_box *dst_box, + const void *src, unsigned src_stride, + unsigned src_x, unsigned src_y); + + /** + * clear a sampler with a specific rgba color + */ + void (*clear_sampler)(struct pipe_video_context *context, + struct pipe_sampler_view *dst, + const struct pipe_box *dst_box, + const float *rgba); + + /*}@*/ + + /** + * create a decoder for a specific video profile + */ + struct pipe_video_decoder *(*create_decoder)(struct pipe_video_context *context, + enum pipe_video_profile profile, + enum pipe_video_entrypoint entrypoint, + enum pipe_video_chroma_format chroma_format, + unsigned width, unsigned height); + + /** + * Creates a buffer as decoding target + */ + struct pipe_video_buffer *(*create_buffer)(struct pipe_video_context *context, + enum pipe_format buffer_format, + enum pipe_video_chroma_format chroma_format, + unsigned width, unsigned height); + + /** + * Creates a video compositor + */ + struct pipe_video_compositor *(*create_compositor)(struct pipe_video_context *context); +}; + +/** + * decoder for a specific video codec + */ +struct pipe_video_decoder +{ + struct pipe_video_context *context; + + enum pipe_video_profile profile; + enum pipe_video_entrypoint entrypoint; + enum pipe_video_chroma_format chroma_format; + unsigned width; + unsigned height; + + /** + * destroy this video decoder + */ + void (*destroy)(struct pipe_video_decoder *decoder); + + /** + * Creates a buffer as decoding input + */ + struct pipe_video_decode_buffer *(*create_buffer)(struct pipe_video_decoder *decoder); + + /** + * flush decoder buffer to video hardware + */ + void (*flush_buffer)(struct pipe_video_decode_buffer *decbuf, + unsigned num_ycbcr_blocks[3], + struct pipe_video_buffer *ref_frames[2], + struct pipe_video_buffer *dst); +}; + +/** + * input buffer for a decoder + */ +struct pipe_video_decode_buffer +{ + struct pipe_video_decoder *decoder; + + /** + * destroy this decode buffer + */ + void (*destroy)(struct pipe_video_decode_buffer *decbuf); + + /** + * map the input buffer into memory before starting decoding + */ + void (*map)(struct pipe_video_decode_buffer *decbuf); + + /** + * get the pointer where to put the ycbcr blocks of a component + */ + struct pipe_ycbcr_block *(*get_ycbcr_stream)(struct pipe_video_decode_buffer *, int component); + + /** + * get the pointer where to put the ycbcr dct block data of a component + */ + short *(*get_ycbcr_buffer)(struct pipe_video_decode_buffer *, int component); + + /** + * get the stride of the mv buffer + */ + unsigned (*get_mv_stream_stride)(struct pipe_video_decode_buffer *decbuf); + + /** + * get the pointer where to put the motion vectors of a ref frame + */ + struct pipe_motionvector *(*get_mv_stream)(struct pipe_video_decode_buffer *decbuf, int ref_frame); + + /** + * decode a bitstream + */ + void (*decode_bitstream)(struct pipe_video_decode_buffer *decbuf, + unsigned num_bytes, const void *data, + struct pipe_mpeg12_picture_desc *picture, + unsigned num_ycbcr_blocks[3]); + + /** + * unmap decoder buffer before flushing + */ + void (*unmap)(struct pipe_video_decode_buffer *decbuf); +}; + +/** + * output for decoding / input for displaying + */ +struct pipe_video_buffer +{ + struct pipe_video_context *context; + + enum pipe_format buffer_format; + enum pipe_video_chroma_format chroma_format; + unsigned width; + unsigned height; + + /** + * destroy this video buffer + */ + void (*destroy)(struct pipe_video_buffer *buffer); + + /** + * get a individual sampler view for each plane + */ + struct pipe_sampler_view **(*get_sampler_view_planes)(struct pipe_video_buffer *buffer); + + /** + * get a individual sampler view for each component + */ + struct pipe_sampler_view **(*get_sampler_view_components)(struct pipe_video_buffer *buffer); + + /** + * get a individual surfaces for each plane + */ + struct pipe_surface **(*get_surfaces)(struct pipe_video_buffer *buffer); +}; + +/** + * composing and displaying of image data + */ +struct pipe_video_compositor +{ + struct pipe_video_context *context; + + /** + * destroy this compositor + */ + void (*destroy)(struct pipe_video_compositor *compositor); + + /** + * set yuv -> rgba conversion matrix + */ + void (*set_csc_matrix)(struct pipe_video_compositor *compositor, const float mat[16]); + + /** + * reset dirty area, so it's cleared with the clear colour + */ + void (*reset_dirty_area)(struct pipe_video_compositor *compositor); + + /** + * set the clear color + */ + void (*set_clear_color)(struct pipe_video_compositor *compositor, float color[4]); + + /** + * set overlay samplers + */ + /*@{*/ + + /** + * reset all currently set layers + */ + void (*clear_layers)(struct pipe_video_compositor *compositor); + + /** + * set a video buffer as a layer to render + */ + void (*set_buffer_layer)(struct pipe_video_compositor *compositor, + unsigned layer, + struct pipe_video_buffer *buffer, + struct pipe_video_rect *src_rect, + struct pipe_video_rect *dst_rect); + + /** + * set a paletted sampler as a layer to render + */ + void (*set_palette_layer)(struct pipe_video_compositor *compositor, + unsigned layer, + struct pipe_sampler_view *indexes, + struct pipe_sampler_view *palette, + struct pipe_video_rect *src_rect, + struct pipe_video_rect *dst_rect); + + /** + * set a rgba sampler as a layer to render + */ + void (*set_rgba_layer)(struct pipe_video_compositor *compositor, + unsigned layer, + struct pipe_sampler_view *rgba, + struct pipe_video_rect *src_rect, + struct pipe_video_rect *dst_rect); + + /*@}*/ + + /** + * render the layers to the frontbuffer + */ + void (*render_picture)(struct pipe_video_compositor *compositor, + enum pipe_mpeg12_picture_type picture_type, + struct pipe_surface *dst_surface, + struct pipe_video_rect *dst_area, + struct pipe_fence_handle **fence); + +}; + +#ifdef __cplusplus +} +#endif + +#endif /* PIPE_VIDEO_CONTEXT_H */ diff --git a/src/gallium/include/pipe/p_video_state.h b/src/gallium/include/pipe/p_video_state.h new file mode 100644 index 00000000000..f46c2dd2bbf --- /dev/null +++ b/src/gallium/include/pipe/p_video_state.h @@ -0,0 +1,139 @@ +/************************************************************************** + * + * Copyright 2009 Younes Manton. + * All Rights Reserved. + * + * Permission is hereby granted, free of charge, to any person obtaining a + * copy of this software and associated documentation files (the + * "Software"), to deal in the Software without restriction, including + * without limitation the rights to use, copy, modify, merge, publish, + * distribute, sub license, and/or sell copies of the Software, and to + * permit persons to whom the Software is furnished to do so, subject to + * the following conditions: + * + * The above copyright notice and this permission notice (including the + * next paragraph) shall be included in all copies or substantial portions + * of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS + * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF + * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT. + * IN NO EVENT SHALL TUNGSTEN GRAPHICS AND/OR ITS SUPPLIERS BE LIABLE FOR + * ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, + * TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE + * SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. + * + **************************************************************************/ + +#ifndef PIPE_VIDEO_STATE_H +#define PIPE_VIDEO_STATE_H + +#include <pipe/p_defines.h> +#include <pipe/p_format.h> +#include <pipe/p_state.h> +#include <pipe/p_screen.h> +#include <util/u_inlines.h> + +#ifdef __cplusplus +extern "C" { +#endif + +struct pipe_video_rect +{ + unsigned x, y, w, h; +}; + +enum pipe_mpeg12_picture_type +{ + PIPE_MPEG12_PICTURE_TYPE_FIELD_TOP, + PIPE_MPEG12_PICTURE_TYPE_FIELD_BOTTOM, + PIPE_MPEG12_PICTURE_TYPE_FRAME +}; + +enum pipe_mpeg12_dct_intra +{ + PIPE_MPEG12_DCT_DELTA = 0, + PIPE_MPEG12_DCT_INTRA = 1 +}; + +enum pipe_mpeg12_dct_type +{ + PIPE_MPEG12_DCT_TYPE_FRAME = 0, + PIPE_MPEG12_DCT_TYPE_FIELD = 1 +}; + +enum pipe_video_field_select +{ + PIPE_VIDEO_FRAME = 0, + PIPE_VIDEO_TOP_FIELD = 1, + PIPE_VIDEO_BOTTOM_FIELD = 3, + + /* TODO + PIPE_VIDEO_DUALPRIME + PIPE_VIDEO_16x8 + */ +}; + +enum pipe_video_mv_weight +{ + PIPE_VIDEO_MV_WEIGHT_MIN = 0, + PIPE_VIDEO_MV_WEIGHT_HALF = 128, + PIPE_VIDEO_MV_WEIGHT_MAX = 256 +}; + +/* bitfields because this is used as a vertex buffer element */ +struct pipe_motionvector +{ + struct { + signed x:16, y:16; + enum pipe_video_field_select field_select:16; + enum pipe_video_mv_weight weight:16; + } top, bottom; +}; + +/* bitfields because this is used as a vertex buffer element */ +struct pipe_ycbcr_block +{ + unsigned x:8, y:8; + enum pipe_mpeg12_dct_intra intra:8; + enum pipe_mpeg12_dct_type coding:8; +}; + +struct pipe_picture_desc +{ + enum pipe_video_profile profile; +}; + +struct pipe_mpeg12_picture_desc +{ + struct pipe_picture_desc base; + + unsigned picture_coding_type; + unsigned picture_structure; + unsigned frame_pred_frame_dct; + unsigned q_scale_type; + unsigned alternate_scan; + unsigned intra_dc_precision; + unsigned intra_vlc_format; + unsigned concealment_motion_vectors; + unsigned f_code[2][2]; + + bool mpeg1; + uint8_t *intra_quantizer_matrix; + uint8_t *non_intra_quantizer_matrix; + +#if 0 + /* TODO: Use bitfields where possible? */ + unsigned top_field_first; + unsigned full_pel_forward_vector; + unsigned full_pel_backward_vector; + struct pipe_buffer *chroma_intra_quantizer_matrix; + struct pipe_buffer *chroma_non_intra_quantizer_matrix; +#endif +}; + +#ifdef __cplusplus +} +#endif + +#endif /* PIPE_VIDEO_STATE_H */ |