diff options
-rw-r--r-- | libhb/builtin_presets.h | 3 | ||||
-rw-r--r-- | libhb/common.h | 2 | ||||
-rw-r--r-- | libhb/cropscale.c | 21 | ||||
-rw-r--r-- | libhb/decavcodec.c | 251 | ||||
-rw-r--r-- | libhb/dxva2api.c | 38 | ||||
-rw-r--r-- | libhb/dxva2api.h | 822 | ||||
-rw-r--r-- | libhb/hb.c | 20 | ||||
-rw-r--r-- | libhb/hb.h | 4 | ||||
-rw-r--r-- | libhb/hb_json.c | 19 | ||||
-rw-r--r-- | libhb/hbtypes.h | 1 | ||||
-rw-r--r-- | libhb/internal.h | 8 | ||||
-rw-r--r-- | libhb/libhb_presets.list | 2 | ||||
-rw-r--r-- | libhb/module.defs | 4 | ||||
-rw-r--r-- | libhb/oclnv12toyuv.c | 334 | ||||
-rw-r--r-- | libhb/oclnv12toyuv.h | 27 | ||||
-rw-r--r-- | libhb/preset.c | 5 | ||||
-rw-r--r-- | libhb/preset_template.json | 1 | ||||
-rw-r--r-- | libhb/scan.c | 5 | ||||
-rw-r--r-- | libhb/stream.c | 5 | ||||
-rw-r--r-- | libhb/vadxva2.c | 804 | ||||
-rw-r--r-- | libhb/vadxva2.h | 208 | ||||
-rw-r--r-- | libhb/work.c | 24 | ||||
-rw-r--r-- | make/configure.py | 3 | ||||
-rw-r--r-- | test/module.defs | 3 | ||||
-rw-r--r-- | test/test.c | 18 |
25 files changed, 65 insertions, 2567 deletions
diff --git a/libhb/builtin_presets.h b/libhb/builtin_presets.h index 6fa988f4e..30c7924c7 100644 --- a/libhb/builtin_presets.h +++ b/libhb/builtin_presets.h @@ -845,7 +845,6 @@ const char hb_builtin_presets_json[] = " \"VideoFramerate\": \"auto\", \n" " \"VideoFramerateMode\": \"vfr\", \n" " \"VideoGrayScale\": false, \n" -" \"VideoHWDecode\": false, \n" " \"VideoLevel\": \"auto\", \n" " \"VideoOptionExtra\": \"\", \n" " \"VideoPreset\": \"medium\", \n" @@ -861,7 +860,7 @@ const char hb_builtin_presets_json[] = " \"x264Option\": \"\", \n" " \"x264UseAdvancedOptions\": false\n" " }, \n" -" \"VersionMajor\": 13, \n" +" \"VersionMajor\": 14, \n" " \"VersionMicro\": 0, \n" " \"VersionMinor\": 0\n" " }\n" diff --git a/libhb/common.h b/libhb/common.h index 813b778ef..040164ceb 100644 --- a/libhb/common.h +++ b/libhb/common.h @@ -607,7 +607,6 @@ struct hb_job_s // initially (for frame accurate positioning // to non-I frames). int use_opencl; - int use_hwd; PRIVATE int use_decomb; PRIVATE int use_detelecine; @@ -983,7 +982,6 @@ struct hb_title_s int video_decode_support; #define HB_DECODE_SUPPORT_SW 0x01 // software (libavcodec or mpeg2dec) #define HB_DECODE_SUPPORT_QSV 0x02 // Intel Quick Sync Video -#define HB_DECODE_SUPPORT_DXVA2 0x04 // Microsoft DXVA2 hb_metadata_t * metadata; diff --git a/libhb/cropscale.c b/libhb/cropscale.c index 63475990e..33fc156f7 100644 --- a/libhb/cropscale.c +++ b/libhb/cropscale.c @@ -23,10 +23,7 @@ struct hb_filter_private_s int height_out; int crop[4]; - /* OpenCL/DXVA2 */ - int use_dxva; - int use_decomb; - int use_detelecine; + /* OpenCL */ hb_oclscale_t *os; //ocl scaler handler struct SwsContext * context; @@ -75,11 +72,7 @@ static int hb_crop_scale_init( hb_filter_object_t * filter, pv->width_out = init->geometry.width - (init->crop[2] + init->crop[3]); pv->height_out = init->geometry.height - (init->crop[0] + init->crop[1]); - /* OpenCL/DXVA2 */ - pv->use_dxva = hb_hwd_enabled(init->job->h); - pv->use_decomb = init->job->use_decomb; - pv->use_detelecine = init->job->use_detelecine; - + /* OpenCL */ if (pv->job->use_opencl && pv->job->title->opencl_support) { pv->os = ( hb_oclscale_t * )malloc( sizeof( hb_oclscale_t ) ); @@ -253,13 +246,9 @@ static int hb_crop_scale_work( hb_filter_object_t * filter, pv->height_out = in->f.height - (pv->crop[0] + pv->crop[1]); } - /* OpenCL/DXVA2 */ - if ((!pv->use_dxva && - !pv->crop[0] && !pv->crop[1] && !pv->crop[2] && !pv->crop[3] && - in->f.fmt == pv->pix_fmt_out && in->f.width == pv->width_out && - in->f.height == pv->height_out) || - (pv->use_dxva && !pv->use_decomb && !pv->use_detelecine && - in->f.width == pv->width_out && in->f.height == pv->height_out)) + if (!pv->crop[0] && !pv->crop[1] && !pv->crop[2] && !pv->crop[3] && + in->f.fmt == pv->pix_fmt_out && in->f.width == pv->width_out && + in->f.height == pv->height_out) { *buf_out = in; *buf_in = NULL; diff --git a/libhb/decavcodec.c b/libhb/decavcodec.c index 874b77e1c..bc6637143 100644 --- a/libhb/decavcodec.c +++ b/libhb/decavcodec.c @@ -42,11 +42,6 @@ #include "hbffmpeg.h" #include "audio_resample.h" -#ifdef USE_HWD -#include "opencl.h" -#include "vadxva2.h" -#endif - #ifdef USE_QSV #include "qsv_common.h" #endif @@ -111,11 +106,6 @@ struct hb_work_private_s int sws_pix_fmt; int cadence[12]; int wait_for_keyframe; -#ifdef USE_HWD - hb_va_dxva2_t * dxva2; - uint8_t * dst_frame; - hb_oclscale_t * opencl_scale; -#endif hb_audio_resample_t * resample; #ifdef USE_QSV @@ -471,21 +461,6 @@ static void closePrivData( hb_work_private_t ** ppv ) } hb_audio_resample_free(pv->resample); -#ifdef USE_HWD - if (pv->opencl_scale != NULL) - { - free(pv->opencl_scale); - } - if (pv->dxva2 != NULL) - { - if (hb_ocl != NULL) - { - HB_OCL_BUF_FREE(hb_ocl, pv->dxva2->cl_mem_nv12); - } - hb_va_close(pv->dxva2); - } -#endif - #ifdef USE_QSV_PTS_WORKAROUND if (pv->qsv.decode && pv->qsv.pts_list != NULL) @@ -508,9 +483,7 @@ static void closePrivData( hb_work_private_t ** ppv ) static void decavcodecClose( hb_work_object_t * w ) { hb_work_private_t * pv = w->private_data; -#ifdef USE_HWD - if( pv->dst_frame ) free( pv->dst_frame ); -#endif + if ( pv ) { closePrivData( &pv ); @@ -875,139 +848,67 @@ static hb_buffer_t *copy_frame( hb_work_private_t *pv ) h = pv->job->title->geometry.height; } -#ifdef USE_HWD - if (pv->dxva2 && pv->job) - { - hb_buffer_t *buf; - int ww, hh; - - buf = hb_video_buffer_init( w, h ); - ww = w; - hh = h; + hb_buffer_t *out = hb_video_buffer_init( w, h ); - if( !pv->dst_frame ) - { - pv->dst_frame = malloc( ww * hh * 3 / 2 ); - } - if( hb_va_extract( pv->dxva2, pv->dst_frame, pv->frame, pv->job->width, pv->job->height, pv->job->title->crop, pv->opencl_scale, pv->job->use_opencl, pv->job->use_decomb, pv->job->use_detelecine ) == HB_WORK_ERROR ) - { - hb_log( "hb_va_Extract failed!!!!!!" ); - } - w = buf->plane[0].stride; - h = buf->plane[0].height; - uint8_t *dst = buf->plane[0].data; - copy_plane( dst, pv->dst_frame, w, ww, h ); - w = buf->plane[1].stride; - h = buf->plane[1].height; - dst = buf->plane[1].data; - copy_plane( dst, pv->dst_frame + ww * hh, w, ww >> 1, h ); - w = buf->plane[2].stride; - h = buf->plane[2].height; - dst = buf->plane[2].data; - copy_plane( dst, pv->dst_frame + ww * hh +( ( ww * hh ) >> 2 ), w, ww >> 1, h ); - return buf; - } - else -#endif - { - hb_buffer_t *buf = hb_video_buffer_init( w, h ); - #ifdef USE_QSV // no need to copy the frame data when decoding with QSV to opaque memory if (pv->qsv.decode && pv->qsv.config.io_pattern == MFX_IOPATTERN_OUT_OPAQUE_MEMORY) { - buf->qsv_details.qsv_atom = pv->frame->data[2]; - buf->qsv_details.ctx = pv->job->qsv.ctx; - return buf; + out->qsv_details.qsv_atom = pv->frame->data[2]; + out->qsv_details.ctx = pv->job->qsv.ctx; + return out; } #endif - uint8_t *dst = buf->data; + uint8_t *dst = out->data; - if (context->pix_fmt != AV_PIX_FMT_YUV420P || w != context->width || - h != context->height) - { - // have to convert to our internal color space and/or rescale - uint8_t * data[4]; - int stride[4]; - hb_picture_fill(data, stride, buf); - - if (pv->sws_context == NULL || - pv->sws_width != context->width || - pv->sws_height != context->height || - pv->sws_pix_fmt != context->pix_fmt) - { - if (pv->sws_context != NULL) - sws_freeContext(pv->sws_context); - pv->sws_context = hb_sws_get_context(context->width, - context->height, - context->pix_fmt, - w, h, AV_PIX_FMT_YUV420P, - SWS_LANCZOS|SWS_ACCURATE_RND); - pv->sws_width = context->width; - pv->sws_height = context->height; - pv->sws_pix_fmt = context->pix_fmt; - } - sws_scale(pv->sws_context, - (const uint8_t* const *)pv->frame->data, - pv->frame->linesize, 0, context->height, data, stride); - } - else + if (context->pix_fmt != AV_PIX_FMT_YUV420P || w != context->width || + h != context->height) + { + // have to convert to our internal color space and/or rescale + uint8_t * data[4]; + int stride[4]; + hb_picture_fill(data, stride, out); + + if (pv->sws_context == NULL || + pv->sws_width != context->width || + pv->sws_height != context->height || + pv->sws_pix_fmt != context->pix_fmt) { - w = buf->plane[0].stride; - h = buf->plane[0].height; - dst = buf->plane[0].data; - copy_plane( dst, pv->frame->data[0], w, pv->frame->linesize[0], h ); - w = buf->plane[1].stride; - h = buf->plane[1].height; - dst = buf->plane[1].data; - copy_plane( dst, pv->frame->data[1], w, pv->frame->linesize[1], h ); - w = buf->plane[2].stride; - h = buf->plane[2].height; - dst = buf->plane[2].data; - copy_plane( dst, pv->frame->data[2], w, pv->frame->linesize[2], h ); + if (pv->sws_context != NULL) + sws_freeContext(pv->sws_context); + pv->sws_context = hb_sws_get_context(context->width, + context->height, + context->pix_fmt, + w, h, AV_PIX_FMT_YUV420P, + SWS_LANCZOS|SWS_ACCURATE_RND); + pv->sws_width = context->width; + pv->sws_height = context->height; + pv->sws_pix_fmt = context->pix_fmt; } - return buf; - } -} - -#ifdef USE_HWD - -static int get_frame_buf_hwd( AVCodecContext *context, AVFrame *frame ) -{ - - hb_work_private_t *pv = (hb_work_private_t*)context->opaque; - if ( (pv != NULL) && pv->dxva2 ) - { - int result = HB_WORK_ERROR; - hb_work_private_t *pv = (hb_work_private_t*)context->opaque; - result = hb_va_get_frame_buf( pv->dxva2, context, frame ); - if( result == HB_WORK_ERROR ) - return avcodec_default_get_buffer( context, frame ); - return 0; + sws_scale(pv->sws_context, + (const uint8_t* const *)pv->frame->data, + pv->frame->linesize, 0, context->height, data, stride); } else - return avcodec_default_get_buffer( context, frame ); -} - -static void hb_ffmpeg_release_frame_buf( struct AVCodecContext *p_context, AVFrame *frame ) -{ - hb_work_private_t *p_dec = (hb_work_private_t*)p_context->opaque; - int i; - if( p_dec->dxva2 ) - { - hb_va_release( p_dec->dxva2, frame ); - } - else if( !frame->opaque ) { - if( frame->type == FF_BUFFER_TYPE_INTERNAL ) - avcodec_default_release_buffer( p_context, frame ); - } - for( i = 0; i < 4; i++ ) - frame->data[i] = NULL; + w = out->plane[0].stride; + h = out->plane[0].height; + dst = out->plane[0].data; + copy_plane( dst, pv->frame->data[0], w, pv->frame->linesize[0], h ); + w = out->plane[1].stride; + h = out->plane[1].height; + dst = out->plane[1].data; + copy_plane( dst, pv->frame->data[1], w, pv->frame->linesize[1], h ); + w = out->plane[2].stride; + h = out->plane[2].height; + dst = out->plane[2].data; + copy_plane( dst, pv->frame->data[2], w, pv->frame->linesize[2], h ); + } + + return out; } -#endif static void log_chapter( hb_work_private_t *pv, int chap_num, int64_t pts ) { @@ -1327,21 +1228,10 @@ static int decodeFrame( hb_work_object_t *w, uint8_t *data, int size, int sequen { frame_dur += pv->frame->repeat_pict * pv->field_duration; } -#ifdef USE_HWD - if( pv->dxva2 && pv->dxva2->do_job == HB_WORK_OK ) - { - if( avp.pts>0 ) - { - if( pv->dxva2->input_pts[0] != 0 && pv->dxva2->input_pts[1] == 0 ) - pv->frame->pkt_pts = pv->dxva2->input_pts[0]; - else - pv->frame->pkt_pts = pv->dxva2->input_pts[0]<pv->dxva2->input_pts[1] ? pv->dxva2->input_pts[0] : pv->dxva2->input_pts[1]; - } - } -#endif + // If there was no pts for this frame, assume constant frame rate // video & estimate the next frame time from the last & duration. - if (pv->frame->pkt_pts == AV_NOPTS_VALUE || hb_hwd_enabled(w->h)) + if (pv->frame->pkt_pts == AV_NOPTS_VALUE) { pts = pv->pts_next; } @@ -1657,30 +1547,6 @@ static int decavcodecvInit( hb_work_object_t * w, hb_job_t * job ) pv->context->workaround_bugs = FF_BUG_AUTODETECT; pv->context->err_recognition = AV_EF_CRCCHECK; pv->context->error_concealment = FF_EC_GUESS_MVS|FF_EC_DEBLOCK; -#ifdef USE_HWD - // QSV decoding is faster, so prefer it to DXVA2 - if (pv->job != NULL && !pv->qsv.decode && hb_hwd_enabled(pv->job->h)) - { - pv->dxva2 = hb_va_create_dxva2( pv->dxva2, w->codec_param ); - if( pv->dxva2 && pv->dxva2->do_job == HB_WORK_OK ) - { - hb_va_new_dxva2( pv->dxva2, pv->context ); - pv->context->slice_flags |= SLICE_FLAG_ALLOW_FIELD; - pv->context->opaque = pv; - pv->context->get_buffer = get_frame_buf_hwd; - pv->context->release_buffer = hb_ffmpeg_release_frame_buf; - pv->context->get_format = hb_ffmpeg_get_format; - pv->opencl_scale = ( hb_oclscale_t * )malloc( sizeof( hb_oclscale_t ) ); - memset( pv->opencl_scale, 0, sizeof( hb_oclscale_t ) ); - pv->threads = 1; - } - else - { - hb_log("decavcodecvInit: hb_va_create_dxva2 failed, using software decoder"); - } - } -#endif - #ifdef USE_QSV if (pv->qsv.decode) @@ -1900,16 +1766,6 @@ static int decavcodecvWork( hb_work_object_t * w, hb_buffer_t ** buf_in, pv->new_chap = in->s.new_chap; pv->chap_time = pts >= 0? pts : pv->pts_next; } -#ifdef USE_HWD - if( pv->dxva2 && pv->dxva2->do_job == HB_WORK_OK ) - { - if( pv->dxva2->input_pts[0] <= pv->dxva2->input_pts[1] ) - pv->dxva2->input_pts[0] = pts; - else if( pv->dxva2->input_pts[0] > pv->dxva2->input_pts[1] ) - pv->dxva2->input_pts[1] = pts; - pv->dxva2->input_dts = dts; - } -#endif if (in->palette != NULL) { pv->palette = in->palette; @@ -2127,17 +1983,6 @@ static int decavcodecvInfo( hb_work_object_t *w, hb_work_info_t *info ) default: break; } -#ifdef USE_HWD - hb_va_dxva2_t *dxva2 = hb_va_create_dxva2(NULL, pv->context->codec_id); - if (dxva2 != NULL) - { - if (hb_check_hwd_fmt(pv->context->pix_fmt)) - { - info->video_decode_support |= HB_DECODE_SUPPORT_DXVA2; - } - hb_va_close(dxva2); - } -#endif return 1; } diff --git a/libhb/dxva2api.c b/libhb/dxva2api.c deleted file mode 100644 index 31f54e37b..000000000 --- a/libhb/dxva2api.c +++ /dev/null @@ -1,38 +0,0 @@ -/* dxva2api.c - - Copyright (c) 2003-2016 HandBrake Team - This file is part of the HandBrake source code - Homepage: <http://handbrake.fr/>. - It may be used under the terms of the GNU General Public License v2. - For full terms see the file COPYING file or visit http://www.gnu.org/licenses/gpl-2.0.html - - Authors: Peng Gao <[email protected]> <http://www.multicorewareinc.com/> - Li Cao <[email protected]> <http://www.multicorewareinc.com/> - - */ -#ifdef USE_HWD -#include "dxva2api.h" - -__inline float hb_dx_fixedtofloat( const DXVA2_Fixed32 _fixed_ ) -{ - return (FLOAT)_fixed_.Value + (FLOAT)_fixed_.Fraction / 0x10000; -} - -__inline const DXVA2_Fixed32 hb_dx_fixed32_opaque_alpha() -{ - DXVA2_Fixed32 _fixed_; - _fixed_.Fraction = 0; - _fixed_.Value = 0; - _fixed_.ll = 1; - return _fixed_; -} - - -__inline DXVA2_Fixed32 hb_dx_floattofixed( const float _float_ ) -{ - DXVA2_Fixed32 _fixed_; - _fixed_.Fraction = LOWORD( _float_ * 0x10000 ); - _fixed_.Value = HIWORD( _float_ * 0x10000 ); - return _fixed_; -} -#endif diff --git a/libhb/dxva2api.h b/libhb/dxva2api.h deleted file mode 100644 index 6d03b34fe..000000000 --- a/libhb/dxva2api.h +++ /dev/null @@ -1,822 +0,0 @@ -/* dxva2api.h - - Copyright (c) 2003-2016 HandBrake Team - This file is part of the HandBrake source code - Homepage: <http://handbrake.fr/>. - It may be used under the terms of the GNU General Public License v2. - For full terms see the file COPYING file or visit http://www.gnu.org/licenses/gpl-2.0.html - - Authors: Peng Gao <[email protected]> <http://www.multicorewareinc.com/> - Li Cao <[email protected]> <http://www.multicorewareinc.com/> - - */ - - -#ifndef _DXVA2API_H -#define _DXVA2API_H -#ifdef USE_HWD -#define MINGW_DXVA2API_H_VERSION (2) - -#if __GNUC__ >= 3 -#pragma GCC system_header -#endif - -#include <objbase.h> -#include <d3d9.h> - -/* Define it to allow using nameless struct/union (non C99 compliant) to match - * the official documentation. */ -//#define DXVA2API_USE_BITFIELDS - -/****************STRUCTURES******************/ -#pragma pack(push, 1) - -#define DXVA2API_USE_BITFIELDS - -typedef struct _DXVA2_ExtendedFormat { -#ifdef DXVA2API_USE_BITFIELDS - union { - struct { - UINT SampleFormat : 8; - UINT VideoChromaSubsampling : 4; - UINT NominalRange : 3; - UINT VideoTransferMatrix : 3; - UINT VideoLighting : 4; - UINT VideoPrimaries : 5; - UINT VideoTransferFunction : 5; - }; - UINT value; - }; -#else - UINT value; -#endif -} DXVA2_ExtendedFormat; - -typedef struct _DXVA2_Frequency { - UINT Numerator; - UINT Denominator; -} DXVA2_Frequency; - -typedef struct _DXVA2_VideoDesc { - UINT SampleWidth; - UINT SampleHeight; - DXVA2_ExtendedFormat SampleFormat; - D3DFORMAT Format; - DXVA2_Frequency InputSampleFreq; - DXVA2_Frequency OutputFrameFreq; - UINT UABProtectionLevel; - UINT Reserved; -} DXVA2_VideoDesc; - -typedef struct _DXVA2_ConfigPictureDecode { - GUID guidConfigBitstreamEncryption; - GUID guidConfigMBcontrolEncryption; - GUID guidConfigResidDiffEncryption; - UINT ConfigBitstreamRaw; - UINT ConfigMBcontrolRasterOrder; - UINT ConfigResidDiffHost; - UINT ConfigSpatialResid8; - UINT ConfigResid8Subtraction; - UINT ConfigSpatialHost8or9Clipping; - UINT ConfigSpatialResidInterleaved; - UINT ConfigIntraResidUnsigned; - UINT ConfigResidDiffAccelerator; - UINT ConfigHostInverseScan; - UINT ConfigSpecificIDCT; - UINT Config4GroupedCoefs; - USHORT ConfigMinRenderTargetBuffCount; - USHORT ConfigDecoderSpecific; -} DXVA2_ConfigPictureDecode; - -typedef struct _DXVA2_DecodeBufferDesc { - DWORD CompressedBufferType; - UINT BufferIndex; - UINT DataOffset; - UINT DataSize; - UINT FirstMBaddress; - UINT NumMBsInBuffer; - UINT Width; - UINT Height; - UINT Stride; - UINT ReservedBits; - PVOID pvPVPState; -} DXVA2_DecodeBufferDesc; - -typedef struct _DXVA2_DecodeExtensionData { - UINT Function; - PVOID pPrivateInputData; - UINT PrivateInputDataSize; - PVOID pPrivateOutputData; - UINT PrivateOutputDataSize; -} DXVA2_DecodeExtensionData; - -typedef struct _DXVA2_DecodeExecuteParams { - UINT NumCompBuffers; - DXVA2_DecodeBufferDesc *pCompressedBuffers; - DXVA2_DecodeExtensionData *pExtensionData; -} DXVA2_DecodeExecuteParams; - -enum { - DXVA2_VideoDecoderRenderTarget = 0, - DXVA2_VideoProcessorRenderTarget= 1, - DXVA2_VideoSoftwareRenderTarget = 2 -}; - -enum { - DXVA2_PictureParametersBufferType = 0, - DXVA2_MacroBlockControlBufferType = 1, - DXVA2_ResidualDifferenceBufferType = 2, - DXVA2_DeblockingControlBufferType = 3, - DXVA2_InverseQuantizationMatrixBufferType = 4, - DXVA2_SliceControlBufferType = 5, - DXVA2_BitStreamDateBufferType = 6, - DXVA2_MotionVectorBuffer = 7, - DXVA2_FilmGrainBuffer = 8 -}; - -/* DXVA MPEG-I/II and VC-1 */ -typedef struct _DXVA_PictureParameters { - USHORT wDecodedPictureIndex; - USHORT wDeblockedPictureIndex; - USHORT wForwardRefPictureIndex; - USHORT wBackwardRefPictureIndex; - USHORT wPicWidthInMBminus1; - USHORT wPicHeightInMBminus1; - UCHAR bMacroblockWidthMinus1; - UCHAR bMacroblockHeightMinus1; - UCHAR bBlockWidthMinus1; - UCHAR bBlockHeightMinus1; - UCHAR bBPPminus1; - UCHAR bPicStructure; - UCHAR bSecondField; - UCHAR bPicIntra; - UCHAR bPicBackwardPrediction; - UCHAR bBidirectionalAveragingMode; - UCHAR bMVprecisionAndChromaRelation; - UCHAR bChromaFormat; - UCHAR bPicScanFixed; - UCHAR bPicScanMethod; - UCHAR bPicReadbackRequests; - UCHAR bRcontrol; - UCHAR bPicSpatialResid8; - UCHAR bPicOverflowBlocks; - UCHAR bPicExtrapolation; - UCHAR bPicDeblocked; - UCHAR bPicDeblockConfined; - UCHAR bPic4MVallowed; - UCHAR bPicOBMC; - UCHAR bPicBinPB; - UCHAR bMV_RPS; - UCHAR bReservedBits; - USHORT wBitstreamFcodes; - USHORT wBitstreamPCEelements; - UCHAR bBitstreamConcealmentNeed; - UCHAR bBitstreamConcealmentMethod; -} DXVA_PictureParameters, *LPDXVA_PictureParameters; - -typedef struct _DXVA_QmatrixData { - BYTE bNewQmatrix[4]; - WORD Qmatrix[4][8 * 8]; -} DXVA_QmatrixData, *LPDXVA_QmatrixData; - -typedef struct _DXVA_SliceInfo { - USHORT wHorizontalPosition; - USHORT wVerticalPosition; - UINT dwSliceBitsInBuffer; - UINT dwSliceDataLocation; - UCHAR bStartCodeBitOffset; - UCHAR bReservedBits; - USHORT wMBbitOffset; - USHORT wNumberMBsInSlice; - USHORT wQuantizerScaleCode; - USHORT wBadSliceChopping; -} DXVA_SliceInfo, *LPDXVA_SliceInfo; - -/* DXVA H264 */ -typedef struct { -#ifdef DXVA2API_USE_BITFIELDS - union { - struct { - UCHAR Index7Bits : 7; - UCHAR AssociatedFlag : 1; - }; - UCHAR bPicEntry; - }; -#else - UCHAR bPicEntry; -#endif -} DXVA_PicEntry_H264; - - -typedef struct { - USHORT wFrameWidthInMbsMinus1; - USHORT wFrameHeightInMbsMinus1; - DXVA_PicEntry_H264 CurrPic; - UCHAR num_ref_frames; -#ifdef DXVA2API_USE_BITFIELDS - union { - struct { - USHORT field_pic_flag : 1; - USHORT MbaffFrameFlag : 1; - USHORT residual_colour_transform_flag : 1; - USHORT sp_for_switch_flag : 1; - USHORT chroma_format_idc : 2; - USHORT RefPicFlag : 1; - USHORT constrained_intra_pred_flag : 1; - USHORT weighted_pred_flag : 1; - USHORT weighted_bipred_idc : 2; - USHORT MbsConsecutiveFlag : 1; - USHORT frame_mbs_only_flag : 1; - USHORT transform_8x8_mode_flag : 1; - USHORT MinLumaBipredSize8x8Flag : 1; - USHORT IntraPicFlag : 1; - }; - USHORT wBitFields; - }; -#else - USHORT wBitFields; -#endif - UCHAR bit_depth_luma_minus8; - UCHAR bit_depth_chroma_minus8; - USHORT Reserved16Bits; - UINT StatusReportFeedbackNumber; - DXVA_PicEntry_H264 RefFrameList[16]; - INT CurrFieldOrderCnt[2]; - INT FieldOrderCntList[16][2]; - CHAR pic_init_qs_minus26; - CHAR chroma_qp_index_offset; - CHAR second_chroma_qp_index_offset; - UCHAR ContinuationFlag; - CHAR pic_init_qp_minus26; - UCHAR num_ref_idx_l0_active_minus1; - UCHAR num_ref_idx_l1_active_minus1; - UCHAR Reserved8BitsA; - USHORT FrameNumList[16]; - - UINT UsedForReferenceFlags; - USHORT NonExistingFrameFlags; - USHORT frame_num; - UCHAR log2_max_frame_num_minus4; - UCHAR pic_order_cnt_type; - UCHAR log2_max_pic_order_cnt_lsb_minus4; - UCHAR delta_pic_order_always_zero_flag; - UCHAR direct_8x8_inference_flag; - UCHAR entropy_coding_mode_flag; - UCHAR pic_order_present_flag; - UCHAR num_slice_groups_minus1; - UCHAR slice_group_map_type; - UCHAR deblocking_filter_control_present_flag; - UCHAR redundant_pic_cnt_present_flag; - UCHAR Reserved8BitsB; - USHORT slice_group_change_rate_minus1; - UCHAR SliceGroupMap[810]; -} DXVA_PicParams_H264; - -typedef struct { - UCHAR bScalingLists4x4[6][16]; - UCHAR bScalingLists8x8[2][64]; -} DXVA_Qmatrix_H264; - - -typedef struct { - UINT BSNALunitDataLocation; - UINT SliceBytesInBuffer; - USHORT wBadSliceChopping; - USHORT first_mb_in_slice; - USHORT NumMbsForSlice; - USHORT BitOffsetToSliceData; - UCHAR slice_type; - UCHAR luma_log2_weight_denom; - UCHAR chroma_log2_weight_denom; - - UCHAR num_ref_idx_l0_active_minus1; - UCHAR num_ref_idx_l1_active_minus1; - CHAR slice_alpha_c0_offset_div2; - CHAR slice_beta_offset_div2; - UCHAR Reserved8Bits; - DXVA_PicEntry_H264 RefPicList[2][32]; - SHORT Weights[2][32][3][2]; - CHAR slice_qs_delta; - CHAR slice_qp_delta; - UCHAR redundant_pic_cnt; - UCHAR direct_spatial_mv_pred_flag; - UCHAR cabac_init_idc; - UCHAR disable_deblocking_filter_idc; - USHORT slice_id; -} DXVA_Slice_H264_Long; - -typedef struct { - UINT BSNALunitDataLocation; - UINT SliceBytesInBuffer; - USHORT wBadSliceChopping; -} DXVA_Slice_H264_Short; - -typedef struct { - USHORT wFrameWidthInMbsMinus1; - USHORT wFrameHeightInMbsMinus1; - DXVA_PicEntry_H264 InPic; - DXVA_PicEntry_H264 OutPic; - USHORT PicOrderCnt_offset; - INT CurrPicOrderCnt; - UINT StatusReportFeedbackNumber; - UCHAR model_id; - UCHAR separate_colour_description_present_flag; - UCHAR film_grain_bit_depth_luma_minus8; - UCHAR film_grain_bit_depth_chroma_minus8; - UCHAR film_grain_full_range_flag; - UCHAR film_grain_colour_primaries; - UCHAR film_grain_transfer_characteristics; - UCHAR film_grain_matrix_coefficients; - UCHAR blending_mode_id; - UCHAR log2_scale_factor; - UCHAR comp_model_present_flag[4]; - UCHAR num_intensity_intervals_minus1[4]; - UCHAR num_model_values_minus1[4]; - UCHAR intensity_interval_lower_bound[3][16]; - UCHAR intensity_interval_upper_bound[3][16]; - SHORT comp_model_value[3][16][8]; -} DXVA_FilmGrainChar_H264; - -typedef struct { - union { - struct { - USHORT Fraction; - SHORT Value; - }; - LONG ll; - }; -}DXVA2_Fixed32; - -typedef struct { - UCHAR Cr; - UCHAR Cb; - UCHAR Y; - UCHAR Alpha; -}DXVA2_AYUVSample8; - -typedef struct { - USHORT Cr; - USHORT Cb; - USHORT Y; - USHORT Alpha; -}DXVA2_AYUVSample16; - -typedef struct { - DXVA2_Fixed32 MinValue; - DXVA2_Fixed32 MaxValue; - DXVA2_Fixed32 DefaultValue; - DXVA2_Fixed32 StepSize; -}DXVA2_ValueRange; - -typedef struct { - DXVA2_Fixed32 Brightness; - DXVA2_Fixed32 Contrast; - DXVA2_Fixed32 Hue; - DXVA2_Fixed32 Saturation; -}DXVA2_ProcAmpValues; - -typedef struct { - DXVA2_Fixed32 Level; - DXVA2_Fixed32 Threshold; - DXVA2_Fixed32 Radius; -}DXVA2_FilterValues; - -typedef struct { - UINT DeviceCaps; - D3DPOOL InputPool; - UINT NumForwardRefSamples; - UINT NumBackwardRefSamples; - UINT Reserved; - UINT DeinterlaceTechnology; - UINT ProcAmpControlCaps; - UINT VideoProcessorOperations; - UINT NoiseFilterTechnology; - UINT DetailFilterTechnology; -}DXVA2_VideoProcessorCaps; - -#ifndef _REFERENCE_TIME_ -#define _REFERENCE_TIME_ -typedef long long int64_t; -typedef int64_t REFERENCE_TIME; -#endif - -typedef struct { - REFERENCE_TIME Start; - REFERENCE_TIME End; - DXVA2_ExtendedFormat SampleFormat; - IDirect3DSurface9 *SrcSurface; - RECT SrcRect; - RECT DstRect; - DXVA2_AYUVSample8 Pal[16]; - DXVA2_Fixed32 PlanarAlpha; - DWORD SampleData; -}DXVA2_VideoSample; - - -typedef struct { - REFERENCE_TIME TargetFrame; - RECT TargetRect; - SIZE ConstrictionSize; - UINT StreamingFlags; - DXVA2_AYUVSample16 BackgroundColor; - DXVA2_ExtendedFormat DestFormat; - DXVA2_ProcAmpValues ProcAmpValues; - DXVA2_Fixed32 Alpha; - DXVA2_FilterValues NoiseFilterLuma; - DXVA2_FilterValues NoiseFilterChroma; - DXVA2_FilterValues DetailFilterLuma; - DXVA2_FilterValues DetailFilterChroma; - DWORD DestData; -} DXVA2_VideoProcessBltParams; - -#pragma pack(pop) - -/*************INTERFACES************/ -#ifdef __cplusplus -extern "C" { -#endif -#define _COM_interface struct -typedef _COM_interface IDirectXVideoDecoderService IDirectXVideoDecoderService; -typedef _COM_interface IDirectXVideoDecoder IDirectXVideoDecoder; - -#undef INTERFACE -#define INTERFACE IDirectXVideoDecoder -DECLARE_INTERFACE_( IDirectXVideoDecoder, IUnknown ) -{ - STDMETHOD( QueryInterface ) ( THIS_ REFIID, PVOID* ) PURE; - STDMETHOD_( ULONG, AddRef ) ( THIS ) PURE; - STDMETHOD_( ULONG, Release ) ( THIS ) PURE; - STDMETHOD( GetVideoDecoderService ) ( THIS_ IDirectXVideoDecoderService** ) PURE; - STDMETHOD( GetCreationParameters ) ( THIS_ GUID*, DXVA2_VideoDesc*, DXVA2_ConfigPictureDecode*, IDirect3DSurface9***, UINT* ) PURE; - STDMETHOD( GetBuffer ) ( THIS_ UINT, void**, UINT* ) PURE; - STDMETHOD( ReleaseBuffer ) ( THIS_ UINT ) PURE; - STDMETHOD( BeginFrame ) ( THIS_ IDirect3DSurface9 *, void* ) PURE; - STDMETHOD( EndFrame ) ( THIS_ HANDLE * ) PURE; - STDMETHOD( Execute ) ( THIS_ const DXVA2_DecodeExecuteParams* ) PURE; - - -}; - -#if !defined(__cplusplus) || defined(CINTERFACE) -#define IDirectXVideoDecoder_QueryInterface( p, a, b ) (p)->lpVtbl->QueryInterface( p, a, b ) -#define IDirectXVideoDecoder_AddRef( p ) (p)->lpVtbl->AddRef( p ) -#define IDirectXVideoDecoder_Release( p ) (p)->lpVtbl->Release( p ) -#define IDirectXVideoDecoder_BeginFrame( p, a, b ) (p)->lpVtbl->BeginFrame( p, a, b ) -#define IDirectXVideoDecoder_EndFrame( p, a ) (p)->lpVtbl->EndFrame( p, a ) -#define IDirectXVideoDecoder_Execute( p, a ) (p)->lpVtbl->Execute( p, a ) -#define IDirectXVideoDecoder_GetBuffer( p, a, b, c ) (p)->lpVtbl->GetBuffer( p, a, b, c ) -#define IDirectXVideoDecoder_GetCreationParameters( p, a, b, c, d, e ) (p)->lpVtbl->GetCreationParameters( p, a, b, c, d, e ) -#define IDirectXVideoDecoder_GetVideoDecoderService( p, a ) (p)->lpVtbl->GetVideoDecoderService( p, a ) -#define IDirectXVideoDecoder_ReleaseBuffer( p, a ) (p)->lpVtbl->ReleaseBuffer( p, a ) -#else -#define IDirectXVideoDecoder_QueryInterface( p, a, b ) (p)->QueryInterface( a, b ) -#define IDirectXVideoDecoder_AddRef( p ) (p)->AddRef() -#define IDirectXVideoDecoder_Release( p ) (p)->Release() -#define IDirectXVideoDecoder_BeginFrame( p, a, b ) (p)->BeginFrame( a, b ) -#define IDirectXVideoDecoder_EndFrame( p, a ) (p)->EndFrame( a ) -#define IDirectXVideoDecoder_Execute( p, a ) (p)->Execute( a ) -#define IDirectXVideoDecoder_GetBuffer( p, a, b, c ) (p)->GetBuffer( a, b, c ) -#define IDirectXVideoDecoder_GetCreationParameters( p, a, b, c, d, e ) (p)->GetCreationParameters( a, b, c, d, e ) -#define IDirectXVideoDecoder_GetVideoDecoderService( p, a ) (p)->GetVideoDecoderService( a ) -#define IDirectXVideoDecoder_ReleaseBuffer( p, a ) (p)->ReleaseBuffer( a ) -#endif - -#undef INTERFACE -#define INTERFACE IDirectXVideoAccelerationService -DECLARE_INTERFACE_( IDirectXVideoAccelerationService, IUnknown ) -{ - STDMETHOD( QueryInterface ) ( THIS_ REFIID, PVOID* ) PURE; - STDMETHOD_( ULONG, AddRef ) ( THIS ) PURE; - STDMETHOD_( ULONG, Release ) ( THIS ) PURE; - STDMETHOD( CreateSurface ) ( THIS_ UINT, UINT, UINT, D3DFORMAT, D3DPOOL, DWORD, DWORD, IDirect3DSurface9**, HANDLE* ) PURE; - -}; - -#if !defined(__cplusplus) || defined(CINTERFACE) -#define IDirectXVideoAccelerationService_QueryInterface( p, a, b ) (p)->lpVtbl->QueryInterface( p, a, b ) -#define IDirectXVideoAccelerationService_AddRef( p ) (p)->lpVtbl->AddRef( p ) -#define IDirectXVideoAccelerationService_Release( p ) (p)->lpVtbl->Release( p ) -#define IDirectXVideoAccelerationService_CreateSurface( p, a, b, c, d, e, f, g, h, i ) (p)->lpVtbl->CreateSurface( p, a, b, c, d, e, f, g, h, i ) -#else -#define IDirectXVideoAccelerationService_QueryInterface( p, a, b ) (p)->QueryInterface( a, b ) -#define IDirectXVideoAccelerationService_AddRef( p ) (p)->AddRef() -#define IDirectXVideoAccelerationService_Release( p ) (p)->Release() -#define IDirectXVideoAccelerationService_CreateSurface( p, a, b, c, d, e, f, g, h, i ) (p)->CreateSurface( a, b, c, d, e, f, g, h, i ) -#endif - -#undef INTERFACE -#define INTERFACE IDirectXVideoDecoderService -DECLARE_INTERFACE_( IDirectXVideoDecoderService, IDirectXVideoAccelerationService ) -{ - STDMETHOD( QueryInterface ) ( THIS_ REFIID, PVOID* ) PURE; - STDMETHOD_( ULONG, AddRef ) ( THIS ) PURE; - STDMETHOD_( ULONG, Release ) ( THIS ) PURE; - STDMETHOD( CreateSurface ) ( THIS_ UINT, UINT, UINT, D3DFORMAT, D3DPOOL, DWORD, DWORD, IDirect3DSurface9**, HANDLE* ) PURE; - STDMETHOD( GetDecoderDeviceGuids ) ( THIS_ UINT*, GUID ** ) PURE; - STDMETHOD( GetDecoderRenderTargets ) ( THIS_ REFGUID, UINT*, D3DFORMAT** ) PURE; - STDMETHOD( GetDecoderConfigurations ) ( THIS_ REFGUID, const DXVA2_VideoDesc*, IUnknown*, UINT*, DXVA2_ConfigPictureDecode** ) PURE; - STDMETHOD( CreateVideoDecoder ) ( THIS_ REFGUID, const DXVA2_VideoDesc*, DXVA2_ConfigPictureDecode*, IDirect3DSurface9**, UINT, IDirectXVideoDecoder** ) PURE; -}; - -#if !defined(__cplusplus) || defined(CINTERFACE) -#define IDirectXVideoDecoderService_QueryInterface( p, a, b ) (p)->lpVtbl->QueryInterface( p, a, b ) -#define IDirectXVideoDecoderService_AddRef( p ) (p)->lpVtbl->AddRef( p ) -#define IDirectXVideoDecoderService_Release( p ) (p)->lpVtbl->Release( p ) -#define IDirectXVideoDecoderService_CreateSurface( p, a, b, c, d, e, f, g, h, i ) (p)->lpVtbl->CreateSurface( p, a, b, c, d, e, f, g, h, i ) -#define IDirectXVideoDecoderService_CreateVideoDecoder( p, a, b, c, d, e, f ) (p)->lpVtbl->CreateVideoDecoder( p, a, b, c, d, e, f ) -#define IDirectXVideoDecoderService_GetDecoderConfigurations( p, a, b, c, d, e ) (p)->lpVtbl->GetDecoderConfigurations( p, a, b, c, d, e ) -#define IDirectXVideoDecoderService_GetDecoderDeviceGuids( p, a, b ) (p)->lpVtbl->GetDecoderDeviceGuids( p, a, b ) -#define IDirectXVideoDecoderService_GetDecoderRenderTargets( p, a, b, c ) (p)->lpVtbl->GetDecoderRenderTargets( p, a, b, c ) -#else -#define IDirectXVideoDecoderService_QueryInterface( p, a, b ) (p)->QueryInterface( a, b ) -#define IDirectXVideoDecoderService_AddRef( p ) (p)->AddRef() -#define IDirectXVideoDecoderService_Release( p ) (p)->Release() -#define IDirectXVideoDecoderService_CreateSurface( p, a, b, c, d, e, f, g, h, i ) (p)->CreateSurface( a, b, c, d, e, f, g, h, i ) -#define IDirectXVideoDecoderService_CreateVideoDecoder( p, a, b, c, d, e, f ) (p)->CreateVideoDecoder( a, b, c, d, e, f ) -#define IDirectXVideoDecoderService_GetDecoderConfigurations( p, a, b, c, d, e ) (p)->GetDecoderConfigurations( a, b, c, d, e ) -#define IDirectXVideoDecoderService_GetDecoderDeviceGuids( p, a, b ) (p)->GetDecoderDeviceGuids( a, b ) -#define IDirectXVideoDecoderService_GetDecoderRenderTargets( p, a, b, c ) (p)->GetDecoderRenderTargets( a, b, c ) -#endif - -#undef INTERFACE -#define INTERFACE IDirect3DDeviceManager9 -DECLARE_INTERFACE_( IDirect3DDeviceManager9, IUnknown ) -{ - STDMETHOD( QueryInterface ) ( THIS_ REFIID, PVOID* ) PURE; - STDMETHOD_( ULONG, AddRef ) ( THIS ) PURE; - STDMETHOD_( ULONG, Release ) ( THIS ) PURE; - STDMETHOD( ResetDevice ) ( THIS_ IDirect3DDevice9*, UINT ) PURE; - STDMETHOD( OpenDeviceHandle ) ( THIS_ HANDLE* ) PURE; - STDMETHOD( CloseDeviceHandle ) ( THIS_ HANDLE ) PURE; - STDMETHOD( TestDevice ) ( THIS_ HANDLE ) PURE; - STDMETHOD( LockDevice ) ( THIS_ HANDLE, IDirect3DDevice9**, BOOL ) PURE; - STDMETHOD( UnlockDevice ) ( THIS_ HANDLE, BOOL ) PURE; - STDMETHOD( GetVideoService ) ( THIS_ HANDLE, REFIID, void** ) PURE; -}; - -#if !defined(__cplusplus) || defined(CINTERFACE) -#define IDirect3DDeviceManager9_QueryInterface( p, a, b ) (p)->lpVtbl->QueryInterface( p, a, b ) -#define IDirect3DDeviceManager9_AddRef( p ) (p)->lpVtbl->AddRef( p ) -#define IDirect3DDeviceManager9_Release( p ) (p)->lpVtbl->Release( p ) -#define IDirect3DDeviceManager9_ResetDevice( p, a, b ) (p)->lpVtbl->ResetDevice( p, a, b ) -#define IDirect3DDeviceManager9_OpenDeviceHandle( p, a ) (p)->lpVtbl->OpenDeviceHandle( p, a ) -#define IDirect3DDeviceManager9_CloseDeviceHandle( p, a ) (p)->lpVtbl->CloseDeviceHandle( p, a ) -#define IDirect3DDeviceManager9_TestDevice( p, a ) (p)->lpVtbl->TestDevice( p, a ) -#define IDirect3DDeviceManager9_LockDevice( p, a, b, c ) (p)->lpVtbl->LockDevice( p, a, b, c ) -#define IDirect3DDeviceManager9_UnlockDevice( p, a, b ) (p)->lpVtbl->UnlockDevice( p, a, b ) -#define IDirect3DDeviceManager9_GetVideoService( p, a, b, c ) (p)->lpVtbl->GetVideoService( p, a, b, c ) -#else -#define IDirect3DDeviceManager9_QueryInterface( p, a, b ) (p)->QueryInterface( a, b ) -#define IDirect3DDeviceManager9_AddRef( p ) (p)->AddRef() -#define IDirect3DDeviceManager9_Release( p ) (p)->Release() -#define IDirect3DDeviceManager9_ResetDevice( p, a, b ) (p)->ResetDevice( a, b ) -#define IDirect3DDeviceManager9_OpenDeviceHandle( p, a ) (p)->OpenDeviceHandle( a ) -#define IDirect3DDeviceManager9_CloseDeviceHandle( p, a ) (p)->CloseDeviceHandle( a ) -#define IDirect3DDeviceManager9_TestDevice( p, a ) (p)->TestDevice( a ) -#define IDirect3DDeviceManager9_LockDevice( p, a, b, c ) (p)->LockDevice( a, b, c ) -#define IDirect3DDeviceManager9_UnlockDevice( p, a, b ) (p)->UnlockDevice( a, b ) -#define IDirect3DDeviceManager9_GetVideoService( p, a, b, c ) (p)->GetVideoService( a, b, c ) -#endif - -typedef _COM_interface IDirectXVideoProcessorService IDirectXVideoProcessorService; -typedef _COM_interface IDirectXVideoProcessor IDirectXVideoProcessor; - -#undef INTERFACE -#define INTERFACE IDirectXVideoProcessor -DECLARE_INTERFACE_( IDirectXVideoProcessor, IUnknown ) -{ - STDMETHOD( QueryInterface ) ( THIS_ REFIID, PVOID* ) PURE; - STDMETHOD_( ULONG, AddRef ) ( THIS ) PURE; - STDMETHOD_( ULONG, Release ) ( THIS ) PURE; - STDMETHOD( GetVideoProcessorService ) ( THIS_ IDirectXVideoProcessorService** ) PURE; - STDMETHOD( GetCreationParameters ) ( THIS_ GUID*, DXVA2_VideoDesc*, D3DFORMAT*, UINT* ) PURE; - STDMETHOD( GetVideoProcessorCaps ) ( THIS_ DXVA2_VideoProcessorCaps* ) PURE; - STDMETHOD( GetProcAmpRange ) ( THIS_ UINT, DXVA2_ValueRange* ) PURE; - STDMETHOD( GetFilterPropertyRange ) ( THIS_ UINT, DXVA2_ValueRange* ) PURE; - STDMETHOD( VideoProcessBlt ) ( THIS_ IDirect3DSurface9*, DXVA2_VideoProcessBltParams*, DXVA2_VideoSample*, UINT, HANDLE* ) PURE; -}; - -#if !defined(__cplusplus) || defined(CINTERFACE) -#define IDirectXVideoProcessor_QueryInterface( p, a, b ) (p)->lpVtbl->QueryInterface( p, a, b ) -#define IDirectXVideoProcessor_AddRef( p ) (p)->lpVtbl->AddRef( p ) -#define IDirectXVideoProcessor_Release( p ) (p)->lpVtbl->Release( p ) -#define IDirectXVideoProcessor_GetVideoProcessorService( p, a ) (p)->lpVtbl->GetVideoProcessorService( p, a ) -#define IDirectXVideoProcessor_GetCreationParameters( p, a, b, c, d ) (p)->lpVtbl->GetCreationParameters( p, a, b, c, d ) -#define IDirectXVideoProcessor_GetVideoProcessorCaps( p, a ) (p)->lpVtbl->GetVideoProcessorCaps( p, a ) -#define IDirectXVideoProcessor_GetProcAmpRange( p, a, b ) (p)->lpVtbl->GetProcAmpRange( p, a, b ) -#define IDirectXVideoProcessor_GetFilterPropertyRange( p, a, b ) (p)->lpVtbl->GetFilterPropertyRange( p, a, b ) -#define IDirectXVideoProcessor_VideoProcessBlt( p, a, b, c, d, e ) (p)->lpVtbl->VideoProcessBlt( p, a, b, c, d, e ) -#else -#define IDirectXVideoProcessor_QueryInterface( p, a, b ) (p)->QueryInterface( a, b ) -#define IDirectXVideoProcessor_AddRef( p ) (p)->AddRef() -#define IDirectXVideoProcessor_Release( p ) (p)->Release() -#define IDirectXVideoProcessor_GetVideoProcessorService( p, a ) (p)->GetVideoProcessorService( a ) -#define IDirectXVideoProcessor_GetCreationParameters( p, a, b, c, d ) (p)->GetCreationParameters( a, b, c, d ) -#define IDirectXVideoProcessor_GetVideoProcessorCaps( p, a ) (p)->GetVideoProcessorCaps( a ) -#define IDirectXVideoProcessor_GetProcAmpRange( p, a, b ) (p)->GetProcAmpRange( a, b ) -#define IDirectXVideoProcessor_GetFilterPropertyRange( p, a, b ) (p)->GetFilterPropertyRange( a, b ) -#define IDirectXVideoProcessor_VideoProcessBlt( p, a, b, c, d, e ) (p)->VideoProcessBlt( a, b, c, d, e ) -#endif - - -#undef INTERFACE -#define INTERFACE IDirectXVideoProcessorService -DECLARE_INTERFACE_( IDirectXVideoProcessorService, IDirectXVideoAccelerationService ) -{ - STDMETHOD( QueryInterface ) ( THIS_ REFIID, PVOID* ) PURE; - STDMETHOD_( ULONG, AddRef ) ( THIS ) PURE; - STDMETHOD_( ULONG, Release ) ( THIS ) PURE; - STDMETHOD( CreateSurface ) ( THIS_ UINT, UINT, UINT, D3DFORMAT, D3DPOOL, DWORD, DWORD, IDirect3DSurface9**, HANDLE* ) PURE; - STDMETHOD( RegisterVideoProcessorSoftwareDevice ) ( THIS_ void* ) PURE; - STDMETHOD( GetVideoProcessorDeviceGuids ) ( THIS_ DXVA2_VideoDesc*, UINT, GUID** ) PURE; - STDMETHOD( GetVideoProcessorRenderTargets ) ( THIS_ REFGUID, DXVA2_VideoDesc*, UINT*, D3DFORMAT** ) PURE; - STDMETHOD( GetVideoProcessorSubStreamFormats ) ( THIS_ REFGUID, DXVA2_VideoDesc*, D3DFORMAT, UINT*, D3DFORMAT** ) PURE; - STDMETHOD( GetVideoProcessorCaps ) ( THIS_ REFGUID, DXVA2_VideoDesc*, D3DFORMAT, DXVA2_VideoProcessorCaps* ) PURE; - STDMETHOD( GetProcAmpRange ) ( THIS_ REFGUID, DXVA2_VideoDesc*, D3DFORMAT, UINT, DXVA2_ValueRange* ) PURE; - STDMETHOD( GetFilterPropertyRange ) ( THIS_ REFGUID, DXVA2_VideoDesc*, D3DFORMAT, UINT, DXVA2_ValueRange* ) PURE; - STDMETHOD( CreateVideoProcessor ) ( THIS_ REFGUID, DXVA2_VideoDesc*, D3DFORMAT, UINT, IDirectXVideoProcessor** ) PURE; -}; - -#if !defined(__cplusplus) || defined(CINTERFACE) -#define IDirectXVideoProcessorService_QueryInterface( p, a, b ) (p)->lpVtbl->QueryInterface( p, a, b ) -#define IDirectXVideoProcessorService_AddRef( p ) (p)->lpVtbl->AddRef( p ) -#define IDirectXVideoProcessorService_Release( p ) (p)->lpVtbl->Release( p ) -#define IDirectXVideoProcessorService_CreateSurface( p, a, b, c, d, e, f, g, h, i ) (p)->lpVtbl->CreateSurface( p, a, b, c, d, e, f, g, h, i ) -#define IDirectXVideoProcessorService_RegisterVideoProcessorSoftwareDevice( p, a ) (p)->lpVtbl->RegisterVideoProcessorSoftwareDevice( p, a ) -#define IDirectXVideoProcessorService_GetVideoProcessorDeviceGuids( p, a, b, c ) (p)->lpVtbl->GetVideoProcessorDeviceGuids( p, a, b, c ) -#define IDirectXVideoProcessorService_GetVideoProcessorRenderTargets( p, a, b, c, d ) (p)->lpVtbl->GetVideoProcessorRenderTargets( p, a, b, c, d ) -#define IDirectXVideoProcessorService_GetVideoProcessorSubStreamFormats( p, a, b, c, d, e ) (p)->lpVtbl->GetVideoProcessorSubStreamFormats( p, a, b, c, d, e ) -#define IDirectXVideoProcessorService_GetVideoProcessorCaps( p, a, b, c, d ) (p)->lpVtbl->GetVideoProcessorCaps( p, a, b, c, d ) -#define IDirectXVideoProcessorService_GetProcAmpRange( p, a, b, c, d, e ) (p)->lpVtbl->GetProcAmpRange( p, a, b, c, d, e ) -#define IDirectXVideoProcessorService_GetFilterPropertyRange( p, a, b, c, d, e ) (p)->lpVtbl->GetFilterPropertyRange( p, a, b, c, d, e ) -#define IDirectXVideoProcessorService_CreateVideoProcessor( p, a, b, c, d, e ) (p)->lpVtbl->CreateVideoProcessor( p, a, b, c, d, e ) -#else -#define IDirectXVideoProcessorService_QueryInterface( p, a, b ) (p)->QueryInterface( a, b ) -#define IDirectXVideoProcessorService_AddRef( p ) (p)->AddRef() -#define IDirectXVideoProcessorService_Release( p ) (p)->Release() -#define IDirectXVideoProcessorService_CreateSurface( p, a, b, c, d, e, f, g, h, i ) (p)->CreateSurface( a, b, c, d, e, f, g, h, i ) -#define IDirectXVideoProcessorService_RegisterVideoProcessorSoftwareDevice( p, a ) (p)->RegisterVideoProcessorSoftwareDevice( a ) -#define IDirectXVideoProcessorService_GetVideoProcessorDeviceGuids( p, a, b, c ) (p)->GetVideoProcessorDeviceGuids( a, b, c ) -#define IDirectXVideoProcessorService_GetVideoProcessorRenderTargets( p, a, b, c, d ) (p)->GetVideoProcessorRenderTargets( a, b, c, d ) -#define IDirectXVideoProcessorService_GetVideoProcessorSubStreamFormats( p, a, b, c, d, e ) (p)->GetVideoProcessorSubStreamFormats( a, b, c, d, e ) -#define IDirectXVideoProcessorService_GetVideoProcessorCaps( p, a, b, c, d ) (p)->GetVideoProcessorCaps( a, b, c, d ) -#define IDirectXVideoProcessorService_GetProcAmpRange( p, a, b, c, d, e ) (p)->GetProcAmpRange( a, b, c, d, e ) -#define IDirectXVideoProcessorService_GetFilterPropertyRange( p, a, b, c, d, e ) (p)->GetFilterPropertyRange( a, b, c, d, e ) -#define IDirectXVideoProcessorService_CreateVideoProcessor( p, a, b, c, d, e ) (p)->CreateVideoProcessor( a, b, c, d, e ) -#endif - - -/***************************************************************************************************** -************************DXVA Video Processor******************************************************** -*******************************************************************************************************/ - - - -/*#undef INTERFACE -#define INTERFACE IDirectXVideoService -DECLARE_INTERFACE_(IDirectXVideoService,IUnknown) -{ - STDMETHOD(DXVA2CreateVideoService)(IDirect3DDevice9*, REFIID, void**) PURE; -}; - -#if !defined(__cplusplus) || defined(CINTERFACE) -#define IDirectXVideoService_DXVA2CreateVideoService(a,b,c) DXVA2CreateVideoService(a,b,c) -#else -#define IDirectXVideoService_DXVA2CreateVideoService(a,b,c) DXVA2CreateVideoService(a,b,c) -#endif*/ - - -#ifdef __cplusplus -}; -#endif - -#ifdef __cplusplus -extern "C" HRESULT WINAPI DXVA2CreateVideoService( IDirect3DDevice9 *, - REFIID riid, - void **ppService ); -#else -extern HRESULT WINAPI DXVA2CreateVideoService( IDirect3DDevice9 *, - REFIID riid, - void **ppService ); -#endif - -typedef -enum _DXVA2_VideoChromaSubSampling -{ DXVA2_VideoChromaSubsamplingMask = 0xf, - DXVA2_VideoChromaSubsampling_Unknown = 0, - DXVA2_VideoChromaSubsampling_ProgressiveChroma = 0x8, - DXVA2_VideoChromaSubsampling_Horizontally_Cosited = 0x4, - DXVA2_VideoChromaSubsampling_Vertically_Cosited = 0x2, - DXVA2_VideoChromaSubsampling_Vertically_AlignedChromaPlanes = 0x1, - DXVA2_VideoChromaSubsampling_MPEG2 = ( DXVA2_VideoChromaSubsampling_Horizontally_Cosited | DXVA2_VideoChromaSubsampling_Vertically_AlignedChromaPlanes ), - DXVA2_VideoChromaSubsampling_MPEG1 = DXVA2_VideoChromaSubsampling_Vertically_AlignedChromaPlanes, - DXVA2_VideoChromaSubsampling_DV_PAL = ( DXVA2_VideoChromaSubsampling_Horizontally_Cosited | DXVA2_VideoChromaSubsampling_Vertically_Cosited ), - DXVA2_VideoChromaSubsampling_Cosited = ( ( DXVA2_VideoChromaSubsampling_Horizontally_Cosited | DXVA2_VideoChromaSubsampling_Vertically_Cosited ) | DXVA2_VideoChromaSubsampling_Vertically_AlignedChromaPlanes )} DXVA2_VideoChromaSubSampling; - -typedef -enum _DXVA2_NominalRange -{ DXVA2_NominalRangeMask = 0x7, - DXVA2_NominalRange_Unknown = 0, - DXVA2_NominalRange_Normal = 1, - DXVA2_NominalRange_Wide = 2, - DXVA2_NominalRange_0_255 = 1, - DXVA2_NominalRange_16_235 = 2, - DXVA2_NominalRange_48_208 = 3} DXVA2_NominalRange; - -typedef -enum _DXVA2_VideoLighting -{ DXVA2_VideoLightingMask = 0xf, - DXVA2_VideoLighting_Unknown = 0, - DXVA2_VideoLighting_bright = 1, - DXVA2_VideoLighting_office = 2, - DXVA2_VideoLighting_dim = 3, - DXVA2_VideoLighting_dark = 4} DXVA2_VideoLighting; - -typedef -enum _DXVA2_VideoPrimaries -{ DXVA2_VideoPrimariesMask = 0x1f, - DXVA2_VideoPrimaries_Unknown = 0, - DXVA2_VideoPrimaries_reserved = 1, - DXVA2_VideoPrimaries_BT709 = 2, - DXVA2_VideoPrimaries_BT470_2_SysM = 3, - DXVA2_VideoPrimaries_BT470_2_SysBG = 4, - DXVA2_VideoPrimaries_SMPTE170M = 5, - DXVA2_VideoPrimaries_SMPTE240M = 6, - DXVA2_VideoPrimaries_EBU3213 = 7, - DXVA2_VideoPrimaries_SMPTE_C = 8} DXVA2_VideoPrimaries; - -typedef -enum _DXVA2_VideoTransferFunction -{ DXVA2_VideoTransFuncMask = 0x1f, - DXVA2_VideoTransFunc_Unknown = 0, - DXVA2_VideoTransFunc_10 = 1, - DXVA2_VideoTransFunc_18 = 2, - DXVA2_VideoTransFunc_20 = 3, - DXVA2_VideoTransFunc_22 = 4, - DXVA2_VideoTransFunc_709 = 5, - DXVA2_VideoTransFunc_240M = 6, - DXVA2_VideoTransFunc_sRGB = 7, - DXVA2_VideoTransFunc_28 = 8} DXVA2_VideoTransferFunction; - -typedef -enum _DXVA2_SampleFormat -{ DXVA2_SampleFormatMask = 0xff, - DXVA2_SampleUnknown = 0, - DXVA2_SampleProgressiveFrame = 2, - DXVA2_SampleFieldInterleavedEvenFirst = 3, - DXVA2_SampleFieldInterleavedOddFirst = 4, - DXVA2_SampleFieldSingleEven = 5, - DXVA2_SampleFieldSingleOdd = 6, - DXVA2_SampleSubStream = 7} DXVA2_SampleFormat; - -typedef -enum _DXVA2_VideoTransferMatrix -{ DXVA2_VideoTransferMatrixMask = 0x7, - DXVA2_VideoTransferMatrix_Unknown = 0, - DXVA2_VideoTransferMatrix_BT709 = 1, - DXVA2_VideoTransferMatrix_BT601 = 2, - DXVA2_VideoTransferMatrix_SMPTE240M = 3} DXVA2_VideoTransferMatrix; - -enum __MIDL___MIDL_itf_dxva2api_0000_0000_0004 -{ DXVA2_NoiseFilterLumaLevel = 1, - DXVA2_NoiseFilterLumaThreshold = 2, - DXVA2_NoiseFilterLumaRadius = 3, - DXVA2_NoiseFilterChromaLevel = 4, - DXVA2_NoiseFilterChromaThreshold = 5, - DXVA2_NoiseFilterChromaRadius = 6, - DXVA2_DetailFilterLumaLevel = 7, - DXVA2_DetailFilterLumaThreshold = 8, - DXVA2_DetailFilterLumaRadius = 9, - DXVA2_DetailFilterChromaLevel = 10, - DXVA2_DetailFilterChromaThreshold = 11, - DXVA2_DetailFilterChromaRadius = 12}; - -enum __MIDL___MIDL_itf_dxva2api_0000_0000_0008 -{ DXVA2_VideoProcess_None = 0, - DXVA2_VideoProcess_YUV2RGB = 0x1, - DXVA2_VideoProcess_StretchX = 0x2, - DXVA2_VideoProcess_StretchY = 0x4, - DXVA2_VideoProcess_AlphaBlend = 0x8, - DXVA2_VideoProcess_SubRects = 0x10, - DXVA2_VideoProcess_SubStreams = 0x20, - DXVA2_VideoProcess_SubStreamsExtended = 0x40, - DXVA2_VideoProcess_YUV2RGBExtended = 0x80, - DXVA2_VideoProcess_AlphaBlendExtended = 0x100, - DXVA2_VideoProcess_Constriction = 0x200, - DXVA2_VideoProcess_NoiseFilter = 0x400, - DXVA2_VideoProcess_DetailFilter = 0x800, - DXVA2_VideoProcess_PlanarAlpha = 0x1000, - DXVA2_VideoProcess_LinearScaling = 0x2000, - DXVA2_VideoProcess_GammaCompensated = 0x4000, - DXVA2_VideoProcess_MaintainsOriginalFieldData = 0x8000, - DXVA2_VideoProcess_Mask = 0xffff}; - - - -__inline float hb_dx_fixedtofloat( const DXVA2_Fixed32 _fixed_ ); - -__inline const DXVA2_Fixed32 hb_dx_fixed32_opaque_alpha(); - -__inline DXVA2_Fixed32 hb_dx_floattofixed( const float _float_ ); -#endif -#endif //_DXVA2API_H diff --git a/libhb/hb.c b/libhb/hb.c index fdda96e77..12e541a92 100644 --- a/libhb/hb.c +++ b/libhb/hb.c @@ -67,31 +67,11 @@ struct hb_handle_s // power management opaque pointer void * system_sleep_opaque; - - // When hardware decoding, scan must also use hardware so that - // libav hardware decode contest is used. So set hardware - // decoding as a global property on the hb instance. - hb_hwd_t hwd; }; hb_work_object_t * hb_objects = NULL; int hb_instance_counter = 0; -void hb_hwd_set_enable( hb_handle_t *h, uint8_t enable ) -{ - h->hwd.enable = enable; -} - -int hb_hwd_enabled( hb_handle_t *h ) -{ - return h->hwd.enable; -} - -hb_hwd_t * hb_hwd_get_context( hb_handle_t *h ) -{ - return &h->hwd; -} - static void thread_func( void * ); static int ff_lockmgr_cb(void **mutex, enum AVLockOp op) diff --git a/libhb/hb.h b/libhb/hb.h index 94f99bce7..da8710aba 100644 --- a/libhb/hb.h +++ b/libhb/hb.h @@ -33,10 +33,6 @@ void hb_register_logger( void (*log_cb)(const char* message) ); hb_handle_t * hb_init( int verbose ); void hb_log_level_set(hb_handle_t *h, int level); -void hb_hwd_set_enable( hb_handle_t *h, uint8_t enable ); -int hb_hwd_enabled( hb_handle_t *h ); -hb_hwd_t * hb_hwd_get_context(); - /* hb_get_version() */ const char * hb_get_full_description(); const char * hb_get_version( hb_handle_t * ); diff --git a/libhb/hb_json.c b/libhb/hb_json.c index 85de1e838..5bc8e5f50 100644 --- a/libhb/hb_json.c +++ b/libhb/hb_json.c @@ -395,8 +395,8 @@ hb_dict_t* hb_job_to_dict( const hb_job_t * job ) "s:{s:o, s:o, s:o,}," // PAR {Num, Den} "s:{s:o, s:o}," - // Video {Codec, QSV {Decode, AsyncDepth}} - "s:{s:o, s:o, s:o, s:{s:o, s:o}}," + // Video {Encoder, OpenCL, QSV {Decode, AsyncDepth}} + "s:{s:o, s:o, s:{s:o, s:o}}," // Audio {CopyMask, FallbackEncoder, AudioList []} "s:{s:[], s:o, s:[]}," // Subtitles {Search {Enable, Forced, Default, Burn}, SubtitleList []} @@ -421,7 +421,6 @@ hb_dict_t* hb_job_to_dict( const hb_job_t * job ) "Video", "Encoder", hb_value_int(job->vcodec), "OpenCL", hb_value_bool(job->use_opencl), - "HWDecode", hb_value_bool(job->use_hwd), "QSV", "Decode", hb_value_bool(job->qsv.decode), "AsyncDepth", hb_value_int(job->qsv.async_depth), @@ -730,15 +729,13 @@ void hb_json_job_scan( hb_handle_t * h, const char * json_job ) dict = hb_value_json(json_job); - int title_index, use_hwd = 0; + int title_index; char *path = NULL; - result = json_unpack_ex(dict, &error, 0, "{s:{s:s, s:i}, s?{s?b}}", + result = json_unpack_ex(dict, &error, 0, "{s:{s:s, s:i}}", "Source", "Path", unpack_s(&path), - "Title", unpack_i(&title_index), - "Video", - "HWDecode", unpack_b(&use_hwd) + "Title", unpack_i(&title_index) ); if (result < 0) { @@ -749,7 +746,6 @@ void hb_json_job_scan( hb_handle_t * h, const char * json_job ) // If the job wants to use Hardware decode, it must also be // enabled during scan. So enable it here. - hb_hwd_set_enable(h, use_hwd); hb_scan(h, path, title_index, -1, 0, 0); // Wait for scan to complete @@ -844,10 +840,10 @@ hb_job_t* hb_dict_to_job( hb_handle_t * h, hb_dict_t *dict ) "s?{s:i, s:i}," // Video {Codec, Quality, Bitrate, Preset, Tune, Profile, Level, Options // TwoPass, Turbo, ColorMatrixCode, - // OpenCL, HWDecode, QSV {Decode, AsyncDepth}} + // OpenCL, QSV {Decode, AsyncDepth}} "s:{s:o, s?f, s?i, s?s, s?s, s?s, s?s, s?s," " s?b, s?b, s?i," - " s?b, s?b, s?{s?b, s?i}}," + " s?b, s?{s?b, s?i}}," // Audio {CopyMask, FallbackEncoder, AudioList} "s?{s?o, s?o, s?o}," // Subtitle {Search {Enable, Forced, Default, Burn}, SubtitleList} @@ -890,7 +886,6 @@ hb_job_t* hb_dict_to_job( hb_handle_t * h, hb_dict_t *dict ) "Turbo", unpack_b(&job->fastfirstpass), "ColorMatrixCode", unpack_i(&job->color_matrix_code), "OpenCL", unpack_b(&job->use_opencl), - "HWDecode", unpack_b(&job->use_hwd), "QSV", "Decode", unpack_b(&job->qsv.decode), "AsyncDepth", unpack_i(&job->qsv.async_depth), diff --git a/libhb/hbtypes.h b/libhb/hbtypes.h index 42a82dd27..c4e36a9d4 100644 --- a/libhb/hbtypes.h +++ b/libhb/hbtypes.h @@ -11,7 +11,6 @@ #define HB_TYPES_H typedef struct hb_handle_s hb_handle_t; -typedef struct hb_hwd_s hb_hwd_t; typedef struct hb_list_s hb_list_t; typedef struct hb_buffer_list_s hb_buffer_list_t; typedef struct hb_rate_s hb_rate_t; diff --git a/libhb/internal.h b/libhb/internal.h index 6bd8695f4..4e477eba6 100644 --- a/libhb/internal.h +++ b/libhb/internal.h @@ -14,14 +14,6 @@ #endif /*********************************************************************** - * Hardware Decode Context - **********************************************************************/ -struct hb_hwd_s -{ - uint8_t enable; -}; - -/*********************************************************************** * common.c **********************************************************************/ void hb_log( char * log, ... ) HB_WPRINTF(1,2); diff --git a/libhb/libhb_presets.list b/libhb/libhb_presets.list index 0009d8674..d66c86568 100644 --- a/libhb/libhb_presets.list +++ b/libhb/libhb_presets.list @@ -1,6 +1,6 @@ <resources> <section name="PresetTemplate"> - <integer name="VersionMajor" value="13" /> + <integer name="VersionMajor" value="14" /> <integer name="VersionMinor" value="0" /> <integer name="VersionMicro" value="0" /> <json name="Preset" file="preset_template.json" /> diff --git a/libhb/module.defs b/libhb/module.defs index 612177e0d..9695abd60 100644 --- a/libhb/module.defs +++ b/libhb/module.defs @@ -37,10 +37,6 @@ LIBHB.out += $(LIBHB.a) ############################################################################### -ifeq (1,$(FEATURE.hwd)) -LIBHB.GCC.D += USE_HWD -endif - ifeq (1,$(FEATURE.libav_aac)) LIBHB.GCC.D += USE_LIBAV_AAC endif diff --git a/libhb/oclnv12toyuv.c b/libhb/oclnv12toyuv.c deleted file mode 100644 index b65039fa0..000000000 --- a/libhb/oclnv12toyuv.c +++ /dev/null @@ -1,334 +0,0 @@ -/* oclnv12toyuv.c - - Copyright (c) 2003-2016 HandBrake Team - This file is part of the HandBrake source code - Homepage: <http://handbrake.fr/>. - It may be used under the terms of the GNU General Public License v2. - For full terms see the file COPYING file or visit http://www.gnu.org/licenses/gpl-2.0.html - - Authors: Peng Gao <[email protected]> <http://www.multicorewareinc.com/> - Li Cao <[email protected]> <http://www.multicorewareinc.com/> - */ - -#ifdef USE_HWD - -#include "opencl.h" -#include "vadxva2.h" -#include "oclnv12toyuv.h" - -/** - * It creates are opencl bufs w is input frame width, h is input frame height -*/ -static int hb_nv12toyuv_create_cl_buf( KernelEnv *kenv, int w, int h, hb_va_dxva2_t *dxva2 ); - -/** - * It creates are opencl kernel. kernel name is nv12toyuv -*/ -static int hb_nv12toyuv_create_cl_kernel( KernelEnv *kenv, hb_va_dxva2_t *dxva2 ); - -/** - * It set opencl arg, input data,output data, input width, output height -*/ -static int hb_nv12toyuv_setkernelarg( KernelEnv *kenv, int w, int h, hb_va_dxva2_t *dxva2 ); - -/** - * It initialize nv12 to yuv kernel. -*/ -static int hb_init_nv12toyuv_ocl( KernelEnv *kenv, int w, int h, hb_va_dxva2_t *dxva2 ); - -/** - * Run nv12 to yuv kernel. - */ -static int hb_nv12toyuv( void **userdata, KernelEnv *kenv ); - -/** - * register nv12 to yuv kernel. - */ -static int hb_nv12toyuv_reg_kernel( void ); - -/** - * It creates are opencl bufs w is input frame width, h is input frame height - */ -static int hb_nv12toyuv_create_cl_buf( KernelEnv *kenv, int w, int h, hb_va_dxva2_t *dxva2 ) -{ - if (hb_ocl == NULL) - { - hb_error("hb_nv12toyuv_create_cl_kernel: OpenCL support not available"); - return 1; - } - - cl_int status = CL_SUCCESS; - int in_bytes = w*h*3/2; - HB_OCL_BUF_CREATE(hb_ocl, dxva2->cl_mem_nv12, CL_MEM_READ_ONLY|CL_MEM_ALLOC_HOST_PTR, in_bytes); - HB_OCL_BUF_CREATE(hb_ocl, dxva2->cl_mem_yuv, CL_MEM_READ_WRITE|CL_MEM_ALLOC_HOST_PTR, in_bytes); - return 0; -} - -/** - * It creates are opencl kernel. kernel name is nv12toyuv - */ -static int hb_nv12toyuv_create_cl_kernel( KernelEnv *kenv, hb_va_dxva2_t *dxva2 ) -{ - if (hb_ocl == NULL) - { - hb_error("hb_nv12toyuv_create_cl_kernel: OpenCL support not available"); - return 1; - } - - int ret; - dxva2->nv12toyuv = hb_ocl->clCreateKernel(kenv->program, "nv12toyuv", &ret); - return ret; -} - -/** - * It set opencl arg, input data,output data, input width, output height - */ -static int hb_nv12toyuv_setkernelarg( KernelEnv *kenv, int w, int h, hb_va_dxva2_t *dxva2 ) -{ - int arg = 0, status; - kenv->kernel = dxva2->nv12toyuv; - - if (hb_ocl == NULL) - { - hb_error("hb_nv12toyuv_setkernelarg: OpenCL support not available"); - return 1; - } - - HB_OCL_CHECK(hb_ocl->clSetKernelArg, kenv->kernel, arg++, sizeof(cl_mem), &dxva2->cl_mem_nv12); - HB_OCL_CHECK(hb_ocl->clSetKernelArg, kenv->kernel, arg++, sizeof(cl_mem), &dxva2->cl_mem_yuv); - HB_OCL_CHECK(hb_ocl->clSetKernelArg, kenv->kernel, arg++, sizeof(int), &w); - HB_OCL_CHECK(hb_ocl->clSetKernelArg, kenv->kernel, arg++, sizeof(int), &h); - return 0; -} - -/** - * It initialize nv12 to yuv kernel. - */ -static int hb_init_nv12toyuv_ocl( KernelEnv *kenv, int w, int h, hb_va_dxva2_t *dxva2 ) -{ - if( !dxva2->nv12toyuv ) - { - if( hb_nv12toyuv_create_cl_buf( kenv, w, h, dxva2 ) ) - { - hb_log( "OpenCL: nv12toyuv_create_cl_buf fail" ); - return -1; - } - if (!dxva2->nv12toyuv_tmp_in) - { - dxva2->nv12toyuv_tmp_in = malloc (w*h*3/2); - } - - if (!dxva2->nv12toyuv_tmp_out) - { - dxva2->nv12toyuv_tmp_out = malloc (w*h*3/2); - } - - hb_nv12toyuv_create_cl_kernel( kenv, dxva2 ); - } - return 0; -} - -/** - * copy_plane - * @param dst - - * @param src - - * @param dstride - - * @param sstride - - * @param h - - */ -static uint8_t *copy_plane( uint8_t *dst, uint8_t* src, int dstride, int sstride, - int h ) -{ - if ( dstride == sstride ) - { - memcpy( dst, src, dstride * h ); - return dst + dstride * h; - } - - int lbytes = dstride <= sstride? dstride : sstride; - while ( --h >= 0 ) - { - memcpy( dst, src, lbytes ); - src += sstride; - dst += dstride; - } - - return dst; -} - -/** - * Run nv12 to yuv kernel. - */ -static int hb_nv12toyuv( void **userdata, KernelEnv *kenv ) -{ - int status; - int w = (int)userdata[0]; - int h = (int)userdata[1]; - uint8_t *bufi1 = userdata[2]; - int *crop = userdata[3]; - hb_va_dxva2_t *dxva2 = userdata[4]; - - uint8_t *bufi2 = userdata[5]; - int p = (int)userdata[6]; - int decomb = (int)userdata[7]; - int detelecine = (int)userdata[8]; - int i; - if( hb_init_nv12toyuv_ocl( kenv, w, h, dxva2 ) ) - { - return -1; - } - - if( hb_nv12toyuv_setkernelarg( kenv, w, h, dxva2 ) ) - { - return -1; - } - - if (hb_ocl == NULL) - { - hb_error("hb_nv12toyuv: OpenCL support not available"); - return -1; - } - - int in_bytes = w*h*3/2; - if( kenv->isAMD ) - { - void *data = hb_ocl->clEnqueueMapBuffer(kenv->command_queue, - dxva2->cl_mem_nv12, - CL_MAP_WRITE_INVALIDATE_REGION, - CL_TRUE, 0, in_bytes, 0, NULL, NULL, NULL); - - for ( i = 0; i < dxva2->height; i++ ) - { - memcpy( data + i * dxva2->width, bufi1 + i * p, dxva2->width ); - if ( i < dxva2->height >> 1 ) - { - memcpy( data + ( dxva2->width * dxva2->height ) + i * dxva2->width, bufi2 + i * p, dxva2->width ); - } - } - hb_ocl->clEnqueueUnmapMemObject(kenv->command_queue, dxva2->cl_mem_nv12, - data, 0, NULL, NULL); - } - else - { - uint8_t *tmp = (uint8_t*)malloc( dxva2->width * dxva2->height * 3 / 2 ); - for( i = 0; i < dxva2->height; i++ ) - { - memcpy( tmp + i * dxva2->width, bufi1 + i * p, dxva2->width ); - if( i < dxva2->height >> 1 ) - { - memcpy( tmp + (dxva2->width * dxva2->height) + i * dxva2->width, bufi2 + i * p, dxva2->width ); - } - } - HB_OCL_CHECK(hb_ocl->clEnqueueWriteBuffer, kenv->command_queue, - dxva2->cl_mem_nv12, CL_TRUE, 0, in_bytes, tmp, 0, NULL, NULL); - free( tmp ); - } - - size_t gdim[2] = {w>>1, h>>1}; - HB_OCL_CHECK(hb_ocl->clEnqueueNDRangeKernel, kenv->command_queue, - kenv->kernel, 2, NULL, gdim, NULL, 0, NULL, NULL ); - - if ((crop[0] || crop[1] || crop[2] || crop[3]) && - (decomb == 0) && (detelecine == 0)) - { - uint8_t * crop_data[4]; - int crop_stride[4]; - - hb_ocl->clEnqueueReadBuffer(kenv->command_queue, dxva2->cl_mem_yuv, - CL_TRUE, 0, in_bytes, dxva2->nv12toyuv_tmp_out, - 0, NULL, NULL); - hb_buffer_t *in = hb_video_buffer_init( w, h ); - - int wmp = in->plane[0].stride; - int hmp = in->plane[0].height; - copy_plane(in->plane[0].data, dxva2->nv12toyuv_tmp_out, wmp, w, hmp); - wmp = in->plane[1].stride; - hmp = in->plane[1].height; - copy_plane(in->plane[1].data, dxva2->nv12toyuv_tmp_out + w * h, - wmp, w >> 1, hmp); - wmp = in->plane[2].stride; - hmp = in->plane[2].height; - copy_plane(in->plane[2].data, dxva2->nv12toyuv_tmp_out + w * h + - ((w * h) >> 2), wmp, w>>1, hmp); - - hb_picture_crop(crop_data, crop_stride, in, crop[0], crop[2]); - int i, ww = w - ( crop[2] + crop[3] ), hh = h - ( crop[0] + crop[1] ); - for( i = 0; i< hh >> 1; i++ ) - { - memcpy( dxva2->nv12toyuv_tmp_in + ((i << 1) + 0) * ww, - crop_data[0]+ ((i << 1) + 0) * crop_stride[0], ww ); - memcpy( dxva2->nv12toyuv_tmp_in + ((i << 1) + 1) * ww, - crop_data[0]+ ((i << 1) + 1) * crop_stride[0], ww ); - memcpy( dxva2->nv12toyuv_tmp_in + (ww * hh) + i * (ww >> 1), - crop_data[1] + i * crop_stride[1], ww >> 1 ); - memcpy( dxva2->nv12toyuv_tmp_in + (ww * hh) + ((ww * hh) >> 2) + - i * (ww >> 1), - crop_data[2] + i * crop_stride[2], ww >> 1 ); - } - - if( kenv->isAMD ) - { - void *data = hb_ocl->clEnqueueMapBuffer(kenv->command_queue, - dxva2->cl_mem_yuv, - CL_MAP_WRITE_INVALIDATE_REGION, - CL_TRUE, 0, ww * hh * 3 / 2, 0, - NULL, NULL, NULL); - memcpy( data, dxva2->nv12toyuv_tmp_in, ww * hh * 3 / 2 ); - hb_ocl->clEnqueueUnmapMemObject(kenv->command_queue, - dxva2->cl_mem_yuv, data, 0, NULL, NULL); - } - else - { - HB_OCL_CHECK(hb_ocl->clEnqueueWriteBuffer, kenv->command_queue, - dxva2->cl_mem_yuv, CL_TRUE, 0, in_bytes, - dxva2->nv12toyuv_tmp_in, 0, NULL, NULL); - } - - hb_buffer_close( &in ); - } - return 0; -} -/** - * register nv12 to yuv kernel. - */ -static int hb_nv12toyuv_reg_kernel( void ) -{ - int st = hb_register_kernel_wrapper( "nv12toyuv", hb_nv12toyuv ); - if( !st ) - { - hb_log( "OpenCL: register kernel[%s] failed", "nv12toyuv" ); - return -1; - } - return 0; -} -/** - * nv12 to yuv interface - * bufi is input frame of nv12, w is input frame width, h is input frame height - */ -int hb_ocl_nv12toyuv( uint8_t *bufi[], int p, int w, int h, int *crop, hb_va_dxva2_t *dxva2, int decomb, int detelecine ) -{ - void *userdata[9]; - userdata[0] = (void*)w; - userdata[1] = (void*)h; - userdata[2] = bufi[0]; - userdata[3] = crop; - userdata[4] = dxva2; - userdata[5] = bufi[1]; - userdata[6] = (void*)p; - userdata[7] = decomb; - userdata[8] = detelecine; - - if( hb_nv12toyuv_reg_kernel() ) - { - return -1; - } - - if( hb_run_kernel( "nv12toyuv", userdata ) ) - { - hb_log( "OpenCL: run kernel[nv12toyuv] failed" ); - return -1; - } - return 0; -} - -#endif // USE_HWD diff --git a/libhb/oclnv12toyuv.h b/libhb/oclnv12toyuv.h deleted file mode 100644 index 05fb6c687..000000000 --- a/libhb/oclnv12toyuv.h +++ /dev/null @@ -1,27 +0,0 @@ -/* oclnv12toyuv.h - - Copyright (c) 2003-2016 HandBrake Team - This file is part of the HandBrake source code - Homepage: <http://handbrake.fr/>. - It may be used under the terms of the GNU General Public License v2. - For full terms see the file COPYING file or visit http://www.gnu.org/licenses/gpl-2.0.html - - Authors: Peng Gao <[email protected]> <http://www.multicorewareinc.com/> - Li Cao <[email protected]> <http://www.multicorewareinc.com/> - - */ - -#ifndef HB_OCLNV12TOYUV_H -#define HB_OCLNV12TOYUV_H - -#include "common.h" -#include "extras/cl.h" -#include "openclwrapper.h" - -/* - * nv12 to yuv interface - * bufi is input frame of nv12, w is input frame width, h is input frame height - */ -int hb_ocl_nv12toyuv(uint8_t *bufi[], int p, int w, int h, int *crop, hb_va_dxva2_t *dxva2, int decomb, int detelecine); - -#endif // HB_OCLNV12TOYUV_H diff --git a/libhb/preset.c b/libhb/preset.c index 2af02b0ed..3c9a32b4d 100644 --- a/libhb/preset.c +++ b/libhb/preset.c @@ -1497,11 +1497,6 @@ int hb_preset_apply_video(const hb_dict_t *preset, hb_dict_t *job_dict) hb_dict_set(video_dict, "OpenCL", hb_value_bool(1)); } } - if ((value = hb_dict_get(preset, "VideoHWDecode")) != NULL) - { - hb_dict_set(video_dict, "HWDecode", - hb_value_xform(value, HB_VALUE_TYPE_BOOL)); - } return 0; } diff --git a/libhb/preset_template.json b/libhb/preset_template.json index a66e1e2e5..d45335ecf 100644 --- a/libhb/preset_template.json +++ b/libhb/preset_template.json @@ -90,7 +90,6 @@ "VideoFramerate": "auto", "VideoFramerateMode": "vfr", "VideoGrayScale": false, - "VideoHWDecode": false, "VideoScaler": "swscale", "VideoPreset": "medium", "VideoTune": "none", diff --git a/libhb/scan.c b/libhb/scan.c index e15e55860..384f5769a 100644 --- a/libhb/scan.c +++ b/libhb/scan.c @@ -1070,10 +1070,9 @@ skip_preview: if (title->video_decode_support != HB_DECODE_SUPPORT_SW) { - hb_log("scan: supported video decoders:%s%s%s", + hb_log("scan: supported video decoders:%s%s", !(title->video_decode_support & HB_DECODE_SUPPORT_SW) ? "" : " avcodec", - !(title->video_decode_support & HB_DECODE_SUPPORT_QSV) ? "" : " qsv", - !(title->video_decode_support & HB_DECODE_SUPPORT_DXVA2) ? "" : " dxva2"); + !(title->video_decode_support & HB_DECODE_SUPPORT_QSV) ? "" : " qsv"); } if( interlaced_preview_count >= ( npreviews / 2 ) ) diff --git a/libhb/stream.c b/libhb/stream.c index 5fa0dda43..49f8a5615 100644 --- a/libhb/stream.c +++ b/libhb/stream.c @@ -15,7 +15,6 @@ #include "hbffmpeg.h" #include "lang.h" #include "libbluray/bluray.h" -#include "vadxva2.h" #define min(a, b) a < b ? a : b #define HB_MAX_PROBE_SIZE (1*1024*1024) @@ -845,9 +844,7 @@ hb_stream_open(hb_handle_t *h, char *path, hb_title_t *title, int scan) d->path = strdup( path ); if (d->path != NULL ) { - // XXX: DXVA2 integration code requires an AVFormatContext - // use lavf instead of our MPEG demuxer when it's enabled - if (!hb_hwd_enabled(d->h) && hb_stream_get_type( d ) != 0 ) + if (hb_stream_get_type( d ) != 0) { if( !scan ) { diff --git a/libhb/vadxva2.c b/libhb/vadxva2.c deleted file mode 100644 index be37aa440..000000000 --- a/libhb/vadxva2.c +++ /dev/null @@ -1,804 +0,0 @@ -/* vadxva2.c - - Copyright (c) 2003-2016 HandBrake Team - This file is part of the HandBrake source code - Homepage: <http://handbrake.fr/>. - It may be used under the terms of the GNU General Public License v2. - For full terms see the file COPYING file or visit http://www.gnu.org/licenses/gpl-2.0.html - - Authors: Peng Gao <[email protected]> <http://www.multicorewareinc.com/> - Li Cao <[email protected]> <http://www.multicorewareinc.com/> - - */ - -#ifdef USE_HWD - -#include "vadxva2.h" -#include "extras/cl.h" -#include "oclnv12toyuv.h" - -static int hb_va_setup( hb_va_dxva2_t *dxva2, void **hw, int width, int height ); -static int hb_va_get( hb_va_dxva2_t *dxva2, AVFrame *frame ); -static int hb_d3d_create_device( hb_va_dxva2_t *dxva2 ); -static void hb_d3d_destroy_device( hb_va_dxva2_t *dxvva2 ); -static int hb_d3d_create_device_manager( hb_va_dxva2_t *dxva2 ); -static void hb_d3d_destroy_device_manager( hb_va_dxva2_t *dxva2 ); -static int hb_dx_create_video_service( hb_va_dxva2_t *dxva2 ); -static void hb_dx_destroy_video_service( hb_va_dxva2_t *dxva2 ); -static int hb_dx_find_video_service_conversion( hb_va_dxva2_t *dxva2, GUID *input, D3DFORMAT *output ); -static int hb_dx_create_video_decoder( hb_va_dxva2_t *dxva2, int codec_id, const hb_title_t* fmt ); -static void hb_dx_create_video_conversion( hb_va_dxva2_t *dxva2 ); -static const hb_d3d_format_t *hb_d3d_find_format( D3DFORMAT format ); -static const hb_dx_mode_t *hb_dx_find_mode( const GUID *guid ); -static void hb_dx_destroy_video_decoder( hb_va_dxva2_t *dxva2 ); -/** - * It destroys a Direct3D device manager - */ -static void hb_d3d_destroy_device_manager( hb_va_dxva2_t *dxva2 ) -{ - if( dxva2->devmng ) - IDirect3DDeviceManager9_Release( dxva2->devmng ); -} -/** - * It releases a Direct3D device and its resources. - */ -static void hb_d3d_destroy_device( hb_va_dxva2_t *dxva2 ) -{ - if( dxva2->d3ddev ) - IDirect3DDevice9_Release( dxva2->d3ddev ); - if( dxva2->d3dobj ) - IDirect3D9_Release( dxva2->d3dobj ); -} -/** - * It destroys a DirectX video service - */ -static void hb_dx_destroy_video_service( hb_va_dxva2_t *dxva2 ) -{ - if( dxva2->device ) - IDirect3DDeviceManager9_CloseDeviceHandle( dxva2->devmng, dxva2->device ); - - if( dxva2->vs ) - IDirectXVideoDecoderService_Release( dxva2->vs ); -} - -static const hb_d3d_format_t *hb_d3d_find_format( D3DFORMAT format ) -{ - unsigned i; - for( i = 0; d3d_formats[i].name; i++ ) - { - if( d3d_formats[i].format == format ) - return &d3d_formats[i]; - } - return NULL; -} - -static void hb_dx_create_video_conversion( hb_va_dxva2_t *dxva2 ) -{ - switch( dxva2->render ) - { - case MAKEFOURCC( 'N', 'V', '1', '2' ): - dxva2->output = MAKEFOURCC( 'Y', 'V', '1', '2' ); - break; - default: - dxva2->output = dxva2->render; - break; - } -} - -void hb_va_release( hb_va_dxva2_t *dxva2, AVFrame *frame ) -{ - LPDIRECT3DSURFACE9 d3d = (LPDIRECT3DSURFACE9)(uintptr_t)frame->data[3]; - unsigned i; - for( i = 0; i < dxva2->surface_count; i++ ) - { - hb_va_surface_t *surface = &dxva2->surface[i]; - if( surface->d3d == d3d ) - surface->refcount--; - } -} - - -void hb_va_close( hb_va_dxva2_t *dxva2 ) -{ - hb_dx_destroy_video_decoder( dxva2 ); - hb_dx_destroy_video_service( dxva2 ); - hb_d3d_destroy_device_manager( dxva2 ); - hb_d3d_destroy_device( dxva2 ); - - if( dxva2->hdxva2_dll ) - FreeLibrary( dxva2->hdxva2_dll ); - if( dxva2->hd3d9_dll ) - FreeLibrary( dxva2->hd3d9_dll ); - - if ( dxva2->nv12toyuv_tmp_in ) - free( dxva2->nv12toyuv_tmp_in ); - if ( dxva2->nv12toyuv_tmp_out ) - free( dxva2->nv12toyuv_tmp_out ); - - dxva2->description = NULL; - free( dxva2 ); -} - -/** - * It creates a DXVA2 decoder using the given video format - */ -static int hb_dx_create_video_decoder( hb_va_dxva2_t *dxva2, int codec_id, const hb_title_t* fmt ) -{ - int surface_alignment; - dxva2->width = fmt->geometry.width; - dxva2->height = fmt->geometry.height; - - switch( codec_id ) - { - case AV_CODEC_ID_H264: - dxva2->surface_count = 16 + 1; - surface_alignment = 16; - break; - case AV_CODEC_ID_HEVC: - dxva2->surface_count = 16 + 1; - surface_alignment = 128; - break; - case AV_CODEC_ID_MPEG2VIDEO: - dxva2->surface_count = 2 + 1; - surface_alignment = 32; - break; - default: - dxva2->surface_count = 2 + 1; - surface_alignment = 16; - break; - } - - dxva2->surface_width = HB_ALIGN(fmt->geometry.width, surface_alignment); - dxva2->surface_height = HB_ALIGN(fmt->geometry.height, surface_alignment); - - LPDIRECT3DSURFACE9 surface_list[VA_DXVA2_MAX_SURFACE_COUNT]; - if( FAILED( IDirectXVideoDecoderService_CreateSurface( dxva2->vs, - dxva2->surface_width, - dxva2->surface_height, - dxva2->surface_count - 1, - dxva2->render, - D3DPOOL_DEFAULT, - 0, - DXVA2_VideoDecoderRenderTarget, - surface_list, NULL ))) - { - hb_log( "dxva2:IDirectXVideoAccelerationService_CreateSurface failed" ); - dxva2->surface_count = 0; - return HB_WORK_ERROR; - } - - unsigned i; - for( i = 0; i<dxva2->surface_count; i++ ) - { - hb_va_surface_t *surface = &dxva2->surface[i]; - surface->d3d = surface_list[i]; - surface->refcount = 0; - surface->order = 0; - } - hb_log( "dxva2:CreateSurface succeed with %d, fmt (%dx%d) surfaces (%dx%d)", dxva2->surface_count, - fmt->geometry.width, fmt->geometry.height, dxva2->surface_width, dxva2->surface_height ); - DXVA2_VideoDesc dsc; - memset( &dsc, 0, sizeof(dsc)); - dsc.SampleWidth = fmt->geometry.width; - dsc.SampleHeight = fmt->geometry.height; - dsc.Format = dxva2->render; - - if( fmt->vrate.num > 0 && fmt->vrate.den > 0 ) - { - dsc.InputSampleFreq.Numerator = fmt->vrate.num; - dsc.InputSampleFreq.Denominator = fmt->vrate.den; - } - else - { - dsc.InputSampleFreq.Numerator = 0; - dsc.InputSampleFreq.Denominator = 0; - } - - dsc.OutputFrameFreq = dsc.InputSampleFreq; - dsc.UABProtectionLevel = FALSE; - dsc.Reserved = 0; - - /* FIXME I am unsure we can let unknown everywhere */ - DXVA2_ExtendedFormat *ext = &dsc.SampleFormat; - ext->SampleFormat = 0; //DXVA2_SampleUnknown; - ext->VideoChromaSubsampling = 0; //DXVA2_VideoChromaSubsampling_Unknown; - ext->NominalRange = 0; //DXVA2_NominalRange_Unknown; - ext->VideoTransferMatrix = 0; //DXVA2_VideoTransferMatrix_Unknown; - ext->VideoLighting = 0; //DXVA2_VideoLighting_Unknown; - ext->VideoPrimaries = 0; //DXVA2_VideoPrimaries_Unknown; - ext->VideoTransferFunction = 0; //DXVA2_VideoTransFunc_Unknown; - - /* List all configurations available for the decoder */ - UINT cfg_count = 0; - DXVA2_ConfigPictureDecode *cfg_list = NULL; - if( FAILED( IDirectXVideoDecoderService_GetDecoderConfigurations( dxva2->vs, &dxva2->input, &dsc, NULL, &cfg_count, &cfg_list ))) - { - hb_log( "dxva2:IDirectXVideoDecoderService_GetDecoderConfigurations failed" ); - return HB_WORK_ERROR; - } - hb_log( "dxva2:we got %d decoder configurations", cfg_count ); - - /* Select the best decoder configuration */ - int cfg_score = 0; - for( i = 0; i < cfg_count; i++ ) - { - const DXVA2_ConfigPictureDecode *cfg = &cfg_list[i]; - hb_log( "dxva2:configuration[%d] ConfigBitstreamRaw %d", i, cfg->ConfigBitstreamRaw ); - int score; - if( cfg->ConfigBitstreamRaw == 1 ) - score = 1; - else if( codec_id == AV_CODEC_ID_H264 && cfg->ConfigBitstreamRaw == 2 ) - score = 2; - else - continue; - if( IsEqualGUID( &cfg->guidConfigBitstreamEncryption, &DXVA_NoEncrypt )) - score += 16; - if( cfg_score < score ) - { - dxva2->cfg = *cfg; - cfg_score = score; - } - } - //my_release(cfg_list); - if( cfg_score <= 0 ) - { - hb_log( "dxva2:Failed to find a supported decoder configuration" ); - return HB_WORK_ERROR; - } - - /* Create the decoder */ - IDirectXVideoDecoder *decoder; - if( FAILED( IDirectXVideoDecoderService_CreateVideoDecoder( dxva2->vs, &dxva2->input, &dsc, &dxva2->cfg, surface_list, dxva2->surface_count, &decoder ))) - { - hb_log( "dxva2:IDirectXVideoDecoderService_CreateVideoDecoder failed" ); - return HB_WORK_ERROR; - } - dxva2->decoder = decoder; - hb_log( "dxva2:IDirectXVideoDecoderService_CreateVideoDecoder succeed" ); - return HB_WORK_OK; -} - -typedef HWND (WINAPI *PROCGETSHELLWND)(); -/** - * It creates a DirectX video service - */ -static int hb_d3d_create_device( hb_va_dxva2_t *dxva2 ) -{ - LPDIRECT3D9 (WINAPI *Create9)( UINT SDKVersion ); - Create9 = (void*)GetProcAddress( dxva2->hd3d9_dll, TEXT( "Direct3DCreate9" )); - if( !Create9 ) - { - hb_log( "dxva2:Cannot locate reference to Direct3DCreate9 ABI in DLL" ); - return HB_WORK_ERROR; - } - LPDIRECT3D9 d3dobj; - d3dobj = Create9( D3D_SDK_VERSION ); - if( !d3dobj ) - { - hb_log( "dxva2:Direct3DCreate9 failed" ); - return HB_WORK_ERROR; - } - dxva2->d3dobj = d3dobj; - D3DADAPTER_IDENTIFIER9 *d3dai = &dxva2->d3dai; - if( FAILED( IDirect3D9_GetAdapterIdentifier( dxva2->d3dobj, D3DADAPTER_DEFAULT, 0, d3dai ))) - { - hb_log( "dxva2:IDirect3D9_GetAdapterIdentifier failed" ); - memset( d3dai, 0, sizeof(*d3dai)); - } - - PROCGETSHELLWND GetShellWindow; - HMODULE hUser32 = GetModuleHandle( "user32" ); - GetShellWindow = (PROCGETSHELLWND) - GetProcAddress( hUser32, "GetShellWindow" ); - - D3DPRESENT_PARAMETERS *d3dpp = &dxva2->d3dpp; - memset( d3dpp, 0, sizeof(*d3dpp)); - d3dpp->Flags = D3DPRESENTFLAG_VIDEO; - d3dpp->Windowed = TRUE; - d3dpp->hDeviceWindow = NULL; - d3dpp->SwapEffect = D3DSWAPEFFECT_DISCARD; - d3dpp->MultiSampleType = D3DMULTISAMPLE_NONE; - d3dpp->PresentationInterval = D3DPRESENT_INTERVAL_DEFAULT; - d3dpp->BackBufferCount = 0; /* FIXME what to put here */ - d3dpp->BackBufferFormat = D3DFMT_X8R8G8B8; /* FIXME what to put here */ - d3dpp->BackBufferWidth = 0; - d3dpp->BackBufferHeight = 0; - d3dpp->EnableAutoDepthStencil = FALSE; - - LPDIRECT3DDEVICE9 d3ddev; - //if (FAILED(IDirect3D9_CreateDevice(d3dobj, D3DADAPTER_DEFAULT, D3DDEVTYPE_HAL, GetShellWindow(), D3DCREATE_SOFTWARE_VERTEXPROCESSING|D3DCREATE_MULTITHREADED, d3dpp, &d3ddev))) - if( FAILED( IDirect3D9_CreateDevice( d3dobj, - D3DADAPTER_DEFAULT, - D3DDEVTYPE_HAL, - GetShellWindow(), - D3DCREATE_HARDWARE_VERTEXPROCESSING|D3DCREATE_MULTITHREADED, - d3dpp, - &d3ddev ))) - { - hb_log( "dxva2:IDirect3D9_CreateDevice failed" ); - return HB_WORK_ERROR; - } - dxva2->d3ddev = d3ddev; - - return HB_WORK_OK; -} -/** - * It creates a Direct3D device manager - */ -static int hb_d3d_create_device_manager( hb_va_dxva2_t *dxva2 ) -{ - HRESULT(WINAPI *CreateDeviceManager9)( UINT *pResetToken, IDirect3DDeviceManager9 ** ); - CreateDeviceManager9 = (void*)GetProcAddress( dxva2->hdxva2_dll, TEXT( "DXVA2CreateDirect3DDeviceManager9" )); - - if( !CreateDeviceManager9 ) - { - hb_log( "dxva2:cannot load function" ); - return HB_WORK_ERROR; - } - - UINT token; - IDirect3DDeviceManager9 *devmng; - if( FAILED( CreateDeviceManager9( &token, &devmng ))) - { - hb_log( "dxva2:OurDirect3DCreateDeviceManager9 failed" ); - return HB_WORK_ERROR; - } - dxva2->token = token; - dxva2->devmng = devmng; - - long hr = IDirect3DDeviceManager9_ResetDevice( devmng, dxva2->d3ddev, token ); - if( FAILED( hr )) - { - hb_log( "dxva2:IDirect3DDeviceManager9_ResetDevice failed: %08x", (unsigned)hr ); - return HB_WORK_ERROR; - } - return HB_WORK_OK; -} -/** - * It creates a DirectX video service - */ -static int hb_dx_create_video_service( hb_va_dxva2_t *dxva2 ) -{ - HRESULT (WINAPI *CreateVideoService)( IDirect3DDevice9 *, REFIID riid, void **ppService ); - CreateVideoService = (void*)GetProcAddress( dxva2->hdxva2_dll, TEXT( "DXVA2CreateVideoService" )); - - if( !CreateVideoService ) - { - hb_log( "dxva2:cannot load function" ); - return HB_WORK_ERROR; - } - - HRESULT hr; - - HANDLE device; - hr = IDirect3DDeviceManager9_OpenDeviceHandle( dxva2->devmng, &device ); - if( FAILED( hr )) - { - hb_log( "dxva2:OpenDeviceHandle failed" ); - return HB_WORK_ERROR; - } - dxva2->device = device; - - IDirectXVideoDecoderService *vs; - hr = IDirect3DDeviceManager9_GetVideoService( dxva2->devmng, device, &IID_IDirectXVideoDecoderService, (void*)&vs ); - if( FAILED( hr )) - { - hb_log( "dxva2:GetVideoService failed" ); - return HB_WORK_ERROR; - } - dxva2->vs = vs; - - return HB_WORK_OK; -} -/** - * Find the best suited decoder mode GUID and render format. - */ -static int hb_dx_find_video_service_conversion( hb_va_dxva2_t *dxva2, GUID *input, D3DFORMAT *output ) -{ - unsigned int input_count = 0; - GUID *input_list = NULL; - if( FAILED( IDirectXVideoDecoderService_GetDecoderDeviceGuids( dxva2->vs, &input_count, &input_list ))) - { - hb_log( "dxva2:IDirectXVideoDecoderService_GetDecoderDeviceGuids failed" ); - return HB_WORK_ERROR; - } - unsigned i, j; - for( i = 0; i < input_count; i++ ) - { - const GUID *g = &input_list[i]; - const hb_dx_mode_t *mode = hb_dx_find_mode( g ); - } - - for( i = 0; dxva2_modes[i].name; i++ ) - { - const hb_dx_mode_t *mode = &dxva2_modes[i]; - if( !mode->codec || mode->codec != dxva2->codec_id ) - continue; - - int is_suported = 0; - const GUID *g; - for( g = &input_list[0]; !is_suported && g < &input_list[input_count]; g++ ) - { - is_suported = IsEqualGUID( mode->guid, g ); - } - if( !is_suported ) - continue; - - unsigned int output_count = 0; - D3DFORMAT *output_list = NULL; - if( FAILED( IDirectXVideoDecoderService_GetDecoderRenderTargets( dxva2->vs, mode->guid, &output_count, &output_list ))) - { - hb_log( "dxva2:IDirectXVideoDecoderService_GetDecoderRenderTargets failed" ); - continue; - } - for( j = 0; j < output_count; j++ ) - { - const D3DFORMAT f = output_list[j]; - const hb_d3d_format_t *format = hb_d3d_find_format( f ); - if( format ) - { - //hb_log( "dxva2:%s is supported for output", format->name ); - } - else - { - hb_log( "dxvar2:%d is supported for output (%4.4s)", f, (const char*)&f ); - } - } - - for( j = 0; d3d_formats[j].name; j++ ) - { - const hb_d3d_format_t *format = &d3d_formats[j]; - int is_suported = 0; - unsigned k; - for( k = 0; !is_suported && k < output_count; k++ ) - { - is_suported = format->format == output_list[k]; - } - if( !is_suported ) - continue; - *input = *mode->guid; - *output = format->format; - return HB_WORK_OK; - } - } - return HB_WORK_ERROR; -} -static const hb_dx_mode_t *hb_dx_find_mode( const GUID *guid ) -{ - unsigned i; - for( i = 0; dxva2_modes[i].name; i++ ) - { - if( IsEqualGUID( dxva2_modes[i].guid, guid )) - return &dxva2_modes[i]; - } - return NULL; -} - - -static void hb_dx_destroy_video_decoder( hb_va_dxva2_t *dxva2 ) -{ - if( dxva2->decoder ) - IDirectXVideoDecoder_Release( dxva2->decoder ); - dxva2->decoder = NULL; - - unsigned i; - for( i = 0; i<dxva2->surface_count; i++ ) - IDirect3DSurface9_Release( dxva2->surface[i].d3d ); - dxva2->surface_count = 0; -} -/** - * setup dxva2 -*/ -static int hb_va_setup( hb_va_dxva2_t *dxva2, void **hw, int width, int height ) -{ - if( dxva2->width == width && dxva2->height == height && dxva2->decoder ) - goto ok; - - hb_dx_destroy_video_decoder( dxva2 ); - *hw = NULL; - dxva2->i_chroma = 0; - - if( width <= 0 || height <= 0 ) - return HB_WORK_ERROR; - - hb_title_t fmt; - memset( &fmt, 0, sizeof(fmt)); - fmt.geometry.width = width; - fmt.geometry.height = height; - - if( hb_dx_create_video_decoder( dxva2, dxva2->codec_id, &fmt ) == HB_WORK_ERROR ) - return HB_WORK_ERROR; - dxva2->hw.decoder = dxva2->decoder; - dxva2->hw.cfg = &dxva2->cfg; - dxva2->hw.surface_count = dxva2->surface_count; - dxva2->hw.surface = dxva2->hw_surface; - - unsigned i; - for( i = 0; i < dxva2->surface_count; i++ ) - dxva2->hw.surface[i] = dxva2->surface[i].d3d; - - hb_dx_create_video_conversion( dxva2 ); - -ok: - *hw = &dxva2->hw; - const hb_d3d_format_t *output = hb_d3d_find_format( dxva2->output ); - dxva2->i_chroma = output->codec; - return HB_WORK_OK; - -} - -static int hb_va_get( hb_va_dxva2_t *dxva2, AVFrame *frame ) -{ - unsigned i, old; - for( i = 0, old = 0; i < dxva2->surface_count; i++ ) - { - hb_va_surface_t *surface = &dxva2->surface[i]; - if( !surface->refcount ) - break; - if( surface->order < dxva2->surface[old].order ) - old = i; - } - if( i >= dxva2->surface_count ) - i = old; - - hb_va_surface_t *surface = &dxva2->surface[i]; - - surface->refcount = 1; - surface->order = dxva2->surface_order++; - - for( i = 0; i < 4; i++ ) - { - frame->data[i] = NULL; - frame->linesize[i] = 0; - if( i == 0 || i == 3 ) - frame->data[i] = (void*)surface->d3d; - } - return HB_WORK_OK; -} -/** - * nv12 to yuv of c reference - */ -static void hb_copy_from_nv12( uint8_t *dst, uint8_t *src[2], size_t src_pitch[2], unsigned width, unsigned height ) -{ - unsigned int i, j; - uint8_t *dstU, *dstV; - dstU = dst + width*height; - dstV = dstU + width*height/4; - unsigned int heithtUV, widthUV; - heithtUV = height/2; - widthUV = width/2; - - for( i = 0; i < height; i++ ) //Y - { - memcpy( dst + i * width, src[0] + i * src_pitch[0], width ); - } - for( i = 0; i < heithtUV; i++ ) - { - for( j = 0; j < widthUV; j++ ) - { - dstU[i * widthUV + j] = *(src[1] + i * src_pitch[1] + 2 * j); - dstV[i *widthUV + j] = *(src[1] + i * src_pitch[1] + 2 * j + 1); - } - } -} - -/** - * lock frame data form surface. - * nv12 to yuv with opencl and with C reference - * scale with opencl - */ -int hb_va_extract( hb_va_dxva2_t *dxva2, uint8_t *dst, AVFrame *frame, int job_w, int job_h, int *crop, hb_oclscale_t *os, int use_opencl, int use_decomb, int use_detelecine ) - -{ - LPDIRECT3DSURFACE9 d3d = (LPDIRECT3DSURFACE9)(uintptr_t)frame->data[3]; - D3DLOCKED_RECT lock; - if( FAILED( IDirect3DSurface9_LockRect( d3d, &lock, NULL, D3DLOCK_READONLY ))) - { - hb_log( "dxva2:Failed to lock surface" ); - return HB_WORK_ERROR; - } - - if( dxva2->render == MAKEFOURCC( 'N', 'V', '1', '2' )) - { - uint8_t *plane[2] = - { - lock.pBits, - (uint8_t*)lock.pBits + lock.Pitch * dxva2->surface_height - }; - size_t pitch[2] = - { - lock.Pitch, - lock.Pitch, - }; - - hb_copy_from_nv12( dst, plane, pitch, dxva2->width, dxva2->height ); - } - IDirect3DSurface9_UnlockRect( d3d ); - return HB_WORK_OK; -} - -/** - * create dxva2 service - * load library D3D9.dll - */ -hb_va_dxva2_t * hb_va_create_dxva2( hb_va_dxva2_t *dxva2, int codec_id ) -{ - if( dxva2 ) - { - hb_va_close( dxva2 ); - dxva2 = NULL; - } - - hb_va_dxva2_t *dxva = calloc( 1, sizeof(*dxva) ); - if( !dxva ) return NULL; - dxva->codec_id = codec_id; - - dxva->hd3d9_dll = LoadLibrary( TEXT( "D3D9.DLL" ) ); - if( !dxva->hd3d9_dll ) - { - hb_deep_log(2, "dxva2:cannot load d3d9.dll"); - goto error; - } - dxva->hdxva2_dll = LoadLibrary( TEXT( "DXVA2.DLL" ) ); - if( !dxva->hdxva2_dll ) - { - hb_deep_log(2, "dxva2:cannot load DXVA2.dll"); - goto error; - } - - if( hb_d3d_create_device( dxva ) == HB_WORK_ERROR ) - { - hb_deep_log(2, "dxva2:Failed to create Direct3D device"); - goto error; - } - - if( hb_d3d_create_device_manager( dxva ) == HB_WORK_ERROR ) - { - hb_deep_log(2, "dxva2:D3dCreateDeviceManager failed"); - goto error; - } - - - if( hb_dx_create_video_service( dxva ) == HB_WORK_ERROR ) - { - hb_deep_log(2, "dxva2:DxCreateVideoService failed"); - goto error; - } - - if( hb_dx_find_video_service_conversion( dxva, &dxva->input, &dxva->render ) == HB_WORK_ERROR ) - { - hb_deep_log(2, "dxva2:DxFindVideoServiceConversion failed"); - goto error; - } - - /* - * We may get a valid DXVA2 decoder later on, but we won't be able to - * use it if libavcodec is built without support for the appropriate - * AVHWaccel, so we need to check for it before declaring victory. - */ - AVHWAccel *hwaccel = NULL; - for (hwaccel = av_hwaccel_next(NULL); - hwaccel != NULL; - hwaccel = av_hwaccel_next(hwaccel)) - { - if (hwaccel->id == codec_id && hwaccel->pix_fmt == AV_PIX_FMT_DXVA2_VLD) - { - dxva->do_job = HB_WORK_OK; - dxva->description = "DXVA2"; - return dxva; - } - } - hb_deep_log(2, "dxva2:compatible AVHWAccel not found"); - -error: - hb_va_close( dxva ); - return NULL; -} - -void hb_va_new_dxva2( hb_va_dxva2_t *dxva2, AVCodecContext *p_context ) -{ - if( p_context->width > 0 && p_context->height > 0 ) - { - if( hb_va_setup( dxva2, &p_context->hwaccel_context, p_context->width, p_context->height ) == HB_WORK_ERROR ) - { - hb_log( "dxva2:hb_va_Setup failed" ); - hb_va_close( dxva2 ); - dxva2 = NULL; - } - } - if( dxva2 ) - { - dxva2->input_pts[0] = 0; - dxva2->input_pts[1] = 0; - if( dxva2->description ) - hb_log( "dxva2:Using %s for hardware decoding", dxva2->description ); - p_context->draw_horiz_band = NULL; - } - -} - -char* hb_get_pix_fmt_name( int pix_fmt ) -{ - static const char *ppsz_name[AV_PIX_FMT_NB] = - { - [AV_PIX_FMT_VDPAU_H264] = "AV_PIX_FMT_VDPAU_H264", - [AV_PIX_FMT_VAAPI_IDCT] = "AV_PIX_FMT_VAAPI_IDCT", - [AV_PIX_FMT_VAAPI_VLD] = "AV_PIX_FMT_VAAPI_VLD", - [AV_PIX_FMT_VAAPI_MOCO] = "AV_PIX_FMT_VAAPI_MOCO", - [AV_PIX_FMT_DXVA2_VLD] = "AV_PIX_FMT_DXVA2_VLD", - [AV_PIX_FMT_YUYV422] = "AV_PIX_FMT_YUYV422", - [AV_PIX_FMT_YUV420P] = "AV_PIX_FMT_YUV420P", - }; - - return ppsz_name[pix_fmt]; -} - -enum PixelFormat hb_ffmpeg_get_format( AVCodecContext *p_context, const enum PixelFormat *pi_fmt ) -{ - int i; - for( i = 0; pi_fmt[i] != AV_PIX_FMT_NONE; i++ ) - { - hb_log( "dxva2:Available decoder output format %d (%s)", pi_fmt[i], hb_get_pix_fmt_name(pi_fmt[i]) ? : "Unknown" ); - if( pi_fmt[i] == AV_PIX_FMT_DXVA2_VLD ) - { - return pi_fmt[i]; - } - } - return avcodec_default_get_format( p_context, pi_fmt ); -} - -int hb_va_get_frame_buf( hb_va_dxva2_t *dxva2, AVCodecContext *p_context, AVFrame *frame ) -{ - frame->type = FF_BUFFER_TYPE_USER; - if( hb_va_get( dxva2, frame ) == HB_WORK_ERROR ) - { - hb_log( "VaGrabSurface failed" ); - return HB_WORK_ERROR; - } - return HB_WORK_OK; - -} - -int hb_check_hwd_fmt( int fmt ) -{ - int result = 1; - switch ( fmt ) - { - case AV_PIX_FMT_YUV420P16LE: - case AV_PIX_FMT_YUV420P16BE: - case AV_PIX_FMT_YUV422P16LE: - case AV_PIX_FMT_YUV422P16BE: - case AV_PIX_FMT_YUV444P16LE: - case AV_PIX_FMT_YUV444P16BE: - case AV_PIX_FMT_YUV420P9BE: - case AV_PIX_FMT_YUV420P9LE: - case AV_PIX_FMT_YUV420P10BE: - case AV_PIX_FMT_YUV420P10LE: - case AV_PIX_FMT_YUV422P10BE: - case AV_PIX_FMT_YUV422P10LE: - case AV_PIX_FMT_YUV444P9BE: - case AV_PIX_FMT_YUV444P9LE: - case AV_PIX_FMT_YUV444P10BE: - case AV_PIX_FMT_YUV444P10LE: - case AV_PIX_FMT_YUV422P9BE: - case AV_PIX_FMT_YUV422P9LE: - case AV_PIX_FMT_GBRP9BE: - case AV_PIX_FMT_GBRP9LE: - case AV_PIX_FMT_GBRP10BE: - case AV_PIX_FMT_GBRP10LE: - case AV_PIX_FMT_GBRP16BE: - case AV_PIX_FMT_GBRP16LE: - case AV_PIX_FMT_YUVA420P9BE: - case AV_PIX_FMT_YUVA420P9LE: - case AV_PIX_FMT_YUVA422P9BE: - case AV_PIX_FMT_YUVA422P9LE: - case AV_PIX_FMT_YUVA444P9BE: - case AV_PIX_FMT_YUVA444P9LE: - case AV_PIX_FMT_YUVA420P10BE: - case AV_PIX_FMT_YUVA420P10LE: - result = 0; - } - return result; -} - -#endif // USE_HWD diff --git a/libhb/vadxva2.h b/libhb/vadxva2.h deleted file mode 100644 index 4eaa20ddd..000000000 --- a/libhb/vadxva2.h +++ /dev/null @@ -1,208 +0,0 @@ -/* vadxva2.h - - Copyright (c) 2003-2016 HandBrake Team - This file is part of the HandBrake source code - Homepage: <http://handbrake.fr/>. - It may be used under the terms of the GNU General Public License v2. - For full terms see the file COPYING file or visit http://www.gnu.org/licenses/gpl-2.0.html - - Authors: Peng Gao <[email protected]> <http://www.multicorewareinc.com/> - Li Cao <[email protected]> <http://www.multicorewareinc.com/> - - */ - -#ifdef USE_HWD - -#ifndef HB_VA_DXVA2_H -#define HB_VA_DXVA2_H - -#include "hbffmpeg.h" -#include "d3d9.h" -#include "libavcodec/dxva2.h" -#include "dxva2api.h" -#include "common.h" -#include "opencl.h" -#include "openclwrapper.h" - -#define HB_FOURCC( a, b, c, d ) ( ((uint32_t)a) | ( ((uint32_t)b) << 8 ) | ( ((uint32_t)c) << 16 ) | ( ((uint32_t)d) << 24 ) ) -#define MAKEFOURCC( a, b, c, d ) ((DWORD)(BYTE)(a) | ((DWORD)(BYTE)(b) << 8) | ((DWORD)(BYTE)(c) << 16) | ((DWORD)(BYTE)(d) << 24 )) -#define HB_CODEC_YV12 HB_FOURCC( 'Y', 'V', '1', '2' ) -#define HB_CODEC_NV12 HB_FOURCC( 'N', 'V', '1', '2' ) -#define DXVA2_E_NOT_INITIALIZED MAKE_HRESULT( 1, 4, 4096 ) -#define DXVA2_E_NEW_VIDEO_DEVICE MAKE_HRESULT( 1, 4, 4097 ) -#define DXVA2_E_VIDEO_DEVICE_LOCKED MAKE_HRESULT( 1, 4, 4098 ) -#define DXVA2_E_NOT_AVAILABLE MAKE_HRESULT( 1, 4, 4099 ) -#define VA_DXVA2_MAX_SURFACE_COUNT (64) - -static const GUID DXVA_NoEncrypt = { 0x1b81bed0, 0xa0c7, 0x11d3, {0xb9, 0x84, 0x00, 0xc0, 0x4f, 0x2e, 0x73, 0xc5} }; -static const GUID IID_IDirectXVideoDecoderService = {0xfc51a551, 0xd5e7, 0x11d9, {0xaf, 0x55, 0x00, 0x05, 0x4e, 0x43, 0xff, 0x02}}; -static const GUID DXVA2_ModeMPEG2_MoComp = { 0xe6a9f44b, 0x61b0, 0x4563, {0x9e, 0xa4, 0x63, 0xd2, 0xa3, 0xc6, 0xfe, 0x66} }; -static const GUID DXVA2_ModeMPEG2_IDCT = { 0xbf22ad00, 0x03ea, 0x4690, {0x80, 0x77, 0x47, 0x33, 0x46, 0x20, 0x9b, 0x7e} }; -static const GUID DXVA2_ModeMPEG2_VLD = { 0xee27417f, 0x5e28, 0x4e65, {0xbe, 0xea, 0x1d, 0x26, 0xb5, 0x08, 0xad, 0xc9} }; -static const GUID DXVA2_ModeH264_A = { 0x1b81be64, 0xa0c7, 0x11d3, {0xb9, 0x84, 0x00, 0xc0, 0x4f, 0x2e, 0x73, 0xc5} }; -static const GUID DXVA2_ModeH264_B = { 0x1b81be65, 0xa0c7, 0x11d3, {0xb9, 0x84, 0x00, 0xc0, 0x4f, 0x2e, 0x73, 0xc5} }; -static const GUID DXVA2_ModeH264_C = { 0x1b81be66, 0xa0c7, 0x11d3, {0xb9, 0x84, 0x00, 0xc0, 0x4f, 0x2e, 0x73, 0xc5} }; -static const GUID DXVA2_ModeH264_D = { 0x1b81be67, 0xa0c7, 0x11d3, {0xb9, 0x84, 0x00, 0xc0, 0x4f, 0x2e, 0x73, 0xc5} }; -static const GUID DXVA2_ModeH264_E = { 0x1b81be68, 0xa0c7, 0x11d3, {0xb9, 0x84, 0x00, 0xc0, 0x4f, 0x2e, 0x73, 0xc5} }; -static const GUID DXVA2_ModeH264_F = { 0x1b81be69, 0xa0c7, 0x11d3, {0xb9, 0x84, 0x00, 0xc0, 0x4f, 0x2e, 0x73, 0xc5} }; -static const GUID DXVADDI_Intel_ModeH264_A = { 0x604F8E64, 0x4951, 0x4c54, {0x88, 0xFE, 0xAB, 0xD2, 0x5C, 0x15, 0xB3, 0xD6} }; -static const GUID DXVADDI_Intel_ModeH264_C = { 0x604F8E66, 0x4951, 0x4c54, {0x88, 0xFE, 0xAB, 0xD2, 0x5C, 0x15, 0xB3, 0xD6} }; -static const GUID DXVADDI_Intel_ModeH264_E = { 0x604F8E68, 0x4951, 0x4c54, {0x88, 0xFE, 0xAB, 0xD2, 0x5C, 0x15, 0xB3, 0xD6} }; -static const GUID DXVA2_ModeWMV8_A = { 0x1b81be80, 0xa0c7, 0x11d3, {0xb9, 0x84, 0x00, 0xc0, 0x4f, 0x2e, 0x73, 0xc5} }; -static const GUID DXVA2_ModeWMV8_B = { 0x1b81be81, 0xa0c7, 0x11d3, {0xb9, 0x84, 0x00, 0xc0, 0x4f, 0x2e, 0x73, 0xc5} }; -static const GUID DXVA2_ModeWMV9_A = { 0x1b81be90, 0xa0c7, 0x11d3, {0xb9, 0x84, 0x00, 0xc0, 0x4f, 0x2e, 0x73, 0xc5} }; -static const GUID DXVA2_ModeWMV9_B = { 0x1b81be91, 0xa0c7, 0x11d3, {0xb9, 0x84, 0x00, 0xc0, 0x4f, 0x2e, 0x73, 0xc5} }; -static const GUID DXVA2_ModeWMV9_C = { 0x1b81be94, 0xa0c7, 0x11d3, {0xb9, 0x84, 0x00, 0xc0, 0x4f, 0x2e, 0x73, 0xc5} }; -static const GUID DXVA2_ModeVC1_A = { 0x1b81beA0, 0xa0c7, 0x11d3, {0xb9, 0x84, 0x00, 0xc0, 0x4f, 0x2e, 0x73, 0xc5} }; -static const GUID DXVA2_ModeVC1_B = { 0x1b81beA1, 0xa0c7, 0x11d3, {0xb9, 0x84, 0x00, 0xc0, 0x4f, 0x2e, 0x73, 0xc5} }; -static const GUID DXVA2_ModeVC1_C = { 0x1b81beA2, 0xa0c7, 0x11d3, {0xb9, 0x84, 0x00, 0xc0, 0x4f, 0x2e, 0x73, 0xc5} }; -static const GUID DXVA2_ModeVC1_D = { 0x1b81beA3, 0xa0c7, 0x11d3, {0xb9, 0x84, 0x00, 0xc0, 0x4f, 0x2e, 0x73, 0xc5} }; -static const GUID DXVA2_ModeHEVC_VLD_Main = { 0x5b11d51b, 0x2f4c,0x4452, {0xbc, 0xc3, 0x09, 0xf2, 0xa1, 0x16, 0x0c, 0xc0} }; - -typedef struct -{ - LPDIRECT3DSURFACE9 d3d; - int refcount; - unsigned int order; - -} hb_va_surface_t; - -typedef struct -{ - uint8_t *base; - uint8_t *buffer; - size_t size; - -} hb_copy_cache_t; - -typedef struct -{ - const char *name; - D3DFORMAT format; - uint32_t codec; - -} hb_d3d_format_t; - -typedef struct -{ - const char *name; - const GUID *guid; - int codec; -} hb_dx_mode_t; - -typedef struct -{ - char *description; - int codec_id; - uint32_t i_chroma; - int width; - int height; - HINSTANCE hd3d9_dll; - HINSTANCE hdxva2_dll; - D3DPRESENT_PARAMETERS d3dpp; - LPDIRECT3D9 d3dobj; - D3DADAPTER_IDENTIFIER9 d3dai; - LPDIRECT3DDEVICE9 d3ddev; - UINT token; - IDirect3DDeviceManager9 *devmng; - HANDLE device; - IDirectXVideoDecoderService *vs; - GUID input; - D3DFORMAT render; - DXVA2_ConfigPictureDecode cfg; - IDirectXVideoDecoder *decoder; - D3DFORMAT output; - struct dxva_context hw; - unsigned surface_count; - unsigned surface_order; - int surface_width; - int surface_height; - uint32_t surface_chroma; - hb_va_surface_t surface[VA_DXVA2_MAX_SURFACE_COUNT]; - LPDIRECT3DSURFACE9 hw_surface[VA_DXVA2_MAX_SURFACE_COUNT]; - IDirectXVideoProcessorService *ps; - IDirectXVideoProcessor *vp; - int64_t input_pts[2]; - int64_t input_dts; - int do_job; - - // running nv12toyuv kernel. - cl_kernel nv12toyuv; - cl_mem cl_mem_nv12; - cl_mem cl_mem_yuv; - uint8_t * nv12toyuv_tmp_in; - uint8_t * nv12toyuv_tmp_out; -} hb_va_dxva2_t; - -typedef struct FilterLink_T -{ - cl_mem cl_inbuf; - cl_mem cl_outbuf; - - uint8_t *mem_inbuf; - uint8_t *mem_outbuf; - int width; - int height; - int linesizeY; - int linesizeUV; - int inmemdataflag; - int outmemdataflag; - int incldataflag; - int outcldataflag; - int framenum; - int outputSize; -} T_FilterLink; - -static const hb_d3d_format_t d3d_formats[] = -{ - { "YV12", MAKEFOURCC( 'Y', 'V', '1', '2' ), HB_CODEC_YV12 }, - { "NV12", MAKEFOURCC( 'N', 'V', '1', '2' ), HB_CODEC_NV12 }, - { NULL, 0, 0 } -}; - -static const hb_dx_mode_t dxva2_modes[] = -{ - { "DXVA2_ModeMPEG2_VLD", &DXVA2_ModeMPEG2_VLD, AV_CODEC_ID_MPEG2VIDEO }, - { "DXVA2_ModeMPEG2_MoComp", &DXVA2_ModeMPEG2_MoComp, 0 }, - { "DXVA2_ModeMPEG2_IDCT", &DXVA2_ModeMPEG2_IDCT, 0 }, - - { "H.264 variable-length decoder (VLD), FGT", &DXVA2_ModeH264_F, AV_CODEC_ID_H264 }, - { "H.264 VLD, no FGT", &DXVA2_ModeH264_E, AV_CODEC_ID_H264 }, - { "H.264 VLD, no FGT (Intel)", &DXVADDI_Intel_ModeH264_E, AV_CODEC_ID_H264 }, - { "H.264 IDCT, FGT", &DXVA2_ModeH264_D, 0 }, - { "H.264 inverse discrete cosine transform (IDCT), no FGT", &DXVA2_ModeH264_C, 0 }, - { "H.264 inverse discrete cosine transform (IDCT), no FGT (Intel)", &DXVADDI_Intel_ModeH264_C, 0 }, - { "H.264 MoComp, FGT", &DXVA2_ModeH264_B, 0 }, - { "H.264 motion compensation (MoComp), no FGT", &DXVA2_ModeH264_A, 0 }, - { "H.264 motion compensation (MoComp), no FGT (Intel)", &DXVADDI_Intel_ModeH264_A, 0 }, - - { "Windows Media Video 8 MoComp", &DXVA2_ModeWMV8_B, 0 }, - { "Windows Media Video 8 post processing", &DXVA2_ModeWMV8_A, 0 }, - - { "Windows Media Video 9 IDCT", &DXVA2_ModeWMV9_C, 0 }, - { "Windows Media Video 9 MoComp", &DXVA2_ModeWMV9_B, 0 }, - { "Windows Media Video 9 post processing", &DXVA2_ModeWMV9_A, 0 }, - - { "VC-1 VLD", &DXVA2_ModeVC1_D, AV_CODEC_ID_VC1 }, - { "VC-1 VLD", &DXVA2_ModeVC1_D, AV_CODEC_ID_WMV3 }, - { "VC-1 IDCT", &DXVA2_ModeVC1_C, 0 }, - { "VC-1 MoComp", &DXVA2_ModeVC1_B, 0 }, - { "VC-1 post processing", &DXVA2_ModeVC1_A, 0 }, - - { "DXVA2_ModeHEVC_VLD_Main", &DXVA2_ModeHEVC_VLD_Main, AV_CODEC_ID_HEVC }, - - { NULL, NULL, 0 } -}; - -int hb_va_get_frame_buf( hb_va_dxva2_t *dxva2, AVCodecContext *p_context, AVFrame *frame ); -int hb_va_extract( hb_va_dxva2_t *dxva2, uint8_t *dst, AVFrame *frame, int job_w, int job_h, int *crop, hb_oclscale_t *os, int use_opencl, int use_decomb, int use_detelecine ); -enum PixelFormat hb_ffmpeg_get_format( AVCodecContext *, const enum PixelFormat * ); -hb_va_dxva2_t *hb_va_create_dxva2( hb_va_dxva2_t *dxva2, int codec_id ); -void hb_va_new_dxva2( hb_va_dxva2_t *dxva2, AVCodecContext *p_context ); -void hb_va_release( hb_va_dxva2_t *dxva2, AVFrame *frame ); -void hb_va_close( hb_va_dxva2_t *dxva2 ); -int hb_check_hwd_fmt( int fmt ); - -#endif // HB_VA_DXVA2_H - -#endif // USE_HWD diff --git a/libhb/work.c b/libhb/work.c index 4b09144b2..e3e41cdb2 100644 --- a/libhb/work.c +++ b/libhb/work.c @@ -359,13 +359,6 @@ void hb_display_job_info(hb_job_t *job) } else #endif -#ifdef USE_HWD - if (hb_hwd_enabled(job->h)) - { - hb_log(" + decoder: %s (dxva2)", title->video_codec_name); - } - else -#endif { hb_log(" + decoder: %s", title->video_codec_name); } @@ -1421,23 +1414,6 @@ static void do_job(hb_job_t *job) goto cleanup; } -#ifdef USE_HWD - /* - * Check support for and enable DXVA2-accelerated when applicable; we need: - * - a compatible input bitstream (HB_DECODE_SUPPORT_DXVA2) - * - DXVA2-accelerated decoding enabled (job->use_hwd) - * - an AVFormatContext (title->opaque_priv) for now - */ - if (title->video_decode_support & HB_DECODE_SUPPORT_DXVA2) - { - hb_hwd_set_enable(job->h, job->use_hwd && title->opaque_priv != NULL); - } - else -#endif - { - hb_hwd_set_enable(job->h, 0); - } - // Filters have an effect on settings. // So initialize the filters and update the job. if (job->list_filter && hb_list_count(job->list_filter)) diff --git a/make/configure.py b/make/configure.py index 2b29d7c86..2a3ad3214 100644 --- a/make/configure.py +++ b/make/configure.py @@ -1245,8 +1245,6 @@ def createCLI(): h = IfHost( 'enable use of Intel Quick Sync Video hardware acceleration', '*-*-*', none=optparse.SUPPRESS_HELP ).value grp.add_option( '--enable-qsv', default=False, action='store_true', help=h ) - h = IfHost( 'enable HWD features', '*-*-*', none=optparse.SUPPRESS_HELP ).value - grp.add_option( '--enable-hwd', default=False, action='store_true', help=h ) h = IfHost( 'enable use of x265 encoding', '*-*-*', none=optparse.SUPPRESS_HELP ).value grp.add_option( '--enable-x265', default=True, action='store_true', help=h ) @@ -1780,7 +1778,6 @@ int main () doc.add( 'FEATURE.fdk_aac', int( options.enable_fdk_aac )) doc.add( 'FEATURE.libav_aac', int( options.enable_libav_aac )) doc.add( 'FEATURE.qsv', int( options.enable_qsv )) - doc.add( 'FEATURE.hwd', int( options.enable_hwd )) doc.add( 'FEATURE.xcode', int( not (Tools.xcodebuild.fail or options.disable_xcode or options.cross) )) doc.add( 'FEATURE.x265', int( options.enable_x265 )) diff --git a/test/module.defs b/test/module.defs index 396b4b070..1154b9bb6 100644 --- a/test/module.defs +++ b/test/module.defs @@ -60,9 +60,6 @@ else ifeq (1-mingw,$(BUILD.cross)-$(BUILD.system)) ifeq ($(HAS.dlfcn),1) TEST.GCC.l += dl endif -ifeq (1,$(FEATURE.hwd)) - TEST.GCC.D += USE_HWD -endif ifeq (1,$(HAS.pthread)) TEST.GCC.l += pthread else diff --git a/test/test.c b/test/test.c index 8e58fa9e3..9e1dc9b01 100644 --- a/test/test.c +++ b/test/test.c @@ -164,7 +164,6 @@ static int64_t stop_at_pts = 0; static int stop_at_frame = 0; static uint64_t min_title_duration = 10; static int use_opencl = -1; -static int use_hwd = -1; #ifdef USE_QSV static int qsv_async_depth = -1; static int qsv_decode = -1; @@ -516,12 +515,6 @@ int main( int argc, char ** argv ) hb_system_sleep_prevent(h); - // FIXME: When hardware decode is enabled, the scan must be performed - // with hardware decode enabled because the decoder context used during - // encoding phase comes from the context used during scan. This is - // broken by design and I would very much like to fix this someday. - hb_hwd_set_enable(h, hb_value_get_bool( - hb_dict_get(preset_dict, "VideoHWDecode"))); hb_scan(h, input, titleindex, preview_count, store_previews, min_title_duration * 90000LL); @@ -1219,8 +1212,6 @@ static void ShowHelp() " -I, --ipod-atom Mark mp4 files so 5.5G iPods will accept them\n" " --no-ipod-atom Disable 5.5G iPod tag\n" " -P, --use-opencl Use OpenCL where applicable\n" -" -U, --use-hwd Use DXVA2 hardware decoding\n" -" --no-hwd Disable DXVA2 hardware decoding\n" "\n" @@ -1914,8 +1905,6 @@ static int ParseOptions( int argc, char ** argv ) { "ipod-atom", no_argument, NULL, 'I' }, { "no-ipod-atom",no_argument, &ipod_atom, 0 }, { "use-opencl", no_argument, NULL, 'P' }, - { "use-hwd", no_argument, NULL, 'U' }, - { "no-hwd", no_argument, &use_hwd, 0 }, { "title", required_argument, NULL, 't' }, { "min-duration",required_argument, NULL, MIN_DURATION }, @@ -2159,9 +2148,6 @@ static int ParseOptions( int argc, char ** argv ) case 'P': use_opencl = 1; break; - case 'U': - use_hwd = 1; - break; case 't': titleindex = atoi( optarg ); break; @@ -3556,10 +3542,6 @@ static hb_dict_t * PreparePreset(const char *preset_name) hb_dict_set(preset, "VideoQSVDecode", hb_value_int(qsv_decode)); } #endif - if (use_hwd != -1) - { - hb_dict_set(preset, "VideoHWDecode", hb_value_bool(use_hwd)); - } if (use_opencl != -1) { hb_dict_set(preset, "VideoScaler", |