From f69b7f1dfc98c90d454078f1a3aabef3bae36fd2 Mon Sep 17 00:00:00 2001 From: sr55 <sr55.hb@outlook.com> Date: Sat, 21 Sep 2013 20:16:51 +0000 Subject: Merging-in the OpenCL Scaling code from the OpenCL branch to trunk. Patch originally by the Multicoreware Inc team, followed by improvements and fixes by Micheal Wootton from AMD Inc, OpenCL: This patch implements Bicubic Scaling in OpenCL. Note that HandBrake currently uses Lanczos so the performance difference appears to be much more significant. We may offer an option of BiCubic in software later. Bicubic scaling may appear a bit sharper than the equivalent Lanczos encode and may increase file size a bit. Quality may be better or worse depending on the scaling and content and personal preference towards sharpness. When comparing performance with a custom HandBrake build that runs Software Bicubic to OpenCL Bicubic, performance increase is about 5~7% on average on a modern GPU. Hardware Decode via DXVA: We also have optional DXVA decoding which may come in useful for slower/lower end systems that have a capable GPU. This is only available on input sources that use the libav decode path. Most GPU hardware for decoding is designed for playback, so if you are running on a high end CPU, it will bottleneck the encode process. Requires OpenCL 1.1 or later supporting GPU. Front end changes and testing framework are not included in this patch. This will be resolved later. Patch will be revised further before the UI is implemented. git-svn-id: svn://svn.handbrake.fr/HandBrake/trunk@5792 b64f7644-9d1e-0410-96f1-a4d463321fa5 --- libhb/stream.c | 56 ++++++++++++++++++++++++++++++++++++++++++++++++++++++-- 1 file changed, 54 insertions(+), 2 deletions(-) (limited to 'libhb/stream.c') diff --git a/libhb/stream.c b/libhb/stream.c index 994cb70de..3512b2d93 100644 --- a/libhb/stream.c +++ b/libhb/stream.c @@ -16,6 +16,7 @@ #include "lang.h" #include "a52dec/a52.h" #include "libbluray/bluray.h" +#include "vadxva2.h" #define min(a, b) a < b ? a : b #define HB_MAX_PROBE_SIZE (1*1024*1024) @@ -49,7 +50,7 @@ typedef struct { static const stream2codec_t st2codec[256] = { st(0x00, U, 0, 0, NULL), st(0x01, V, WORK_DECMPEG2, 0, "MPEG1"), - st(0x02, V, WORK_DECMPEG2, 0, "MPEG2"), + st(0x02, V, WORK_DECMPEG2, AV_CODEC_ID_MPEG2VIDEO, "MPEG2"), st(0x03, A, HB_ACODEC_FFMPEG, AV_CODEC_ID_MP2, "MPEG1"), st(0x04, A, HB_ACODEC_FFMPEG, AV_CODEC_ID_MP2, "MPEG2"), st(0x05, N, 0, 0, "ISO 13818-1 private section"), @@ -609,6 +610,10 @@ static int hb_stream_get_type(hb_stream_t *stream) if ( fread(buf, 1, sizeof(buf), stream->file_handle) == sizeof(buf) ) { +#ifdef USE_HWD + if ( hb_gui_use_hwd_flag == 1 ) + return 0; +#endif int psize; if ( ( psize = hb_stream_check_for_ts(buf) ) != 0 ) { @@ -1096,7 +1101,28 @@ hb_title_t * hb_stream_title_scan(hb_stream_t *stream, hb_title_t * title) { hb_log( "transport stream missing PCRs - using video DTS instead" ); } - +#ifdef USE_HWD + hb_va_dxva2_t * dxva2 = NULL; + dxva2 = hb_va_create_dxva2( dxva2, title->video_codec_param ); + if ( dxva2 ) + { + title->hwd_support = 1; + hb_va_close(dxva2); + dxva2 = NULL; + } + else + title->hwd_support = 0; +#else + title->hwd_support = 0; +#endif +#ifdef USE_OPENCL + if ( hb_confirm_gpu_type() == 0 ) + title->opencl_support = 1; + else + title->opencl_support = 0; +#else + title->opencl_support = 0; +#endif // Height, width, rate and aspect ratio information is filled in // when the previews are built return title; @@ -5513,6 +5539,7 @@ static hb_title_t *ffmpeg_title_scan( hb_stream_t *stream, hb_title_t *title ) title->demuxer = HB_NULL_DEMUXER; title->video_codec = 0; int i; + int pix_fmt = -1; for (i = 0; i < ic->nb_streams; ++i ) { if ( ic->streams[i]->codec->codec_type == AVMEDIA_TYPE_VIDEO && @@ -5520,6 +5547,7 @@ static hb_title_t *ffmpeg_title_scan( hb_stream_t *stream, hb_title_t *title ) title->video_codec == 0 ) { AVCodecContext *context = ic->streams[i]->codec; + pix_fmt = context->pix_fmt; if ( context->pix_fmt != AV_PIX_FMT_YUV420P && !sws_isSupportedInput( context->pix_fmt ) ) { @@ -5626,6 +5654,30 @@ static hb_title_t *ffmpeg_title_scan( hb_stream_t *stream, hb_title_t *title ) chapter->seconds = title->seconds; hb_list_add( title->list_chapter, chapter ); } +#ifdef USE_HWD + hb_va_dxva2_t * dxva2 = NULL; + dxva2 = hb_va_create_dxva2( dxva2, title->video_codec_param ); + if (dxva2) + { + title->hwd_support = 1; + hb_va_close(dxva2); + dxva2 = NULL; + } + else + title->hwd_support = 0; + if ( hb_check_hwd_fmt(pix_fmt) == 0) + title->hwd_support = 0; +#else + title->hwd_support = 0; +#endif +#ifdef USE_OPENCL + if (hb_confirm_gpu_type() == 0) + title->opencl_support = 1; + else + title->opencl_support = 0; +#else + title->opencl_support = 0; +#endif return title; } -- cgit v1.2.3