TCGlob *tc_glob_open(const char *pattern, uint32_t flags) { TCGlob *tcg = NULL; flags = GLOB_ERR; /* flags intentionally overridden */ if (pattern != NULL && strlen(pattern) > 0) { tcg = tc_malloc(sizeof(TCGlob)); if (tcg != NULL) { int err = 0; tcg->pattern = NULL; err = glob(pattern, flags, NULL, &(tcg->glob)); switch (err) { case GLOB_NOMATCH: tcg->pattern = tc_strdup(pattern); // XXX tcg->current = -1; break; case GLOB_NOERROR: tcg->current = 0; break; default: /* any other error: clean it up */ tc_log_error(__FILE__, "internal glob failed (code=%i)", err); tc_free(tcg); tcg = NULL; } } } return tcg; }
static int astat_configure(TCModuleInstance *self, const char *options, vob_t *vob) { AStatPrivateData *pd = NULL; TC_MODULE_SELF_CHECK(self, "configure"); pd = self->userdata; /* re-enforce defaults */ pd->min = 0; pd->max = 0; pd->filepath = NULL; pd->silence_limit = SILENCE_MAX_VALUE; if (options) { char buf[1024]; int ret = optstr_get(options, "file", "%[^:]", buf); // XXX if (ret > 0) { pd->filepath = tc_strdup(buf); if (pd->filepath == NULL) { return TC_ERROR; } if (verbose) { tc_log_info(MOD_NAME, "saving audio scale value to '%s'", pd->filepath); } } optstr_get(options, "silence_limit", "%u", &pd->silence_limit); if (verbose) { tc_log_info(MOD_NAME, "silence threshold value: %i", pd->silence_limit); } } return TC_OK; }
/** * transform_configure: Configure this instance of the module. See * tcmodule-data.h for function details. */ static int transform_configure(TCModuleInstance *self, const char *options, vob_t *vob) { FilterData *fd = NULL; char* filenamecopy, *filebasename; FILE* f; TC_MODULE_SELF_CHECK(self, "configure"); fd = self->userdata; VSTransformData* td = &(fd->td); fd->vob = vob; if (!fd->vob) return TC_ERROR; /* cannot happen */ /**** Initialise private data structure */ VSFrameInfo fi_src; VSFrameInfo fi_dest; vsFrameInfoInit(&fi_src, fd->vob->ex_v_width, fd->vob->ex_v_height, transcode2ourPF(fd->vob->im_v_codec)); vsFrameInfoInit(&fi_dest, fd->vob->ex_v_width, fd->vob->ex_v_height, transcode2ourPF(fd->vob->im_v_codec)); VSTransformConfig conf = vsTransformGetDefaultConfig(MOD_NAME); conf.verbose = verbose; fd->sharpen = 0.8; vsTransformationsInit(&fd->trans); filenamecopy = tc_strdup(fd->vob->video_in_file); filebasename = basename(filenamecopy); if (strlen(filebasename) < TC_BUF_LINE - 4) { tc_snprintf(fd->input, TC_BUF_LINE, "%s.trf", filebasename); } else { tc_log_warn(MOD_NAME, "input name too long, using default `%s'", DEFAULT_TRANS_FILE_NAME); tc_snprintf(fd->input, TC_BUF_LINE, DEFAULT_TRANS_FILE_NAME); } /* process remaining options */ if (options != NULL) { // We support also the help option. if(optstr_lookup(options, "help")) { tc_log_info(MOD_NAME,vs_transform_help); return(TC_IMPORT_ERROR); } optstr_get(options, "input", "%[^:]", (char*)&fd->input); optstr_get(options, "maxshift", "%d", &conf.maxShift); optstr_get(options, "maxangle", "%lf", &conf.maxAngle); optstr_get(options, "smoothing", "%d", &conf.smoothing); optstr_get(options, "invert" , "%d", &conf.invert); optstr_get(options, "relative" , "%d", &conf.relative); optstr_get(options, "zoom" ,"%lf", &conf.zoom); optstr_get(options, "optzoom" , "%d", &conf.optZoom); optstr_get(options, "zoomspeed", "%lf",&conf.zoomSpeed); optstr_get(options, "interpol" , "%d", (int*)(&conf.interpolType)); optstr_get(options, "sharpen" ,"%lf", &fd->sharpen); if(optstr_lookup(options, "tripod")){ tc_log_info(MOD_NAME,"Virtual tripod mode: relative=False, smoothing=0"); conf.relative=0; conf.smoothing=0; } } if(vsTransformDataInit(td, &conf, &fi_src, &fi_dest) != VS_OK){ tc_log_error(MOD_NAME, "initialization of VSTransformData failed"); return TC_ERROR; } vsTransformGetConfig(&conf,td); if (verbose) { tc_log_info(MOD_NAME, "Image Transformation/Stabilization Settings:"); tc_log_info(MOD_NAME, " input = %s", fd->input); tc_log_info(MOD_NAME, " smoothing = %d", conf.smoothing); tc_log_info(MOD_NAME, " maxshift = %d", conf.maxShift); tc_log_info(MOD_NAME, " maxangle = %f", conf.maxAngle); tc_log_info(MOD_NAME, " crop = %s", conf.crop ? "Black" : "Keep"); tc_log_info(MOD_NAME, " relative = %s", conf.relative ? "True": "False"); tc_log_info(MOD_NAME, " invert = %s", conf.invert ? "True" : "False"); tc_log_info(MOD_NAME, " zoom = %f", conf.zoom); tc_log_info(MOD_NAME, " optzoom = %d", conf.optZoom); if(conf.optZoom==2){ tc_log_info(MOD_NAME, " zoomspeed = %f", conf.zoomSpeed); } tc_log_info(MOD_NAME, " interpol = %s", getInterpolationTypeName(conf.interpolType)); tc_log_info(MOD_NAME, " sharpen = %f", fd->sharpen); } f = fopen(fd->input, "r"); if (f == NULL) { tc_log_error(MOD_NAME, "cannot open input file %s!\n", fd->input); /* return (-1); when called using tcmodinfo this will fail */ } else { VSManyLocalMotions mlms; if(vsReadLocalMotionsFile(f,&mlms)==VS_OK){ // calculate the actual transforms from the localmotions if(vsLocalmotions2Transforms(td, &mlms,&fd->trans)!=VS_OK) tc_log_error(MOD_NAME, "calculating transformations failed!\n"); }else{ // try to read old format if (!vsReadOldTransforms(td, f, &fd->trans)) { /* read input file */ tc_log_error(MOD_NAME, "error parsing input file %s!\n", fd->input); } } } fclose(f); if (vsPreprocessTransforms(td, &fd->trans)!= VS_OK ) { tc_log_error(MOD_NAME, "error while preprocessing transforms!"); return TC_ERROR; } // sharpen is still in transcode... /* Is this the right point to add the filter? Seems to be the case.*/ if(fd->sharpen>0){ /* load unsharp filter */ char unsharp_param[256]; sprintf(unsharp_param,"luma=%f:%s:chroma=%f:%s", fd->sharpen, "luma_matrix=5x5", fd->sharpen/2, "chroma_matrix=5x5"); if (!tc_filter_add("unsharp", unsharp_param)) { tc_log_warn(MOD_NAME, "cannot load unsharp filter!"); } } return TC_OK; }
/* * deshake_configure: Configure this instance of the module. See * tcmodule-data.h for function details. */ static int deshake_configure(TCModuleInstance *self, const char *options, vob_t *vob) { DeshakeData *sd = NULL; TC_MODULE_SELF_CHECK(self, "configure"); char* filenamecopy, *filebasename; sd = self->userdata; /* sd->framesize = sd->vob->im_v_width * MAX_PLANES * sizeof(char) * 2 * sd->vob->im_v_height * 2; */ MotionDetect* md = &(sd->md); TransformData* td = &(sd->td); // init MotionDetect part VSFrameInfo fi; initFrameInfo(&fi, sd->vob->ex_v_width, sd->vob->ex_v_height, transcode2ourPF(sd->vob->im_v_codec)); if(initMotionDetect(md, &fi, MOD_NAME) != VS_OK){ tc_log_error(MOD_NAME, "initialization of Motion Detection failed"); return TC_ERROR; } sd->result = tc_malloc(TC_BUF_LINE); filenamecopy = tc_strdup(sd->vob->video_in_file); filebasename = basename(filenamecopy); if (strlen(filebasename) < TC_BUF_LINE - 4) { tc_snprintf(sd->result, TC_BUF_LINE, "%s.trf", filebasename); } else { tc_log_warn(MOD_NAME, "input name too long, using default `%s'", DEFAULT_TRANS_FILE_NAME); tc_snprintf(sd->result, TC_BUF_LINE, DEFAULT_TRANS_FILE_NAME); } // init trasform part VSFrameInfo fi_dest; initFrameInfo(&fi_dest, sd->vob->ex_v_width, sd->vob->ex_v_height, transcode2ourPF(sd->vob->im_v_codec)); if(initTransformData(td, &fi, &fi_dest, MOD_NAME) != VS_OK){ tc_log_error(MOD_NAME, "initialization of TransformData failed"); return TC_ERROR; } td->verbose=verbose; if (options != NULL) { // for some reason this plugin is called in the old fashion // (not with inspect). Anyway we support both ways of getting help. if(optstr_lookup(options, "help")) { tc_log_info(MOD_NAME,deshake_help); return(TC_IMPORT_ERROR); } optstr_get(options, "result", "%[^:]", sd->result); optstr_get(options, "shakiness", "%d", &md->shakiness); optstr_get(options, "accuracy", "%d", &md->accuracy); optstr_get(options, "stepsize", "%d", &md->stepSize); optstr_get(options, "algo", "%d", &md->algo); optstr_get(options, "mincontrast","%lf",&md->contrastThreshold); md->show = 0; optstr_get(options, "maxshift", "%d", &td->maxShift); optstr_get(options, "maxangle", "%lf", &td->maxAngle); optstr_get(options, "smoothing", "%d", &td->smoothing); optstr_get(options, "crop" , "%d", (int*)&td->crop); optstr_get(options, "zoom" , "%lf",&td->zoom); optstr_get(options, "optzoom" , "%d", &td->optZoom); optstr_get(options, "interpol" , "%d", (int*)(&td->interpolType)); optstr_get(options, "sharpen" , "%lf",&td->sharpen); td->relative=1; td->invert=0; } if(configureMotionDetect(md)!= VS_OK){ tc_log_error(MOD_NAME, "configuration of Motion Detection failed"); return TC_ERROR; } if(configureTransformData(td)!= VS_OK){ tc_log_error(MOD_NAME, "configuration of Tranform failed"); return TC_ERROR; } if (verbose) { tc_log_info(MOD_NAME, "Video Deshake Settings:"); tc_log_info(MOD_NAME, " smoothing = %d", td->smoothing); tc_log_info(MOD_NAME, " shakiness = %d", md->shakiness); tc_log_info(MOD_NAME, " accuracy = %d", md->accuracy); tc_log_info(MOD_NAME, " stepsize = %d", md->stepSize); tc_log_info(MOD_NAME, " algo = %d", md->algo); tc_log_info(MOD_NAME, " mincontrast = %f", md->contrastThreshold); tc_log_info(MOD_NAME, " show = %d", md->show); tc_log_info(MOD_NAME, " result = %s", sd->result); tc_log_info(MOD_NAME, " maxshift = %d", td->maxShift); tc_log_info(MOD_NAME, " maxangle = %f", td->maxAngle); tc_log_info(MOD_NAME, " crop = %s", td->crop ? "Black" : "Keep"); tc_log_info(MOD_NAME, " zoom = %f", td->zoom); tc_log_info(MOD_NAME, " optzoom = %s", td->optZoom ? "On" : "Off"); tc_log_info(MOD_NAME, " interpol = %s", interpolTypes[td->interpolType]); tc_log_info(MOD_NAME, " sharpen = %f", td->sharpen); } sd->avg.initialized=0; sd->f = fopen(sd->result, "w"); if (sd->f == NULL) { tc_log_error(MOD_NAME, "cannot open result file %s!\n", sd->result); return TC_ERROR; } return TC_OK; }