1 /*
2 * This file is part of FFmpeg.
3 *
4 * FFmpeg is free software; you can redistribute it and/or
5 * modify it under the terms of the GNU Lesser General Public
6 * License as published by the Free Software Foundation; either
7 * version 2.1 of the License, or (at your option) any later version.
8 *
9 * FFmpeg is distributed in the hope that it will be useful,
10 * but WITHOUT ANY WARRANTY; without even the implied warranty of
11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
12 * Lesser General Public License for more details.
13 *
14 * You should have received a copy of the GNU Lesser General Public
15 * License along with FFmpeg; if not, write to the Free Software
16 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
17 */
18
19 #include <va/va.h>
20 #include <va/va_dec_jpeg.h>
21
25
29 {
32 VAPictureParameterBufferJPEGBaseline pp;
34
36
37 pp = (VAPictureParameterBufferJPEGBaseline) {
38 .picture_width = avctx->
width,
39 .picture_height = avctx->
height,
40
41 .num_components =
s->nb_components,
42 };
43
44 for (
i = 0;
i <
s->nb_components;
i++) {
45 pp.components[
i].component_id =
s->component_id[
i];
46 pp.components[
i].h_sampling_factor =
s->h_count[
i];
47 pp.components[
i].v_sampling_factor =
s->v_count[
i];
48 pp.components[
i].quantiser_table_selector =
s->quant_index[
i];
49 }
50
52 VAPictureParameterBufferType,
53 &pp, sizeof(pp));
54 if (err < 0)
56
57 return 0;
58
61 return err;
62 }
63
65 {
68
70 }
71
75 {
78 VAHuffmanTableBufferJPEGBaseline huff;
79 VAIQMatrixBufferJPEGBaseline
quant;
80 VASliceParameterBufferJPEGBaseline
sp;
82
83 memset(&huff, 0, sizeof(huff));
84 for (
i = 0;
i < 2;
i++) {
85 huff.load_huffman_table[
i] = 1;
86 for (j = 0; j < 16; j++)
87 huff.huffman_table[
i].num_dc_codes[j] =
s->raw_huffman_lengths[0][
i][j];
88 for (j = 0; j < 12; j++)
89 huff.huffman_table[
i].dc_values[j] =
s->raw_huffman_values[0][
i][j];
90 for (j = 0; j < 16; j++)
91 huff.huffman_table[
i].num_ac_codes[j] =
s->raw_huffman_lengths[1][
i][j];
92 for (j = 0; j < 162; j++)
93 huff.huffman_table[
i].ac_values[j] =
s->raw_huffman_values[1][
i][j];
94 }
95
97 VAHuffmanTableBufferType,
98 &huff, sizeof(huff));
99 if (err < 0)
101
103 for (
i = 0;
i < 4;
i++) {
104 quant.load_quantiser_table[
i] = 1;
105 for (j = 0; j < 64; j++)
106 quant.quantiser_table[
i][j] =
s->quant_matrixes[
i][j];
107 }
108
110 VAIQMatrixBufferType,
112 if (err < 0)
114
115 sp = (VASliceParameterBufferJPEGBaseline) {
116 .slice_data_size =
size,
117 .slice_data_offset = 0,
118 .slice_data_flag = VA_SLICE_DATA_FLAG_ALL,
119
120 .slice_horizontal_position = 0,
121 .slice_vertical_position = 0,
122
123 .restart_interval =
s->restart_interval,
124 .num_mcus =
s->mb_width *
s->mb_height,
125 };
126
127 sp.num_components =
s->nb_components;
128 for (
i = 0;
i <
s->nb_components;
i++) {
129 sp.components[
i].component_selector =
s->component_id[
s->comp_index[
i]];
130 sp.components[
i].dc_table_selector =
s->dc_index[
i];
131 sp.components[
i].ac_table_selector =
s->ac_index[
i];
132 }
133
135 if (err)
137
138 return 0;
139
142 return err;
143 }
144
146 .
name =
"mjpeg_vaapi",
159 };