1 /*
2 * Video Decode and Presentation API for UNIX (VDPAU) is used for
3 * HW decode acceleration for MPEG-1/2, MPEG-4 ASP, H.264 and VC-1.
4 *
5 * Copyright (c) 2008 NVIDIA
6 *
7 * This file is part of FFmpeg.
8 *
9 * FFmpeg is free software; you can redistribute it and/or
10 * modify it under the terms of the GNU Lesser General Public
11 * License as published by the Free Software Foundation; either
12 * version 2.1 of the License, or (at your option) any later version.
13 *
14 * FFmpeg is distributed in the hope that it will be useful,
15 * but WITHOUT ANY WARRANTY; without even the implied warranty of
16 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
17 * Lesser General Public License for more details.
18 *
19 * You should have received a copy of the GNU Lesser General Public
20 * License along with FFmpeg; if not, write to the Free Software
21 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
22 */
23
24 #include <limits.h>
28
29 #undef NDEBUG
30 #include <assert.h>
31
34
35 /**
36 * @addtogroup VDPAU_Decoding
37 *
38 * @{
39 */
40
42 {
45 VdpReferenceFrameH264 *rf, *rf2;
47 int i, list, pic_frame_idx;
48
50 assert(render);
51
52 rf = &render->
info.
h264.referenceFrames[0];
53 #define H264_RF_COUNT FF_ARRAY_ELEMS(render->info.h264.referenceFrames)
54
55 for (list = 0; list < 2; ++list) {
58
59 for (i = 0; i < ls; ++i) {
60 pic = lp[i];
62 continue;
64
66 assert(render_ref);
67
68 rf2 = &render->
info.
h264.referenceFrames[0];
69 while (rf2 != rf) {
70 if (
71 (rf2->surface == render_ref->
surface)
72 && (rf2->is_long_term == pic->
long_ref)
73 && (rf2->frame_idx == pic_frame_idx)
74 )
75 break;
76 ++rf2;
77 }
78 if (rf2 != rf) {
81 continue;
82 }
83
85 continue;
86
87 rf->surface = render_ref->
surface;
91 rf->field_order_cnt[0] = pic->
field_poc[0];
92 rf->field_order_cnt[1] = pic->
field_poc[1];
93 rf->frame_idx = pic_frame_idx;
94
95 ++rf;
96 }
97 }
98
100 rf->surface = VDP_INVALID_HANDLE;
101 rf->is_long_term = 0;
102 rf->top_is_reference = 0;
103 rf->bottom_is_reference = 0;
104 rf->field_order_cnt[0] = 0;
105 rf->field_order_cnt[1] = 0;
106 rf->frame_idx = 0;
107 }
108 }
109
111 const uint8_t *buf,
int buf_size)
112 {
114
116 assert(render);
117
122 );
123
128 }
129
131 {
134 int i;
135
137 assert(render);
138
139 for (i = 0; i < 2; ++i) {
141 if (foc == INT_MAX)
142 foc = 0;
143 render->
info.
h264.field_order_cnt[i] = foc;
144 }
145
147 }
148
150 {
153
155 assert(render);
156
158 if (render->
info.
h264.slice_count < 1)
159 return;
160
188
191 }
192
194 int buf_size, int slice_count)
195 {
197 int i;
198
200
202 assert(render);
203
204 /* fill VdpPictureInfoMPEG1Or2 struct */
214 render->
info.
mpeg.full_pel_forward_vector = s->
full_pel[0];
// MPEG-1 only. Set 0 for MPEG-2
215 render->
info.
mpeg.full_pel_backward_vector = s->
full_pel[1];
// MPEG-1 only. Set 0 for MPEG-2
216 render->
info.
mpeg.f_code[0][0] = s->
mpeg_f_code[0][0];
// For MPEG-1 fill both horiz. & vert.
220 for (i = 0; i < 64; ++i) {
223 }
224
225 render->
info.
mpeg.forward_reference = VDP_INVALID_HANDLE;
226 render->
info.
mpeg.backward_reference = VDP_INVALID_HANDLE;
227
231 assert(next);
233 // no return here, going to set forward prediction
236 if (!last)
// FIXME: Does this test make sense?
237 last = render; // predict second field from the first
239 }
240
242
243 render->
info.
mpeg.slice_count = slice_count;
244
245 if (slice_count)
248 }
249
251 int buf_size)
252 {
255
257 assert(render);
258
259 /* fill LvPictureInfoVC1 struct */
281 /* Specific to simple/main profile only */
286
289
290 render->
info.
vc1.forward_reference = VDP_INVALID_HANDLE;
291 render->
info.
vc1.backward_reference = VDP_INVALID_HANDLE;
292
294 render->
info.
vc1.picture_type = 4;
295 else
297
301 assert(next);
303 // no break here, going to set forward prediction
306 if (!last)
// FIXME: Does this test make sense?
307 last = render; // predict second field from the first
309 }
310
312
313 render->
info.
vc1.slice_count = 1;
314
317 }
318
320 int buf_size)
321 {
323 int i;
324
326
328 assert(render);
329
330 /* fill VdpPictureInfoMPEG4Part2 struct */
347 for (i = 0; i < 64; ++i) {
350 }
351 render->
info.
mpeg4.forward_reference = VDP_INVALID_HANDLE;
352 render->
info.
mpeg4.backward_reference = VDP_INVALID_HANDLE;
353
357 assert(next);
360 // no break here, going to set forward prediction
363 assert(last);
365 }
366
368
371 }
372
373 // Only dummy functions for now
375 {
376 return 0;
377 }
378
380 {
381 return 0;
382 }
383
385 {
386 return 0;
387 }
388
390 .
name =
"mpeg1_vdpau",
397 };
398
400 .
name =
"mpeg2_vdpau",
407 };
408
409 /* @}*/