st/va: add iq matrix handling for MJPEG
[mesa.git] / src / gallium / state_trackers / va / picture_mjpeg.c
1 /**************************************************************************
2 *
3 * Copyright 2017 Advanced Micro Devices, Inc.
4 * All Rights Reserved.
5 *
6 * Permission is hereby granted, free of charge, to any person obtaining a
7 * copy of this software and associated documentation files (the
8 * "Software"), to deal in the Software without restriction, including
9 * without limitation the rights to use, copy, modify, merge, publish,
10 * distribute, sub license, and/or sell copies of the Software, and to
11 * permit persons to whom the Software is furnished to do so, subject to
12 * the following conditions:
13 *
14 * The above copyright notice and this permission notice (including the
15 * next paragraph) shall be included in all copies or substantial portions
16 * of the Software.
17 *
18 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
19 * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
20 * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT.
21 * IN NO EVENT SHALL THE COPYRIGHT HOLDER(S) OR AUTHOR(S) BE LIABLE FOR
22 * ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
23 * TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
24 * SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
25 *
26 **************************************************************************/
27
28 #include "va_private.h"
29
30 void vlVaHandlePictureParameterBufferMJPEG(vlVaDriver *drv, vlVaContext *context, vlVaBuffer *buf)
31 {
32 VAPictureParameterBufferJPEGBaseline *mjpeg = buf->data;
33 int i;
34
35 assert(buf->size >= sizeof(VAPictureParameterBufferJPEGBaseline) && buf->num_elements == 1);
36
37 context->desc.mjpeg.picture_parameter.picture_width = mjpeg->picture_width;
38 context->desc.mjpeg.picture_parameter.picture_height = mjpeg->picture_height;
39
40 for (i = 0; i < mjpeg->num_components; ++i) {
41 context->desc.mjpeg.picture_parameter.components[i].component_id =
42 mjpeg->components[i].component_id;
43 context->desc.mjpeg.picture_parameter.components[i].h_sampling_factor =
44 mjpeg->components[i].h_sampling_factor;
45 context->desc.mjpeg.picture_parameter.components[i].v_sampling_factor =
46 mjpeg->components[i].v_sampling_factor;
47 context->desc.mjpeg.picture_parameter.components[i].quantiser_table_selector =
48 mjpeg->components[i].quantiser_table_selector;
49 }
50
51 context->desc.mjpeg.picture_parameter.num_components = mjpeg->num_components;
52 }
53
54 void vlVaHandleIQMatrixBufferMJPEG(vlVaContext *context, vlVaBuffer *buf)
55 {
56 VAIQMatrixBufferJPEGBaseline *mjpeg = buf->data;
57
58 assert(buf->size >= sizeof(VAIQMatrixBufferJPEGBaseline) && buf->num_elements == 1);
59
60 memcpy(&context->desc.mjpeg.quantization_table.load_quantiser_table, mjpeg->load_quantiser_table, 4);
61 memcpy(&context->desc.mjpeg.quantization_table.quantiser_table, mjpeg->quantiser_table, 4 * 64);
62 }
63
64 void vlVaHandleHuffmanTableBufferType(vlVaContext *context, vlVaBuffer *buf)
65 {
66 /* TODO */
67 }
68
69 void vlVaHandleSliceParameterBufferMJPEG(vlVaContext *context, vlVaBuffer *buf)
70 {
71 /* TODO */
72 }