您当前的位置:首页 > IT编程 > C++
| C语言 | Java | VB | VC | python | Android | TensorFlow | C++ | oracle | 学术与代码 | cnn卷积神经网络 | gnn | 图像修复 | Keras | 数据集 | Neo4j | 自然语言处理 | 深度学习 | 医学CAD | 医学影像 | 超参数 | pointnet | pytorch | 异常检测 | Transformers | 情感分类 | 知识图谱 |

自学教程:C++ vorbis_analysis_init函数代码示例

51自学网 2021-06-03 09:47:08
  C++
这篇教程C++ vorbis_analysis_init函数代码示例写得很实用,希望能帮到您。

本文整理汇总了C++中vorbis_analysis_init函数的典型用法代码示例。如果您正苦于以下问题:C++ vorbis_analysis_init函数的具体用法?C++ vorbis_analysis_init怎么用?C++ vorbis_analysis_init使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。

在下文中一共展示了vorbis_analysis_init函数的30个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的C++代码示例。

示例1: _create_codebook_header_buffer

static GstBuffer *_create_codebook_header_buffer (void){  GstBuffer *buffer;  ogg_packet header;  ogg_packet header_comm;  ogg_packet header_code;  vorbis_info_init (&vi);  vorbis_encode_setup_vbr (&vi, 1, 44000, 0.5);  vorbis_encode_setup_init (&vi);  vorbis_analysis_init (&vd, &vi);  vorbis_block_init (&vd, &vb);  vorbis_comment_init (&vc);  vorbis_analysis_headerout (&vd, &vc, &header, &header_comm, &header_code);  buffer = gst_buffer_new_and_alloc (header_code.bytes);  gst_buffer_fill (buffer, 0, header_code.packet, header_code.bytes);  return buffer;}
开发者ID:lubing521,项目名称:gst-embedded-builder,代码行数:21,


示例2: encoder_create_vbr

encoder_instance encoder_create_vbr(int ch, int bitrate, float quality) {  encoder_instance state = malloc(sizeof(struct encoder_state));  state->data = NULL;  state->data_len = 0;    vorbis_info_init(&state->vi);    if (vorbis_encode_init_vbr(&state->vi, ch, bitrate, quality) != 0) {    free(state);    return NULL;  }    vorbis_comment_init(&state->vc);  vorbis_comment_add_tag(&state->vc, "ENCODER", "libvorbis.js");    vorbis_analysis_init(&state->vd, &state->vi);  vorbis_block_init(&state->vd, &state->vb);    srand(time(NULL));  ogg_stream_init(&state->os, rand());    return state;}
开发者ID:paul-wade,项目名称:libvorbis.js,代码行数:23,


示例3: xmms_ices_encoder_create

/* Create an ogg stream and vorbis encoder, with the configuration * specified in the encoder_state. */static gbooleanxmms_ices_encoder_create (encoder_state *s, vorbis_comment *vc){	ogg_packet header[3];	if (s->encoder_inited) {		XMMS_DBG ("OOPS: xmms_ices_encoder_create called "		          "with s->encoder_inited == TRUE !");	}	XMMS_DBG ("Creating encoder in ABR mode: min/avg/max bitrate %d/%d/%d",	          s->min_br, s->nom_br, s->max_br);	/* Create the Vorbis encoder. */	vorbis_info_init (&s->vi);	if (vorbis_encode_init (&s->vi, s->channels, s->rate,	                        s->max_br, s->nom_br, s->min_br) < 0)		return FALSE;	vorbis_analysis_init (&s->vd, &s->vi);	vorbis_block_init (&s->vd, &s->vb);	/* Initialize the ogg stream and input the vorbis header	 * packets. */	ogg_stream_init (&s->os, s->serial++);	vorbis_analysis_headerout (&s->vd, vc, &header[0], &header[1], &header[2]);	ogg_stream_packetin (&s->os, &header[0]);	ogg_stream_packetin (&s->os, &header[1]);	ogg_stream_packetin (&s->os, &header[2]);	s->in_header = TRUE;	s->flushing = FALSE;	s->samples_in_current_page = 0;	s->previous_granulepos = 0;	s->encoder_inited = TRUE;	return TRUE;}
开发者ID:eggpi,项目名称:xmms2-guilherme,代码行数:40,


示例4: vorbis_encoder_reinit

static boolvorbis_encoder_reinit(struct vorbis_encoder *encoder, GError **error){	vorbis_info_init(&encoder->vi);	if (encoder->quality >= -1.0) {		/* a quality was configured (VBR) */		if (0 != vorbis_encode_init_vbr(&encoder->vi,						encoder->audio_format.channels,						encoder->audio_format.sample_rate,						encoder->quality * 0.1)) {			g_set_error(error, vorbis_encoder_quark(), 0,				    "error initializing vorbis vbr");			vorbis_info_clear(&encoder->vi);			return false;		}	} else {		/* a bit rate was configured */		if (0 != vorbis_encode_init(&encoder->vi,					    encoder->audio_format.channels,					    encoder->audio_format.sample_rate, -1.0,					    encoder->bitrate * 1000, -1.0)) {			g_set_error(error, vorbis_encoder_quark(), 0,				    "error initializing vorbis encoder");			vorbis_info_clear(&encoder->vi);			return false;		}	}	vorbis_analysis_init(&encoder->vd, &encoder->vi);	vorbis_block_init(&encoder->vd, &encoder->vb);	ogg_stream_init(&encoder->os, g_random_int());	return true;}
开发者ID:andrewrk,项目名称:mpd,代码行数:37,


示例5: vorbis_info_init

	StreamEncoder::StreamEncoder()	{		//Initialize the info 		vorbis_info_init(&mVorbisInfo);		if (ErrorCheck(vorbis_encode_init(&mVorbisInfo, 2, 44100, 100, 80, 60)) == true)		{			//Error			Write("vorbis_encode_init error");			return;		}		if (ErrorCheck(vorbis_analysis_init(&mVorbisDspState, &mVorbisInfo)) == true)		{			//Error			Write("vorbis_analysis_init error");			return;		}		vorbis_comment_init(&mVorbisComment);		//vorbis_comment_add(&mVorbisComment, "Comments");		int vahCode = vorbis_analysis_headerout(&mVorbisDspState, &mVorbisComment, &mOggPacketIdentification, &mOggPacketComment, &mOggPacketCodes);		if (ErrorCheck(vahCode) == true)		{			//Error			Write("vorbis_analysis_init error");			return;		}		if (ErrorCheck(vorbis_block_init(&mVorbisDspState, &mVorbisBlock)) == true)		{			//Error			Write("vorbis_block_init error");			return;		}	}
开发者ID:zippo227,项目名称:ogg_enc_buffer,代码行数:36,


示例6: vorbis_analysis_init

void EncoderVorbis::initStream() {    // set up analysis state and auxiliary encoding storage    vorbis_analysis_init(&m_vdsp, &m_vinfo);    vorbis_block_init(&m_vdsp, &m_vblock);    // set up packet-to-stream encoder; attach a random serial number    srand(time(0));    ogg_stream_init(&m_oggs, getSerial());    // add comment    vorbis_comment_init(&m_vcomment);    vorbis_comment_add_tag(&m_vcomment, "ENCODER", "mixxx/libvorbis");    if (m_metaDataArtist != NULL) {        vorbis_comment_add_tag(&m_vcomment, "ARTIST", m_metaDataArtist);    }    if (m_metaDataTitle != NULL) {        vorbis_comment_add_tag(&m_vcomment, "TITLE", m_metaDataTitle);    }    if (m_metaDataAlbum != NULL) {        vorbis_comment_add_tag(&m_vcomment, "ALBUM", m_metaDataAlbum);    }    // set up the vorbis headers    ogg_packet headerInit;    ogg_packet headerComment;    ogg_packet headerCode;    vorbis_analysis_headerout(&m_vdsp, &m_vcomment, &headerInit, &headerComment, &headerCode);    ogg_stream_packetin(&m_oggs, &headerInit);    ogg_stream_packetin(&m_oggs, &headerComment);    ogg_stream_packetin(&m_oggs, &headerCode);    // The encoder is now inialized. The encode method will start streaming by    // sending the header first.    m_header_write = true;    m_bStreamInitialized = true;}
开发者ID:dk0104,项目名称:mixxx,代码行数:36,


示例7: Encode_Ogg

int Encode_Ogg(void *stream,void(*writefunc)(void *bytes,int count,void *stream),int freq,int channels,float *samples,int length,float compression) {    oggwriter *ogg;    int eos;    int result;    ogg=(oggwriter*)malloc(sizeof(oggwriter));    vorbis_info_init(&ogg->vi);    result=vorbis_encode_init_vbr(&ogg->vi,channels,freq,compression);    if(result) return -1;	//error format not supported...// add a comment    vorbis_comment_init(&ogg->vc);    vorbis_comment_add_tag(&ogg->vc,"ENCODER","encoder_example.c");// set up the analysis state and auxiliary encoding storage    vorbis_analysis_init(&ogg->vd,&ogg->vi);    vorbis_block_init(&ogg->vd,&ogg->vb);    srand(time(NULL));    ogg_stream_init(&ogg->os,rand());    ogg_packet header;    ogg_packet header_comm;    ogg_packet header_code;    vorbis_analysis_headerout(&ogg->vd,&ogg->vc,&header,&header_comm,&header_code);    ogg_stream_packetin(&ogg->os,&header); //automatically placed in its own page    ogg_stream_packetin(&ogg->os,&header_comm);    ogg_stream_packetin(&ogg->os,&header_code);//This ensures the actual audio data will start on a new page, as per spec    while(1) {        result=ogg_stream_flush(&ogg->os,&ogg->og);        if(result==0)break;        writefunc(ogg->og.header,ogg->og.header_len,stream);        writefunc(ogg->og.body,ogg->og.body_len,stream);    }    int i,c,n;    eos=0;    while(!eos) {        if (length>0) {            float **buffer=vorbis_analysis_buffer(&ogg->vd,READ);            n=length;            if (n>READ) n=READ;//uninterleave samples            for (i=0; i<n; i++) {                for (c=0; c<channels; c++) {                    buffer[c][i]=*samples++;                }            }            length=length-n;//tell the library how much we actually submitted            vorbis_analysis_wrote(&ogg->vd,i);        } else {            vorbis_analysis_wrote(&ogg->vd,0);        }        while(vorbis_analysis_blockout(&ogg->vd,&ogg->vb)==1) {//analysis, assume we want to use bitrate management            vorbis_analysis(&ogg->vb,NULL);            vorbis_bitrate_addblock(&ogg->vb);            while(vorbis_bitrate_flushpacket(&ogg->vd,&ogg->op)) {//weld the packet into the bitstream                ogg_stream_packetin(&ogg->os,&ogg->op);//write out pages (if any)                while(!eos) {                    result=ogg_stream_pageout(&ogg->os,&ogg->og);                    if(result==0)break;                    writefunc(ogg->og.header,ogg->og.header_len,stream);                    writefunc(ogg->og.body,ogg->og.body_len,stream);                    if (ogg_page_eos(&ogg->og)) eos=1;                }            }        }    }//clean up and exit.  vorbis_info_clear() must be called last    ogg_stream_clear(&ogg->os);    vorbis_block_clear(&ogg->vb);    vorbis_dsp_clear(&ogg->vd);    vorbis_comment_clear(&ogg->vc);    vorbis_info_clear(&ogg->vi);    free(ogg);    return 0;}
开发者ID:nitrologic,项目名称:mod,代码行数:94,


示例8: gst_vorbis_enc_setup

static gbooleangst_vorbis_enc_setup (GstVorbisEnc * vorbisenc){  GST_LOG_OBJECT (vorbisenc, "setup");  if (vorbisenc->bitrate < 0 && vorbisenc->min_bitrate < 0      && vorbisenc->max_bitrate < 0) {    vorbisenc->quality_set = TRUE;  }  update_start_message (vorbisenc);  /* choose an encoding mode */  /* (mode 0: 44kHz stereo uncoupled, roughly 128kbps VBR) */  vorbis_info_init (&vorbisenc->vi);  if (vorbisenc->quality_set) {    if (vorbis_encode_setup_vbr (&vorbisenc->vi,            vorbisenc->channels, vorbisenc->frequency,            vorbisenc->quality) != 0) {      GST_ERROR_OBJECT (vorbisenc,          "vorbisenc: initialisation failed: invalid parameters for quality");      vorbis_info_clear (&vorbisenc->vi);      return FALSE;    }    /* do we have optional hard quality restrictions? */    if (vorbisenc->max_bitrate > 0 || vorbisenc->min_bitrate > 0) {      struct ovectl_ratemanage_arg ai;      vorbis_encode_ctl (&vorbisenc->vi, OV_ECTL_RATEMANAGE_GET, &ai);      ai.bitrate_hard_min = vorbisenc->min_bitrate;      ai.bitrate_hard_max = vorbisenc->max_bitrate;      ai.management_active = 1;      vorbis_encode_ctl (&vorbisenc->vi, OV_ECTL_RATEMANAGE_SET, &ai);    }  } else {    long min_bitrate, max_bitrate;    min_bitrate = vorbisenc->min_bitrate > 0 ? vorbisenc->min_bitrate : -1;    max_bitrate = vorbisenc->max_bitrate > 0 ? vorbisenc->max_bitrate : -1;    if (vorbis_encode_setup_managed (&vorbisenc->vi,            vorbisenc->channels,            vorbisenc->frequency,            max_bitrate, vorbisenc->bitrate, min_bitrate) != 0) {      GST_ERROR_OBJECT (vorbisenc,          "vorbis_encode_setup_managed "          "(c %d, rate %d, max br %ld, br %d, min br %ld) failed",          vorbisenc->channels, vorbisenc->frequency, max_bitrate,          vorbisenc->bitrate, min_bitrate);      vorbis_info_clear (&vorbisenc->vi);      return FALSE;    }  }  if (vorbisenc->managed && vorbisenc->bitrate < 0) {    vorbis_encode_ctl (&vorbisenc->vi, OV_ECTL_RATEMANAGE_AVG, NULL);  } else if (!vorbisenc->managed) {    /* Turn off management entirely (if it was turned on). */    vorbis_encode_ctl (&vorbisenc->vi, OV_ECTL_RATEMANAGE_SET, NULL);  }  vorbis_encode_setup_init (&vorbisenc->vi);  /* set up the analysis state and auxiliary encoding storage */  vorbis_analysis_init (&vorbisenc->vd, &vorbisenc->vi);  vorbis_block_init (&vorbisenc->vd, &vorbisenc->vb);  /* samples == granulepos start at 0 again */  vorbisenc->samples_out = 0;  /* fresh encoder available */  vorbisenc->setup = TRUE;  return TRUE;}
开发者ID:ConfusedReality,项目名称:pkg_multimedia_gst-plugins-base,代码行数:79,


示例9: ExportOGG

bool ExportOGG(AudacityProject *project,               bool stereo, wxString fName,               bool selectionOnly, double t0, double t1){   double    rate    = project->GetRate();   wxWindow  *parent = project;   TrackList *tracks = project->GetTracks();   double    quality = (gPrefs->Read("/FileFormats/OggExportQuality", 50)/(float)100.0);   wxLogNull logNo;            // temporarily disable wxWindows error messages    bool      cancelling = false;   wxFFile outFile(fName, "wb");   if(!outFile.IsOpened()) {      wxMessageBox(_("Unable to open target file for writing"));      return false;   }   // All the Ogg and Vorbis encoding data   ogg_stream_state stream;   ogg_page         page;   ogg_packet       packet;   vorbis_info      info;   vorbis_comment   comment;   vorbis_dsp_state dsp;   vorbis_block     block;   // Encoding setup   vorbis_info_init(&info);   vorbis_encode_init_vbr(&info, stereo ? 2 : 1, int(rate + 0.5), quality);   vorbis_comment_init(&comment);   // If we wanted to add comments, we would do it here   // Set up analysis state and auxiliary encoding storage   vorbis_analysis_init(&dsp, &info);   vorbis_block_init(&dsp, &block);   // Set up packet->stream encoder.  According to encoder example,   // a random serial number makes it more likely that you can make   // chained streams with concatenation.   srand(time(NULL));   ogg_stream_init(&stream, rand());   // First we need to write the required headers:   //    1. The Ogg bitstream header, which contains codec setup params   //    2. The Vorbis comment header   //    3. The bitstream codebook.   //   // After we create those our responsibility is complete, libvorbis will   // take care of any other ogg bistream constraints (again, according   // to the example encoder source)   ogg_packet bitstream_header;   ogg_packet comment_header;   ogg_packet codebook_header;   vorbis_analysis_headerout(&dsp, &comment, &bitstream_header, &comment_header,         &codebook_header);   // Place these headers into the stream   ogg_stream_packetin(&stream, &bitstream_header);   ogg_stream_packetin(&stream, &comment_header);   ogg_stream_packetin(&stream, &codebook_header);   // Flushing these headers now guarentees that audio data will   // start on a new page, which apparently makes streaming easier   ogg_stream_flush(&stream, &page);   outFile.Write(page.header, page.header_len);   outFile.Write(page.body, page.body_len);   double t = t0;   bool   done = false;   wxProgressDialog *progress = NULL;   wxYield();   wxStartTimer();   while(!done && !cancelling){      float       deltat = (float)SAMPLES_PER_RUN / rate;      sampleCount samplesThisRun = SAMPLES_PER_RUN;      Mixer       *mixer = new Mixer(stereo ? 2 : 1, SAMPLES_PER_RUN,             /* interleaved = */ false, rate, floatSample);      if(t + deltat > t1) {         done = true;         deltat = t1 - t;         samplesThisRun = int(deltat * rate + 0.5);      }            mixer->Clear();      TrackListIterator iter(tracks);      Track *tr = iter.First();      while (tr) {         if (tr->GetKind() == Track::Wave) {            if (tr->GetSelected() || !selectionOnly) {               if (tr->GetChannel() == Track::MonoChannel)                  mixer->MixMono((WaveTrack *) tr, t, t + deltat);//.........这里部分代码省略.........
开发者ID:ruthmagnus,项目名称:audacity,代码行数:101,


示例10: vorbis_info_init

tbool CVorbisEncoder::Process_Init_Descendant(){	// Setup encoder	vorbis_info_init(&vi);	//mfQuality = -0.1;	if (vorbis_encode_init_vbr(&vi, miOutputChannels, miInputSampleFreq, mfQuality) != 0) {		AppendErrMsg("Function vorbis_encode_init_vbr failed for unknown reason.");		return false;	}	// Note: Using vorbis_encode_init rather than vorbis_encode_init_vbr makes encoding 4 times slower	// because it will try harder at targetting the bitrate you ask of it.	// Also I think the guy with the unpronouncable name that tuned vorbis (the aoTuV versions)	// only bothered to optimize the "_vbr" method.. and that's quite ok.	// Lasse	//	//if (vorbis_encode_init(&vi, miOutputChannels, miInputSampleFreq, 256000, 192000, 32000) != 0) {	//	AppendErrMsg("Function vorbis_encode_init(..) failed for unknown reason.");	//	return false;	//}	// TODO: add comments	vorbis_comment_init(&vc);	vorbis_comment_add_tag(&vc,"ENCODER","Koblo 1.0 // aoTuV b5");	vorbis_comment_add_tag(&vc,"KOBLO_ENC_QUAL", (char*)GetQualityName(meQuality));		/* set up the analysis state and auxiliary encoding storage */	vorbis_analysis_init(&vd,&vi);	vorbis_block_init(&vd,&vb);		/* set up our packet->stream encoder */	/* pick a random serial number; that way we can more likely build		chained streams just by concatenation */	srand((unsigned)time(NULL));	ogg_stream_init(&os,rand());		/* Vorbis streams begin with three headers; the initial header (with		most of the codec setup parameters) which is mandated by the Ogg		bitstream spec.  The second header holds any comment fields.  The		third header holds the bitstream codebook.  We merely need to		make the headers, then pass them to libvorbis one at a time;		libvorbis handles the additional Ogg bitstream constraints */		{		ogg_packet header;		ogg_packet header_comm;		ogg_packet header_code;				vorbis_analysis_headerout(&vd,&vc,&header,&header_comm,&header_code);		ogg_stream_packetin(&os,&header); /* automatically placed in its own			page */		ogg_stream_packetin(&os,&header_comm);		ogg_stream_packetin(&os,&header_code);				/* This ensures the actual			* audio data will start on a new page, as per spec			*/		while(1){			int result=ogg_stream_flush(&os,&og);			if(result==0)break;			//fwrite(og.header,1,og.header_len,stdout);			//fwrite(og.body,1,og.body_len,stdout);			WriteOutput((char*)og.header, og.header_len);			WriteOutput((char*)og.body, og.body_len);		}	}	return true;} // Process_Init_Secendant
开发者ID:eriser,项目名称:koblo_software-1,代码行数:68,


示例11: main

//.........这里部分代码省略.........   ---------------------------------------------------------------------   Encoding using an average bitrate mode (ABR).   example: 44kHz stereo coupled, average 128kbps VBR      ret = vorbis_encode_init(&vi,2,44100,-1,128000,-1);   ---------------------------------------------------------------------   Encode using a quality mode, but select that quality mode by asking for   an approximate bitrate.  This is not ABR, it is true VBR, but selected   using the bitrate interface, and then turning bitrate management off:   ret = ( vorbis_encode_setup_managed(&vi,2,44100,-1,128000,-1) ||           vorbis_encode_ctl(&vi,OV_ECTL_RATEMANAGE2_SET,NULL) ||           vorbis_encode_setup_init(&vi));   *********************************************************************/  ret=vorbis_encode_init_vbr(&vi,2,44100,0.1);  /* do not continue if setup failed; this can happen if we ask for a     mode that libVorbis does not support (eg, too low a bitrate, etc,     will return 'OV_EIMPL') */  if(ret)exit(1);  /* add a comment */  vorbis_comment_init(&vc);  vorbis_comment_add_tag(&vc,"ENCODER","encoder_example.c");  /* set up the analysis state and auxiliary encoding storage */  vorbis_analysis_init(&vd,&vi);  vorbis_block_init(&vd,&vb);    /* set up our packet->stream encoder */  /* pick a random serial number; that way we can more likely build     chained streams just by concatenation */  srand(time(NULL));  ogg_stream_init(&os,rand());  /* Vorbis streams begin with three headers; the initial header (with     most of the codec setup parameters) which is mandated by the Ogg     bitstream spec.  The second header holds any comment fields.  The     third header holds the bitstream codebook.  We merely need to     make the headers, then pass them to libvorbis one at a time;     libvorbis handles the additional Ogg bitstream constraints */  {    ogg_packet header;    ogg_packet header_comm;    ogg_packet header_code;    vorbis_analysis_headerout(&vd,&vc,&header,&header_comm,&header_code);    ogg_stream_packetin(&os,&header); /* automatically placed in its own					 page */    ogg_stream_packetin(&os,&header_comm);    ogg_stream_packetin(&os,&header_code);	/* This ensures the actual	 * audio data will start on a new page, as per spec	 */	while(!eos){		int result=ogg_stream_flush(&os,&og);		if(result==0)break;
开发者ID:John-He-928,项目名称:krkrz,代码行数:67,


示例12: rmdInitEncoder

//.........这里部分代码省略.........    enc_data_t->m_th_inf.aspect_denominator           = 1;    enc_data_t->m_th_inf.colorspace                   = OC_CS_UNSPECIFIED;    enc_data_t->m_th_inf.pixelformat                  = OC_PF_420;    enc_data_t->m_th_inf.target_bitrate               = pdata->args.v_bitrate;    enc_data_t->m_th_inf.quality                      = pdata->args.v_quality;    enc_data_t->m_th_inf.dropframes_p                 = 0;    enc_data_t->m_th_inf.quick_p                      = 1;    enc_data_t->m_th_inf.keyframe_auto_p              = 1;    enc_data_t->m_th_inf.keyframe_frequency           = 64;    enc_data_t->m_th_inf.keyframe_frequency_force     = 64;    enc_data_t->m_th_inf.keyframe_data_target_bitrate = enc_data_t->m_th_inf.quality * 1.5;    enc_data_t->m_th_inf.keyframe_auto_threshold      = 80;    enc_data_t->m_th_inf.keyframe_mindistance         = 8;    enc_data_t->m_th_inf.noise_sensitivity            = 1;    enc_data_t->m_th_inf.sharpness                    = 2;    theora_encode_init(&enc_data_t->m_th_st,&enc_data_t->m_th_inf);    if(!pdata->args.nosound){        int ret;        vorbis_info_init(&enc_data_t->m_vo_inf);        ret = vorbis_encode_init_vbr(&enc_data_t->m_vo_inf,                                     pdata->args.channels,                                     pdata->args.frequency,                                     (float)pdata->args.s_quality*0.1);        if(ret){            fprintf(stderr,"Error while setting up vorbis stream quality!/n");            exit(2);        }        vorbis_comment_init(&enc_data_t->m_vo_cmmnt);        vorbis_analysis_init(&enc_data_t->m_vo_dsp,&enc_data_t->m_vo_inf);        vorbis_block_init(&enc_data_t->m_vo_dsp,&enc_data_t->m_vo_block);    }    theora_encode_header(&enc_data_t->m_th_st,&enc_data_t->m_ogg_pckt1);    ogg_stream_packetin(&enc_data_t->m_ogg_ts,&enc_data_t->m_ogg_pckt1);    if(ogg_stream_pageout(&enc_data_t->m_ogg_ts,&enc_data_t->m_ogg_pg)!=1){        fprintf(stderr,"Internal Ogg library error./n");        exit(2);    }    fwrite(enc_data_t->m_ogg_pg.header,1,           enc_data_t->m_ogg_pg.header_len,           enc_data_t->fp);    fwrite(enc_data_t->m_ogg_pg.body,1,           enc_data_t->m_ogg_pg.body_len,           enc_data_t->fp);    theora_comment_init(&enc_data_t->m_th_cmmnt);    theora_comment_add_tag(&enc_data_t->m_th_cmmnt,"recordMyDesktop",VERSION);    theora_encode_comment(&enc_data_t->m_th_cmmnt,&enc_data_t->m_ogg_pckt1);    ogg_stream_packetin(&enc_data_t->m_ogg_ts,&enc_data_t->m_ogg_pckt1);    theora_encode_tables(&enc_data_t->m_th_st,&enc_data_t->m_ogg_pckt1);    ogg_stream_packetin(&enc_data_t->m_ogg_ts,&enc_data_t->m_ogg_pckt1);    if(!pdata->args.nosound){        ogg_packet header;        ogg_packet header_comm;        ogg_packet header_code;        vorbis_analysis_headerout(&enc_data_t->m_vo_dsp,                                  &enc_data_t->m_vo_cmmnt,
开发者ID:jamoozy,项目名称:recordmydesktop,代码行数:67,


示例13: OpenEncoder

/***************************************************************************** * OpenEncoder: probe the encoder and return score *****************************************************************************/static int OpenEncoder( vlc_object_t *p_this ){    encoder_t *p_enc = (encoder_t *)p_this;    encoder_sys_t *p_sys;    int i_quality, i_min_bitrate, i_max_bitrate;    ogg_packet header[3];    if( p_enc->fmt_out.i_codec != VLC_CODEC_VORBIS &&            !p_enc->b_force )    {        return VLC_EGENERIC;    }    /* Allocate the memory needed to store the decoder's structure */    if( ( p_sys = (encoder_sys_t *)malloc(sizeof(encoder_sys_t)) ) == NULL )        return VLC_ENOMEM;    p_enc->p_sys = p_sys;    p_enc->pf_encode_audio = Encode;    p_enc->fmt_in.i_codec  = VLC_CODEC_FL32;    p_enc->fmt_out.i_codec = VLC_CODEC_VORBIS;    config_ChainParse( p_enc, ENC_CFG_PREFIX, ppsz_enc_options, p_enc->p_cfg );    i_quality = var_GetInteger( p_enc, ENC_CFG_PREFIX "quality" );    if( i_quality > 10 ) i_quality = 10;    if( i_quality < 0 ) i_quality = 0;    if( var_GetBool( p_enc, ENC_CFG_PREFIX "cbr" ) ) i_quality = 0;    i_max_bitrate = var_GetInteger( p_enc, ENC_CFG_PREFIX "max-bitrate" );    i_min_bitrate = var_GetInteger( p_enc, ENC_CFG_PREFIX "min-bitrate" );    /* Initialize vorbis encoder */    vorbis_info_init( &p_sys->vi );    if( i_quality > 0 )    {        /* VBR mode */        if( vorbis_encode_setup_vbr( &p_sys->vi,                                     p_enc->fmt_in.audio.i_channels, p_enc->fmt_in.audio.i_rate,                                     i_quality * 0.1 ) )        {            vorbis_info_clear( &p_sys->vi );            free( p_enc->p_sys );            msg_Err( p_enc, "VBR mode initialisation failed" );            return VLC_EGENERIC;        }        /* Do we have optional hard quality restrictions? */        if( i_max_bitrate > 0 || i_min_bitrate > 0 )        {            struct ovectl_ratemanage_arg ai;            vorbis_encode_ctl( &p_sys->vi, OV_ECTL_RATEMANAGE_GET, &ai );            ai.bitrate_hard_min = i_min_bitrate;            ai.bitrate_hard_max = i_max_bitrate;            ai.management_active = 1;            vorbis_encode_ctl( &p_sys->vi, OV_ECTL_RATEMANAGE_SET, &ai );        }        else        {            /* Turn off management entirely */            vorbis_encode_ctl( &p_sys->vi, OV_ECTL_RATEMANAGE_SET, NULL );        }    }    else    {        if( vorbis_encode_setup_managed( &p_sys->vi,                                         p_enc->fmt_in.audio.i_channels, p_enc->fmt_in.audio.i_rate,                                         i_min_bitrate > 0 ? i_min_bitrate * 1000: -1,                                         p_enc->fmt_out.i_bitrate,                                         i_max_bitrate > 0 ? i_max_bitrate * 1000: -1 ) )        {            vorbis_info_clear( &p_sys->vi );            msg_Err( p_enc, "CBR mode initialisation failed" );            free( p_enc->p_sys );            return VLC_EGENERIC;        }    }    vorbis_encode_setup_init( &p_sys->vi );    /* Add a comment */    vorbis_comment_init( &p_sys->vc);    vorbis_comment_add_tag( &p_sys->vc, "ENCODER", "VLC media player");    /* Set up the analysis state and auxiliary encoding storage */    vorbis_analysis_init( &p_sys->vd, &p_sys->vi );    vorbis_block_init( &p_sys->vd, &p_sys->vb );    /* Create and store headers */    vorbis_analysis_headerout( &p_sys->vd, &p_sys->vc,                               &header[0], &header[1], &header[2]);    for( int i = 0; i < 3; i++ )    {//.........这里部分代码省略.........
开发者ID:J861449197,项目名称:vlc,代码行数:101,


示例14: oe_encode

int oe_encode ( oe_enc_opt* opt ){	ogg_stream_state os;	ogg_page 		 og;	ogg_packet 		 op;	vorbis_dsp_state vd;	vorbis_block     vb;	vorbis_info      vi;	long	samplesdone   = 0;    int		eos;	long	bytes_written = 0;	long	packetsdone   = 0;	int		ret           = 0;		vorbis_info_init ( &vi );	if ( opt->quality >= 0.0f )	{		if ( vorbis_encode_init_vbr ( &vi, opt->channels, opt->rate, opt->quality ) )		{			vorbis_info_clear ( &vi );			return 1;		}	}	else	{		if ( vorbis_encode_init ( 									&vi,									opt->channels,									opt->rate,									opt->max_bitrate > 0 ? opt->max_bitrate * 1000 : -1,									opt->bitrate * 1000, 									opt->min_bitrate > 0 ? opt->min_bitrate * 1000 : -1								) )		{			vorbis_info_clear ( &vi );			return 1;		}	}	vorbis_analysis_init ( &vd, &vi );	vorbis_block_init    ( &vd, &vb );	ogg_stream_init ( &os, opt->serialno );	ogg_packet header_main;	ogg_packet header_comments;	ogg_packet header_codebooks;	int result;	vorbis_analysis_headerout ( &vd,opt->comments, &header_main, &header_comments, &header_codebooks );	ogg_stream_packetin ( &os, &header_main );	ogg_stream_packetin ( &os, &header_comments );	ogg_stream_packetin ( &os, &header_codebooks );	while ( ( result = ogg_stream_flush ( &os, &og ) ) )	{		if ( !result )			break;				ret = oe_write_page ( &og, opt->out );		if ( ret != og.header_len + og.body_len )		{			ret = 1;			goto cleanup;		}		else			bytes_written += ret;	}		eos = 0;	while ( !eos )	{		float** buffer       = vorbis_analysis_buffer ( &vd, READSIZE );		long    samples_read = opt->read_samples ( opt->readdata, buffer, READSIZE );		if ( samples_read == 0 )			vorbis_analysis_wrote ( &vd, 0 );		else		{			samplesdone += samples_read;			vorbis_analysis_wrote ( &vd, samples_read );		}		while ( vorbis_analysis_blockout ( &vd, &vb ) == 1 )		{			vorbis_analysis         ( &vb, NULL );			vorbis_bitrate_addblock ( &vb );			while ( vorbis_bitrate_flushpacket ( &vd, &op ) )			{				ogg_stream_packetin ( &os,&op );				packetsdone++;//.........这里部分代码省略.........
开发者ID:Fliper12,项目名称:darkbasicpro,代码行数:101,


示例15: Kernel

void CDemoVideoRecorder::Init(int Width, int Height, int FPS, int Format, const char *pName){    m_pSound = Kernel()->RequestInterface<ISound>();    m_FPS = FPS;    m_ScreenWidth = Width;    m_ScreenHeight = Height;    m_Format = Format;    if (m_Format == IClient::DEMO_RECORD_FORMAT_OGV)    {        ogg_stream_init(&m_TheoraOggStreamState, rand());        ogg_stream_init(&m_VorbisOggStreamState, rand());        char aBuf[1024];        if (str_find_rev(pName, "/"))            str_format(aBuf, sizeof(aBuf), "%s.ogv", str_find_rev(pName, "/"));        else if (str_find_rev(aBuf, "//"))            str_format(aBuf, sizeof(pName), "%s.ogv", str_find_rev(pName, "//"));        else            str_format(aBuf, sizeof(aBuf), "%s.ogv", pName);        m_OggFile = io_open(aBuf, IOFLAG_WRITE);        //thread_sleep(10000);        vorbis_info_init(&m_VorbisEncodingInfo);        vorbis_encode_init_vbr(&m_VorbisEncodingInfo, 2, g_Config.m_SndRate, 1.0f); //2 ch - samplerate - quality 1        vorbis_analysis_init(&m_VorbisState, &m_VorbisEncodingInfo);        vorbis_block_init(&m_VorbisState, &m_VorbisBlock);        vorbis_comment_init(&m_VorbisComment);        ogg_packet header;        ogg_packet header_comm;        ogg_packet header_code;        vorbis_analysis_headerout(&m_VorbisState, &m_VorbisComment, &header, &header_comm, &header_code);        ogg_stream_packetin(&m_VorbisOggStreamState, &header);        ogg_stream_packetin(&m_VorbisOggStreamState, &header_comm);        ogg_stream_packetin(&m_VorbisOggStreamState, &header_code);        th_info_init(&m_TheoraEncodingInfo);        m_TheoraEncodingInfo.frame_width = m_ScreenWidth+15&~0xF;        m_TheoraEncodingInfo.frame_height = m_ScreenHeight+15&~0xF;        m_TheoraEncodingInfo.pic_width = m_ScreenWidth;        m_TheoraEncodingInfo.pic_height = m_ScreenHeight;        m_TheoraEncodingInfo.pic_x = m_TheoraEncodingInfo.frame_width - m_ScreenWidth>>1&~1;        m_TheoraEncodingInfo.pic_y = m_TheoraEncodingInfo.frame_height - m_ScreenHeight>>1&~1;        m_TheoraEncodingInfo.colorspace = TH_CS_UNSPECIFIED;        m_TheoraEncodingInfo.fps_numerator = FPS; //fps        m_TheoraEncodingInfo.fps_denominator = 1;        m_TheoraEncodingInfo.aspect_numerator = -1;        m_TheoraEncodingInfo.aspect_denominator = -1;        m_TheoraEncodingInfo.pixel_fmt = TH_PF_444;        m_TheoraEncodingInfo.target_bitrate = (int)(64870*(ogg_int64_t)48000>>16);        m_TheoraEncodingInfo.quality = 32;        m_TheoraEncodingInfo.keyframe_granule_shift = 0;        m_pThreoraContext = th_encode_alloc(&m_TheoraEncodingInfo);        int arg = TH_RATECTL_CAP_UNDERFLOW;        th_encode_ctl(m_pThreoraContext, TH_ENCCTL_SET_RATE_FLAGS, &arg, sizeof(arg));        th_comment CommentHeader;        ogg_packet OggPacket;        th_comment_init(&CommentHeader);        mem_zero(&OggPacket, sizeof(OggPacket));            //Flush        //Step 1        th_encode_flushheader(m_pThreoraContext, &CommentHeader, &OggPacket); // first header        ogg_stream_packetin(&m_TheoraOggStreamState, &OggPacket);        //        ogg_page OggPage;        ogg_stream_pageout(&m_TheoraOggStreamState, &OggPage);        io_write(m_OggFile, OggPage.header, OggPage.header_len);        io_write(m_OggFile, OggPage.body, OggPage.body_len);        while(1)        {            ogg_page OggPage;            if (ogg_stream_flush(&m_VorbisOggStreamState,&OggPage) == 0)                break;            io_write(m_OggFile, OggPage.header, OggPage.header_len);            io_write(m_OggFile, OggPage.body, OggPage.body_len);        }        while(th_encode_flushheader(m_pThreoraContext, &CommentHeader, &OggPacket))        {            ogg_stream_packetin(&m_TheoraOggStreamState, &OggPacket);        }        ogg_stream_flush(&m_TheoraOggStreamState, &OggPage);        io_write(m_OggFile, OggPage.header, OggPage.header_len);        io_write(m_OggFile, OggPage.body, OggPage.body_len);    }
开发者ID:Kebein,项目名称:teeworlds,代码行数:92,


示例16: ADM_assert

//________________________________________________//   Init lame encoder// frequence    : Impose frequency , 0 means reuse the incoming fq// mode                         : ADM_STEREO etc...// bitrate              : Bitrate in kbps (96,192...)// return 0 : init failed//                              1 : init succeeded//_______________________________________________uint8_t AUDMEncoder_Vorbis::init(ADM_audioEncoderDescriptor *config){  int ret;  VORBIS_encoderParam *vorbisConf=(VORBIS_encoderParam *)config->param;  ADM_assert(config->paramSize==sizeof(VORBIS_encoderParam));  ogg_packet header1,header2,header3;  int err;      vorbis_info_init(&VI) ;  switch(vorbisConf->mode)  {        case ADM_VORBIS_VBR:                      err=vorbis_encode_init(&VI,                              _wavheader->channels,                              _wavheader->frequency,                              -1, // Max bitrate                                    config->bitrate*1000, //long nominal_bitrate,                              -1 //long min_bitrate))                            );                      break;    case  ADM_VORBIS_QUALITY :                    err=vorbis_encode_init_vbr(&VI,                                _wavheader->channels,                                _wavheader->frequency,                                vorbisConf->quality/10                              );                    break;          default:      ADM_assert(0);  }  if (err!=0)   {	  delete (vorbisStruct*)_handle;	  _handle = NULL;    printf("[vorbis] init error %d/n",err);    return 0;  }  vorbis_analysis_init(&VD, &VI) ;  vorbis_block_init(&VD, &VB);  vorbis_comment_init(&VC);  vorbis_comment_add_tag(&VC, "encoder", "AVIDEMUX2") ;  vorbis_analysis_headerout(&VD, &VC, &header1,                             &header2, &header3);// Store all headers as extra data// see ogg vorbis decode for details// we need 3 packets  _extraSize=header1.bytes+header2.bytes+header3.bytes+3*sizeof(uint32_t);  _extraData=new uint8_t[_extraSize];  uint32_t *ex=(uint32_t *)_extraData;  uint8_t *d;  d=_extraData+sizeof(uint32_t)*3;  ex[0]=header1.bytes;  ex[1]=header2.bytes;  ex[2]=header3.bytes;  memcpy(d,header1.packet,ex[0]);  d+=ex[0];  memcpy(d,header2.packet,ex[1]);  d+=ex[1];  memcpy(d,header3.packet,ex[2]);  vorbis_comment_clear(&VC);			  printf("/n[Vorbis]Vorbis encoder initialized/n");  switch(vorbisConf->mode)  {    case ADM_VORBIS_VBR:      printf("[Vorbis]CBR Bitrate:%lu/n",config->bitrate);      break;    case ADM_VORBIS_QUALITY: //FIXME FIXME FIXME      printf("[Vorbis]VBR Quality:%.1f/n",vorbisConf->quality);    break;    default:      ADM_assert(0);  }     printf("[Vorbis]Channels  :%lu/n",_wavheader->channels);  printf("[Vorbis]Frequency :%lu/n",_wavheader->frequency);  return 1;}
开发者ID:BackupTheBerlios,项目名称:avidemux-svn,代码行数:98,


示例17: print

//.........这里部分代码省略.........				struct ovectl_ratemanage_arg extraParam;				vorbis_encode_ctl(&vi, OV_ECTL_RATEMANAGE_GET, &extraParam);				extraParam.bitrate_hard_min = (oggparms.minBitr > 0 ? (1000 * oggparms.minBitr) : -1);				extraParam.bitrate_hard_max = (oggparms.maxBitr > 0 ? (1000 * oggparms.maxBitr) : -1);				extraParam.management_active = 1;				vorbis_encode_ctl(&vi, OV_ECTL_RATEMANAGE_SET, &extraParam);				if (!oggparms.silent) {					sprintf(outputString + strlen(outputString), " using constrained VBR (");					if (oggparms.minBitr != -1) {						sprintf(outputString + strlen(outputString), "min %i kbps, ", oggparms.minBitr);					} else {						sprintf(outputString + strlen(outputString), "no min, ");					}					if (oggparms.maxBitr != -1) {						sprintf(outputString + strlen(outputString), "max %i kbps)/nSet optional hard quality restrictions/n", oggparms.maxBitr);					} else {						sprintf(outputString + strlen(outputString), "no max)/nSet optional hard quality restrictions/n");					}				}			} else {				sprintf(outputString + strlen(outputString), "/n");			}		}		puts(outputString);		vorbis_encode_setup_init(&vi);		vorbis_comment_init(&vc);		vorbis_analysis_init(&vd, &vi);		vorbis_block_init(&vd, &vb);		ogg_stream_init(&os, 0);		vorbis_analysis_headerout(&vd, &vc, &header, &header_comm, &header_code);		ogg_stream_packetin(&os, &header);		ogg_stream_packetin(&os, &header_comm);		ogg_stream_packetin(&os, &header_code);		while (!eos) {			int result = ogg_stream_flush(&os,&og);			if (result == 0) {				break;			}			outputOgg.write(og.header, og.header_len);			outputOgg.write(og.body, og.body_len);		}		while (!eos) {			int numSamples = ((samplesLeft < 2048) ? samplesLeft : 2048);			float **buffer = vorbis_analysis_buffer(&vd, numSamples);			/* We must tell the encoder that we have reached the end of the stream */			if (numSamples == 0) {				vorbis_analysis_wrote(&vd, 0);			} else {				/* Adapted from oggenc 1.1.1 */				if (rawAudioType.bitsPerSample == 8) {					const byte *rawDataUnsigned = (const byte *)rawData;					for (int i = 0; i < numSamples; i++) {						for (int j = 0; j < numChannels; j++) {
开发者ID:alexbevi,项目名称:scummvm-tools,代码行数:67,


示例18: encode_ogg

static int encode_ogg (cdrom_drive *drive, rip_opts_s *rip_opts,		       text_tag_s *text_tag, int track,		       int tracktot, char *filename, char **filenames){  ogg_stream_state os;  ogg_page og;  ogg_packet op;  vorbis_dsp_state vd;  vorbis_block vb;  vorbis_info vi;  long samplesdone = 0;  int sector = 0, last_sector = 0;  long bytes_written = 0, packetsdone = 0;  double time_elapsed = 0.0;  int ret = 0;  time_t *timer;  double time;    int serialno = rand ();  vorbis_comment vc;  long total_samples_per_channel = 0;  int channels = 2;  int eos = 0;  long rate = 44100;  FILE *out = fopen (filename, "w+");  timer = timer_start ();  if (!rip_opts->managed && (rip_opts->min_bitrate > 0 || rip_opts->max_bitrate > 0)) {    log_msg ("Min or max bitrate requires managed", FL, FN, LN);    return -1;  }  if (rip_opts->bitrate < 0 && rip_opts->min_bitrate < 0 && rip_opts->max_bitrate < 0) {    rip_opts->quality_set = 1;  }    start_func (filename, rip_opts->bitrate, rip_opts->quality, rip_opts->quality_set,	      rip_opts->managed, rip_opts->min_bitrate, rip_opts->max_bitrate);    vorbis_info_init (&vi);  if (rip_opts->quality_set > 0) {    if (vorbis_encode_setup_vbr (&vi, channels, rate, rip_opts->quality)) {      log_msg ("Couldn't initialize vorbis_info", FL, FN, LN);      vorbis_info_clear (&vi);      return -1;    }    /* two options here, max or min bitrate */    if (rip_opts->max_bitrate > 0 || rip_opts->min_bitrate > 0) {      struct ovectl_ratemanage_arg ai;      vorbis_encode_ctl (&vi, OV_ECTL_RATEMANAGE_GET, &ai);      ai.bitrate_hard_min = rip_opts->min_bitrate;      ai.bitrate_hard_max = rip_opts->max_bitrate;      ai.management_active = 1;      vorbis_encode_ctl (&vi, OV_ECTL_RATEMANAGE_SET, &ai);    }  } else {    if (vorbis_encode_setup_managed (&vi, channels, rate,				     rip_opts->max_bitrate > 0 ? rip_opts->max_bitrate * 1000 : -1,				     rip_opts->bitrate * 1000,				     rip_opts->min_bitrate > 0 ? rip_opts->min_bitrate * 1000 : -1)) {      log_msg ("Mode init failed, encode setup managed", FL, FN, LN);      vorbis_info_clear (&vi);      return -1;    }  }  if (rip_opts->managed && rip_opts->bitrate < 0) {    vorbis_encode_ctl (&vi, OV_ECTL_RATEMANAGE_AVG, NULL);  } else if (!rip_opts->managed) {    vorbis_encode_ctl (&vi, OV_ECTL_RATEMANAGE_SET, NULL);  }  /* set advanced encoder options */  vorbis_encode_setup_init (&vi);  vorbis_analysis_init (&vd, &vi);  vorbis_block_init (&vd, &vb);  ogg_stream_init (&os, serialno);  {    ogg_packet header_main;    ogg_packet header_comments;    ogg_packet header_codebooks;    int result;    char buf[32];    vorbis_comment_init (&vc);    vorbis_comment_add_tag (&vc, "title", text_tag->songname);    vorbis_comment_add_tag (&vc, "artist", text_tag->artistname);    vorbis_comment_add_tag (&vc, "album", text_tag->albumname);    vorbis_comment_add_tag (&vc, "genre", text_tag->genre);    snprintf (buf, 32, "%d", text_tag->year);    vorbis_comment_add_tag (&vc, "date", buf);    snprintf (buf, 32, "%02d", text_tag->track);//.........这里部分代码省略.........
开发者ID:tedkulp,项目名称:bossogg,代码行数:101,


示例19: WXUNUSED

int ExportOGG::Export(AudacityProject *project,                       int numChannels,                       const wxString &fName,                       bool selectionOnly,                       double t0,                       double t1,                       MixerSpec *mixerSpec,                       const Tags *metadata,                       int WXUNUSED(subformat)){   double    rate    = project->GetRate();   const TrackList *tracks = project->GetTracks();   double    quality = (gPrefs->Read(wxT("/FileFormats/OggExportQuality"), 50)/(float)100.0);   wxLogNull logNo;            // temporarily disable wxWidgets error messages   int updateResult = eProgressSuccess;   int       eos = 0;   FileIO outFile(fName, FileIO::Output);   if (!outFile.IsOpened()) {      wxMessageBox(_("Unable to open target file for writing"));      return false;   }   // All the Ogg and Vorbis encoding data   ogg_stream_state stream;   ogg_page         page;   ogg_packet       packet;   vorbis_info      info;   vorbis_comment   comment;   vorbis_dsp_state dsp;   vorbis_block     block;   // Encoding setup   vorbis_info_init(&info);   vorbis_encode_init_vbr(&info, numChannels, int(rate + 0.5), quality);   // Retrieve tags   if (!FillComment(project, &comment, metadata)) {      return false;   }   // Set up analysis state and auxiliary encoding storage   vorbis_analysis_init(&dsp, &info);   vorbis_block_init(&dsp, &block);   // Set up packet->stream encoder.  According to encoder example,   // a random serial number makes it more likely that you can make   // chained streams with concatenation.   srand(time(NULL));   ogg_stream_init(&stream, rand());   // First we need to write the required headers:   //    1. The Ogg bitstream header, which contains codec setup params   //    2. The Vorbis comment header   //    3. The bitstream codebook.   //   // After we create those our responsibility is complete, libvorbis will   // take care of any other ogg bistream constraints (again, according   // to the example encoder source)   ogg_packet bitstream_header;   ogg_packet comment_header;   ogg_packet codebook_header;   vorbis_analysis_headerout(&dsp, &comment, &bitstream_header, &comment_header,         &codebook_header);   // Place these headers into the stream   ogg_stream_packetin(&stream, &bitstream_header);   ogg_stream_packetin(&stream, &comment_header);   ogg_stream_packetin(&stream, &codebook_header);   // Flushing these headers now guarentees that audio data will   // start on a NEW page, which apparently makes streaming easier   while (ogg_stream_flush(&stream, &page)) {      outFile.Write(page.header, page.header_len);      outFile.Write(page.body, page.body_len);   }   const WaveTrackConstArray waveTracks =      tracks->GetWaveTrackConstArray(selectionOnly, false);   {      auto mixer = CreateMixer(waveTracks,         tracks->GetTimeTrack(),         t0, t1,         numChannels, SAMPLES_PER_RUN, false,         rate, floatSample, true, mixerSpec);      ProgressDialog progress(wxFileName(fName).GetName(),         selectionOnly ?         _("Exporting the selected audio as Ogg Vorbis") :         _("Exporting the entire project as Ogg Vorbis"));      while (updateResult == eProgressSuccess && !eos) {         float **vorbis_buffer = vorbis_analysis_buffer(&dsp, SAMPLES_PER_RUN);         sampleCount samplesThisRun = mixer->Process(SAMPLES_PER_RUN);         if (samplesThisRun == 0) {//.........这里部分代码省略.........
开发者ID:AthiVarathan,项目名称:audacity,代码行数:101,


示例20: eprintf

// Just create the Quicktime objects since this routine is also called// for reopening.int FileVorbis::open_file(int rd, int wr){	int result = 0;	this->rd = rd;	this->wr = wr;//printf("FileVorbis::open_file 1/n");	if(rd)	{//printf("FileVorbis::open_file 1/n");		if(!(fd = fopen(asset->path, "rb")))		{			eprintf("Error while opening /"%s/" for reading. /n%m/n", asset->path);			result = 1;		}		else		{//printf("FileVorbis::open_file 2 %p %p/n", fd, vf);			if(ov_open(fd, &vf, NULL, 0) < 0)			{				eprintf("Invalid bitstream in %s/n", asset->path);				result = 1;			}			else			{//printf("FileVorbis::open_file 1/n");				vorbis_info *vi = ov_info(&vf, -1);				asset->channels = vi->channels;				if(!asset->sample_rate)					asset->sample_rate = vi->rate;//printf("FileVorbis::open_file 1/n");				asset->audio_length = ov_pcm_total(&vf,-1);//printf("FileVorbis::open_file 1/n");				asset->audio_data = 1;// printf("FileVorbis::open_file 1 %d %d %d/n", // asset->channels, // asset->sample_rate, // asset->audio_length);			}		}	}	if(wr)	{		if(!(fd = fopen(asset->path, "wb")))		{			eprintf("Error while opening /"%s/" for writing. /n%m/n", asset->path);			result = 1;		}		else		{			vorbis_info_init(&vi);			if(!asset->vorbis_vbr)				result = vorbis_encode_init(&vi, 					asset->channels, 					asset->sample_rate, 					asset->vorbis_max_bitrate, 					asset->vorbis_bitrate, 					asset->vorbis_min_bitrate);			else			{				result = vorbis_encode_setup_managed(&vi,					asset->channels, 					asset->sample_rate, 					asset->vorbis_max_bitrate, 					asset->vorbis_bitrate, 					asset->vorbis_min_bitrate);				result |= vorbis_encode_ctl(&vi, OV_ECTL_RATEMANAGE_AVG, NULL);				result |= vorbis_encode_setup_init(&vi);			}			if(!result)			{				vorbis_analysis_init(&vd, &vi);				vorbis_block_init(&vd, &vb);				vorbis_comment_init(&vc);				srand(time(NULL));				ogg_stream_init(&os, rand());				ogg_packet header;				ogg_packet header_comm;				ogg_packet header_code;				vorbis_analysis_headerout(&vd, 					&vc,					&header,					&header_comm,					&header_code);				ogg_stream_packetin(&os,					&header);				ogg_stream_packetin(&os, 					&header_comm);				ogg_stream_packetin(&os,					&header_code);				while(1)				{					int result = ogg_stream_flush(&os, &og);					if(result == 0) break;//.........这里部分代码省略.........
开发者ID:beequ7et,项目名称:cinelerra-cv,代码行数:101,


示例21: Start

bool Start(void *ctx, int iInChannels, int iInRate, int iInBits,          const char* title, const char* artist,          const char* albumartist, const char* album,          const char* year, const char* track, const char* genre,          const char* comment, int iTrackLength){  ogg_context *context = (ogg_context *)ctx;  if (!context || !context->callbacks.write)    return false;  // we accept only 2 ch 16bit atm  if (iInChannels != 2 || iInBits != 16)    return false;  if (preset == -1)    vorbis_encode_init(&context->vorbisInfo, iInChannels, iInRate, -1, bitrate*1000, -1);  else    vorbis_encode_init_vbr(&context->vorbisInfo, iInChannels, iInRate, float(preset)/10.0f);  /* add a comment */  vorbis_comment comm;  vorbis_comment_init(&comm);  vorbis_comment_add_tag(&comm, (char*)"comment", (char*)comment);  vorbis_comment_add_tag(&comm, (char*)"artist", (char*)artist);  vorbis_comment_add_tag(&comm, (char*)"title", (char*)title);  vorbis_comment_add_tag(&comm, (char*)"album", (char*)album);  vorbis_comment_add_tag(&comm, (char*)"albumartist", (char*)albumartist);  vorbis_comment_add_tag(&comm, (char*)"genre", (char*)genre);  vorbis_comment_add_tag(&comm, (char*)"tracknumber", (char*)track);  vorbis_comment_add_tag(&comm, (char*)"date", (char*)year);  /* set up the analysis state and auxiliary encoding storage */  vorbis_analysis_init(&context->vorbisDspState, &context->vorbisInfo);  vorbis_block_init(&context->vorbisDspState, &context->vorbisBlock);  /* set up our packet->stream encoder */  /* pick a random serial number; that way we can more likely build  chained streams just by concatenation */  srand((unsigned int)time(NULL));  ogg_stream_init(&context->oggStreamState, rand());  /* write out the metadata */  ogg_packet header;  ogg_packet header_comm;  ogg_packet header_code;  ogg_page   page;  vorbis_analysis_headerout(&context->vorbisDspState, &comm,                            &header, &header_comm, &header_code);  ogg_stream_packetin(&context->oggStreamState, &header);  ogg_stream_packetin(&context->oggStreamState, &header_comm);  ogg_stream_packetin(&context->oggStreamState, &header_code);  while (1)  {    /* This ensures the actual     * audio data will start on a new page, as per spec     */    int result = ogg_stream_flush(&context->oggStreamState, &page);    if (result == 0)      break;    context->callbacks.write(context->callbacks.opaque, page.header, page.header_len);    context->callbacks.write(context->callbacks.opaque, page.body, page.body_len);  }  vorbis_comment_clear(&comm);  context->inited = true;  return true;}
开发者ID:jmarshallnz,项目名称:audioencoder.vorbis,代码行数:71,


示例22: vorbis_info_init

//________________________________________________//   Init Vorbis encoder// frequence    : Impose frequency , 0 means reuse the incoming fq// mode			: VBR CBR// bitrate for CBR	: bitrate in kbps (96,192...)//		  for VBR	: quality (0, 1, 2, ... 11)//				// return 0 : init failed//                              1 : init succeeded//_______________________________________________uint8_t AVDMProcessAudio_Vorbis::init( uint32_t bitrate, uint8_t mode){	ogg_packet header1,header2,header3;	int err; 	vorbis_info_init(&VI) ; 	if (mode==0) {  //VBR		err=vorbis_encode_init_vbr(&VI,			      _wavheader->channels,			       _wavheader->frequency,			      ((float)bitrate-1)/10			      );	} else {  //CBR		err=vorbis_encode_init(&VI,			      _wavheader->channels,			       _wavheader->frequency,			      -1, // Max bitrate      			      bitrate*1000, //long nominal_bitrate,			      -1 //long min_bitrate))			      );	}	if (err!=0) {		printf("vorbis init error/n");		return 0;	}	vorbis_analysis_init(&VD, &VI) ;	vorbis_block_init(&VD, &VB);      	vorbis_comment_init(&VC);	vorbis_comment_add_tag(&VC, "encoder", "AVIDEMUX2") ;		vorbis_analysis_headerout(&VD, &VC, &header1,                                &header2, &header3);					// Store all headers as extra data	// see ogg vorbis decode for details	// we need 3 packets		_extraLen=header1.bytes+header2.bytes+header3.bytes+3*sizeof(uint32_t);	_extraData=new uint8_t[_extraLen];		uint32_t *ex=(uint32_t *)_extraData;	uint8_t *d;	d=_extraData+sizeof(uint32_t)*3;	ex[0]=header1.bytes;	ex[1]=header2.bytes;	ex[2]=header3.bytes;	memcpy(d,header1.packet,ex[0]);	d+=ex[0];	memcpy(d,header2.packet,ex[1]);	d+=ex[1];	memcpy(d,header3.packet,ex[2]);	vorbis_comment_clear(&VC);				printf("/nVorbis encoder initialized/n");	if (mode==0)		printf("VBR Quality:%i/n",bitrate-1);	else		printf("CBR Bitrate:%lu/n",bitrate);	printf("Channels:%lu/n",_wavheader->channels);	printf("Frequenc:%lu/n",_wavheader->frequency);    return 1;}
开发者ID:BackupTheBerlios,项目名称:avidemux-svn,代码行数:74,


示例23: encode_vorbis_file

//.........这里部分代码省略.........	 } 	 	 /********** Encode setup ************/	 	 /* choose an encoding mode */	 /* (mode 0: 44kHz stereo uncoupled, roughly 128kbps VBR) */	 vorbis_info_init(&vi);	 // always encode to mono	 // SL-52913 & SL-53779 determined this quality level to be our 'good	 // enough' general-purpose quality level with a nice low bitrate.	 // Equivalent to oggenc -q0.5	 F32 quality = 0.05f;//	 quality = (bitrate==128000 ? 0.4f : 0.1);//	 if (vorbis_encode_init(&vi, /* num_channels */ 1 ,sample_rate, -1, bitrate, -1))	 if (vorbis_encode_init_vbr(&vi, /* num_channels */ 1 ,sample_rate, quality))//	 if (vorbis_encode_setup_managed(&vi,1,sample_rate,-1,bitrate,-1) ||//		vorbis_encode_ctl(&vi,OV_ECTL_RATEMANAGE_AVG,NULL) ||//		vorbis_encode_setup_init(&vi))	{		llwarns << "unable to initialize vorbis codec at quality " << quality << llendl;		//		llwarns << "unable to initialize vorbis codec at bitrate " << bitrate << llendl;		return(LLVORBISENC_DEST_OPEN_ERR);	}	 	 /* add a comment */	 vorbis_comment_init(&vc);//	 vorbis_comment_add(&vc,"Linden");	 	 /* set up the analysis state and auxiliary encoding storage */	 vorbis_analysis_init(&vd,&vi);	 vorbis_block_init(&vd,&vb);	 	 /* set up our packet->stream encoder */	 /* pick a random serial number; that way we can more likely build		chained streams just by concatenation */	 ogg_stream_init(&os, ll_rand());	 	 /* Vorbis streams begin with three headers; the initial header (with		most of the codec setup parameters) which is mandated by the Ogg		bitstream spec.  The second header holds any comment fields.  The		third header holds the bitstream codebook.  We merely need to		make the headers, then pass them to libvorbis one at a time;		libvorbis handles the additional Ogg bitstream constraints */	 	 {		 ogg_packet header;		 ogg_packet header_comm;		 ogg_packet header_code;		 		 vorbis_analysis_headerout(&vd,&vc,&header,&header_comm,&header_code);		 ogg_stream_packetin(&os,&header); /* automatically placed in its own											  page */		 ogg_stream_packetin(&os,&header_comm);		 ogg_stream_packetin(&os,&header_code);		 		 /* We don't have to write out here, but doing so makes streaming 		  * much easier, so we do, flushing ALL pages. This ensures the actual		  * audio data will start on a new page		  */		 while(!eos){			 int result=ogg_stream_flush(&os,&og);			 if(result==0)break;
开发者ID:1234-,项目名称:SingularityViewer,代码行数:67,


示例24: encvorbisInit

int encvorbisInit( hb_work_object_t * w, hb_job_t * job ){    hb_audio_t * audio = w->audio;    int i;    ogg_packet header[3];    hb_work_private_t * pv = calloc( 1, sizeof( hb_work_private_t ) );    w->private_data = pv;    pv->out_discrete_channels = HB_AMIXDOWN_GET_DISCRETE_CHANNEL_COUNT(audio->config.out.mixdown);    pv->job   = job;    hb_log( "encvorbis: opening libvorbis" );    /* init */    for( i = 0; i < 3; i++ )    {        // Zero vorbis headers so that we don't crash in mk_laceXiph        // when vorbis_encode_setup_managed fails.        memset( w->config->vorbis.headers[i], 0, sizeof( ogg_packet ) );    }    vorbis_info_init( &pv->vi );    if( audio->config.out.bitrate > 0 )    {        /* 28kbps/channel seems to be the minimum for 6ch vorbis. */        int min_bitrate = 28 * pv->out_discrete_channels;        if (pv->out_discrete_channels > 2 && audio->config.out.bitrate < min_bitrate)        {            hb_log( "encvorbis: Selected bitrate (%d kbps) too low for %d channel audio.", audio->config.out.bitrate, pv->out_discrete_channels);            hb_log( "encvorbis: Resetting bitrate to %d kbps", min_bitrate);            /* Naughty! We shouldn't modify the audio from here. */            audio->config.out.bitrate = min_bitrate;        }        if( vorbis_encode_setup_managed( &pv->vi, pv->out_discrete_channels,              audio->config.out.samplerate, -1, 1000 * audio->config.out.bitrate, -1 ) )        {            hb_error( "encvorbis: vorbis_encode_setup_managed failed./n" );            *job->die = 1;            return -1;        }    }    else if( audio->config.out.quality != -1 )    {        // map VBR quality to Vorbis API (divide by 10)        if( vorbis_encode_setup_vbr( &pv->vi, pv->out_discrete_channels,              audio->config.out.samplerate, audio->config.out.quality/10 ) )        {            hb_error( "encvorbis: vorbis_encode_setup_vbr failed./n" );            *job->die = 1;            return -1;        }    }    if( vorbis_encode_ctl( &pv->vi, OV_ECTL_RATEMANAGE2_SET, NULL ) ||          vorbis_encode_setup_init( &pv->vi ) )    {        hb_error( "encvorbis: vorbis_encode_ctl( ratemanage2_set ) OR vorbis_encode_setup_init failed./n" );        *job->die = 1;        return -1;    }    /* add a comment */    vorbis_comment_init( &pv->vc );    vorbis_comment_add_tag( &pv->vc, "Encoder", "HandBrake");    vorbis_comment_add_tag( &pv->vc, "LANGUAGE", w->config->vorbis.language);    /* set up the analysis state and auxiliary encoding storage */    vorbis_analysis_init( &pv->vd, &pv->vi);    vorbis_block_init( &pv->vd, &pv->vb);    /* get the 3 headers */    vorbis_analysis_headerout( &pv->vd, &pv->vc,                               &header[0], &header[1], &header[2] );    for( i = 0; i < 3; i++ )    {        memcpy( w->config->vorbis.headers[i], &header[i],                sizeof( ogg_packet ) );        memcpy( w->config->vorbis.headers[i] + sizeof( ogg_packet ),                header[i].packet, header[i].bytes );    }    pv->input_samples = pv->out_discrete_channels * OGGVORBIS_FRAME_SIZE;    audio->config.out.samples_per_frame = OGGVORBIS_FRAME_SIZE;    pv->buf = malloc( pv->input_samples * sizeof( float ) );    pv->list = hb_list_init();    switch (pv->out_discrete_channels) {        case 1:            pv->channel_map[0] = 0;            break;        case 6:            // Vorbis uses the following channel map = L C R Ls Rs Lfe            if( audio->config.in.channel_map == &hb_ac3_chan_map )            {                pv->channel_map[0] = 1;                pv->channel_map[1] = 2;                pv->channel_map[2] = 3;//.........这里部分代码省略.........
开发者ID:GunioRobot,项目名称:HandBrake,代码行数:101,


示例25: lame_encode_ogg_init

int lame_encode_ogg_init(lame_global_flags *gfp){  lame_internal_flags *gfc=gfp->internal_flags;  char comment[MAX_COMMENT_LENGTH+1];    /********** Encode setup ************/    /* choose an encoding mode */  /* (mode 0: 44kHz stereo uncoupled, roughly 128kbps VBR) */  if (gfp->compression_ratio < 5.01) {    memcpy(&vi2,&info_E,sizeof(vi2));    MSGF( gfc, "Encoding with Vorbis mode info_E /n" );  } else if (gfp->compression_ratio < 6) {    memcpy(&vi2,&info_D,sizeof(vi2));    MSGF( gfc, "Encoding with Vorbis mode info_D /n" );  } else if (gfp->compression_ratio < 8) {    memcpy(&vi2,&info_C,sizeof(vi2));    MSGF( gfc, "Encoding with Vorbis mode info_C /n" );  } else if (gfp->compression_ratio < 10) {    memcpy(&vi2,&info_B,sizeof(vi2));    MSGF( gfc, "Encoding with Vorbis mode info_B /n" );  } else if (gfp->compression_ratio < 12) {    memcpy(&vi2,&info_A,sizeof(vi2));    MSGF( gfc, "Encoding with Vorbis mode info_A /n" );  } else {    memcpy(&vi2,&info_A,sizeof(vi2));    MSGF( gfc, "Encoding with Vorbis mode info_A /n" );  }  vi2.channels = gfc->channels_out;  vi2.rate = gfp->out_samplerate;    /* add a comment */  vorbis_comment_init(&vc2);  vorbis_comment_add(&vc2,"Track encoded using L.A.M.E. libvorbis interface.");  /* Add ID3-style comments to the output using (for the time being) the     "private data members" in the "id3tag_spec" data structure. This was     from a patch by Ralph Giles <[email
C++ vorbis_analysis_wrote函数代码示例
C++ vorbis_analysis_buffer函数代码示例
万事OK自学网:51自学网_软件自学网_CAD自学网自学excel、自学PS、自学CAD、自学C语言、自学css3实例,是一个通过网络自主学习工作技能的自学平台,网友喜欢的软件自学网站。