Skip to content

Commit

Permalink
ffmpeg: add xvba hwaccel
Browse files Browse the repository at this point in the history
  • Loading branch information
FernetMenta committed Mar 26, 2012
1 parent 6c0d14e commit b0ec419
Show file tree
Hide file tree
Showing 14 changed files with 616 additions and 2 deletions.
8 changes: 8 additions & 0 deletions lib/ffmpeg/configure
Expand Up @@ -111,6 +111,7 @@ Configuration options:
--disable-vaapi disable VAAPI code
--disable-vdpau disable VDPAU code
--disable-dxva2 disable DXVA2 code
--disable-xvba disable XVBA code
--enable-runtime-cpudetect detect cpu capabilities at runtime (bigger binary)
--enable-hardcoded-tables use hardcoded tables instead of runtime generation
--enable-memalign-hack emulate memalign, interferes with memory debuggers
Expand Down Expand Up @@ -932,6 +933,7 @@ CONFIG_LIST="
swscale_alpha
vaapi
vdpau
xvba
version3
x11grab
zlib
Expand Down Expand Up @@ -1240,6 +1242,7 @@ h264_decoder_select="golomb h264dsp h264pred"
h264_dxva2_hwaccel_deps="dxva2api_h"
h264_dxva2_hwaccel_select="dxva2 h264_decoder"
h264_vaapi_hwaccel_select="vaapi"
h264_xvba_hwaccel_select="xvba"
h264_vdpau_decoder_select="vdpau h264_decoder"
imc_decoder_select="fft mdct"
jpegls_decoder_select="golomb"
Expand All @@ -1263,6 +1266,7 @@ mpeg2_dxva2_hwaccel_deps="dxva2api_h"
mpeg2_dxva2_hwaccel_select="dxva2 mpeg2video_decoder"
mpeg2_vaapi_hwaccel_select="vaapi mpeg2video_decoder"
mpeg4_vaapi_hwaccel_select="vaapi mpeg4_decoder"
mpeg2_xvba_hwaccel_select="xvba mpeg2video_decoder"
mpeg4_vdpau_decoder_deps="vdpau_vdpau_h vdpau_vdpau_x11_h vdpau_mpeg4_support"
mpeg4_vdpau_decoder_select="vdpau mpeg4_decoder"
mpeg_xvmc_decoder_deps="X11_extensions_XvMClib_h"
Expand Down Expand Up @@ -1306,6 +1310,7 @@ vc1_decoder_select="h263_decoder"
vc1_dxva2_hwaccel_deps="dxva2api_h DXVA_PictureParameters_wDecodedPictureIndex"
vc1_dxva2_hwaccel_select="dxva2 vc1_decoder"
vc1_vaapi_hwaccel_select="vaapi vc1_decoder"
vc1_xvba_hwaccel_select="xvba vc1_decoder"
vc1_vdpau_decoder_select="vdpau vc1_decoder"
vorbis_decoder_select="mdct"
vorbis_encoder_select="mdct"
Expand All @@ -1327,12 +1332,14 @@ wmv3_decoder_select="vc1_decoder"
wmv3_dxva2_hwaccel_select="vc1_dxva2_hwaccel"
wmv3_vaapi_hwaccel_select="vc1_vaapi_hwaccel"
wmv3_vdpau_decoder_select="vc1_vdpau_decoder"
wmv3_xvba_hwaccel_select="vc1_xvba_hwaccel"
zlib_decoder_select="zlib"
zlib_encoder_select="zlib"
zmbv_decoder_select="zlib"
zmbv_encoder_select="zlib"

vaapi_deps="va_va_h"
xvba_deps="amd_amdxvba_h"
vdpau_deps="vdpau_vdpau_h vdpau_vdpau_x11_h"

# parsers
Expand Down Expand Up @@ -2762,6 +2769,7 @@ check_header sys/select.h
check_header termios.h
check_header vdpau/vdpau.h
check_header vdpau/vdpau_x11.h
check_header amd/amdxvba.h
check_cpp_condition vdpau/vdpau.h "defined(VDP_DECODER_PROFILE_MPEG4_PART2_SP)" && enable vdpau_mpeg4_support

check_header X11/extensions/XvMClib.h
Expand Down
7 changes: 6 additions & 1 deletion lib/ffmpeg/libavcodec/Makefile
Expand Up @@ -3,7 +3,7 @@ include $(SUBDIR)../config.mak
NAME = avcodec
FFLIBS = avcore avutil

HEADERS = avcodec.h avfft.h dxva2.h opt.h vaapi.h vdpau.h xvmc.h
HEADERS = avcodec.h avfft.h dxva2.h opt.h vaapi.h vdpau.h xvmc.h xvba.h

OBJS = allcodecs.o \
audioconvert.o \
Expand Down Expand Up @@ -43,6 +43,7 @@ RDFT-OBJS-$(CONFIG_HARDCODED_TABLES) += sin_tables.o
OBJS-$(CONFIG_RDFT) += rdft.o $(RDFT-OBJS-yes)
OBJS-$(CONFIG_VAAPI) += vaapi.o
OBJS-$(CONFIG_VDPAU) += vdpau.o
OBJS-$(CONFIG_XVBA) += xvba.o

# decoders/encoders/hardware accelerators
OBJS-$(CONFIG_A64MULTI_ENCODER) += a64multienc.o elbg.o
Expand Down Expand Up @@ -169,6 +170,7 @@ OBJS-$(CONFIG_H264_DECODER) += h264.o \
mpegvideo.o error_resilience.o
OBJS-$(CONFIG_H264_DXVA2_HWACCEL) += dxva2_h264.o
OBJS-$(CONFIG_H264_VAAPI_HWACCEL) += vaapi_h264.o
OBJS-$(CONFIG_H264_XVBA_HWACCEL) += xvba_h264.o
OBJS-$(CONFIG_HUFFYUV_DECODER) += huffyuv.o
OBJS-$(CONFIG_HUFFYUV_ENCODER) += huffyuv.o
OBJS-$(CONFIG_IDCIN_DECODER) += idcinvideo.o
Expand Down Expand Up @@ -246,6 +248,7 @@ OBJS-$(CONFIG_MPEG1VIDEO_ENCODER) += mpeg12enc.o mpegvideo_enc.o \
mpegvideo.o error_resilience.o
OBJS-$(CONFIG_MPEG2_DXVA2_HWACCEL) += dxva2_mpeg2.o
OBJS-$(CONFIG_MPEG2_VAAPI_HWACCEL) += vaapi_mpeg2.o
OBJS-$(CONFIG_MPEG2_XVBA_HWACCEL) += xvba_mpeg2.o
OBJS-$(CONFIG_MPEG2VIDEO_DECODER) += mpeg12.o mpeg12data.o \
mpegvideo.o error_resilience.o
OBJS-$(CONFIG_MPEG2VIDEO_ENCODER) += mpeg12enc.o mpegvideo_enc.o \
Expand Down Expand Up @@ -379,6 +382,7 @@ OBJS-$(CONFIG_VC1_DECODER) += vc1dec.o vc1.o vc1data.o vc1dsp.o \
intrax8.o intrax8dsp.o
OBJS-$(CONFIG_VC1_DXVA2_HWACCEL) += dxva2_vc1.o
OBJS-$(CONFIG_VC1_VAAPI_HWACCEL) += vaapi_vc1.o
OBJS-$(CONFIG_VC1_XVBA_HWACCEL) += xvba_vc1.o
OBJS-$(CONFIG_VCR1_DECODER) += vcr1.o
OBJS-$(CONFIG_VCR1_ENCODER) += vcr1.o
OBJS-$(CONFIG_VMDAUDIO_DECODER) += vmdav.o
Expand Down Expand Up @@ -647,6 +651,7 @@ SKIPHEADERS-$(CONFIG_DXVA2) += dxva2.h dxva2_internal.h
SKIPHEADERS-$(CONFIG_LIBDIRAC) += libdirac.h
SKIPHEADERS-$(CONFIG_LIBSCHROEDINGER) += libschroedinger.h
SKIPHEADERS-$(CONFIG_VAAPI) += vaapi_internal.h
SKIPHEADERS-$(CONFIG_XVBA) += xvba_internal.h
SKIPHEADERS-$(CONFIG_VDPAU) += vdpau.h
SKIPHEADERS-$(CONFIG_XVMC) += xvmc.h
SKIPHEADERS += mpegaudio3.h
Expand Down
4 changes: 4 additions & 0 deletions lib/ffmpeg/libavcodec/allcodecs.c
Expand Up @@ -57,13 +57,17 @@ void avcodec_register_all(void)
REGISTER_HWACCEL (H263_VAAPI, h263_vaapi);
REGISTER_HWACCEL (H264_DXVA2, h264_dxva2);
REGISTER_HWACCEL (H264_VAAPI, h264_vaapi);
REGISTER_HWACCEL (H264_XVBA, h264_xvba);
REGISTER_HWACCEL (MPEG2_DXVA2, mpeg2_dxva2);
REGISTER_HWACCEL (MPEG2_VAAPI, mpeg2_vaapi);
REGISTER_HWACCEL (MPEG4_VAAPI, mpeg4_vaapi);
REGISTER_HWACCEL (MPEG2_XVBA, mpeg2_xvba);
REGISTER_HWACCEL (VC1_DXVA2, vc1_dxva2);
REGISTER_HWACCEL (VC1_VAAPI, vc1_vaapi);
REGISTER_HWACCEL (VC1_XVBA, vc1_xvba);
REGISTER_HWACCEL (WMV3_DXVA2, wmv3_dxva2);
REGISTER_HWACCEL (WMV3_VAAPI, wmv3_vaapi);
REGISTER_HWACCEL (WMV3_XVBA, wmv3_xvba);

/* video codecs */
REGISTER_ENCODER (A64MULTI, a64multi);
Expand Down
1 change: 1 addition & 0 deletions lib/ffmpeg/libavcodec/h264.c
Expand Up @@ -55,6 +55,7 @@ static const uint8_t div6[52]={
static const enum PixelFormat hwaccel_pixfmt_list_h264_jpeg_420[] = {
PIX_FMT_DXVA2_VLD,
PIX_FMT_VAAPI_VLD,
PIX_FMT_XVBA_VLD,
PIX_FMT_YUVJ420P,
PIX_FMT_NONE
};
Expand Down
1 change: 1 addition & 0 deletions lib/ffmpeg/libavcodec/mpegvideo.c
Expand Up @@ -117,6 +117,7 @@ const enum PixelFormat ff_pixfmt_list_420[] = {
const enum PixelFormat ff_hwaccel_pixfmt_list_420[] = {
PIX_FMT_DXVA2_VLD,
PIX_FMT_VAAPI_VLD,
PIX_FMT_XVBA_VLD,
PIX_FMT_YUV420P,
PIX_FMT_NONE
};
Expand Down
65 changes: 65 additions & 0 deletions lib/ffmpeg/libavcodec/xvba.c
@@ -0,0 +1,65 @@
/*
* HW decode acceleration for MPEG-2, H.264 and VC-1
*
* Copyright (C) 2005-2011 Team XBMC
*
* 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
*/


/**
* \addtogroup XVBA_Decoding
*
* @{
*/

#include <stdint.h>
#include "xvba.h"
#include "avcodec.h"

int ff_xvba_translate_profile(int profile) {

if (profile == 66)
return 1;
else if (profile == 77)
return 2;
else if (profile == 100)
return 3;
else if (profile == 0)
return 4;
else if (profile == 1)
return 5;
else if (profile == 3)
return 6;
else
return -1;
}

void ff_xvba_add_slice_data(struct xvba_render_state *render, const void *buffer, uint32_t size) {

render->buffers = av_fast_realloc(
render->buffers,
&render->buffers_alllocated,
sizeof(struct xvba_bitstream_buffers)*(render->num_slices + 1)
);

render->buffers[render->num_slices].buffer = buffer;
render->buffers[render->num_slices].size = size;

render->num_slices++;
}

71 changes: 71 additions & 0 deletions lib/ffmpeg/libavcodec/xvba.h
@@ -0,0 +1,71 @@
/*
* HW decode acceleration for MPEG-2, H.264 and VC-1
*
* Copyright (C) 2005-2011 Team XBMC
*
* 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_XVBA_H
#define AVCODEC_XVBA_H

#include <stdint.h>
#include <X11/Xlib.h>
#include <amd/amdxvba.h>


/**
* \defgroup XVBA_Decoding VA API Decoding
* \ingroup Decoder
* @{
*/

/** \brief The videoSurface is used for rendering. */
#define FF_XVBA_STATE_USED_FOR_RENDER 1

/**
* \brief The videoSurface is needed for reference/prediction.
* The codec manipulates this.
*/
#define FF_XVBA_STATE_USED_FOR_REFERENCE 2

/**
* \brief The videoSurface holds a decoded frame.
* The codec manipulates this.
*/
#define FF_XVBA_STATE_DECODED 4

/* @} */

struct xvba_bitstream_buffers
{
const void *buffer;
unsigned int size;
};

struct xvba_render_state {

int state; ///< Holds FF_XVBA_STATE_* values.
void *surface;
XVBAPictureDescriptor *picture_descriptor;
XVBAQuantMatrixAvc *iq_matrix;
int num_slices;
struct xvba_bitstream_buffers *buffers;
uint32_t buffers_alllocated;
};

#endif /* AVCODEC_XVBA_H */

0 comments on commit b0ec419

Please sign in to comment.