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
44 {
46
48 return 0;
49 }
50
51 #if CONFIG_H263_VDPAU_HWACCEL || CONFIG_MPEG1_VDPAU_HWACCEL || \
52 CONFIG_MPEG2_VDPAU_HWACCEL || CONFIG_MPEG4_VDPAU_HWACCEL || \
53 CONFIG_VC1_VDPAU_HWACCEL || CONFIG_WMV3_VDPAU_HWACCEL
55 {
59
62
65
66 return 0;
67 }
68 #endif
69
72 {
75
78 if (!buffers)
80
83
84 buffers->struct_version = VDP_BITSTREAM_BUFFER_VERSION;
85 buffers->bitstream =
buf;
86 buffers->bitstream_bytes =
size;
87 return 0;
88 }
89
90 /* Obsolete non-hwaccel VDPAU support below... */
91
93 {
95 VdpReferenceFrameH264 *rf, *rf2;
97 int i, list, pic_frame_idx;
98
100 assert(render);
101
102 rf = &render->
info.
h264.referenceFrames[0];
103 #define H264_RF_COUNT FF_ARRAY_ELEMS(render->info.h264.referenceFrames)
104
105 for (list = 0; list < 2; ++list) {
108
109 for (i = 0; i < ls; ++i) {
110 pic = lp[i];
112 continue;
114
116 assert(render_ref);
117
118 rf2 = &render->
info.
h264.referenceFrames[0];
119 while (rf2 != rf) {
120 if (
121 (rf2->surface == render_ref->
surface)
122 && (rf2->is_long_term == pic->
long_ref)
123 && (rf2->frame_idx == pic_frame_idx)
124 )
125 break;
126 ++rf2;
127 }
128 if (rf2 != rf) {
131 continue;
132 }
133
135 continue;
136
137 rf->surface = render_ref->
surface;
141 rf->field_order_cnt[0] = pic->
field_poc[0];
142 rf->field_order_cnt[1] = pic->
field_poc[1];
143 rf->frame_idx = pic_frame_idx;
144
145 ++rf;
146 }
147 }
148
150 rf->surface = VDP_INVALID_HANDLE;
151 rf->is_long_term = 0;
152 rf->top_is_reference = 0;
153 rf->bottom_is_reference = 0;
154 rf->field_order_cnt[0] = 0;
155 rf->field_order_cnt[1] = 0;
156 rf->frame_idx = 0;
157 }
158 }
159
161 {
163 assert(render);
164
169 );
170
175 }
176
177 #if CONFIG_H264_VDPAU_DECODER
179 {
181 int i;
182
184 assert(render);
185
186 for (i = 0; i < 2; ++i) {
188 if (foc == INT_MAX)
189 foc = 0;
190 render->
info.
h264.field_order_cnt[i] = foc;
191 }
192
194 }
195
197 {
199
201 assert(render);
202
204 if (render->
info.
h264.slice_count < 1)
205 return;
206
234
237 }
238 #endif /* CONFIG_H264_VDPAU_DECODER */
239
240 #if CONFIG_MPEG_VDPAU_DECODER || CONFIG_MPEG1_VDPAU_DECODER
242 int buf_size, int slice_count)
243 {
245 int i;
246
248
250 assert(render);
251
252 /* fill VdpPictureInfoMPEG1Or2 struct */
262 render->
info.
mpeg.full_pel_forward_vector = s->
full_pel[0];
// MPEG-1 only. Set 0 for MPEG-2
263 render->
info.
mpeg.full_pel_backward_vector = s->
full_pel[1];
// MPEG-1 only. Set 0 for MPEG-2
264 render->
info.
mpeg.f_code[0][0] = s->
mpeg_f_code[0][0];
// For MPEG-1 fill both horiz. & vert.
268 for (i = 0; i < 64; ++i) {
271 }
272
273 render->
info.
mpeg.forward_reference = VDP_INVALID_HANDLE;
274 render->
info.
mpeg.backward_reference = VDP_INVALID_HANDLE;
275
279 assert(next);
281 // no return here, going to set forward prediction
284 if (!last)
// FIXME: Does this test make sense?
285 last = render; // predict second field from the first
287 }
288
290
291 render->
info.
mpeg.slice_count = slice_count;
292
293 if (slice_count)
296 }
297 #endif /* CONFIG_MPEG_VDPAU_DECODER || CONFIG_MPEG1_VDPAU_DECODER */
298
299 #if CONFIG_VC1_VDPAU_DECODER
301 int buf_size)
302 {
305
307 assert(render);
308
309 /* fill LvPictureInfoVC1 struct */
310 render->
info.
vc1.frame_coding_mode = v->
fcm ? v->
fcm + 1 : 0;
331 /* Specific to simple/main profile only */
336
339
340 render->
info.
vc1.forward_reference = VDP_INVALID_HANDLE;
341 render->
info.
vc1.backward_reference = VDP_INVALID_HANDLE;
342
344 render->
info.
vc1.picture_type = 4;
345 else
347
351 assert(next);
353 // no break here, going to set forward prediction
356 if (!last)
// FIXME: Does this test make sense?
357 last = render; // predict second field from the first
359 }
360
362
363 render->
info.
vc1.slice_count = 1;
364
367 }
368 #endif /* (CONFIG_VC1_VDPAU_DECODER */
369
370 #if CONFIG_MPEG4_VDPAU_DECODER
372 int buf_size)
373 {
375 int i;
376
378
380 assert(render);
381
382 /* fill VdpPictureInfoMPEG4Part2 struct */
399 for (i = 0; i < 64; ++i) {
402 }
403 render->
info.
mpeg4.forward_reference = VDP_INVALID_HANDLE;
404 render->
info.
mpeg4.backward_reference = VDP_INVALID_HANDLE;
405
409 assert(next);
412 // no break here, going to set forward prediction
415 assert(last);
417 }
418
420
423 }
424 #endif /* CONFIG_MPEG4_VDPAU_DECODER */
425
426 /* @}*/