void SortidaFitxer::crea(GstElement *pipeline, GstElement *queue, GstElement *mux_pgm, const char* type, const char* typeconverter, const char* typeencoder) { QString sbin("_bin_fitxer_%1"), sconv("_fitxer_%1"), sencoder("_encoder_%1"); bin_fitxer = gst_bin_new ((char*)sbin.prepend(type).toStdString().c_str()); conv = gst_element_factory_make(typeconverter, (char*)sconv.prepend(typeconverter).toStdString().c_str()); //encoder = gst_element_factory_make(typeencoder, (char*)sencoder.prepend(typeencoder).toStdString().c_str()); //Comprovem que s'han pogut crear tots els elements d'entrada if(!bin_fitxer || !conv){ g_printerr ("Un dels elements de la sortida a fitxer no s'ha pogut crear. Sortint.\n"); } //Afegim tots els elements al bin corresponent gst_bin_add_many (GST_BIN (bin_fitxer), conv, NULL); //Afegim els bin_fitxer al pipeline gst_bin_add (GST_BIN (pipeline), bin_fitxer); //Linkem els elements gst_element_link_many (queue, conv, mux_pgm, NULL); }
void my_rev_fath(vector<double>& fath_vec, vector<double>& moth_vec, vector<double>& h_vec, vector<double>& fath_up_vec) { unsigned int len=fath_vec.size(); unsigned int lenup=fath_up_vec.size(); vector<double> dyfath_vec(2*len-1,0.0); vector<double> dymoth_vec(2*len-1,0.0); dydadup(fath_vec,dyfath_vec); dydadup(moth_vec,dymoth_vec); vector<double> fconv(h_vec.size()+2*len-2,0.0); vector<double> mconv(h_vec.size()+2*len-2,0.0); db_vit fconv_vit=fconv.begin(); db_vit mconv_vit=mconv.begin(); vector<double> sconv(h_vec.size()+2*len-1,0.0); conv_dec(h_vec.begin(), h_vec.end(), 3, dyfath_vec.begin(), dyfath_vec.end(), 0, fconv_vit); conv_dec(h_vec.begin(), h_vec.end(), 0, dymoth_vec.begin(), dymoth_vec.end(), 0, mconv_vit); VVdif(&fconv,&mconv, &sconv); for(unsigned int it=0;it<lenup;it++) fath_up_vec[it]=*(sconv.begin()+h_vec.size()-2+it); }
void zzzcode(NODE *p, int c) { NODE *l, *r; TWORD t; int m; char *ch; switch (c) { case 'N': /* logical ops, turned into 0-1 */ /* use register given by register 1 */ cbgen( 0, m=getlab2()); deflab( p->n_label ); printf( " clrl %s\n", rnames[getlr( p, '1' )->n_rval] ); deflab( m ); return; case 'A': /* Assign a constant directly to a memory position */ printf("\t"); if (p->n_type < LONG || ISPTR(p->n_type)) casg(p); else casg64(p); printf("\n"); break; case 'B': /* long long compare */ twollcomp(p); break; case 'C': /* num words pushed on arg stack */ printf("$%d", p->n_qual); break; case 'D': /* INCR and DECR */ zzzcode(p->n_left, 'A'); printf("\n "); #if 0 case 'E': /* INCR and DECR, FOREFF */ if (p->n_right->n_lval == 1) { printf("%s", (p->n_op == INCR ? "inc" : "dec") ); prtype(p->n_left); printf(" "); adrput(stdout, p->n_left); return; } printf("%s", (p->n_op == INCR ? "add" : "sub") ); prtype(p->n_left); printf("2 "); adrput(stdout, p->n_right); printf(","); adrput(p->n_left); return; #endif case 'F': /* register type of right operand */ { register NODE *n; register int ty; n = getlr( p, 'R' ); ty = n->n_type; if (x2debug) printf("->%d<-", ty); if ( ty==DOUBLE) printf("d"); else if ( ty==FLOAT ) printf("f"); else printf("l"); return; } case 'G': /* emit conversion instructions */ sconv(p); break; case 'J': /* jump or ret? */ { struct interpass *ip = DLIST_PREV((struct interpass *)p2env.epp, qelem); if (ip->type != IP_DEFLAB || ip->ip_lbl != getlr(p, 'L')->n_lval) expand(p, FOREFF, "jbr LL"); else printf("ret"); } break; case 'L': /* type of left operand */ case 'R': /* type of right operand */ { register NODE *n; n = getlr ( p, c); if (x2debug) printf("->%d<-", n->n_type); prtype(n); return; } case 'O': /* print out emulated ops */ expand(p, FOREFF, "\tmovq AR,-(%sp)\n"); expand(p, FOREFF, "\tmovq AL,-(%sp)\n"); if (p->n_op == DIV && p->n_type == ULONGLONG) ch = "udiv"; else if (p->n_op == DIV) ch = "div"; else if (p->n_op == MOD && p->n_type == ULONGLONG) ch = "umod"; else if (p->n_op == MOD) ch = "mod"; else if (p->n_op == MUL) ch = "mul"; else ch = 0, comperr("ZO %d", p->n_op); printf("\tcalls $4,__%sdi3\n", ch); break; case 'Z': /* complement mask for bit instr */ printf("$%Ld", ~p->n_right->n_lval); return; case 'U': /* 32 - n, for unsigned right shifts */ t = DEUNSIGN(p->n_left->n_type); m = t == CHAR ? 8 : t == SHORT ? 16 : 32; printf("$" CONFMT, m - p->n_right->n_lval); return; case 'T': /* rounded structure length for arguments */ { int size; size = p->n_stsize; SETOFF( size, 4); printf("$%d", size); return; } case 'S': /* structure assignment */ { register int size; size = p->n_stsize; l = r = NULL; /* XXX gcc */ if( p->n_op == STASG ){ l = p->n_left; r = p->n_right; } else if( p->n_op == STARG ){ /* store an arg into a temporary */ printf("\tsubl2 $%d,%%sp\n", size < 4 ? 4 : size); l = mklnode(OREG, 0, SP, INT); r = p->n_left; } else cerror( "STASG bad" ); if( r->n_op == ICON ) r->n_op = NAME; else if( r->n_op == REG ) r->n_op = OREG; else if( r->n_op != OREG ) cerror( "STASG-r" ); if (size != 0) { if( size <= 0 || size > 65535 ) cerror("structure size <0=0 or >65535"); switch(size) { case 1: printf(" movb "); break; case 2: printf(" movw "); break; case 4: printf(" movl "); break; case 8: printf(" movq "); break; default: printf(" movc3 $%d,", size); break; } adrput(stdout, r); printf(","); adrput(stdout, l); printf("\n"); } if( r->n_op == NAME ) r->n_op = ICON; else if( r->n_op == OREG ) r->n_op = REG; if (p->n_op == STARG) tfree(l); } break; default: comperr("illegal zzzcode '%c'", c); } }
int decimate_trace(Tbl *dectbl,float *in, int nin, double dt0, double t0, float **out, int *nout, double *dt, double *t0out) { int i,nstages; float *buf, *buf2; FIR_decimation *d; int decfac; /* current decimation factor */ double deltat0=0.0; /* accumulation of time offsets for edge condition of FIR filter (i.e. we don't do partial convolutions on edges) */ double dt_this_stage; double si; /* current sample interval (staged to larger values) */ int n; /* current number of samples */ int ret_code; nstages = maxtbl(dectbl); buf = (float *) calloc (nin,sizeof(float)); buf2 = (float *) calloc (nin,sizeof(float)); if( (buf == NULL) || (buf2 == NULL) ) { elog_notify(0,"decimate_trace: cannot malloc buffers of length %d\n", nin); return(-999); } /* Note this routine works if nstages = 0 (empty tbl) */ scopy(nin,in,1,buf,1); decfac = 1; si=dt0; n=nin; for (i=0; i<nstages; i++) { d = (FIR_decimation *) gettbl(dectbl,i); /* this computation of the time offset to the first decimated output sample assumes the FIR filter is zero phase and symmetric. The -1 may surprise you, but is correct and was verified by tests. It is the interval versus points problem. */ decfac *= d->decfac; dt_this_stage = si*((double)((d->ncoefs)-1))/2.0; deltat0 += dt_this_stage; si *= (double)(d->decfac); if((d->decfac == 1) && (d->ncoefs == 0) ) { /* Fall in this block for no decimation with zero length filter (the "none" case ) */ scopy(n,buf,1,buf2,1); *nout = n; } else { if((d->ncoefs)>n) { free(buf); free(buf2); out = NULL; *nout = 0; return(-1); } ret_code = sconv(buf,n,d->coefs,d->ncoefs,0,d->decfac, buf2,nout); /* This fragment should never really be executed, but better safe than sorry. We don't issue a warning because the correction should be appropriate. */ if(ret_code > 0) { double time_correction; time_correction = si*((double)ret_code); deltat0 += time_correction; } } /* this always works because nout <= nin */ scopy(*nout,buf2,1,buf,1); n = *nout; } /* finally the output vector is created here */ *out = (float *)calloc(*nout,sizeof(float)); if(*out == NULL) elog_die(0,"decimate_trace: cannot malloc output vector of length %d\n", *nout); scopy(*nout,buf2,1,*out,1); *t0out = t0 + deltat0; *dt = si; free(buf); free(buf2); return(decfac); }
void EntradaFitxer::crea(int k, GstElement *pipeline, QString nom_fitxer) { //Elements de font d'entrada de fitxer QString sbin("bin_font%1"), ssource("source_%1"), sdec("decoder%1"), svolumen_m("volumen_mix%1"), squeue("audio_queue%1"); QString saconv("audio_conv_%1"), sabin("bin_audio_%1"), sconv("video_conv_%1"), ssink("video_sink_%1"); //Creem entrada de fitxer i el decodebin, els afegim al pipeline i els linkem. bin_font = gst_bin_new ((char*)sbin.arg(k).toStdString().c_str()); source = gst_element_factory_make ("filesrc", (char*)ssource.arg(k).toStdString().c_str()); dec = gst_element_factory_make ("decodebin2", (char*)sdec.arg(k).toStdString().c_str()); //Comprovem que s'han pogut crear tots els elements d'entrada if(!bin_font || !source || !dec){ g_printerr ("Un dels elements de l'entrada de fitxer no s'ha pogut crear. Sortint.\n"); } g_signal_connect (dec, "new-decoded-pad", G_CALLBACK (cb_newpad_audio), this); g_signal_connect (dec, "new-decoded-pad", G_CALLBACK (cb_newpad_video), this); gst_bin_add_many (GST_BIN (bin_font), source, dec, NULL); gst_element_link (source, dec); //Creem l'entrada d'àudio a.bin = gst_bin_new ((char*)sabin.arg(k).toStdString().c_str()); conv_audio = gst_element_factory_make("audioconvert", (char*)saconv.arg(k).toStdString().c_str()); audiopad = gst_element_get_static_pad (conv_audio, "sink"); a.queue_mix= gst_element_factory_make("queue2", (char*)squeue.arg(k).toStdString().c_str()); a.volume_mix = gst_element_factory_make("volume", (char*)svolumen_m.arg(k).toStdString().c_str()); //Comprovem que s'han pogut crear tots els elements d'entrada if(!a.bin || !conv_audio || !audiopad || !a.queue_mix || !a.volume_mix){ g_printerr ("Un dels elements de l'entrada de fitxer d'àudio no s'ha pogut crear. Sortint.\n"); } gst_bin_add_many (GST_BIN (a.bin), conv_audio, a.queue_mix, a.volume_mix, NULL); gst_element_link_many (conv_audio, a.queue_mix, a.volume_mix, NULL); gst_element_add_pad (a.bin, gst_ghost_pad_new ("sink", audiopad)); gst_object_unref (audiopad); gst_bin_add (GST_BIN (bin_font), a.bin); //Creem l'entrada de vídeo v.creacomuns(k,"video_fitxer"); v.creatransformadors(k); conv_video = gst_element_factory_make ("ffmpegcolorspace", (char*)sconv.arg(k).toStdString().c_str()); videopad = gst_element_get_static_pad (conv_video, "sink"); v.sink = gst_element_factory_make ("xvimagesink", (char*)ssink.arg(k).toStdString().c_str()); //Comprovem que s'han pogut crear tots els elements d'entrada if( !videopad || !conv_video || !v.sink){ g_printerr ("Un dels elements de l'entrada de fitxer de vídeo no s'ha pogut crear. Sortint.\n"); } gst_bin_add_many (GST_BIN (v.bin), conv_video, v.tee, v.queue, v.scale, v.sink, v.queue_mix, v.color_conv, v.scale_mix, NULL); gst_element_link_many (conv_video, v.tee, v.queue, v.scale, v.sink, NULL); gst_element_add_pad (v.bin, gst_ghost_pad_new ("sink", videopad)); gst_object_unref (videopad); gst_bin_add (GST_BIN (bin_font), v.bin); //Seleccionem el fitxer d'entrada const char *c_nom_fitxer = nom_fitxer.toStdString().c_str(); g_object_set (G_OBJECT (source), "location", c_nom_fitxer, NULL); gst_element_set_state(v.sink, GST_STATE_READY); //Afegim el bin_video_pgm al pipeline gst_bin_add (GST_BIN (pipeline),bin_font); }