ffmpeg: remove fglrx and xvba support

Signed-off-by: Stephan Raue <stephan@openelec.tv>
This commit is contained in:
Stephan Raue 2013-09-26 07:53:59 +02:00
parent afda7312e1
commit c5e3a155f2
15 changed files with 0 additions and 2065 deletions

View File

@ -53,12 +53,6 @@ else
FFMPEG_VDPAU="--disable-vdpau"
fi
if [ "$XVBA" = yes ]; then
FFMPEG_XVBA="--enable-xvba"
else
FFMPEG_XVBA="--disable-xvba"
fi
if [ "$XBMC" = "master" ]; then
FFMPEG_CONFIGURE=" "
else
@ -165,7 +159,6 @@ cd $PKG_BUILD/
$FFMPEG_CRYSTALHD \
$FFMPEG_VAAPI \
$FFMPEG_VDPAU \
$FFMPEG_XVBA \
--disable-dxva2 \
--enable-runtime-cpudetect \
$FFMPEG_TABLES \

View File

@ -48,15 +48,3 @@ if [ "$VDPAU" = yes ]; then
PKG_DEPENDS="$PKG_DEPENDS libvdpau"
fi
if [ "$XVBA" = yes ]; then
get_graphicdrivers
for drv in $GRAPHIC_DRIVERS; do
if [ "$drv" = "fglrx" ]; then
PKG_DEPENDS="$PKG_DEPENDS xf86-video-fglrx"
PKG_BUILD_DEPENDS_TARGET="$PKG_BUILD_DEPENDS_TARGET xf86-video-fglrx"
elif [ "$drv" = "fglrx-legacy" ]; then
PKG_DEPENDS="$PKG_DEPENDS xf86-video-fglrx-legacy"
PKG_BUILD_DEPENDS_TARGET="$PKG_BUILD_DEPENDS_TARGET xf86-video-fglrx-legacy"
fi
done
fi

View File

@ -1,813 +0,0 @@
diff -Naur a/configure b/configure
--- a/configure 2012-05-12 21:45:47.005596234 +0200
+++ b/configure 2012-05-12 21:46:03.902936436 +0200
@@ -113,6 +113,7 @@
--enable-vdpau enable VDPAU code [autodetect]
--disable-dxva2 disable DXVA2 code
--disable-vda disable VDA 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
--disable-safe-bitstream-reader
@@ -1084,6 +1085,7 @@
vaapi
vda
vdpau
+ xvba
version3
x11grab
zlib
@@ -1423,6 +1425,7 @@
h264_vaapi_hwaccel_select="vaapi h264_decoder"
h264_vda_hwaccel_deps="VideoDecodeAcceleration_VDADecoder_h pthreads"
h264_vda_hwaccel_select="vda h264_decoder"
+h264_xvba_hwaccel_select="xvba"
h264_vdpau_decoder_select="vdpau h264_decoder"
imc_decoder_select="fft mdct sinewin"
jpegls_decoder_select="golomb"
@@ -1459,6 +1462,7 @@
mpeg4_decoder_select="h263_decoder mpeg4video_parser"
mpeg4_encoder_select="h263_encoder"
mpeg4_vaapi_hwaccel_select="vaapi mpeg4_decoder"
+mpeg2_xvba_hwaccel_select="xvba mpeg2video_decoder"
mpeg4_vdpau_decoder_select="vdpau mpeg4_decoder"
msmpeg4_crystalhd_decoder_select="crystalhd"
msmpeg4v1_decoder_select="h263_decoder"
@@ -1501,6 +1505,7 @@
vc1_dxva2_hwaccel_deps="dxva2api_h"
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"
vc1image_decoder_select="vc1_decoder"
vorbis_decoder_select="mdct"
@@ -1525,6 +1530,7 @@
wmv3_vaapi_hwaccel_select="vc1_vaapi_hwaccel"
wmv3_vdpau_decoder_select="vc1_vdpau_decoder"
wmv3image_decoder_select="wmv3_decoder"
+wmv3_xvba_hwaccel_select="vc1_xvba_hwaccel"
zlib_decoder_select="zlib"
zlib_encoder_select="zlib"
zmbv_decoder_select="zlib"
@@ -1533,6 +1539,7 @@
crystalhd_deps="libcrystalhd_libcrystalhd_if_h"
vaapi_deps="va_va_h"
vda_deps="VideoDecodeAcceleration_VDADecoder_h pthreads"
+xvba_deps="amd_amdxvba_h"
vdpau_deps="vdpau_vdpau_h vdpau_vdpau_x11_h"
# parsers
@@ -3062,6 +3069,7 @@
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
diff -Naur a/libavcodec/allcodecs.c b/libavcodec/allcodecs.c
--- a/libavcodec/allcodecs.c 2012-05-12 21:45:47.257601308 +0200
+++ b/libavcodec/allcodecs.c 2012-05-12 21:46:03.905936496 +0200
@@ -59,14 +59,18 @@
REGISTER_HWACCEL (H264_VAAPI, h264_vaapi);
REGISTER_HWACCEL (H264_VDA, h264_vda);
REGISTER_HWACCEL (MPEG1_VDPAU, mpeg1_vdpau);
+ REGISTER_HWACCEL (H264_XVBA, h264_xvba);
REGISTER_HWACCEL (MPEG2_DXVA2, mpeg2_dxva2);
REGISTER_HWACCEL (MPEG2_VAAPI, mpeg2_vaapi);
REGISTER_HWACCEL (MPEG2_VDPAU, mpeg2_vdpau);
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);
diff -Naur a/libavcodec/h264.c b/libavcodec/h264.c
--- a/libavcodec/h264.c 2012-05-12 21:45:47.757611376 +0200
+++ b/libavcodec/h264.c 2012-05-12 21:46:03.908936558 +0200
@@ -60,6 +60,7 @@
PIX_FMT_DXVA2_VLD,
PIX_FMT_VAAPI_VLD,
PIX_FMT_VDA_VLD,
+ PIX_FMT_XVBA_VLD,
PIX_FMT_YUVJ420P,
PIX_FMT_NONE
};
diff -Naur a/libavcodec/Makefile b/libavcodec/Makefile
--- a/libavcodec/Makefile 2012-05-12 21:45:47.927614798 +0200
+++ b/libavcodec/Makefile 2012-05-12 21:46:03.904936476 +0200
@@ -3,7 +3,7 @@
NAME = avcodec
FFLIBS = avutil
-HEADERS = avcodec.h avfft.h dxva2.h opt.h vaapi.h vda.h vdpau.h version.h xvmc.h
+HEADERS = avcodec.h avfft.h dxva2.h opt.h vaapi.h vda.h vdpau.h version.h xvmc.h xvba.h
OBJS = allcodecs.o \
audioconvert.o \
@@ -51,6 +51,7 @@
OBJS-$(CONFIG_VAAPI) += vaapi.o
OBJS-$(CONFIG_VDA) += vda.o
OBJS-$(CONFIG_VDPAU) += vdpau.o
+OBJS-$(CONFIG_XVBA) += xvba.o
# decoders/encoders/hardware accelerators
OBJS-$(CONFIG_A64MULTI_ENCODER) += a64multienc.o elbg.o
@@ -201,6 +202,7 @@
OBJS-$(CONFIG_H264_DXVA2_HWACCEL) += dxva2_h264.o
OBJS-$(CONFIG_H264_VAAPI_HWACCEL) += vaapi_h264.o
OBJS-$(CONFIG_H264_VDA_HWACCEL) += vda_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
@@ -284,6 +286,7 @@
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 \
@@ -431,6 +434,7 @@
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
@@ -732,6 +736,7 @@
SKIPHEADERS-$(CONFIG_LIBSCHROEDINGER) += libschroedinger.h
SKIPHEADERS-$(CONFIG_VAAPI) += vaapi_internal.h
SKIPHEADERS-$(CONFIG_VDA) += vda_internal.h
+SKIPHEADERS-$(CONFIG_XVBA) += xvba_internal.h
SKIPHEADERS-$(CONFIG_VDPAU) += vdpau.h
SKIPHEADERS-$(CONFIG_XVMC) += xvmc.h
SKIPHEADERS-$(HAVE_W32THREADS) += w32pthreads.h
diff -Naur a/libavcodec/mpegvideo.c b/libavcodec/mpegvideo.c
--- a/libavcodec/mpegvideo.c 2012-05-12 21:45:48.027616812 +0200
+++ b/libavcodec/mpegvideo.c 2012-05-12 21:46:03.910936598 +0200
@@ -136,6 +136,7 @@
PIX_FMT_DXVA2_VLD,
PIX_FMT_VAAPI_VLD,
PIX_FMT_VDA_VLD,
+ PIX_FMT_XVBA_VLD,
PIX_FMT_YUV420P,
PIX_FMT_NONE
};
diff -Naur a/libavcodec/xvba.c b/libavcodec/xvba.c
--- a/libavcodec/xvba.c 1970-01-01 01:00:00.000000000 +0100
+++ b/libavcodec/xvba.c 2012-05-12 21:46:03.918936758 +0200
@@ -0,0 +1,66 @@
+/*
+ * 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 "xvba_internal.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 uint8_t *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++;
+}
+
diff -Naur a/libavcodec/xvba.h b/libavcodec/xvba.h
--- a/libavcodec/xvba.h 1970-01-01 01:00:00.000000000 +0100
+++ b/libavcodec/xvba.h 2012-05-12 21:46:03.918936758 +0200
@@ -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 */
diff -Naur a/libavcodec/xvba_h264.c b/libavcodec/xvba_h264.c
--- a/libavcodec/xvba_h264.c 1970-01-01 01:00:00.000000000 +0100
+++ b/libavcodec/xvba_h264.c 2012-05-12 21:46:03.919936778 +0200
@@ -0,0 +1,180 @@
+/*
+ * H.264 HW decode acceleration through XVBA
+ *
+ * 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
+ */
+
+#include "xvba.h"
+#include "xvba_internal.h"
+#include "h264.h"
+#include <assert.h>
+
+/** @file
+ * This file implements the glue code between FFmpeg's and XvBA API's
+ * structures for H.264 decoding.
+ */
+
+
+/** Initialize and start decoding a frame with XVBA. */
+static int 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 xvba_render_state *render;
+ XVBAPictureDescriptor *pic_descriptor;
+ int i;
+
+ render = (struct xvba_render_state *)s->current_picture_ptr->f.data[0];
+ assert(render);
+
+ if (render->picture_descriptor == 0)
+ return -1;
+
+ pic_descriptor = render->picture_descriptor;
+
+ for (i = 0; i < 2; ++i) {
+ int foc = s->current_picture_ptr->field_poc[i];
+ if (foc == INT_MAX)
+ foc = 0;
+ pic_descriptor->avc_curr_field_order_cnt_list[i] = foc;
+ }
+
+ pic_descriptor->avc_frame_num = h->frame_num;
+
+ render->num_slices = 0;
+
+ return 0;
+}
+
+/** End a hardware decoding based frame. */
+static int end_frame(AVCodecContext *avctx)
+{
+ H264Context * const h = avctx->priv_data;
+ MpegEncContext * const s = &h->s;
+ struct xvba_render_state *render;
+ XVBAPictureDescriptor *pic_descriptor;
+ XVBAQuantMatrixAvc *iq_matrix;
+
+ render = (struct xvba_render_state *)s->current_picture_ptr->f.data[0];
+ assert(render);
+
+ if (render->picture_descriptor == 0 || render->iq_matrix == 0)
+ return -1;
+
+ pic_descriptor = render->picture_descriptor;
+ iq_matrix = render->iq_matrix;
+
+ av_dlog(avctx, "end_frame()\n");
+
+ /* Fill in Picture Parameters*/
+ pic_descriptor->profile = ff_xvba_translate_profile(avctx->profile);
+ pic_descriptor->level = avctx->level;
+ pic_descriptor->width_in_mb = s->mb_width;
+ pic_descriptor->height_in_mb = s->mb_height;
+ pic_descriptor->picture_structure = s->picture_structure;
+ pic_descriptor->chroma_format = s->chroma_format ? s->chroma_format : 1;
+ pic_descriptor->avc_intra_flag = (h->slice_type == FF_I_TYPE) ? 1 : 0;
+ pic_descriptor->avc_reference = (s->current_picture_ptr->f.reference & 3) ? 1 : 0;
+
+ pic_descriptor->avc_bit_depth_luma_minus8 = h->sps.bit_depth_luma - 8;
+ pic_descriptor->avc_bit_depth_chroma_minus8 = h->sps.bit_depth_chroma - 8;
+ pic_descriptor->avc_log2_max_frame_num_minus4 = h->sps.log2_max_frame_num -4;
+ pic_descriptor->avc_pic_order_cnt_type = h->sps.poc_type;
+ pic_descriptor->avc_log2_max_pic_order_cnt_lsb_minus4 = h->sps.log2_max_poc_lsb - 4;
+ pic_descriptor->avc_num_ref_frames = h->sps.ref_frame_count;
+ pic_descriptor->avc_reserved_8bit = 0;
+
+ pic_descriptor->avc_num_slice_groups_minus1 = h->pps.slice_group_count - 1;
+ pic_descriptor->avc_num_ref_idx_l0_active_minus1 = h->pps.ref_count[0] - 1;
+ pic_descriptor->avc_num_ref_idx_l1_active_minus1 = h->pps.ref_count[1] - 1;
+
+ pic_descriptor->avc_pic_init_qp_minus26 = h->pps.init_qp - 26;
+ pic_descriptor->avc_pic_init_qs_minus26 = h->pps.init_qs - 26;
+ pic_descriptor->avc_chroma_qp_index_offset = h->pps.chroma_qp_index_offset[0];
+ pic_descriptor->avc_second_chroma_qp_index_offset = h->pps.chroma_qp_index_offset[1];
+ pic_descriptor->avc_slice_group_change_rate_minus1 = 0; // not implemented in ffmpeg
+ pic_descriptor->avc_reserved_16bit = 0; // must be 0
+ memset(pic_descriptor->avc_field_order_cnt_list,0,sizeof(pic_descriptor->avc_field_order_cnt_list)); // must be 0
+ memset(pic_descriptor->avc_slice_group_map,0,sizeof(pic_descriptor->avc_slice_group_map)); // must be 0
+
+ // sps
+ pic_descriptor->sps_info.avc.delta_pic_always_zero_flag = h->sps.delta_pic_order_always_zero_flag;
+ pic_descriptor->sps_info.avc.direct_8x8_inference_flag = h->sps.direct_8x8_inference_flag;
+ pic_descriptor->sps_info.avc.frame_mbs_only_flag = h->sps.frame_mbs_only_flag;
+ pic_descriptor->sps_info.avc.gaps_in_frame_num_value_allowed_flag = h->sps.gaps_in_frame_num_allowed_flag;
+ pic_descriptor->sps_info.avc.mb_adaptive_frame_field_flag = h->sps.mb_aff;
+ pic_descriptor->sps_info.avc.residual_colour_transform_flag = h->sps.residual_color_transform_flag;
+ pic_descriptor->sps_info.avc.xvba_avc_sps_reserved = 0;
+
+ // pps
+ pic_descriptor->pps_info.avc.entropy_coding_mode_flag = h->pps.cabac;
+ pic_descriptor->pps_info.avc.pic_order_present_flag = h->pps.pic_order_present;
+ pic_descriptor->pps_info.avc.weighted_pred_flag = h->pps.weighted_pred;
+ pic_descriptor->pps_info.avc.weighted_bipred_idc = h->pps.weighted_bipred_idc;
+ pic_descriptor->pps_info.avc.deblocking_filter_control_present_flag = h->pps.deblocking_filter_parameters_present;
+ pic_descriptor->pps_info.avc.constrained_intra_pred_flag = h->pps.constrained_intra_pred;
+ pic_descriptor->pps_info.avc.redundant_pic_cnt_present_flag = h->pps.redundant_pic_cnt_present;
+ pic_descriptor->pps_info.avc.transform_8x8_mode_flag = h->pps.transform_8x8_mode;
+ pic_descriptor->pps_info.avc.xvba_avc_pps_reserved = 0; // must be 0
+
+ memcpy(iq_matrix->bScalingLists4x4, h->pps.scaling_matrix4, sizeof(iq_matrix->bScalingLists4x4));
+ memcpy(iq_matrix->bScalingLists8x8, h->pps.scaling_matrix8, sizeof(iq_matrix->bScalingLists8x8));
+
+ // Wait for an I-frame before start decoding. Workaround for ATI UVD and UVD+ GPUs
+ if (!h->got_first_iframe) {
+ if (h->slice_type != FF_I_TYPE && h->slice_type != FF_SI_TYPE)
+ return -1;
+ h->got_first_iframe = 1;
+ }
+
+ ff_draw_horiz_band(s, 0, s->avctx->height);
+
+ return 0;
+}
+
+/** Decode the given H.264 slice with XVBA. */
+static int decode_slice(AVCodecContext *avctx,
+ const uint8_t *buffer,
+ uint32_t size)
+{
+ H264Context * const h = avctx->priv_data;
+ MpegEncContext * const s = &h->s;
+ struct xvba_render_state *render;
+
+ render = (struct xvba_render_state *)s->current_picture_ptr->f.data[0];
+ assert(render);
+
+ ff_xvba_add_slice_data(render, buffer, size);
+
+ return 0;
+}
+
+AVHWAccel ff_h264_xvba_hwaccel = {
+ .name = "h264_xvba",
+ .type = AVMEDIA_TYPE_VIDEO,
+ .id = CODEC_ID_H264,
+ .pix_fmt = PIX_FMT_XVBA_VLD,
+ .capabilities = 0,
+ .start_frame = start_frame,
+ .end_frame = end_frame,
+ .decode_slice = decode_slice,
+ .priv_data_size = 0,
+};
diff -Naur a/libavcodec/xvba_internal.h b/libavcodec/xvba_internal.h
--- a/libavcodec/xvba_internal.h 1970-01-01 01:00:00.000000000 +0100
+++ b/libavcodec/xvba_internal.h 2012-05-12 21:46:03.920936798 +0200
@@ -0,0 +1,24 @@
+/*
+ * 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
+ */
+
+int ff_xvba_translate_profile(int profile);
+void ff_xvba_add_slice_data(struct xvba_render_state *render, const uint8_t *buffer, uint32_t size);
diff -Naur a/libavcodec/xvba_mpeg2.c b/libavcodec/xvba_mpeg2.c
--- a/libavcodec/xvba_mpeg2.c 1970-01-01 01:00:00.000000000 +0100
+++ b/libavcodec/xvba_mpeg2.c 2012-05-12 21:46:03.920936798 +0200
@@ -0,0 +1,52 @@
+/*
+ * MPEG-2 HW decode acceleration through XVBA
+ *
+ * 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
+ */
+
+#include "dsputil.h"
+
+static int start_frame(AVCodecContext *avctx, av_unused const uint8_t *buffer, av_unused uint32_t size)
+{
+ struct MpegEncContext * const s = avctx->priv_data;
+ return 0;
+}
+
+static int end_frame(AVCodecContext *avctx)
+{
+ return 0;
+}
+
+static int decode_slice(AVCodecContext *avctx, const uint8_t *buffer, uint32_t size)
+{
+ struct MpegEncContext * const s = avctx->priv_data;
+ return 0;
+}
+
+AVHWAccel ff_mpeg2_xvba_hwaccel = {
+ .name = "mpeg2_xvba",
+ .type = AVMEDIA_TYPE_VIDEO,
+ .id = CODEC_ID_MPEG2VIDEO,
+ .pix_fmt = PIX_FMT_XVBA_VLD,
+ .capabilities = 0,
+ .start_frame = start_frame,
+ .end_frame = end_frame,
+ .decode_slice = decode_slice,
+ .priv_data_size = 0,
+};
diff -Naur a/libavcodec/xvba_vc1.c b/libavcodec/xvba_vc1.c
--- a/libavcodec/xvba_vc1.c 1970-01-01 01:00:00.000000000 +0100
+++ b/libavcodec/xvba_vc1.c 2012-05-12 21:46:03.921936819 +0200
@@ -0,0 +1,194 @@
+/*
+ * VC-1 HW decode acceleration through XVBA
+ *
+ * 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
+ */
+
+#include "xvba.h"
+#include "xvba_internal.h"
+#include "vc1.h"
+#include "vc1data.h"
+#include <assert.h>
+
+
+/** @file
+ * Implement structures of ffmpeg <-> XvBA
+ */
+
+/* Initialize and start decoding a frame with XvBA */
+static int start_frame(AVCodecContext *avctx,
+ av_unused const uint8_t *buffer,
+ av_unused uint32_t size)
+{
+ VC1Context * const v = avctx->priv_data;
+ MpegEncContext * const s = &v->s;
+ struct xvba_render_state *render;
+
+ render = (struct xvba_render_state *)s->current_picture_ptr->f.data[0];
+ assert(render);
+
+ render->num_slices = 0;
+ return 0;
+}
+
+/* End a hardware decoding based frame */
+static int end_frame(AVCodecContext *avctx)
+{
+ VC1Context* const v = avctx->priv_data;
+ MpegEncContext* const s = &v->s;
+ struct xvba_render_state *render, *last, *next;
+ XVBAPictureDescriptor *pic_descriptor;
+
+ render = (struct xvba_render_state *)s->current_picture_ptr->f.data[0];
+ assert(render);
+
+ if (render->picture_descriptor == 0)
+ return -1;
+
+ pic_descriptor = render->picture_descriptor;
+
+ av_dlog(avctx, "xvba_vc1_end_frame()\n");
+
+ memset(pic_descriptor, 0, sizeof(*pic_descriptor));
+
+ /* Fill in Parameters - for reference see AMD sdk documentation */
+ pic_descriptor->profile = ff_xvba_translate_profile(v->profile);
+ pic_descriptor->level = v->level;
+ //done like in va-driver and vaapi
+ if (v->profile == PROFILE_ADVANCED) {
+ pic_descriptor->width_in_mb = s->avctx->coded_width;
+ pic_descriptor->height_in_mb = s->avctx->coded_height;
+ } else {
+ pic_descriptor->width_in_mb = s->mb_width;
+ pic_descriptor->height_in_mb = s->mb_height;
+ }
+ pic_descriptor->picture_structure = s->picture_structure;
+ // xvba-video set this to 1 only 4:2:0 supported
+ // doc says: if not set, choose 1 - we try this
+ pic_descriptor->chroma_format = 1;
+ pic_descriptor->avc_intra_flag = s->pict_type == FF_I_TYPE || v->bi_type == 1;
+ pic_descriptor->avc_reference = (s->current_picture_ptr->f.reference & 3) ? 1 : 0;
+
+ // VC-1 explicit parameters see page 30 of sdk
+ // sps_info
+ pic_descriptor->sps_info.vc1.postprocflag = v->postprocflag;
+
+ // done as in vaapi
+ pic_descriptor->sps_info.vc1.pulldown = v->broadcast;
+ pic_descriptor->sps_info.vc1.interlace = v->interlace;
+ pic_descriptor->sps_info.vc1.tfcntrflag = v->tfcntrflag;
+ pic_descriptor->sps_info.vc1.finterpflag = v->finterpflag;
+ pic_descriptor->sps_info.vc1.reserved = 1;
+ // eventually check if this makes sense together with interlace
+ pic_descriptor->sps_info.vc1.psf = v->psf;
+ // what about if it is a frame (page 31)
+ // looked at xvba-driver
+ pic_descriptor->sps_info.vc1.second_field = !s->first_field;
+ pic_descriptor->sps_info.vc1.xvba_vc1_sps_reserved = 0;
+
+ // VC-1 explicit parameters see page 30 of sdk
+ // pps_info
+ pic_descriptor->pps_info.vc1.panscan_flag = v->panscanflag;
+ pic_descriptor->pps_info.vc1.refdist_flag = v->refdist_flag;
+ pic_descriptor->pps_info.vc1.loopfilter = s->loop_filter;
+ pic_descriptor->pps_info.vc1.fastuvmc = v->fastuvmc;
+ pic_descriptor->pps_info.vc1.extended_mv = v->extended_mv;
+ pic_descriptor->pps_info.vc1.dquant = v->dquant;
+ pic_descriptor->pps_info.vc1.vstransform = v->vstransform;
+ pic_descriptor->pps_info.vc1.overlap = v->overlap;
+ pic_descriptor->pps_info.vc1.quantizer = v->quantizer_mode;
+ pic_descriptor->pps_info.vc1.extended_dmv = v->extended_dmv;
+ pic_descriptor->pps_info.vc1.maxbframes = s->avctx->max_b_frames;
+ pic_descriptor->pps_info.vc1.rangered = (pic_descriptor->profile == PROFILE_SIMPLE) ? 0 : v->rangered;
+ pic_descriptor->pps_info.vc1.syncmarker = (pic_descriptor->profile == PROFILE_SIMPLE) ? 0 : s->resync_marker;
+ pic_descriptor->pps_info.vc1.multires = v->multires;
+ pic_descriptor->pps_info.vc1.reserved = 1;
+ pic_descriptor->pps_info.vc1.range_mapy_flag = v->range_mapy_flag;
+ pic_descriptor->pps_info.vc1.range_mapy = v->range_mapy;
+ pic_descriptor->pps_info.vc1.range_mapuv_flag = v->range_mapuv_flag;
+ pic_descriptor->pps_info.vc1.range_mapuv = v->range_mapuv;
+ pic_descriptor->pps_info.vc1.xvba_vc1_pps_reserved = 0;
+
+ pic_descriptor->past_surface = 0;
+ pic_descriptor->future_surface = 0;
+ switch (s->pict_type) {
+ case FF_B_TYPE:
+ next = (struct xvba_render_state *)s->next_picture.f.data[0];
+ assert(next);
+ if (next)
+ pic_descriptor->past_surface = next->surface;
+ // fall-through
+ case FF_P_TYPE:
+ last = (struct xvba_render_state *)s->last_picture.f.data[0];
+ assert(last);
+ if (last)
+ pic_descriptor->future_surface = last->surface;
+ break;
+ }
+
+ ff_draw_horiz_band(s, 0, s->avctx->height);
+
+ return 0;
+}
+
+static int decode_slice(AVCodecContext *avctx, const uint8_t *buffer, uint32_t size)
+{
+ VC1Context* const v = avctx->priv_data;
+ MpegEncContext* const s = &v->s;
+ struct xvba_render_state *render;
+
+ render = (struct xvba_render_state *)s->current_picture_ptr->f.data[0];
+ assert(render);
+
+ if (avctx->codec_id == CODEC_ID_VC1 &&
+ size >= 4 && IS_MARKER(AV_RB32(buffer))) {
+ buffer += 4;
+ size -= 4;
+ }
+
+ ff_xvba_add_slice_data(render, buffer, size);
+
+ return 0;
+}
+
+#if CONFIG_WMV3_XVBA_HWACCEL
+AVHWAccel ff_wmv3_xvba_hwaccel = {
+ .name = "wmv3_xvba",
+ .type = AVMEDIA_TYPE_VIDEO,
+ .id = CODEC_ID_WMV3,
+ .pix_fmt = PIX_FMT_XVBA_VLD,
+ .capabilities = 0,
+ .start_frame = start_frame,
+ .end_frame = end_frame,
+ .decode_slice = decode_slice,
+ .priv_data_size = 0,
+};
+#endif
+
+AVHWAccel ff_vc1_xvba_hwaccel = {
+ .name = "vc1_xvba",
+ .type = AVMEDIA_TYPE_VIDEO,
+ .id = CODEC_ID_VC1,
+ .pix_fmt = PIX_FMT_XVBA_VLD,
+ .capabilities = 0,
+ .start_frame = start_frame,
+ .end_frame = end_frame,
+ .decode_slice = decode_slice,
+ .priv_data_size = 0,
+};
diff -Naur a/libavcodec/xvmc_internal.h b/libavcodec/xvmc_internal.h
--- a/libavcodec/xvmc_internal.h 2012-05-12 21:45:48.572627784 +0200
+++ b/libavcodec/xvmc_internal.h 2012-05-12 21:46:03.922936840 +0200
@@ -1,5 +1,7 @@
/*
- * XVideo Motion Compensation internal functions
+ * HW decode acceleration for MPEG-2, H.264 and VC-1
+ *
+ * Copyright (C) 2005-2011 Team XBMC
*
* This file is part of FFmpeg.
*
diff -Naur a/libavutil/pixdesc.c b/libavutil/pixdesc.c
--- a/libavutil/pixdesc.c 2012-05-12 21:45:49.442645301 +0200
+++ b/libavutil/pixdesc.c 2012-05-12 21:46:03.923936860 +0200
@@ -874,6 +874,12 @@
.log2_chroma_h = 1,
.flags = PIX_FMT_HWACCEL,
},
+ [PIX_FMT_XVBA_VLD] = {
+ .name = "xvba_vld",
+ .log2_chroma_w = 1,
+ .log2_chroma_h = 1,
+ .flags = PIX_FMT_HWACCEL,
+ },
[PIX_FMT_YUV420P9LE] = {
.name = "yuv420p9le",
.nb_components = 3,
diff -Naur a/libavutil/pixfmt.h b/libavutil/pixfmt.h
--- a/libavutil/pixfmt.h 2012-05-12 21:45:49.445645361 +0200
+++ b/libavutil/pixfmt.h 2012-05-12 21:46:03.924936880 +0200
@@ -129,6 +129,7 @@
PIX_FMT_YUV444P16BE, ///< planar YUV 4:4:4, 48bpp, (1 Cr & Cb sample per 1x1 Y samples), big-endian
PIX_FMT_VDPAU_MPEG4, ///< MPEG4 HW decoding with VDPAU, data[0] contains a vdpau_render_state struct which contains the bitstream of the slices as well as various fields extracted from headers
PIX_FMT_DXVA2_VLD, ///< HW decoding through DXVA2, Picture.data[3] contains a LPDIRECT3DSURFACE9 pointer
+ PIX_FMT_XVBA_VLD, ///< HW decoding through DXVA2, Picture.data[3] contains a vaapi_render_state struct which contains the bitstream of the slices as well as various fields extracted from headers
PIX_FMT_RGB444LE, ///< packed RGB 4:4:4, 16bpp, (msb)4A 4R 4G 4B(lsb), little-endian, most significant bits to 0
PIX_FMT_RGB444BE, ///< packed RGB 4:4:4, 16bpp, (msb)4A 4R 4G 4B(lsb), big-endian, most significant bits to 0

View File

@ -1,50 +0,0 @@
From 1f4d4832065673eaa989bd8d45f55703d8a135ab Mon Sep 17 00:00:00 2001
From: xbmc <xbmc@AD02.(none)>
Date: Mon, 30 Apr 2012 13:58:29 +0200
Subject: [PATCH] ffmpeg: xvba, adapt to new ffmpeg, fix artifacts for h.264
---
libavcodec/xvba_h264.c | 9 ++++-----
1 file changed, 4 insertions(+), 5 deletions(-)
diff --git a/libavcodec/xvba_h264.c b/libavcodec/xvba_h264.c
index 1f737b0..9be6ffb 100644
--- a/libavcodec/xvba_h264.c
+++ b/libavcodec/xvba_h264.c
@@ -91,7 +91,7 @@ static int end_frame(AVCodecContext *avctx)
pic_descriptor->height_in_mb = s->mb_height;
pic_descriptor->picture_structure = s->picture_structure;
pic_descriptor->chroma_format = s->chroma_format ? s->chroma_format : 1;
- pic_descriptor->avc_intra_flag = (h->slice_type == FF_I_TYPE) ? 1 : 0;
+ pic_descriptor->avc_intra_flag = (h->slice_type == AV_PICTURE_TYPE_I) ? 1 : 0;
pic_descriptor->avc_reference = (s->current_picture_ptr->f.reference & 3) ? 1 : 0;
pic_descriptor->avc_bit_depth_luma_minus8 = h->sps.bit_depth_luma - 8;
@@ -136,11 +136,12 @@ static int end_frame(AVCodecContext *avctx)
pic_descriptor->pps_info.avc.xvba_avc_pps_reserved = 0; // must be 0
memcpy(iq_matrix->bScalingLists4x4, h->pps.scaling_matrix4, sizeof(iq_matrix->bScalingLists4x4));
- memcpy(iq_matrix->bScalingLists8x8, h->pps.scaling_matrix8, sizeof(iq_matrix->bScalingLists8x8));
+ memcpy(iq_matrix->bScalingLists8x8[0], h->pps.scaling_matrix8[0], sizeof(iq_matrix->bScalingLists8x8[0]));
+ memcpy(iq_matrix->bScalingLists8x8[1], h->pps.scaling_matrix8[3], sizeof(iq_matrix->bScalingLists8x8[0]));
// Wait for an I-frame before start decoding. Workaround for ATI UVD and UVD+ GPUs
if (!h->got_first_iframe) {
- if (h->slice_type != FF_I_TYPE && h->slice_type != FF_SI_TYPE)
+ if (h->slice_type != AV_PICTURE_TYPE_I && h->slice_type != AV_PICTURE_TYPE_SI)
return -1;
h->got_first_iframe = 1;
}
@@ -172,9 +173,7 @@ static int decode_slice(AVCodecContext *avctx,
.type = AVMEDIA_TYPE_VIDEO,
.id = CODEC_ID_H264,
.pix_fmt = PIX_FMT_XVBA_VLD,
- .capabilities = 0,
.start_frame = start_frame,
.end_frame = end_frame,
.decode_slice = decode_slice,
- .priv_data_size = 0,
};
--
1.7.10

View File

@ -1,64 +0,0 @@
From 81d1514a1daf379d58c61080244bb01c7ee7e662 Mon Sep 17 00:00:00 2001
From: fritsch <peter.fruehberger@gmail.com>
Date: Mon, 30 Apr 2012 21:33:18 +0200
Subject: [PATCH] xvba: (VC-1) rename FF_P_TYPE, FF_B_TYPE and FF_I_TYPE to
new ffmpeg conventions
---
libavcodec/xvba_vc1.c | 10 +++-------
1 file changed, 3 insertions(+), 7 deletions(-)
diff --git a/libavcodec/xvba_vc1.c b/libavcodec/xvba_vc1.c
index c202b9c..7315b62 100644
--- a/libavcodec/xvba_vc1.c
+++ b/libavcodec/xvba_vc1.c
@@ -82,7 +82,7 @@ static int end_frame(AVCodecContext *avctx)
// xvba-video set this to 1 only 4:2:0 supported
// doc says: if not set, choose 1 - we try this
pic_descriptor->chroma_format = 1;
- pic_descriptor->avc_intra_flag = s->pict_type == FF_I_TYPE || v->bi_type == 1;
+ pic_descriptor->avc_intra_flag = s->pict_type == AV_PICTURE_TYPE_I || v->bi_type == 1;
pic_descriptor->avc_reference = (s->current_picture_ptr->f.reference & 3) ? 1 : 0;
// VC-1 explicit parameters see page 30 of sdk
@@ -128,13 +128,13 @@ static int end_frame(AVCodecContext *avctx)
pic_descriptor->past_surface = 0;
pic_descriptor->future_surface = 0;
switch (s->pict_type) {
- case FF_B_TYPE:
+ case AV_PICTURE_TYPE_B:
next = (struct xvba_render_state *)s->next_picture.f.data[0];
assert(next);
if (next)
pic_descriptor->past_surface = next->surface;
// fall-through
- case FF_P_TYPE:
+ case AV_PICTURE_TYPE_P:
last = (struct xvba_render_state *)s->last_picture.f.data[0];
assert(last);
if (last)
@@ -173,11 +173,9 @@ static int decode_slice(AVCodecContext *avctx, const uint8_t *buffer, uint32_t s
.type = AVMEDIA_TYPE_VIDEO,
.id = CODEC_ID_WMV3,
.pix_fmt = PIX_FMT_XVBA_VLD,
- .capabilities = 0,
.start_frame = start_frame,
.end_frame = end_frame,
.decode_slice = decode_slice,
- .priv_data_size = 0,
};
#endif
@@ -186,9 +184,7 @@ static int decode_slice(AVCodecContext *avctx, const uint8_t *buffer, uint32_t s
.type = AVMEDIA_TYPE_VIDEO,
.id = CODEC_ID_VC1,
.pix_fmt = PIX_FMT_XVBA_VLD,
- .capabilities = 0,
.start_frame = start_frame,
.end_frame = end_frame,
.decode_slice = decode_slice,
- .priv_data_size = 0,
};
--
1.7.10

View File

@ -1,34 +0,0 @@
From adc34a12c7d8b778021ae75562ccedd98a43a602 Mon Sep 17 00:00:00 2001
From: xbmc <fernetmenta@online.de>
Date: Thu, 28 Jun 2012 13:06:16 +0200
Subject: [PATCH] xvba: correct h.264 level in case it was encoded wrongly,
thanks @fritsch for pointing this out
---
lib/ffmpeg/libavcodec/xvba_h264.c | 10 ++++++++++
1 file changed, 10 insertions(+)
diff --git a/libavcodec/xvba_h264.c b/libavcodec/xvba_h264.c
index 9be6ffb..a077442 100644
--- a/libavcodec/xvba_h264.c
+++ b/libavcodec/xvba_h264.c
@@ -102,6 +102,16 @@ static int end_frame(AVCodecContext *avctx)
pic_descriptor->avc_num_ref_frames = h->sps.ref_frame_count;
pic_descriptor->avc_reserved_8bit = 0;
+ /* Set correct level */
+ if (pic_descriptor->level == 41) {
+ const unsigned int mbw = pic_descriptor->width_in_mb;
+ const unsigned int mbh = pic_descriptor->height_in_mb;
+ const unsigned int max_ref_frames = 12288 * 1024 / (mbw * mbh * 384);
+ const unsigned int num_ref_frames = pic_descriptor->avc_num_ref_frames;
+ if (max_ref_frames < num_ref_frames)
+ pic_descriptor->level = 51;
+ }
+
pic_descriptor->avc_num_slice_groups_minus1 = h->pps.slice_group_count - 1;
pic_descriptor->avc_num_ref_idx_l0_active_minus1 = h->pps.ref_count[0] - 1;
pic_descriptor->avc_num_ref_idx_l1_active_minus1 = h->pps.ref_count[1] - 1;
--
1.7.10

View File

@ -1,13 +0,0 @@
diff --git a/libavutil/utils.c b/libavutil/utils.c
index 971b48b..b57078e 100644
--- a/libavutil/utils.c
+++ b/libavutil/utils.c
@@ -28,7 +28,7 @@
unsigned avutil_version(void)
{
- av_assert0(PIX_FMT_VDA_VLD == 81); //check if the pix fmt enum has not had anything inserted or removed by mistake
+ av_assert0(PIX_FMT_VDA_VLD == 82); //check if the pix fmt enum has not had anything inserted or removed by mistake
av_assert0(AV_SAMPLE_FMT_DBLP == 9);
av_assert0(AVMEDIA_TYPE_ATTACHMENT == 4);
av_assert0(AV_PICTURE_TYPE_BI == 7);

View File

@ -1,804 +0,0 @@
diff -Naur ffmpeg-1.2.3/configure ffmpeg-1.2.3.patch/configure
--- ffmpeg-1.2.3/configure 2013-09-09 22:46:04.636832059 +0200
+++ ffmpeg-1.2.3.patch/configure 2013-09-09 22:47:15.023872481 +0200
@@ -144,6 +144,7 @@
--disable-vaapi disable VAAPI code [autodetect]
--enable-vda enable VDA code
--disable-vdpau disable VDPAU code [autodetect]
+ --disable-xvba disable XVBA code
Individual component options:
--disable-everything disable all components listed below
@@ -1197,6 +1198,7 @@
vaapi
vda
vdpau
+ xvba
"
LIBRARY_LIST="
@@ -1827,6 +1829,7 @@
dxva2_deps="dxva2api_h"
vaapi_deps="va_va_h"
vda_deps="VideoDecodeAcceleration_VDADecoder_h pthreads"
+xvba_deps="amd_amdxvba_h"
vda_extralibs="-framework CoreFoundation -framework VideoDecodeAcceleration -framework QuartzCore"
vdpau_deps="vdpau_vdpau_h vdpau_vdpau_x11_h"
@@ -1847,6 +1850,8 @@
h264_vdpau_decoder_select="h264_decoder"
h264_vdpau_hwaccel_deps="vdpau"
h264_vdpau_hwaccel_select="h264_decoder"
+h264_xvba_hwaccel_select="h264_decoder"
+h264_xvba_hwaccel_deps="xvba"
mpeg_vdpau_decoder_deps="vdpau"
mpeg_vdpau_decoder_select="mpegvideo_decoder"
mpeg1_vdpau_decoder_deps="vdpau"
@@ -1859,6 +1864,8 @@
mpeg2_vaapi_hwaccel_deps="vaapi"
mpeg2_vaapi_hwaccel_select="mpeg2video_decoder"
mpeg2_vdpau_hwaccel_deps="vdpau"
+mpeg2_xvba_hwaccel_select="mpeg2video_decoder"
+mpeg2_xvba_hwaccel_deps="xvba"
mpeg2_vdpau_hwaccel_select="mpeg2video_decoder"
mpeg4_crystalhd_decoder_select="crystalhd"
mpeg4_vaapi_hwaccel_deps="vaapi"
@@ -1877,11 +1884,14 @@
vc1_vdpau_decoder_select="vc1_decoder"
vc1_vdpau_hwaccel_deps="vdpau"
vc1_vdpau_hwaccel_select="vc1_decoder"
+vc1_xvba_hwaccel_select="vc1_decoder"
+vc1_xvba_hwaccel_deps="xvba"
wmv3_crystalhd_decoder_select="crystalhd"
wmv3_dxva2_hwaccel_select="vc1_dxva2_hwaccel"
wmv3_vaapi_hwaccel_select="vc1_vaapi_hwaccel"
wmv3_vdpau_decoder_select="vc1_vdpau_decoder"
wmv3_vdpau_hwaccel_select="vc1_vdpau_hwaccel"
+wmv3_xvba_hwaccel_select="vc1_xvba_hwaccel"
# parsers
h264_parser_select="golomb h264chroma h264dsp h264pred h264qpel videodsp"
@@ -3836,6 +3846,7 @@
check_header vdpau/vdpau.h
check_header vdpau/vdpau_x11.h
check_cpp_condition vdpau/vdpau.h "defined(VDP_DECODER_PROFILE_MPEG4_PART2_SP)" && enable vdpau_mpeg4_support
+check_header amd/amdxvba.h
check_header VideoDecodeAcceleration/VDADecoder.h
check_header windows.h
diff -Naur ffmpeg-1.2.3/libavcodec/allcodecs.c ffmpeg-1.2.3.patch/libavcodec/allcodecs.c
--- ffmpeg-1.2.3/libavcodec/allcodecs.c 2013-08-27 02:13:44.000000000 +0200
+++ ffmpeg-1.2.3.patch/libavcodec/allcodecs.c 2013-09-09 22:46:40.577852790 +0200
@@ -79,18 +79,22 @@
REGISTER_HWACCEL(H264_VAAPI, h264_vaapi);
REGISTER_HWACCEL(H264_VDA, h264_vda);
REGISTER_HWACCEL(H264_VDPAU, h264_vdpau);
+ REGISTER_HWACCEL(H264_XVBA, h264_xvba);
REGISTER_HWACCEL(MPEG1_VDPAU, mpeg1_vdpau);
REGISTER_HWACCEL(MPEG2_DXVA2, mpeg2_dxva2);
REGISTER_HWACCEL(MPEG2_VAAPI, mpeg2_vaapi);
REGISTER_HWACCEL(MPEG2_VDPAU, mpeg2_vdpau);
+ REGISTER_HWACCEL(MPEG2_XVBA, mpeg2_xvba);
REGISTER_HWACCEL(MPEG4_VAAPI, mpeg4_vaapi);
REGISTER_HWACCEL(MPEG4_VDPAU, mpeg4_vdpau);
REGISTER_HWACCEL(VC1_DXVA2, vc1_dxva2);
REGISTER_HWACCEL(VC1_VAAPI, vc1_vaapi);
REGISTER_HWACCEL(VC1_VDPAU, vc1_vdpau);
+ REGISTER_HWACCEL(VC1_XVBA, vc1_xvba);
REGISTER_HWACCEL(WMV3_DXVA2, wmv3_dxva2);
REGISTER_HWACCEL(WMV3_VAAPI, wmv3_vaapi);
REGISTER_HWACCEL(WMV3_VDPAU, wmv3_vdpau);
+ REGISTER_HWACCEL(WMV3_XVBA, wmv3_xvba);
/* video codecs */
REGISTER_ENCODER(A64MULTI, a64multi);
diff -Naur ffmpeg-1.2.3/libavcodec/h264.c ffmpeg-1.2.3.patch/libavcodec/h264.c
--- ffmpeg-1.2.3/libavcodec/h264.c 2013-09-09 22:46:04.639832061 +0200
+++ ffmpeg-1.2.3.patch/libavcodec/h264.c 2013-09-09 22:46:40.579852792 +0200
@@ -81,6 +81,9 @@
#if CONFIG_H264_VDPAU_HWACCEL
AV_PIX_FMT_VDPAU,
#endif
+#if CONFIG_H264_XVBA_HWACCEL
+ AV_PIX_FMT_XVBA_VLD,
+#endif
AV_PIX_FMT_YUV420P,
AV_PIX_FMT_NONE
};
diff -Naur ffmpeg-1.2.3/libavcodec/Makefile ffmpeg-1.2.3.patch/libavcodec/Makefile
--- ffmpeg-1.2.3/libavcodec/Makefile 2013-08-27 02:13:44.000000000 +0200
+++ ffmpeg-1.2.3.patch/libavcodec/Makefile 2013-09-09 22:46:40.580852793 +0200
@@ -12,6 +12,7 @@
vdpau.h \
version.h \
xvmc.h \
+ xvba.h \
OBJS = allcodecs.o \
audioconvert.o \
@@ -73,6 +74,7 @@
OBJS-$(CONFIG_SINEWIN) += sinewin.o
OBJS-$(CONFIG_VAAPI) += vaapi.o
OBJS-$(CONFIG_VDPAU) += vdpau.o
+OBJS-$(CONFIG_XVBA) += xvba.o
OBJS-$(CONFIG_VIDEODSP) += videodsp.o
OBJS-$(CONFIG_VP3DSP) += vp3dsp.o
@@ -232,6 +234,7 @@
OBJS-$(CONFIG_H264_VDA_HWACCEL) += vda_h264.o
OBJS-$(CONFIG_H264_VDA_DECODER) += vda_h264_dec.o
OBJS-$(CONFIG_H264_VDPAU_HWACCEL) += vdpau_h264.o
+OBJS-$(CONFIG_H264_XVBA_HWACCEL) += xvba_h264.o
OBJS-$(CONFIG_HUFFYUV_DECODER) += huffyuv.o huffyuvdec.o
OBJS-$(CONFIG_HUFFYUV_ENCODER) += huffyuv.o huffyuvenc.o
OBJS-$(CONFIG_IAC_DECODER) += imc.o
@@ -295,6 +298,7 @@
OBJS-$(CONFIG_MPEG2_DXVA2_HWACCEL) += dxva2_mpeg2.o
OBJS-$(CONFIG_MPEG2_VAAPI_HWACCEL) += vaapi_mpeg2.o
OBJS-$(CONFIG_MPEG2_VDPAU_HWACCEL) += vdpau_mpeg12.o
+OBJS-$(CONFIG_MPEG2_XVBA_HWACCEL) += xvba_mpeg2.o
OBJS-$(CONFIG_MPEG2VIDEO_DECODER) += mpeg12.o mpeg12data.o
OBJS-$(CONFIG_MPEG2VIDEO_ENCODER) += mpeg12enc.o mpeg12.o \
timecode.o
@@ -459,6 +463,7 @@
OBJS-$(CONFIG_VC1_DXVA2_HWACCEL) += dxva2_vc1.o
OBJS-$(CONFIG_VC1_VAAPI_HWACCEL) += vaapi_vc1.o
OBJS-$(CONFIG_VC1_VDPAU_HWACCEL) += vdpau_vc1.o
+OBJS-$(CONFIG_VC1_XVBA_HWACCEL) += xvba_vc1.o
OBJS-$(CONFIG_VCR1_DECODER) += vcr1.o
OBJS-$(CONFIG_VMDAUDIO_DECODER) += vmdav.o
OBJS-$(CONFIG_VMDVIDEO_DECODER) += vmdav.o
@@ -788,6 +793,7 @@
SKIPHEADERS-$(CONFIG_LIBUTVIDEO) += libutvideo.h
SKIPHEADERS-$(CONFIG_MPEG_XVMC_DECODER) += xvmc.h
SKIPHEADERS-$(CONFIG_VAAPI) += vaapi_internal.h
+SKIPHEADERS-$(CONFIG_XVBA) += xvba_internal.h
SKIPHEADERS-$(CONFIG_VDA) += vda.h
SKIPHEADERS-$(CONFIG_VDPAU) += vdpau.h
SKIPHEADERS-$(HAVE_OS2THREADS) += os2threads.h
diff -Naur ffmpeg-1.2.3/libavcodec/xvba.c ffmpeg-1.2.3.patch/libavcodec/xvba.c
--- ffmpeg-1.2.3/libavcodec/xvba.c 1970-01-01 01:00:00.000000000 +0100
+++ ffmpeg-1.2.3.patch/libavcodec/xvba.c 2013-09-09 22:46:40.580852793 +0200
@@ -0,0 +1,66 @@
+/*
+ * 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 "xvba_internal.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 uint8_t *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++;
+}
+
diff -Naur ffmpeg-1.2.3/libavcodec/xvba.h ffmpeg-1.2.3.patch/libavcodec/xvba.h
--- ffmpeg-1.2.3/libavcodec/xvba.h 1970-01-01 01:00:00.000000000 +0100
+++ ffmpeg-1.2.3.patch/libavcodec/xvba.h 2013-09-09 22:46:40.581852794 +0200
@@ -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;
+ unsigned int num_slices;
+ struct xvba_bitstream_buffers *buffers;
+ uint32_t buffers_alllocated;
+};
+
+#endif /* AVCODEC_XVBA_H */
diff -Naur ffmpeg-1.2.3/libavcodec/xvba_h264.c ffmpeg-1.2.3.patch/libavcodec/xvba_h264.c
--- ffmpeg-1.2.3/libavcodec/xvba_h264.c 1970-01-01 01:00:00.000000000 +0100
+++ ffmpeg-1.2.3.patch/libavcodec/xvba_h264.c 2013-09-09 22:46:40.582852794 +0200
@@ -0,0 +1,192 @@
+/*
+ * H.264 HW decode acceleration through XVBA
+ *
+ * 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
+ */
+
+#include "xvba.h"
+#include "xvba_internal.h"
+#include "h264.h"
+#include <assert.h>
+
+/** @file
+ * This file implements the glue code between FFmpeg's and XvBA API's
+ * structures for H.264 decoding.
+ */
+
+
+/** Initialize and start decoding a frame with XVBA. */
+static int start_frame(AVCodecContext *avctx,
+ av_unused const uint8_t *buffer,
+ av_unused uint32_t size)
+{
+ H264Context * const h = avctx->priv_data;
+ struct xvba_render_state *render;
+ XVBAPictureDescriptor *pic_descriptor;
+ int i;
+
+ render = (struct xvba_render_state *)h->cur_pic_ptr->f.data[0];
+ assert(render);
+
+ if (render->picture_descriptor == 0)
+ return -1;
+
+ pic_descriptor = render->picture_descriptor;
+
+ for (i = 0; i < 2; ++i) {
+ int foc = h->cur_pic_ptr->field_poc[i];
+ if (foc == INT_MAX)
+ foc = 0;
+ pic_descriptor->avc_curr_field_order_cnt_list[i] = foc;
+ }
+
+ pic_descriptor->avc_frame_num = h->frame_num;
+
+ render->num_slices = 0;
+
+ return 0;
+}
+
+/** End a hardware decoding based frame. */
+static int end_frame(AVCodecContext *avctx)
+{
+ H264Context * const h = avctx->priv_data;
+ struct xvba_render_state *render;
+ XVBAPictureDescriptor *pic_descriptor;
+ XVBAQuantMatrixAvc *iq_matrix;
+
+ render = (struct xvba_render_state *)h->cur_pic_ptr->f.data[0];
+ assert(render);
+
+ if (render->picture_descriptor == 0 || render->iq_matrix == 0)
+ return -1;
+
+ pic_descriptor = render->picture_descriptor;
+ iq_matrix = render->iq_matrix;
+
+ av_dlog(avctx, "end_frame()\n");
+
+ /* Fill in Picture Parameters*/
+ pic_descriptor->profile = ff_xvba_translate_profile(avctx->profile);
+ pic_descriptor->level = avctx->level;
+ pic_descriptor->width_in_mb = h->mb_width;
+ pic_descriptor->height_in_mb = h->mb_height;
+ pic_descriptor->picture_structure = h->picture_structure;
+ pic_descriptor->chroma_format = h->chroma_format_idc ? h->chroma_format_idc : 1;
+ pic_descriptor->avc_intra_flag = (h->slice_type == AV_PICTURE_TYPE_I) ? 1 : 0;
+ pic_descriptor->avc_reference = (h->cur_pic_ptr->f.reference & 3) ? 1 : 0;
+
+ pic_descriptor->avc_bit_depth_luma_minus8 = h->sps.bit_depth_luma - 8;
+ pic_descriptor->avc_bit_depth_chroma_minus8 = h->sps.bit_depth_chroma - 8;
+ pic_descriptor->avc_log2_max_frame_num_minus4 = h->sps.log2_max_frame_num -4;
+ pic_descriptor->avc_pic_order_cnt_type = h->sps.poc_type;
+ pic_descriptor->avc_log2_max_pic_order_cnt_lsb_minus4 = h->sps.log2_max_poc_lsb - 4;
+ pic_descriptor->avc_num_ref_frames = h->sps.ref_frame_count;
+ pic_descriptor->avc_reserved_8bit = 0;
+
+ /* Set a level that can decode stuff in every case without a lookup table
+ xvba seems to have problems only when the number of Reframes goes beyond
+ the max support number of Level4.1@High. So in praxis decoding a Level 3.0
+ file that in deed has level4.1@High specs does not matter. We use this fact
+ and check if the ref_frames stay in the range Level4.1@high can decode if
+ not, we set Level5.1 */
+ if (pic_descriptor->avc_num_ref_frames > 4) {
+ const unsigned int mbw = pic_descriptor->width_in_mb;
+ const unsigned int mbh = pic_descriptor->height_in_mb;
+ // this matches Level4.1@High stats to differ between <= 4.1 and 5.1
+ const unsigned int max_ref_frames = 12288 * 1024 / (mbw * mbh * 384);
+ const unsigned int num_ref_frames = pic_descriptor->avc_num_ref_frames;
+ if (max_ref_frames < num_ref_frames)
+ pic_descriptor->level = 51;
+ }
+
+ pic_descriptor->avc_num_slice_groups_minus1 = h->pps.slice_group_count - 1;
+ pic_descriptor->avc_num_ref_idx_l0_active_minus1 = h->pps.ref_count[0] - 1;
+ pic_descriptor->avc_num_ref_idx_l1_active_minus1 = h->pps.ref_count[1] - 1;
+
+ pic_descriptor->avc_pic_init_qp_minus26 = h->pps.init_qp - 26;
+ pic_descriptor->avc_pic_init_qs_minus26 = h->pps.init_qs - 26;
+ pic_descriptor->avc_chroma_qp_index_offset = h->pps.chroma_qp_index_offset[0];
+ pic_descriptor->avc_second_chroma_qp_index_offset = h->pps.chroma_qp_index_offset[1];
+ pic_descriptor->avc_slice_group_change_rate_minus1 = 0; // not implemented in ffmpeg
+ pic_descriptor->avc_reserved_16bit = 0; // must be 0
+ memset(pic_descriptor->avc_field_order_cnt_list,0,sizeof(pic_descriptor->avc_field_order_cnt_list)); // must be 0
+ memset(pic_descriptor->avc_slice_group_map,0,sizeof(pic_descriptor->avc_slice_group_map)); // must be 0
+
+ // sps
+ pic_descriptor->sps_info.avc.delta_pic_always_zero_flag = h->sps.delta_pic_order_always_zero_flag;
+ pic_descriptor->sps_info.avc.direct_8x8_inference_flag = h->sps.direct_8x8_inference_flag;
+ pic_descriptor->sps_info.avc.frame_mbs_only_flag = h->sps.frame_mbs_only_flag;
+ pic_descriptor->sps_info.avc.gaps_in_frame_num_value_allowed_flag = h->sps.gaps_in_frame_num_allowed_flag;
+ pic_descriptor->sps_info.avc.mb_adaptive_frame_field_flag = h->sps.mb_aff;
+ pic_descriptor->sps_info.avc.residual_colour_transform_flag = h->sps.residual_color_transform_flag;
+ pic_descriptor->sps_info.avc.xvba_avc_sps_reserved = 0;
+
+ // pps
+ pic_descriptor->pps_info.avc.entropy_coding_mode_flag = h->pps.cabac;
+ pic_descriptor->pps_info.avc.pic_order_present_flag = h->pps.pic_order_present;
+ pic_descriptor->pps_info.avc.weighted_pred_flag = h->pps.weighted_pred;
+ pic_descriptor->pps_info.avc.weighted_bipred_idc = h->pps.weighted_bipred_idc;
+ pic_descriptor->pps_info.avc.deblocking_filter_control_present_flag = h->pps.deblocking_filter_parameters_present;
+ pic_descriptor->pps_info.avc.constrained_intra_pred_flag = h->pps.constrained_intra_pred;
+ pic_descriptor->pps_info.avc.redundant_pic_cnt_present_flag = h->pps.redundant_pic_cnt_present;
+ pic_descriptor->pps_info.avc.transform_8x8_mode_flag = h->pps.transform_8x8_mode;
+ pic_descriptor->pps_info.avc.xvba_avc_pps_reserved = 0; // must be 0
+
+ memcpy(iq_matrix->bScalingLists4x4, h->pps.scaling_matrix4, sizeof(iq_matrix->bScalingLists4x4));
+ memcpy(iq_matrix->bScalingLists8x8[0], h->pps.scaling_matrix8[0], sizeof(iq_matrix->bScalingLists8x8[0]));
+ memcpy(iq_matrix->bScalingLists8x8[1], h->pps.scaling_matrix8[3], sizeof(iq_matrix->bScalingLists8x8[0]));
+
+ // Wait for an I-frame before start decoding. Workaround for ATI UVD and UVD+ GPUs
+ if (!h->got_first_iframe) {
+ if (h->slice_type != AV_PICTURE_TYPE_I && h->slice_type != AV_PICTURE_TYPE_SI)
+ return -1;
+ h->got_first_iframe = 1;
+ }
+
+ ff_draw_horiz_band(h->avctx, &h->dsp, h->cur_pic_ptr, NULL, 0, h->avctx->height, h->picture_structure, h->first_field, 0, 0, 0, 0);
+
+ return 0;
+}
+
+/** Decode the given H.264 slice with XVBA. */
+static int decode_slice(AVCodecContext *avctx,
+ const uint8_t *buffer,
+ uint32_t size)
+{
+ H264Context * const h = avctx->priv_data;
+ struct xvba_render_state *render;
+
+ render = (struct xvba_render_state *)h->cur_pic_ptr->f.data[0];
+ assert(render);
+
+ ff_xvba_add_slice_data(render, buffer, size);
+
+ return 0;
+}
+
+AVHWAccel ff_h264_xvba_hwaccel = {
+ .name = "h264_xvba",
+ .type = AVMEDIA_TYPE_VIDEO,
+ .id = CODEC_ID_H264,
+ .pix_fmt = AV_PIX_FMT_XVBA_VLD,
+ .start_frame = start_frame,
+ .end_frame = end_frame,
+ .decode_slice = decode_slice,
+};
diff -Naur ffmpeg-1.2.3/libavcodec/xvba_internal.h ffmpeg-1.2.3.patch/libavcodec/xvba_internal.h
--- ffmpeg-1.2.3/libavcodec/xvba_internal.h 1970-01-01 01:00:00.000000000 +0100
+++ ffmpeg-1.2.3.patch/libavcodec/xvba_internal.h 2013-09-09 22:46:40.582852794 +0200
@@ -0,0 +1,24 @@
+/*
+ * 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
+ */
+
+int ff_xvba_translate_profile(int profile);
+void ff_xvba_add_slice_data(struct xvba_render_state *render, const uint8_t *buffer, uint32_t size);
diff -Naur ffmpeg-1.2.3/libavcodec/xvba_mpeg2.c ffmpeg-1.2.3.patch/libavcodec/xvba_mpeg2.c
--- ffmpeg-1.2.3/libavcodec/xvba_mpeg2.c 1970-01-01 01:00:00.000000000 +0100
+++ ffmpeg-1.2.3.patch/libavcodec/xvba_mpeg2.c 2013-09-09 22:46:40.582852794 +0200
@@ -0,0 +1,52 @@
+/*
+ * MPEG-2 HW decode acceleration through XVBA
+ *
+ * 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
+ */
+
+#include "dsputil.h"
+
+static int start_frame(AVCodecContext *avctx, av_unused const uint8_t *buffer, av_unused uint32_t size)
+{
+ struct MpegEncContext * const s = avctx->priv_data;
+ return 0;
+}
+
+static int end_frame(AVCodecContext *avctx)
+{
+ return 0;
+}
+
+static int decode_slice(AVCodecContext *avctx, const uint8_t *buffer, uint32_t size)
+{
+ struct MpegEncContext * const s = avctx->priv_data;
+ return 0;
+}
+
+AVHWAccel ff_mpeg2_xvba_hwaccel = {
+ .name = "mpeg2_xvba",
+ .type = AVMEDIA_TYPE_VIDEO,
+ .id = CODEC_ID_MPEG2VIDEO,
+ .pix_fmt = AV_PIX_FMT_XVBA_VLD,
+ .capabilities = 0,
+ .start_frame = start_frame,
+ .end_frame = end_frame,
+ .decode_slice = decode_slice,
+ .priv_data_size = 0,
+};
diff -Naur ffmpeg-1.2.3/libavcodec/xvba_vc1.c ffmpeg-1.2.3.patch/libavcodec/xvba_vc1.c
--- ffmpeg-1.2.3/libavcodec/xvba_vc1.c 1970-01-01 01:00:00.000000000 +0100
+++ ffmpeg-1.2.3.patch/libavcodec/xvba_vc1.c 2013-09-09 22:46:40.583852794 +0200
@@ -0,0 +1,190 @@
+/*
+ * VC-1 HW decode acceleration through XVBA
+ *
+ * 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
+ */
+
+#include "xvba.h"
+#include "xvba_internal.h"
+#include "vc1.h"
+#include "vc1data.h"
+#include <assert.h>
+
+
+/** @file
+ * Implement structures of ffmpeg <-> XvBA
+ */
+
+/* Initialize and start decoding a frame with XvBA */
+static int start_frame(AVCodecContext *avctx,
+ av_unused const uint8_t *buffer,
+ av_unused uint32_t size)
+{
+ VC1Context * const v = avctx->priv_data;
+ MpegEncContext * const s = &v->s;
+ struct xvba_render_state *render;
+
+ render = (struct xvba_render_state *)s->current_picture_ptr->f.data[0];
+ assert(render);
+
+ render->num_slices = 0;
+ return 0;
+}
+
+/* End a hardware decoding based frame */
+static int end_frame(AVCodecContext *avctx)
+{
+ VC1Context* const v = avctx->priv_data;
+ MpegEncContext* const s = &v->s;
+ struct xvba_render_state *render, *last, *next;
+ XVBAPictureDescriptor *pic_descriptor;
+
+ render = (struct xvba_render_state *)s->current_picture_ptr->f.data[0];
+ assert(render);
+
+ if (render->picture_descriptor == 0)
+ return -1;
+
+ pic_descriptor = render->picture_descriptor;
+
+ av_dlog(avctx, "xvba_vc1_end_frame()\n");
+
+ memset(pic_descriptor, 0, sizeof(*pic_descriptor));
+
+ /* Fill in Parameters - for reference see AMD sdk documentation */
+ pic_descriptor->profile = ff_xvba_translate_profile(v->profile);
+ pic_descriptor->level = v->level;
+ //done like in va-driver and vaapi
+ if (v->profile == PROFILE_ADVANCED) {
+ pic_descriptor->width_in_mb = s->avctx->coded_width;
+ pic_descriptor->height_in_mb = s->avctx->coded_height;
+ } else {
+ pic_descriptor->width_in_mb = s->mb_width;
+ pic_descriptor->height_in_mb = s->mb_height;
+ }
+ pic_descriptor->picture_structure = s->picture_structure;
+ // xvba-video set this to 1 only 4:2:0 supported
+ // doc says: if not set, choose 1 - we try this
+ pic_descriptor->chroma_format = 1;
+ pic_descriptor->avc_intra_flag = s->pict_type == AV_PICTURE_TYPE_I || v->bi_type == 1;
+ pic_descriptor->avc_reference = (s->current_picture_ptr->f.reference & 3) ? 1 : 0;
+
+ // VC-1 explicit parameters see page 30 of sdk
+ // sps_info
+ pic_descriptor->sps_info.vc1.postprocflag = v->postprocflag;
+
+ // done as in vaapi
+ pic_descriptor->sps_info.vc1.pulldown = v->broadcast;
+ pic_descriptor->sps_info.vc1.interlace = v->interlace;
+ pic_descriptor->sps_info.vc1.tfcntrflag = v->tfcntrflag;
+ pic_descriptor->sps_info.vc1.finterpflag = v->finterpflag;
+ pic_descriptor->sps_info.vc1.reserved = 1;
+ // eventually check if this makes sense together with interlace
+ pic_descriptor->sps_info.vc1.psf = v->psf;
+ // what about if it is a frame (page 31)
+ // looked at xvba-driver
+ pic_descriptor->sps_info.vc1.second_field = !s->first_field;
+ pic_descriptor->sps_info.vc1.xvba_vc1_sps_reserved = 0;
+
+ // VC-1 explicit parameters see page 30 of sdk
+ // pps_info
+ pic_descriptor->pps_info.vc1.panscan_flag = v->panscanflag;
+ pic_descriptor->pps_info.vc1.refdist_flag = v->refdist_flag;
+ pic_descriptor->pps_info.vc1.loopfilter = s->loop_filter;
+ pic_descriptor->pps_info.vc1.fastuvmc = v->fastuvmc;
+ pic_descriptor->pps_info.vc1.extended_mv = v->extended_mv;
+ pic_descriptor->pps_info.vc1.dquant = v->dquant;
+ pic_descriptor->pps_info.vc1.vstransform = v->vstransform;
+ pic_descriptor->pps_info.vc1.overlap = v->overlap;
+ pic_descriptor->pps_info.vc1.quantizer = v->quantizer_mode;
+ pic_descriptor->pps_info.vc1.extended_dmv = v->extended_dmv;
+ pic_descriptor->pps_info.vc1.maxbframes = s->avctx->max_b_frames;
+ pic_descriptor->pps_info.vc1.rangered = (pic_descriptor->profile == PROFILE_SIMPLE) ? 0 : v->rangered;
+ pic_descriptor->pps_info.vc1.syncmarker = (pic_descriptor->profile == PROFILE_SIMPLE) ? 0 : s->resync_marker;
+ pic_descriptor->pps_info.vc1.multires = v->multires;
+ pic_descriptor->pps_info.vc1.reserved = 1;
+ pic_descriptor->pps_info.vc1.range_mapy_flag = v->range_mapy_flag;
+ pic_descriptor->pps_info.vc1.range_mapy = v->range_mapy;
+ pic_descriptor->pps_info.vc1.range_mapuv_flag = v->range_mapuv_flag;
+ pic_descriptor->pps_info.vc1.range_mapuv = v->range_mapuv;
+ pic_descriptor->pps_info.vc1.xvba_vc1_pps_reserved = 0;
+
+ pic_descriptor->past_surface = 0;
+ pic_descriptor->future_surface = 0;
+ switch (s->pict_type) {
+ case AV_PICTURE_TYPE_B:
+ next = (struct xvba_render_state *)s->next_picture.f.data[0];
+ assert(next);
+ if (next)
+ pic_descriptor->past_surface = next->surface;
+ // fall-through
+ case AV_PICTURE_TYPE_P:
+ last = (struct xvba_render_state *)s->last_picture.f.data[0];
+ assert(last);
+ if (last)
+ pic_descriptor->future_surface = last->surface;
+ break;
+ }
+
+ ff_draw_horiz_band(s->avctx, &s->dsp, s->current_picture_ptr, s->last_picture_ptr, 0, s->avctx->height, s->picture_structure, s->first_field, (s->unrestricted_mv && !s->intra_only), s->low_delay, s->v_edge_pos, s->h_edge_pos);
+
+ return 0;
+}
+
+static int decode_slice(AVCodecContext *avctx, const uint8_t *buffer, uint32_t size)
+{
+ VC1Context* const v = avctx->priv_data;
+ MpegEncContext* const s = &v->s;
+ struct xvba_render_state *render;
+
+ render = (struct xvba_render_state *)s->current_picture_ptr->f.data[0];
+ assert(render);
+
+ if (avctx->codec_id == CODEC_ID_VC1 &&
+ size >= 4 && IS_MARKER(AV_RB32(buffer))) {
+ buffer += 4;
+ size -= 4;
+ }
+
+ ff_xvba_add_slice_data(render, buffer, size);
+
+ return 0;
+}
+
+#if CONFIG_WMV3_XVBA_HWACCEL
+AVHWAccel ff_wmv3_xvba_hwaccel = {
+ .name = "wmv3_xvba",
+ .type = AVMEDIA_TYPE_VIDEO,
+ .id = CODEC_ID_WMV3,
+ .pix_fmt = AV_PIX_FMT_XVBA_VLD,
+ .start_frame = start_frame,
+ .end_frame = end_frame,
+ .decode_slice = decode_slice,
+};
+#endif
+
+AVHWAccel ff_vc1_xvba_hwaccel = {
+ .name = "vc1_xvba",
+ .type = AVMEDIA_TYPE_VIDEO,
+ .id = CODEC_ID_VC1,
+ .pix_fmt = AV_PIX_FMT_XVBA_VLD,
+ .start_frame = start_frame,
+ .end_frame = end_frame,
+ .decode_slice = decode_slice,
+};
diff -Naur ffmpeg-1.2.3/libavutil/pixdesc.c ffmpeg-1.2.3.patch/libavutil/pixdesc.c
--- ffmpeg-1.2.3/libavutil/pixdesc.c 2013-08-27 02:13:47.000000000 +0200
+++ ffmpeg-1.2.3.patch/libavutil/pixdesc.c 2013-09-09 22:46:40.584852795 +0200
@@ -1141,6 +1141,12 @@
.log2_chroma_h = 1,
.flags = PIX_FMT_HWACCEL,
},
+ [AV_PIX_FMT_XVBA_VLD] = {
+ .name = "xvba_vld",
+ .log2_chroma_w = 1,
+ .log2_chroma_h = 1,
+ .flags = PIX_FMT_HWACCEL,
+ },
[AV_PIX_FMT_YUV420P9LE] = {
.name = "yuv420p9le",
.nb_components = 3,
diff -Naur ffmpeg-1.2.3/libavutil/pixfmt.h ffmpeg-1.2.3.patch/libavutil/pixfmt.h
--- ffmpeg-1.2.3/libavutil/pixfmt.h 2013-08-27 02:13:47.000000000 +0200
+++ ffmpeg-1.2.3.patch/libavutil/pixfmt.h 2013-09-09 22:46:40.585852796 +0200
@@ -124,6 +124,7 @@
AV_PIX_FMT_VAAPI_MOCO, ///< HW acceleration through VA API at motion compensation entry-point, Picture.data[3] contains a vaapi_render_state struct which contains macroblocks as well as various fields extracted from headers
AV_PIX_FMT_VAAPI_IDCT, ///< HW acceleration through VA API at IDCT entry-point, Picture.data[3] contains a vaapi_render_state struct which contains fields extracted from headers
AV_PIX_FMT_VAAPI_VLD, ///< HW decoding through VA API, Picture.data[3] contains a vaapi_render_state struct which contains the bitstream of the slices as well as various fields extracted from headers
+ AV_PIX_FMT_XVBA_VLD, ///< HW decoding through xvba, Picture.data[3] contains a xvba_rander_state struct which contains the bitstream of the slices
AV_PIX_FMT_YUV420P16LE, ///< planar YUV 4:2:0, 24bpp, (1 Cr & Cb sample per 2x2 Y samples), little-endian
AV_PIX_FMT_YUV420P16BE, ///< planar YUV 4:2:0, 24bpp, (1 Cr & Cb sample per 2x2 Y samples), big-endian

View File

@ -1,39 +0,0 @@
From 53b61e3b71c358df2ca7605f8d8478878862ca07 Mon Sep 17 00:00:00 2001
From: fritsch <peter.fruehberger@gmail.com>
Date: Sat, 13 Apr 2013 11:30:39 +0200
Subject: [PATCH] XVBA: revisit draw functions
---
libavcodec/xvba_h264.c | 2 +-
libavcodec/xvba_vc1.c | 2 +-
2 files changed, 2 insertions(+), 2 deletions(-)
diff --git a/libavcodec/xvba_h264.c b/libavcodec/xvba_h264.c
index ae45f3a..309d928 100644
--- a/libavcodec/xvba_h264.c
+++ b/libavcodec/xvba_h264.c
@@ -160,7 +160,7 @@ static int end_frame(AVCodecContext *avctx)
h->got_first_iframe = 1;
}
- ff_draw_horiz_band(h->avctx, &h->dsp, h->cur_pic_ptr, NULL, 0, h->avctx->height, h->picture_structure, h->first_field, 0, 0, 0, 0);
+ ff_h264_draw_horiz_band(h, 0, h->avctx->height);
return 0;
}
diff --git a/libavcodec/xvba_vc1.c b/libavcodec/xvba_vc1.c
index bf3d9c2..ff35a28 100644
--- a/libavcodec/xvba_vc1.c
+++ b/libavcodec/xvba_vc1.c
@@ -142,7 +142,7 @@ static int end_frame(AVCodecContext *avctx)
break;
}
- ff_draw_horiz_band(s->avctx, &s->dsp, s->current_picture_ptr, s->last_picture_ptr, 0, s->avctx->height, s->picture_structure, s->first_field, (s->unrestricted_mv && !s->intra_only), s->low_delay, s->v_edge_pos, s->h_edge_pos);
+ ff_mpeg_draw_horiz_band(s, 0, s->avctx->height);
return 0;
}
--
1.8.1.5

View File

@ -1,13 +0,0 @@
diff --git a/libavutil/utils.c b/libavutil/utils.c
index fbfbc49..56a83a7 100644
--- a/libavutil/utils.c
+++ b/libavutil/utils.c
@@ -28,7 +28,7 @@
unsigned avutil_version(void)
{
- av_assert0(AV_PIX_FMT_VDA_VLD == 81); //check if the pix fmt enum has not had anything inserted or removed by mistake
+ av_assert0(AV_PIX_FMT_VDA_VLD == 82); //check if the pix fmt enum has not had anything inserted or removed by mistake
av_assert0(AV_SAMPLE_FMT_DBLP == 9);
av_assert0(AVMEDIA_TYPE_ATTACHMENT == 4);
av_assert0(AV_PICTURE_TYPE_BI == 7);

View File

@ -1,26 +0,0 @@
From af7027858d0b95dda461933ab6e02df4611378d9 Mon Sep 17 00:00:00 2001
From: fritsch <peter.fruehberger@gmail.com>
Date: Sat, 13 Apr 2013 12:06:02 +0200
Subject: [PATCH] (ffmpeg): Make XVBA codec available
---
libavcodec/vc1dec.c | 3 +++
1 file changed, 3 insertions(+)
diff --git a/libavcodec/vc1dec.c b/libavcodec/vc1dec.c
index 2130c74..4d611f9 100644
--- a/libavcodec/vc1dec.c
+++ b/libavcodec/vc1dec.c
@@ -5807,6 +5807,9 @@ static int vc1_decode_frame(AVCodecContext *avctx, void *data,
#if CONFIG_VDPAU
AV_PIX_FMT_VDPAU,
#endif
+#if CONFIG_XVBA
+ AV_PIX_FMT_XVBA_VLD,
+#endif
AV_PIX_FMT_YUV420P,
AV_PIX_FMT_NONE
};
--
1.8.1.5

View File

@ -1,26 +0,0 @@
From 7eadcd87bee856b71d98f5a02ab210fcb7b57311 Mon Sep 17 00:00:00 2001
From: fritsch <peter.fruehberger@gmail.com>
Date: Sat, 13 Apr 2013 16:38:50 +0200
Subject: [PATCH] ffmpeg: XVBA-VC1 use v->second_field instead of
!s->first_field to make VC1 interlaced working
---
libavcodec/xvba_vc1.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/libavcodec/xvba_vc1.c b/libavcodec/xvba_vc1.c
index ff35a28..04e7983 100644
--- a/libavcodec/xvba_vc1.c
+++ b/libavcodec/xvba_vc1.c
@@ -99,7 +99,7 @@ static int end_frame(AVCodecContext *avctx)
pic_descriptor->sps_info.vc1.psf = v->psf;
// what about if it is a frame (page 31)
// looked at xvba-driver
- pic_descriptor->sps_info.vc1.second_field = !s->first_field;
+ pic_descriptor->sps_info.vc1.second_field = v->second_field;
pic_descriptor->sps_info.vc1.xvba_vc1_sps_reserved = 0;
// VC-1 explicit parameters see page 30 of sdk
--
1.8.1.6

View File

@ -1,26 +0,0 @@
From 2b6cd6a04eb38e0ac210c6e5c70267dd12512295 Mon Sep 17 00:00:00 2001
From: fritsch <peter.fruehberger@gmail.com>
Date: Sat, 27 Apr 2013 17:36:15 +0200
Subject: [PATCH] XVBA: Only set second_field when we are interlaced and an
interlaced field
---
libavcodec/xvba_vc1.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/libavcodec/xvba_vc1.c b/libavcodec/xvba_vc1.c
index 04e7983..eb90c12 100644
--- a/libavcodec/xvba_vc1.c
+++ b/libavcodec/xvba_vc1.c
@@ -99,7 +99,7 @@ static int end_frame(AVCodecContext *avctx)
pic_descriptor->sps_info.vc1.psf = v->psf;
// what about if it is a frame (page 31)
// looked at xvba-driver
- pic_descriptor->sps_info.vc1.second_field = v->second_field;
+ pic_descriptor->sps_info.vc1.second_field = v->interlace && v->second_field && (v->fcm == ILACE_FIELD);
pic_descriptor->sps_info.vc1.xvba_vc1_sps_reserved = 0;
// VC-1 explicit parameters see page 30 of sdk
--
1.8.1.6

View File

@ -1,84 +0,0 @@
From e1c66a2726b0342bf8c166546838f72d3cfb26a8 Mon Sep 17 00:00:00 2001
From: fritsch <peter.fruehberger@gmail.com>
Date: Sat, 27 Apr 2013 22:08:50 +0200
Subject: [PATCH] xvba: translate picture_structure to a value xvba understands
---
libavcodec/xvba.c | 11 +++++++++++
libavcodec/xvba_h264.c | 4 +++-
libavcodec/xvba_internal.h | 1 +
libavcodec/xvba_vc1.c | 4 +++-
4 files changed, 18 insertions(+), 2 deletions(-)
diff --git a/libavcodec/xvba.c b/libavcodec/xvba.c
index be29e5d..566922e 100644
--- a/libavcodec/xvba.c
+++ b/libavcodec/xvba.c
@@ -31,6 +31,7 @@
#include "xvba.h"
#include "xvba_internal.h"
#include "avcodec.h"
+#include "mpegvideo.h"
int ff_xvba_translate_profile(int profile) {
@@ -50,6 +51,16 @@ int ff_xvba_translate_profile(int profile) {
return -1;
}
+// See page 25 of the documentation
+int ff_xvba_translate_picture_structure(int picture_structure) {
+ if(picture_structure == PICT_TOP_FIELD)
+ return 0;
+ else if (picture_structure == PICT_BOTTOM_FIELD)
+ return 1;
+ else //PICT_FRAME by default
+ return 3;
+}
+
void ff_xvba_add_slice_data(struct xvba_render_state *render, const uint8_t *buffer, uint32_t size) {
render->buffers = av_fast_realloc(
diff --git a/libavcodec/xvba_h264.c b/libavcodec/xvba_h264.c
index 309d928..20ba2f2 100644
--- a/libavcodec/xvba_h264.c
+++ b/libavcodec/xvba_h264.c
@@ -87,7 +87,9 @@ static int end_frame(AVCodecContext *avctx)
pic_descriptor->level = avctx->level;
pic_descriptor->width_in_mb = h->mb_width;
pic_descriptor->height_in_mb = h->mb_height;
- pic_descriptor->picture_structure = h->picture_structure;
+
+ pic_descriptor->picture_structure = ff_xvba_translate_picture_structure(h->picture_structure);
+
pic_descriptor->chroma_format = h->chroma_format_idc ? h->chroma_format_idc : 1;
pic_descriptor->avc_intra_flag = (h->slice_type == AV_PICTURE_TYPE_I) ? 1 : 0;
pic_descriptor->avc_reference = (h->cur_pic_ptr->f.reference & 3) ? 1 : 0;
diff --git a/libavcodec/xvba_internal.h b/libavcodec/xvba_internal.h
index 9653f85..18faa3e 100644
--- a/libavcodec/xvba_internal.h
+++ b/libavcodec/xvba_internal.h
@@ -21,4 +21,5 @@
*/
int ff_xvba_translate_profile(int profile);
+int ff_xvba_translate_picture_structure(int picture_structure);
void ff_xvba_add_slice_data(struct xvba_render_state *render, const uint8_t *buffer, uint32_t size);
diff --git a/libavcodec/xvba_vc1.c b/libavcodec/xvba_vc1.c
index eb90c12..c98dba5 100644
--- a/libavcodec/xvba_vc1.c
+++ b/libavcodec/xvba_vc1.c
@@ -78,7 +78,9 @@ static int end_frame(AVCodecContext *avctx)
pic_descriptor->width_in_mb = s->mb_width;
pic_descriptor->height_in_mb = s->mb_height;
}
- pic_descriptor->picture_structure = s->picture_structure;
+
+ pic_descriptor->picture_structure = ff_xvba_translate_picture_structure(s->picture_structure);
+
// xvba-video set this to 1 only 4:2:0 supported
// doc says: if not set, choose 1 - we try this
pic_descriptor->chroma_format = 1;
--
1.8.1.6

View File

@ -1,54 +0,0 @@
From 4474d708a96a2488f346a323cc79e6597c9326bf Mon Sep 17 00:00:00 2001
From: xbmc <fernetmenta@online.de>
Date: Tue, 30 Apr 2013 21:18:55 +0200
Subject: [PATCH] ffmpeg xvba: fix vc1 field interlace
---
lib/ffmpeg/libavcodec/xvba.c | 4 ++--
libavcodec/xvba.h | 1 +
libavcodec/xvba_vc1.c | 1 +
3 files changed, 4 insertions(+), 2 deletions(-)
diff --git a/libavcodec/xvba.c b/libavcodec/xvba.c
index 566922e..c6ff2fe 100644
--- a/libavcodec/xvba.c
+++ b/libavcodec/xvba.c
@@ -53,9 +53,9 @@ int ff_xvba_translate_profile(int profile) {
// See page 25 of the documentation
int ff_xvba_translate_picture_structure(int picture_structure) {
- if(picture_structure == PICT_TOP_FIELD)
+ if(picture_structure == PICT_BOTTOM_FIELD)
return 0;
- else if (picture_structure == PICT_BOTTOM_FIELD)
+ else if (picture_structure == PICT_TOP_FIELD)
return 1;
else //PICT_FRAME by default
return 3;
diff --git a/libavcodec/xvba.h b/libavcodec/xvba.h
index 9f9ff0c..e590faf 100644
--- a/libavcodec/xvba.h
+++ b/libavcodec/xvba.h
@@ -66,6 +66,7 @@ struct xvba_render_state {
unsigned int num_slices;
struct xvba_bitstream_buffers *buffers;
uint32_t buffers_alllocated;
+ int psf;
};
#endif /* AVCODEC_XVBA_H */
diff --git a/libavcodec/xvba_vc1.c b/libavcodec/xvba_vc1.c
index c98dba5..e7a85a7 100644
--- a/libavcodec/xvba_vc1.c
+++ b/libavcodec/xvba_vc1.c
@@ -143,6 +143,7 @@ static int end_frame(AVCodecContext *avctx)
pic_descriptor->future_surface = last->surface;
break;
}
+ render->psf = v->psf;
ff_mpeg_draw_horiz_band(s, 0, s->avctx->height);
--
1.8.1.6