1 /**************************************************************************
3 * Copyright 2017 Advanced Micro Devices, Inc.
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:
14 * The above copyright notice and this permission notice (including the
15 * next paragraph) shall be included in all copies or substantial portions
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.
26 **************************************************************************/
28 #include "va_private.h"
30 void vlVaHandlePictureParameterBufferMJPEG(vlVaDriver
*drv
, vlVaContext
*context
, vlVaBuffer
*buf
)
32 VAPictureParameterBufferJPEGBaseline
*mjpeg
= buf
->data
;
35 assert(buf
->size
>= sizeof(VAPictureParameterBufferJPEGBaseline
) && buf
->num_elements
== 1);
37 context
->desc
.mjpeg
.picture_parameter
.picture_width
= mjpeg
->picture_width
;
38 context
->desc
.mjpeg
.picture_parameter
.picture_height
= mjpeg
->picture_height
;
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
;
51 context
->desc
.mjpeg
.picture_parameter
.num_components
= mjpeg
->num_components
;
54 void vlVaHandleIQMatrixBufferMJPEG(vlVaContext
*context
, vlVaBuffer
*buf
)
56 VAIQMatrixBufferJPEGBaseline
*mjpeg
= buf
->data
;
58 assert(buf
->size
>= sizeof(VAIQMatrixBufferJPEGBaseline
) && buf
->num_elements
== 1);
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);
64 void vlVaHandleHuffmanTableBufferType(vlVaContext
*context
, vlVaBuffer
*buf
)
66 VAHuffmanTableBufferJPEGBaseline
*mjpeg
= buf
->data
;
69 assert(buf
->size
>= sizeof(VASliceParameterBufferJPEGBaseline
) && buf
->num_elements
== 1);
71 for (i
= 0; i
< 2; ++i
) {
72 context
->desc
.mjpeg
.huffman_table
.load_huffman_table
[i
] = mjpeg
->load_huffman_table
[i
];
74 memcpy(&context
->desc
.mjpeg
.huffman_table
.table
[i
].num_dc_codes
,
75 mjpeg
->huffman_table
[i
].num_dc_codes
, 16);
76 memcpy(&context
->desc
.mjpeg
.huffman_table
.table
[i
].dc_values
,
77 mjpeg
->huffman_table
[i
].dc_values
, 12);
78 memcpy(&context
->desc
.mjpeg
.huffman_table
.table
[i
].num_ac_codes
,
79 mjpeg
->huffman_table
[i
].num_ac_codes
, 16);
80 memcpy(&context
->desc
.mjpeg
.huffman_table
.table
[i
].ac_values
,
81 mjpeg
->huffman_table
[i
].ac_values
, 162);
82 memcpy(&context
->desc
.mjpeg
.huffman_table
.table
[i
].pad
, mjpeg
->huffman_table
[i
].pad
, 2);
86 void vlVaHandleSliceParameterBufferMJPEG(vlVaContext
*context
, vlVaBuffer
*buf
)