From: Rodeo Date: Sat, 3 Aug 2013 11:07:40 +0000 (+0000) Subject: QSV: use software decoding for 10-bit H.264 sources. X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=e2bcc9268327061277fb154e6989c709ce98d5e5;p=handbrake QSV: use software decoding for 10-bit H.264 sources. git-svn-id: svn://svn.handbrake.fr/HandBrake/branches/qsv@5681 b64f7644-9d1e-0410-96f1-a4d463321fa5 --- diff --git a/libhb/common.h b/libhb/common.h index 5b364b6a7..658f00f70 100644 --- a/libhb/common.h +++ b/libhb/common.h @@ -847,6 +847,10 @@ struct hb_title_s char *container_name; int data_rate; +#ifdef USE_QSV + int qsv_decode_support; +#endif + hb_metadata_t *metadata; hb_list_t * list_chapter; @@ -943,6 +947,9 @@ typedef struct hb_work_info_s int color_prim; int color_transfer; int color_matrix; +#ifdef USE_QSV + int qsv_decode_support; +#endif }; struct { // info only valid for audio decoders diff --git a/libhb/decavcodec.c b/libhb/decavcodec.c index 3dd76516e..01c2760f4 100644 --- a/libhb/decavcodec.c +++ b/libhb/decavcodec.c @@ -1172,8 +1172,7 @@ static int decavcodecvInit( hb_work_object_t * w, hb_job_t * job ) pv->list = hb_list_init(); #ifdef USE_QSV - if (job != NULL && job->vcodec == HB_VCODEC_QSV_H264 && - w->codec_param == AV_CODEC_ID_H264) + if (hb_qsv_decode_is_enabled(job)) { int ret; hb_dict_t *qsv_opts = NULL; @@ -1674,6 +1673,11 @@ static int decavcodecvInfo( hb_work_object_t *w, hb_work_info_t *info ) } } +#ifdef USE_QSV + info->qsv_decode_support = hb_qsv_decode_is_supported(pv->context->codec_id, + pv->context->pix_fmt); +#endif + return 1; } diff --git a/libhb/decmpeg2.c b/libhb/decmpeg2.c index 8844a09af..2a186295d 100644 --- a/libhb/decmpeg2.c +++ b/libhb/decmpeg2.c @@ -911,6 +911,10 @@ static int decmpeg2Info( hb_work_object_t *w, hb_work_info_t *info ) info->level = m->info->sequence->profile_level_id & 0xf; info->name = "mpeg2"; +#ifdef USE_QSV + info->qsv_decode_support = 0; +#endif + if( pv->libmpeg2->info->sequence->flags & SEQ_FLAG_COLOUR_DESCRIPTION ) { switch( pv->libmpeg2->info->sequence->colour_primaries ) diff --git a/libhb/qsv_common.c b/libhb/qsv_common.c index 7054f1faa..268eccce6 100644 --- a/libhb/qsv_common.c +++ b/libhb/qsv_common.c @@ -244,3 +244,23 @@ const char* hb_qsv_decode_get_codec_name(enum AVCodecID codec_id) return NULL; } } + +int hb_qsv_decode_is_enabled(hb_job_t *job) +{ + return ((job != NULL && job->title->qsv_decode_support) && + (job->vcodec & HB_VCODEC_QSV_MASK)); +} + +int hb_qsv_decode_is_supported(enum AVCodecID codec_id, + enum AVPixelFormat pix_fmt) +{ + switch (codec_id) + { + case AV_CODEC_ID_H264: + return (pix_fmt == AV_PIX_FMT_YUV420P || + pix_fmt == AV_PIX_FMT_YUVJ420P); + + default: + return 0; + } +} diff --git a/libhb/qsv_common.h b/libhb/qsv_common.h index 2ee5cbf1a..c2f4f710c 100644 --- a/libhb/qsv_common.h +++ b/libhb/qsv_common.h @@ -61,5 +61,7 @@ void hb_qsv_info_print(); /* Intel Quick Sync Video DECODE utilities */ const char* hb_qsv_decode_get_codec_name(enum AVCodecID codec_id); +int hb_qsv_decode_is_enabled(hb_job_t *job); +int hb_qsv_decode_is_supported(enum AVCodecID codec_id, enum AVPixelFormat pix_fmt); #endif diff --git a/libhb/scan.c b/libhb/scan.c index 0d7dde7ff..507662f36 100644 --- a/libhb/scan.c +++ b/libhb/scan.c @@ -865,6 +865,10 @@ skip_preview: title->color_transfer = vid_info.color_transfer; title->color_matrix = vid_info.color_matrix; +#ifdef USE_QSV + title->qsv_decode_support = vid_info.qsv_decode_support; +#endif + // compute the aspect ratio based on the storage dimensions and the // pixel aspect ratio (if supplied) or just storage dimensions if no PAR. title->aspect = (double)title->width / (double)title->height; diff --git a/libhb/work.c b/libhb/work.c index 418ac185d..cfa75c2f9 100644 --- a/libhb/work.c +++ b/libhb/work.c @@ -12,7 +12,7 @@ #include "libavformat/avformat.h" #ifdef USE_QSV -#include "libavcodec/qsv.h" +#include "qsv_common.h" #include "qsv_filter_pp.h" #endif @@ -235,7 +235,17 @@ void hb_display_job_info(hb_job_t *job) hb_log(" * video track"); - hb_log(" + decoder: %s", title->video_codec_name ); +#ifdef USE_QSV + if (hb_qsv_decode_is_enabled(job)) + { + hb_log(" + decoder: %s", + hb_qsv_decode_get_codec_name(title->video_codec_param)); + } + else +#endif + { + hb_log(" + decoder: %s", title->video_codec_name); + } if( title->video_bitrate ) { @@ -679,9 +689,10 @@ static void do_job(hb_job_t *job) init.vrate = title->rate; init.cfr = 0; +#ifdef USE_QSV int is_vpp_interlace = 0; int is_actual_crop_resize = 0; - if( job->vcodec == HB_VCODEC_QSV_H264 && title->video_codec_param == AV_CODEC_ID_H264 ) + if (hb_qsv_decode_is_enabled(job)) { for( i = 0; i < hb_list_count( job->list_filter ); i++ ) { @@ -715,15 +726,17 @@ static void do_job(hb_job_t *job) init.cfr = 0; } int is_additional_vpp_function = (is_actual_crop_resize || is_vpp_interlace); +#endif for( i = 0; i < hb_list_count( job->list_filter ); ) { hb_filter_object_t * filter = hb_list_item( job->list_filter, i ); +#ifdef USE_QSV // to do not use QSV related if not handled from its decode if( job->vcodec == HB_VCODEC_QSV_H264 ) // for now, only h.264 related stuff - if( title->video_codec_param != AV_CODEC_ID_H264 ) + if (!hb_qsv_decode_is_enabled(job)) { if( filter->id == HB_FILTER_QSV_PRE || filter->id == HB_FILTER_QSV_POST || @@ -782,6 +795,7 @@ static void do_job(hb_job_t *job) } } } +#endif if( filter->init( filter, &init ) ) { @@ -826,14 +840,18 @@ static void do_job(hb_job_t *job) } } - if( job->vcodec == HB_VCODEC_QSV_H264 && title->video_codec_param == AV_CODEC_ID_H264){ +#ifdef USE_QSV + if (hb_qsv_decode_is_enabled(job)) + { job->fifo_mpeg2 = hb_fifo_init( FIFO_MINI, FIFO_MINI_WAKE ); job->fifo_raw = hb_fifo_init( FIFO_MINI, FIFO_MINI_WAKE ); job->fifo_sync = hb_fifo_init( FIFO_MINI, FIFO_MINI_WAKE ); job->fifo_render = hb_fifo_init( FIFO_MINI, FIFO_MINI_WAKE ); - job->fifo_mpeg4 = hb_fifo_init( FIFO_MINI, FIFO_MINI_WAKE ); + job->fifo_mpeg4 = hb_fifo_init( FIFO_MINI, FIFO_MINI_WAKE ); } - else{ + else +#endif + { job->fifo_mpeg2 = hb_fifo_init( FIFO_LARGE, FIFO_LARGE_WAKE ); job->fifo_raw = hb_fifo_init( FIFO_SMALL, FIFO_SMALL_WAKE ); job->fifo_sync = hb_fifo_init( FIFO_SMALL, FIFO_SMALL_WAKE );