static int fields_inspect(TCModuleInstance *self, const char *param, const char **value) { FieldsPrivateData *pd = NULL; TC_MODULE_SELF_CHECK(self, "inspect"); TC_MODULE_SELF_CHECK(param, "inspect"); pd = self->userdata; if (optstr_lookup(param, "help")) { *value = fields_help; } if (optstr_lookup(param, "flip")) { tc_snprintf(pd->conf_str, sizeof(pd->conf_str), "%s", (pd->field_ops & FIELD_OP_FLIP) ?"yes" :"no"); *value = pd->conf_str; } if (optstr_lookup(param, "shift")) { tc_snprintf(pd->conf_str, sizeof(pd->conf_str), "%s", (pd->field_ops & FIELD_OP_SHIFT) ?"yes" :"no"); *value = pd->conf_str; } if (optstr_lookup(param, "flip_first")) { tc_snprintf(pd->conf_str, sizeof(pd->conf_str), "%s", (pd->field_ops & FIELD_OP_REVERSE) ?"yes" :"no"); *value = pd->conf_str; } return TC_OK; }
int tc_format_description(TCFormatID format, char *buf, size_t bufsize) { char storage[TC_BUF_MIN] = { '\0' }; int idx = find_tc_format(tc_formats_info, id_matcher, &format); int ret, flags = 0; if (idx == TC_NULL_MATCH) { /* not found */ strlcpy(buf, "unknwon", bufsize); return -1; } flags = tc_formats_info[idx].flags; tc_snprintf(storage, sizeof(storage), "%s%s|%s|%s%s", (flags ) ?"(" :"", (flags & TC_VIDEO) ?"video" :"", (flags & TC_AUDIO) ?"audio" :"", (flags & TC_EXTRA) ?"extra" :"", (flags ) ?")" :""); ret = tc_snprintf(buf, bufsize, "%-12s: %-20s %s", tc_formats_info[idx].name, storage, tc_formats_info[idx].comment); return ret; }
static int astat_inspect(TCModuleInstance *self, const char *param, const char **value) { AStatPrivateData *pd = NULL; TC_MODULE_SELF_CHECK(self, "inspect"); TC_MODULE_SELF_CHECK(param, "inspect"); TC_MODULE_SELF_CHECK(value, "inspect"); pd = self->userdata; if (optstr_lookup(param, "help")) { *value = help_string; } if (optstr_lookup(param, "file")) { if (pd->filepath == NULL) { *value = "None"; } else { tc_snprintf(pd->optstr_buf, sizeof(pd->optstr_buf), "%s", pd->filepath); *value = pd->optstr_buf; } } if (optstr_lookup(param, "silence_limit")) { tc_snprintf(pd->optstr_buf, sizeof(pd->optstr_buf), "%i", pd->silence_limit); *value = pd->optstr_buf; } return TC_OK; }
static int vag_inspect(TCModuleInstance *self, const char *param, const char **value) { PrivateData *pd = NULL; static char buf[TC_BUF_MAX]; TC_MODULE_SELF_CHECK(self, "inspect"); TC_MODULE_SELF_CHECK(param, "inspect"); TC_MODULE_SELF_CHECK(value, "inspect"); pd = self->userdata; if (optstr_lookup(param, "help")) { tc_snprintf(buf, sizeof(buf), "Overview:\n" " Decodes PlayStation VAG format (ADPCM-style) audio.\n" "Options available:\n" " blocksize=N Set stereo blocking size (16-%d, default %d)\n", MAX_STEREO_BLOCK, DEF_STEREO_BLOCK); *value = buf; return TC_IMPORT_OK; } if (optstr_lookup(param, "blocksize")) { tc_snprintf(buf, sizeof(buf), "%d", pd->blocksize); *value = buf; return TC_IMPORT_OK; } return TC_IMPORT_OK; }
static int doublefps_inspect(TCModuleInstance *self, const char *param, const char **value) { DfpsPrivateData *pd = NULL; static char buf[TC_BUF_MAX]; TC_MODULE_SELF_CHECK(self, "inspect"); TC_MODULE_SELF_CHECK(param, "inspect"); TC_MODULE_SELF_CHECK(value, "inspect"); pd = self->userdata; if (optstr_lookup(param, "help")) { *value = "Overview:\n" "\n" " Doubles the frame rate of interlaced video by separating each field\n" " into a separate frame. The fields can either be left as is (giving a\n" " progessive video with half the height of the original) or re-interlaced\n" " into their original height (at the doubled frame rate) for the\n" " application of a separate deinterlacing filter.\n" "\n" " Note that due to transcode limitations, it is currently necessary to\n" " use the -Z option to specify the output frame size when using\n" " half-height mode (this does not slow the program down if no actual\n" " zooming is done).\n" "\n" " When using this filter in half-height mode, make sure you specify\n" " \"--encode_fields p\" on the transcode command line, and do not use the\n" " \"-I\" option.\n" "\n" "Options available:\n" "\n" " topfirst=0|1 Selects whether the top field is the first displayed.\n" " Defaults to 0 (bottom-first) for 480-line video, 1\n" " (top-first) otherwise.\n" "\n" " fullheight=0|1 Selects whether or not to retain full height when\n" " doubling the frame rate. If this is set to 1, the\n" " resulting video will have the same frame size as the\n" " original at double the frame rate, and the frames will\n" " consist of fields 0 and 1, 1 and 2, 2 and 3, and so\n" " forth. This can be used to let a separate filter\n" " perform deinterlacing on the double-rate frames; note\n" " that the filter must be able to deal with the top and\n" " bottom fields switching with each frame.\n" " Note that this option cannot be changed after startup.\n" ; } if (optstr_lookup(param, "topfirst")) { tc_snprintf(buf, sizeof(buf), "%d", pd->topfirst); *value = buf; } if (optstr_lookup(param, "fullheight")) { tc_snprintf(buf, sizeof(buf), "%d", pd->fullheight); *value = buf; } return TC_OK; }
static int raw_configure(TCModuleInstance *self, const char *options, vob_t *vob) { char vid_name[PATH_MAX]; char aud_name[PATH_MAX]; RawPrivateData *pd = NULL; TC_MODULE_SELF_CHECK(self, "configure"); pd = self->userdata; // XXX if (vob->audio_out_file == NULL || !strcmp(vob->audio_out_file, "/dev/null")) { /* use affine names */ tc_snprintf(vid_name, PATH_MAX, "%s.%s", vob->video_out_file, RAW_VID_EXT); tc_snprintf(aud_name, PATH_MAX, "%s.%s", vob->video_out_file, RAW_AUD_EXT); } else { /* copy names verbatim */ strlcpy(vid_name, vob->video_out_file, PATH_MAX); strlcpy(aud_name, vob->audio_out_file, PATH_MAX); } /* avoid fd loss in case of failed configuration */ if (pd->fd_vid == -1) { pd->fd_vid = open(vid_name, O_RDWR|O_CREAT|O_TRUNC, S_IRUSR|S_IWUSR|S_IRGRP|S_IROTH); if (pd->fd_vid == -1) { tc_log_error(MOD_NAME, "failed to open video stream file"); return TC_ERROR; } } /* avoid fd loss in case of failed configuration */ if (pd->fd_aud == -1) { pd->fd_aud = open(aud_name, O_RDWR|O_CREAT|O_TRUNC, S_IRUSR|S_IWUSR|S_IRGRP|S_IROTH); if (pd->fd_aud == -1) { tc_log_error(MOD_NAME, "failed to open audio stream file"); return TC_ERROR; } } if (vob->verbose >= TC_DEBUG) { tc_log_info(MOD_NAME, "video output: %s (%s)", vid_name, (pd->fd_vid == -1) ?"FAILED" :"OK"); tc_log_info(MOD_NAME, "audio output: %s (%s)", aud_name, (pd->fd_aud == -1) ?"FAILED" :"OK"); } return TC_OK; }
int tc_socket_init(const char *socket_path_) { struct sockaddr_un server_addr; client_sock = -1; server_sock = -1; tc_mutex_init(&tc_socket_msg_lock); if (tc_snprintf(socket_path, sizeof(socket_path), "%s", socket_path_) < 0){ tc_log_error(__FILE__, "Socket pathname too long (1)"); *socket_path = 0; return 0; } errno = 0; if (unlink(socket_path) != 0 && errno != ENOENT) { tc_log_error(__FILE__, "Unable to remove \"%s\": %s", socket_path, strerror(errno)); return 0; } server_addr.sun_family = AF_UNIX; if (tc_snprintf(server_addr.sun_path, sizeof(server_addr.sun_path), "%s", socket_path) < 0 ) { tc_log_error(__FILE__, "Socket pathname too long"); return 0; } server_sock = socket(AF_UNIX, SOCK_STREAM, 0); if (server_sock < 0) { tc_log_perror(__FILE__, "Unable to create server socket"); return 0; } if (bind(server_sock, (struct sockaddr *)&server_addr, sizeof(server_addr)) ) { tc_log_perror(__FILE__, "Unable to bind server socket"); close(server_sock); server_sock = -1; unlink(socket_path); // just in case return 0; } if (listen(server_sock, 5) < 0) { tc_log_perror(__FILE__, "Unable to activate server socket"); close(server_sock); unlink(socket_path); return 0; } return 1; }
METHOD int pvn_configure(TCModuleInstance *self, const char *options, vob_t *vob) { PrivateData *pd = NULL; char buf[TC_BUF_MAX]; int len; TC_MODULE_SELF_CHECK(self, "configure"); pd->width = vob->ex_v_width; pd->height = vob->ex_v_height; /* FIXME: stdout should be handled in a more standard fashion */ if (strcmp(vob->video_out_file, "-") == 0) { // allow /dev/stdout too? pd->fd = 1; } else { pd->fd = open(vob->video_out_file, O_WRONLY | O_CREAT | O_TRUNC, 0666); if (pd->fd < 0) { tc_log_error(MOD_NAME, "Unable to open %s: %s", vob->video_out_file, strerror(errno)); goto fail; } } len = tc_snprintf(buf, sizeof(buf), "PV%da\r\n%d %d\r\n", vob->decolor ? 5 : 6, pd->width, pd->height); if (len < 0) goto fail; if (tc_pwrite(pd->fd, buf, len) != len) { tc_log_error(MOD_NAME, "Unable to write header to %s: %s", vob->video_out_file, strerror(errno)); goto fail; } pd->framecount_pos = lseek(pd->fd, 0, SEEK_CUR); // failure okay len = tc_snprintf(buf, sizeof(buf), "%10d\r\n8\r\n%lf\r\n", 0, (double)vob->ex_fps); if (len < 0) goto fail; if (tc_pwrite(pd->fd, buf, len) != len) { tc_log_error(MOD_NAME, "Unable to write header to %s: %s", vob->video_out_file, strerror(errno)); goto fail; } return TC_OK; fail: pvn_stop(self); return TC_ERROR; }
static int tc_log_console_send(TCLogContext *ctx, TCLogType type, const char *tag, const char *fmt, va_list ap) { int is_dynbuf = TC_FALSE, truncated = TC_FALSE; /* flag: we must use a dynamic (larger than static) buffer? */ char buf[TC_LOG_BUF_SIZE]; char *msg = buf; size_t size = sizeof(buf); const char *templ = NULL; /* sanity check, avoid {under,over}flow; */ type = TC_CLAMP(type, TC_LOG_ERR, TC_LOG_MARK); /* sanity check, avoid dealing with NULL as much as we can */ if (!ctx->use_colors && type != TC_LOG_MARK) { type = TC_LOG_MSG; } tag = (tag != NULL) ?tag :""; fmt = (fmt != NULL) ?fmt :""; /* TC_LOG_EXTRA special handling: force always empty tag */ tag = (type == TC_LOG_MARK) ?"" :tag; templ = log_template(type); size = strlen(templ) + strlen(tag) + strlen(fmt) + 1; if (size > sizeof(buf)) { /* * we use malloc/fprintf instead of tc_malloc because * we want custom error messages */ msg = malloc(size); if (msg != NULL) { is_dynbuf = TC_TRUE; } else { fprintf(stderr, "(%s) CRITICAL: can't get memory in " "tc_log() output will be truncated.\n", __FILE__); /* force reset to default values */ msg = buf; size = sizeof(buf) - 1; truncated = TC_TRUE; } } else { size = sizeof(buf) - 1; } /* construct real format string */ tc_snprintf(msg, size, templ, tag, fmt); vfprintf(ctx->f, msg, ap); if (is_dynbuf) { free(msg); } /* ensure that all *other* messages are written */ /* we don't (yet) honor the flush_threshold */ fflush(ctx->f); return (truncated) ?-1 :0; }
static int a52_do_init(char *path) { const char *error; tc_snprintf(module, sizeof(module), "%s/%s", path, MODULE); if(verbose & TC_DEBUG) tc_log_msg(__FILE__, "loading external module %s", module); // try transcode's module directory handle = dlopen(module, RTLD_NOW); if (!handle) { //try the default: // handle = dlopen(MODULE, RTLD_GLOBAL| RTLD_LAZY); if (!handle) { error = dlerror(); fputs (error, stderr); fputs("\n", stderr); return -1; } } p_a52_decore = dlsym(handle, "a52_decore"); error = dlerror(); if (error != NULL) { fputs(error, stderr); fputs("\n", stderr); return -1; } return 0; }
static int y4m_write_stream_header2(FILE *fd, y4m_stream_info_t *i) { char s[Y4M_LINE_MAX+1]; int n; int err; y4m_ratio_t tmpframerate = y4m_si_get_framerate(i); y4m_ratio_t tmpsamplerate = y4m_si_get_sampleaspect(i); y4m_ratio_reduce(&tmpframerate); y4m_ratio_reduce(&tmpsamplerate); n = tc_snprintf(s, sizeof(s), "%s W%d H%d F%d:%d I%s A%d:%d", Y4M_MAGIC, y4m_si_get_width(i), y4m_si_get_height(i), y4m_si_get_framerate(i).n, y4m_si_get_framerate(i).d, (y4m_si_get_interlace(i) == Y4M_ILACE_NONE) ? "p" : (y4m_si_get_interlace(i) == Y4M_ILACE_TOP_FIRST) ? "t" : (y4m_si_get_interlace(i) == Y4M_ILACE_BOTTOM_FIRST) ? "b" : "?", y4m_si_get_sampleaspect(i).n, y4m_si_get_sampleaspect(i).d); if (n < 0) return Y4M_ERR_HEADER; if ((err = y4m_snprint_xtags(s + n, sizeof(s) - n - 1, y4m_si_xtags(i))) != Y4M_OK) return err; /* zero on error */ return (fwrite(s, strlen(s), 1, fd) ? Y4M_OK : Y4M_ERR_SYSTEM); }
static int modrequest_scan(const char *modpath, const char *modstr, glob_t *globbuf) { char path_model[PATH_MAX]; char buf[TC_BUF_MIN]; const char *pc = NULL; int err = 0; pc = strchr(modstr, ':'); if (pc == NULL) { return 1; } if ((pc - modstr + 1) > sizeof(buf)) { return 2; /* XXX watch out here */ } strlcpy(buf, modstr, pc - modstr + 1); tc_snprintf(path_model, sizeof(path_model), "%s/%s_*.so", modpath, buf); err = glob(path_model, GLOB_ERR, NULL, globbuf); if (err) { tc_log_error(EXE, "error while scanning for modules: %s", (err == GLOB_NOSPACE) ?"can't get enough memory" : (err == GLOB_ABORTED) ?"read error" : /* GLOB_NOMATCH */ "no modules found"); return -1; } return 0; }
static int write_tmpfile(char* header, char* content, int content_size, int slot_id){ FILE* tmp = NULL; int i = 0; char* filename = NULL; filename = tc_malloc(sizeof(char)*(strlen(TMP_FILE) + TMP_STRING_SIZE)); if (!filename){ tc_log_error(MOD_NAME, "Out of memory !!!"); return -1; } if (verbose & TC_DEBUG) tc_log_info(MOD_NAME, "Temporary filename correctly allocated."); tc_snprintf(filename, strlen(TMP_FILE) + TMP_STRING_SIZE, "%s-%d.tmp", TMP_FILE, slot_id); tmp = fopen(filename, "w"); if (!tmp){ tc_log_error(MOD_NAME, "Cannot write temporary file !"); return -1; } for(i=0; i<strlen(header); i++) fputc(header[i], tmp); for(i=0; i< content_size; i++) fputc(content[i], tmp); fclose(tmp); free(filename); return 0; }
static int aart_render(char* buffer, int width, int height, int slot_id, char* font, char* pallete, int threads, int buffer_option){ char pnm_header[255] = "", cmd_line[MAX_LENGTH] = "", buffer_option_string[PATH_MAX] = ""; FILE* aart_output = NULL; int i = 0, j = 0, resize = 0; if (verbose & TC_DEBUG) tc_log_info(MOD_NAME, "Formating buffer option string."); if (buffer_option != 1) tc_snprintf(buffer_option_string, strlen("--nobuffer"), "--nobuffer"); if (verbose & TC_DEBUG) tc_log_info(MOD_NAME, "Buffer option string correctly formated."); tc_snprintf(cmd_line, MAX_LENGTH, "aart %s-%d.tmp --font %s --pallete %s --inmod=pnm --outmod=pnm %s --threads=%d", TMP_FILE, slot_id, font, pallete, buffer_option_string, threads); tc_snprintf(pnm_header, 255, "P6\n%d %d\n255\n", width, height); if (write_tmpfile(pnm_header, buffer, width*height*3, slot_id) == -1) return -1; if (!(aart_output = popen(cmd_line, "r"))){ tc_log_error(MOD_NAME, "`aart` call failure !"); return -1; } resize = parse_stream_header(aart_output, width); /* Now, let's fill the buffer */ for (i=0; i<=(width*height*3); i++){ if (j == width*3){ /* We reached an end of row and skip aart additionnal pixels */ for (j=0; j< 3*(resize - width); j++) fgetc(aart_output); j = 0; } buffer[i] = fgetc(aart_output); j++; } pclose(aart_output); return 0; }
static int yw_configure(TCModuleInstance *self, const char *options, vob_t *vob) { char vid_name[PATH_MAX]; char aud_name[PATH_MAX]; YWPrivateData *pd = NULL; int ret; TC_MODULE_SELF_CHECK(self, "configure"); pd = self->userdata; if (vob->audio_out_file == NULL || !strcmp(vob->audio_out_file, "/dev/null")) { /* use affine names */ tc_snprintf(vid_name, PATH_MAX, "%s.%s", vob->video_out_file, YW_VID_EXT); tc_snprintf(aud_name, PATH_MAX, "%s.%s", vob->video_out_file, YW_AUD_EXT); } else { /* copy names verbatim */ strlcpy(vid_name, vob->video_out_file, PATH_MAX); strlcpy(aud_name, vob->audio_out_file, PATH_MAX); } pd->width = vob->ex_v_width; pd->height = vob->ex_v_height; ret = yw_open_video(pd, vid_name, vob); if (ret != TC_OK) { return ret; } ret = yw_open_audio(pd, aud_name, vob); if (ret != TC_OK) { return ret; } if (vob->verbose >= TC_DEBUG) { tc_log_info(MOD_NAME, "video output: %s (%s)", vid_name, (pd->fd_vid == -1) ?"FAILED" :"OK"); tc_log_info(MOD_NAME, "audio output: %s (%s)", aud_name, (pd->wav == NULL) ?"FAILED" :"OK"); } return TC_OK; }
int f_system_merge(pvm_config_env *p_pvm_conf) { pvm_config_filelist *p_video_list=NULL,*p_audio_list=NULL; char s_buffer[MAX_BUF],*p_par=NULL; int s_file_dest=-1,s_count=0; if (p_pvm_conf->s_build_intermed_file==0) { if ((s_file_dest=creat(p_pvm_conf->s_sys_list.p_destination,S_IWUSR|S_IRUSR|S_IRGRP|S_IROTH))==-1) { fprintf(stderr,"(%s) can't create %s output file.\n",__FILE__,p_pvm_conf->s_sys_list.p_destination); pvm_parser_close(); p_pvm_conf=NULL; return(1); } } for (p_video_list=p_pvm_conf->p_add_list;((p_video_list->s_type==TC_AUDIO)&&(p_video_list!=NULL));p_video_list=p_video_list->p_next); for (p_audio_list=p_pvm_conf->p_add_list;((p_audio_list->s_type==TC_VIDEO)&&(p_audio_list!=NULL));p_audio_list=p_audio_list->p_next); if (p_video_list==NULL) { fprintf(stderr,"(%s) request a system merge without video list inside %s .\n",__FILE__,p_out_file_name); return(1); } else if (p_audio_list==NULL) { fprintf(stderr,"(%s) request a system merge without audio list inside %s .\n",__FILE__,p_out_file_name); return(1); } p_par=strtok(p_pvm_conf->p_multiplex_cmd,"\""); while ((p_video_list!=NULL)&&(p_audio_list!=NULL)) { memset(s_buffer,'\0',sizeof(s_buffer)); tc_snprintf(s_buffer,sizeof(s_buffer),"%s-%06d",p_pvm_conf->s_sys_list.p_destination,s_count++); if (f_multiplexer(p_pvm_conf->s_sys_list.p_codec,p_par,p_video_list->p_filename,p_audio_list->p_filename,s_buffer,verbose)) { fprintf(stderr,"(%s) unsupported codec %s.\n",__FILE__,p_merge_cmd); return(1); } remove(p_video_list->p_filename); remove(p_audio_list->p_filename); if (p_pvm_conf->s_build_intermed_file==0) { if (verbose & TC_DEBUG) fprintf(stderr,"(%s) multiplex audio %s and video %s into %s\n",__FILE__,p_audio_list->p_filename,p_video_list->p_filename,s_buffer); if(f_copy_remove_func("open",s_buffer,s_file_dest)) return(1); if (verbose & TC_DEBUG) fprintf(stderr,"(%s) merge into %s and remove file %s\n",__FILE__,p_pvm_conf->s_sys_list.p_destination,s_buffer); } p_video_list=p_video_list->p_next; p_audio_list=p_audio_list->p_next; } if (p_pvm_conf->s_build_intermed_file==0) close(s_file_dest); return(0); }
static int do_probe(const char *file, const char *nav_seek_file, int title, int range, int mplayer_flag, int verbose_flag, ProbeInfo *info_ret) { TCSession *session = tc_get_session(); char cmdbuf[PATH_MAX+1000]; FILE *pipe; if (mplayer_flag) { if (tc_snprintf(cmdbuf, sizeof(cmdbuf), "%s -B -M -i \"%s\" -d %d", TCPROBE_EXE, file, verbose_flag) < 0) return 0; } else { if (tc_snprintf(cmdbuf, sizeof(cmdbuf), "%s -B -i \"%s\" -T %d -H %d -d %d", TCPROBE_EXE, file, title, range, verbose_flag) < 0) return 0; if (nav_seek_file && tc_snprintf(cmdbuf+strlen(cmdbuf), sizeof(cmdbuf)-strlen(cmdbuf), " -f \"%s\"", nav_seek_file) < 0) return 0; } pipe = popen(cmdbuf, "r"); if (!pipe) return 0; if (fread(&session->tc_probe_pid, sizeof(pid_t), 1, pipe) != 1) { pclose(pipe); return 0; } if (fread(info_ret, sizeof(*info_ret), 1, pipe) != 1) { pclose(pipe); return 0; } pclose(pipe); return 1; }
static int doublefps_get_config(TCModuleInstance *self, char *options) { DfpsPrivateData *pd = NULL; char buf[TC_BUF_MIN]; TC_MODULE_SELF_CHECK(self, "get_config"); pd = self->userdata; optstr_filter_desc(options, MOD_NAME, MOD_CAP, MOD_VERSION, MOD_AUTHOR, "VAEY4", "1"); tc_snprintf(buf, sizeof(buf), "%i", pd->topfirst); optstr_param(options, "topfirst", "select if top first is first displayed or not", "%d", buf, "0", "1"); tc_snprintf(buf, sizeof(buf), "%i", pd->fullheight); optstr_param(options, "fullheight", "select if full height must be retained when doubling fps", "%d", buf, "0", "1"); return TC_OK; }
static int divx5_init(const char *path) { const char *error; int *quiet_encore; tc_snprintf(module, sizeof(module), "%s/%s", path, MODULE); // try transcode's module directory handle = dlopen(module, RTLD_NOW); if (!handle) { //try the default: handle = dlopen(MODULE, RTLD_GLOBAL| RTLD_LAZY); if (!handle) { tc_log_warn(MOD_NAME, "%s", dlerror()); return(-1); } else { if(verbose_flag & TC_DEBUG) tc_log_info(MOD_NAME, "Loading external codec module %s", MODULE); } } else { if(verbose_flag & TC_DEBUG) tc_log_info(MOD_NAME, "Loading external codec module %s", module); } divx5_encore = dlsym(handle, "encore"); if ((error = dlerror()) != NULL) { tc_log_warn(MOD_NAME, "%s", error); return(-1); } quiet_encore=dlsym(handle, "quiet_encore"); if ((error = dlerror()) != NULL) { tc_log_warn(MOD_NAME, "%s", error); return(-1); } *quiet_encore=1; // debug if(verbose_flag & TC_STATS) *quiet_encore=0; return(0); }
static int y4m_snprint_xtags(char *s, int maxn, y4m_xtag_list_t *xtags) { int i, room; for (i = 0, room = maxn - 1; i < y4m_xtag_count(xtags); i++) { int n = tc_snprintf(s, room + 1, " %s", y4m_xtag_get(xtags, i)); if ((n < 0) || (n > room)) return Y4M_ERR_HEADER; s += n; room -= n; } s[0] = '\n'; /* finish off header with newline */ s[1] = '\0'; /* ...and end-of-string */ return Y4M_OK; }
int load_plugin(const char *path, int id, int verbose) { const char *error = NULL; char module[TC_BUF_MAX]; int n; if (filter[id].name == NULL) { tc_log_error(__FILE__, "bad filter#%i name (%s)", id, filter[id].name); return -1; } filter[id].options = NULL; /* replace "=" by "/0" in filter name */ for (n = 0; n < strlen(filter[id].name); n++) { if (filter[id].name[n] == '=') { filter[id].name[n] = '\0'; filter[id].options = filter[id].name + n + 1; break; } } tc_snprintf(module, sizeof(module), "%s/filter_%s.so", path, filter[id].name); /* try transcode's module directory */ filter[id].handle = dlopen(module, RTLD_LAZY); if (filter[id].handle != NULL) { filter[id].entry = dlsym(filter[id].handle, "tc_filter"); } else { if (verbose) { tc_log_error(__FILE__, "loading filter module '%s' failed (reason: %s)", module, dlerror()); } return -1; } error = dlerror(); if (error != NULL) { if (verbose) { tc_log_error(__FILE__, "error while loading '%s': %s\n", module, error); } return -1; } return 0; }
int tc_codec_description(TCCodecID codec, char *buf, size_t bufsize) { int idx = find_tc_codec(tc_codecs_info, id_matcher, &codec); int ret; if (idx == TC_NULL_MATCH) { /* not found */ return -1; } ret = tc_snprintf(buf, bufsize, "%-12s: (fourcc=%s multipass=%-3s) %s", tc_codecs_info[idx].name, tc_codecs_info[idx].fourcc, tc_codecs_info[idx].multipass ?"yes" :"no", tc_codecs_info[idx].comment); return ret; // FIXME }
static void dump_processing(int sock) { uint32_t dropped = 0, encoded = 0; int im = 0, fl = 0, ex = 0; char buf[TC_BUF_LINE]; int n; dropped = tc_get_frames_dropped(); encoded = tc_get_frames_encoded(); tc_framebuffer_get_counters(&im, &fl, &ex); n = tc_snprintf(buf, sizeof(buf), "E=%lu|D=%lu|im=%i|fl=%i|ex=%i", encoded, dropped, im, fl, ex); if (n > 0) sendall(sock, buf, n); }
static int faac_inspect(TCModuleInstance *self, const char *param, const char **value) { static char buf[TC_BUF_MAX]; TC_MODULE_SELF_CHECK(self, "inspect"); TC_MODULE_SELF_CHECK(param, "inspect"); if (optstr_lookup(param, "help")) { tc_snprintf(buf, sizeof(buf), "Overview:\n" " Encodes audio to AAC using the FAAC library.\n" "Options:\n" " quality: set encoder quality [0-100]\n"); *value = buf; } return TC_OK; }
static int astat_get_config(TCModuleInstance *self, char *options) { char buf[TC_BUF_MIN]; AStatPrivateData *pd = NULL; TC_MODULE_SELF_CHECK(self, "get_config"); pd = self->userdata; optstr_filter_desc(options, MOD_NAME, MOD_CAP, MOD_VERSION, MOD_AUTHOR, "AE", "1"); optstr_param(options, "file", "save rescale value to file", "%s", ""); tc_snprintf(buf, sizeof(buf), "%i", pd->silence_limit); optstr_param(options, "silence_limit", "maximum silence amplitude", "%i", buf, "0", "1024"); /* pretty arbitrary */ return TC_OK; }
static int invert_get_config(TCModuleInstance *self, char *options) { InvertPrivateData *mfd = NULL; char buf[TC_BUF_MIN]; TC_MODULE_SELF_CHECK(self, "get_config"); mfd = self->userdata; optstr_filter_desc(options, MOD_NAME, MOD_CAP, MOD_VERSION, MOD_AUTHOR, "VRY4O", "1"); optstr_param(options, "help", "Inverts the image", "", "0"); tc_snprintf(buf, sizeof(buf), "%u-%u/%d", mfd->start, mfd->end, mfd->step); optstr_param(options, "range", "apply filter to [start-end]/step frames", "%u-%u/%d", buf, "0", "oo", "0", "oo", "1", "oo"); return TC_OK; }
static int pvn_inspect(TCModuleInstance *self, const char *param, const char **value) { static char buf[TC_BUF_MAX]; TC_MODULE_SELF_CHECK(self, "inspect"); TC_MODULE_SELF_CHECK(param, "inspect"); if (optstr_lookup(param, "help")) { tc_snprintf(buf, sizeof(buf), "Overview:\n" " Writes a PVN video stream (format PV6a, 8-bit data).\n" " A grayscale file (PV5a) is written instead if the -K\n" " switch is given to transcode.\n" " The RGB colorspace must be used (-V rgb24).\n" "No options available.\n"); *value = buf; } return TC_OK; }
static int lowpass_get_config(TCModuleInstance *self, char *options) { LowPassPrivateData *pd = NULL; char buf[TC_BUF_MIN]; TC_MODULE_SELF_CHECK(self, "get_config"); pd = self->userdata; /* use optstr_param to do introspection */ if (options) { optstr_filter_desc(options, MOD_NAME, MOD_CAP, MOD_VERSION, MOD_AUTHOR, "AE", "1"); tc_snprintf(buf, sizeof(buf), "%d", pd->taps); optstr_param(options, "taps", "strength (may be negative)", "%d", buf, "-50", "50"); } return TC_OK; }
static int nuv_inspect(TCModuleInstance *self, const char *param, const char **value) { PrivateData *pd; static char buf[TC_BUF_MAX]; TC_MODULE_SELF_CHECK(self, "inspect"); TC_MODULE_SELF_CHECK(param, "inspect"); TC_MODULE_SELF_CHECK(value, "inspect"); pd = self->userdata; if (optstr_lookup(param, "help")) { tc_snprintf(buf, sizeof(buf), "Overview:\n" " Decodes NuppelVideo streams.\n" "Options available: None.\n"); *value = buf; } return TC_IMPORT_OK; }
static int tc_im_inspect(TCModuleInstance *self, const char *param, const char **value) { TCIMPrivateData *pd = NULL; TC_MODULE_SELF_CHECK(self, "inspect"); pd = self->userdata; if (optstr_lookup(param, "help")) { *value = tc_im_help; } if (optstr_lookup(param, "format")) { *value = pd->img_fmt; } if (optstr_lookup(param, "quality")) { tc_snprintf(pd->opt_buf, sizeof(pd->opt_buf), "%lu", pd->quality); *value = pd->opt_buf; } return TC_OK; }