Commit 92c6a099 authored by Laurent Aimar's avatar Laurent Aimar

H264 DXVA2 implementation

 It allows VLD H264 decoding using DXVA2 (GPU assisted decoding API under
VISTA and Windows 7).
 It is implemented by using AVHWAccel API. It has been tested successfully
for some time in VLC using an nvidia card on Windows 7.

 To compile it, you need to have the system header dxva2api.h (either from
microsoft or using http://downloads.videolan.org/pub/videolan/testing/contrib/dxva2api.h)
 The generated libavcodec.dll does not depend directly on any new lib as
the necessary objects are given by the application using FFmpeg.

Originally committed as revision 21353 to svn://svn.ffmpeg.org/ffmpeg/trunk
parent 3d7b42f9
...@@ -107,6 +107,7 @@ Configuration options: ...@@ -107,6 +107,7 @@ Configuration options:
--disable-rdft disable RDFT code --disable-rdft disable RDFT code
--disable-vaapi disable VAAPI code --disable-vaapi disable VAAPI code
--disable-vdpau disable VDPAU code --disable-vdpau disable VDPAU code
--disable-dxva2 disable DXVA2 code
--enable-runtime-cpudetect detect cpu capabilities at runtime (bigger binary) --enable-runtime-cpudetect detect cpu capabilities at runtime (bigger binary)
--enable-hardcoded-tables use hardcoded tables instead of runtime generation --enable-hardcoded-tables use hardcoded tables instead of runtime generation
--enable-memalign-hack emulate memalign, interferes with memory debuggers --enable-memalign-hack emulate memalign, interferes with memory debuggers
...@@ -865,6 +866,7 @@ CONFIG_LIST=" ...@@ -865,6 +866,7 @@ CONFIG_LIST="
bzlib bzlib
dct dct
doc doc
dxva2
fastdiv fastdiv
ffmpeg ffmpeg
ffplay ffplay
...@@ -1174,6 +1176,8 @@ h263_vaapi_hwaccel_select="vaapi h263_decoder" ...@@ -1174,6 +1176,8 @@ h263_vaapi_hwaccel_select="vaapi h263_decoder"
h263i_decoder_select="h263_decoder" h263i_decoder_select="h263_decoder"
h263p_encoder_select="h263_encoder" h263p_encoder_select="h263_encoder"
h264_decoder_select="golomb" h264_decoder_select="golomb"
h264_dxva2_hwaccel_deps="dxva2api_h"
h264_dxva2_hwaccel_select="dxva2 h264_decoder"
h264_vaapi_hwaccel_deps="va_va_h" h264_vaapi_hwaccel_deps="va_va_h"
h264_vaapi_hwaccel_select="vaapi" h264_vaapi_hwaccel_select="vaapi"
h264_vdpau_decoder_deps="vdpau_vdpau_h vdpau_vdpau_x11_h" h264_vdpau_decoder_deps="vdpau_vdpau_h vdpau_vdpau_x11_h"
...@@ -2399,6 +2403,7 @@ check_func_headers windows.h VirtualAlloc ...@@ -2399,6 +2403,7 @@ check_func_headers windows.h VirtualAlloc
check_header conio.h check_header conio.h
check_header dlfcn.h check_header dlfcn.h
check_header dxva2api.h
check_header malloc.h check_header malloc.h
check_header poll.h check_header poll.h
check_header sys/mman.h check_header sys/mman.h
......
...@@ -3,7 +3,7 @@ include $(SUBDIR)../config.mak ...@@ -3,7 +3,7 @@ include $(SUBDIR)../config.mak
NAME = avcodec NAME = avcodec
FFLIBS = avutil FFLIBS = avutil
HEADERS = avcodec.h opt.h vaapi.h vdpau.h xvmc.h HEADERS = avcodec.h dxva2.h opt.h vaapi.h vdpau.h xvmc.h
OBJS = allcodecs.o \ OBJS = allcodecs.o \
audioconvert.o \ audioconvert.o \
...@@ -135,6 +135,7 @@ OBJS-$(CONFIG_H263_ENCODER) += mpegvideo_enc.o mpeg4video.o mpeg4vide ...@@ -135,6 +135,7 @@ OBJS-$(CONFIG_H263_ENCODER) += mpegvideo_enc.o mpeg4video.o mpeg4vide
OBJS-$(CONFIG_H264_DECODER) += h264.o h264idct.o h264pred.o h264_loopfilter.o h264_direct.o cabac.o \ OBJS-$(CONFIG_H264_DECODER) += h264.o h264idct.o h264pred.o h264_loopfilter.o h264_direct.o cabac.o \
h264_sei.o h264_ps.o h264_refs.o h264_cavlc.o h264_cabac.o\ h264_sei.o h264_ps.o h264_refs.o h264_cavlc.o h264_cabac.o\
mpegvideo.o error_resilience.o mpegvideo.o error_resilience.o
OBJS-$(CONFIG_H264_DXVA2_HWACCEL) += dxva2_h264.o
OBJS-$(CONFIG_H264_ENCODER) += h264enc.o h264dspenc.o OBJS-$(CONFIG_H264_ENCODER) += h264enc.o h264dspenc.o
OBJS-$(CONFIG_H264_VAAPI_HWACCEL) += vaapi_h264.o OBJS-$(CONFIG_H264_VAAPI_HWACCEL) += vaapi_h264.o
OBJS-$(CONFIG_HUFFYUV_DECODER) += huffyuv.o OBJS-$(CONFIG_HUFFYUV_DECODER) += huffyuv.o
......
...@@ -55,6 +55,7 @@ void avcodec_register_all(void) ...@@ -55,6 +55,7 @@ void avcodec_register_all(void)
/* hardware accelerators */ /* hardware accelerators */
REGISTER_HWACCEL (H263_VAAPI, h263_vaapi); REGISTER_HWACCEL (H263_VAAPI, h263_vaapi);
REGISTER_HWACCEL (H264_DXVA2, h264_dxva2);
REGISTER_HWACCEL (H264_VAAPI, h264_vaapi); REGISTER_HWACCEL (H264_VAAPI, h264_vaapi);
REGISTER_HWACCEL (MPEG2_VAAPI, mpeg2_vaapi); REGISTER_HWACCEL (MPEG2_VAAPI, mpeg2_vaapi);
REGISTER_HWACCEL (MPEG4_VAAPI, mpeg4_vaapi); REGISTER_HWACCEL (MPEG4_VAAPI, mpeg4_vaapi);
......
/*
* DXVA2 HW acceleration
*
* copyright (c) 2009 Laurent Aimar
*
* 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
*/
#ifndef AVCODEC_DXVA_H
#define AVCODEC_DXVA_H
#include <stdint.h>
#include <dxva2api.h>
/**
* This structure is used to provides the necessary configurations and data
* to the DXVA2 FFmpeg HWAccel implementation.
*
* The application must make it available as AVCodecContext.hwaccel_context.
*/
struct dxva_context {
/**
* DXVA2 decoder object
*/
IDirectXVideoDecoder *decoder;
/**
* DXVA2 configuration used to create the decoder
*/
const DXVA2_ConfigPictureDecode *cfg;
/**
* The number of surface in the surface array
*/
unsigned surface_count;
/**
* The array of Direct3D surfaces used to create the decoder
*/
LPDIRECT3DSURFACE9 *surface;
/**
* A bit field configuring the workarounds needed for using the decoder
*/
uint64_t workaround;
/**
* Private to the FFmpeg AVHWAccel implementation
*/
unsigned report_id;
};
#endif /* AVCODEC_DXVA_H */
This diff is collapsed.
...@@ -81,6 +81,7 @@ const enum PixelFormat ff_pixfmt_list_420[] = { ...@@ -81,6 +81,7 @@ const enum PixelFormat ff_pixfmt_list_420[] = {
}; };
const enum PixelFormat ff_hwaccel_pixfmt_list_420[] = { const enum PixelFormat ff_hwaccel_pixfmt_list_420[] = {
PIX_FMT_DXVA2_VLD,
PIX_FMT_VAAPI_VLD, PIX_FMT_VAAPI_VLD,
PIX_FMT_YUV420P, PIX_FMT_YUV420P,
PIX_FMT_NONE PIX_FMT_NONE
......
...@@ -646,6 +646,12 @@ const AVPixFmtDescriptor av_pix_fmt_descriptors[PIX_FMT_NB] = { ...@@ -646,6 +646,12 @@ const AVPixFmtDescriptor av_pix_fmt_descriptors[PIX_FMT_NB] = {
}, },
.flags = PIX_FMT_BE, .flags = PIX_FMT_BE,
}, },
[PIX_FMT_DXVA2_VLD] = {
.name = "dxva2_vld",
.log2_chroma_w = 1,
.log2_chroma_h = 1,
.flags = PIX_FMT_HWACCEL,
},
}; };
int av_get_bits_per_pixel(const AVPixFmtDescriptor *pixdesc) int av_get_bits_per_pixel(const AVPixFmtDescriptor *pixdesc)
......
...@@ -126,6 +126,7 @@ enum PixelFormat { ...@@ -126,6 +126,7 @@ enum PixelFormat {
PIX_FMT_YUV444P16LE, ///< planar YUV 4:4:4, 48bpp, (1 Cr & Cb sample per 1x1 Y samples), little-endian PIX_FMT_YUV444P16LE, ///< planar YUV 4:4:4, 48bpp, (1 Cr & Cb sample per 1x1 Y samples), little-endian
PIX_FMT_YUV444P16BE, ///< planar YUV 4:4:4, 48bpp, (1 Cr & Cb sample per 1x1 Y samples), big-endian 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_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_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 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
}; };
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment