diff options
author | jstebbins <[email protected]> | 2014-12-16 22:37:59 +0000 |
---|---|---|
committer | jstebbins <[email protected]> | 2014-12-16 22:37:59 +0000 |
commit | cb6a52dcf9b33810272773fa02b457e3a4c8b7f0 (patch) | |
tree | d16ef6545aa9ce0ef0c1d51bf82de28e84e12993 /libhb | |
parent | f56efd7b52c89da8cac55b4d4a187f2c87fdfee6 (diff) |
json: fix building with qsv enabled.
git-svn-id: svn://svn.handbrake.fr/HandBrake/trunk@6603 b64f7644-9d1e-0410-96f1-a4d463321fa5
Diffstat (limited to 'libhb')
-rw-r--r-- | libhb/common.c | 26 | ||||
-rw-r--r-- | libhb/common.h | 1 | ||||
-rw-r--r-- | libhb/enc_qsv.c | 38 | ||||
-rw-r--r-- | libhb/qsv_filter.c | 36 | ||||
-rw-r--r-- | libhb/qsv_filter_pp.c | 10 | ||||
-rw-r--r-- | libhb/work.c | 8 |
6 files changed, 68 insertions, 51 deletions
diff --git a/libhb/common.c b/libhb/common.c index ee4c566ba..0206b99ac 100644 --- a/libhb/common.c +++ b/libhb/common.c @@ -2316,6 +2316,32 @@ void hb_reduce( int *x, int *y, int num, int den ) } } +void hb_limit_rational( int *x, int *y, int num, int den, int limit ) +{ + hb_reduce( &num, &den, num, den ); + if ( num < limit && den < limit ) + { + *x = num; + *y = den; + return; + } + + if ( num > den ) + { + double div = (double)limit / num; + num = limit; + den *= div; + } + else + { + double div = (double)limit / den; + den = limit; + num *= div; + } + *x = num; + *y = den; +} + /********************************************************************** * hb_reduce64 ********************************************************************** diff --git a/libhb/common.h b/libhb/common.h index 1b86cf4e1..17d47a76f 100644 --- a/libhb/common.h +++ b/libhb/common.h @@ -135,6 +135,7 @@ void * hb_list_item( const hb_list_t *, int ); void hb_list_close( hb_list_t ** ); void hb_reduce( int *x, int *y, int num, int den ); +void hb_limit_rational( int *x, int *y, int num, int den, int limit ); void hb_reduce64( int64_t *x, int64_t *y, int64_t num, int64_t den ); void hb_limit_rational64( int64_t *x, int64_t *y, int64_t num, int64_t den, int64_t limit ); diff --git a/libhb/enc_qsv.c b/libhb/enc_qsv.c index ddf1cf664..a1ba9d5f2 100644 --- a/libhb/enc_qsv.c +++ b/libhb/enc_qsv.c @@ -268,9 +268,9 @@ int qsv_enc_init(hb_work_private_t *pv) else { pv->sws_context_to_nv12 = hb_sws_get_context( - job->geometry.width, job->geometry.height, + job->width, job->height, AV_PIX_FMT_YUV420P, - job->geometry.width, job->geometry.height, + job->width, job->height, AV_PIX_FMT_NV12, SWS_LANCZOS|SWS_ACCURATE_RND); } @@ -505,24 +505,20 @@ int encqsvInit(hb_work_object_t *w, hb_job_t *job) } // sanitize values that may exceed the Media SDK variable size - int64_t vrate, vrate_base; - int64_t par_width, par_height; - hb_limit_rational64(&vrate, &vrate_base, - job->vrate, job->vrate_base, UINT32_MAX); - hb_limit_rational64(&par_width, &par_height, - job->anamorphic.par_width, - job->anamorphic.par_height, UINT16_MAX); + hb_rational_t par; + hb_limit_rational(&par.num, &par.den, + job->par.num, job->par.den, UINT16_MAX); // some encoding parameters are used by filters to configure their output if (pv->param.videoParam->mfx.FrameInfo.PicStruct != MFX_PICSTRUCT_PROGRESSIVE) { - job->qsv.enc_info.align_height = AV_QSV_ALIGN32(job->geometry.height); + job->qsv.enc_info.align_height = AV_QSV_ALIGN32(job->height); } else { - job->qsv.enc_info.align_height = AV_QSV_ALIGN16(job->geometry.height); + job->qsv.enc_info.align_height = AV_QSV_ALIGN16(job->height); } - job->qsv.enc_info.align_width = AV_QSV_ALIGN16(job->geometry.width); + job->qsv.enc_info.align_width = AV_QSV_ALIGN16(job->width); job->qsv.enc_info.pic_struct = pv->param.videoParam->mfx.FrameInfo.PicStruct; job->qsv.enc_info.is_init_done = 1; @@ -532,14 +528,14 @@ int encqsvInit(hb_work_object_t *w, hb_job_t *job) pv->param.videoParam->mfx.CodecProfile = MFX_PROFILE_UNKNOWN; pv->param.videoParam->mfx.FrameInfo.FourCC = MFX_FOURCC_NV12; pv->param.videoParam->mfx.FrameInfo.ChromaFormat = MFX_CHROMAFORMAT_YUV420; - pv->param.videoParam->mfx.FrameInfo.FrameRateExtN = vrate; - pv->param.videoParam->mfx.FrameInfo.FrameRateExtD = vrate_base; - pv->param.videoParam->mfx.FrameInfo.AspectRatioW = par_width; - pv->param.videoParam->mfx.FrameInfo.AspectRatioH = par_height; + pv->param.videoParam->mfx.FrameInfo.FrameRateExtN = job->vrate.num; + pv->param.videoParam->mfx.FrameInfo.FrameRateExtD = job->vrate.den; + pv->param.videoParam->mfx.FrameInfo.AspectRatioW = par.num; + pv->param.videoParam->mfx.FrameInfo.AspectRatioH = par.den; pv->param.videoParam->mfx.FrameInfo.CropX = 0; pv->param.videoParam->mfx.FrameInfo.CropY = 0; - pv->param.videoParam->mfx.FrameInfo.CropW = job->geometry.width; - pv->param.videoParam->mfx.FrameInfo.CropH = job->geometry.height; + pv->param.videoParam->mfx.FrameInfo.CropW = job->width; + pv->param.videoParam->mfx.FrameInfo.CropH = job->height; pv->param.videoParam->mfx.FrameInfo.PicStruct = job->qsv.enc_info.pic_struct; pv->param.videoParam->mfx.FrameInfo.Width = job->qsv.enc_info.align_width; pv->param.videoParam->mfx.FrameInfo.Height = job->qsv.enc_info.align_height; @@ -770,7 +766,7 @@ int encqsvInit(hb_work_object_t *w, hb_job_t *job) // set the keyframe interval if (pv->param.gop.gop_pic_size < 0) { - int rate = (int)((double)job->vrate / (double)job->vrate_base + 0.5); + int rate = (int)((double)job->vrate.num / (double)job->vrate.den + 0.5); if (pv->param.videoParam->mfx.RateControlMethod == MFX_RATECONTROL_CQP) { // ensure B-pyramid is enabled for CQP on Haswell @@ -1387,8 +1383,8 @@ static void compute_init_delay(hb_work_private_t *pv, mfxBitstream *bs) * compute it based on the init_delay and average frame duration, * and account for potential rounding errors due to the timebase. */ - double avg_frame_dur = ((double)pv->job->vrate_base / - (double)pv->job->vrate * 90000.); + double avg_frame_dur = ((double)pv->job->vrate.den / + (double)pv->job->vrate.num * 90000.); pv->bfrm_delay = (init_delay + (avg_frame_dur / 2)) / avg_frame_dur; diff --git a/libhb/qsv_filter.c b/libhb/qsv_filter.c index 6c78a5f2d..8487865fe 100644 --- a/libhb/qsv_filter.c +++ b/libhb/qsv_filter.c @@ -148,8 +148,8 @@ static int filter_init( av_qsv_context* qsv, hb_filter_private_t * pv ){ // FrameRate is important for VPP to start with if( qsv->dec_space->m_mfxVideoParam.mfx.FrameInfo.FrameRateExtN == 0 && qsv->dec_space->m_mfxVideoParam.mfx.FrameInfo.FrameRateExtD == 0 ){ - qsv->dec_space->m_mfxVideoParam.mfx.FrameInfo.FrameRateExtN = pv->job->title->rate; - qsv->dec_space->m_mfxVideoParam.mfx.FrameInfo.FrameRateExtD = pv->job->title->rate_base; + qsv->dec_space->m_mfxVideoParam.mfx.FrameInfo.FrameRateExtN = pv->job->title->vrate.num; + qsv->dec_space->m_mfxVideoParam.mfx.FrameInfo.FrameRateExtD = pv->job->title->vrate.den; } /* @@ -179,8 +179,8 @@ static int filter_init( av_qsv_context* qsv, hb_filter_private_t * pv ){ qsv_vpp->m_mfxVideoParam.vpp.In.FourCC = qsv->dec_space->m_mfxVideoParam.mfx.FrameInfo.FourCC; qsv_vpp->m_mfxVideoParam.vpp.In.ChromaFormat = qsv->dec_space->m_mfxVideoParam.mfx.FrameInfo.ChromaFormat; - qsv_vpp->m_mfxVideoParam.vpp.In.FrameRateExtN = pv->job->vrate; - qsv_vpp->m_mfxVideoParam.vpp.In.FrameRateExtD = pv->job->vrate_base; + qsv_vpp->m_mfxVideoParam.vpp.In.FrameRateExtN = pv->job->vrate.num; + qsv_vpp->m_mfxVideoParam.vpp.In.FrameRateExtD = pv->job->vrate.den; qsv_vpp->m_mfxVideoParam.vpp.In.AspectRatioW = qsv->dec_space->m_mfxVideoParam.mfx.FrameInfo.AspectRatioW; qsv_vpp->m_mfxVideoParam.vpp.In.AspectRatioH = qsv->dec_space->m_mfxVideoParam.mfx.FrameInfo.AspectRatioH; qsv_vpp->m_mfxVideoParam.vpp.In.Width = qsv->dec_space->m_mfxVideoParam.mfx.FrameInfo.Width; @@ -192,8 +192,8 @@ static int filter_init( av_qsv_context* qsv, hb_filter_private_t * pv ){ qsv_vpp->m_mfxVideoParam.vpp.Out.FourCC = qsv->dec_space->m_mfxVideoParam.mfx.FrameInfo.FourCC; qsv_vpp->m_mfxVideoParam.vpp.Out.ChromaFormat = qsv->dec_space->m_mfxVideoParam.mfx.FrameInfo.ChromaFormat; - qsv_vpp->m_mfxVideoParam.vpp.Out.FrameRateExtN = pv->job->vrate; - qsv_vpp->m_mfxVideoParam.vpp.Out.FrameRateExtD = pv->job->vrate_base; + qsv_vpp->m_mfxVideoParam.vpp.Out.FrameRateExtN = pv->job->vrate.num; + qsv_vpp->m_mfxVideoParam.vpp.Out.FrameRateExtD = pv->job->vrate.den; qsv_vpp->m_mfxVideoParam.vpp.Out.AspectRatioW = qsv->dec_space->m_mfxVideoParam.mfx.FrameInfo.AspectRatioW; qsv_vpp->m_mfxVideoParam.vpp.Out.AspectRatioH = qsv->dec_space->m_mfxVideoParam.mfx.FrameInfo.AspectRatioH; qsv_vpp->m_mfxVideoParam.vpp.Out.Width = pv->job->qsv.enc_info.align_width; @@ -360,10 +360,6 @@ static int hb_qsv_filter_init( hb_filter_object_t * filter, // will be later as more params will be known // filter_init(pv->job->qsv, pv); - // just passing - init->vrate = init->vrate; - init->vrate_base = init->vrate_base; - // framerate shaping not yet supported init->cfr = 0; @@ -439,7 +435,6 @@ void qsv_filter_close( av_qsv_context* qsv, AV_QSV_STAGE_TYPE vpp_type ){ static void hb_qsv_filter_close( hb_filter_object_t * filter ) { - int i = 0; hb_filter_private_t * pv = filter->private_data; if ( !pv ) @@ -639,18 +634,17 @@ static int hb_qsv_filter_work( hb_filter_object_t * filter, out = *buf_out; if(pv->is_frc_used && out) { - mfxStatus sts = MFX_ERR_NONE; - if(out->qsv_details.qsv_atom){ - av_qsv_stage* stage = av_qsv_get_last_stage( out->qsv_details.qsv_atom ); - mfxFrameSurface1 *work_surface = stage->out.p_surface; + if(out->qsv_details.qsv_atom){ + av_qsv_stage* stage = av_qsv_get_last_stage( out->qsv_details.qsv_atom ); + mfxFrameSurface1 *work_surface = stage->out.p_surface; - av_qsv_wait_on_sync( qsv,stage ); + av_qsv_wait_on_sync( qsv,stage ); - av_qsv_space *qsv_vpp = pv->vpp_space; - int64_t duration = ((double)qsv_vpp->m_mfxVideoParam.vpp.Out.FrameRateExtD/(double)qsv_vpp->m_mfxVideoParam.vpp.Out.FrameRateExtN ) * 90000.; - out->s.start = work_surface->Data.TimeStamp; - out->s.stop = work_surface->Data.TimeStamp + duration; - } + av_qsv_space *qsv_vpp = pv->vpp_space; + int64_t duration = ((double)qsv_vpp->m_mfxVideoParam.vpp.Out.FrameRateExtD/(double)qsv_vpp->m_mfxVideoParam.vpp.Out.FrameRateExtN ) * 90000.; + out->s.start = work_surface->Data.TimeStamp; + out->s.stop = work_surface->Data.TimeStamp + duration; + } } hb_list_rem(pv->list,*buf_out); } diff --git a/libhb/qsv_filter_pp.c b/libhb/qsv_filter_pp.c index 1703281a8..e05050a20 100644 --- a/libhb/qsv_filter_pp.c +++ b/libhb/qsv_filter_pp.c @@ -136,8 +136,8 @@ static int filter_pre_init( av_qsv_context* qsv, hb_filter_private_t * pv ){ // FrameRate is important for VPP to start with if( qsv->dec_space->m_mfxVideoParam.mfx.FrameInfo.FrameRateExtN == 0 && qsv->dec_space->m_mfxVideoParam.mfx.FrameInfo.FrameRateExtD == 0 ){ - qsv->dec_space->m_mfxVideoParam.mfx.FrameInfo.FrameRateExtN = pv->job->title->rate; - qsv->dec_space->m_mfxVideoParam.mfx.FrameInfo.FrameRateExtD = pv->job->title->rate_base; + qsv->dec_space->m_mfxVideoParam.mfx.FrameInfo.FrameRateExtN = pv->job->title->vrate.num; + qsv->dec_space->m_mfxVideoParam.mfx.FrameInfo.FrameRateExtD = pv->job->title->vrate.den; } qsv_vpp->m_mfxVideoParam.vpp.In.FourCC = qsv->dec_space->m_mfxVideoParam.mfx.FrameInfo.FourCC; @@ -153,14 +153,14 @@ static int filter_pre_init( av_qsv_context* qsv, hb_filter_private_t * pv ){ qsv_vpp->m_mfxVideoParam.vpp.In.AspectRatioH = qsv->dec_space->m_mfxVideoParam.mfx.FrameInfo.AspectRatioH; qsv_vpp->m_mfxVideoParam.vpp.In.Width = AV_QSV_ALIGN16(pv->job->title->geometry.width); qsv_vpp->m_mfxVideoParam.vpp.In.Height = (MFX_PICSTRUCT_PROGRESSIVE == qsv_vpp->m_mfxVideoParam.vpp.In.PicStruct)? - AV_QSV_ALIGN16(pv->job->title->height) : AV_QSV_ALIGN32(pv->job->title->geometry.height); + AV_QSV_ALIGN16(pv->job->title->geometry.height) : AV_QSV_ALIGN32(pv->job->title->geometry.height); qsv_vpp->m_mfxVideoParam.vpp.Out.FourCC = qsv->dec_space->m_mfxVideoParam.mfx.FrameInfo.FourCC; qsv_vpp->m_mfxVideoParam.vpp.Out.ChromaFormat = qsv->dec_space->m_mfxVideoParam.mfx.FrameInfo.ChromaFormat; qsv_vpp->m_mfxVideoParam.vpp.Out.CropX = qsv->dec_space->m_mfxVideoParam.mfx.FrameInfo.CropX; qsv_vpp->m_mfxVideoParam.vpp.Out.CropY = qsv->dec_space->m_mfxVideoParam.mfx.FrameInfo.CropY; qsv_vpp->m_mfxVideoParam.vpp.Out.CropW = pv->job->title->geometry.width; - qsv_vpp->m_mfxVideoParam.vpp.Out.CropH = pv->job->title->height; + qsv_vpp->m_mfxVideoParam.vpp.Out.CropH = pv->job->title->geometry.height; qsv_vpp->m_mfxVideoParam.vpp.Out.PicStruct = qsv->dec_space->m_mfxVideoParam.mfx.FrameInfo.PicStruct; qsv_vpp->m_mfxVideoParam.vpp.Out.FrameRateExtN = qsv->dec_space->m_mfxVideoParam.mfx.FrameInfo.FrameRateExtN; qsv_vpp->m_mfxVideoParam.vpp.Out.FrameRateExtD = qsv->dec_space->m_mfxVideoParam.mfx.FrameInfo.FrameRateExtD; @@ -168,7 +168,7 @@ static int filter_pre_init( av_qsv_context* qsv, hb_filter_private_t * pv ){ qsv_vpp->m_mfxVideoParam.vpp.Out.AspectRatioH = qsv->dec_space->m_mfxVideoParam.mfx.FrameInfo.AspectRatioH; qsv_vpp->m_mfxVideoParam.vpp.Out.Width = AV_QSV_ALIGN16(pv->job->title->geometry.width); qsv_vpp->m_mfxVideoParam.vpp.Out.Height = (MFX_PICSTRUCT_PROGRESSIVE == qsv_vpp->m_mfxVideoParam.vpp.In.PicStruct)? - AV_QSV_ALIGN16(pv->job->title->height) : AV_QSV_ALIGN32(pv->job->title->height); + AV_QSV_ALIGN16(pv->job->title->geometry.height) : AV_QSV_ALIGN32(pv->job->title->geometry.height); memset(&qsv_vpp->request, 0, sizeof(mfxFrameAllocRequest)*2); } diff --git a/libhb/work.c b/libhb/work.c index 2860233c6..7b135c85a 100644 --- a/libhb/work.c +++ b/libhb/work.c @@ -769,8 +769,8 @@ static void do_job(hb_job_t *job) int num_cpu_filters = 0; hb_filter_object_t *filter; // default values for VPP filter - vpp_settings[0] = job->title->width; - vpp_settings[1] = job->title->height; + vpp_settings[0] = job->title->geometry.width; + vpp_settings[1] = job->title->geometry.height; vpp_settings[2] = job->title->crop[0]; vpp_settings[3] = job->title->crop[1]; vpp_settings[4] = job->title->crop[2]; @@ -842,8 +842,8 @@ static void do_job(hb_job_t *job) filter = hb_filter_init(HB_FILTER_QSV_POST); hb_add_filter(job, filter, NULL); } - if (vpp_settings[0] != job->title->width || - vpp_settings[1] != job->title->height || + if (vpp_settings[0] != job->title->geometry.width || + vpp_settings[1] != job->title->geometry.height || vpp_settings[2] >= 1 /* crop */ || vpp_settings[3] >= 1 /* crop */ || vpp_settings[4] >= 1 /* crop */ || |