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
;
36 assert(buf
->size
>= sizeof(VAPictureParameterBufferJPEGBaseline
) && buf
->num_elements
== 1);
38 context
->desc
.mjpeg
.picture_parameter
.picture_width
= mjpeg
->picture_width
;
39 context
->desc
.mjpeg
.picture_parameter
.picture_height
= mjpeg
->picture_height
;
41 for (i
= 0; i
< mjpeg
->num_components
; ++i
) {
42 context
->desc
.mjpeg
.picture_parameter
.components
[i
].component_id
=
43 mjpeg
->components
[i
].component_id
;
44 context
->desc
.mjpeg
.picture_parameter
.components
[i
].h_sampling_factor
=
45 mjpeg
->components
[i
].h_sampling_factor
;
46 context
->desc
.mjpeg
.picture_parameter
.components
[i
].v_sampling_factor
=
47 mjpeg
->components
[i
].v_sampling_factor
;
48 context
->desc
.mjpeg
.picture_parameter
.components
[i
].quantiser_table_selector
=
49 mjpeg
->components
[i
].quantiser_table_selector
;
51 sf
= mjpeg
->components
[i
].h_sampling_factor
<< 4 | mjpeg
->components
[i
].v_sampling_factor
;
52 context
->mjpeg
.sampling_factor
<<= 8;
53 context
->mjpeg
.sampling_factor
|= sf
;
56 context
->desc
.mjpeg
.picture_parameter
.num_components
= mjpeg
->num_components
;
59 void vlVaHandleIQMatrixBufferMJPEG(vlVaContext
*context
, vlVaBuffer
*buf
)
61 VAIQMatrixBufferJPEGBaseline
*mjpeg
= buf
->data
;
63 assert(buf
->size
>= sizeof(VAIQMatrixBufferJPEGBaseline
) && buf
->num_elements
== 1);
65 memcpy(&context
->desc
.mjpeg
.quantization_table
.load_quantiser_table
, mjpeg
->load_quantiser_table
, 4);
66 memcpy(&context
->desc
.mjpeg
.quantization_table
.quantiser_table
, mjpeg
->quantiser_table
, 4 * 64);
69 void vlVaHandleHuffmanTableBufferType(vlVaContext
*context
, vlVaBuffer
*buf
)
71 VAHuffmanTableBufferJPEGBaseline
*mjpeg
= buf
->data
;
74 assert(buf
->size
>= sizeof(VASliceParameterBufferJPEGBaseline
) && buf
->num_elements
== 1);
76 for (i
= 0; i
< 2; ++i
) {
77 context
->desc
.mjpeg
.huffman_table
.load_huffman_table
[i
] = mjpeg
->load_huffman_table
[i
];
79 memcpy(&context
->desc
.mjpeg
.huffman_table
.table
[i
].num_dc_codes
,
80 mjpeg
->huffman_table
[i
].num_dc_codes
, 16);
81 memcpy(&context
->desc
.mjpeg
.huffman_table
.table
[i
].dc_values
,
82 mjpeg
->huffman_table
[i
].dc_values
, 12);
83 memcpy(&context
->desc
.mjpeg
.huffman_table
.table
[i
].num_ac_codes
,
84 mjpeg
->huffman_table
[i
].num_ac_codes
, 16);
85 memcpy(&context
->desc
.mjpeg
.huffman_table
.table
[i
].ac_values
,
86 mjpeg
->huffman_table
[i
].ac_values
, 162);
87 memcpy(&context
->desc
.mjpeg
.huffman_table
.table
[i
].pad
, mjpeg
->huffman_table
[i
].pad
, 2);
91 void vlVaHandleSliceParameterBufferMJPEG(vlVaContext
*context
, vlVaBuffer
*buf
)
93 VASliceParameterBufferJPEGBaseline
*mjpeg
= buf
->data
;
96 assert(buf
->size
>= sizeof(VASliceParameterBufferJPEGBaseline
) && buf
->num_elements
== 1);
98 context
->desc
.mjpeg
.slice_parameter
.slice_data_size
= mjpeg
->slice_data_size
;
99 context
->desc
.mjpeg
.slice_parameter
.slice_data_offset
= mjpeg
->slice_data_offset
;
100 context
->desc
.mjpeg
.slice_parameter
.slice_data_flag
= mjpeg
->slice_data_flag
;
101 context
->desc
.mjpeg
.slice_parameter
.slice_horizontal_position
= mjpeg
->slice_horizontal_position
;
102 context
->desc
.mjpeg
.slice_parameter
.slice_vertical_position
= mjpeg
->slice_vertical_position
;
104 for (i
= 0; i
< mjpeg
->num_components
; ++i
) {
105 context
->desc
.mjpeg
.slice_parameter
.components
[i
].component_selector
=
106 mjpeg
->components
[i
].component_selector
;
107 context
->desc
.mjpeg
.slice_parameter
.components
[i
].dc_table_selector
=
108 mjpeg
->components
[i
].dc_table_selector
;
109 context
->desc
.mjpeg
.slice_parameter
.components
[i
].ac_table_selector
=
110 mjpeg
->components
[i
].ac_table_selector
;
113 context
->desc
.mjpeg
.slice_parameter
.num_components
= mjpeg
->num_components
;
114 context
->desc
.mjpeg
.slice_parameter
.restart_interval
= mjpeg
->restart_interval
;
115 context
->desc
.mjpeg
.slice_parameter
.num_mcus
= mjpeg
->num_mcus
;