Skip to content

Commit

Permalink
QSV: use software decoding for 10-bit H.264 sources.
Browse files Browse the repository at this point in the history
git-svn-id: svn://svn.handbrake.fr/HandBrake/branches/qsv@5681 b64f7644-9d1e-0410-96f1-a4d463321fa5
  • Loading branch information
twalker314 committed Aug 3, 2013
1 parent 20ad60b commit e2bcc92
Show file tree
Hide file tree
Showing 7 changed files with 68 additions and 9 deletions.
7 changes: 7 additions & 0 deletions libhb/common.h
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -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
Expand Down
8 changes: 6 additions & 2 deletions libhb/decavcodec.c
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -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;
}

Expand Down
4 changes: 4 additions & 0 deletions libhb/decmpeg2.c
Original file line number Diff line number Diff line change
Expand Up @@ -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 )
Expand Down
20 changes: 20 additions & 0 deletions libhb/qsv_common.c
Original file line number Diff line number Diff line change
Expand Up @@ -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;
}
}
2 changes: 2 additions & 0 deletions libhb/qsv_common.h
Original file line number Diff line number Diff line change
Expand Up @@ -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
4 changes: 4 additions & 0 deletions libhb/scan.c
Original file line number Diff line number Diff line change
Expand Up @@ -865,6 +865,10 @@ static int DecodePreviews( hb_scan_t * data, hb_title_t * title )
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;
Expand Down
32 changes: 25 additions & 7 deletions libhb/work.c
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down Expand Up @@ -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 )
{
Expand Down Expand Up @@ -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++ )
{
Expand Down Expand Up @@ -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 ||
Expand Down Expand Up @@ -782,6 +795,7 @@ static void do_job(hb_job_t *job)
}
}
}
#endif

if( filter->init( filter, &init ) )
{
Expand Down Expand Up @@ -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 );
Expand Down

0 comments on commit e2bcc92

Please sign in to comment.