From: handbrake Date: Mon, 15 Jul 2013 19:51:52 +0000 (+0000) Subject: QSV: fix for Render/Burn-in subtitles X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=71523bca83278e8fe691ba18fc443fd1378273eb;p=handbrake QSV: fix for Render/Burn-in subtitles git-svn-id: svn://svn.handbrake.fr/HandBrake/branches/qsv@5651 b64f7644-9d1e-0410-96f1-a4d463321fa5 --- diff --git a/libhb/qsv_memory.c b/libhb/qsv_memory.c index f0aa41615..72a18d278 100644 --- a/libhb/qsv_memory.c +++ b/libhb/qsv_memory.c @@ -38,10 +38,16 @@ int qsv_nv12_to_yuv420(struct SwsContext* sws_context,hb_buffer_t* dst, mfxFrame int in_pitch = src->Data.Pitch; int h = src->Info.CropH; int w = src->Info.CropW; -#if 0 + uint8_t *in_luma = 0; + uint8_t *in_chroma = 0; + static int copyframe_in_use = 1; + + mfxStatus sts = MFX_ERR_NONE; mfxFrameSurface1 accel_dst; + if (copyframe_in_use) + { accel_dst.Info.FourCC = src->Info.FourCC; accel_dst.Info.CropH = src->Info.CropH; accel_dst.Info.CropW = src->Info.CropW; @@ -54,14 +60,25 @@ int qsv_nv12_to_yuv420(struct SwsContext* sws_context,hb_buffer_t* dst, mfxFrame accel_dst.Data.VU = calloc( 1, in_pitch*h/2 ); sts = core->CopyFrame(core->pthis, &accel_dst, src ); - AV_QSV_CHECK_RESULT(sts, MFX_ERR_NONE, sts); - - uint8_t *in_luma = accel_dst.Data.Y + accel_dst.Info.CropY * in_pitch + accel_dst.Info.CropX; - uint8_t *in_chroma = accel_dst.Data.VU + accel_dst.Info.CropY / 2 * in_pitch + accel_dst.Info.CropX; -#else - uint8_t *in_luma = src->Data.Y + src->Info.CropY * in_pitch + src->Info.CropX; - uint8_t *in_chroma = src->Data.VU + src->Info.CropY / 2 * in_pitch + src->Info.CropX; -#endif + if (sts < MFX_ERR_NONE) + { + free(accel_dst.Data.Y); + free(accel_dst.Data.VU); + copyframe_in_use = 0; + } + else + { + in_luma = accel_dst.Data.Y + accel_dst.Info.CropY * in_pitch + accel_dst.Info.CropX; + in_chroma = accel_dst.Data.VU + accel_dst.Info.CropY / 2 * in_pitch + accel_dst.Info.CropX; + } + } + + if (!copyframe_in_use) + { + in_luma = src->Data.Y + src->Info.CropY * in_pitch + src->Info.CropX; + in_chroma = src->Data.VU + src->Info.CropY / 2 * in_pitch + src->Info.CropX; + } + hb_video_buffer_realloc( dst, w, h ); uint8_t *srcs[] = { in_luma, in_chroma }; @@ -70,15 +87,13 @@ int qsv_nv12_to_yuv420(struct SwsContext* sws_context,hb_buffer_t* dst, mfxFrame uint8_t *dsts[] = { dst->plane[0].data, dst->plane[1].data, dst->plane[2].data }; int dsts_stride[] = { dst->plane[0].stride, dst->plane[1].stride, dst->plane[2].stride }; - // note about - // mfxStatus (*CopyFrame) (mfxHDL pthis, mfxFrameSurface1 *dst, mfxFrameSurface1 *src); - // mfxStatus (*CopyBuffer)(mfxHDL pthis, mfxU8 *dst, mfxU32 size, mfxFrameSurface1 *src); - ret = sws_scale(sws_context, srcs, srcs_stride, 0, h, dsts, dsts_stride ); -#if 0 + + if (copyframe_in_use) + { free(accel_dst.Data.Y); free(accel_dst.Data.VU); -#endif + } return ret; } diff --git a/libhb/work.c b/libhb/work.c index 032d85a72..0a892c111 100644 --- a/libhb/work.c +++ b/libhb/work.c @@ -745,7 +745,7 @@ static void do_job(hb_job_t *job) /*validated*/ ||(filter->id == HB_FILTER_DEINTERLACE && is_vpp_interlace) || filter->id == HB_FILTER_DEBLOCK || filter->id == HB_FILTER_DENOISE // note: MFX_EXTBUFF_VPP_DENOISE - || filter->id == HB_FILTER_RENDER_SUB +/*validated*/ // || filter->id == HB_FILTER_RENDER_SUB /*validated*/ // || filter->id == HB_FILTER_ROTATE // validated, note : it makes sense to have more local to Video Memory, OpenCL as an example || (filter->id == HB_FILTER_QSV && !is_additional_vpp_function ) ){ @@ -766,7 +766,7 @@ static void do_job(hb_job_t *job) if( check_filter->id > HB_FILTER_QSV_PRE && check_filter->id < HB_FILTER_QSV_POST && // if original filter used - we need to wrap them into QSV pipeline ((check_filter->id == HB_FILTER_DEINTERLACE && !is_vpp_interlace) || - check_filter->id == HB_FILTER_ROTATE ) ) + check_filter->id == HB_FILTER_ROTATE || check_filter->id == HB_FILTER_RENDER_SUB) ) { to_use = 1; break;