1 /*
2 * MPEG-4 / H.263 HW decode acceleration through VA API
3 *
4 * Copyright (C) 2008-2009 Splitted-Desktop Systems
5 *
6 * This file is part of FFmpeg.
7 *
8 * FFmpeg is free software; you can redistribute it and/or
9 * modify it under the terms of the GNU Lesser General Public
10 * License as published by the Free Software Foundation; either
11 * version 2.1 of the License, or (at your option) any later version.
12 *
13 * FFmpeg is distributed in the hope that it will be useful,
14 * but WITHOUT ANY WARRANTY; without even the implied warranty of
15 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
16 * Lesser General Public License for more details.
17 *
18 * You should have received a copy of the GNU Lesser General Public
19 * License along with FFmpeg; if not, write to the Free Software
20 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
21 */
22
23 #include "config_components.h"
24
31
32 /** Reconstruct bitstream intra_dc_vlc_thr */
34 {
35 switch (
s->intra_dc_threshold) {
36 case 99: return 0;
37 case 13: return 1;
38 case 15: return 2;
39 case 17: return 3;
40 case 19: return 4;
41 case 21: return 5;
42 case 23: return 6;
43 case 0: return 7;
44 }
45 return 0;
46 }
47
52 {
56 VAPictureParameterBufferMPEG4 pic_param;
58
60
61 pic_param = (VAPictureParameterBufferMPEG4) {
62 .vop_width =
s->width,
63 .vop_height =
s->height,
64 .forward_reference_picture = VA_INVALID_ID,
65 .backward_reference_picture = VA_INVALID_ID,
66 .vol_fields.bits = {
69 .interlaced = !
s->progressive_sequence,
70 .obmc_disable = 1,
71 .sprite_enable =
ctx->vol_sprite_usage,
72 .sprite_warping_accuracy =
ctx->sprite_warping_accuracy,
73 .quant_type =
ctx->mpeg_quant,
74 .quarter_sample =
s->quarter_sample,
75 .data_partitioned =
ctx->h.data_partitioning,
76 .reversible_vlc =
ctx->rvlc,
77 .resync_marker_disable = !
ctx->resync_marker,
78 },
79 .no_of_sprite_warping_points =
ctx->num_sprite_warping_points,
80 .quant_precision =
ctx->quant_precision,
81 .vop_fields.bits = {
83 .backward_reference_vop_coding_type =
85 .vop_rounding_type =
s->no_rounding,
87 .top_field_first =
s->top_field_first,
88 .alternate_vertical_scan_flag =
s->alternate_scan,
89 },
90 .vop_fcode_forward =
ctx->f_code,
91 .vop_fcode_backward =
ctx->b_code,
94 .num_gobs_in_vop =
98 };
99
100 for (
i = 0;
i <
ctx->num_sprite_warping_points &&
i < 3;
i++) {
101 pic_param.sprite_trajectory_du[
i] =
ctx->sprite_traj[
i][0];
102 pic_param.sprite_trajectory_dv[
i] =
ctx->sprite_traj[
i][1];
103 }
104
109
111 VAPictureParameterBufferType,
112 &pic_param, sizeof(pic_param));
113 if (err < 0)
115
116 /* Only the first inverse quantisation method uses the weighting matrices */
117 if (pic_param.vol_fields.bits.quant_type) {
118 VAIQMatrixBufferMPEG4 iq_matrix;
119
120 iq_matrix.load_intra_quant_mat = 1;
121 iq_matrix.load_non_intra_quant_mat = 1;
122
123 for (
i = 0;
i < 64;
i++) {
125 iq_matrix.intra_quant_mat[
i] =
s->intra_matrix[n];
126 iq_matrix.non_intra_quant_mat[
i] =
s->inter_matrix[n];
127 }
128
130 VAIQMatrixBufferType,
131 &iq_matrix, sizeof(iq_matrix));
132 if (err < 0)
134 }
135 return 0;
136
139 return err;
140 }
141
143 {
147
151
153
156 }
157
159 {
162 VASliceParameterBufferMPEG4 slice_param;
163 int err;
164
165 slice_param = (VASliceParameterBufferMPEG4) {
166 .slice_data_size =
size,
167 .slice_data_offset = 0,
168 .slice_data_flag = VA_SLICE_DATA_FLAG_ALL,
170 .macroblock_number = 0,
171 .quant_scale =
h->c.qscale,
172 };
173
175 &slice_param, 1, sizeof(slice_param),
177 if (err < 0) {
179 return err;
180 }
181
182 return 0;
183 }
184
185 #if CONFIG_MPEG4_VAAPI_HWACCEL
187 .
p.
name =
"mpeg4_vaapi",
200 };
201 #endif
202
203 #if CONFIG_H263_VAAPI_HWACCEL
205 .
p.
name =
"h263_vaapi",
218 };
219 #endif