Ticket #1009: ffmpeg-1.0.4-xvba_support.patch
| File ffmpeg-1.0.4-xvba_support.patch, 33.4 KB (added by , 13 years ago) |
|---|
-
ffmpeg-1.0.4
diff -Naur ffmpeg-1.0.4.old/configure ffmpeg-1.0.4/configure
old new 132 132 --disable-fft disable FFT code 133 133 --enable-dxva2 enable DXVA2 code 134 134 --enable-vaapi enable VAAPI code [autodetect] 135 --enable-xvba enable XVBA code [autodetect] 135 136 --enable-vda enable VDA code [autodetect] 136 137 --enable-vdpau enable VDPAU code [autodetect] 137 138 … … 1172 1173 swscale_alpha 1173 1174 thumb 1174 1175 vaapi 1176 xvba 1175 1177 vda 1176 1178 vdpau 1177 1179 version3 … … 1616 1618 h264_dxva2_hwaccel_deps="dxva2api_h" 1617 1619 h264_dxva2_hwaccel_select="dxva2 h264_decoder" 1618 1620 h264_vaapi_hwaccel_select="vaapi h264_decoder" 1621 h264_xvba_hwaccel_select="xvba h264_decoder" 1619 1622 h264_vda_decoder_select="vda h264_parser h264_decoder" 1620 1623 h264_vda_hwaccel_deps="VideoDecodeAcceleration_VDADecoder_h pthreads" 1621 1624 h264_vda_hwaccel_select="vda h264_decoder" … … 1654 1657 mpeg2_dxva2_hwaccel_select="dxva2 mpeg2video_decoder" 1655 1658 mpeg2_vdpau_hwaccel_select="vdpau mpeg2video_decoder" 1656 1659 mpeg2_vaapi_hwaccel_select="vaapi mpeg2video_decoder" 1660 mpeg2_xvba_hwaccel_select="xvba mpeg2video_decoder" 1657 1661 mpeg2video_decoder_select="error_resilience mpegvideo" 1658 1662 mpeg2video_encoder_select="aandcttables error_resilience mpegvideoenc" 1659 1663 mpeg4_crystalhd_decoder_select="crystalhd" … … 1706 1710 vc1_dxva2_hwaccel_deps="dxva2api_h" 1707 1711 vc1_dxva2_hwaccel_select="dxva2 vc1_decoder" 1708 1712 vc1_vaapi_hwaccel_select="vaapi vc1_decoder" 1713 vc1_xvba_hwaccel_select="xvba vc1_decoder" 1709 1714 vc1_vdpau_decoder_select="vdpau vc1_decoder" 1710 1715 vc1image_decoder_select="vc1_decoder" 1711 1716 vorbis_decoder_select="mdct" … … 1730 1735 wmv3_crystalhd_decoder_select="crystalhd" 1731 1736 wmv3_dxva2_hwaccel_select="vc1_dxva2_hwaccel" 1732 1737 wmv3_vaapi_hwaccel_select="vc1_vaapi_hwaccel" 1738 wmv3_xvba_hwaccel_select="vc1_xvba_hwaccel" 1733 1739 wmv3_vdpau_decoder_select="vc1_vdpau_decoder" 1734 1740 wmv3image_decoder_select="wmv3_decoder" 1735 1741 zerocodec_decoder_select="zlib" … … 1740 1746 1741 1747 crystalhd_deps="libcrystalhd_libcrystalhd_if_h" 1742 1748 vaapi_deps="va_va_h" 1749 xvba_deps="amdxvba_h" 1743 1750 vda_deps="VideoDecodeAcceleration_VDADecoder_h pthreads" 1744 1751 vdpau_deps="vdpau_vdpau_h vdpau_vdpau_x11_h" 1745 1752 … … 3558 3565 check_header unistd.h 3559 3566 check_header vdpau/vdpau.h 3560 3567 check_header vdpau/vdpau_x11.h 3568 check_header amd/amdxvba.h 3561 3569 check_header windows.h 3562 3570 check_header X11/extensions/XvMClib.h 3563 3571 check_header asm/types.h … … 3611 3619 check_lib math.h sin -lm && LIBM="-lm" 3612 3620 disabled crystalhd || check_lib libcrystalhd/libcrystalhd_if.h DtsCrystalHDVersion -lcrystalhd || disable crystalhd 3613 3621 enabled vaapi && require vaapi va/va.h vaInitialize -lva 3622 #enabled xvba && require xvba amd/amdxvba.h 3614 3623 3615 3624 check_mathfunc cbrtf 3616 3625 check_mathfunc exp2 … … 4026 4035 echo "SDL support ${sdl-no}" 4027 4036 echo "libdxva2 enabled ${dxva2-no}" 4028 4037 echo "libva enabled ${vaapi-no}" 4038 echo "xvba enabled ${xvba-no}" 4029 4039 echo "libvdpau enabled ${vdpau-no}" 4030 4040 echo "AVISynth enabled ${avisynth-no}" 4031 4041 echo "frei0r enabled ${frei0r-no}" -
libavcodec/allcodecs.c
diff -Naur ffmpeg-1.0.4.old/libavcodec/allcodecs.c ffmpeg-1.0.4/libavcodec/allcodecs.c
old new 58 58 REGISTER_HWACCEL (H263_VAAPI, h263_vaapi); 59 59 REGISTER_HWACCEL (H264_DXVA2, h264_dxva2); 60 60 REGISTER_HWACCEL (H264_VAAPI, h264_vaapi); 61 REGISTER_HWACCEL (H264_XVBA, h264_xvba); 61 62 REGISTER_HWACCEL (H264_VDA, h264_vda); 62 63 REGISTER_HWACCEL (MPEG1_VDPAU, mpeg1_vdpau); 63 64 REGISTER_HWACCEL (MPEG2_DXVA2, mpeg2_dxva2); 64 65 REGISTER_HWACCEL (MPEG2_VAAPI, mpeg2_vaapi); 66 REGISTER_HWACCEL (MPEG2_XVBA, mpeg2_xvba); 65 67 REGISTER_HWACCEL (MPEG2_VDPAU, mpeg2_vdpau); 66 68 REGISTER_HWACCEL (MPEG4_VAAPI, mpeg4_vaapi); 67 69 REGISTER_HWACCEL (VC1_DXVA2, vc1_dxva2); 68 70 REGISTER_HWACCEL (VC1_VAAPI, vc1_vaapi); 71 REGISTER_HWACCEL (VC1_XVBA, vc1_xvba); 69 72 REGISTER_HWACCEL (WMV3_DXVA2, wmv3_dxva2); 70 73 REGISTER_HWACCEL (WMV3_VAAPI, wmv3_vaapi); 74 REGISTER_HWACCEL (WMV3_XVBA, wmv3_xvba); 71 75 72 76 /* video codecs */ 73 77 REGISTER_ENCODER (A64MULTI, a64multi); -
libavcodec/h264.c
diff -Naur ffmpeg-1.0.4.old/libavcodec/h264.c ffmpeg-1.0.4/libavcodec/h264.c
old new 69 69 static const enum PixelFormat hwaccel_pixfmt_list_h264_jpeg_420[] = { 70 70 PIX_FMT_DXVA2_VLD, 71 71 PIX_FMT_VAAPI_VLD, 72 PIX_FMT_XVBA_VLD, 72 73 PIX_FMT_VDA_VLD, 73 74 PIX_FMT_YUVJ420P, 74 75 PIX_FMT_NONE -
libavcodec/Makefile
diff -Naur ffmpeg-1.0.4.old/libavcodec/Makefile ffmpeg-1.0.4/libavcodec/Makefile
old new 12 12 vdpau.h \ 13 13 version.h \ 14 14 xvmc.h \ 15 xvba.h \ 15 16 16 17 OBJS = allcodecs.o \ 17 18 audioconvert.o \ … … 66 67 OBJS-$(CONFIG_SINEWIN) += sinewin.o 67 68 OBJS-$(CONFIG_VAAPI) += vaapi.o 68 69 OBJS-$(CONFIG_VDPAU) += vdpau.o 70 OBJS-$(CONFIG_XVBA) += xvba.o 69 71 OBJS-$(CONFIG_VP3DSP) += vp3dsp.o 70 72 71 73 # decoders/encoders/hardware accelerators … … 216 218 h264_refs.o h264_cavlc.o h264_cabac.o 217 219 OBJS-$(CONFIG_H264_DXVA2_HWACCEL) += dxva2_h264.o 218 220 OBJS-$(CONFIG_H264_VAAPI_HWACCEL) += vaapi_h264.o 221 OBJS-$(CONFIG_H264_XVBA_HWACCEL) += xvba_h264.o 219 222 OBJS-$(CONFIG_H264_VDA_HWACCEL) += vda_h264.o 220 223 OBJS-$(CONFIG_H264_VDA_DECODER) += vda_h264_dec.o 221 224 OBJS-$(CONFIG_HUFFYUV_DECODER) += huffyuv.o … … 291 294 timecode.o 292 295 OBJS-$(CONFIG_MPEG2_DXVA2_HWACCEL) += dxva2_mpeg2.o 293 296 OBJS-$(CONFIG_MPEG2_VAAPI_HWACCEL) += vaapi_mpeg2.o 297 OBJS-$(CONFIG_MPEG2_XVBA_HWACCEL) += xvba_mpeg2.o 294 298 OBJS-$(CONFIG_MPEG2VIDEO_DECODER) += mpeg12.o mpeg12data.o 295 299 OBJS-$(CONFIG_MPEG2VIDEO_ENCODER) += mpeg12enc.o mpeg12.o \ 296 300 timecode.o … … 446 450 intrax8.o intrax8dsp.o 447 451 OBJS-$(CONFIG_VC1_DXVA2_HWACCEL) += dxva2_vc1.o 448 452 OBJS-$(CONFIG_VC1_VAAPI_HWACCEL) += vaapi_vc1.o 453 OBJS-$(CONFIG_VC1_XVBA_HWACCEL) += xvba_vc1.o 449 454 OBJS-$(CONFIG_VCR1_DECODER) += vcr1.o 450 455 OBJS-$(CONFIG_VCR1_ENCODER) += vcr1.o 451 456 OBJS-$(CONFIG_VMDAUDIO_DECODER) += vmdav.o … … 767 772 SKIPHEADERS-$(CONFIG_LIBUTVIDEO) += libutvideo.h 768 773 SKIPHEADERS-$(CONFIG_MPEG_XVMC_DECODER) += xvmc.h 769 774 SKIPHEADERS-$(CONFIG_VAAPI) += vaapi_internal.h 775 SKIPHEADERS-$(CONFIG_XVBA) += xvba_internal.h 770 776 SKIPHEADERS-$(CONFIG_VDA) += vda.h 771 777 SKIPHEADERS-$(CONFIG_VDPAU) += vdpau.h 772 778 SKIPHEADERS-$(HAVE_OS2THREADS) += os2threads.h -
libavcodec/mpegvideo.c
diff -Naur ffmpeg-1.0.4.old/libavcodec/mpegvideo.c ffmpeg-1.0.4/libavcodec/mpegvideo.c
old new 133 133 const enum PixelFormat ff_hwaccel_pixfmt_list_420[] = { 134 134 PIX_FMT_DXVA2_VLD, 135 135 PIX_FMT_VAAPI_VLD, 136 PIX_FMT_XVBA_VLD, 136 137 PIX_FMT_VDA_VLD, 137 138 PIX_FMT_YUV420P, 138 139 PIX_FMT_NONE -
libavcodec/xvba.c
diff -Naur ffmpeg-1.0.4.old/libavcodec/xvba.c ffmpeg-1.0.4/libavcodec/xvba.c
old new 1 /* 2 * HW decode acceleration for MPEG-2, H.264 and VC-1 3 * 4 * Copyright (C) 2005-2011 Team XBMC 5 * 6 * This file is part of FFmpeg. 7 * 8 * FFmpeg is free software; you can redistribute it and/or 9 * modify it under the terms of the GNU Lesser General Public 10 * License as published by the Free Software Foundation; either 11 * version 2.1 of the License, or (at your option) any later version. 12 * 13 * FFmpeg is distributed in the hope that it will be useful, 14 * but WITHOUT ANY WARRANTY; without even the implied warranty of 15 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 16 * Lesser General Public License for more details. 17 * 18 * You should have received a copy of the GNU Lesser General Public 19 * License along with FFmpeg; if not, write to the Free Software 20 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA 21 */ 22 23 24 /** 25 * \addtogroup XVBA_Decoding 26 * 27 * @{ 28 */ 29 30 #include <stdint.h> 31 #include "xvba.h" 32 #include "xvba_internal.h" 33 #include "avcodec.h" 34 35 int ff_xvba_translate_profile(int profile) { 36 37 if (profile == 66) 38 return 1; 39 else if (profile == 77) 40 return 2; 41 else if (profile == 100) 42 return 3; 43 else if (profile == 0) 44 return 4; 45 else if (profile == 1) 46 return 5; 47 else if (profile == 3) 48 return 6; 49 else 50 return -1; 51 } 52 53 void ff_xvba_add_slice_data(struct xvba_render_state *render, const uint8_t *buffer, uint32_t size) { 54 55 render->buffers = av_fast_realloc( 56 render->buffers, 57 &render->buffers_alllocated, 58 sizeof(struct xvba_bitstream_buffers)*(render->num_slices + 1) 59 ); 60 61 render->buffers[render->num_slices].buffer = buffer; 62 render->buffers[render->num_slices].size = size; 63 64 render->num_slices++; 65 } 66 -
libavcodec/xvba.h
diff -Naur ffmpeg-1.0.4.old/libavcodec/xvba.h ffmpeg-1.0.4/libavcodec/xvba.h
old new 1 /* 2 * HW decode acceleration for MPEG-2, H.264 and VC-1 3 * 4 * Copyright (C) 2005-2011 Team XBMC 5 * 6 * This file is part of FFmpeg. 7 * 8 * FFmpeg is free software; you can redistribute it and/or 9 * modify it under the terms of the GNU Lesser General Public 10 * License as published by the Free Software Foundation; either 11 * version 2.1 of the License, or (at your option) any later version. 12 * 13 * FFmpeg is distributed in the hope that it will be useful, 14 * but WITHOUT ANY WARRANTY; without even the implied warranty of 15 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 16 * Lesser General Public License for more details. 17 * 18 * You should have received a copy of the GNU Lesser General Public 19 * License along with FFmpeg; if not, write to the Free Software 20 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA 21 */ 22 23 #ifndef AVCODEC_XVBA_H 24 #define AVCODEC_XVBA_H 25 26 #include <stdint.h> 27 #include <X11/Xlib.h> 28 #include <amd/amdxvba.h> 29 30 31 /** 32 * \defgroup XVBA_Decoding VA API Decoding 33 * \ingroup Decoder 34 * @{ 35 */ 36 37 /** \brief The videoSurface is used for rendering. */ 38 #define FF_XVBA_STATE_USED_FOR_RENDER 1 39 40 /** 41 * \brief The videoSurface is needed for reference/prediction. 42 * The codec manipulates this. 43 */ 44 #define FF_XVBA_STATE_USED_FOR_REFERENCE 2 45 46 /** 47 * \brief The videoSurface holds a decoded frame. 48 * The codec manipulates this. 49 */ 50 #define FF_XVBA_STATE_DECODED 4 51 52 /* @} */ 53 54 struct xvba_bitstream_buffers 55 { 56 const void *buffer; 57 unsigned int size; 58 }; 59 60 struct xvba_render_state { 61 62 int state; ///< Holds FF_XVBA_STATE_* values. 63 void *surface; 64 XVBAPictureDescriptor *picture_descriptor; 65 XVBAQuantMatrixAvc *iq_matrix; 66 unsigned int num_slices; 67 struct xvba_bitstream_buffers *buffers; 68 uint32_t buffers_alllocated; 69 }; 70 71 #endif /* AVCODEC_XVBA_H */ -
libavcodec/xvba_h264.c
diff -Naur ffmpeg-1.0.4.old/libavcodec/xvba_h264.c ffmpeg-1.0.4/libavcodec/xvba_h264.c
old new 1 /* 2 * H.264 HW decode acceleration through XVBA 3 * 4 * Copyright (C) 2005-2011 Team XBMC 5 * 6 * This file is part of FFmpeg. 7 * 8 * FFmpeg is free software; you can redistribute it and/or 9 * modify it under the terms of the GNU Lesser General Public 10 * License as published by the Free Software Foundation; either 11 * version 2.1 of the License, or (at your option) any later version. 12 * 13 * FFmpeg is distributed in the hope that it will be useful, 14 * but WITHOUT ANY WARRANTY; without even the implied warranty of 15 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 16 * Lesser General Public License for more details. 17 * 18 * You should have received a copy of the GNU Lesser General Public 19 * License along with FFmpeg; if not, write to the Free Software 20 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA 21 */ 22 23 #include "xvba.h" 24 #include "xvba_internal.h" 25 #include "h264.h" 26 #include <assert.h> 27 28 /** @file 29 * This file implements the glue code between FFmpeg's and XvBA API's 30 * structures for H.264 decoding. 31 */ 32 33 34 /** Initialize and start decoding a frame with XVBA. */ 35 static int start_frame(AVCodecContext *avctx, 36 av_unused const uint8_t *buffer, 37 av_unused uint32_t size) 38 { 39 H264Context * const h = avctx->priv_data; 40 MpegEncContext * const s = &h->s; 41 struct xvba_render_state *render; 42 XVBAPictureDescriptor *pic_descriptor; 43 int i; 44 45 render = (struct xvba_render_state *)s->current_picture_ptr->f.data[0]; 46 assert(render); 47 48 if (render->picture_descriptor == 0) 49 return -1; 50 51 pic_descriptor = render->picture_descriptor; 52 53 for (i = 0; i < 2; ++i) { 54 int foc = s->current_picture_ptr->field_poc[i]; 55 if (foc == INT_MAX) 56 foc = 0; 57 pic_descriptor->avc_curr_field_order_cnt_list[i] = foc; 58 } 59 60 pic_descriptor->avc_frame_num = h->frame_num; 61 62 render->num_slices = 0; 63 64 return 0; 65 } 66 67 /** End a hardware decoding based frame. */ 68 static int end_frame(AVCodecContext *avctx) 69 { 70 H264Context * const h = avctx->priv_data; 71 MpegEncContext * const s = &h->s; 72 struct xvba_render_state *render; 73 XVBAPictureDescriptor *pic_descriptor; 74 XVBAQuantMatrixAvc *iq_matrix; 75 76 render = (struct xvba_render_state *)s->current_picture_ptr->f.data[0]; 77 assert(render); 78 79 if (render->picture_descriptor == 0 || render->iq_matrix == 0) 80 return -1; 81 82 pic_descriptor = render->picture_descriptor; 83 iq_matrix = render->iq_matrix; 84 85 av_dlog(avctx, "end_frame()\n"); 86 87 /* Fill in Picture Parameters*/ 88 pic_descriptor->profile = ff_xvba_translate_profile(avctx->profile); 89 pic_descriptor->level = avctx->level; 90 pic_descriptor->width_in_mb = s->mb_width; 91 pic_descriptor->height_in_mb = s->mb_height; 92 pic_descriptor->picture_structure = s->picture_structure; 93 pic_descriptor->chroma_format = s->chroma_format ? s->chroma_format : 1; 94 pic_descriptor->avc_intra_flag = (h->slice_type == AV_PICTURE_TYPE_I) ? 1 : 0; 95 pic_descriptor->avc_reference = (s->current_picture_ptr->f.reference & 3) ? 1 : 0; 96 97 pic_descriptor->avc_bit_depth_luma_minus8 = h->sps.bit_depth_luma - 8; 98 pic_descriptor->avc_bit_depth_chroma_minus8 = h->sps.bit_depth_chroma - 8; 99 pic_descriptor->avc_log2_max_frame_num_minus4 = h->sps.log2_max_frame_num -4; 100 pic_descriptor->avc_pic_order_cnt_type = h->sps.poc_type; 101 pic_descriptor->avc_log2_max_pic_order_cnt_lsb_minus4 = h->sps.log2_max_poc_lsb - 4; 102 pic_descriptor->avc_num_ref_frames = h->sps.ref_frame_count; 103 pic_descriptor->avc_reserved_8bit = 0; 104 105 /* Set a level that can decode stuff in every case without a lookup table 106 xvba seems to have problems only when the number of Reframes goes beyond 107 the max support number of Level4.1@High. So in praxis decoding a Level 3.0 108 file that in deed has level4.1@High specs does not matter. We use this fact 109 and check if the ref_frames stay in the range Level4.1@high can decode if 110 not, we set Level5.1 */ 111 if (pic_descriptor->avc_num_ref_frames > 4) { 112 const unsigned int mbw = pic_descriptor->width_in_mb; 113 const unsigned int mbh = pic_descriptor->height_in_mb; 114 // this matches Level4.1@High stats to differ between <= 4.1 and 5.1 115 const unsigned int max_ref_frames = 12288 * 1024 / (mbw * mbh * 384); 116 const unsigned int num_ref_frames = pic_descriptor->avc_num_ref_frames; 117 if (max_ref_frames < num_ref_frames) 118 pic_descriptor->level = 51; 119 } 120 121 pic_descriptor->avc_num_slice_groups_minus1 = h->pps.slice_group_count - 1; 122 pic_descriptor->avc_num_ref_idx_l0_active_minus1 = h->pps.ref_count[0] - 1; 123 pic_descriptor->avc_num_ref_idx_l1_active_minus1 = h->pps.ref_count[1] - 1; 124 125 pic_descriptor->avc_pic_init_qp_minus26 = h->pps.init_qp - 26; 126 pic_descriptor->avc_pic_init_qs_minus26 = h->pps.init_qs - 26; 127 pic_descriptor->avc_chroma_qp_index_offset = h->pps.chroma_qp_index_offset[0]; 128 pic_descriptor->avc_second_chroma_qp_index_offset = h->pps.chroma_qp_index_offset[1]; 129 pic_descriptor->avc_slice_group_change_rate_minus1 = 0; // not implemented in ffmpeg 130 pic_descriptor->avc_reserved_16bit = 0; // must be 0 131 memset(pic_descriptor->avc_field_order_cnt_list,0,sizeof(pic_descriptor->avc_field_order_cnt_list)); // must be 0 132 memset(pic_descriptor->avc_slice_group_map,0,sizeof(pic_descriptor->avc_slice_group_map)); // must be 0 133 134 // sps 135 pic_descriptor->sps_info.avc.delta_pic_always_zero_flag = h->sps.delta_pic_order_always_zero_flag; 136 pic_descriptor->sps_info.avc.direct_8x8_inference_flag = h->sps.direct_8x8_inference_flag; 137 pic_descriptor->sps_info.avc.frame_mbs_only_flag = h->sps.frame_mbs_only_flag; 138 pic_descriptor->sps_info.avc.gaps_in_frame_num_value_allowed_flag = h->sps.gaps_in_frame_num_allowed_flag; 139 pic_descriptor->sps_info.avc.mb_adaptive_frame_field_flag = h->sps.mb_aff; 140 pic_descriptor->sps_info.avc.residual_colour_transform_flag = h->sps.residual_color_transform_flag; 141 pic_descriptor->sps_info.avc.xvba_avc_sps_reserved = 0; 142 143 // pps 144 pic_descriptor->pps_info.avc.entropy_coding_mode_flag = h->pps.cabac; 145 pic_descriptor->pps_info.avc.pic_order_present_flag = h->pps.pic_order_present; 146 pic_descriptor->pps_info.avc.weighted_pred_flag = h->pps.weighted_pred; 147 pic_descriptor->pps_info.avc.weighted_bipred_idc = h->pps.weighted_bipred_idc; 148 pic_descriptor->pps_info.avc.deblocking_filter_control_present_flag = h->pps.deblocking_filter_parameters_present; 149 pic_descriptor->pps_info.avc.constrained_intra_pred_flag = h->pps.constrained_intra_pred; 150 pic_descriptor->pps_info.avc.redundant_pic_cnt_present_flag = h->pps.redundant_pic_cnt_present; 151 pic_descriptor->pps_info.avc.transform_8x8_mode_flag = h->pps.transform_8x8_mode; 152 pic_descriptor->pps_info.avc.xvba_avc_pps_reserved = 0; // must be 0 153 154 memcpy(iq_matrix->bScalingLists4x4, h->pps.scaling_matrix4, sizeof(iq_matrix->bScalingLists4x4)); 155 memcpy(iq_matrix->bScalingLists8x8[0], h->pps.scaling_matrix8[0], sizeof(iq_matrix->bScalingLists8x8[0])); 156 memcpy(iq_matrix->bScalingLists8x8[1], h->pps.scaling_matrix8[3], sizeof(iq_matrix->bScalingLists8x8[0])); 157 158 // Wait for an I-frame before start decoding. Workaround for ATI UVD and UVD+ GPUs 159 if (!h->got_first_iframe) { 160 if (h->slice_type != AV_PICTURE_TYPE_I && h->slice_type != AV_PICTURE_TYPE_SI) 161 return -1; 162 h->got_first_iframe = 1; 163 } 164 165 ff_draw_horiz_band(s, 0, s->avctx->height); 166 167 return 0; 168 } 169 170 /** Decode the given H.264 slice with XVBA. */ 171 static int decode_slice(AVCodecContext *avctx, 172 const uint8_t *buffer, 173 uint32_t size) 174 { 175 H264Context * const h = avctx->priv_data; 176 MpegEncContext * const s = &h->s; 177 struct xvba_render_state *render; 178 179 render = (struct xvba_render_state *)s->current_picture_ptr->f.data[0]; 180 assert(render); 181 182 ff_xvba_add_slice_data(render, buffer, size); 183 184 return 0; 185 } 186 187 AVHWAccel ff_h264_xvba_hwaccel = { 188 .name = "h264_xvba", 189 .type = AVMEDIA_TYPE_VIDEO, 190 .id = CODEC_ID_H264, 191 .pix_fmt = PIX_FMT_XVBA_VLD, 192 .start_frame = start_frame, 193 .end_frame = end_frame, 194 .decode_slice = decode_slice, 195 }; -
libavcodec/xvba_internal.h
diff -Naur ffmpeg-1.0.4.old/libavcodec/xvba_internal.h ffmpeg-1.0.4/libavcodec/xvba_internal.h
old new 1 /* 2 * HW decode acceleration for MPEG-2, H.264 and VC-1 3 * 4 * Copyright (C) 2005-2011 Team XBMC 5 * 6 * This file is part of FFmpeg. 7 * 8 * FFmpeg is free software; you can redistribute it and/or 9 * modify it under the terms of the GNU Lesser General Public 10 * License as published by the Free Software Foundation; either 11 * version 2.1 of the License, or (at your option) any later version. 12 * 13 * FFmpeg is distributed in the hope that it will be useful, 14 * but WITHOUT ANY WARRANTY; without even the implied warranty of 15 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 16 * Lesser General Public License for more details. 17 * 18 * You should have received a copy of the GNU Lesser General Public 19 * License along with FFmpeg; if not, write to the Free Software 20 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA 21 */ 22 23 int ff_xvba_translate_profile(int profile); 24 void ff_xvba_add_slice_data(struct xvba_render_state *render, const uint8_t *buffer, uint32_t size); -
libavcodec/xvba_mpeg2.c
diff -Naur ffmpeg-1.0.4.old/libavcodec/xvba_mpeg2.c ffmpeg-1.0.4/libavcodec/xvba_mpeg2.c
old new 1 /* 2 * MPEG-2 HW decode acceleration through XVBA 3 * 4 * Copyright (C) 2005-2011 Team XBMC 5 * 6 * This file is part of FFmpeg. 7 * 8 * FFmpeg is free software; you can redistribute it and/or 9 * modify it under the terms of the GNU Lesser General Public 10 * License as published by the Free Software Foundation; either 11 * version 2.1 of the License, or (at your option) any later version. 12 * 13 * FFmpeg is distributed in the hope that it will be useful, 14 * but WITHOUT ANY WARRANTY; without even the implied warranty of 15 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 16 * Lesser General Public License for more details. 17 * 18 * You should have received a copy of the GNU Lesser General Public 19 * License along with FFmpeg; if not, write to the Free Software 20 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA 21 */ 22 23 #include "dsputil.h" 24 25 static int start_frame(AVCodecContext *avctx, av_unused const uint8_t *buffer, av_unused uint32_t size) 26 { 27 struct MpegEncContext * const s = avctx->priv_data; 28 return 0; 29 } 30 31 static int end_frame(AVCodecContext *avctx) 32 { 33 return 0; 34 } 35 36 static int decode_slice(AVCodecContext *avctx, const uint8_t *buffer, uint32_t size) 37 { 38 struct MpegEncContext * const s = avctx->priv_data; 39 return 0; 40 } 41 42 AVHWAccel ff_mpeg2_xvba_hwaccel = { 43 .name = "mpeg2_xvba", 44 .type = AVMEDIA_TYPE_VIDEO, 45 .id = CODEC_ID_MPEG2VIDEO, 46 .pix_fmt = PIX_FMT_XVBA_VLD, 47 .capabilities = 0, 48 .start_frame = start_frame, 49 .end_frame = end_frame, 50 .decode_slice = decode_slice, 51 .priv_data_size = 0, 52 }; -
libavcodec/xvba_vc1.c
diff -Naur ffmpeg-1.0.4.old/libavcodec/xvba_vc1.c ffmpeg-1.0.4/libavcodec/xvba_vc1.c
old new 1 /* 2 * VC-1 HW decode acceleration through XVBA 3 * 4 * Copyright (C) 2005-2011 Team XBMC 5 * 6 * This file is part of FFmpeg. 7 * 8 * FFmpeg is free software; you can redistribute it and/or 9 * modify it under the terms of the GNU Lesser General Public 10 * License as published by the Free Software Foundation; either 11 * version 2.1 of the License, or (at your option) any later version. 12 * 13 * FFmpeg is distributed in the hope that it will be useful, 14 * but WITHOUT ANY WARRANTY; without even the implied warranty of 15 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 16 * Lesser General Public License for more details. 17 * 18 * You should have received a copy of the GNU Lesser General Public 19 * License along with FFmpeg; if not, write to the Free Software 20 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA 21 */ 22 23 #include "xvba.h" 24 #include "xvba_internal.h" 25 #include "vc1.h" 26 #include "vc1data.h" 27 #include <assert.h> 28 29 30 /** @file 31 * Implement structures of ffmpeg <-> XvBA 32 */ 33 34 /* Initialize and start decoding a frame with XvBA */ 35 static int start_frame(AVCodecContext *avctx, 36 av_unused const uint8_t *buffer, 37 av_unused uint32_t size) 38 { 39 VC1Context * const v = avctx->priv_data; 40 MpegEncContext * const s = &v->s; 41 struct xvba_render_state *render; 42 43 render = (struct xvba_render_state *)s->current_picture_ptr->f.data[0]; 44 assert(render); 45 46 render->num_slices = 0; 47 return 0; 48 } 49 50 /* End a hardware decoding based frame */ 51 static int end_frame(AVCodecContext *avctx) 52 { 53 VC1Context* const v = avctx->priv_data; 54 MpegEncContext* const s = &v->s; 55 struct xvba_render_state *render, *last, *next; 56 XVBAPictureDescriptor *pic_descriptor; 57 58 render = (struct xvba_render_state *)s->current_picture_ptr->f.data[0]; 59 assert(render); 60 61 if (render->picture_descriptor == 0) 62 return -1; 63 64 pic_descriptor = render->picture_descriptor; 65 66 av_dlog(avctx, "xvba_vc1_end_frame()\n"); 67 68 memset(pic_descriptor, 0, sizeof(*pic_descriptor)); 69 70 /* Fill in Parameters - for reference see AMD sdk documentation */ 71 pic_descriptor->profile = ff_xvba_translate_profile(v->profile); 72 pic_descriptor->level = v->level; 73 //done like in va-driver and vaapi 74 if (v->profile == PROFILE_ADVANCED) { 75 pic_descriptor->width_in_mb = s->avctx->coded_width; 76 pic_descriptor->height_in_mb = s->avctx->coded_height; 77 } else { 78 pic_descriptor->width_in_mb = s->mb_width; 79 pic_descriptor->height_in_mb = s->mb_height; 80 } 81 pic_descriptor->picture_structure = s->picture_structure; 82 // xvba-video set this to 1 only 4:2:0 supported 83 // doc says: if not set, choose 1 - we try this 84 pic_descriptor->chroma_format = 1; 85 pic_descriptor->avc_intra_flag = s->pict_type == AV_PICTURE_TYPE_I || v->bi_type == 1; 86 pic_descriptor->avc_reference = (s->current_picture_ptr->f.reference & 3) ? 1 : 0; 87 88 // VC-1 explicit parameters see page 30 of sdk 89 // sps_info 90 pic_descriptor->sps_info.vc1.postprocflag = v->postprocflag; 91 92 // done as in vaapi 93 pic_descriptor->sps_info.vc1.pulldown = v->broadcast; 94 pic_descriptor->sps_info.vc1.interlace = v->interlace; 95 pic_descriptor->sps_info.vc1.tfcntrflag = v->tfcntrflag; 96 pic_descriptor->sps_info.vc1.finterpflag = v->finterpflag; 97 pic_descriptor->sps_info.vc1.reserved = 1; 98 // eventually check if this makes sense together with interlace 99 pic_descriptor->sps_info.vc1.psf = v->psf; 100 // what about if it is a frame (page 31) 101 // looked at xvba-driver 102 pic_descriptor->sps_info.vc1.second_field = !s->first_field; 103 pic_descriptor->sps_info.vc1.xvba_vc1_sps_reserved = 0; 104 105 // VC-1 explicit parameters see page 30 of sdk 106 // pps_info 107 pic_descriptor->pps_info.vc1.panscan_flag = v->panscanflag; 108 pic_descriptor->pps_info.vc1.refdist_flag = v->refdist_flag; 109 pic_descriptor->pps_info.vc1.loopfilter = s->loop_filter; 110 pic_descriptor->pps_info.vc1.fastuvmc = v->fastuvmc; 111 pic_descriptor->pps_info.vc1.extended_mv = v->extended_mv; 112 pic_descriptor->pps_info.vc1.dquant = v->dquant; 113 pic_descriptor->pps_info.vc1.vstransform = v->vstransform; 114 pic_descriptor->pps_info.vc1.overlap = v->overlap; 115 pic_descriptor->pps_info.vc1.quantizer = v->quantizer_mode; 116 pic_descriptor->pps_info.vc1.extended_dmv = v->extended_dmv; 117 pic_descriptor->pps_info.vc1.maxbframes = s->avctx->max_b_frames; 118 pic_descriptor->pps_info.vc1.rangered = (pic_descriptor->profile == PROFILE_SIMPLE) ? 0 : v->rangered; 119 pic_descriptor->pps_info.vc1.syncmarker = (pic_descriptor->profile == PROFILE_SIMPLE) ? 0 : s->resync_marker; 120 pic_descriptor->pps_info.vc1.multires = v->multires; 121 pic_descriptor->pps_info.vc1.reserved = 1; 122 pic_descriptor->pps_info.vc1.range_mapy_flag = v->range_mapy_flag; 123 pic_descriptor->pps_info.vc1.range_mapy = v->range_mapy; 124 pic_descriptor->pps_info.vc1.range_mapuv_flag = v->range_mapuv_flag; 125 pic_descriptor->pps_info.vc1.range_mapuv = v->range_mapuv; 126 pic_descriptor->pps_info.vc1.xvba_vc1_pps_reserved = 0; 127 128 pic_descriptor->past_surface = 0; 129 pic_descriptor->future_surface = 0; 130 switch (s->pict_type) { 131 case AV_PICTURE_TYPE_B: 132 next = (struct xvba_render_state *)s->next_picture.f.data[0]; 133 assert(next); 134 if (next) 135 pic_descriptor->past_surface = next->surface; 136 // fall-through 137 case AV_PICTURE_TYPE_P: 138 last = (struct xvba_render_state *)s->last_picture.f.data[0]; 139 assert(last); 140 if (last) 141 pic_descriptor->future_surface = last->surface; 142 break; 143 } 144 145 ff_draw_horiz_band(s, 0, s->avctx->height); 146 147 return 0; 148 } 149 150 static int decode_slice(AVCodecContext *avctx, const uint8_t *buffer, uint32_t size) 151 { 152 VC1Context* const v = avctx->priv_data; 153 MpegEncContext* const s = &v->s; 154 struct xvba_render_state *render; 155 156 render = (struct xvba_render_state *)s->current_picture_ptr->f.data[0]; 157 assert(render); 158 159 if (avctx->codec_id == CODEC_ID_VC1 && 160 size >= 4 && IS_MARKER(AV_RB32(buffer))) { 161 buffer += 4; 162 size -= 4; 163 } 164 165 ff_xvba_add_slice_data(render, buffer, size); 166 167 return 0; 168 } 169 170 #if CONFIG_WMV3_XVBA_HWACCEL 171 AVHWAccel ff_wmv3_xvba_hwaccel = { 172 .name = "wmv3_xvba", 173 .type = AVMEDIA_TYPE_VIDEO, 174 .id = CODEC_ID_WMV3, 175 .pix_fmt = PIX_FMT_XVBA_VLD, 176 .start_frame = start_frame, 177 .end_frame = end_frame, 178 .decode_slice = decode_slice, 179 }; 180 #endif 181 182 AVHWAccel ff_vc1_xvba_hwaccel = { 183 .name = "vc1_xvba", 184 .type = AVMEDIA_TYPE_VIDEO, 185 .id = CODEC_ID_VC1, 186 .pix_fmt = PIX_FMT_XVBA_VLD, 187 .start_frame = start_frame, 188 .end_frame = end_frame, 189 .decode_slice = decode_slice, 190 }; -
libavutil/pixdesc.c
diff -Naur ffmpeg-1.0.4.old/libavutil/pixdesc.c ffmpeg-1.0.4/libavutil/pixdesc.c
old new 902 902 .log2_chroma_h = 1, 903 903 .flags = PIX_FMT_HWACCEL, 904 904 }, 905 [PIX_FMT_XVBA_VLD] = { 906 .name = "xvba_vld", 907 .log2_chroma_w = 1, 908 .log2_chroma_h = 1, 909 .flags = PIX_FMT_HWACCEL, 910 }, 905 911 [PIX_FMT_YUV420P9LE] = { 906 912 .name = "yuv420p9le", 907 913 .nb_components = 3, -
libavutil/pixfmt.h
diff -Naur ffmpeg-1.0.4.old/libavutil/pixfmt.h ffmpeg-1.0.4/libavutil/pixfmt.h
old new 132 132 PIX_FMT_YUV444P16BE, ///< planar YUV 4:4:4, 48bpp, (1 Cr & Cb sample per 1x1 Y samples), big-endian 133 133 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 134 134 PIX_FMT_DXVA2_VLD, ///< HW decoding through DXVA2, Picture.data[3] contains a LPDIRECT3DSURFACE9 pointer 135 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 135 136 136 137 PIX_FMT_RGB444LE, ///< packed RGB 4:4:4, 16bpp, (msb)4A 4R 4G 4B(lsb), little-endian, most significant bits to 0 137 138 PIX_FMT_RGB444BE, ///< packed RGB 4:4:4, 16bpp, (msb)4A 4R 4G 4B(lsb), big-endian, most significant bits to 0
