static void hb_qsv_filter_pre_close( hb_filter_object_t * filter ){ int i = 0; mfxStatus sts = MFX_ERR_NONE; hb_filter_private_t * pv = filter->private_data; if ( !pv ) { return; } sws_freeContext(pv->sws_context_to_nv12); sws_freeContext(pv->sws_context_from_nv12); av_qsv_context* qsv = pv->job->qsv; if(qsv && qsv->vpp_space && av_qsv_list_count(qsv->vpp_space) > 0 ){ if(pv->qsv_user && qsv->mfx_session){ sts=MFXVideoUSER_Unregister(qsv->mfx_session,0); AV_QSV_CHECK_RESULT(sts, MFX_ERR_NONE, sts); for(i=hb_list_count(pv->qsv_user);i>0;i--){ qsv_filter_t *plugin = hb_list_item(pv->qsv_user,i-1); hb_list_rem(pv->qsv_user,plugin); plugin_close(plugin); } hb_list_close(&pv->qsv_user); } // closing local stuff qsv_filter_close(qsv,AV_QSV_VPP_USER); // closing the commong stuff av_qsv_context_clean(qsv); } hb_cond_close(&pv->pre.frame_completed); hb_lock_close(&pv->pre.frame_completed_lock); hb_cond_close(&pv->post.frame_completed); hb_lock_close(&pv->post.frame_completed_lock); hb_cond_close(&pv->pre_busy.frame_completed); hb_lock_close(&pv->pre_busy.frame_completed_lock); hb_cond_close(&pv->post_busy.frame_completed); hb_lock_close(&pv->post_busy.frame_completed_lock); hb_list_close( &pv->list ); free( pv ); filter->private_data = NULL; }
/*********************************************************************** * hb_batch_init *********************************************************************** * **********************************************************************/ hb_batch_t * hb_batch_init( char * path ) { hb_batch_t * d; struct stat sb; DIR * dir; struct dirent * entry; char * filename; if ( stat( path, &sb ) ) return NULL; if ( !S_ISDIR( sb.st_mode ) ) return NULL; dir = opendir( path ); if ( dir == NULL ) return NULL; d = calloc( sizeof( hb_batch_t ), 1 ); d->list_file = hb_list_init(); while ( (entry = readdir( dir ) ) ) { filename = hb_strdup_printf( "%s" DIR_SEP_STR "%s", path, entry->d_name ); if ( stat( filename, &sb ) ) { free( filename ); continue; } if ( !S_ISREG( sb.st_mode ) ) { free( filename ); continue; } hb_list_add( d->list_file, filename ); } closedir( dir ); if ( hb_list_count( d->list_file ) == 0 ) { hb_list_close( &d->list_file ); free( d ); return NULL; } d->path = strdup( path ); return d; }
/*********************************************************************** * hb_batch_close *********************************************************************** * Closes and frees everything **********************************************************************/ void hb_batch_close( hb_batch_t ** _d ) { hb_batch_t * d = *_d; char * filename; while ( ( filename = hb_list_item( d->list_file, 0 ) ) ) { hb_list_rem( d->list_file, filename ); free( filename ); } hb_list_close( &d->list_file ); free( d->path ); free( d ); *_d = NULL; }
static void hb_opencl_devices_list_close(hb_list_t **_list) { if (_list != NULL) { hb_list_t *list = *_list; hb_opencl_device_t *device; while (list != NULL && hb_list_count(list) > 0) { if ((device = hb_list_item(list, 0)) != NULL) { hb_list_rem(list, device); free(device); } } } hb_list_close(_list); }
void encx265Close(hb_work_object_t *w) { hb_work_private_t *pv = w->private_data; if (pv->delayed_chapters != NULL) { struct chapter_s *item; while ((item = hb_list_item(pv->delayed_chapters, 0)) != NULL) { hb_list_rem(pv->delayed_chapters, item); free(item); } hb_list_close(&pv->delayed_chapters); } x265_param_free(pv->param); x265_encoder_close(pv->x265); free(pv); w->private_data = NULL; }
mfxStatus plugin_close(qsv_filter_t* plugin){ int i = 0; mfxStatus sts = MFX_ERR_NONE; if(!plugin->is_init_done) return sts; mfxExtOpaqueSurfaceAlloc* plugin_opaque_alloc = NULL; plugin_opaque_alloc = (mfxExtOpaqueSurfaceAlloc*) get_ext_buffer(plugin->videoparam->ExtParam, plugin->videoparam->NumExtParam, MFX_EXTBUFF_OPAQUE_SURFACE_ALLOCATION); if(!plugin_opaque_alloc || !plugin_opaque_alloc->In.Surfaces || !plugin_opaque_alloc->Out.Surfaces) return MFX_ERR_INVALID_VIDEO_PARAM; sts = plugin->core->UnmapOpaqueSurface(plugin->core->pthis, plugin_opaque_alloc->In.NumSurface, plugin_opaque_alloc->In.Type, plugin_opaque_alloc->In.Surfaces); AV_QSV_CHECK_RESULT(sts, MFX_ERR_NONE, sts); sts = plugin->core->UnmapOpaqueSurface(plugin->core->pthis, plugin_opaque_alloc->Out.NumSurface, plugin_opaque_alloc->Out.Type, plugin_opaque_alloc->Out.Surfaces); AV_QSV_CHECK_RESULT(sts, MFX_ERR_NONE, sts); if(plugin->tasks){ for(i=hb_list_count(plugin->tasks);i>0;i--){ qsv_filter_task_t *task = hb_list_item(plugin->tasks,i-1); hb_list_rem(plugin->tasks,task); free(task); } hb_list_close(&plugin->tasks); } plugin->is_init_done = 0; return sts; }