diff -ruN ffmpeg/configure ffmpeg.3/configure
--- ffmpeg/configure	2009-04-23 17:25:50.000000000 +0400
+++ ffmpeg.3/configure	2009-04-25 19:15:40.000000000 +0400
@@ -2030,6 +2030,7 @@
 
 check_lib math.h sin -lm
 check_lib va/va.h vaInitialize -lva
+check_lib va/va_x11.h vaGetDisplay -lva-x11
 
 # test for C99 functions in math.h
 for func in llrint lrint lrintf round roundf truncf; do
diff -ruN ffmpeg/ffplay.c ffmpeg.3/ffplay.c
--- ffmpeg/ffplay.c	2009-04-20 12:11:52.000000000 +0400
+++ ffmpeg.3/ffplay.c	2009-04-25 19:16:00.000000000 +0400
@@ -29,6 +29,8 @@
 #include "libavcodec/audioconvert.h"
 #include "libavcodec/opt.h"
 
+#include "VAAPI.h"
+
 #include "cmdutils.h"
 
 #include <SDL.h>
@@ -1356,6 +1358,11 @@
     AVFrame *frame= avcodec_alloc_frame();
     double pts;
 
+    /* Initialize vaapi */
+    CVAAPI(320, 240);
+    /* Change get_format method */
+    is->video_st->codec->get_format = FFGetFormat;
+
     for(;;) {
         while (is->paused && !is->videoq.abort_request) {
             SDL_Delay(10);
@@ -1387,6 +1394,8 @@
 //            if (len1 < 0)
 //                break;
         if (got_picture) {
+            /* Here we'll play with out current output */
+	    FFTestVAAPI(is->video_st->codec, frame);
             if (output_picture2(is, frame, pts) < 0)
                 goto the_end;
         }
diff -ruN ffmpeg/libavcodec/allcodecs.c ffmpeg.3/libavcodec/allcodecs.c
--- ffmpeg/libavcodec/allcodecs.c	2009-04-23 17:25:50.000000000 +0400
+++ ffmpeg.3/libavcodec/allcodecs.c	2009-04-25 19:15:49.000000000 +0400
@@ -55,6 +55,7 @@
 
     /* hardware accelerators */
     REGISTER_HWACCEL (H263_VAAPI, h263_vaapi);
+    REGISTER_HWACCEL (H264_VAAPI, h264_vaapi);
     REGISTER_HWACCEL (MPEG2_VAAPI, mpeg2_vaapi);
     REGISTER_HWACCEL (MPEG4_VAAPI, mpeg4_vaapi);
     REGISTER_HWACCEL (VC1_VAAPI, vc1_vaapi);
diff -ruN ffmpeg/libavcodec/Makefile ffmpeg.3/libavcodec/Makefile
--- ffmpeg/libavcodec/Makefile	2009-04-23 17:25:50.000000000 +0400
+++ ffmpeg.3/libavcodec/Makefile	2009-04-25 19:15:49.000000000 +0400
@@ -104,6 +104,7 @@
 OBJS-$(CONFIG_H263P_ENCODER)           += mpegvideo_enc.o motion_est.o ratecontrol.o h263.o mpeg12data.o mpegvideo.o error_resilience.o
 OBJS-$(CONFIG_H264_DECODER)            += h264.o h264idct.o h264pred.o h264_parser.o cabac.o mpegvideo.o error_resilience.o
 OBJS-$(CONFIG_H264_ENCODER)            += h264enc.o h264dspenc.o
+OBJS-$(CONFIG_H264_VAAPI_HWACCEL)      += h264.o h264idct.o h264pred.o h264_parser.o cabac.o mpegvideo.o error_resilience.o vaapi.o vaapi_h264.o
 OBJS-$(CONFIG_H264_VDPAU_DECODER)      += vdpau.o h264.o h264idct.o h264pred.o h264_parser.o cabac.o mpegvideo.o error_resilience.o
 OBJS-$(CONFIG_HUFFYUV_DECODER)         += huffyuv.o
 OBJS-$(CONFIG_HUFFYUV_ENCODER)         += huffyuv.o
diff -ruN ffmpeg/libavcodec/Makefile.orig ffmpeg.3/libavcodec/Makefile.orig
--- ffmpeg/libavcodec/Makefile.orig	1970-01-01 03:00:00.000000000 +0300
+++ ffmpeg.3/libavcodec/Makefile.orig	2009-04-23 17:25:50.000000000 +0400
@@ -0,0 +1,548 @@
+include $(SUBDIR)../config.mak
+
+NAME = avcodec
+FFLIBS = avutil
+
+HEADERS = avcodec.h opt.h vdpau.h xvmc.h
+
+OBJS = allcodecs.o                                                      \
+       audioconvert.o                                                   \
+       avpacket.o                                                       \
+       bitstream.o                                                      \
+       bitstream_filter.o                                               \
+       dsputil.o                                                        \
+       eval.o                                                           \
+       faanidct.o                                                       \
+       imgconvert.o                                                     \
+       jrevdct.o                                                        \
+       opt.o                                                            \
+       options.o                                                        \
+       parser.o                                                         \
+       raw.o                                                            \
+       resample.o                                                       \
+       resample2.o                                                      \
+       simple_idct.o                                                    \
+       utils.o                                                          \
+
+# parts needed for many different codecs
+OBJS-$(CONFIG_AANDCT)                  += aandcttab.o
+OBJS-$(CONFIG_ENCODERS)                += faandct.o jfdctfst.o jfdctint.o
+OBJS-$(CONFIG_FFT)                     += fft.o
+OBJS-$(CONFIG_GOLOMB)                  += golomb.o
+OBJS-$(CONFIG_MDCT)                    += mdct.o
+OBJS-$(CONFIG_RDFT)                    += rdft.o
+
+# decoders/encoders/hardware accelerators
+OBJS-$(CONFIG_AAC_DECODER)             += aac.o aactab.o mpeg4audio.o aac_parser.o aac_ac3_parser.o
+OBJS-$(CONFIG_AASC_DECODER)            += aasc.o msrledec.o
+OBJS-$(CONFIG_AC3_DECODER)             += eac3dec.o ac3dec.o ac3tab.o ac3dec_data.o ac3.o
+OBJS-$(CONFIG_AC3_ENCODER)             += ac3enc.o ac3tab.o ac3.o
+OBJS-$(CONFIG_ALAC_DECODER)            += alac.o
+OBJS-$(CONFIG_ALAC_ENCODER)            += alacenc.o lpc.o
+OBJS-$(CONFIG_AMV_DECODER)             += sp5xdec.o mjpegdec.o mjpeg.o
+OBJS-$(CONFIG_APE_DECODER)             += apedec.o
+OBJS-$(CONFIG_ASV1_DECODER)            += asv1.o mpeg12data.o
+OBJS-$(CONFIG_ASV1_ENCODER)            += asv1.o mpeg12data.o
+OBJS-$(CONFIG_ASV2_DECODER)            += asv1.o mpeg12data.o
+OBJS-$(CONFIG_ASV2_ENCODER)            += asv1.o mpeg12data.o
+OBJS-$(CONFIG_ATRAC3_DECODER)          += atrac3.o
+OBJS-$(CONFIG_AVS_DECODER)             += avs.o
+OBJS-$(CONFIG_BETHSOFTVID_DECODER)     += bethsoftvideo.o
+OBJS-$(CONFIG_BFI_DECODER)             += bfi.o
+OBJS-$(CONFIG_BMP_DECODER)             += bmp.o msrledec.o
+OBJS-$(CONFIG_BMP_ENCODER)             += bmpenc.o
+OBJS-$(CONFIG_C93_DECODER)             += c93.o
+OBJS-$(CONFIG_CAVS_DECODER)            += cavs.o cavsdec.o cavsdsp.o mpeg12data.o mpegvideo.o
+OBJS-$(CONFIG_CINEPAK_DECODER)         += cinepak.o
+OBJS-$(CONFIG_CLJR_DECODER)            += cljr.o
+OBJS-$(CONFIG_CLJR_ENCODER)            += cljr.o
+OBJS-$(CONFIG_COOK_DECODER)            += cook.o
+OBJS-$(CONFIG_CSCD_DECODER)            += cscd.o
+OBJS-$(CONFIG_CYUV_DECODER)            += cyuv.o
+OBJS-$(CONFIG_DCA_DECODER)             += dca.o
+OBJS-$(CONFIG_DNXHD_DECODER)           += dnxhddec.o dnxhddata.o
+OBJS-$(CONFIG_DNXHD_ENCODER)           += dnxhdenc.o dnxhddata.o mpegvideo_enc.o motion_est.o ratecontrol.o mpeg12data.o mpegvideo.o
+OBJS-$(CONFIG_DSICINAUDIO_DECODER)     += dsicinav.o
+OBJS-$(CONFIG_DSICINVIDEO_DECODER)     += dsicinav.o
+OBJS-$(CONFIG_DVBSUB_DECODER)          += dvbsubdec.o
+OBJS-$(CONFIG_DVBSUB_ENCODER)          += dvbsub.o
+OBJS-$(CONFIG_DVDSUB_DECODER)          += dvdsubdec.o
+OBJS-$(CONFIG_DVDSUB_ENCODER)          += dvdsubenc.o
+OBJS-$(CONFIG_DVVIDEO_DECODER)         += dv.o
+OBJS-$(CONFIG_DVVIDEO_ENCODER)         += dv.o
+OBJS-$(CONFIG_DXA_DECODER)             += dxa.o
+OBJS-$(CONFIG_EAC3_DECODER)            += eac3dec.o ac3dec.o ac3tab.o ac3dec_data.o ac3.o
+OBJS-$(CONFIG_EACMV_DECODER)           += eacmv.o
+OBJS-$(CONFIG_EATGQ_DECODER)           += eatgq.o eaidct.o
+OBJS-$(CONFIG_EATGV_DECODER)           += eatgv.o
+OBJS-$(CONFIG_EATQI_DECODER)           += eatqi.o eaidct.o mpeg12.o mpeg12data.o mpegvideo.o error_resilience.o
+OBJS-$(CONFIG_EIGHTBPS_DECODER)        += 8bps.o
+OBJS-$(CONFIG_EIGHTSVX_EXP_DECODER)    += 8svx.o
+OBJS-$(CONFIG_EIGHTSVX_FIB_DECODER)    += 8svx.o
+OBJS-$(CONFIG_ESCAPE124_DECODER)       += escape124.o
+OBJS-$(CONFIG_FFV1_DECODER)            += ffv1.o rangecoder.o
+OBJS-$(CONFIG_FFV1_ENCODER)            += ffv1.o rangecoder.o
+OBJS-$(CONFIG_FFVHUFF_DECODER)         += huffyuv.o
+OBJS-$(CONFIG_FFVHUFF_ENCODER)         += huffyuv.o
+OBJS-$(CONFIG_FLAC_DECODER)            += flacdec.o flacdata.o flac.o
+OBJS-$(CONFIG_FLAC_ENCODER)            += flacenc.o flacdata.o flac.o lpc.o
+OBJS-$(CONFIG_FLASHSV_DECODER)         += flashsv.o
+OBJS-$(CONFIG_FLASHSV_ENCODER)         += flashsvenc.o
+OBJS-$(CONFIG_FLIC_DECODER)            += flicvideo.o
+OBJS-$(CONFIG_FLV_DECODER)             += h263dec.o h263.o mpeg12data.o mpegvideo.o error_resilience.o
+OBJS-$(CONFIG_FLV_ENCODER)             += mpegvideo_enc.o motion_est.o ratecontrol.o h263.o mpeg12data.o mpegvideo.o error_resilience.o
+OBJS-$(CONFIG_FOURXM_DECODER)          += 4xm.o
+OBJS-$(CONFIG_FRAPS_DECODER)           += fraps.o huffman.o
+OBJS-$(CONFIG_GIF_DECODER)             += gifdec.o lzw.o
+OBJS-$(CONFIG_GIF_ENCODER)             += gif.o
+OBJS-$(CONFIG_H261_DECODER)            += h261dec.o h261.o mpegvideo.o error_resilience.o
+OBJS-$(CONFIG_H261_ENCODER)            += h261enc.o h261.o mpegvideo_enc.o motion_est.o ratecontrol.o mpeg12data.o mpegvideo.o
+OBJS-$(CONFIG_H263_DECODER)            += h263dec.o h263.o h263_parser.o mpeg12data.o mpegvideo.o error_resilience.o
+OBJS-$(CONFIG_H263_VAAPI_HWACCEL)      += h263dec.o h263.o h263_parser.o mpeg12data.o mpegvideo.o error_resilience.o vaapi.o vaapi_mpeg4.o
+OBJS-$(CONFIG_H263I_DECODER)           += h263dec.o h263.o mpeg12data.o mpegvideo.o error_resilience.o
+OBJS-$(CONFIG_H263_ENCODER)            += mpegvideo_enc.o motion_est.o ratecontrol.o h263.o mpeg12data.o mpegvideo.o error_resilience.o
+OBJS-$(CONFIG_H263P_ENCODER)           += mpegvideo_enc.o motion_est.o ratecontrol.o h263.o mpeg12data.o mpegvideo.o error_resilience.o
+OBJS-$(CONFIG_H264_DECODER)            += h264.o h264idct.o h264pred.o h264_parser.o cabac.o mpegvideo.o error_resilience.o
+OBJS-$(CONFIG_H264_ENCODER)            += h264enc.o h264dspenc.o
+OBJS-$(CONFIG_H264_VDPAU_DECODER)      += vdpau.o h264.o h264idct.o h264pred.o h264_parser.o cabac.o mpegvideo.o error_resilience.o
+OBJS-$(CONFIG_HUFFYUV_DECODER)         += huffyuv.o
+OBJS-$(CONFIG_HUFFYUV_ENCODER)         += huffyuv.o
+OBJS-$(CONFIG_IDCIN_DECODER)           += idcinvideo.o
+OBJS-$(CONFIG_IMC_DECODER)             += imc.o
+OBJS-$(CONFIG_INDEO2_DECODER)          += indeo2.o
+OBJS-$(CONFIG_INDEO3_DECODER)          += indeo3.o
+OBJS-$(CONFIG_INTERPLAY_DPCM_DECODER)  += dpcm.o
+OBJS-$(CONFIG_INTERPLAY_VIDEO_DECODER) += interplayvideo.o
+OBJS-$(CONFIG_JPEGLS_DECODER)          += jpeglsdec.o jpegls.o mjpegdec.o mjpeg.o
+OBJS-$(CONFIG_JPEGLS_ENCODER)          += jpeglsenc.o jpegls.o
+OBJS-$(CONFIG_KMVC_DECODER)            += kmvc.o
+OBJS-$(CONFIG_LJPEG_ENCODER)           += ljpegenc.o mjpegenc.o mjpeg.o mpegvideo_enc.o motion_est.o ratecontrol.o mpeg12data.o mpegvideo.o
+OBJS-$(CONFIG_LOCO_DECODER)            += loco.o
+OBJS-$(CONFIG_MACE3_DECODER)           += mace.o
+OBJS-$(CONFIG_MACE6_DECODER)           += mace.o
+OBJS-$(CONFIG_MDEC_DECODER)            += mdec.o mpeg12.o mpeg12data.o mpegvideo.o error_resilience.o
+OBJS-$(CONFIG_MIMIC_DECODER)           += mimic.o
+OBJS-$(CONFIG_MJPEG_DECODER)           += mjpegdec.o mjpeg.o
+OBJS-$(CONFIG_MJPEG_ENCODER)           += mjpegenc.o mjpeg.o mpegvideo_enc.o motion_est.o ratecontrol.o mpeg12data.o mpegvideo.o
+OBJS-$(CONFIG_MJPEGB_DECODER)          += mjpegbdec.o mjpegdec.o mjpeg.o
+OBJS-$(CONFIG_MLP_DECODER)             += mlpdec.o mlp_parser.o mlp.o
+OBJS-$(CONFIG_MMVIDEO_DECODER)         += mmvideo.o
+OBJS-$(CONFIG_MOTIONPIXELS_DECODER)    += motionpixels.o
+OBJS-$(CONFIG_MP1_DECODER)             += mpegaudiodec.o mpegaudiodecheader.o mpegaudio.o mpegaudiodata.o
+OBJS-$(CONFIG_MP2_DECODER)             += mpegaudiodec.o mpegaudiodecheader.o mpegaudio.o mpegaudiodata.o
+OBJS-$(CONFIG_MP2_ENCODER)             += mpegaudioenc.o mpegaudio.o mpegaudiodata.o
+OBJS-$(CONFIG_MP3ADU_DECODER)          += mpegaudiodec.o mpegaudiodecheader.o mpegaudio.o mpegaudiodata.o
+OBJS-$(CONFIG_MP3ON4_DECODER)          += mpegaudiodec.o mpegaudiodecheader.o mpegaudio.o mpegaudiodata.o mpeg4audio.o
+OBJS-$(CONFIG_MP3_DECODER)             += mpegaudiodec.o mpegaudiodecheader.o mpegaudio.o mpegaudiodata.o
+OBJS-$(CONFIG_MPC7_DECODER)            += mpc7.o mpc.o mpegaudiodec.o mpegaudiodecheader.o mpegaudio.o mpegaudiodata.o
+OBJS-$(CONFIG_MPC8_DECODER)            += mpc8.o mpc.o mpegaudiodec.o mpegaudiodecheader.o mpegaudio.o mpegaudiodata.o
+OBJS-$(CONFIG_MPEG_VDPAU_DECODER)      += vdpau.o mpeg12.o mpeg12data.o mpegvideo.o error_resilience.o
+OBJS-$(CONFIG_MPEG1_VDPAU_DECODER)     += vdpau.o mpeg12.o mpeg12data.o mpegvideo.o error_resilience.o
+OBJS-$(CONFIG_MPEG_XVMC_DECODER)       += mpegvideo_xvmc.o mpeg12.o mpeg12data.o mpegvideo.o error_resilience.o
+OBJS-$(CONFIG_MPEGVIDEO_DECODER)       += mpeg12.o mpeg12data.o mpegvideo.o error_resilience.o
+OBJS-$(CONFIG_MPEG1VIDEO_DECODER)      += mpeg12.o mpeg12data.o mpegvideo.o error_resilience.o
+OBJS-$(CONFIG_MPEG1VIDEO_ENCODER)      += mpeg12enc.o mpeg12data.o mpegvideo_enc.o motion_est.o ratecontrol.o mpeg12.o mpeg12data.o mpegvideo.o error_resilience.o
+OBJS-$(CONFIG_MPEG2_VAAPI_HWACCEL)     += mpeg12.o mpeg12data.o mpegvideo.o error_resilience.o vaapi.o vaapi_mpeg2.o
+OBJS-$(CONFIG_MPEG2VIDEO_DECODER)      += mpeg12.o mpeg12data.o mpegvideo.o error_resilience.o
+OBJS-$(CONFIG_MPEG2VIDEO_ENCODER)      += mpeg12enc.o mpeg12data.o mpegvideo_enc.o motion_est.o ratecontrol.o mpeg12.o mpeg12data.o mpegvideo.o error_resilience.o
+OBJS-$(CONFIG_MPEG4_DECODER)           += h263dec.o h263.o mpeg4video_parser.o mpeg12data.o mpegvideo.o error_resilience.o
+OBJS-$(CONFIG_MPEG4_ENCODER)           += mpegvideo_enc.o motion_est.o ratecontrol.o h263.o mpeg12data.o mpegvideo.o error_resilience.o
+OBJS-$(CONFIG_MPEG4_VAAPI_HWACCEL)     += h263dec.o h263.o mpeg4video_parser.o mpeg12data.o mpegvideo.o error_resilience.o vaapi.o vaapi_mpeg4.o
+OBJS-$(CONFIG_MSMPEG4V1_DECODER)       += msmpeg4.o msmpeg4data.o h263dec.o h263.o mpeg12data.o mpegvideo.o error_resilience.o
+OBJS-$(CONFIG_MSMPEG4V1_ENCODER)       += msmpeg4.o msmpeg4data.o mpegvideo_enc.o motion_est.o ratecontrol.o h263.o mpeg12data.o mpegvideo.o error_resilience.o
+OBJS-$(CONFIG_MSMPEG4V2_DECODER)       += msmpeg4.o msmpeg4data.o h263dec.o h263.o mpeg12data.o mpegvideo.o error_resilience.o
+OBJS-$(CONFIG_MSMPEG4V2_ENCODER)       += msmpeg4.o msmpeg4data.o mpegvideo_enc.o motion_est.o ratecontrol.o h263.o mpeg12data.o mpegvideo.o error_resilience.o
+OBJS-$(CONFIG_MSMPEG4V3_DECODER)       += msmpeg4.o msmpeg4data.o h263dec.o h263.o mpeg12data.o mpegvideo.o error_resilience.o
+OBJS-$(CONFIG_MSMPEG4V3_ENCODER)       += msmpeg4.o msmpeg4data.o mpegvideo_enc.o motion_est.o ratecontrol.o h263.o mpeg12data.o mpegvideo.o error_resilience.o
+OBJS-$(CONFIG_MSRLE_DECODER)           += msrle.o msrledec.o
+OBJS-$(CONFIG_MSVIDEO1_DECODER)        += msvideo1.o
+OBJS-$(CONFIG_MSZH_DECODER)            += lcldec.o
+OBJS-$(CONFIG_NELLYMOSER_DECODER)      += nellymoserdec.o nellymoser.o
+OBJS-$(CONFIG_NELLYMOSER_ENCODER)      += nellymoserenc.o nellymoser.o
+OBJS-$(CONFIG_NUV_DECODER)             += nuv.o rtjpeg.o
+OBJS-$(CONFIG_PAM_DECODER)             += pnmenc.o pnm.o
+OBJS-$(CONFIG_PAM_ENCODER)             += pnmenc.o
+OBJS-$(CONFIG_PBM_DECODER)             += pnmenc.o pnm.o
+OBJS-$(CONFIG_PBM_ENCODER)             += pnmenc.o
+OBJS-$(CONFIG_PCX_DECODER)             += pcx.o
+OBJS-$(CONFIG_PCX_ENCODER)             += pcxenc.o
+OBJS-$(CONFIG_PGM_DECODER)             += pnmenc.o pnm.o
+OBJS-$(CONFIG_PGM_ENCODER)             += pnmenc.o
+OBJS-$(CONFIG_PGMYUV_DECODER)          += pnmenc.o pnm.o
+OBJS-$(CONFIG_PGMYUV_ENCODER)          += pnmenc.o
+OBJS-$(CONFIG_PNG_DECODER)             += png.o pngdec.o
+OBJS-$(CONFIG_PNG_ENCODER)             += png.o pngenc.o
+OBJS-$(CONFIG_PPM_DECODER)             += pnmenc.o pnm.o
+OBJS-$(CONFIG_PPM_ENCODER)             += pnmenc.o
+OBJS-$(CONFIG_PTX_DECODER)             += ptx.o
+OBJS-$(CONFIG_QCELP_DECODER)           += qcelpdec.o qcelp_lsp.o celp_math.o celp_filters.o acelp_vectors.o
+OBJS-$(CONFIG_QDM2_DECODER)            += qdm2.o mpegaudiodec.o mpegaudiodecheader.o mpegaudio.o mpegaudiodata.o
+OBJS-$(CONFIG_QDRAW_DECODER)           += qdrw.o
+OBJS-$(CONFIG_QPEG_DECODER)            += qpeg.o
+OBJS-$(CONFIG_QTRLE_DECODER)           += qtrle.o
+OBJS-$(CONFIG_QTRLE_ENCODER)           += qtrleenc.o
+OBJS-$(CONFIG_RA_144_DECODER)          += ra144.o celp_filters.o
+OBJS-$(CONFIG_RA_288_DECODER)          += ra288.o celp_math.o celp_filters.o
+OBJS-$(CONFIG_RAWVIDEO_DECODER)        += rawdec.o
+OBJS-$(CONFIG_RAWVIDEO_ENCODER)        += rawenc.o
+OBJS-$(CONFIG_RL2_DECODER)             += rl2.o
+OBJS-$(CONFIG_ROQ_DECODER)             += roqvideodec.o roqvideo.o
+OBJS-$(CONFIG_ROQ_ENCODER)             += roqvideoenc.o roqvideo.o elbg.o
+OBJS-$(CONFIG_ROQ_DPCM_DECODER)        += dpcm.o
+OBJS-$(CONFIG_ROQ_DPCM_ENCODER)        += roqaudioenc.o
+OBJS-$(CONFIG_RPZA_DECODER)            += rpza.o
+OBJS-$(CONFIG_RV10_DECODER)            += rv10.o h263.o mpeg12data.o mpegvideo.o error_resilience.o
+OBJS-$(CONFIG_RV10_ENCODER)            += rv10.o mpegvideo_enc.o motion_est.o ratecontrol.o h263.o mpeg12data.o mpegvideo.o error_resilience.o
+OBJS-$(CONFIG_RV20_DECODER)            += rv10.o h263.o mpeg12data.o mpegvideo.o error_resilience.o
+OBJS-$(CONFIG_RV20_ENCODER)            += rv10.o mpegvideo_enc.o motion_est.o ratecontrol.o h263.o mpeg12data.o mpegvideo.o error_resilience.o
+OBJS-$(CONFIG_RV30_DECODER)            += rv30.o rv34.o h264pred.o rv30dsp.o mpegvideo.o error_resilience.o
+OBJS-$(CONFIG_RV40_DECODER)            += rv40.o rv34.o h264pred.o rv40dsp.o mpegvideo.o error_resilience.o
+OBJS-$(CONFIG_SGI_DECODER)             += sgidec.o
+OBJS-$(CONFIG_SGI_ENCODER)             += sgienc.o rle.o
+OBJS-$(CONFIG_SHORTEN_DECODER)         += shorten.o
+OBJS-$(CONFIG_SMACKAUD_DECODER)        += smacker.o
+OBJS-$(CONFIG_SMACKER_DECODER)         += smacker.o
+OBJS-$(CONFIG_SMC_DECODER)             += smc.o
+OBJS-$(CONFIG_SNOW_DECODER)            += snow.o rangecoder.o
+OBJS-$(CONFIG_SNOW_ENCODER)            += snow.o rangecoder.o motion_est.o ratecontrol.o h263.o mpeg12data.o mpegvideo.o error_resilience.o
+OBJS-$(CONFIG_SOL_DPCM_DECODER)        += dpcm.o
+OBJS-$(CONFIG_SONIC_DECODER)           += sonic.o
+OBJS-$(CONFIG_SONIC_ENCODER)           += sonic.o
+OBJS-$(CONFIG_SONIC_LS_ENCODER)        += sonic.o
+OBJS-$(CONFIG_SP5X_DECODER)            += sp5xdec.o mjpegdec.o mjpeg.o
+OBJS-$(CONFIG_SUNRAST_DECODER)         += sunrast.o
+OBJS-$(CONFIG_SVQ1_DECODER)            += svq1dec.o svq1.o h263.o mpeg12data.o mpegvideo.o error_resilience.o
+OBJS-$(CONFIG_SVQ1_ENCODER)            += svq1enc.o svq1.o motion_est.o h263.o mpeg12data.o mpegvideo.o error_resilience.o
+OBJS-$(CONFIG_SVQ3_DECODER)            += h264.o h264idct.o h264pred.o h264_parser.o cabac.o mpegvideo.o error_resilience.o svq1dec.o svq1.o h263.o
+OBJS-$(CONFIG_TARGA_DECODER)           += targa.o
+OBJS-$(CONFIG_TARGA_ENCODER)           += targaenc.o rle.o
+OBJS-$(CONFIG_THEORA_DECODER)          += vp3.o xiph.o vp3dsp.o
+OBJS-$(CONFIG_THP_DECODER)             += mjpegdec.o mjpeg.o
+OBJS-$(CONFIG_TIERTEXSEQVIDEO_DECODER) += tiertexseqv.o
+OBJS-$(CONFIG_TIFF_DECODER)            += tiff.o lzw.o faxcompr.o
+OBJS-$(CONFIG_TIFF_ENCODER)            += tiffenc.o rle.o lzwenc.o
+OBJS-$(CONFIG_TRUEHD_DECODER)          += mlpdec.o mlp_parser.o mlp.o
+OBJS-$(CONFIG_TRUEMOTION1_DECODER)     += truemotion1.o
+OBJS-$(CONFIG_TRUEMOTION2_DECODER)     += truemotion2.o
+OBJS-$(CONFIG_TRUESPEECH_DECODER)      += truespeech.o
+OBJS-$(CONFIG_TSCC_DECODER)            += tscc.o msrledec.o
+OBJS-$(CONFIG_TTA_DECODER)             += tta.o
+OBJS-$(CONFIG_TXD_DECODER)             += txd.o s3tc.o
+OBJS-$(CONFIG_ULTI_DECODER)            += ulti.o
+OBJS-$(CONFIG_V210X_DECODER)           += v210x.o
+OBJS-$(CONFIG_VB_DECODER)              += vb.o
+OBJS-$(CONFIG_VC1_DECODER)             += vc1.o vc1data.o vc1dsp.o msmpeg4data.o h263dec.o h263.o intrax8.o intrax8dsp.o error_resilience.o mpegvideo.o msmpeg4.o
+OBJS-$(CONFIG_VC1_VAAPI_HWACCEL)       += vc1.o vc1data.o vc1dsp.o msmpeg4data.o h263dec.o h263.o intrax8.o intrax8dsp.o error_resilience.o mpegvideo.o msmpeg4.o vaapi.o vaapi_vc1.o
+OBJS-$(CONFIG_VC1_VDPAU_DECODER)       += vdpau.o vc1.o vc1data.o vc1dsp.o msmpeg4data.o h263dec.o h263.o intrax8.o intrax8dsp.o error_resilience.o mpegvideo.o msmpeg4.o
+OBJS-$(CONFIG_VCR1_DECODER)            += vcr1.o
+OBJS-$(CONFIG_VCR1_ENCODER)            += vcr1.o
+OBJS-$(CONFIG_VMDAUDIO_DECODER)        += vmdav.o
+OBJS-$(CONFIG_VMDVIDEO_DECODER)        += vmdav.o
+OBJS-$(CONFIG_VMNC_DECODER)            += vmnc.o
+OBJS-$(CONFIG_VORBIS_DECODER)          += vorbis_dec.o vorbis.o vorbis_data.o xiph.o
+OBJS-$(CONFIG_VORBIS_ENCODER)          += vorbis_enc.o vorbis.o vorbis_data.o
+OBJS-$(CONFIG_VP3_DECODER)             += vp3.o vp3dsp.o
+OBJS-$(CONFIG_VP5_DECODER)             += vp5.o vp56.o vp56data.o vp3dsp.o
+OBJS-$(CONFIG_VP6_DECODER)             += vp6.o vp56.o vp56data.o vp3dsp.o vp6dsp.o huffman.o
+OBJS-$(CONFIG_VP6A_DECODER)            += vp6.o vp56.o vp56data.o vp3dsp.o vp6dsp.o huffman.o
+OBJS-$(CONFIG_VP6F_DECODER)            += vp6.o vp56.o vp56data.o vp3dsp.o vp6dsp.o huffman.o
+OBJS-$(CONFIG_VQA_DECODER)             += vqavideo.o
+OBJS-$(CONFIG_WAVPACK_DECODER)         += wavpack.o
+OBJS-$(CONFIG_WMAV1_DECODER)           += wmadec.o wma.o
+OBJS-$(CONFIG_WMAV1_ENCODER)           += wmaenc.o wma.o
+OBJS-$(CONFIG_WMAV2_DECODER)           += wmadec.o wma.o
+OBJS-$(CONFIG_WMAV2_ENCODER)           += wmaenc.o wma.o
+OBJS-$(CONFIG_WMV1_DECODER)            += h263dec.o h263.o mpeg12data.o mpegvideo.o error_resilience.o
+OBJS-$(CONFIG_WMV1_ENCODER)            += mpegvideo_enc.o motion_est.o ratecontrol.o h263.o mpeg12data.o mpegvideo.o error_resilience.o
+OBJS-$(CONFIG_WMV2_DECODER)            += wmv2dec.o wmv2.o msmpeg4.o msmpeg4data.o h263dec.o h263.o intrax8.o intrax8dsp.o mpeg12data.o mpegvideo.o error_resilience.o
+OBJS-$(CONFIG_WMV2_ENCODER)            += wmv2enc.o wmv2.o msmpeg4.o msmpeg4data.o mpegvideo_enc.o motion_est.o ratecontrol.o h263.o mpeg12data.o mpegvideo.o error_resilience.o
+OBJS-$(CONFIG_WMV3_DECODER)            += vc1.o vc1data.o vc1dsp.o msmpeg4data.o h263dec.o h263.o intrax8.o intrax8dsp.o error_resilience.o mpegvideo.o msmpeg4.o
+OBJS-$(CONFIG_WMV3_VAAPI_HWACCEL)      += vc1.o vc1data.o vc1dsp.o msmpeg4data.o h263dec.o h263.o intrax8.o intrax8dsp.o error_resilience.o mpegvideo.o msmpeg4.o vaapi.o vaapi_vc1.o
+OBJS-$(CONFIG_WMV3_VDPAU_DECODER)      += vdpau.o vc1.o vc1data.o vc1dsp.o msmpeg4data.o h263dec.o h263.o intrax8.o intrax8dsp.o error_resilience.o mpegvideo.o msmpeg4.o
+OBJS-$(CONFIG_WNV1_DECODER)            += wnv1.o
+OBJS-$(CONFIG_WS_SND1_DECODER)         += ws-snd1.o
+OBJS-$(CONFIG_XAN_DPCM_DECODER)        += dpcm.o
+OBJS-$(CONFIG_XAN_WC3_DECODER)         += xan.o
+OBJS-$(CONFIG_XAN_WC4_DECODER)         += xan.o
+OBJS-$(CONFIG_XL_DECODER)              += xl.o
+OBJS-$(CONFIG_XSUB_DECODER)            += xsubdec.o
+OBJS-$(CONFIG_ZLIB_DECODER)            += lcldec.o
+OBJS-$(CONFIG_ZLIB_ENCODER)            += lclenc.o
+OBJS-$(CONFIG_ZMBV_DECODER)            += zmbv.o
+OBJS-$(CONFIG_ZMBV_ENCODER)            += zmbvenc.o
+
+# (AD)PCM decoders/encoders
+OBJS-$(CONFIG_PCM_ALAW_DECODER)           += pcm.o
+OBJS-$(CONFIG_PCM_ALAW_ENCODER)           += pcm.o
+OBJS-$(CONFIG_PCM_DVD_DECODER)            += pcm.o
+OBJS-$(CONFIG_PCM_DVD_ENCODER)            += pcm.o
+OBJS-$(CONFIG_PCM_F32BE_DECODER)          += pcm.o
+OBJS-$(CONFIG_PCM_F32BE_ENCODER)          += pcm.o
+OBJS-$(CONFIG_PCM_F32LE_DECODER)          += pcm.o
+OBJS-$(CONFIG_PCM_F32LE_ENCODER)          += pcm.o
+OBJS-$(CONFIG_PCM_F64BE_DECODER)          += pcm.o
+OBJS-$(CONFIG_PCM_F64BE_ENCODER)          += pcm.o
+OBJS-$(CONFIG_PCM_F64LE_DECODER)          += pcm.o
+OBJS-$(CONFIG_PCM_F64LE_ENCODER)          += pcm.o
+OBJS-$(CONFIG_PCM_MULAW_DECODER)          += pcm.o
+OBJS-$(CONFIG_PCM_MULAW_ENCODER)          += pcm.o
+OBJS-$(CONFIG_PCM_S8_DECODER)             += pcm.o
+OBJS-$(CONFIG_PCM_S8_ENCODER)             += pcm.o
+OBJS-$(CONFIG_PCM_S16BE_DECODER)          += pcm.o
+OBJS-$(CONFIG_PCM_S16BE_ENCODER)          += pcm.o
+OBJS-$(CONFIG_PCM_S16LE_DECODER)          += pcm.o
+OBJS-$(CONFIG_PCM_S16LE_ENCODER)          += pcm.o
+OBJS-$(CONFIG_PCM_S16LE_PLANAR_DECODER)   += pcm.o
+OBJS-$(CONFIG_PCM_S24BE_DECODER)          += pcm.o
+OBJS-$(CONFIG_PCM_S24BE_ENCODER)          += pcm.o
+OBJS-$(CONFIG_PCM_S24DAUD_DECODER)        += pcm.o
+OBJS-$(CONFIG_PCM_S24DAUD_ENCODER)        += pcm.o
+OBJS-$(CONFIG_PCM_S24LE_DECODER)          += pcm.o
+OBJS-$(CONFIG_PCM_S24LE_ENCODER)          += pcm.o
+OBJS-$(CONFIG_PCM_S32BE_DECODER)          += pcm.o
+OBJS-$(CONFIG_PCM_S32BE_ENCODER)          += pcm.o
+OBJS-$(CONFIG_PCM_S32LE_DECODER)          += pcm.o
+OBJS-$(CONFIG_PCM_S32LE_ENCODER)          += pcm.o
+OBJS-$(CONFIG_PCM_U8_DECODER)             += pcm.o
+OBJS-$(CONFIG_PCM_U8_ENCODER)             += pcm.o
+OBJS-$(CONFIG_PCM_U16BE_DECODER)          += pcm.o
+OBJS-$(CONFIG_PCM_U16BE_ENCODER)          += pcm.o
+OBJS-$(CONFIG_PCM_U16LE_DECODER)          += pcm.o
+OBJS-$(CONFIG_PCM_U16LE_ENCODER)          += pcm.o
+OBJS-$(CONFIG_PCM_U24BE_DECODER)          += pcm.o
+OBJS-$(CONFIG_PCM_U24BE_ENCODER)          += pcm.o
+OBJS-$(CONFIG_PCM_U24LE_DECODER)          += pcm.o
+OBJS-$(CONFIG_PCM_U24LE_ENCODER)          += pcm.o
+OBJS-$(CONFIG_PCM_U32BE_DECODER)          += pcm.o
+OBJS-$(CONFIG_PCM_U32BE_ENCODER)          += pcm.o
+OBJS-$(CONFIG_PCM_U32LE_DECODER)          += pcm.o
+OBJS-$(CONFIG_PCM_U32LE_ENCODER)          += pcm.o
+OBJS-$(CONFIG_PCM_ZORK_DECODER)           += pcm.o
+OBJS-$(CONFIG_PCM_ZORK_ENCODER)           += pcm.o
+
+OBJS-$(CONFIG_ADPCM_4XM_DECODER)          += adpcm.o
+OBJS-$(CONFIG_ADPCM_ADX_DECODER)          += adxdec.o
+OBJS-$(CONFIG_ADPCM_ADX_ENCODER)          += adxenc.o
+OBJS-$(CONFIG_ADPCM_CT_DECODER)           += adpcm.o
+OBJS-$(CONFIG_ADPCM_EA_DECODER)           += adpcm.o
+OBJS-$(CONFIG_ADPCM_EA_MAXIS_XA_DECODER)  += adpcm.o
+OBJS-$(CONFIG_ADPCM_EA_R1_DECODER)        += adpcm.o
+OBJS-$(CONFIG_ADPCM_EA_R2_DECODER)        += adpcm.o
+OBJS-$(CONFIG_ADPCM_EA_R3_DECODER)        += adpcm.o
+OBJS-$(CONFIG_ADPCM_EA_XAS_DECODER)       += adpcm.o
+OBJS-$(CONFIG_ADPCM_G726_DECODER)         += g726.o
+OBJS-$(CONFIG_ADPCM_G726_ENCODER)         += g726.o
+OBJS-$(CONFIG_ADPCM_IMA_AMV_DECODER)      += adpcm.o
+OBJS-$(CONFIG_ADPCM_IMA_DK3_DECODER)      += adpcm.o
+OBJS-$(CONFIG_ADPCM_IMA_DK4_DECODER)      += adpcm.o
+OBJS-$(CONFIG_ADPCM_IMA_EA_EACS_DECODER)  += adpcm.o
+OBJS-$(CONFIG_ADPCM_IMA_EA_SEAD_DECODER)  += adpcm.o
+OBJS-$(CONFIG_ADPCM_IMA_ISS_DECODER)      += adpcm.o
+OBJS-$(CONFIG_ADPCM_IMA_QT_DECODER)       += adpcm.o
+OBJS-$(CONFIG_ADPCM_IMA_QT_ENCODER)       += adpcm.o
+OBJS-$(CONFIG_ADPCM_IMA_SMJPEG_DECODER)   += adpcm.o
+OBJS-$(CONFIG_ADPCM_IMA_WAV_DECODER)      += adpcm.o
+OBJS-$(CONFIG_ADPCM_IMA_WAV_ENCODER)      += adpcm.o
+OBJS-$(CONFIG_ADPCM_IMA_WS_DECODER)       += adpcm.o
+OBJS-$(CONFIG_ADPCM_MS_DECODER)           += adpcm.o
+OBJS-$(CONFIG_ADPCM_MS_ENCODER)           += adpcm.o
+OBJS-$(CONFIG_ADPCM_SBPRO_2_DECODER)      += adpcm.o
+OBJS-$(CONFIG_ADPCM_SBPRO_3_DECODER)      += adpcm.o
+OBJS-$(CONFIG_ADPCM_SBPRO_4_DECODER)      += adpcm.o
+OBJS-$(CONFIG_ADPCM_SWF_DECODER)          += adpcm.o
+OBJS-$(CONFIG_ADPCM_SWF_ENCODER)          += adpcm.o
+OBJS-$(CONFIG_ADPCM_THP_DECODER)          += adpcm.o
+OBJS-$(CONFIG_ADPCM_XA_DECODER)           += adpcm.o
+OBJS-$(CONFIG_ADPCM_YAMAHA_DECODER)       += adpcm.o
+OBJS-$(CONFIG_ADPCM_YAMAHA_ENCODER)       += adpcm.o
+
+# libavformat dependencies
+OBJS-$(CONFIG_EAC3_DEMUXER)            += ac3_parser.o ac3tab.o aac_ac3_parser.o
+OBJS-$(CONFIG_FLAC_DEMUXER)            += flacdec.o flacdata.o flac.o
+OBJS-$(CONFIG_FLAC_MUXER)              += flacdec.o flacdata.o flac.o
+OBJS-$(CONFIG_GXF_DEMUXER)             += mpeg12data.o
+OBJS-$(CONFIG_MATROSKA_AUDIO_MUXER)    += xiph.o mpeg4audio.o flacdec.o flacdata.o flac.o
+OBJS-$(CONFIG_MATROSKA_DEMUXER)        += mpeg4audio.o
+OBJS-$(CONFIG_MATROSKA_MUXER)          += xiph.o mpeg4audio.o flacdec.o flacdata.o flac.o
+OBJS-$(CONFIG_MOV_DEMUXER)             += mpeg4audio.o mpegaudiodata.o
+OBJS-$(CONFIG_MPEGTS_MUXER)            += mpegvideo.o
+OBJS-$(CONFIG_NUT_MUXER)               += mpegaudiodata.o
+OBJS-$(CONFIG_OGG_DEMUXER)             += flacdec.o flacdata.o flac.o
+OBJS-$(CONFIG_OGG_MUXER)               += xiph.o flacdec.o flacdata.o flac.o
+OBJS-$(CONFIG_RTP_MUXER)               += mpegvideo.o
+
+# external codec libraries
+OBJS-$(CONFIG_LIBAMR_NB)               += libamr.o
+OBJS-$(CONFIG_LIBAMR_WB)               += libamr.o
+OBJS-$(CONFIG_LIBDIRAC_DECODER)        += libdiracdec.o
+OBJS-$(CONFIG_LIBDIRAC_ENCODER)        += libdiracenc.o libdirac_libschro.o
+OBJS-$(CONFIG_LIBFAAC)                 += libfaac.o
+OBJS-$(CONFIG_LIBFAAD)                 += libfaad.o
+OBJS-$(CONFIG_LIBGSM)                  += libgsm.o
+OBJS-$(CONFIG_LIBMP3LAME)              += libmp3lame.o
+OBJS-$(CONFIG_LIBOPENJPEG)             += libopenjpeg.o
+OBJS-$(CONFIG_LIBSCHROEDINGER_DECODER) += libschroedingerdec.o libschroedinger.o libdirac_libschro.o
+OBJS-$(CONFIG_LIBSCHROEDINGER_ENCODER) += libschroedingerenc.o libschroedinger.o libdirac_libschro.o
+OBJS-$(CONFIG_LIBSPEEX)                += libspeexdec.o
+OBJS-$(CONFIG_LIBTHEORA)               += libtheoraenc.o
+OBJS-$(CONFIG_LIBVORBIS)               += libvorbis.o
+OBJS-$(CONFIG_LIBX264)                 += libx264.o
+OBJS-$(CONFIG_LIBXVID)                 += libxvidff.o libxvid_rc.o
+
+# parsers
+OBJS-$(CONFIG_AAC_PARSER)              += aac_parser.o aac_ac3_parser.o mpeg4audio.o
+OBJS-$(CONFIG_AC3_PARSER)              += ac3_parser.o ac3tab.o aac_ac3_parser.o
+OBJS-$(CONFIG_CAVSVIDEO_PARSER)        += cavs_parser.o
+OBJS-$(CONFIG_DCA_PARSER)              += dca_parser.o
+OBJS-$(CONFIG_DIRAC_PARSER)            += dirac_parser.o
+OBJS-$(CONFIG_DNXHD_PARSER)            += dnxhd_parser.o
+OBJS-$(CONFIG_DVBSUB_PARSER)           += dvbsub_parser.o
+OBJS-$(CONFIG_DVDSUB_PARSER)           += dvdsub_parser.o
+OBJS-$(CONFIG_H261_PARSER)             += h261_parser.o
+OBJS-$(CONFIG_H263_PARSER)             += h263_parser.o
+OBJS-$(CONFIG_H264_PARSER)             += h264_parser.o
+OBJS-$(CONFIG_MJPEG_PARSER)            += mjpeg_parser.o
+OBJS-$(CONFIG_MLP_PARSER)              += mlp_parser.o mlp.o
+OBJS-$(CONFIG_MPEG4VIDEO_PARSER)       += mpeg4video_parser.o h263.o mpeg12data.o mpegvideo.o error_resilience.o
+OBJS-$(CONFIG_MPEGAUDIO_PARSER)        += mpegaudio_parser.o mpegaudiodecheader.o mpegaudiodata.o
+OBJS-$(CONFIG_MPEGVIDEO_PARSER)        += mpegvideo_parser.o mpeg12.o mpeg12data.o mpegvideo.o error_resilience.o
+OBJS-$(CONFIG_PNM_PARSER)              += pnm_parser.o pnm.o
+OBJS-$(CONFIG_VC1_PARSER)              += vc1_parser.o
+OBJS-$(CONFIG_VP3_PARSER)              += vp3_parser.o
+
+# bitstream filters
+OBJS-$(CONFIG_DUMP_EXTRADATA_BSF)         += dump_extradata_bsf.o
+OBJS-$(CONFIG_H264_MP4TOANNEXB_BSF)       += h264_mp4toannexb_bsf.o
+OBJS-$(CONFIG_IMX_DUMP_HEADER_BSF)        += imx_dump_header_bsf.o
+OBJS-$(CONFIG_MJPEGA_DUMP_HEADER_BSF)     += mjpega_dump_header_bsf.o
+OBJS-$(CONFIG_MOV2TEXTSUB_BSF)            += movsub_bsf.o
+OBJS-$(CONFIG_MP3_HEADER_COMPRESS_BSF)    += mp3_header_compress_bsf.o
+OBJS-$(CONFIG_MP3_HEADER_DECOMPRESS_BSF)  += mp3_header_decompress_bsf.o mpegaudiodata.o
+OBJS-$(CONFIG_NOISE_BSF)                  += noise_bsf.o
+OBJS-$(CONFIG_REMOVE_EXTRADATA_BSF)       += remove_extradata_bsf.o
+OBJS-$(CONFIG_TEXT2MOVSUB_BSF)            += movsub_bsf.o
+
+# thread libraries
+OBJS-$(HAVE_BEOSTHREADS)               += beosthread.o
+OBJS-$(HAVE_OS2THREADS)                += os2thread.o
+OBJS-$(HAVE_PTHREADS)                  += pthread.o
+OBJS-$(HAVE_W32THREADS)                += w32thread.o
+
+# processor-specific code
+YASM-OBJS-FFT-$(HAVE_AMD3DNOW)         += x86/fft_3dn.o
+YASM-OBJS-FFT-$(HAVE_AMD3DNOWEXT)      += x86/fft_3dn2.o
+YASM-OBJS-FFT-$(HAVE_SSE)              += x86/fft_sse.o
+YASM-OBJS-$(CONFIG_FFT)                += x86/fft_mmx.o $(YASM-OBJS-FFT-yes)
+YASM-OBJS-$(CONFIG_GPL)                += x86/h264_deblock_sse2.o       \
+                                          x86/h264_idct_sse2.o          \
+
+MMX-OBJS-$(CONFIG_CAVS_DECODER)        += x86/cavsdsp_mmx.o
+MMX-OBJS-$(CONFIG_ENCODERS)            += x86/dsputilenc_mmx.o
+MMX-OBJS-$(CONFIG_FLAC_ENCODER)        += x86/flacdsp_mmx.o
+MMX-OBJS-$(CONFIG_GPL)                 += x86/idct_mmx.o
+MMX-OBJS-$(CONFIG_SNOW_DECODER)        += x86/snowdsp_mmx.o
+MMX-OBJS-$(CONFIG_THEORA_DECODER)      += x86/vp3dsp_mmx.o x86/vp3dsp_sse2.o
+MMX-OBJS-$(CONFIG_VC1_DECODER)         += x86/vc1dsp_mmx.o
+MMX-OBJS-$(CONFIG_VP3_DECODER)         += x86/vp3dsp_mmx.o x86/vp3dsp_sse2.o
+MMX-OBJS-$(CONFIG_VP5_DECODER)         += x86/vp3dsp_mmx.o x86/vp3dsp_sse2.o
+MMX-OBJS-$(CONFIG_VP6_DECODER)         += x86/vp3dsp_mmx.o x86/vp3dsp_sse2.o \
+                                          x86/vp6dsp_mmx.o x86/vp6dsp_sse2.o
+MMX-OBJS-$(CONFIG_VP6A_DECODER)        += x86/vp3dsp_mmx.o x86/vp3dsp_sse2.o \
+                                          x86/vp6dsp_mmx.o x86/vp6dsp_sse2.o
+MMX-OBJS-$(CONFIG_VP6F_DECODER)        += x86/vp3dsp_mmx.o x86/vp3dsp_sse2.o \
+                                          x86/vp6dsp_mmx.o x86/vp6dsp_sse2.o
+MMX-OBJS-$(CONFIG_WMV3_DECODER)        += x86/vc1dsp_mmx.o
+MMX-OBJS-$(HAVE_YASM)                  += x86/dsputil_yasm.o            \
+                                          $(YASM-OBJS-yes)
+
+OBJS-$(HAVE_MMX)                       += x86/cpuid.o                   \
+                                          x86/dnxhd_mmx.o               \
+                                          x86/dsputil_mmx.o             \
+                                          x86/fdct_mmx.o                \
+                                          x86/idct_mmx_xvid.o           \
+                                          x86/idct_sse2_xvid.o          \
+                                          x86/motion_est_mmx.o          \
+                                          x86/mpegvideo_mmx.o           \
+                                          x86/simple_idct_mmx.o         \
+
+OBJS-$(ARCH_ALPHA)                     += alpha/dsputil_alpha.o         \
+                                          alpha/dsputil_alpha_asm.o     \
+                                          alpha/motion_est_alpha.o      \
+                                          alpha/motion_est_mvi_asm.o    \
+                                          alpha/mpegvideo_alpha.o       \
+                                          alpha/simple_idct_alpha.o     \
+
+OBJS-$(ARCH_ARM)                       += arm/dsputil_arm.o             \
+                                          arm/dsputil_arm_s.o           \
+                                          arm/jrevdct_arm.o             \
+                                          arm/mpegvideo_arm.o           \
+                                          arm/simple_idct_arm.o         \
+
+OBJS-$(HAVE_ARMV5TE)                   += arm/mpegvideo_armv5te.o       \
+                                          arm/mpegvideo_armv5te_s.o     \
+                                          arm/simple_idct_armv5te.o     \
+
+OBJS-$(HAVE_ARMV6)                     += arm/simple_idct_armv6.o       \
+
+OBJS-$(HAVE_ARMVFP)                    += arm/dsputil_vfp.o             \
+                                          arm/float_arm_vfp.o           \
+
+OBJS-$(HAVE_IWMMXT)                    += arm/dsputil_iwmmxt.o          \
+                                          arm/mpegvideo_iwmmxt.o        \
+
+OBJS-$(HAVE_NEON)                      += arm/dsputil_neon.o            \
+                                          arm/dsputil_neon_s.o          \
+                                          arm/h264dsp_neon.o            \
+                                          arm/h264idct_neon.o           \
+                                          arm/simple_idct_neon.o        \
+
+OBJS-$(ARCH_BFIN)                      += bfin/dsputil_bfin.o           \
+                                          bfin/fdct_bfin.o              \
+                                          bfin/idct_bfin.o              \
+                                          bfin/mpegvideo_bfin.o         \
+                                          bfin/pixels_bfin.o            \
+                                          bfin/vp3_bfin.o               \
+                                          bfin/vp3_idct_bfin.o          \
+
+OBJS-$(ARCH_PPC)                       += ppc/dsputil_ppc.o             \
+
+ALTIVEC-OBJS-$(CONFIG_H264_DECODER)    += ppc/h264_altivec.o
+ALTIVEC-OBJS-$(CONFIG_VC1_DECODER)     += ppc/vc1dsp_altivec.o
+ALTIVEC-OBJS-$(CONFIG_WMV3_DECODER)    += ppc/vc1dsp_altivec.o
+
+OBJS-$(HAVE_ALTIVEC)                   += ppc/check_altivec.o           \
+                                          ppc/dsputil_altivec.o         \
+                                          ppc/fdct_altivec.o            \
+                                          ppc/fft_altivec.o             \
+                                          ppc/float_altivec.o           \
+                                          ppc/gmc_altivec.o             \
+                                          ppc/idct_altivec.o            \
+                                          ppc/int_altivec.o             \
+                                          ppc/mpegvideo_altivec.o       \
+                                          $(ALTIVEC-OBJS-yes)
+
+OBJS-$(ARCH_SH4)                       += sh4/dsputil_align.o           \
+                                          sh4/dsputil_sh4.o             \
+                                          sh4/idct_sh4.o                \
+
+OBJS-$(CONFIG_MLIB)                    += mlib/dsputil_mlib.o           \
+
+OBJS-$(HAVE_MMI)                       += ps2/dsputil_mmi.o             \
+                                          ps2/idct_mmi.o                \
+                                          ps2/mpegvideo_mmi.o           \
+
+OBJS-$(HAVE_VIS)                       += sparc/dsputil_vis.o           \
+                                          sparc/simple_idct_vis.o       \
+
+
+EXAMPLES = api
+
+TESTPROGS = cabac dct eval fft h264 rangecoder snow
+TESTPROGS-$(ARCH_X86) += x86/cpuid
+TESTPROGS-$(HAVE_MMX) += motion
+
+DIRS = alpha arm bfin mlib ppc ps2 sh4 sparc x86
+
+include $(SUBDIR)../subdir.mak
+
+$(SUBDIR)dct-test$(EXESUF): $(SUBDIR)dctref.o
diff -ruN ffmpeg/libavcodec/vaapi_h264.c ffmpeg.3/libavcodec/vaapi_h264.c
--- ffmpeg/libavcodec/vaapi_h264.c	1970-01-01 03:00:00.000000000 +0300
+++ ffmpeg.3/libavcodec/vaapi_h264.c	2009-04-25 19:15:49.000000000 +0400
@@ -0,0 +1,331 @@
+/*
+ * H.264 HW decode acceleration through VA API
+ *
+ * Copyright (C) 2008-2009 Splitted-Desktop Systems
+ *
+ * This file is part of FFmpeg.
+ *
+ * FFmpeg is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License as published by the Free Software Foundation; either
+ * version 2.1 of the License, or (at your option) any later version.
+ *
+ * FFmpeg is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with FFmpeg; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
+ */
+
+#include "vaapi_internal.h"
+#include "h264.h"
+
+/** Reconstruct bitstream slice_type */
+static int h264_get_slice_type(H264Context *h)
+{
+    int slice_type = -1;
+    switch (h->slice_type) {
+    case FF_P_TYPE:  slice_type = 0; break;
+    case FF_B_TYPE:  slice_type = 1; break;
+    case FF_I_TYPE:  slice_type = 2; break;
+    case FF_SP_TYPE: slice_type = 3; break;
+    case FF_SI_TYPE: slice_type = 4; break;
+    }
+    return slice_type;
+}
+
+static void vaapi_h264_init_picture(VAPictureH264 *va_pic)
+{
+    va_pic->picture_id          = 0xffffffff;
+    va_pic->flags               = VA_PICTURE_H264_INVALID;
+    va_pic->TopFieldOrderCnt    = 0;
+    va_pic->BottomFieldOrderCnt = 0;
+}
+
+static void vaapi_h264_fill_picture(VAPictureH264 *va_pic, Picture *pic, int pic_structure)
+{
+    int poc;
+
+    if (pic_structure == 0)
+        pic_structure = pic->reference;
+
+    va_pic->picture_id = ff_vaapi_get_surface(pic);
+    va_pic->frame_idx  = pic->long_ref ? pic->pic_id : pic->frame_num;
+
+    va_pic->flags = 0;
+    if (pic_structure != PICT_FRAME) {
+        if (pic_structure & PICT_TOP_FIELD)
+            va_pic->flags |= VA_PICTURE_H264_TOP_FIELD;
+        if (pic_structure & PICT_BOTTOM_FIELD)
+            va_pic->flags |= VA_PICTURE_H264_BOTTOM_FIELD;
+    }
+    if (pic->reference) {
+        if (pic->long_ref)
+            va_pic->flags |= VA_PICTURE_H264_LONG_TERM_REFERENCE;
+        else
+            va_pic->flags |= VA_PICTURE_H264_SHORT_TERM_REFERENCE;
+    }
+
+    poc = 0;
+    if (pic_structure & PICT_TOP_FIELD) {
+        if ((poc = pic->field_poc[0]) == INT_MAX)
+            poc = 0;
+    }
+    va_pic->TopFieldOrderCnt = poc;
+
+    poc = 0;
+    if (pic_structure & PICT_BOTTOM_FIELD) {
+        if ((poc = pic->field_poc[1]) == INT_MAX)
+            poc = 0;
+    }
+    va_pic->BottomFieldOrderCnt = poc;
+}
+
+/** Decoded Picture Buffer */
+typedef struct DPB {
+    unsigned int   size;
+    unsigned int   max_size;
+    VAPictureH264 *pics;
+} DPB;
+
+static void dpb_init(DPB *dpb, VAPictureH264 *pics, unsigned int max_size)
+{
+    unsigned int i;
+
+    dpb->size     = 0;
+    dpb->max_size = max_size;
+    dpb->pics     = pics;
+    for (i = 0; i < dpb->max_size; i++)
+        vaapi_h264_init_picture(&dpb->pics[i]);
+}
+
+static void dpb_add(DPB *dpb, Picture *ff_pic)
+{
+    unsigned int i;
+
+    for (i = 0; i < dpb->size; i++) {
+        VAPictureH264 * const pic = &dpb->pics[i];
+        if (pic->picture_id == ff_vaapi_get_surface(ff_pic)) {
+            VAPictureH264 new_pic;
+            vaapi_h264_fill_picture(&new_pic, ff_pic, 0);
+            if ((new_pic.flags ^ pic->flags) & (VA_PICTURE_H264_TOP_FIELD | VA_PICTURE_H264_BOTTOM_FIELD)) {
+                /* Merge second field */
+                if (new_pic.flags & VA_PICTURE_H264_TOP_FIELD) {
+                    pic->flags              |= VA_PICTURE_H264_TOP_FIELD;
+                    pic->TopFieldOrderCnt    = new_pic.TopFieldOrderCnt;
+                }
+                if (new_pic.flags & VA_PICTURE_H264_BOTTOM_FIELD) {
+                    pic->flags              |= VA_PICTURE_H264_BOTTOM_FIELD;
+                    pic->BottomFieldOrderCnt = new_pic.BottomFieldOrderCnt;
+                }
+            }
+            return;
+        }
+    }
+
+    assert(dpb->size < dpb->max_size);
+    vaapi_h264_fill_picture(&dpb->pics[dpb->size++], ff_pic, 0);
+}
+
+static void vaapi_h264_fill_ReferenceFrames(VAPictureParameterBufferH264 *pic_param, H264Context *h)
+{
+    DPB dpb;
+    unsigned int i, l;
+
+    dpb_init(&dpb,
+             pic_param->ReferenceFrames,
+             FF_ARRAY_ELEMS(pic_param->ReferenceFrames));
+
+    for (l = 0; l < h->list_count; l++) {
+        for (i = 0; i < h->ref_count[l]; i++) {
+            Picture * const pic = &h->ref_list[l][i];
+            if (pic->reference)
+                dpb_add(&dpb, pic);
+        }
+    }
+}
+
+static void vaapi_h264_fill_RefPicList(VAPictureH264 RefPicList[32], Picture *ref_list, unsigned int ref_count)
+{
+    unsigned int i, n = 0;
+
+    for (i = 0; i < ref_count; i++)
+        if (ref_list[i].reference)
+            vaapi_h264_fill_picture(&RefPicList[n++], &ref_list[i], 0);
+
+    for (; n < 32; n++)
+        vaapi_h264_init_picture(&RefPicList[n]);
+}
+
+static int vaapi_h264_start_frame(AVCodecContext *avctx, av_unused const uint8_t *buffer, av_unused uint32_t size)
+{
+    H264Context * const h = avctx->priv_data;
+    MpegEncContext * const s = &h->s;
+    struct vaapi_context * const vactx = avctx->hwaccel_context;
+    VAPictureParameterBufferH264 *pic_param;
+    VAIQMatrixBufferH264 *iq_matrix;
+
+    dprintf(avctx, "vaapi_h264_start_frame()\n");
+
+    vactx->slice_param_size = sizeof(VASliceParameterBufferH264);
+
+    /* Fill in VAPictureParameterBufferH264 */
+    pic_param = ff_vaapi_alloc_picture(vactx, sizeof(VAPictureParameterBufferH264));
+    if (!pic_param)
+        return -1;
+    vaapi_h264_fill_picture(&pic_param->CurrPic, s->current_picture_ptr, s->picture_structure);
+    vaapi_h264_fill_ReferenceFrames(pic_param, h);
+    pic_param->picture_width_in_mbs_minus1                      = s->mb_width - 1;
+    pic_param->picture_height_in_mbs_minus1                     = s->mb_height - 1;
+    pic_param->bit_depth_luma_minus8                            = h->sps.bit_depth_luma   >= 8 ? h->sps.bit_depth_luma   - 8 : 0;
+    pic_param->bit_depth_chroma_minus8                          = h->sps.bit_depth_chroma >= 8 ? h->sps.bit_depth_chroma - 8 : 0;
+    pic_param->num_ref_frames                                   = h->sps.ref_frame_count;
+    pic_param->seq_fields.value                                 = 0; /* reset all bits */
+    pic_param->seq_fields.bits.chroma_format_idc                = h->sps.chroma_format_idc;
+    pic_param->seq_fields.bits.residual_colour_transform_flag   = h->sps.residual_color_transform_flag; /* XXX: only for 4:4:4 high profile? */
+    pic_param->seq_fields.bits.gaps_in_frame_num_value_allowed_flag = h->sps.gaps_in_frame_num_allowed_flag;
+    pic_param->seq_fields.bits.frame_mbs_only_flag              = h->sps.frame_mbs_only_flag;
+    pic_param->seq_fields.bits.mb_adaptive_frame_field_flag     = h->sps.mb_aff;
+    pic_param->seq_fields.bits.direct_8x8_inference_flag        = h->sps.direct_8x8_inference_flag;
+    pic_param->seq_fields.bits.MinLumaBiPredSize8x8             = h->sps.level_idc >= 31; /* A.3.3.2 */
+    pic_param->seq_fields.bits.log2_max_frame_num_minus4        = h->sps.log2_max_frame_num - 4;
+    pic_param->seq_fields.bits.pic_order_cnt_type               = h->sps.poc_type;
+    pic_param->seq_fields.bits.log2_max_pic_order_cnt_lsb_minus4 = h->sps.log2_max_poc_lsb - 4;
+    pic_param->seq_fields.bits.delta_pic_order_always_zero_flag = h->sps.delta_pic_order_always_zero_flag;
+    pic_param->num_slice_groups_minus1                          = h->pps.slice_group_count - 1;
+    pic_param->slice_group_map_type                             = h->pps.mb_slice_group_map_type;
+    pic_param->slice_group_change_rate_minus1                   = 0; /* XXX: unimplemented in FFmpeg */
+    pic_param->pic_init_qp_minus26                              = h->pps.init_qp - 26;
+    pic_param->pic_init_qs_minus26                              = h->pps.init_qs - 26;
+    pic_param->chroma_qp_index_offset                           = h->pps.chroma_qp_index_offset[0];
+    pic_param->second_chroma_qp_index_offset                    = h->pps.chroma_qp_index_offset[1];
+    pic_param->pic_fields.value                                 = 0; /* reset all bits */
+    pic_param->pic_fields.bits.entropy_coding_mode_flag         = h->pps.cabac;
+    pic_param->pic_fields.bits.weighted_pred_flag               = h->pps.weighted_pred;
+    pic_param->pic_fields.bits.weighted_bipred_idc              = h->pps.weighted_bipred_idc;
+    pic_param->pic_fields.bits.transform_8x8_mode_flag          = h->pps.transform_8x8_mode;
+    pic_param->pic_fields.bits.field_pic_flag                   = h->s.picture_structure != PICT_FRAME;
+    pic_param->pic_fields.bits.constrained_intra_pred_flag      = h->pps.constrained_intra_pred;
+    pic_param->pic_fields.bits.pic_order_present_flag           = h->pps.pic_order_present;
+    pic_param->pic_fields.bits.deblocking_filter_control_present_flag = h->pps.deblocking_filter_parameters_present;
+    pic_param->pic_fields.bits.redundant_pic_cnt_present_flag   = h->pps.redundant_pic_cnt_present;
+    pic_param->pic_fields.bits.reference_pic_flag               = h->nal_ref_idc != 0;
+    pic_param->frame_num                                        = h->frame_num;
+
+    /* Fill in VAIQMatrixBufferH264 */
+    iq_matrix = ff_vaapi_alloc_iq_matrix(vactx, sizeof(VAIQMatrixBufferH264));
+    if (!iq_matrix)
+        return -1;
+    memcpy(iq_matrix->ScalingList4x4, h->pps.scaling_matrix4, sizeof(iq_matrix->ScalingList4x4));
+    memcpy(iq_matrix->ScalingList8x8, h->pps.scaling_matrix8, sizeof(iq_matrix->ScalingList8x8));
+    return 0;
+}
+
+static int vaapi_h264_end_frame(AVCodecContext *avctx)
+{
+    H264Context * const h = avctx->priv_data;
+
+    dprintf(avctx, "vaapi_h264_end_frame()\n");
+
+    return ff_vaapi_common_end_frame(&h->s);
+}
+
+static int vaapi_h264_decode_slice(AVCodecContext *avctx, const uint8_t *buffer, uint32_t size)
+{
+    H264Context * const h = avctx->priv_data;
+    MpegEncContext * const s = &h->s;
+    VASliceParameterBufferH264 *slice_param;
+    unsigned int i, j, l;
+
+    dprintf(avctx, "vaapi_h264_decode_slice(): buffer %p, size %d\n", buffer, size);
+
+    /* Fill in VASliceParameterBufferH264 */
+    slice_param = (VASliceParameterBufferH264 *)ff_vaapi_alloc_slice(avctx->hwaccel_context, buffer, size);
+    if (!slice_param)
+        return -1;
+    slice_param->slice_data_bit_offset          = get_bits_count(&h->s.gb) + 8; /* bit buffer started beyond nal_unit_type */
+    slice_param->first_mb_in_slice              = (s->mb_y >> FIELD_OR_MBAFF_PICTURE) * s->mb_width + s->mb_x;
+    slice_param->slice_type                     = h264_get_slice_type(h);
+    slice_param->direct_spatial_mv_pred_flag    = h->slice_type == FF_B_TYPE ? h->direct_spatial_mv_pred : 0;
+    slice_param->num_ref_idx_l0_active_minus1   = h->ref_count[0] - 1;
+    slice_param->num_ref_idx_l1_active_minus1   = h->ref_count[1] - 1;
+    slice_param->cabac_init_idc                 = h->cabac_init_idc;
+    slice_param->slice_qp_delta                 = s->qscale - h->pps.init_qp;
+    slice_param->disable_deblocking_filter_idc  = h->deblocking_filter < 2 ? !h->deblocking_filter : h->deblocking_filter;
+    slice_param->slice_alpha_c0_offset_div2     = h->slice_alpha_c0_offset / 2;
+    slice_param->slice_beta_offset_div2         = h->slice_beta_offset / 2;
+    vaapi_h264_fill_RefPicList(slice_param->RefPicList0, h->ref_list[0], h->list_count > 0 ? h->ref_count[0] : 0);
+    vaapi_h264_fill_RefPicList(slice_param->RefPicList1, h->ref_list[1], h->list_count > 1 ? h->ref_count[1] : 0);
+    slice_param->luma_log2_weight_denom         = h->luma_log2_weight_denom;
+    slice_param->chroma_log2_weight_denom       = h->chroma_log2_weight_denom;
+
+    for (l = 0; l < 2; l++) {
+        typedef short (*chroma_table_t)[32][2];
+        unsigned char *p_luma_weight_flag;
+        unsigned char *p_chroma_weight_flag;
+        short *p_luma_weight;
+        short *p_luma_offset;
+        chroma_table_t p_chroma_weight;
+        chroma_table_t p_chroma_offset;
+        const int luma_def = 1 << h->luma_log2_weight_denom;
+        const int chroma_def = 1 << h->chroma_log2_weight_denom;
+
+        if (l == 0) {
+            p_luma_weight_flag   = &slice_param->luma_weight_l0_flag;
+            p_luma_weight        = slice_param->luma_weight_l0;
+            p_luma_offset        = slice_param->luma_offset_l0;
+            p_chroma_weight_flag = &slice_param->chroma_weight_l0_flag;
+            p_chroma_weight      = &slice_param->chroma_weight_l0;
+            p_chroma_offset      = &slice_param->chroma_offset_l0;
+        }
+        else {
+            p_luma_weight_flag   = &slice_param->luma_weight_l1_flag;
+            p_luma_weight        = slice_param->luma_weight_l1;
+            p_luma_offset        = slice_param->luma_offset_l1;
+            p_chroma_weight_flag = &slice_param->chroma_weight_l1_flag;
+            p_chroma_weight      = &slice_param->chroma_weight_l1;
+            p_chroma_offset      = &slice_param->chroma_offset_l1;
+        }
+
+        *p_luma_weight_flag = h->luma_weight_flag[l];
+        *p_chroma_weight_flag = h->chroma_weight_flag[l];
+        for (i = 0; i < h->ref_count[l]; i++) {
+            /* VA API also wants the inferred (default) values, not
+               only what is available in the bitstream (7.4.3.2) */
+            if (h->luma_weight_flag[l]) {
+                p_luma_weight[i] = h->luma_weight[l][i];
+                p_luma_offset[i] = h->luma_offset[l][i];
+            }
+            else {
+                p_luma_weight[i] = luma_def;
+                p_luma_offset[i] = 0;
+            }
+            for (j = 0; j < 2; j++) {
+                if (h->chroma_weight_flag[l]) {
+                    (*p_chroma_weight)[i][j] = h->chroma_weight[l][i][j];
+                    (*p_chroma_offset)[i][j] = h->chroma_offset[l][i][j];
+                }
+                else {
+                    (*p_chroma_weight)[i][j] = chroma_def;
+                    (*p_chroma_offset)[i][j] = 0;
+                }
+            }
+        }
+    }
+    return 0;
+}
+
+AVHWAccel h264_vaapi_hwaccel = {
+    .name           = "h264_vaapi",
+    .type           = CODEC_TYPE_VIDEO,
+    .id             = CODEC_ID_H264,
+    .pix_fmt        = PIX_FMT_VAAPI_VLD,
+    .capabilities   = 0,
+    .start_frame    = vaapi_h264_start_frame,
+    .end_frame      = vaapi_h264_end_frame,
+    .decode_slice   = vaapi_h264_decode_slice,
+    .priv_data_size = 0,
+};
diff -ruN ffmpeg/Makefile ffmpeg.3/Makefile
--- ffmpeg/Makefile	2009-03-30 16:44:45.000000000 +0400
+++ ffmpeg.3/Makefile	2009-04-25 19:15:33.000000000 +0400
@@ -64,8 +64,8 @@
 ffplay_g$(EXESUF): FF_EXTRALIBS += $(SDL_LIBS)
 ffserver_g$(EXESUF): FF_LDFLAGS += $(FFSERVERLDFLAGS)
 
-%_g$(EXESUF): %.o cmdutils.o $(FF_DEP_LIBS)
-	$(CC) $(FF_LDFLAGS) -o $@ $< cmdutils.o $(FF_EXTRALIBS)
+%_g$(EXESUF): %.o cmdutils.o VAAPI.o $(FF_DEP_LIBS)
+	$(CC) $(FF_LDFLAGS) -o $@ $< cmdutils.o VAAPI.o $(FF_EXTRALIBS)
 
 tools/%$(EXESUF): tools/%.c
 	$(CC) $(CFLAGS) $(FF_LDFLAGS) -o $@ $< $(FF_EXTRALIBS)
diff -ruN ffmpeg/VAAPI.c ffmpeg.3/VAAPI.c
--- ffmpeg/VAAPI.c	1970-01-01 03:00:00.000000000 +0300
+++ ffmpeg.3/VAAPI.c	2009-04-24 15:35:42.000000000 +0400
@@ -0,0 +1,930 @@
+/********************************************************************************************************
+ * This file contains VAAPI specific code. 								*
+ *													*
+ * In Xbmc we should make a class VAAPI and place it to VAAPI.cpp					*
+ * (See xbmc/cores/dvdplayer/DVDCodecs/Video/VDPAU.cpp for example)					*
+ *													*
+ * Then we should correct 										*
+ * xbmc/cores/dvdplayer/DVDCodecs/Video/DVDVideoCodecFFmpeg.cpp 					*
+ * (See #ifdef HAVE_LIBVDPAU blocks for example)							*	
+ *													*
+ * The next step is to update xbmc's internal ffmpeg							*
+ * First patch ffmpeg sources in xbmc/cores/dvdplayer/Codecs/ffmpeg 					*						
+ * (If ffmpeg API changes then we should correct files here xbmc/cores/ffmpeg)				*
+ * Then compile xbmc											*
+ * And finally launch xbmc/cores/dvdplayer/Codecs/ffmpeg/build_xbmc.sh to 				*
+ * generate fresh *.so to dll loader									*
+ *													*	
+ * This was a short plan how to implement VAAPI support in XBMC						*
+ *													*
+ *													*
+ * Current problem is: after execution of 								*
+ * "len = m_dllAvCodec.avcodec_decode_video(m_pCodecContext, m_pFrame, &iGotPicture, pData, iSize);"	*
+ * (DVDVideoCodecFFmpeg.cpp:305) 									*
+ * in m_pFrame we get picture in PIX_FMT_VAAPI_VLD, which is not supported by 				*
+ * swscale and other parts of xbmc									*
+ *													*
+ * It is a "dirty" version. Looks like we can avoid casting to and from 				*
+ * imgfmt (taken from mplayer). There is still some (I think useful) variables 				*
+ * with fake values (like picture age, or surface nunber). Adittionally 				*
+ * maybe we should use existing mDisplay instead of initialize new instant.				*
+ *******************************************************************************************************/
+
+#include <stdio.h>
+#include <stdlib.h>
+#include <string.h>
+#include <errno.h>
+#include <assert.h>
+
+#include <va/va_x11.h>
+#include <X11/Xlib.h>
+
+#include "libavutil/common.h"
+#include "libavcodec/vaapi.h"
+#include "libavcodec/avcodec.h"
+#include "libavcodec/mpegvideo.h"
+
+
+
+
+/*** Defenition of image formats (taken from mplayer) */
+
+
+/* RGB/BGR Formats */
+#define IMGFMT_RGB_MASK 0xFFFFFF00
+#define IMGFMT_RGB (('R'<<24)|('G'<<16)|('B'<<8))
+#define IMGFMT_RGB1  (IMGFMT_RGB|1)
+#define IMGFMT_RGB4  (IMGFMT_RGB|4)
+#define IMGFMT_RGB4_CHAR  (IMGFMT_RGB|4|128) // RGB4 with 1 pixel per byte
+#define IMGFMT_RGB8  (IMGFMT_RGB|8)
+#define IMGFMT_RGB15 (IMGFMT_RGB|15)
+#define IMGFMT_RGB16 (IMGFMT_RGB|16)
+#define IMGFMT_RGB24 (IMGFMT_RGB|24)
+#define IMGFMT_RGB32 (IMGFMT_RGB|32)
+
+#define IMGFMT_BGR_MASK 0xFFFFFF00
+#define IMGFMT_BGR (('B'<<24)|('G'<<16)|('R'<<8))
+#define IMGFMT_BGR1 (IMGFMT_BGR|1)
+#define IMGFMT_BGR4 (IMGFMT_BGR|4)
+#define IMGFMT_BGR4_CHAR (IMGFMT_BGR|4|128) // BGR4 with 1 pixel per byte
+#define IMGFMT_BGR8 (IMGFMT_BGR|8)
+#define IMGFMT_BGR15 (IMGFMT_BGR|15)
+#define IMGFMT_BGR16 (IMGFMT_BGR|16)
+#define IMGFMT_BGR24 (IMGFMT_BGR|24)
+#define IMGFMT_BGR32 (IMGFMT_BGR|32)
+
+#ifdef WORDS_BIGENDIAN
+#define IMGFMT_ABGR IMGFMT_RGB32
+#define IMGFMT_BGRA (IMGFMT_RGB32|64)
+#define IMGFMT_ARGB IMGFMT_BGR32
+#define IMGFMT_RGBA (IMGFMT_BGR32|64)
+#else
+#define IMGFMT_ABGR (IMGFMT_BGR32|64)
+#define IMGFMT_BGRA IMGFMT_BGR32
+#define IMGFMT_ARGB (IMGFMT_RGB32|64)
+#define IMGFMT_RGBA IMGFMT_RGB32
+#endif
+
+/* old names for compatibility */
+#define IMGFMT_RG4B  IMGFMT_RGB4_CHAR
+#define IMGFMT_BG4B  IMGFMT_BGR4_CHAR
+
+#define IMGFMT_IS_RGB(fmt) (((fmt)&IMGFMT_RGB_MASK)==IMGFMT_RGB)
+#define IMGFMT_IS_BGR(fmt) (((fmt)&IMGFMT_BGR_MASK)==IMGFMT_BGR)
+
+#define IMGFMT_RGB_DEPTH(fmt) ((fmt)&0x3F)
+#define IMGFMT_BGR_DEPTH(fmt) ((fmt)&0x3F)
+
+
+/* Planar YUV Formats */
+
+#define IMGFMT_YVU9 0x39555659
+#define IMGFMT_IF09 0x39304649
+#define IMGFMT_YV12 0x32315659
+#define IMGFMT_I420 0x30323449
+#define IMGFMT_IYUV 0x56555949
+#define IMGFMT_CLPL 0x4C504C43
+#define IMGFMT_Y800 0x30303859
+#define IMGFMT_Y8   0x20203859
+#define IMGFMT_NV12 0x3231564E
+#define IMGFMT_NV21 0x3132564E
+
+/* unofficial Planar Formats, FIXME if official 4CC exists */
+#define IMGFMT_444P 0x50343434
+#define IMGFMT_422P 0x50323234
+#define IMGFMT_411P 0x50313134
+#define IMGFMT_HM12 0x32314D48
+
+/* Packed YUV Formats */
+
+#define IMGFMT_IUYV 0x56595549
+#define IMGFMT_IY41 0x31435949
+#define IMGFMT_IYU1 0x31555949
+#define IMGFMT_IYU2 0x32555949
+#define IMGFMT_UYVY 0x59565955
+#define IMGFMT_UYNV 0x564E5955
+#define IMGFMT_cyuv 0x76757963
+#define IMGFMT_Y422 0x32323459
+#define IMGFMT_YUY2 0x32595559
+#define IMGFMT_YUNV 0x564E5559
+#define IMGFMT_YVYU 0x55595659
+#define IMGFMT_Y41P 0x50313459
+#define IMGFMT_Y211 0x31313259
+#define IMGFMT_Y41T 0x54313459
+#define IMGFMT_Y42T 0x54323459
+#define IMGFMT_V422 0x32323456
+#define IMGFMT_V655 0x35353656
+#define IMGFMT_CLJR 0x524A4C43
+#define IMGFMT_YUVP 0x50565559
+#define IMGFMT_UYVP 0x50565955
+
+/* Compressed Formats */
+#define IMGFMT_MPEGPES (('M'<<24)|('P'<<16)|('E'<<8)|('S'))
+#define IMGFMT_MJPEG (('M')|('J'<<8)|('P'<<16)|('G'<<24))
+/* Formats that are understood by zoran chips, we include
+ * non-interlaced, interlaced top-first, interlaced bottom-first */
+#define IMGFMT_ZRMJPEGNI  (('Z'<<24)|('R'<<16)|('N'<<8)|('I'))
+#define IMGFMT_ZRMJPEGIT (('Z'<<24)|('R'<<16)|('I'<<8)|('T'))
+#define IMGFMT_ZRMJPEGIB (('Z'<<24)|('R'<<16)|('I'<<8)|('B'))
+
+// I think that this code could not be used by any other codec/format
+#define IMGFMT_XVMC 0x1DC70000
+#define IMGFMT_XVMC_MASK 0xFFFF0000
+#define IMGFMT_IS_XVMC(fmt) (((fmt)&IMGFMT_XVMC_MASK)==IMGFMT_XVMC)
+//these are chroma420
+#define IMGFMT_XVMC_MOCO_MPEG2 (IMGFMT_XVMC|0x02)
+#define IMGFMT_XVMC_IDCT_MPEG2 (IMGFMT_XVMC|0x82)
+
+/* VA API Formats */
+
+#define IMGFMT_VAAPI               0x56410000 /* 'VA'00 */
+#define IMGFMT_VAAPI_MASK          0xFFFF0000
+#define IMGFMT_IS_VAAPI(fmt)       (((fmt) & IMGFMT_VAAPI_MASK) == IMGFMT_VAAPI)
+#define IMGFMT_VAAPI_CODEC_MASK    0x000000F0
+#define IMGFMT_VAAPI_CODEC(fmt)    ((fmt) & IMGFMT_VAAPI_CODEC_MASK)
+#define IMGFMT_VAAPI_CODEC_MPEG2   (0x10)
+#define IMGFMT_VAAPI_CODEC_MPEG4   (0x20)
+#define IMGFMT_VAAPI_CODEC_H264    (0x30)
+#define IMGFMT_VAAPI_CODEC_VC1     (0x40)
+#define IMGFMT_VAAPI_MPEG2         (IMGFMT_VAAPI|IMGFMT_VAAPI_CODEC_MPEG2)
+#define IMGFMT_VAAPI_MPEG2_IDCT    (IMGFMT_VAAPI|IMGFMT_VAAPI_CODEC_MPEG2|1)
+#define IMGFMT_VAAPI_MPEG2_MOCO    (IMGFMT_VAAPI|IMGFMT_VAAPI_CODEC_MPEG2|2)
+#define IMGFMT_VAAPI_MPEG4         (IMGFMT_VAAPI|IMGFMT_VAAPI_CODEC_MPEG4)
+#define IMGFMT_VAAPI_H263          (IMGFMT_VAAPI|IMGFMT_VAAPI_CODEC_MPEG4|1)
+#define IMGFMT_VAAPI_H264          (IMGFMT_VAAPI|IMGFMT_VAAPI_CODEC_H264)
+#define IMGFMT_VAAPI_VC1           (IMGFMT_VAAPI|IMGFMT_VAAPI_CODEC_VC1)
+#define IMGFMT_VAAPI_WMV3          (IMGFMT_VAAPI|IMGFMT_VAAPI_CODEC_VC1|1)
+
+// VDPAU specific format.
+#define IMGFMT_VDPAU               0x1DC80000
+#define IMGFMT_VDPAU_MASK          0xFFFF0000
+#define IMGFMT_IS_VDPAU(fmt)       (((fmt)&IMGFMT_VDPAU_MASK)==IMGFMT_VDPAU)
+#define IMGFMT_VDPAU_MPEG1         (IMGFMT_VDPAU|0x01)
+#define IMGFMT_VDPAU_MPEG2         (IMGFMT_VDPAU|0x02)
+#define IMGFMT_VDPAU_H264          (IMGFMT_VDPAU|0x03)
+#define IMGFMT_VDPAU_WMV3          (IMGFMT_VDPAU|0x04)
+#define IMGFMT_VDPAU_VC1           (IMGFMT_VDPAU|0x05)
+
+
+
+
+/*** This section containing signficant variables and defenitions*/
+
+
+/* Numbers of video surfaces */
+#define NUM_VIDEO_SURFACES_MPEG2  3 /* 1 decode frame, up to 2 reference */
+#define NUM_VIDEO_SURFACES_MPEG4  3 /* 1 decode frame, up to 2 reference */
+#define NUM_VIDEO_SURFACES_H264  17 /* 1 decode frame, up to 16 references */
+#define NUM_VIDEO_SURFACES_VC1    3 /* 1 decode frame, up to 2 references */
+
+static uint32_t g_image_width;
+static uint32_t g_image_height;
+static uint32_t g_image_format;
+static uint32_t va_image_width;
+static uint32_t va_image_height;
+
+static struct vaapi_context *va_context;
+static VAProfile *va_profiles;
+static int va_num_profiles;
+static VAEntrypoint *va_entrypoints;
+static int va_num_entrypoints;
+static VASurfaceID *va_surface_ids;
+static int va_num_surfaces;
+static VAImageFormat *va_image_formats;
+static int va_num_image_formats;
+
+extern Display *mDisplay = NULL;
+
+#define DEBUG 1
+
+#if DEBUG
+#define VA_CHECK_STATUS(status) do {                                    \
+        if ((status) != VA_STATUS_SUCCESS) {                            \
+            av_log(NULL, AV_LOG_INFO, "vo_vaapi:(%s:%d): status (%d) != VA_STATUS_SUCCESS\n", \
+                   __FILE__, __LINE__, status);                         \
+            /*assert((status) == VA_STATUS_SUCCESS);*/                  \
+        }                                                               \
+    } while (0)
+#else
+#define VA_CHECK_STATUS(status)
+#endif
+
+
+
+
+/*** This section contains auxiliary functions in our future class */
+
+
+/* We define this functions later */
+static void FFReleaseBuffer(AVCodecContext *avctx, AVFrame *pic);
+static void FFDrawSlice(struct AVCodecContext *s,
+                                const AVFrame *src, int offset[4],
+				int y, int type, int height);
+static int FFGetBuffer(AVCodecContext *avctx, AVFrame *pic);
+
+
+/* fmt_conversation */
+static const struct {
+    int fmt;
+    enum PixelFormat pix_fmt;
+    enum CodecID codec_id;
+} conversion_map[] = {
+    {IMGFMT_BGR32, PIX_FMT_RGB32},
+    {IMGFMT_BGR24, PIX_FMT_BGR24},
+    {IMGFMT_BGR16, PIX_FMT_RGB565},
+    {IMGFMT_BGR8,  PIX_FMT_RGB8},
+    {IMGFMT_BGR4,  PIX_FMT_RGB4},
+    {IMGFMT_BGR1,  PIX_FMT_MONOBLACK},
+    {IMGFMT_RGB1,  PIX_FMT_MONOBLACK},
+    {IMGFMT_RG4B,  PIX_FMT_BGR4_BYTE},
+    {IMGFMT_BG4B,  PIX_FMT_RGB4_BYTE},
+    {IMGFMT_RGB32, PIX_FMT_BGR32},
+    {IMGFMT_RGB24, PIX_FMT_RGB24},
+    {IMGFMT_RGB16, PIX_FMT_BGR565},
+    {IMGFMT_RGB15, PIX_FMT_BGR555},
+    {IMGFMT_RGB8,  PIX_FMT_BGR8},
+    {IMGFMT_RGB4,  PIX_FMT_BGR4},
+    {IMGFMT_BGR8,  PIX_FMT_PAL8},
+    {IMGFMT_YUY2,  PIX_FMT_YUYV422},
+    {IMGFMT_UYVY,  PIX_FMT_UYVY422},
+    {IMGFMT_NV12,  PIX_FMT_NV12},
+    {IMGFMT_NV21,  PIX_FMT_NV21},
+    {IMGFMT_Y800,  PIX_FMT_GRAY8},
+    {IMGFMT_Y8,    PIX_FMT_GRAY8},
+    {IMGFMT_YVU9,  PIX_FMT_YUV410P},
+    {IMGFMT_IF09,  PIX_FMT_YUV410P},
+    {IMGFMT_YV12,  PIX_FMT_YUV420P},
+    {IMGFMT_I420,  PIX_FMT_YUV420P},
+    {IMGFMT_IYUV,  PIX_FMT_YUV420P},
+    {IMGFMT_411P,  PIX_FMT_YUV411P},
+    {IMGFMT_422P,  PIX_FMT_YUV422P},
+    {IMGFMT_444P,  PIX_FMT_YUV444P},
+
+    // YUVJ are YUV formats that use the full Y range and not just
+    // 16 - 235 (see colorspaces.txt).
+    // Currently they are all treated the same way.
+    {IMGFMT_YV12,  PIX_FMT_YUVJ420P},
+    {IMGFMT_422P,  PIX_FMT_YUVJ422P},
+    {IMGFMT_444P,  PIX_FMT_YUVJ444P},
+
+    {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},
+
+    /* VA API formats */
+    {IMGFMT_VAAPI_MPEG2,     PIX_FMT_VAAPI_VLD,  CODEC_ID_MPEG2VIDEO},
+    {IMGFMT_VAAPI_MPEG2_IDCT,PIX_FMT_VAAPI_IDCT, CODEC_ID_MPEG2VIDEO},
+    {IMGFMT_VAAPI_MPEG2_MOCO,PIX_FMT_VAAPI_MOCO, CODEC_ID_MPEG2VIDEO},
+    {IMGFMT_VAAPI_MPEG4,     PIX_FMT_VAAPI_VLD,  CODEC_ID_MPEG4},
+    {IMGFMT_VAAPI_H263,      PIX_FMT_VAAPI_VLD,  CODEC_ID_H263},
+    {IMGFMT_VAAPI_H264,      PIX_FMT_VAAPI_VLD,  CODEC_ID_H264},
+    {IMGFMT_VAAPI_WMV3,      PIX_FMT_VAAPI_VLD,  CODEC_ID_WMV3},
+    {IMGFMT_VAAPI_VC1,       PIX_FMT_VAAPI_VLD,  CODEC_ID_VC1},
+
+    {0, PIX_FMT_NONE}
+};
+
+
+enum PixelFormat imgfmt2pixfmt(int fmt)
+{
+    int i;
+    enum PixelFormat pix_fmt;
+    for (i = 0; conversion_map[i].fmt; i++)
+        if (conversion_map[i].fmt == fmt)
+            break;
+    pix_fmt = conversion_map[i].pix_fmt;
+    if (pix_fmt == PIX_FMT_NONE)
+        av_log(NULL, AV_LOG_INFO,  "YEG: Unsupported format %i\n", fmt);
+    return pix_fmt;
+}
+
+
+int pixfmt2imgfmt(enum PixelFormat pix_fmt, int codec_id)
+{
+    int i;
+    int fmt;
+    for (i = 0; conversion_map[i].pix_fmt != PIX_FMT_NONE; i++)
+        if (conversion_map[i].pix_fmt == pix_fmt &&
+            (conversion_map[i].codec_id == 0 ||
+             conversion_map[i].codec_id == codec_id))
+            break;
+    fmt = conversion_map[i].fmt;
+    if (!fmt)
+        av_log(NULL, AV_LOG_INFO, "YEG: Unsupported PixelFormat %i\n", pix_fmt);
+    return fmt;
+}
+
+
+/* Here functions for initialisation and configuration */
+
+static const char *string_of_VAImageFormat(VAImageFormat *imgfmt)
+{
+    static char str[5]; /* XXX: not MT-safe */
+    str[0] = imgfmt->fourcc;
+    str[1] = imgfmt->fourcc >> 8;
+    str[2] = imgfmt->fourcc >> 16;
+    str[3] = imgfmt->fourcc >> 24;
+    str[4] = '\0';
+    return str;
+}
+
+
+static const char *string_of_VAProfile(VAProfile profile)
+{
+    switch (profile) {
+#define PROFILE(profile) \
+        case VAProfile##profile: return "VAProfile" #profile
+        PROFILE(MPEG2Simple);
+        PROFILE(MPEG2Main);
+        PROFILE(MPEG4Simple);
+        PROFILE(MPEG4AdvancedSimple);
+        PROFILE(MPEG4Main);
+        PROFILE(H264Baseline);
+        PROFILE(H264Main);
+        PROFILE(H264High);
+        PROFILE(VC1Simple);
+        PROFILE(VC1Main);
+        PROFILE(VC1Advanced);
+#undef PROFILE
+    }
+    return "<unknown>";
+}
+
+
+static const char *string_of_VAEntrypoint(VAEntrypoint entrypoint)
+{
+    switch (entrypoint) {
+#define ENTRYPOINT(entrypoint) \
+        case VAEntrypoint##entrypoint: return "VAEntrypoint" #entrypoint
+        ENTRYPOINT(VLD);
+        ENTRYPOINT(IZZ);
+        ENTRYPOINT(IDCT);
+        ENTRYPOINT(MoComp);
+        ENTRYPOINT(Deblocking);
+#undef ENTRYPOINT
+    }
+    return "<unknown>";
+}
+
+
+static int has_profile(VAProfile profile)
+{
+    assert(va_profiles && va_num_profiles > 0);
+    for (int i = 0; i < va_num_profiles; i++) {
+        if (va_profiles[i] == profile)
+            return 1;
+    }
+    return 0;
+}
+
+
+static int VAProfile_from_imgfmt(uint32_t format)
+{
+    static const int mpeg2_profiles[] =
+        { VAProfileMPEG2Main, VAProfileMPEG2Simple, -1 };
+    static const int mpeg4_profiles[] =
+        { VAProfileMPEG4Main, VAProfileMPEG4AdvancedSimple, VAProfileMPEG4Simple, -1 };
+    static const int h264_profiles[] =
+        { VAProfileH264High, VAProfileH264Main, VAProfileH264Baseline, -1 };
+    static const int wmv3_profiles[] =
+        { VAProfileVC1Main, VAProfileVC1Simple, -1 };
+    static const int vc1_profiles[] =
+        { VAProfileVC1Advanced, -1 };
+
+    const int *profiles = NULL;
+    switch (IMGFMT_VAAPI_CODEC(format)) {
+    case IMGFMT_VAAPI_CODEC_MPEG2:
+        profiles = mpeg2_profiles;
+        break;
+    case IMGFMT_VAAPI_CODEC_MPEG4:
+        profiles = mpeg4_profiles;
+        break;
+    case IMGFMT_VAAPI_CODEC_H264:
+        profiles = h264_profiles;
+        break;
+    case IMGFMT_VAAPI_CODEC_VC1:
+        switch (format) {
+        case IMGFMT_VAAPI_WMV3:
+            profiles = wmv3_profiles;
+            break;
+        case IMGFMT_VAAPI_VC1:
+            profiles = vc1_profiles;
+            break;
+        }
+        break;
+    }
+
+    if (profiles) {
+        for (int i = 0; profiles[i] != -1; i++) {
+            if (has_profile(profiles[i]))
+                return profiles[i];
+        }
+    }
+    return -1;
+}
+
+
+static int has_entrypoint(VAEntrypoint entrypoint)
+{
+    assert(va_entrypoints && va_num_entrypoints > 0);
+    for (int i = 0; i < va_num_entrypoints; i++) {
+        if (va_entrypoints[i] == entrypoint)
+            return 1;
+    }
+    return 0;
+}
+
+
+static int VAEntrypoint_from_imgfmt(uint32_t format)
+{
+    int entrypoint = 0;
+    switch (format) {
+    case IMGFMT_VAAPI_MPEG2:
+    case IMGFMT_VAAPI_MPEG4:
+    case IMGFMT_VAAPI_H263:
+    case IMGFMT_VAAPI_H264:
+    case IMGFMT_VAAPI_WMV3:
+    case IMGFMT_VAAPI_VC1:
+        entrypoint = VAEntrypointVLD;
+        break;
+    case IMGFMT_VAAPI_MPEG2_IDCT:
+        entrypoint = VAEntrypointIDCT;
+        break;
+    case IMGFMT_VAAPI_MPEG2_MOCO:
+        entrypoint = VAEntrypointMoComp;
+        break;
+    }
+
+    if (entrypoint)
+        return has_entrypoint(entrypoint);
+
+    return -1;
+}
+
+
+static int init_entrypoints(VAProfile profile)
+{
+    VAStatus status;
+    int i, max_entrypoints;
+
+    if (va_entrypoints && va_num_entrypoints > 0)
+        return 0;
+
+    if (va_entrypoints)
+        av_free(va_entrypoints);
+
+    max_entrypoints = vaMaxNumEntrypoints(va_context->display);
+    va_entrypoints = calloc(max_entrypoints, sizeof(*va_entrypoints));
+    if (va_entrypoints == NULL)
+        return -1;
+
+    status = vaQueryConfigEntrypoints(va_context->display, profile,
+                                      va_entrypoints, &va_num_entrypoints);
+    VA_CHECK_STATUS(status);
+    if (status != VA_STATUS_SUCCESS)
+        return -1;
+
+    av_log(NULL, AV_LOG_INFO, "YEG:init_entrypoints(%s): %d entrypoints available\n",
+           string_of_VAProfile(profile), va_num_entrypoints);
+    for (i = 0; i < va_num_entrypoints; i++)
+        av_log(NULL, AV_LOG_INFO, " %s\n", string_of_VAEntrypoint(va_entrypoints[i]));
+    return 0;
+}
+
+
+static void free_video_specific(void)
+{
+    if (va_context && va_context->context_id) {
+        vaDestroyContext(va_context->display, va_context->context_id);
+        va_context->context_id = 0;
+    }
+
+    if (va_surface_ids) {
+        vaDestroySurfaces(va_context->display, va_surface_ids, va_num_surfaces);
+        av_free(va_surface_ids);
+        va_surface_ids = NULL;
+    }
+
+    if (va_context && va_context->config_id) {
+        vaDestroyConfig(va_context->display, va_context->config_id);
+        va_context->config_id = 0;
+    }
+}
+
+
+static int ConfigVAAPI(uint32_t width, uint32_t height, uint32_t format)
+{
+    VAConfigAttrib attrib;
+    VAStatus status;
+    int profile, entrypoint;
+
+    av_log(NULL, AV_LOG_INFO, "YEG:ConfigVAAPI(): size %dx%d, format %x\n", width, height, format);
+
+    /* Check we have not already called ConfigVAAPI() before */
+    if (g_image_format == format &&
+        g_image_width == width &&
+        va_num_surfaces &&
+        va_context->config_id > 0 &&
+        va_context->context_id > 0) {
+        av_log(NULL, AV_LOG_INFO, "YEG:ConfigVAAPI(): check why we are reconfiguring again VAAPI!\n");
+        return 0;
+    }
+
+    /* Check format -- query_format() should have checked that for us */
+    if (!IMGFMT_IS_VAAPI(format)) {
+        assert(IMGFMT_IS_VAAPI(format));
+        return 1;
+    }
+
+    /* Check profile -- query_format() should have checked that for us */
+    profile = VAProfile_from_imgfmt(format);
+    if (profile < 0) {
+        assert(profile >= 0);
+        return 1;
+    }
+
+    /* Check entry-point -- query_format() should have checked that for us */
+    init_entrypoints(profile);
+    entrypoint = VAEntrypoint_from_imgfmt(format);
+    if (entrypoint < 0) {
+        assert(entrypoint >= 0);
+        return 1;
+    }
+
+    /* Check chroma format -- query_format() should have checked that for us */
+    attrib.type = VAConfigAttribRTFormat;
+    status = vaGetConfigAttributes(va_context->display, profile, entrypoint, &attrib, 1);
+    VA_CHECK_STATUS(status);
+    if (status != VA_STATUS_SUCCESS)
+        return 1;
+    if ((attrib.value & VA_RT_FORMAT_YUV420) == 0) {
+        assert((attrib.value & VA_RT_FORMAT_YUV420) != 0);
+        return 1;
+    }
+
+    free_video_specific();
+
+    /* Create a configuration for the decode pipeline */
+    status = vaCreateConfig(va_context->display, profile, entrypoint, &attrib, 1, &va_context->config_id);
+    VA_CHECK_STATUS(status);
+    if (status != VA_STATUS_SUCCESS)
+        return 1;
+
+    /* Create video surfaces */
+    switch (IMGFMT_VAAPI_CODEC(format)) {
+    case IMGFMT_VAAPI_CODEC_MPEG2:
+        va_num_surfaces = NUM_VIDEO_SURFACES_MPEG2;
+        break;
+    case IMGFMT_VAAPI_CODEC_MPEG4:
+        va_num_surfaces = NUM_VIDEO_SURFACES_MPEG4;
+        break;
+    case IMGFMT_VAAPI_CODEC_H264:
+        va_num_surfaces = NUM_VIDEO_SURFACES_H264;
+        break;
+    case IMGFMT_VAAPI_CODEC_VC1:
+        va_num_surfaces = NUM_VIDEO_SURFACES_VC1;
+        break;
+    default:
+        assert(0);
+        return 1;
+    }
+    va_surface_ids = calloc(va_num_surfaces, sizeof(*va_surface_ids));
+    if (va_surface_ids == NULL)
+        return 1;
+    status = vaCreateSurfaces(va_context->display, width, height, VA_RT_FORMAT_YUV420,
+                              va_num_surfaces, va_surface_ids);
+    VA_CHECK_STATUS(status);
+    if (status != VA_STATUS_SUCCESS)
+        return 1;
+
+    /* Create a context for the decode pipeline */
+    status = vaCreateContext(va_context->display, va_context->config_id,
+                             width, height, VA_PROGRESSIVE,
+                             va_surface_ids, va_num_surfaces,
+                             &va_context->context_id);
+    VA_CHECK_STATUS(status);
+    if (status != VA_STATUS_SUCCESS)
+        return 1;
+
+    g_image_width  = width;
+    g_image_height = height;
+    g_image_format = format;
+
+    return 0;
+}
+
+
+static int has_hw_codec(uint32_t format)
+{
+    VAConfigAttrib attrib;
+    VAStatus status;
+    int profile, entrypoint;
+
+    /* check for codec */
+    profile = VAProfile_from_imgfmt(format);
+    if (profile < 0)
+        return 0;
+
+    /* check for entry-point */
+    /* XXX: only VLD is supported at this time */
+    init_entrypoints(profile);
+    entrypoint = VAEntrypoint_from_imgfmt(format);
+    assert(entrypoint == VAEntrypointVLD);
+    if (entrypoint != VAEntrypointVLD)
+        return 0;
+
+    /* check chroma format (only 4:2:0 for now) */
+    attrib.type = VAConfigAttribRTFormat;
+    status = vaGetConfigAttributes(va_context->display, profile, entrypoint, &attrib, 1);
+    VA_CHECK_STATUS(status);
+    if (status != VA_STATUS_SUCCESS)
+        return 0;
+    if ((attrib.value & VA_RT_FORMAT_YUV420) == 0)
+        return 0;
+
+    av_log(NULL, AV_LOG_INFO, "YEG:has_hw_codec(): HW decoder available\n");
+    return 1;
+}
+
+
+static int query_format(uint32_t format)
+{
+    if (has_hw_codec(format))
+	return 1;
+    return 0;
+}
+
+/* We need this staff to get  right pix_format */
+
+
+void set_format_params(struct AVCodecContext *avctx, enum PixelFormat fmt){
+    int imgfmt;
+    imgfmt = pixfmt2imgfmt(fmt, avctx->codec_id);
+    if (IMGFMT_IS_XVMC(imgfmt) || IMGFMT_IS_VDPAU(imgfmt) || IMGFMT_IS_VAAPI(imgfmt)) {
+        avctx->thread_count    = 1;
+        avctx->get_buffer      = FFGetBuffer;
+        avctx->release_buffer  = FFReleaseBuffer;
+        avctx->reget_buffer    = FFGetBuffer;
+        avctx->draw_horiz_band = FFDrawSlice;
+        avctx->slice_flags = SLICE_FLAG_CODED_ORDER|SLICE_FLAG_ALLOW_FIELD;
+    }
+}
+
+
+static int query_format_1(AVCodecContext *avctx, int fmt)
+{
+    int  width, height, r ;
+    /* XXX: some codecs have not initialized width and height yet at
+ *        this point, so we are faking the dimensions so that init_vo()
+ *               doesn't fail because of 0x0 size */
+    if ((width = avctx->width) == 0)
+        avctx->width = 16;
+    if ((height = avctx->height) == 0)
+        avctx->height = 16;
+    set_format_params(avctx, fmt);
+    r = 0;
+    if (!ConfigVAAPI(avctx->width,avctx->height,pixfmt2imgfmt(fmt, avctx->codec_id)))
+            r = 1;
+    avctx->hwaccel_context = (void*) va_context;
+    avctx->width = width;
+    avctx->height = height;
+    return r;
+}
+
+
+static int FFGetBuffer(AVCodecContext *avctx, AVFrame *pic)
+{
+    int align=15;
+    int r;
+    int easi_number;
+
+    if(avctx->pix_fmt == PIX_FMT_YUV410P)
+        align=63; //yes seriously, its really needed (16x16 chroma blocks in SVQ1 -> 64x64)
+    
+    set_format_params(avctx, avctx->pix_fmt);
+/*
+    r = 0;
+    if (!ConfigVAAPI(avctx->width,avctx->height,pixfmt2imgfmt(avctx->pix_fmt, avctx->codec_id)))
+            r = -1;
+    avctx->hwaccel_context = (void*) va_context;
+
+    if(r < 0){
+        avctx->release_buffer= avcodec_default_release_buffer;
+        avctx->get_buffer= avcodec_default_get_buffer;
+        return avctx->get_buffer(avctx, pic);
+    }
+*/
+    avctx->draw_horiz_band= NULL;
+    
+    /*Not sure about surface number!*/
+    easi_number = 0;
+    pic->data[0] = pic->data[3] = (char *)(uintptr_t) va_surface_ids[easi_number];
+    pic->data[1] = pic->data[2] = NULL;
+    pic->linesize[0] = pic->linesize[1] = pic->linesize[2] = 0;
+
+    pic->type= FF_BUFFER_TYPE_USER;
+    /*Maybe age is a usefull variable*/
+    pic->age = 1;
+
+    return 0;
+}
+
+
+static void FFDrawSlice(struct AVCodecContext *s,
+                                const AVFrame *src, int offset[4],
+				int y, int type, int height)
+{ 
+    av_log(NULL, AV_LOG_INFO, "YEG: draw_slice: Nothing to do here\n");
+}
+
+
+static void FFReleaseBuffer(AVCodecContext *avctx, AVFrame *pic)
+{
+    int i;
+
+    if(pic->type!=FF_BUFFER_TYPE_USER){
+        avcodec_default_release_buffer(avctx, pic);
+        return;
+    }
+
+    for(i=0; i<4; i++){
+        pic->data[i]= NULL;
+    }
+}
+
+
+
+
+/*** This functions sould be in public section of our future class */
+
+
+int CVAAPI(int width, int height)
+{
+/* We can reduce this code by removing av_log */
+    VAStatus va_status;
+    int va_major_version, va_minor_version;
+    int i, max_image_formats, max_profiles;
+
+    va_image_width = width;
+    va_image_height = height;
+
+    /* Maybe we should use external display instead of making new one  */
+    mDisplay = XOpenDisplay(":0.0");
+
+    va_context = calloc(1, sizeof(*va_context));
+    if (va_context == NULL)
+        return -1;
+
+    va_context->display = vaGetDisplay(mDisplay);
+    if (va_context->display == NULL)
+        return -1;
+    av_log(NULL, AV_LOG_INFO, "YEG: VA display %p\n", va_context->display);
+
+    va_status = vaInitialize(va_context->display, &va_major_version, &va_minor_version);
+    VA_CHECK_STATUS(va_status);
+    if (va_status != VA_STATUS_SUCCESS)
+        return -1;
+    av_log(NULL, AV_LOG_INFO, "YEG: VA API version %d.%d\n",
+           va_major_version, va_minor_version);
+
+    max_image_formats = vaMaxNumImageFormats(va_context->display);
+    va_image_formats = calloc(max_image_formats, sizeof(*va_image_formats));
+    if (va_image_formats == NULL)
+        return -1;
+    va_status = vaQueryImageFormats(va_context->display, va_image_formats, &va_num_image_formats);
+    VA_CHECK_STATUS(va_status);
+    if (va_status != VA_STATUS_SUCCESS)
+        return -1;
+    av_log(NULL, AV_LOG_INFO, "YEG: %d image formats available\n",
+           va_num_image_formats);
+    for (i = 0; i < va_num_image_formats; i++)
+        av_log(NULL, AV_LOG_INFO, " %s\n", string_of_VAImageFormat(&va_image_formats[i]));
+
+    max_profiles = vaMaxNumProfiles(va_context->display);
+    va_profiles = calloc(max_profiles, sizeof(*va_profiles));
+    if (va_profiles == NULL)
+        return -1;
+    va_status = vaQueryConfigProfiles(va_context->display, va_profiles, &va_num_profiles);
+    VA_CHECK_STATUS(va_status);
+    if (va_status != VA_STATUS_SUCCESS)
+        return -1;
+    av_log(NULL, AV_LOG_INFO, "YEG: %d profiles available\n",
+           va_num_profiles);
+    for (i = 0; i < va_num_profiles; i++)
+        av_log(NULL, AV_LOG_INFO, " %s\n", string_of_VAProfile(va_profiles[i]));
+
+    return 0;
+}
+
+
+void uCVAAPI() //~CVAAPI
+{
+    free_video_specific();
+
+    if (va_entrypoints) {
+        av_free(va_entrypoints);
+        va_entrypoints = NULL;
+    }
+
+    if (va_profiles) {
+        av_free(va_profiles);
+        va_profiles = NULL;
+    }
+
+    if (va_context && va_context->display) {
+        vaTerminate(va_context->display);
+        va_context->display = NULL;
+    }
+
+    if (va_context) {
+        av_free(va_context);
+        va_context = NULL;
+    }
+}
+
+
+enum PixelFormat FFGetFormat(struct AVCodecContext * avctx, 
+				const enum PixelFormat * fmt)
+{
+    enum PixelFormat selected_format = PIX_FMT_NONE;
+    int imgfmt;
+    int i, try_hwaccel;
+
+    for (try_hwaccel = 1; try_hwaccel >= 0; --try_hwaccel) {
+        for (i = 0; fmt[i] != PIX_FMT_NONE; i++){
+            imgfmt = pixfmt2imgfmt(fmt[i], avctx->codec_id);
+            if ((try_hwaccel ^ IMGFMT_IS_VAAPI(imgfmt)) != 0)
+                continue;
+            if (query_format_1(avctx, fmt[i]) >= 0) {
+                selected_format = fmt[i];
+                break;
+            }
+        }
+        if (selected_format != PIX_FMT_NONE)
+            break;
+    }
+    set_format_params(avctx, selected_format);
+    return selected_format;
+}
+
+
+
+
+/*** This function is just a place where we can test our Format conversation and so on */
+
+void FFTestVAAPI(AVCodecContext *avctx, AVFrame *frame)
+{
+    Window wnd;
+    VAStatus status;
+    VAImage *va_image;
+    int r;
+
+   /*amount of objects without uninit */ 
+    av_log(NULL, AV_LOG_INFO, "YEG: Lets try to show smth\n");
+    wnd = XCreateSimpleWindow(mDisplay, DefaultRootWindow(mDisplay), 0, 0, 320, 240, 0, 0, 0);
+    r = XMapWindow(mDisplay, wnd);
+    status = vaSyncSurface(va_context->display, va_context->context_id, va_surface_ids[0]);
+    VA_CHECK_STATUS(status);
+    if (status != VA_STATUS_SUCCESS)
+        av_log(NULL, AV_LOG_INFO, "YEG: vaSyncSurface failed\n");
+	
+    va_image = calloc(1, sizeof(*va_image));
+    status = vaCreateImage(va_context->display, va_image_formats + 1, 320, 240, va_image);
+    VA_CHECK_STATUS(status);
+
+    status = vaGetImage(va_context->display, va_surface_ids[0], 0, 0, 320, 240, va_image->image_id);
+    VA_CHECK_STATUS(status);
+    if (status != VA_STATUS_SUCCESS)
+        av_log(NULL, AV_LOG_INFO, "YEG: vaDeriveImage failed\n");
+
+
+    status = vaPutSurface(va_context->display, va_surface_ids[0], wnd, 0, 0, 320, 240, 0, 0, 320, 240, NULL, 0, 0);
+    VA_CHECK_STATUS(status);
+    if (status != VA_STATUS_SUCCESS)
+        av_log(NULL, AV_LOG_INFO, "YEG: vaPutSurface failed\n");
+
+}
diff -ruN ffmpeg/VAAPI.h ffmpeg.3/VAAPI.h
--- ffmpeg/VAAPI.h	1970-01-01 03:00:00.000000000 +0300
+++ ffmpeg.3/VAAPI.h	2009-04-24 15:35:54.000000000 +0400
@@ -0,0 +1,17 @@
+/************************************************
+ * VAAPI specific code				*
+ *						*
+ * Here should be defenition of VAAPI class, 	*
+ * but currently we just define it's public 	*
+ * functions					*
+ ************************************************/
+
+int CVAAPI(int width, int height);
+
+void uCVAAPI(); //~CVAAPI
+
+enum PixelFormat FFGetFormat(struct AVCodecContext * avctx,
+                                const enum PixelFormat * pix_fmt);
+
+void FFTestVAAPI(AVCodecContext *avctx, AVFrame *frame);
+
