1 /*
2 * MPEG-2 HW acceleration.
3 *
4 * copyright (c) 2010 Laurent Aimar
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
24
25 #define MAX_SLICES (SLICE_MAX_START_CODE - SLICE_MIN_START_CODE + 1)
27 DXVA_PictureParameters
pp;
31
34 };
35
39 DXVA_PictureParameters *pp)
40 {
43
44 memset(pp, 0, sizeof(*pp));
46 pp->wDeblockedPictureIndex = 0;
49 else
50 pp->wForwardRefPictureIndex = 0xffff;
53 else
54 pp->wBackwardRefPictureIndex = 0xffff;
55 pp->wPicWidthInMBminus1 = s->
mb_width - 1;
56 pp->wPicHeightInMBminus1 = (s->
mb_height >> is_field) - 1;
57 pp->bMacroblockWidthMinus1 = 15;
58 pp->bMacroblockHeightMinus1 = 15;
59 pp->bBlockWidthMinus1 = 7;
60 pp->bBlockHeightMinus1 = 7;
61 pp->bBPPminus1 = 7;
66 pp->bBidirectionalAveragingMode = 0;
67 pp->bMVprecisionAndChromaRelation= 0; /* FIXME */
69 pp->bPicScanFixed = 1;
71 pp->bPicReadbackRequests = 0;
72 pp->bRcontrol = 0;
73 pp->bPicSpatialResid8 = 0;
74 pp->bPicOverflowBlocks = 0;
75 pp->bPicExtrapolation = 0;
76 pp->bPicDeblocked = 0;
77 pp->bPicDeblockConfined = 0;
78 pp->bPic4MVallowed = 0;
79 pp->bPicOBMC = 0;
80 pp->bPicBinPB = 0;
81 pp->bMV_RPS = 0;
82 pp->bReservedBits = 0;
83 pp->wBitstreamFcodes = (s->
mpeg_f_code[0][0] << 12) |
98 pp->bBitstreamConcealmentNeed = 0;
99 pp->bBitstreamConcealmentMethod = 0;
100 }
101
105 DXVA_QmatrixData *qm)
106 {
107 int i;
108 for (i = 0; i < 4; i++)
109 qm->bNewQmatrix[i] = 1;
110 for (i = 0; i < 64; i++) {
116 }
117 }
118
121 DXVA_SliceInfo *slice,
122 unsigned position,
124 {
127
128 memset(slice, 0, sizeof(*slice));
129 slice->wHorizontalPosition = s->
mb_x;
130 slice->wVerticalPosition = s->
mb_y >> is_field;
131 slice->dwSliceBitsInBuffer = 8 *
size;
132 slice->dwSliceDataLocation = position;
133 slice->bStartCodeBitOffset = 0;
134 slice->bReservedBits = 0;
135 /* XXX We store the index of the first MB and it will be fixed later */
137 slice->wBadSliceChopping = 0;
138
140
141 slice->wQuantizerScaleCode =
get_bits(&gb, 5);
144
146 }
148 DXVA2_DecodeBufferDesc *bs,
149 DXVA2_DecodeBufferDesc *sc)
150 {
158 unsigned dxva_size;
159 unsigned i;
160
162 DXVA2_BitStreamDateBufferType,
163 (void **)&dxva_data, &dxva_size)))
164 return -1;
165 current = dxva_data;
166 end = dxva_data + dxva_size;
167
170 unsigned position = slice->dwSliceDataLocation;
171 unsigned size = slice->dwSliceBitsInBuffer / 8;
172 if (size > end - current) {
174 break;
175 }
176 slice->dwSliceDataLocation = current - dxva_data;
177
179 slice->wNumberMBsInSlice =
180 slice[1].wNumberMBsInSlice - slice[0].wNumberMBsInSlice;
181 else
182 slice->wNumberMBsInSlice =
183 mb_count - slice[0].wNumberMBsInSlice;
184
185 memcpy(current, &ctx_pic->
bitstream[position], size);
187 }
189 DXVA2_BitStreamDateBufferType)))
190 return -1;
192 return -1;
193
194 memset(bs, 0, sizeof(*bs));
195 bs->CompressedBufferType = DXVA2_BitStreamDateBufferType;
196 bs->DataSize = current - dxva_data;
197 bs->NumMBsInBuffer = mb_count;
198
200 DXVA2_SliceControlBufferType,
203 mb_count);
204 }
205
209 {
214
216 return -1;
217 assert(ctx_pic);
218
221
225 return 0;
226 }
227
230 {
234 unsigned position;
235
237 return -1;
238
242
245 buffer, size);
246 return 0;
247 }
248
250 {
255
257 return -1;
259 &ctx_pic->
pp,
sizeof(ctx_pic->
pp),
260 &ctx_pic->
qm,
sizeof(ctx_pic->
qm),
262 if (!ret)
265 }
266
268 .
name =
"mpeg2_dxva2",
276 };