summaryrefslogtreecommitdiff
blob: c7216093f532438bb0924d376fd80c93367c6d7e (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
1001
1002
1003
1004
1005
1006
1007
1008
1009
1010
1011
1012
1013
1014
1015
1016
1017
1018
1019
1020
1021
1022
1023
1024
1025
1026
1027
1028
1029
1030
1031
1032
1033
1034
1035
1036
1037
1038
1039
1040
1041
1042
1043
1044
1045
1046
1047
1048
1049
1050
1051
1052
1053
1054
1055
1056
1057
1058
1059
1060
1061
1062
1063
1064
1065
1066
1067
1068
1069
1070
1071
1072
1073
1074
1075
1076
1077
1078
1079
1080
1081
1082
1083
1084
1085
1086
1087
1088
1089
1090
1091
1092
1093
1094
1095
1096
1097
1098
1099
1100
1101
1102
1103
1104
1105
1106
1107
1108
1109
1110
1111
1112
1113
1114
1115
1116
1117
1118
1119
1120
1121
1122
1123
1124
1125
1126
1127
1128
1129
1130
1131
1132
1133
1134
1135
1136
1137
1138
1139
1140
1141
1142
1143
1144
1145
1146
1147
1148
1149
1150
1151
1152
1153
1154
1155
1156
1157
1158
1159
1160
1161
1162
1163
1164
1165
1166
1167
1168
1169
1170
1171
1172
1173
1174
1175
1176
1177
1178
1179
1180
1181
1182
1183
1184
1185
1186
1187
1188
1189
1190
1191
1192
1193
1194
1195
1196
1197
1198
1199
diff --git a/configure b/configure
index 39fef26..3a97c6e 100755
--- a/configure
+++ b/configure
@@ -549,7 +549,7 @@ _libopencore_amrnb=auto
 _libavbsfs_all=$(sed -n 's/^[^#]*BSF.*(.*, *\(.*\)).*/\1_bsf/p' libavcodec/allcodecs.c | tr '[a-z]' '[A-Z]')
 _libavbsfs=$_libavbsfs_all
 _libavhwaccels_all=$(sed -n 's/^[^#]*HWACCEL.*(.*, *\(.*\)).*/\1_hwaccel/p' libavcodec/allcodecs.c | tr '[a-z]' '[A-Z]')
-_libavhwaccels=$(for h in $_libavhwaccels_all; do case $h in (*_VAAPI_HWACCEL) echo $h;; esac; done)
+_libavhwaccels=$(for h in $_libavhwaccels_all; do case $h in (*_VDPAU_HWACCEL|*_VAAPI_HWACCEL) echo $h;; esac; done)
 _libavdemuxers_all=$(sed -n 's/^[^#]*DEMUX.*(.*, *\(.*\)).*/\1_demuxer/p' libavformat/allformats.c | tr '[a-z]' '[A-Z]')
 _libavdemuxers=$(echo $_libavdemuxers_all | sed -e 's/ LIB[A-Z0-9_]*_DEMUXER//g' -e s/REDIR_DEMUXER// -e s/AVISYNTH_DEMUXER//)
 _libavmuxers_all=$(sed -n 's/^[^#]*_MUX.*(.*, *\(.*\)).*/\1_muxer/p' libavformat/allformats.c | tr '[a-z]' '[A-Z]')
@@ -4500,7 +4500,7 @@ if test "$_vdpau" = yes ; then
 else
   def_vdpau='#define CONFIG_VDPAU 0'
   _novomodules="vdpau $_novomodules"
-  _libavdecoders=$(echo $_libavdecoders | sed -e "s/\(MPEG\|MPEG[124]\|H26[34]\|WMV3\|VC1\)_VDPAU_DECODER//g")
+  _libavhwaccels=$(echo $_libavhwaccels | sed -e "s/\(MPEG[124]\|H26[34]\|WMV3\|VC1\)_VDPAU_HWACCEL//g")
 fi
 echores "$_vdpau"
 
diff --git a/etc/codecs.conf b/etc/codecs.conf
index 15c6e8d..8f6a122 100644
--- a/etc/codecs.conf
+++ b/etc/codecs.conf
@@ -146,6 +146,7 @@ videocodec ffmpeg1
   fourcc m1v1
   driver ffmpeg
   dll "mpeg1video"
+  out VDPAU_MPEG1
   out YV12,I420,IYUV
 
 videocodec ffmpeg2
@@ -182,6 +183,7 @@ videocodec ffmpeg2
   driver ffmpeg
   dll "mpeg2video"
   out VAAPI_MPEG2
+  out VDPAU_MPEG2
   out YV12,I420,IYUV
   out 422P,444P
 
@@ -221,6 +223,7 @@ videocodec ffmpeg12
   fourcc slif ; SoftLab MPEG-2 I-frames Codec
   driver ffmpeg
   dll "mpegvideo"
+  out VDPAU_MPEG1,VDPAU_MPEG2
   out YV12,I420,IYUV
   out 422P,444P
 
@@ -307,44 +310,6 @@ videocodec ffmpeg12mc
   out IDCT_MPEG2
   out MOCO_MPEG2
 
-videocodec ffmpeg12vdpau
-  info "FFmpeg MPEG-1/2 (VDPAU)"
-  status working
-  format 0x10000001  ; MPEG-1
-  format 0x10000002  ; MPEG-2
-  fourcc mpg1,mpg2,MPG2
-  fourcc PIM1        ; Pinnacle hardware-MPEG-1
-  fourcc PIM2        ; Pinnacle hardware-MPEG-2
-  fourcc "DVR "
-  fourcc hdv2
-  fourcc MPEG
-  fourcc hdv1
-  fourcc hdv3        ; HDV 1080i50
-  fourcc hdv5        ; HDV  720p25
-  fourcc mx5p        ; MPEG IMX 625/50 (50 Mb/s)
-  fourcc MMES,mmes   ; matrox mpeg2 in avi
-  fourcc hdv6,hdv7,hdv8
-  fourcc xdv1,xdv2,xdv3
-  fourcc xdv4,xdv5,xdv6
-  fourcc xdv7,xdv8,xdv9
-  fourcc xdva,xdvb,xdvc
-  fourcc xdvd,xdve,xdvf
-  fourcc xd5a,xd5b,xd5c
-  fourcc xd5d,xd5e,xd5f
-  fourcc xd59
-  fourcc mx5n,mx4n,mx4p
-  fourcc mx3n,mx3p
-  fourcc AVmp
-  fourcc mp2v,mpgv
-  fourcc LMP2 ; Lead mpeg2 in avi
-  fourcc m2v1,m1v1
-  driver ffmpeg
-  dll "mpegvideo_vdpau"
-  out VDPAU_MPEG1
-  out VDPAU_MPEG2
-
-; we have only native open source codecs for these:
-
 videocodec ffnuv
   info "NuppelVideo"
   status working
@@ -883,15 +849,8 @@ videocodec ffwmv3
   driver ffmpeg
   dll wmv3
   out VAAPI_WMV3
-  out YV12,I420,IYUV
-
-videocodec ffwmv3vdpau
-  info "FFmpeg WMV3/WMV9 (VDPAU)"
-  status buggy
-  fourcc WMV3,wmv3
-  driver ffmpeg
-  dll wmv3_vdpau
   out VDPAU_WMV3
+  out YV12,I420,IYUV
 
 videocodec ffvc1
   info "FFmpeg WVC1"
@@ -901,16 +860,8 @@ videocodec ffvc1
   driver ffmpeg
   dll vc1
   out VAAPI_VC1
-  out YV12,I420,IYUV
-
-videocodec ffvc1vdpau
-  info "FFmpeg WVC1 (VDPAU)"
-  status buggy
-  fourcc WVC1,wvc1,WMVA
-  fourcc vc-1,VC-1
-  driver ffmpeg
-  dll vc1_vdpau
   out VDPAU_VC1
+  out YV12,I420,IYUV
 
 videocodec ffh264
   info "FFmpeg H.264"
@@ -923,19 +874,8 @@ videocodec ffh264
   driver ffmpeg
   dll h264
   out VAAPI_H264
-  out YV12,I420,IYUV
-
-videocodec ffh264vdpau
-  info "FFmpeg H.264 (VDPAU)"
-  status working
-  fourcc H264,h264
-  fourcc X264,x264
-  fourcc avc1,AVC1
-  fourcc davc,DAVC
-  format 0x10000005
-  driver ffmpeg
-  dll h264_vdpau
   out VDPAU_H264
+  out YV12,I420,IYUV
 
 videocodec coreavcwindows
   info "CoreAVC H.264 for x86 - http://corecodec.org/"
@@ -994,39 +933,8 @@ videocodec ffodivx
   driver ffmpeg
   dll mpeg4 ;opendivx
   out VAAPI_MPEG4
-  out YV12,I420,IYUV
-
-videocodec ffodivxvdpau
-  info "FFmpeg MPEG-4,DIVX-4/5 (VDPAU)"
-  status working
-  fourcc FMP4,fmp4
-  fourcc DIVX,divx
-  fourcc DIV1,div1 divx
-  fourcc MP4S,mp4s ; ISO MPEG-4 Video V1
-  fourcc M4S2,m4s2
-  fourcc xvid,XVID,XviD,XVIX
-  fourcc DX50,dx50,BLZ0 DX50
-  fourcc mp4v,MP4V
-  format 0x4
-  fourcc UMP4
-  fourcc RMP4
-  fourcc 3IV2,3iv2  ; 3ivx Delta 4
-  fourcc DXGM
-  fourcc SEDG ; diskless camcorder Samsung Miniket VP-M110
-  fourcc SMP4,smp4 ; Samsung SMP4 video codec
-  fourcc VIDM ; vidm 4.01 codec
-  format 0x10000004  ; mpeg 4 es
-  fourcc m4cc,M4CC
-  fourcc hdx4,HDX4
-  fourcc FVFW,fvfw
-  fourcc FFDS
-  fourcc DCOD,MVXM,EM4A,PM4V
-  fourcc M4T3,DMK2,DIGI,INMC
-  fourcc EPHV,SN40
-  fourcc uldx,ULDX,VSPX
-  driver ffmpeg
-  dll mpeg4_vdpau
   out VDPAU_MPEG4
+  out YV12,I420,IYUV
 
 videocodec ffwv1f
   info "WV1F MPEG-4"
diff --git a/fmt-conversion.c b/fmt-conversion.c
index a9ba43d..cf5566d 100644
--- a/fmt-conversion.c
+++ b/fmt-conversion.c
@@ -81,12 +81,6 @@ static const struct {
 
     {IMGFMT_XVMC_MOCO_MPEG2, PIX_FMT_XVMC_MPEG2_MC},
     {IMGFMT_XVMC_IDCT_MPEG2, PIX_FMT_XVMC_MPEG2_IDCT},
-    {IMGFMT_VDPAU_MPEG1,     PIX_FMT_VDPAU_MPEG1},
-    {IMGFMT_VDPAU_MPEG2,     PIX_FMT_VDPAU_MPEG2},
-    {IMGFMT_VDPAU_H264,      PIX_FMT_VDPAU_H264},
-    {IMGFMT_VDPAU_WMV3,      PIX_FMT_VDPAU_WMV3},
-    {IMGFMT_VDPAU_VC1,       PIX_FMT_VDPAU_VC1},
-    {IMGFMT_VDPAU_MPEG4,     PIX_FMT_VDPAU_MPEG4},
 
     /* VA API formats */
     {IMGFMT_VAAPI_MPEG2,     PIX_FMT_VAAPI_VLD,  CODEC_ID_MPEG2VIDEO},
@@ -98,6 +92,14 @@ static const struct {
     {IMGFMT_VAAPI_WMV3,      PIX_FMT_VAAPI_VLD,  CODEC_ID_WMV3},
     {IMGFMT_VAAPI_VC1,       PIX_FMT_VAAPI_VLD,  CODEC_ID_VC1},
 
+    /* VDPAU formats */
+    {IMGFMT_VDPAU_MPEG1,     PIX_FMT_VDPAU, CODEC_ID_MPEG1VIDEO},
+    {IMGFMT_VDPAU_MPEG2,     PIX_FMT_VDPAU, CODEC_ID_MPEG2VIDEO},
+    {IMGFMT_VDPAU_MPEG4,     PIX_FMT_VDPAU, CODEC_ID_MPEG4},
+    {IMGFMT_VDPAU_H264,      PIX_FMT_VDPAU, CODEC_ID_H264},
+    {IMGFMT_VDPAU_WMV3,      PIX_FMT_VDPAU, CODEC_ID_WMV3},
+    {IMGFMT_VDPAU_VC1,       PIX_FMT_VDPAU, CODEC_ID_VC1},
+
     {0, PIX_FMT_NONE}
 };
 
diff --git a/libavcodec/allcodecs.c b/libavcodec/allcodecs.c
index 43e49d1..646c590 100644
--- a/libavcodec/allcodecs.c
+++ b/libavcodec/allcodecs.c
@@ -61,6 +61,13 @@ void avcodec_register_all(void)
     REGISTER_HWACCEL (VC1_VAAPI, vc1_vaapi);
     REGISTER_HWACCEL (WMV3_VAAPI, wmv3_vaapi);
 
+    REGISTER_HWACCEL (H264_VDPAU, h264_vdpau);
+    REGISTER_HWACCEL (MPEG1_VDPAU, mpeg1_vdpau);
+    REGISTER_HWACCEL (MPEG2_VDPAU, mpeg2_vdpau);
+    REGISTER_HWACCEL (MPEG4_VDPAU, mpeg4_vdpau);
+    REGISTER_HWACCEL (VC1_VDPAU, vc1_vdpau);
+    REGISTER_HWACCEL (WMV3_VDPAU, wmv3_vdpau);
+
     /* video codecs */
     REGISTER_DECODER (AASC, aasc);
     REGISTER_DECODER (AMV, amv);
@@ -108,7 +115,6 @@ void avcodec_register_all(void)
     REGISTER_DECODER (H263I, h263i);
     REGISTER_ENCODER (H263P, h263p);
     REGISTER_DECODER (H264, h264);
-    REGISTER_DECODER (H264_VDPAU, h264_vdpau);
     REGISTER_ENCDEC  (HUFFYUV, huffyuv);
     REGISTER_DECODER (IDCIN, idcin);
     REGISTER_DECODER (INDEO2, indeo2);
@@ -128,10 +134,7 @@ void avcodec_register_all(void)
     REGISTER_ENCDEC  (MPEG1VIDEO, mpeg1video);
     REGISTER_ENCDEC  (MPEG2VIDEO, mpeg2video);
     REGISTER_ENCDEC  (MPEG4, mpeg4);
-    REGISTER_DECODER (MPEG4_VDPAU, mpeg4_vdpau);
     REGISTER_DECODER (MPEGVIDEO, mpegvideo);
-    REGISTER_DECODER (MPEG_VDPAU, mpeg_vdpau);
-    REGISTER_DECODER (MPEG1_VDPAU, mpeg1_vdpau);
     REGISTER_ENCDEC  (MSMPEG4V1, msmpeg4v1);
     REGISTER_ENCDEC  (MSMPEG4V2, msmpeg4v2);
     REGISTER_ENCDEC  (MSMPEG4V3, msmpeg4v3);
@@ -182,7 +185,6 @@ void avcodec_register_all(void)
     REGISTER_DECODER (V210X, v210x);
     REGISTER_DECODER (VB, vb);
     REGISTER_DECODER (VC1, vc1);
-    REGISTER_DECODER (VC1_VDPAU, vc1_vdpau);
     REGISTER_DECODER (VCR1, vcr1);
     REGISTER_DECODER (VMDVIDEO, vmdvideo);
     REGISTER_DECODER (VMNC, vmnc);
@@ -195,7 +197,6 @@ void avcodec_register_all(void)
     REGISTER_ENCDEC  (WMV1, wmv1);
     REGISTER_ENCDEC  (WMV2, wmv2);
     REGISTER_DECODER (WMV3, wmv3);
-    REGISTER_DECODER (WMV3_VDPAU, wmv3_vdpau);
     REGISTER_DECODER (WNV1, wnv1);
     REGISTER_DECODER (XAN_WC3, xan_wc3);
     REGISTER_DECODER (XL, xl);
diff --git a/libavcodec/avcodec.h b/libavcodec/avcodec.h
index 81f9d98..d63f5f3 100644
--- a/libavcodec/avcodec.h
+++ b/libavcodec/avcodec.h
@@ -614,10 +614,6 @@ typedef struct RcOverride{
  */
 #define CODEC_CAP_SMALL_LAST_FRAME 0x0040
 /**
- * Codec can export data for HW decoding (VDPAU).
- */
-#define CODEC_CAP_HWACCEL_VDPAU    0x0080
-/**
  * Codec can output multiple frames per AVPacket
  */
 #define CODEC_CAP_SUBFRAMES        0x0100
diff --git a/libavcodec/error_resilience.c b/libavcodec/error_resilience.c
index 8c6ac9d..2f08ddb 100644
--- a/libavcodec/error_resilience.c
+++ b/libavcodec/error_resilience.c
@@ -684,7 +684,6 @@ void ff_er_frame_end(MpegEncContext *s){
 
     if(!s->error_recognition || s->error_count==0 || s->avctx->lowres ||
        s->avctx->hwaccel ||
-       s->avctx->codec->capabilities&CODEC_CAP_HWACCEL_VDPAU ||
        s->picture_structure != PICT_FRAME || // we dont support ER of field pictures yet, though it should not crash if enabled
        s->error_count==3*s->mb_width*(s->avctx->skip_top + s->avctx->skip_bottom)) return;
 
diff --git a/libavcodec/h263dec.c b/libavcodec/h263dec.c
index a4d9532..d35bd26 100644
--- a/libavcodec/h263dec.c
+++ b/libavcodec/h263dec.c
@@ -33,7 +33,6 @@
 #include "h263_parser.h"
 #include "mpeg4video_parser.h"
 #include "msmpeg4.h"
-#include "vdpau_internal.h"
 #include "flv.h"
 #include "mpeg4video.h"
 
@@ -617,11 +616,6 @@ retry:
     if(MPV_frame_start(s, avctx) < 0)
         return -1;
 
-    if (CONFIG_MPEG4_VDPAU_DECODER && (s->avctx->codec->capabilities & CODEC_CAP_HWACCEL_VDPAU)) {
-        ff_vdpau_mpeg4_decode_picture(s, buf, buf_size);
-        goto frame_end;
-    }
-
     if (avctx->hwaccel) {
         if (avctx->hwaccel->start_frame(avctx, buf, buf_size) < 0)
             return -1;
diff --git a/libavcodec/h264.c b/libavcodec/h264.c
index 6056497..493bdf5 100644
--- a/libavcodec/h264.c
+++ b/libavcodec/h264.c
@@ -36,7 +36,6 @@
 #include "golomb.h"
 #include "mathops.h"
 #include "rectangle.h"
-#include "vdpau_internal.h"
 
 #include "cabac.h"
 #if ARCH_X86
@@ -1626,9 +1625,6 @@ static void field_end(H264Context *h){
     s->current_picture_ptr->qscale_type= FF_QSCALE_TYPE_H264;
     s->current_picture_ptr->pict_type= s->pict_type;
 
-    if (CONFIG_H264_VDPAU_DECODER && s->avctx->codec->capabilities&CODEC_CAP_HWACCEL_VDPAU)
-        ff_vdpau_h264_set_reference_frames(s);
-
     if(!s->dropable) {
         ff_h264_execute_ref_pic_marking(h, h->mmco, h->mmco_index);
         h->prev_poc_msb= h->poc_msb;
@@ -1642,9 +1638,6 @@ static void field_end(H264Context *h){
             av_log(avctx, AV_LOG_ERROR, "hardware accelerator failed to decode picture\n");
     }
 
-    if (CONFIG_H264_VDPAU_DECODER && s->avctx->codec->capabilities&CODEC_CAP_HWACCEL_VDPAU)
-        ff_vdpau_h264_picture_complete(s);
-
     /*
      * FIXME: Error handling code does not seem to support interlaced
      * when slices span multiple rows
@@ -2355,8 +2348,6 @@ static void execute_decode_slices(H264Context *h, int context_count){
 
     if (s->avctx->hwaccel)
         return;
-    if(s->avctx->codec->capabilities&CODEC_CAP_HWACCEL_VDPAU)
-        return;
     if(context_count == 1) {
         decode_slice(avctx, &h);
     } else {
@@ -2499,11 +2490,6 @@ static int decode_nal_units(H264Context *h, const uint8_t *buf, int buf_size){
                     if (avctx->hwaccel->decode_slice(avctx, &buf[buf_index - consumed], consumed) < 0)
                         return -1;
                 }else
-                if(CONFIG_H264_VDPAU_DECODER && s->avctx->codec->capabilities&CODEC_CAP_HWACCEL_VDPAU){
-                    static const uint8_t start_code[] = {0x00, 0x00, 0x01};
-                    ff_vdpau_add_data_chunk(s, start_code, sizeof(start_code));
-                    ff_vdpau_add_data_chunk(s, &buf[buf_index - consumed], consumed );
-                }else
                     context_count++;
             }
             break;
@@ -3080,20 +3066,3 @@ AVCodec h264_decoder = {
     .long_name = NULL_IF_CONFIG_SMALL("H.264 / AVC / MPEG-4 AVC / MPEG-4 part 10"),
     .pix_fmts= ff_hwaccel_pixfmt_list_420,
 };
-
-#if CONFIG_H264_VDPAU_DECODER
-AVCodec h264_vdpau_decoder = {
-    "h264_vdpau",
-    CODEC_TYPE_VIDEO,
-    CODEC_ID_H264,
-    sizeof(H264Context),
-    ff_h264_decode_init,
-    NULL,
-    ff_h264_decode_end,
-    decode_frame,
-    CODEC_CAP_DR1 | CODEC_CAP_DELAY | CODEC_CAP_HWACCEL_VDPAU,
-    .flush= flush_dpb,
-    .long_name = NULL_IF_CONFIG_SMALL("H.264 / AVC / MPEG-4 AVC / MPEG-4 part 10 (VDPAU acceleration)"),
-    .pix_fmts = (const enum PixelFormat[]){PIX_FMT_VDPAU_H264, PIX_FMT_NONE},
-};
-#endif
diff --git a/libavcodec/mpeg12.c b/libavcodec/mpeg12.c
index 636ae06..be32e8d 100644
--- a/libavcodec/mpeg12.c
+++ b/libavcodec/mpeg12.c
@@ -35,7 +35,6 @@
 #include "mpeg12data.h"
 #include "mpeg12decdata.h"
 #include "bytestream.h"
-#include "vdpau_internal.h"
 #include "xvmc_internal.h"
 
 //#undef NDEBUG
@@ -1226,12 +1225,7 @@ static enum PixelFormat mpeg_get_pixelformat(AVCodecContext *avctx){
 
     if(avctx->xvmc_acceleration)
         return avctx->get_format(avctx,pixfmt_xvmc_mpg2_420);
-    else if(avctx->codec->capabilities&CODEC_CAP_HWACCEL_VDPAU){
-        if(avctx->codec_id == CODEC_ID_MPEG1VIDEO)
-            return PIX_FMT_VDPAU_MPEG1;
-        else
-            return PIX_FMT_VDPAU_MPEG2;
-    }else{
+    else{
         if(s->chroma_format <  2)
             return avctx->get_format(avctx,ff_hwaccel_pixfmt_list_420);
         else if(s->chroma_format == 2)
@@ -1324,9 +1318,7 @@ static int mpeg_decode_postinit(AVCodecContext *avctx){
         avctx->pix_fmt = mpeg_get_pixelformat(avctx);
         avctx->hwaccel = ff_find_hwaccel(avctx->codec->id, avctx->pix_fmt);
         //until then pix_fmt may be changed right after codec init
-        if( avctx->pix_fmt == PIX_FMT_XVMC_MPEG2_IDCT ||
-            avctx->hwaccel ||
-            s->avctx->codec->capabilities&CODEC_CAP_HWACCEL_VDPAU )
+        if( avctx->pix_fmt == PIX_FMT_XVMC_MPEG2_IDCT || avctx->hwaccel )
             if( avctx->idct_algo == FF_IDCT_AUTO )
                 avctx->idct_algo = FF_IDCT_SIMPLE;
 
@@ -2063,8 +2055,7 @@ static int vcr2_init_sequence(AVCodecContext *avctx)
     avctx->pix_fmt = mpeg_get_pixelformat(avctx);
     avctx->hwaccel = ff_find_hwaccel(avctx->codec->id, avctx->pix_fmt);
 
-    if( avctx->pix_fmt == PIX_FMT_XVMC_MPEG2_IDCT || avctx->hwaccel ||
-        s->avctx->codec->capabilities&CODEC_CAP_HWACCEL_VDPAU )
+    if( avctx->pix_fmt == PIX_FMT_XVMC_MPEG2_IDCT || avctx->hwaccel )
         if( avctx->idct_algo == FF_IDCT_AUTO )
             avctx->idct_algo = FF_IDCT_SIMPLE;
 
@@ -2292,9 +2283,6 @@ static int decode_chunks(AVCodecContext *avctx,
                         s2->error_count += s2->thread_context[i]->error_count;
                 }
 
-                if (CONFIG_MPEG_VDPAU_DECODER && avctx->codec->capabilities&CODEC_CAP_HWACCEL_VDPAU)
-                    ff_vdpau_mpeg_picture_complete(s2, buf, buf_size, s->slice_count);
-
                 if (slice_end(avctx, picture)) {
                     if(s2->last_picture_ptr || s2->low_delay) //FIXME merge with the stuff in mpeg_decode_slice
                         *data_size = sizeof(AVPicture);
@@ -2441,11 +2429,6 @@ static int decode_chunks(AVCodecContext *avctx,
                     return -1;
                 }
 
-                if (avctx->codec->capabilities&CODEC_CAP_HWACCEL_VDPAU) {
-                    s->slice_count++;
-                    break;
-                }
-
                 if(avctx->thread_count > 1){
                     int threshold= (s2->mb_height*s->slice_count + avctx->thread_count/2) / avctx->thread_count;
                     if(threshold <= mb_y){
@@ -2570,36 +2553,3 @@ AVCodec mpeg_xvmc_decoder = {
 };
 
 #endif
-
-#if CONFIG_MPEG_VDPAU_DECODER
-AVCodec mpeg_vdpau_decoder = {
-    "mpegvideo_vdpau",
-    CODEC_TYPE_VIDEO,
-    CODEC_ID_MPEG2VIDEO,
-    sizeof(Mpeg1Context),
-    mpeg_decode_init,
-    NULL,
-    mpeg_decode_end,
-    mpeg_decode_frame,
-    CODEC_CAP_DR1 | CODEC_CAP_TRUNCATED | CODEC_CAP_HWACCEL_VDPAU | CODEC_CAP_DELAY,
-    .flush= flush,
-    .long_name = NULL_IF_CONFIG_SMALL("MPEG-1/2 video (VDPAU acceleration)"),
-};
-#endif
-
-#if CONFIG_MPEG1_VDPAU_DECODER
-AVCodec mpeg1_vdpau_decoder = {
-    "mpeg1video_vdpau",
-    CODEC_TYPE_VIDEO,
-    CODEC_ID_MPEG1VIDEO,
-    sizeof(Mpeg1Context),
-    mpeg_decode_init,
-    NULL,
-    mpeg_decode_end,
-    mpeg_decode_frame,
-    CODEC_CAP_DR1 | CODEC_CAP_TRUNCATED | CODEC_CAP_HWACCEL_VDPAU | CODEC_CAP_DELAY,
-    .flush= flush,
-    .long_name = NULL_IF_CONFIG_SMALL("MPEG-1 video (VDPAU acceleration)"),
-};
-#endif
-
diff --git a/libavcodec/mpeg4videodec.c b/libavcodec/mpeg4videodec.c
index a1786e8..757df3d 100644
--- a/libavcodec/mpeg4videodec.c
+++ b/libavcodec/mpeg4videodec.c
@@ -2243,20 +2243,3 @@ AVCodec mpeg4_decoder = {
     .long_name= NULL_IF_CONFIG_SMALL("MPEG-4 part 2"),
     .pix_fmts= ff_hwaccel_pixfmt_list_420,
 };
-
-
-#if CONFIG_MPEG4_VDPAU_DECODER
-AVCodec mpeg4_vdpau_decoder = {
-    "mpeg4_vdpau",
-    CODEC_TYPE_VIDEO,
-    CODEC_ID_MPEG4,
-    sizeof(MpegEncContext),
-    decode_init,
-    NULL,
-    ff_h263_decode_end,
-    ff_h263_decode_frame,
-    CODEC_CAP_DR1 | CODEC_CAP_TRUNCATED | CODEC_CAP_DELAY | CODEC_CAP_HWACCEL_VDPAU,
-    .long_name= NULL_IF_CONFIG_SMALL("MPEG-4 part 2 (VDPAU)"),
-    .pix_fmts= (const enum PixelFormat[]){PIX_FMT_VDPAU_MPEG4, PIX_FMT_NONE},
-};
-#endif
diff --git a/libavcodec/mpegvideo.c b/libavcodec/mpegvideo.c
index ea96cbe..8dd5ac1 100644
--- a/libavcodec/mpegvideo.c
+++ b/libavcodec/mpegvideo.c
@@ -82,6 +82,7 @@ const enum PixelFormat ff_pixfmt_list_420[] = {
 
 const enum PixelFormat ff_hwaccel_pixfmt_list_420[] = {
     PIX_FMT_VAAPI_VLD,
+    PIX_FMT_VDPAU,
     PIX_FMT_YUV420P,
     PIX_FMT_NONE
 };
@@ -1018,7 +1019,6 @@ void MPV_frame_end(MpegEncContext *s)
     if(CONFIG_MPEG_XVMC_DECODER && s->avctx->xvmc_acceleration){
         ff_xvmc_field_end(s);
     }else if(!s->avctx->hwaccel
-       && !(s->avctx->codec->capabilities&CODEC_CAP_HWACCEL_VDPAU)
        && s->unrestricted_mv
        && s->current_picture.reference
        && !s->intra_only
diff --git a/libavcodec/vc1dec.c b/libavcodec/vc1dec.c
index d2a50a3..8770756 100644
--- a/libavcodec/vc1dec.c
+++ b/libavcodec/vc1dec.c
@@ -36,7 +36,6 @@
 #include "unary.h"
 #include "simple_idct.h"
 #include "mathops.h"
-#include "vdpau_internal.h"
 
 #undef NDEBUG
 #include <assert.h>
@@ -3140,13 +3139,6 @@ static int vc1_decode_frame(AVCodecContext *avctx,
         s->current_picture_ptr= &s->picture[i];
     }
 
-    if (s->avctx->codec->capabilities&CODEC_CAP_HWACCEL_VDPAU){
-        if (v->profile < PROFILE_ADVANCED)
-            avctx->pix_fmt = PIX_FMT_VDPAU_WMV3;
-        else
-            avctx->pix_fmt = PIX_FMT_VDPAU_VC1;
-    }
-
     //for advanced profile we may need to parse and unescape data
     if (avctx->codec_id == CODEC_ID_VC1) {
         int buf_size2 = 0;
@@ -3163,8 +3155,7 @@ static int vc1_decode_frame(AVCodecContext *avctx,
                 if(size <= 0) continue;
                 switch(AV_RB32(start)){
                 case VC1_CODE_FRAME:
-                    if (avctx->hwaccel ||
-                        s->avctx->codec->capabilities&CODEC_CAP_HWACCEL_VDPAU)
+                    if (avctx->hwaccel)
                         buf_start = start;
                     buf_size2 = vc1_unescape_buffer(start + 4, size, buf2);
                     break;
@@ -3256,10 +3247,7 @@ static int vc1_decode_frame(AVCodecContext *avctx,
     s->me.qpel_put= s->dsp.put_qpel_pixels_tab;
     s->me.qpel_avg= s->dsp.avg_qpel_pixels_tab;
 
-    if ((CONFIG_VC1_VDPAU_DECODER)
-        &&s->avctx->codec->capabilities&CODEC_CAP_HWACCEL_VDPAU)
-        ff_vdpau_vc1_decode_picture(s, buf_start, (buf + buf_size) - buf_start);
-    else if (avctx->hwaccel) {
+    if (avctx->hwaccel) {
         if (avctx->hwaccel->start_frame(avctx, buf, buf_size) < 0)
             return -1;
         if (avctx->hwaccel->decode_slice(avctx, buf_start, (buf + buf_size) - buf_start) < 0)
@@ -3349,37 +3337,3 @@ AVCodec wmv3_decoder = {
     .pix_fmts = ff_hwaccel_pixfmt_list_420
 };
 #endif
-
-#if CONFIG_WMV3_VDPAU_DECODER
-AVCodec wmv3_vdpau_decoder = {
-    "wmv3_vdpau",
-    CODEC_TYPE_VIDEO,
-    CODEC_ID_WMV3,
-    sizeof(VC1Context),
-    vc1_decode_init,
-    NULL,
-    vc1_decode_end,
-    vc1_decode_frame,
-    CODEC_CAP_DR1 | CODEC_CAP_DELAY | CODEC_CAP_HWACCEL_VDPAU,
-    NULL,
-    .long_name = NULL_IF_CONFIG_SMALL("Windows Media Video 9 VDPAU"),
-    .pix_fmts = (const enum PixelFormat[]){PIX_FMT_VDPAU_WMV3, PIX_FMT_NONE}
-};
-#endif
-
-#if CONFIG_VC1_VDPAU_DECODER
-AVCodec vc1_vdpau_decoder = {
-    "vc1_vdpau",
-    CODEC_TYPE_VIDEO,
-    CODEC_ID_VC1,
-    sizeof(VC1Context),
-    vc1_decode_init,
-    NULL,
-    vc1_decode_end,
-    vc1_decode_frame,
-    CODEC_CAP_DR1 | CODEC_CAP_DELAY | CODEC_CAP_HWACCEL_VDPAU,
-    NULL,
-    .long_name = NULL_IF_CONFIG_SMALL("SMPTE VC-1 VDPAU"),
-    .pix_fmts = (const enum PixelFormat[]){PIX_FMT_VDPAU_VC1, PIX_FMT_NONE}
-};
-#endif
diff --git a/libavcodec/vdpau.c b/libavcodec/vdpau.c
index 7cc8ad1..c60b1e7 100644
--- a/libavcodec/vdpau.c
+++ b/libavcodec/vdpau.c
@@ -30,7 +30,6 @@
 #include <assert.h>
 
 #include "vdpau.h"
-#include "vdpau_internal.h"
 
 /**
  * \addtogroup VDPAU_Decoding
@@ -38,15 +37,57 @@
  * @{
  */
 
-void ff_vdpau_h264_set_reference_frames(MpegEncContext *s)
+static void vdpau_h264_fill_field_order_cnt(int32_t field_order_cnt[2], Picture *pic, int pic_structure)
 {
-    H264Context *h = s->avctx->priv_data;
+    int i;
+    for (i = 0; i < 2; i++) {
+        const int poc = pic->field_poc[i];
+        field_order_cnt[i] = poc != INT_MAX ? poc : 0;
+    }
+}
+
+static void vdpau_h264_init_picture(VdpReferenceFrameH264 *rf)
+{
+    rf->surface             = VDP_INVALID_HANDLE;
+    rf->is_long_term        = 0;
+    rf->top_is_reference    = 0;
+    rf->bottom_is_reference = 0;
+    rf->field_order_cnt[0]  = 0;
+    rf->field_order_cnt[1]  = 0;
+    rf->frame_idx           = 0;
+}
+
+static void vdpau_h264_fill_picture(VdpReferenceFrameH264 *rf, Picture *pic, int pic_structure)
+{
+    struct vdpau_render_state *render;
+
+    assert(rf);
+    assert(pic);
+
+    if (pic_structure == 0)
+        pic_structure = pic->reference;
+
+    render = (struct vdpau_render_state *)pic->data[3];
+    assert(render);
+
+    rf->surface             = render->surface;
+    rf->is_long_term        = pic->reference && pic->long_ref;
+    rf->top_is_reference    = (pic_structure & PICT_TOP_FIELD) != 0;
+    rf->bottom_is_reference = (pic_structure & PICT_BOTTOM_FIELD) != 0;
+    rf->frame_idx           = pic->long_ref ? pic->pic_id : pic->frame_num;
+
+    vdpau_h264_fill_field_order_cnt(rf->field_order_cnt, pic, pic_structure);
+}
+
+static void vdpau_h264_set_reference_frames(H264Context *h)
+{
+    MpegEncContext * const s = &h->s;
     struct vdpau_render_state *render, *render_ref;
     VdpReferenceFrameH264 *rf, *rf2;
     Picture *pic;
     int i, list, pic_frame_idx;
 
-    render = (struct vdpau_render_state *)s->current_picture_ptr->data[0];
+    render = (struct vdpau_render_state *)s->current_picture_ptr->data[3];
     assert(render);
 
     rf = &render->info.h264.referenceFrames[0];
@@ -62,7 +103,7 @@ void ff_vdpau_h264_set_reference_frames(MpegEncContext *s)
                 continue;
             pic_frame_idx = pic->long_ref ? pic->pic_id : pic->frame_num;
 
-            render_ref = (struct vdpau_render_state *)pic->data[0];
+            render_ref = (struct vdpau_render_state *)pic->data[3];
             assert(render_ref);
 
             rf2 = &render->info.h264.referenceFrames[0];
@@ -84,70 +125,92 @@ void ff_vdpau_h264_set_reference_frames(MpegEncContext *s)
             if (rf >= &render->info.h264.referenceFrames[H264_RF_COUNT])
                 continue;
 
-            rf->surface             = render_ref->surface;
-            rf->is_long_term        = pic->long_ref;
-            rf->top_is_reference    = (pic->reference & PICT_TOP_FIELD)    ? VDP_TRUE : VDP_FALSE;
-            rf->bottom_is_reference = (pic->reference & PICT_BOTTOM_FIELD) ? VDP_TRUE : VDP_FALSE;
-            rf->field_order_cnt[0]  = pic->field_poc[0];
-            rf->field_order_cnt[1]  = pic->field_poc[1];
-            rf->frame_idx           = pic_frame_idx;
+            vdpau_h264_fill_picture(rf, pic, pic->reference);
 
             ++rf;
         }
     }
 
-    for (; rf < &render->info.h264.referenceFrames[H264_RF_COUNT]; ++rf) {
-        rf->surface             = VDP_INVALID_HANDLE;
-        rf->is_long_term        = 0;
-        rf->top_is_reference    = 0;
-        rf->bottom_is_reference = 0;
-        rf->field_order_cnt[0]  = 0;
-        rf->field_order_cnt[1]  = 0;
-        rf->frame_idx           = 0;
-    }
+    for (; rf < &render->info.h264.referenceFrames[H264_RF_COUNT]; ++rf)
+        vdpau_h264_init_picture(rf);
 }
 
-void ff_vdpau_add_data_chunk(MpegEncContext *s,
-                             const uint8_t *buf, int buf_size)
+static int vdpau_ensure_bitstream_buffers(struct vdpau_render_state *render)
 {
-    struct vdpau_render_state *render;
-
-    render = (struct vdpau_render_state *)s->current_picture_ptr->data[0];
-    assert(render);
-
     render->bitstream_buffers= av_fast_realloc(
         render->bitstream_buffers,
         &render->bitstream_buffers_allocated,
         sizeof(*render->bitstream_buffers)*(render->bitstream_buffers_used + 1)
     );
 
+    if (!render->bitstream_buffers)
+        return -1;
+
+    return 0;
+}
+
+static int vdpau_common_start_frame(AVCodecContext *avctx, av_unused const uint8_t *buffer, av_unused uint32_t size)
+{
+    MpegEncContext * const s = avctx->priv_data;
+    struct vdpau_render_state *render;
+
+    render = (struct vdpau_render_state *)s->current_picture_ptr->data[3];
+    assert(render);
+
+    render->bitstream_buffers_used = 0;
+    return 0;
+}
+
+static int vdpau_common_end_frame(AVCodecContext *avctx)
+{
+    MpegEncContext * const s = avctx->priv_data;
+    struct vdpau_render_state *render;
+
+    render = (struct vdpau_render_state *)s->current_picture_ptr->data[3];
+    assert(render);
+
+    if (render->bitstream_buffers_used) {
+        ff_draw_horiz_band(s, 0, s->avctx->height);
+        render->bitstream_buffers_used = 0;
+    }
+    return 0;
+}
+
+static int vdpau_common_decode_slice(AVCodecContext *avctx, const uint8_t *buf, uint32_t buf_size)
+{
+    MpegEncContext * const s = avctx->priv_data;
+    struct vdpau_render_state *render;
+
+    render = (struct vdpau_render_state *)s->current_picture_ptr->data[3];
+    assert(render);
+
+    if (vdpau_ensure_bitstream_buffers(render) < 0)
+        return -1;
+
     render->bitstream_buffers[render->bitstream_buffers_used].struct_version  = VDP_BITSTREAM_BUFFER_VERSION;
     render->bitstream_buffers[render->bitstream_buffers_used].bitstream       = buf;
     render->bitstream_buffers[render->bitstream_buffers_used].bitstream_bytes = buf_size;
     render->bitstream_buffers_used++;
+    return 0;
 }
 
-void ff_vdpau_h264_picture_complete(MpegEncContext *s)
+static int vdpau_h264_start_frame(AVCodecContext *avctx, const uint8_t *buffer, uint32_t size)
 {
-    H264Context *h = s->avctx->priv_data;
+    H264Context * const h = avctx->priv_data;
+    MpegEncContext * const s = &h->s;
     struct vdpau_render_state *render;
-    int i;
 
-    render = (struct vdpau_render_state *)s->current_picture_ptr->data[0];
+    render = (struct vdpau_render_state *)s->current_picture_ptr->data[3];
     assert(render);
 
-    render->info.h264.slice_count = h->slice_num;
-    if (render->info.h264.slice_count < 1)
-        return;
+    vdpau_h264_set_reference_frames(h);
 
-    for (i = 0; i < 2; ++i) {
-        int foc = s->current_picture_ptr->field_poc[i];
-        if (foc == INT_MAX)
-            foc = 0;
-        render->info.h264.field_order_cnt[i] = foc;
-    }
+    vdpau_h264_fill_field_order_cnt(render->info.h264.field_order_cnt,
+                                    s->current_picture_ptr,
+                                    s->picture_structure);
 
-    render->info.h264.is_reference                           = (s->current_picture_ptr->reference & 3) ? VDP_TRUE : VDP_FALSE;
+    /* fill VdpPictureInfoH264 struct */
+    render->info.h264.is_reference                           = h->nal_ref_idc != 0;
     render->info.h264.frame_num                              = h->frame_num;
     render->info.h264.field_pic_flag                         = s->picture_structure != PICT_FRAME;
     render->info.h264.bottom_field_flag                      = s->picture_structure == PICT_BOTTOM_FIELD;
@@ -175,19 +238,44 @@ void ff_vdpau_h264_picture_complete(MpegEncContext *s)
     memcpy(render->info.h264.scaling_lists_4x4, h->pps.scaling_matrix4, sizeof(render->info.h264.scaling_lists_4x4));
     memcpy(render->info.h264.scaling_lists_8x8, h->pps.scaling_matrix8, sizeof(render->info.h264.scaling_lists_8x8));
 
-    ff_draw_horiz_band(s, 0, s->avctx->height);
-    render->bitstream_buffers_used = 0;
+    render->info.h264.slice_count                = 0;
+
+    return vdpau_common_start_frame(avctx, buffer, size);
+}
+
+static int vdpau_h264_decode_slice(AVCodecContext *avctx, const uint8_t *buffer, uint32_t size)
+{
+    MpegEncContext * const s = avctx->priv_data;
+    struct vdpau_render_state *render;
+    static const uint8_t start_code_prefix_one_3byte[3] = { 0x00, 0x00, 0x01 };
+
+    render = (struct vdpau_render_state *)s->current_picture_ptr->data[3];
+    assert(render);
+
+    if (vdpau_ensure_bitstream_buffers(render) < 0)
+        return -1;
+
+    render->bitstream_buffers[render->bitstream_buffers_used].struct_version  = VDP_BITSTREAM_BUFFER_VERSION;
+    render->bitstream_buffers[render->bitstream_buffers_used].bitstream       = start_code_prefix_one_3byte;
+    render->bitstream_buffers[render->bitstream_buffers_used].bitstream_bytes = sizeof(start_code_prefix_one_3byte);
+    render->bitstream_buffers_used++;
+
+    if (vdpau_common_decode_slice(avctx, buffer, size) < 0)
+        return -1;
+
+    ++render->info.h264.slice_count;
+    return 0;
 }
 
-void ff_vdpau_mpeg_picture_complete(MpegEncContext *s, const uint8_t *buf,
-                                    int buf_size, int slice_count)
+static int vdpau_mpeg2_start_frame(AVCodecContext *avctx, const uint8_t *buffer, uint32_t size)
 {
+    MpegEncContext * const s = avctx->priv_data;
     struct vdpau_render_state *render, *last, *next;
     int i;
 
-    if (!s->current_picture_ptr) return;
+    if (!s->current_picture_ptr) return 0;
 
-    render = (struct vdpau_render_state *)s->current_picture_ptr->data[0];
+    render = (struct vdpau_render_state *)s->current_picture_ptr->data[3];
     assert(render);
 
     /* fill VdpPictureInfoMPEG1Or2 struct */
@@ -216,36 +304,47 @@ void ff_vdpau_mpeg_picture_complete(MpegEncContext *s, const uint8_t *buf,
 
     switch(s->pict_type){
     case  FF_B_TYPE:
-        next = (struct vdpau_render_state *)s->next_picture.data[0];
+        next = (struct vdpau_render_state *)s->next_picture.data[3];
         assert(next);
         render->info.mpeg.backward_reference     = next->surface;
         // no return here, going to set forward prediction
     case  FF_P_TYPE:
-        last = (struct vdpau_render_state *)s->last_picture.data[0];
+        last = (struct vdpau_render_state *)s->last_picture.data[3];
         if (!last) // FIXME: Does this test make sense?
             last = render; // predict second field from the first
         render->info.mpeg.forward_reference      = last->surface;
     }
 
-    ff_vdpau_add_data_chunk(s, buf, buf_size);
+    render->info.mpeg.slice_count                = 0;
 
-    render->info.mpeg.slice_count                = slice_count;
+    return vdpau_common_start_frame(avctx, buffer, size);
+}
 
-    if (slice_count)
-        ff_draw_horiz_band(s, 0, s->avctx->height);
-    render->bitstream_buffers_used               = 0;
+static int vdpau_mpeg2_decode_slice(AVCodecContext *avctx, const uint8_t *buffer, uint32_t size)
+{
+    MpegEncContext * const s = avctx->priv_data;
+    struct vdpau_render_state *render;
+
+    render = (struct vdpau_render_state *)s->current_picture_ptr->data[3];
+    assert(render);
+
+    if (vdpau_common_decode_slice(avctx, buffer, size) < 0)
+        return -1;
+
+    ++render->info.mpeg.slice_count;
+    return 0;
 }
 
-void ff_vdpau_vc1_decode_picture(MpegEncContext *s, const uint8_t *buf,
-                                 int buf_size)
+static int vdpau_vc1_start_frame(AVCodecContext *avctx, const uint8_t *buffer, uint32_t size)
 {
-    VC1Context *v = s->avctx->priv_data;
+    VC1Context * const v = avctx->priv_data;
+    MpegEncContext * const s = &v->s;
     struct vdpau_render_state *render, *last, *next;
 
-    render = (struct vdpau_render_state *)s->current_picture.data[0];
+    render = (struct vdpau_render_state *)s->current_picture_ptr->data[3];
     assert(render);
 
-    /*  fill LvPictureInfoVC1 struct */
+    /* fill VdpPictureInfoVC1 struct */
     render->info.vc1.frame_coding_mode  = v->fcm;
     render->info.vc1.postprocflag       = v->postprocflag;
     render->info.vc1.pulldown           = v->broadcast;
@@ -286,34 +385,47 @@ void ff_vdpau_vc1_decode_picture(MpegEncContext *s, const uint8_t *buf,
 
     switch(s->pict_type){
     case  FF_B_TYPE:
-        next = (struct vdpau_render_state *)s->next_picture.data[0];
+        next = (struct vdpau_render_state *)s->next_picture.data[3];
         assert(next);
         render->info.vc1.backward_reference = next->surface;
         // no break here, going to set forward prediction
     case  FF_P_TYPE:
-        last = (struct vdpau_render_state *)s->last_picture.data[0];
+        last = (struct vdpau_render_state *)s->last_picture.data[3];
         if (!last) // FIXME: Does this test make sense?
             last = render; // predict second field from the first
         render->info.vc1.forward_reference = last->surface;
     }
 
-    ff_vdpau_add_data_chunk(s, buf, buf_size);
+    render->info.vc1.slice_count                 = 0;
 
-    render->info.vc1.slice_count          = 1;
+    return vdpau_common_start_frame(avctx, buffer, size);
+}
 
-    ff_draw_horiz_band(s, 0, s->avctx->height);
-    render->bitstream_buffers_used        = 0;
+static int vdpau_vc1_decode_slice(AVCodecContext *avctx, const uint8_t *buffer, uint32_t size)
+{
+    VC1Context * const v = avctx->priv_data;
+    MpegEncContext * const s = &v->s;
+    struct vdpau_render_state *render;
+
+    render = (struct vdpau_render_state *)s->current_picture_ptr->data[3];
+    assert(render);
+
+    if (vdpau_common_decode_slice(avctx, buffer, size) < 0)
+        return -1;
+
+    ++render->info.vc1.slice_count;
+    return 0;
 }
 
-void ff_vdpau_mpeg4_decode_picture(MpegEncContext *s, const uint8_t *buf,
-                                   int buf_size)
+static int vdpau_mpeg4_start_frame(AVCodecContext *avctx, const uint8_t *buffer, uint32_t size)
 {
+    MpegEncContext * const s = avctx->priv_data;
     struct vdpau_render_state *render, *last, *next;
     int i;
 
-    if (!s->current_picture_ptr) return;
+    if (!s->current_picture_ptr) return 0;
 
-    render = (struct vdpau_render_state *)s->current_picture_ptr->data[0];
+    render = (struct vdpau_render_state *)s->current_picture_ptr->data[3];
     assert(render);
 
     /* fill VdpPictureInfoMPEG4Part2 struct */
@@ -338,21 +450,104 @@ void ff_vdpau_mpeg4_decode_picture(MpegEncContext *s, const uint8_t *buf,
 
     switch (s->pict_type) {
     case FF_B_TYPE:
-        next = (struct vdpau_render_state *)s->next_picture.data[0];
+        next = (struct vdpau_render_state *)s->next_picture.data[3];
         assert(next);
         render->info.mpeg4.backward_reference     = next->surface;
         render->info.mpeg4.vop_coding_type        = 2;
         // no break here, going to set forward prediction
     case FF_P_TYPE:
-        last = (struct vdpau_render_state *)s->last_picture.data[0];
+        last = (struct vdpau_render_state *)s->last_picture.data[3];
         assert(last);
         render->info.mpeg4.forward_reference      = last->surface;
     }
 
-    ff_vdpau_add_data_chunk(s, buf, buf_size);
+    if (vdpau_common_start_frame(avctx, buffer, size) < 0)
+        return -1;
 
-    ff_draw_horiz_band(s, 0, s->avctx->height);
-    render->bitstream_buffers_used = 0;
+    return vdpau_common_decode_slice(avctx, buffer, size);
 }
 
+static int vdpau_mpeg4_decode_slice(av_unused AVCodecContext *avctx, av_unused const uint8_t *buffer, av_unused uint32_t size)
+{
+    return 0;
+}
+
+#if CONFIG_MPEG1_VDPAU_HWACCEL
+AVHWAccel mpeg1_vdpau_hwaccel = {
+    .name           = "mpeg1_vdpau",
+    .type           = CODEC_TYPE_VIDEO,
+    .id             = CODEC_ID_MPEG1VIDEO,
+    .pix_fmt        = PIX_FMT_VDPAU,
+    .capabilities   = 0,
+    .start_frame    = vdpau_mpeg2_start_frame,
+    .end_frame      = vdpau_common_end_frame,
+    .decode_slice   = vdpau_mpeg2_decode_slice,
+};
+#endif
+
+#if CONFIG_MPEG2_VDPAU_HWACCEL
+AVHWAccel mpeg2_vdpau_hwaccel = {
+    .name           = "mpeg2_vdpau",
+    .type           = CODEC_TYPE_VIDEO,
+    .id             = CODEC_ID_MPEG2VIDEO,
+    .pix_fmt        = PIX_FMT_VDPAU,
+    .capabilities   = 0,
+    .start_frame    = vdpau_mpeg2_start_frame,
+    .end_frame      = vdpau_common_end_frame,
+    .decode_slice   = vdpau_mpeg2_decode_slice,
+};
+#endif
+
+#if CONFIG_H264_VDPAU_HWACCEL
+AVHWAccel h264_vdpau_hwaccel = {
+    .name           = "h264_vdpau",
+    .type           = CODEC_TYPE_VIDEO,
+    .id             = CODEC_ID_H264,
+    .pix_fmt        = PIX_FMT_VDPAU,
+    .capabilities   = 0,
+    .start_frame    = vdpau_h264_start_frame,
+    .end_frame      = vdpau_common_end_frame,
+    .decode_slice   = vdpau_h264_decode_slice,
+};
+#endif
+
+#if CONFIG_WMV3_VDPAU_HWACCEL
+AVHWAccel wmv3_vdpau_hwaccel = {
+    .name           = "wmv3_vdpau",
+    .type           = CODEC_TYPE_VIDEO,
+    .id             = CODEC_ID_WMV3,
+    .pix_fmt        = PIX_FMT_VDPAU,
+    .capabilities   = 0,
+    .start_frame    = vdpau_vc1_start_frame,
+    .end_frame      = vdpau_common_end_frame,
+    .decode_slice   = vdpau_vc1_decode_slice,
+};
+#endif
+
+#if CONFIG_VC1_VDPAU_HWACCEL
+AVHWAccel vc1_vdpau_hwaccel = {
+    .name           = "vc1_vdpau",
+    .type           = CODEC_TYPE_VIDEO,
+    .id             = CODEC_ID_VC1,
+    .pix_fmt        = PIX_FMT_VDPAU,
+    .capabilities   = 0,
+    .start_frame    = vdpau_vc1_start_frame,
+    .end_frame      = vdpau_common_end_frame,
+    .decode_slice   = vdpau_vc1_decode_slice,
+};
+#endif
+
+#if CONFIG_MPEG4_VDPAU_HWACCEL
+AVHWAccel mpeg4_vdpau_hwaccel = {
+    .name           = "mpeg4_vdpau",
+    .type           = CODEC_TYPE_VIDEO,
+    .id             = CODEC_ID_MPEG4,
+    .pix_fmt        = PIX_FMT_VDPAU,
+    .capabilities   = 0,
+    .start_frame    = vdpau_mpeg4_start_frame,
+    .end_frame      = vdpau_common_end_frame,
+    .decode_slice   = vdpau_mpeg4_decode_slice,
+};
+#endif
+
 /* @}*/
diff --git a/libavutil/pixdesc.c b/libavutil/pixdesc.c
index b689519..217c49f 100644
--- a/libavutil/pixdesc.c
+++ b/libavutil/pixdesc.c
@@ -646,6 +646,12 @@ const AVPixFmtDescriptor av_pix_fmt_descriptors[PIX_FMT_NB] = {
         },
         .flags = PIX_FMT_BE,
     },
+    [PIX_FMT_VDPAU] = {
+        .name = "vdpau",
+        .log2_chroma_w = 1,
+        .log2_chroma_h = 1,
+        .flags = PIX_FMT_HWACCEL,
+    },
 };
 
 int av_get_bits_per_pixel(const AVPixFmtDescriptor *pixdesc)
diff --git a/libavutil/pixfmt.h b/libavutil/pixfmt.h
index ddd17fb..1f17073 100644
--- a/libavutil/pixfmt.h
+++ b/libavutil/pixfmt.h
@@ -127,6 +127,7 @@ enum PixelFormat {
     PIX_FMT_YUV444P16BE,  ///< planar YUV 4:4:4, 48bpp, (1 Cr & Cb sample per 1x1 Y samples), big-endian
     PIX_FMT_VDPAU_MPEG4,  ///< MPEG4 HW decoding with VDPAU, data[0] contains a vdpau_render_state struct which contains the bitstream of the slices as well as various fields extracted from headers
     PIX_FMT_DXVA2_VLD,    ///< HW decoding through DXVA2, Picture.data[3] contains a LPDIRECT3DSURFACE9 pointer
+    PIX_FMT_VDPAU,        ///< HW decoding with VDPAU, Picture.data[3] contains a vdpau_render_state struct which contains the bitstream of the slices as well as various fields extracted from headers
     PIX_FMT_NB,        ///< number of pixel formats, DO NOT USE THIS if you want to link with shared libav* because the number of formats might differ between versions
 };
 
diff --git a/libmpcodecs/vd_ffmpeg.c b/libmpcodecs/vd_ffmpeg.c
index 1e8e71f..d49d009 100644
--- a/libmpcodecs/vd_ffmpeg.c
+++ b/libmpcodecs/vd_ffmpeg.c
@@ -275,7 +275,7 @@ static int init(sh_video_t *sh){
     }
 #endif /* CONFIG_VAAPI */
 #if CONFIG_VDPAU
-    if(lavc_codec->capabilities & CODEC_CAP_HWACCEL_VDPAU){
+    if(get_video_hwaccel() == HWACCEL_VDPAU){
         avctx->get_format = get_format;
     }
 #endif /* CONFIG_VDPAU */
diff --git a/libvo/vo_vdpau.c b/libvo/vo_vdpau.c
index 2ee7ccc..e728aff 100644
--- a/libvo/vo_vdpau.c
+++ b/libvo/vo_vdpau.c
@@ -977,7 +977,7 @@ static int draw_slice(uint8_t *image[], int stride[], int w, int h,
                       int x, int y)
 {
     VdpStatus vdp_st;
-    struct vdpau_render_state *rndr = (struct vdpau_render_state *)image[0];
+    struct vdpau_render_state *rndr = (struct vdpau_render_state *)image[3];
     int max_refs = image_format == IMGFMT_VDPAU_H264 ? rndr->info.h264.num_ref_frames : 2;
 
     if (handle_preemption() < 0)
@@ -1080,10 +1080,10 @@ static uint32_t get_image(mp_image_t *mpi)
         return VO_FALSE;
     }
     mpi->flags |= MP_IMGFLAG_DIRECT;
-    mpi->stride[0] = mpi->stride[1] = mpi->stride[2] = 0;
-    mpi->planes[0] = mpi->planes[1] = mpi->planes[2] = NULL;
+    mpi->stride[0] = mpi->stride[1] = mpi->stride[2] = mpi->stride[3] = 0;
+    mpi->planes[0] = mpi->planes[1] = mpi->planes[2] = mpi->planes[3] = NULL;
     // hack to get around a check and to avoid a special-case in vd_ffmpeg.c
-    mpi->planes[0] = (void *)rndr;
+    mpi->planes[0] = mpi->planes[3] = (void *)rndr;
     mpi->num_planes = 1;
     mpi->priv = rndr;
     return VO_TRUE;