enum
{
- // default MSDK VPP filters
- HB_FILTER_QSV = 1,
// for QSV - important to have before other filters
- HB_FILTER_QSV_PRE,
+ HB_FILTER_QSV_PRE = 1,
// First, filters that may change the framerate (drop or dup frames)
HB_FILTER_DETELECINE,
// for QSV - important to have as a last one
HB_FILTER_QSV_POST,
+ // default MSDK VPP filter
+ HB_FILTER_QSV,
};
hb_filter_object_t * hb_filter_init( int filter_id );
received_item = NULL;
}
int sync_idx = av_qsv_get_free_sync( qsv_encode, qsv );
-
+ if (sync_idx == -1)
+ {
+ hb_error("qsv: Not enough resources allocated for QSV encode");
+ return 0;
+ }
av_qsv_task *task = av_qsv_list_item( qsv_encode->tasks, pv->async_depth );
for (;;)
memcpy(&(qsv_vpp->p_surfaces[i]->Info), &(qsv_vpp->m_mfxVideoParam.vpp.Out), sizeof(mfxFrameInfo));
}
- qsv_vpp->sync_num = FFMIN( qsv_vpp->surface_num, AV_QSV_SYNC_NUM ); // AV_QSV_SYNC_NUM;
+ qsv_vpp->sync_num = FFMIN( qsv_vpp->surface_num, AV_QSV_SYNC_NUM );
for (i = 0; i < qsv_vpp->sync_num; i++){
qsv_vpp->p_syncp[i] = av_mallocz(sizeof(av_qsv_sync));
int sync_idx = av_qsv_get_free_sync(qsv_vpp, qsv);
int surface_idx = -1;
- for(;;){
-
+ for(;;)
+ {
+ if (sync_idx == -1)
+ {
+ hb_error("qsv: Not enough resources allocated for QSV filter");
+ ret = 0;
+ break;
+ }
if( sts == MFX_ERR_MORE_SURFACE || sts == MFX_ERR_NONE )
surface_idx = av_qsv_get_free_surface(qsv_vpp, qsv, &(qsv_vpp->m_mfxVideoParam.vpp.Out), QSV_PART_ANY);
if (surface_idx == -1) {
- hb_log("qsv: Not enough resources allocated for the filter");
+ hb_error("qsv: Not enough resources allocated for QSV filter");
ret = 0;
break;
}
AV_QSV_ZERO_MEMORY(qsv_vpp->m_mfxVideoParam);
- if(prev_vpp)
+ if (prev_vpp)
+ {
memcpy( &qsv_vpp->m_mfxVideoParam.vpp, &prev_vpp->m_mfxVideoParam.vpp, sizeof(prev_vpp->m_mfxVideoParam.vpp));
- else{
+ }
+ else
+ {
AV_QSV_ZERO_MEMORY(qsv_vpp->m_mfxVideoParam);
// FrameRate is important for VPP to start with
qsv_vpp->m_mfxVideoParam.IOPattern = MFX_IOPATTERN_IN_OPAQUE_MEMORY | MFX_IOPATTERN_OUT_OPAQUE_MEMORY;
- qsv_vpp->surface_num = FFMIN(prev_vpp? prev_vpp->surface_num : qsv->dec_space->surface_num/2, AV_QSV_SURFACE_NUM );
+ qsv_vpp->surface_num = FFMIN(prev_vpp ? prev_vpp->surface_num : qsv->dec_space->surface_num/2, AV_QSV_SURFACE_NUM);
for(i = 0; i < qsv_vpp->surface_num; i++){
qsv_vpp->p_surfaces[i] = av_mallocz( sizeof(mfxFrameSurface1) );
memcpy(&(qsv_vpp->p_surfaces[i]->Info), &(qsv_vpp->m_mfxVideoParam.vpp.Out), sizeof(mfxFrameInfo));
}
- qsv_vpp->sync_num = FFMIN(prev_vpp? prev_vpp->sync_num : qsv->dec_space->sync_num/2, AV_QSV_SYNC_NUM );
+ qsv_vpp->sync_num = FFMIN(prev_vpp ? prev_vpp->sync_num : qsv->dec_space->sync_num, AV_QSV_SYNC_NUM);
for (i = 0; i < qsv_vpp->sync_num; i++){
qsv_vpp->p_syncp[i] = av_mallocz(sizeof(av_qsv_sync));
AV_QSV_CHECK_POINTER(qsv_vpp->p_syncp[i], MFX_ERR_MEMORY_ALLOC);
// PIX_FMT_YUV420P, ///< planar YUV 4:2:0, 12bpp, (1 Cr & Cb sample per 2x2 Y samples) , 3 planes: Y, U, V
// PIX_FMT_NV12, ///< planar YUV 4:2:0, 12bpp, 1 plane for Y and 1 plane for the UV components, which are interleaved (first byte U and the following byte V)
pv->sws_context_from_nv12 = hb_sws_get_context(
- pv->job->width, pv->job->height, AV_PIX_FMT_NV12,
- pv->job->width, pv->job->height, AV_PIX_FMT_YUV420P,
+ pv->job->title->width, pv->job->title->height, AV_PIX_FMT_NV12,
+ pv->job->title->width, pv->job->title->height, AV_PIX_FMT_YUV420P,
SWS_LANCZOS|SWS_ACCURATE_RND);
pv->sws_context_to_nv12 = hb_sws_get_context(
- pv->job->width, pv->job->height, AV_PIX_FMT_YUV420P,
- pv->job->width, pv->job->height, AV_PIX_FMT_NV12,
+ pv->job->title->width, pv->job->title->height, AV_PIX_FMT_YUV420P,
+ pv->job->title->width, pv->job->title->height, AV_PIX_FMT_NV12,
SWS_LANCZOS|SWS_ACCURATE_RND);
-
return 0;
}
int pre_process_frame(hb_buffer_t *in, av_qsv_context* qsv, hb_filter_private_t * pv ){
av_qsv_space *qsv_vpp = pv->vpp_space;
- if(received_item){
+ if (received_item)
+ {
stage = av_qsv_get_last_stage( received_item );
work_surface = stage->out.p_surface;
}
for (;;)
{
- if( sts == MFX_ERR_MORE_SURFACE || sts == MFX_ERR_NONE )
+ if (sync_idx == -1)
+ {
+ hb_error("qsv: Not enough resources allocated for the preprocessing filter");
+ ret = 0;
+ break;
+ }
+
+ if (sts == MFX_ERR_MORE_SURFACE || sts == MFX_ERR_NONE)
surface_idx = av_qsv_get_free_surface(qsv_vpp, qsv, &(qsv_vpp->m_mfxVideoParam.vpp.Out), QSV_PART_ANY);
if (surface_idx == -1) {
- hb_log("qsv: Not enough resources allocated for the filter");
+ hb_error("qsv: Not enough resources allocated for the preprocessing filter");
ret = 0;
break;
}
sts = MFXVideoUSER_ProcessFrameAsync(qsv->mfx_session, &work_surface, 1, &qsv_vpp->p_surfaces[surface_idx] , 1, qsv_vpp->p_syncp[sync_idx]->p_sync);
- if( MFX_ERR_MORE_DATA == sts ){
- if(!qsv_vpp->pending){
+ if (MFX_ERR_MORE_DATA == sts)
+ {
+ if (!qsv_vpp->pending)
+ {
qsv_vpp->pending = av_qsv_list_init(0);
}
#include "hbffmpeg.h"
#include "qsv_memory.h"
-
int qsv_nv12_to_yuv420(struct SwsContext* sws_context,hb_buffer_t* dst, mfxFrameSurface1* src, mfxCoreInterface *core){
int ret = 0;
int i,j;
- int in_pitch = src->Data.Pitch;
- int h = src->Info.CropH;
- int w = src->Info.CropW;
- uint8_t *in_luma = 0;
- uint8_t *in_chroma = 0;
+ int in_pitch = src->Data.Pitch;
+ int w = AV_QSV_ALIGN16(src->Info.Width);
+ int h = (MFX_PICSTRUCT_PROGRESSIVE == src->Info.PicStruct) ? AV_QSV_ALIGN16(src->Info.Height) : AV_QSV_ALIGN32(src->Info.Height);
+ uint8_t *in_luma = 0;
+ uint8_t *in_chroma = 0;
static int copyframe_in_use = 1;
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;
- accel_dst.Info.CropY = src->Info.CropY;
- accel_dst.Info.CropX = src->Info.CropX;
- accel_dst.Info.Width = src->Info.Width;
- accel_dst.Info.Height = src->Info.Height;
- accel_dst.Data.Pitch = src->Data.Pitch;
- accel_dst.Data.Y = calloc( 1, in_pitch*h );
- accel_dst.Data.VU = calloc( 1, in_pitch*h/2 );
-
- sts = core->CopyFrame(core->pthis, &accel_dst, src );
+ accel_dst.Info.FourCC = src->Info.FourCC;
+ accel_dst.Info.CropH = src->Info.CropH;
+ accel_dst.Info.CropW = src->Info.CropW;
+ accel_dst.Info.CropY = src->Info.CropY;
+ accel_dst.Info.CropX = src->Info.CropX;
+ accel_dst.Info.Width = w;
+ accel_dst.Info.Height = h;
+ accel_dst.Data.Pitch = src->Data.Pitch;
+ accel_dst.Data.Y = calloc( 1, in_pitch*h );
+ accel_dst.Data.VU = calloc( 1, in_pitch*h/2 );
+
+ sts = core->CopyFrame(core->pthis, &accel_dst, src);
+
if (sts < MFX_ERR_NONE)
{
free(accel_dst.Data.Y);
hb_video_buffer_realloc( dst, w, h );
- uint8_t *srcs[] = { in_luma, in_chroma };
+ uint8_t *srcs[] = { in_luma, in_chroma };
int srcs_stride[] = { in_pitch, in_pitch };
- uint8_t *dsts[] = { dst->plane[0].data, dst->plane[1].data, dst->plane[2].data };
+ 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 };
ret = sws_scale(sws_context, srcs, srcs_stride, 0, h, dsts, dsts_stride );
if (copyframe_in_use)
{
- free(accel_dst.Data.Y);
- free(accel_dst.Data.VU);
+ free(accel_dst.Data.Y);
+ free(accel_dst.Data.VU);
}
return ret;
int w = src->plane[0].width;
int h = src->plane[0].height;
- int out_pitch = dst->Data.Pitch;
- uint8_t *out_luma = dst->Data.Y;
+ int out_pitch = dst->Data.Pitch;
+ uint8_t *out_luma = dst->Data.Y;
uint8_t *out_chroma = dst->Data.VU;
- uint8_t *srcs[] = { src->plane[0].data, src->plane[1].data, src->plane[2].data };
- int srcs_stride[] = { src->plane[0].stride, src->plane[1].stride, src->plane[2].stride };
+ uint8_t *srcs[] = { src->plane[0].data, src->plane[1].data, src->plane[2].data };
+ int srcs_stride[] = { src->plane[0].stride, src->plane[1].stride, src->plane[2].stride };
- uint8_t *dsts[] = { out_luma, out_chroma };
- int dsts_stride[] = { out_pitch, out_pitch };
+ uint8_t *dsts[] = { out_luma, out_chroma };
+ int dsts_stride[] = { out_pitch, out_pitch };
ret = sws_scale(sws_context, srcs, srcs_stride, 0, h, dsts, dsts_stride );