Commit 26aeded5 authored by Roland Scheidegger's avatar Roland Scheidegger

gallium: remove video interface and related stuff

These interfaces weren't quite was needed, and building disabled for a while.
Some code actually build since some branch merge, and were now not fully
converted to gallium-resources.
See http://www.mail-archive.com/mesa3d-dev@lists.sourceforge.net/msg09619.html
for a discussion of this. Video related work is done in origin/pipe-video
branch.
parent c64285ae
/**************************************************************************
*
* 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.
*
**************************************************************************/
#include "vl_bitstream_parser.h"
#include <assert.h>
#include <limits.h>
#include <util/u_memory.h>
static unsigned
grab_bits(unsigned cursor, unsigned how_many_bits, unsigned bitstream_elt)
{
unsigned excess_bits = sizeof(unsigned) * CHAR_BIT - how_many_bits - cursor;
assert(cursor < sizeof(unsigned) * CHAR_BIT);
assert(how_many_bits > 0 && how_many_bits <= sizeof(unsigned) * CHAR_BIT);
assert(cursor + how_many_bits <= sizeof(unsigned) * CHAR_BIT);
return (bitstream_elt << excess_bits) >> (excess_bits + cursor);
}
static unsigned
show_bits(unsigned cursor, unsigned how_many_bits, const unsigned *bitstream)
{
unsigned cur_int = cursor / (sizeof(unsigned) * CHAR_BIT);
unsigned cur_bit = cursor % (sizeof(unsigned) * CHAR_BIT);
assert(bitstream);
if (cur_bit + how_many_bits > sizeof(unsigned) * CHAR_BIT) {
unsigned lower = grab_bits(cur_bit, sizeof(unsigned) * CHAR_BIT - cur_bit,
bitstream[cur_int]);
unsigned upper = grab_bits(0, cur_bit + how_many_bits - sizeof(unsigned) * CHAR_BIT,
bitstream[cur_int + 1]);
return lower | upper << (sizeof(unsigned) * CHAR_BIT - cur_bit);
}
else
return grab_bits(cur_bit, how_many_bits, bitstream[cur_int]);
}
bool vl_bitstream_parser_init(struct vl_bitstream_parser *parser,
unsigned num_bitstreams,
const void **bitstreams,
const unsigned *sizes)
{
assert(parser);
assert(num_bitstreams);
assert(bitstreams);
assert(sizes);
parser->num_bitstreams = num_bitstreams;
parser->bitstreams = (const unsigned**)bitstreams;
parser->sizes = sizes;
parser->cur_bitstream = 0;
parser->cursor = 0;
return true;
}
void vl_bitstream_parser_cleanup(struct vl_bitstream_parser *parser)
{
assert(parser);
}
unsigned
vl_bitstream_parser_get_bits(struct vl_bitstream_parser *parser,
unsigned how_many_bits)
{
unsigned bits;
assert(parser);
bits = vl_bitstream_parser_show_bits(parser, how_many_bits);
vl_bitstream_parser_forward(parser, how_many_bits);
return bits;
}
unsigned
vl_bitstream_parser_show_bits(struct vl_bitstream_parser *parser,
unsigned how_many_bits)
{
unsigned bits = 0;
unsigned shift = 0;
unsigned cursor;
unsigned cur_bitstream;
assert(parser);
cursor = parser->cursor;
cur_bitstream = parser->cur_bitstream;
while (1) {
unsigned bits_left = parser->sizes[cur_bitstream] * CHAR_BIT - cursor;
unsigned bits_to_show = how_many_bits > bits_left ? bits_left : how_many_bits;
bits |= show_bits(cursor, bits_to_show,
parser->bitstreams[cur_bitstream]) << shift;
if (how_many_bits > bits_to_show) {
how_many_bits -= bits_to_show;
cursor = 0;
++cur_bitstream;
shift += bits_to_show;
}
else
break;
}
return bits;
}
void vl_bitstream_parser_forward(struct vl_bitstream_parser *parser,
unsigned how_many_bits)
{
assert(parser);
assert(how_many_bits);
parser->cursor += how_many_bits;
while (parser->cursor > parser->sizes[parser->cur_bitstream] * CHAR_BIT) {
parser->cursor -= parser->sizes[parser->cur_bitstream++] * CHAR_BIT;
assert(parser->cur_bitstream < parser->num_bitstreams);
}
}
void vl_bitstream_parser_rewind(struct vl_bitstream_parser *parser,
unsigned how_many_bits)
{
signed c;
assert(parser);
assert(how_many_bits);
c = parser->cursor - how_many_bits;
while (c < 0) {
c += parser->sizes[parser->cur_bitstream--] * CHAR_BIT;
assert(parser->cur_bitstream < parser->num_bitstreams);
}
parser->cursor = (unsigned)c;
}
/**************************************************************************
*
* 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 vl_bitstream_parser_h
#define vl_bitstream_parser_h
#include "pipe/p_compiler.h"
struct vl_bitstream_parser
{
unsigned num_bitstreams;
const unsigned **bitstreams;
const unsigned *sizes;
unsigned cur_bitstream;
unsigned cursor;
};
bool vl_bitstream_parser_init(struct vl_bitstream_parser *parser,
unsigned num_bitstreams,
const void **bitstreams,
const unsigned *sizes);
void vl_bitstream_parser_cleanup(struct vl_bitstream_parser *parser);
unsigned
vl_bitstream_parser_get_bits(struct vl_bitstream_parser *parser,
unsigned how_many_bits);
unsigned
vl_bitstream_parser_show_bits(struct vl_bitstream_parser *parser,
unsigned how_many_bits);
void vl_bitstream_parser_forward(struct vl_bitstream_parser *parser,
unsigned how_many_bits);
void vl_bitstream_parser_rewind(struct vl_bitstream_parser *parser,
unsigned how_many_bits);
#endif /* vl_bitstream_parser_h */
This diff is collapsed.
/**************************************************************************
*
* 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 vl_compositor_h
#define vl_compositor_h
#include <pipe/p_compiler.h>
#include <pipe/p_state.h>
#include <pipe/p_video_state.h>
struct pipe_context;
struct pipe_texture;
struct vl_compositor
{
struct pipe_context *pipe;
struct pipe_framebuffer_state fb_state;
void *sampler;
void *vertex_shader;
void *fragment_shader;
void *vertex_elems;
struct pipe_viewport_state viewport;
struct pipe_scissor_state scissor;
struct pipe_vertex_buffer vertex_bufs[2];
struct pipe_buffer *vs_const_buf, *fs_const_buf;
};
bool vl_compositor_init(struct vl_compositor *compositor, struct pipe_context *pipe);
void vl_compositor_cleanup(struct vl_compositor *compositor);
void vl_compositor_render(struct vl_compositor *compositor,
/*struct pipe_texture *backround,
struct pipe_video_rect *backround_area,*/
struct pipe_texture *src_surface,
enum pipe_mpeg12_picture_type picture_type,
/*unsigned num_past_surfaces,
struct pipe_texture *past_surfaces,
unsigned num_future_surfaces,
struct pipe_texture *future_surfaces,*/
struct pipe_video_rect *src_area,
struct pipe_texture *dst_surface,
struct pipe_video_rect *dst_area,
/*unsigned num_layers,
struct pipe_texture *layers,
struct pipe_video_rect *layer_src_areas,
struct pipe_video_rect *layer_dst_areas,*/
struct pipe_fence_handle **fence);
void vl_compositor_set_csc_matrix(struct vl_compositor *compositor, const float *mat);
#endif /* vl_compositor_h */
/**************************************************************************
*
* 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.
*
**************************************************************************/
#include "vl_csc.h"
#include <util/u_math.h>
#include <util/u_debug.h>
/*
* Color space conversion formulas
*
* To convert YCbCr to RGB,
* vec4 ycbcr, rgb
* mat44 csc
* rgb = csc * ycbcr
*
* To calculate the color space conversion matrix csc with ProcAmp adjustments,
* mat44 csc, cstd, procamp, bias
* csc = cstd * (procamp * bias)
*
* Where cstd is a matrix corresponding to one of the color standards (BT.601, BT.709, etc)
* adjusted for the kind of YCbCr -> RGB mapping wanted (1:1, full),
* bias is a matrix corresponding to the kind of YCbCr -> RGB mapping wanted (1:1, full)
*
* To calculate procamp,
* mat44 procamp, hue, saturation, brightness, contrast
* procamp = brightness * (saturation * (contrast * hue))
* Alternatively,
* procamp = saturation * (brightness * (contrast * hue))
*
* contrast
* [ c, 0, 0, 0]
* [ 0, c, 0, 0]
* [ 0, 0, c, 0]
* [ 0, 0, 0, 1]
*
* brightness
* [ 1, 0, 0, b]
* [ 0, 1, 0, 0]
* [ 0, 0, 1, 0]
* [ 0, 0, 0, 1]
*
* saturation
* [ 1, 0, 0, 0]
* [ 0, s, 0, 0]
* [ 0, 0, s, 0]
* [ 0, 0, 0, 1]
*
* hue
* [ 1, 0, 0, 0]
* [ 0, cos(h), sin(h), 0]
* [ 0, -sin(h), cos(h), 0]
* [ 0, 0, 0, 1]
*
* procamp
* [ c, 0, 0, b]
* [ 0, c*s*cos(h), c*s*sin(h), 0]
* [ 0, -c*s*sin(h), c*s*cos(h), 0]
* [ 0, 0, 0, 1]
*
* bias
* [ 1, 0, 0, ybias]
* [ 0, 1, 0, cbbias]
* [ 0, 0, 1, crbias]
* [ 0, 0, 0, 1]
*
* csc
* [ c*cstd[ 0], c*cstd[ 1]*s*cos(h) - c*cstd[ 2]*s*sin(h), c*cstd[ 2]*s*cos(h) + c*cstd[ 1]*s*sin(h), cstd[ 3] + cstd[ 0]*(b + c*ybias) + cstd[ 1]*(c*cbbias*s*cos(h) + c*crbias*s*sin(h)) + cstd[ 2]*(c*crbias*s*cos(h) - c*cbbias*s*sin(h))]
* [ c*cstd[ 4], c*cstd[ 5]*s*cos(h) - c*cstd[ 6]*s*sin(h), c*cstd[ 6]*s*cos(h) + c*cstd[ 5]*s*sin(h), cstd[ 7] + cstd[ 4]*(b + c*ybias) + cstd[ 5]*(c*cbbias*s*cos(h) + c*crbias*s*sin(h)) + cstd[ 6]*(c*crbias*s*cos(h) - c*cbbias*s*sin(h))]
* [ c*cstd[ 8], c*cstd[ 9]*s*cos(h) - c*cstd[10]*s*sin(h), c*cstd[10]*s*cos(h) + c*cstd[ 9]*s*sin(h), cstd[11] + cstd[ 8]*(b + c*ybias) + cstd[ 9]*(c*cbbias*s*cos(h) + c*crbias*s*sin(h)) + cstd[10]*(c*crbias*s*cos(h) - c*cbbias*s*sin(h))]
* [ c*cstd[12], c*cstd[13]*s*cos(h) - c*cstd[14]*s*sin(h), c*cstd[14]*s*cos(h) + c*cstd[13]*s*sin(h), cstd[15] + cstd[12]*(b + c*ybias) + cstd[13]*(c*cbbias*s*cos(h) + c*crbias*s*sin(h)) + cstd[14]*(c*crbias*s*cos(h) - c*cbbias*s*sin(h))]
*/
/*
* Converts ITU-R BT.601 YCbCr pixels to RGB pixels where:
* Y is in [16,235], Cb and Cr are in [16,240]
* R, G, and B are in [16,235]
*/
static const float bt_601[16] =
{
1.0f, 0.0f, 1.371f, 0.0f,
1.0f, -0.336f, -0.698f, 0.0f,
1.0f, 1.732f, 0.0f, 0.0f,
0.0f, 0.0f, 0.0f, 1.0f
};
/*
* Converts ITU-R BT.601 YCbCr pixels to RGB pixels where:
* Y is in [16,235], Cb and Cr are in [16,240]
* R, G, and B are in [0,255]
*/
static const float bt_601_full[16] =
{
1.164f, 0.0f, 1.596f, 0.0f,
1.164f, -0.391f, -0.813f, 0.0f,
1.164f, 2.018f, 0.0f, 0.0f,
0.0f, 0.0f, 0.0f, 1.0f
};
/*
* Converts ITU-R BT.709 YCbCr pixels to RGB pixels where:
* Y is in [16,235], Cb and Cr are in [16,240]
* R, G, and B are in [16,235]
*/
static const float bt_709[16] =
{
1.0f, 0.0f, 1.540f, 0.0f,
1.0f, -0.183f, -0.459f, 0.0f,
1.0f, 1.816f, 0.0f, 0.0f,
0.0f, 0.0f, 0.0f, 1.0f
};
/*
* Converts ITU-R BT.709 YCbCr pixels to RGB pixels where:
* Y is in [16,235], Cb and Cr are in [16,240]
* R, G, and B are in [0,255]
*/
static const float bt_709_full[16] =
{
1.164f, 0.0f, 1.793f, 0.0f,
1.164f, -0.213f, -0.534f, 0.0f,
1.164f, 2.115f, 0.0f, 0.0f,
0.0f, 0.0f, 0.0f, 1.0f
};
static const float identity[16] =
{
1.0f, 0.0f, 0.0f, 0.0f,
0.0f, 1.0f, 0.0f, 0.0f,
0.0f, 0.0f, 1.0f, 0.0f,
0.0f, 0.0f, 0.0f, 1.0f
};
void vl_csc_get_matrix(enum VL_CSC_COLOR_STANDARD cs,
struct vl_procamp *procamp,
bool full_range,
float *matrix)
{
float ybias = full_range ? -16.0f/255.0f : 0.0f;
float cbbias = -128.0f/255.0f;
float crbias = -128.0f/255.0f;
float c = procamp ? procamp->contrast : 1.0f;
float s = procamp ? procamp->saturation : 1.0f;
float b = procamp ? procamp->brightness : 0.0f;
float h = procamp ? procamp->hue : 0.0f;
const float *cstd;
assert(matrix);
switch (cs) {
case VL_CSC_COLOR_STANDARD_BT_601:
cstd = full_range ? &bt_601_full[0] : &bt_601[0];
break;
case VL_CSC_COLOR_STANDARD_BT_709:
cstd = full_range ? &bt_709_full[0] : &bt_709[0];
break;
case VL_CSC_COLOR_STANDARD_IDENTITY:
default:
assert(cs == VL_CSC_COLOR_STANDARD_IDENTITY);
memcpy(matrix, &identity[0], sizeof(float) * 16);
return;
}
matrix[ 0] = c*cstd[ 0];
matrix[ 1] = c*cstd[ 1]*s*cosf(h) - c*cstd[ 2]*s*sinf(h);
matrix[ 2] = c*cstd[ 2]*s*cosf(h) + c*cstd[ 1]*s*sinf(h);
matrix[ 3] = cstd[ 3] + cstd[ 0]*(b + c*ybias) + cstd[ 1]*(c*cbbias*s*cosf(h) + c*crbias*s*sinf(h)) + cstd[ 2]*(c*crbias*s*cosf(h) - c*cbbias*s*sinf(h));
matrix[ 4] = c*cstd[ 4];
matrix[ 5] = c*cstd[ 5]*s*cosf(h) - c*cstd[ 6]*s*sinf(h);
matrix[ 6] = c*cstd[ 6]*s*cosf(h) + c*cstd[ 5]*s*sinf(h);
matrix[ 7] = cstd[ 7] + cstd[ 4]*(b + c*ybias) + cstd[ 5]*(c*cbbias*s*cosf(h) + c*crbias*s*sinf(h)) + cstd[ 6]*(c*crbias*s*cosf(h) - c*cbbias*s*sinf(h));
matrix[ 8] = c*cstd[ 8];
matrix[ 9] = c*cstd[ 9]*s*cosf(h) - c*cstd[10]*s*sinf(h);
matrix[10] = c*cstd[10]*s*cosf(h) + c*cstd[ 9]*s*sinf(h);
matrix[11] = cstd[11] + cstd[ 8]*(b + c*ybias) + cstd[ 9]*(c*cbbias*s*cosf(h) + c*crbias*s*sinf(h)) + cstd[10]*(c*crbias*s*cosf(h) - c*cbbias*s*sinf(h));
matrix[12] = c*cstd[12];
matrix[13] = c*cstd[13]*s*cos(h) - c*cstd[14]*s*sin(h);
matrix[14] = c*cstd[14]*s*cos(h) + c*cstd[13]*s*sin(h);
matrix[15] = cstd[15] + cstd[12]*(b + c*ybias) + cstd[13]*(c*cbbias*s*cos(h) + c*crbias*s*sin(h)) + cstd[14]*(c*crbias*s*cos(h) - c*cbbias*s*sin(h));
}
/**************************************************************************
*
* 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 vl_csc_h
#define vl_csc_h
#include <pipe/p_compiler.h>
struct vl_procamp
{
float brightness;
float contrast;
float saturation;
float hue;
};
enum VL_CSC_COLOR_STANDARD
{
VL_CSC_COLOR_STANDARD_IDENTITY,
VL_CSC_COLOR_STANDARD_BT_601,
VL_CSC_COLOR_STANDARD_BT_709
};
void vl_csc_get_matrix(enum VL_CSC_COLOR_STANDARD cs,
struct vl_procamp *procamp,
bool full_range,
float *matrix);
#endif /* vl_csc_h */
This diff is collapsed.
/**************************************************************************
*
* 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 vl_mpeg12_mc_renderer_h
#define vl_mpeg12_mc_renderer_h
#include <pipe/p_compiler.h>
#include <pipe/p_state.h>
#include <pipe/p_video_state.h>
struct pipe_context;
struct pipe_video_surface;
struct pipe_macroblock;
/* A slice is video-width (rounded up to a multiple of macroblock width) x macroblock height */
enum VL_MPEG12_MC_RENDERER_BUFFER_MODE
{
VL_MPEG12_MC_RENDERER_BUFFER_SLICE, /* Saves memory at the cost of smaller batches */
VL_MPEG12_MC_RENDERER_BUFFER_PICTURE /* Larger batches, more memory */
};
enum VL_MPEG12_MC_RENDERER_EMPTY_BLOCK
{
VL_MPEG12_MC_RENDERER_EMPTY_BLOCK_XFER_ALL, /* Waste of memory bandwidth */
VL_MPEG12_MC_RENDERER_EMPTY_BLOCK_XFER_ONE, /* Can only do point-filtering when interpolating subsampled chroma channels */
VL_MPEG12_MC_RENDERER_EMPTY_BLOCK_XFER_NONE /* Needs conditional texel fetch! */
};
struct vl_mpeg12_mc_renderer
{
struct pipe_context *pipe;
unsigned picture_width;
unsigned picture_height;
enum pipe_video_chroma_format chroma_format;
enum VL_MPEG12_MC_RENDERER_BUFFER_MODE bufmode;
enum VL_MPEG12_MC_RENDERER_EMPTY_BLOCK eb_handling;
bool pot_buffers;
unsigned macroblocks_per_batch;
struct pipe_viewport_state viewport;
struct pipe_scissor_state scissor;
struct pipe_buffer *vs_const_buf;
struct pipe_buffer *fs_const_buf;
struct pipe_framebuffer_state fb_state;
void *vertex_elems[3];
union
{
void *all[5];
struct { void *y, *cb, *cr, *ref[2]; } individual;
} samplers;
void *i_vs, *p_vs[2], *b_vs[2];
void *i_fs, *p_fs[2], *b_fs[2];
union
{
struct pipe_texture *all[5];
struct { struct pipe_texture *y, *cb, *cr, *ref[2]; } individual;
} textures;
union
{
struct pipe_vertex_buffer all[3];
struct { struct pipe_vertex_buffer ycbcr, ref[2]; } individual;
} vertex_bufs;
struct pipe_texture *surface, *past, *future;
struct pipe_fence_handle **fence;
unsigned num_macroblocks;
struct pipe_mpeg12_macroblock *macroblock_buf;
struct pipe_transfer *tex_transfer[3];
short *texels[3];
struct { float x, y; } surface_tex_inv_size;
struct { float x, y; } zero_block[3];
};
bool vl_mpeg12_mc_renderer_init(struct vl_mpeg12_mc_renderer *renderer,
struct pipe_context *pipe,
unsigned picture_width,
unsigned picture_height,
enum pipe_video_chroma_format chroma_format,
enum VL_MPEG12_MC_RENDERER_BUFFER_MODE bufmode,
enum VL_MPEG12_MC_RENDERER_EMPTY_BLOCK eb_handling,
bool pot_buffers);
void vl_mpeg12_mc_renderer_cleanup(struct vl_mpeg12_mc_renderer *renderer);
void vl_mpeg12_mc_renderer_render_macroblocks(struct vl_mpeg12_mc_renderer *renderer,
struct pipe_texture *surface,
struct pipe_texture *past,
struct pipe_texture *future,
unsigned num_macroblocks,
struct pipe_mpeg12_macroblock *mpeg12_macroblocks,
struct pipe_fence_handle **fence);