这篇教程C++ vorbis_info_init函数代码示例写得很实用,希望能帮到您。
本文整理汇总了C++中vorbis_info_init函数的典型用法代码示例。如果您正苦于以下问题:C++ vorbis_info_init函数的具体用法?C++ vorbis_info_init怎么用?C++ vorbis_info_init使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。 在下文中一共展示了vorbis_info_init函数的28个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的C++代码示例。 示例1: ogg_vorbis_rewrite/*! * /brief Create a new OGG/Vorbis filestream and set it up for writing. * /param s File pointer that points to on-disk storage. * /param comment Comment that should be embedded in the OGG/Vorbis file. * /return A new filestream. */static int ogg_vorbis_rewrite(struct ast_filestream *s, const char *comment){ ogg_packet header; ogg_packet header_comm; ogg_packet header_code; struct vorbis_desc *tmp = (struct vorbis_desc *)s->_private; tmp->writing = 1; vorbis_info_init(&tmp->vi); if (vorbis_encode_init_vbr(&tmp->vi, 1, DEFAULT_SAMPLE_RATE, 0.4)) { ast_log(LOG_ERROR, "Unable to initialize Vorbis encoder!/n"); return -1; } vorbis_comment_init(&tmp->vc); vorbis_comment_add_tag(&tmp->vc, "ENCODER", "Asterisk PBX"); if (comment) vorbis_comment_add_tag(&tmp->vc, "COMMENT", (char *) comment); vorbis_analysis_init(&tmp->vd, &tmp->vi); vorbis_block_init(&tmp->vd, &tmp->vb); ogg_stream_init(&tmp->os, ast_random()); vorbis_analysis_headerout(&tmp->vd, &tmp->vc, &header, &header_comm, &header_code); ogg_stream_packetin(&tmp->os, &header); ogg_stream_packetin(&tmp->os, &header_comm); ogg_stream_packetin(&tmp->os, &header_code); while (!tmp->eos) { if (ogg_stream_flush(&tmp->os, &tmp->og) == 0) break; if (!fwrite(tmp->og.header, 1, tmp->og.header_len, s->f)) { ast_log(LOG_WARNING, "fwrite() failed: %s/n", strerror(errno)); } if (!fwrite(tmp->og.body, 1, tmp->og.body_len, s->f)) { ast_log(LOG_WARNING, "fwrite() failed: %s/n", strerror(errno)); } if (ogg_page_eos(&tmp->og)) tmp->eos = 1; } return 0;}
开发者ID:neoplacer,项目名称:gsm_asterisk,代码行数:54,
示例2: oggvorbis_encode_initstatic av_cold int oggvorbis_encode_init(AVCodecContext *avccontext) { OggVorbisContext *context = avccontext->priv_data ; ogg_packet header, header_comm, header_code; uint8_t *p; unsigned int offset, len; vorbis_info_init(&context->vi) ; if(oggvorbis_init_encoder(&context->vi, avccontext) < 0) { av_log(avccontext, AV_LOG_ERROR, "oggvorbis_encode_init: init_encoder failed/n") ; return -1 ; } vorbis_analysis_init(&context->vd, &context->vi) ; vorbis_block_init(&context->vd, &context->vb) ; vorbis_comment_init(&context->vc); vorbis_comment_add_tag(&context->vc, "encoder", LIBAVCODEC_IDENT) ; vorbis_analysis_headerout(&context->vd, &context->vc, &header, &header_comm, &header_code); len = header.bytes + header_comm.bytes + header_code.bytes; avccontext->extradata_size= 64 + len + len/255; p = avccontext->extradata= av_mallocz(avccontext->extradata_size); p[0] = 2; offset = 1; offset += av_xiphlacing(&p[offset], header.bytes); offset += av_xiphlacing(&p[offset], header_comm.bytes); memcpy(&p[offset], header.packet, header.bytes); offset += header.bytes; memcpy(&p[offset], header_comm.packet, header_comm.bytes); offset += header_comm.bytes; memcpy(&p[offset], header_code.packet, header_code.bytes); offset += header_code.bytes; avccontext->extradata_size = offset; avccontext->extradata= av_realloc(avccontext->extradata, avccontext->extradata_size);/* vorbis_block_clear(&context->vb); vorbis_dsp_clear(&context->vd); vorbis_info_clear(&context->vi);*/ vorbis_comment_clear(&context->vc); avccontext->frame_size = OGGVORBIS_FRAME_SIZE ; avccontext->coded_frame= avcodec_alloc_frame(); avccontext->coded_frame->key_frame= 1; return 0 ;}
开发者ID:1Server,项目名称:OneServer-Android,代码行数:48,
示例3: vorbis_info_initvoid WebMEncoder::initializeAudioEncoder() { /* Initialize Vorbis */ vorbis_info_init(&vi); const float QUALITY = 0.4f; int ret2=vorbis_encode_init_vbr(&vi,audioChannels,audioSampleRate,QUALITY); if(ret2) { printf("ERROR: BAD VORBIS INIT/n"); exit(1); } /* add a comment */ vorbis_comment_init(&vc); vorbis_comment_add_tag(&vc,"SOURCE","MAME Game Audio"); /* set up the analysis state and auxiliary encoding storage */ vorbis_analysis_init(&vd,&vi); vorbis_block_init(&vd,&vb);}
开发者ID:Ilgrim,项目名称:MAMEHub,代码行数:16,
示例4: vorbis_startstatic void vorbis_start(stream_processor *stream){ misc_vorbis_info *info; stream->type = "vorbis"; stream->process_page = vorbis_process; stream->process_end = vorbis_end; stream->data = calloc(1, sizeof(misc_vorbis_info)); info = stream->data; vorbis_comment_init(&info->vc); vorbis_info_init(&info->vi);}
开发者ID:jameshilliard,项目名称:WECB-BH-GPL,代码行数:16,
示例5: vorbis_dec_change_statestatic GstStateChangeReturnvorbis_dec_change_state (GstElement * element, GstStateChange transition){ GstVorbisDec *vd = GST_VORBIS_DEC (element); GstStateChangeReturn res; switch (transition) { case GST_STATE_CHANGE_NULL_TO_READY: break; case GST_STATE_CHANGE_READY_TO_PAUSED: vorbis_info_init (&vd->vi); vorbis_comment_init (&vd->vc); vd->initialized = FALSE; gst_vorbis_dec_reset (vd); break; case GST_STATE_CHANGE_PAUSED_TO_PLAYING: break; default: break; } res = parent_class->change_state (element, transition); switch (transition) { case GST_STATE_CHANGE_PLAYING_TO_PAUSED: break; case GST_STATE_CHANGE_PAUSED_TO_READY: GST_DEBUG_OBJECT (vd, "PAUSED -> READY, clearing vorbis structures"); vd->initialized = FALSE;#ifndef USE_TREMOLO vorbis_block_clear (&vd->vb);#endif vorbis_dsp_clear (&vd->vd); vorbis_comment_clear (&vd->vc); vorbis_info_clear (&vd->vi); gst_vorbis_dec_reset (vd); break; case GST_STATE_CHANGE_READY_TO_NULL: break; default: break; } return res;}
开发者ID:ChinnaSuhas,项目名称:ossbuild,代码行数:47,
示例6: startRecordingbool startRecording(const char *outputFile){ assert(hasRecordingThread==0); //initialize output file RecordingParams *rp=(RecordingParams*)malloc(sizeof(RecordingParams)); rp->outputFile=fopen(outputFile, "wb"); if (rp->outputFile==NULL) { free(rp); return false; } //initialize vorbis encoder vorbis_info_init(&rp->vi); vorbis_encode_init_vbr(&rp->vi, RecordingNoOfChannels, DefaultSampleRate, .5); vorbis_comment_init(&rp->vc); vorbis_comment_add_tag(&rp->vc,(char*)"ENCODER",(char*)"QGis-mapper ogg encoder"); vorbis_analysis_init(&rp->vd, &rp->vi); vorbis_block_init(&rp->vd, &rp->vb); //initialize ogg output stream srand(time(NULL)); ogg_stream_init(&rp->os,rand()); { ogg_packet header; ogg_packet header_comm; ogg_packet header_code; vorbis_analysis_headerout(&rp->vd,&rp->vc,&header,&header_comm,&header_code); ogg_stream_packetin(&rp->os,&header); ogg_stream_packetin(&rp->os,&header_comm); ogg_stream_packetin(&rp->os,&header_code); ogg_flushall(rp); } //initialize audio buffer pthread_spin_lock(&recBufferLock); recBuffer=sb_createBuffer(); pthread_spin_unlock(&recBufferLock); threadRunStop=0; pthread_create(&recordingThread, NULL, recordingThreadFct, rp); hasRecordingThread=true; return true;}
开发者ID:detlevn,项目名称:qgismapper,代码行数:47,
示例7: vorbis_info_initRefPtr<MediaDataDecoder::InitPromise>VorbisDataDecoder::Init(){ vorbis_info_init(&mVorbisInfo); vorbis_comment_init(&mVorbisComment); PodZero(&mVorbisDsp); PodZero(&mVorbisBlock); AutoTArray<unsigned char*,4> headers; AutoTArray<size_t,4> headerLens; if (!XiphExtradataToHeaders(headers, headerLens, mInfo.mCodecSpecificConfig->Elements(), mInfo.mCodecSpecificConfig->Length())) { return InitPromise::CreateAndReject(DecoderFailureReason::INIT_ERROR, __func__); } for (size_t i = 0; i < headers.Length(); i++) { if (NS_FAILED(DecodeHeader(headers[i], headerLens[i]))) { return InitPromise::CreateAndReject(DecoderFailureReason::INIT_ERROR, __func__); } } MOZ_ASSERT(mPacketCount == 3); int r = vorbis_synthesis_init(&mVorbisDsp, &mVorbisInfo); if (r) { return InitPromise::CreateAndReject(DecoderFailureReason::INIT_ERROR, __func__); } r = vorbis_block_init(&mVorbisDsp, &mVorbisBlock); if (r) { return InitPromise::CreateAndReject(DecoderFailureReason::INIT_ERROR, __func__); } if (mInfo.mRate != (uint32_t)mVorbisDsp.vi->rate) { LOG(LogLevel::Warning, ("Invalid Vorbis header: container and codec rate do not match!")); } if (mInfo.mChannels != (uint32_t)mVorbisDsp.vi->channels) { LOG(LogLevel::Warning, ("Invalid Vorbis header: container and codec channels do not match!")); } return InitPromise::CreateAndResolve(TrackInfo::kAudioTrack, __func__);}
开发者ID:Shaif95,项目名称:gecko-dev,代码行数:44,
示例8: sizeof void OggWriter::setupEncoder() { vorbis_info * vi = static_cast< vorbis_info * >( std::malloc( sizeof( vorbis_info ) ) ); this->encoder_.reset( vi, vorbisInfoHelper ); vorbis_info_init( vi ); int ret = vorbis_encode_init_vbr( vi, this->getChannels(), this->getSampleRate(), this->quality_ ); if( ret != 0 ) { throw error::CodecError( "Vorbis initialization error" ); } vorbis_dsp_state * vd = static_cast< vorbis_dsp_state * >( std::malloc( sizeof( vorbis_dsp_state ) ) ); this->dsp_.reset( vd, vorbisDSPHelper ); vorbis_analysis_init( vd, vi ); vorbis_block * vb = static_cast< vorbis_block * >( std::malloc( sizeof( vorbis_block ) ) ); this->block_.reset( vb, vorbisBlockHelper ); vorbis_block_init( vd, vb ); this->getSampleBuffer().resize( 1024 * 4 * this->getChannels() ); }
开发者ID:legnaleurc,项目名称:khopper-pkg-debian,代码行数:19,
示例9: vcedit_supported_streamstatic int vcedit_supported_stream(vcedit_state *state, ogg_page *og) { ogg_stream_state os; vorbis_info vi; vorbis_comment vc; ogg_packet header; int result = 0; ogg_stream_init(&os, ogg_page_serialno(og)); vorbis_info_init(&vi); vorbis_comment_init(&vc); if( !ogg_page_bos(og) ) result = -1; if(result >= 0 && ogg_stream_pagein(&os, og) < 0) { state->lasterror = _("Error reading first page of Ogg bitstream."); result = -1; } if(result >= 0 && ogg_stream_packetout(&os, &header) != 1) { state->lasterror = _("Error reading initial header packet."); result = -1; } if(result >= 0 && vorbis_synthesis_headerin(&vi, &vc, &header) >= 0) { result = 1; } else { /* Not vorbis, may eventually become a chain of checks (Speex, * Theora), but for the moment return 0, bos scan will push * the current page onto the buffer. */ } ogg_stream_clear(&os); vorbis_info_clear(&vi); vorbis_comment_clear(&vc); return result;}
开发者ID:JoeyZheng,项目名称:deadbeef,代码行数:42,
示例10: _create_codebook_header_bufferstatic 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:rawoul,项目名称:gst-plugins-base,代码行数:21,
示例11: OpenDecoder/***************************************************************************** * OpenDecoder: probe the decoder and return score *****************************************************************************/static int OpenDecoder( vlc_object_t *p_this ){ decoder_t *p_dec = (decoder_t*)p_this; decoder_sys_t *p_sys; if( p_dec->fmt_in.i_codec != VLC_CODEC_VORBIS ) { return VLC_EGENERIC; } /* Allocate the memory needed to store the decoder's structure */ if( ( p_dec->p_sys = p_sys = malloc( sizeof(*p_sys) ) ) == NULL ) return VLC_ENOMEM; /* Misc init */ date_Set( &p_sys->end_date, 0 ); p_sys->i_last_block_size = 0; p_sys->b_packetizer = false; p_sys->i_headers = 0; /* Take care of vorbis init */ vorbis_info_init( &p_sys->vi ); vorbis_comment_init( &p_sys->vc ); /* Set output properties */ p_dec->fmt_out.i_cat = AUDIO_ES;#ifdef MODULE_NAME_IS_tremor p_dec->fmt_out.i_codec = VLC_CODEC_FI32;#else p_dec->fmt_out.i_codec = VLC_CODEC_FL32;#endif /* Set callbacks */ p_dec->pf_decode_audio = (aout_buffer_t *(*)(decoder_t *, block_t **)) DecodeBlock; p_dec->pf_packetize = (block_t *(*)(decoder_t *, block_t **)) DecodeBlock; return VLC_SUCCESS;}
开发者ID:shanewfx,项目名称:vlc-arib,代码行数:43,
示例12: vorbis_parse_change_statestatic GstStateChangeReturnvorbis_parse_change_state (GstElement * element, GstStateChange transition){ GstVorbisParse *parse = GST_VORBIS_PARSE (element); GstStateChangeReturn ret; switch (transition) { case GST_STATE_CHANGE_READY_TO_PAUSED: vorbis_info_init (&parse->vi); vorbis_comment_init (&parse->vc); parse->prev_granulepos = -1; parse->prev_blocksize = -1; parse->packetno = 0; parse->streamheader_sent = FALSE; parse->buffer_queue = g_queue_new (); parse->event_queue = g_queue_new (); break; default: break; } ret = parent_class->change_state (element, transition); switch (transition) { case GST_STATE_CHANGE_PAUSED_TO_READY: vorbis_info_clear (&parse->vi); vorbis_comment_clear (&parse->vc); vorbis_parse_clear_queue (parse); g_queue_free (parse->buffer_queue); parse->buffer_queue = NULL; g_queue_free (parse->event_queue); parse->event_queue = NULL; break; default: break; } return ret;}
开发者ID:jwzl,项目名称:ossbuild,代码行数:39,
示例13: encoder_create_vbrencoder_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,
示例14: OpenDecoder/***************************************************************************** * OpenDecoder: probe the decoder and return score *****************************************************************************/static int OpenDecoder( vlc_object_t *p_this ){ decoder_t *p_dec = (decoder_t*)p_this; decoder_sys_t *p_sys; if( p_dec->fmt_in.i_codec != VLC_CODEC_VORBIS ) return VLC_EGENERIC; /* Allocate the memory needed to store the decoder's structure */ p_dec->p_sys = p_sys = malloc( sizeof(*p_sys) ); if( unlikely( !p_sys ) ) return VLC_ENOMEM; /* Misc init */ date_Set( &p_sys->end_date, 0 ); p_sys->i_last_block_size = 0; p_sys->b_packetizer = false; p_sys->b_has_headers = false; /* Take care of vorbis init */ vorbis_info_init( &p_sys->vi ); vorbis_comment_init( &p_sys->vc ); /* Set output properties */#ifdef MODULE_NAME_IS_tremor p_dec->fmt_out.i_codec = VLC_CODEC_S32N;#else p_dec->fmt_out.i_codec = VLC_CODEC_FL32;#endif /* Set callbacks */ p_dec->pf_decode = DecodeAudio; p_dec->pf_packetize = Packetize; p_dec->pf_flush = Flush; return VLC_SUCCESS;}
开发者ID:IAPark,项目名称:vlc,代码行数:40,
示例15: vorbis_encoder_reinitstatic 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,
示例16: 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,
示例17: 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,
示例18: ovd_reparse_streamBOOL ovd_reparse_stream(ovd_stream_buf* buf){ ovd_handle* handle = (ovd_handle*)buf->handle; if (buf->len) { ogg_sync_wrote(handle->oy, buf->len); int result = ogg_sync_pageout(handle->oy, &handle->og); if (result == 0) { buf->len = OVD_STREAM_BUF_LEN; return TRUE; } else if (result < 0) return FALSE; }// ogg_stream_init(&handle->os, ogg_page_serialno(&handle->og)); handle->os = ogg_stream_create(ogg_page_serialno(&handle->og)); vorbis_info_init(&handle->vi); vorbis_comment_init(&handle->vc); if (ogg_stream_pagein(handle->os, &handle->og) < 0) return FALSE; if (ogg_stream_packetout(handle->os,&handle->op) != 1) return FALSE; if (vorbis_synthesis_headerin(&handle->vi, &handle->vc, &handle->op) < 0) return FALSE; handle->init = 0; handle->eof = 0; ovd_header_init(handle); buf->buf = ogg_sync_bufferin(handle->oy, OVD_STREAM_BUF_LEN); buf->len = OVD_STREAM_BUF_LEN; return TRUE;}
开发者ID:h16o2u9u,项目名称:rtoss,代码行数:36,
示例19: memcpyBOOL OggDec::GetWaveformat(WAVEFORMATEX *wfx,char *buf){ char *buffer; if(NULL==wfx)return FALSE; if(bWaveGet){ memcpy(wfx,&wfmt,sizeof(WAVEFORMATEX)); return TRUE; }else if(NULL==buf){ return FALSE; } buffer=ogg_sync_buffer(&oy,4096); memcpy(buffer,buf,4096); ogg_sync_wrote(&oy,4096); ogg_sync_pageout(&oy,&og); ogg_stream_init(&os,ogg_page_serialno(&og)); vorbis_info_init(&vi); vorbis_comment_init(&vc); ogg_stream_pagein(&os,&og); ogg_stream_packetout(&os,&op); vorbis_synthesis_headerin(&vi,&vc,&op); wfx->wFormatTag = WAVE_FORMAT_PCM; wfx->nChannels = vi.channels; wfx->wBitsPerSample = 16; wfx->nSamplesPerSec = vi.rate; wfx->nBlockAlign = wfx->nChannels * (wfx->wBitsPerSample/8); wfx->nAvgBytesPerSec = wfx->nSamplesPerSec * wfx->nBlockAlign; wfx->cbSize = 0; ogg_sync_clear(&oy); ogg_stream_clear(&os); vorbis_comment_clear(&vc); vorbis_info_clear(&vi); return TRUE;}
开发者ID:0xrofi,项目名称:Aquaplus,代码行数:36,
示例20: OggInitint OggInit(CFile *f, OggData *data){ ogg_packet packet; int num_vorbis;#ifdef USE_THEORA int num_theora;#endif int stream_start; int ret; unsigned magic; f->read(&magic, sizeof(magic)); if (SDL_SwapLE32(magic) != 0x5367674F) { // "OggS" in ASCII return -1; } f->seek(0, SEEK_SET); ogg_sync_init(&data->sync); vorbis_info_init(&data->vinfo); vorbis_comment_init(&data->vcomment);#ifdef USE_THEORA theora_info_init(&data->tinfo); theora_comment_init(&data->tcomment);#endif#ifdef USE_THEORA num_theora = 0;#endif num_vorbis = 0; stream_start = 0; while (!stream_start) { ogg_stream_state test; if (OggGetNextPage(&data->page, &data->sync, f)) { return -1; } if (!ogg_page_bos(&data->page)) { if (num_vorbis) { ogg_stream_pagein(&data->astream, &data->page); }#ifdef USE_THEORA if (num_theora) { ogg_stream_pagein(&data->vstream, &data->page); }#endif stream_start = 1; break; } ogg_stream_init(&test, ogg_page_serialno(&data->page)); ogg_stream_pagein(&test, &data->page); // initial codec headers while (ogg_stream_packetout(&test, &packet) == 1) {#ifdef USE_THEORA if (theora_decode_header(&data->tinfo, &data->tcomment, &packet) >= 0) { memcpy(&data->vstream, &test, sizeof(test)); ++num_theora; } else#endif if (!vorbis_synthesis_headerin(&data->vinfo, &data->vcomment, &packet)) { memcpy(&data->astream, &test, sizeof(test)); ++num_vorbis; } else { ogg_stream_clear(&test); } } } data->audio = num_vorbis;#ifdef USE_THEORA data->video = num_theora;#endif // remainint codec headers while ((num_vorbis && num_vorbis < 3)#ifdef USE_THEORA || (num_theora && num_theora < 3) ) { // are we in the theora page ? while (num_theora && num_theora < 3 && (ret = ogg_stream_packetout(&data->vstream, &packet))) { if (ret < 0) { return -1; } if (theora_decode_header(&data->tinfo, &data->tcomment, &packet)) { return -1; } ++num_theora; }#else ) {#endif // are we in the vorbis page ? while (num_vorbis && num_vorbis < 3 && (ret = ogg_stream_packetout(&data->astream, &packet))) { if (ret < 0) {//.........这里部分代码省略.........
开发者ID:OneSleepyDev,项目名称:boswars_osd,代码行数:101,
示例21: vorbis_openstatic gint vorbis_open(void){ ogg_packet header; ogg_packet header_comm; ogg_packet header_code; vorbis_init(NULL); vorbis_info_init(&vi); vorbis_comment_init(&vc); if (tuple) { gchar tmpstr[32]; gint scrint; add_string_from_tuple (& vc, "title", tuple, FIELD_TITLE); add_string_from_tuple (& vc, "artist", tuple, FIELD_ARTIST); add_string_from_tuple (& vc, "album", tuple, FIELD_ALBUM); add_string_from_tuple (& vc, "genre", tuple, FIELD_GENRE); add_string_from_tuple (& vc, "date", tuple, FIELD_DATE); add_string_from_tuple (& vc, "comment", tuple, FIELD_COMMENT); if ((scrint = tuple_get_int(tuple, FIELD_TRACK_NUMBER, NULL))) { g_snprintf(tmpstr, sizeof(tmpstr), "%d", scrint); vorbis_comment_add_tag(&vc, "tracknumber", tmpstr); } if ((scrint = tuple_get_int(tuple, FIELD_YEAR, NULL))) { g_snprintf(tmpstr, sizeof(tmpstr), "%d", scrint); vorbis_comment_add_tag(&vc, "year", tmpstr); } } if (vorbis_encode_init_vbr (& vi, input.channels, input.frequency, v_base_quality)) { vorbis_info_clear(&vi); return 0; } vorbis_analysis_init(&vd, &vi); vorbis_block_init(&vd, &vb); srand(time(NULL)); ogg_stream_init(&os, rand()); 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 (ogg_stream_flush (& os, & og)) { write_output(og.header, og.header_len); write_output(og.body, og.body_len); } return 1;}
开发者ID:ivan-dives,项目名称:audacious-plugins,代码行数:63,
示例22: input_calculate_ogg_sleepint input_calculate_ogg_sleep(ogg_page *page){ static ogg_stream_state os; ogg_packet op; static vorbis_info vi; static vorbis_comment vc; static input_type codec = ICES_INPUT_UNKNOWN; static int need_start_pos, need_headers, state_in_use = 0; static int serialno = 0; static uint64_t offset; static uint64_t first_granulepos; if (ogg_page_granulepos(page) == -1) { LOG_ERROR0("Timing control: corrupt timing information in vorbis file, cannot stream."); return -1; } if (ogg_page_bos (page)) { control.oldsamples = 0; if (state_in_use) ogg_stream_clear (&os); ogg_stream_init (&os, ogg_page_serialno (page)); serialno = ogg_page_serialno (page); state_in_use = 1; vorbis_info_init (&vi); vorbis_comment_init (&vc); need_start_pos = 1; need_headers = 3; codec = ICES_INPUT_UNKNOWN; offset = (uint64_t)0; } if (need_start_pos) { int found_first_granulepos = 0; ogg_stream_pagein (&os, page); while (ogg_stream_packetout (&os, &op) == 1) { if (need_headers) { /* check for Vorbis. For Vorbis the Magic is {0x01|0x03|0x05}"vorbis" */ if (op.bytes > 7 && memcmp(op.packet+1, "vorbis", 6) == 0) { if (vorbis_synthesis_headerin (&vi, &vc, &op) < 0) { LOG_ERROR0("Timing control: can't determine sample rate for input, not vorbis."); control.samplerate = 0; vorbis_info_clear (&vi); ogg_stream_clear (&os); return -1; } control.samplerate = vi.rate; codec = ICES_INPUT_VORBIS; } /* check for Opus. For Opus the magic is "OpusHead" */ else if (op.bytes == 19 && memcmp(op.packet, "OpusHead", 8) == 0) { if (op.packet[8] != 1) { LOG_ERROR0("Timing control: can't determine sample rate for input, unsupported Opus version."); control.samplerate = 0; vorbis_info_clear (&vi); ogg_stream_clear (&os); return -1; } /* Sample rate is fixed for Opus: 48kHz */ control.samplerate = 48000; codec = ICES_INPUT_OGG; /* No more headers after this one needed */ need_headers = 1; } else if (op.bytes >= 80 && memcmp(op.packet, "Speex ", 8) == 0) { if (__read_int32_le(op.packet+28) != 1 || __read_int32_le(op.packet+32) != op.bytes) { LOG_ERROR0("Timing control: can't determine sample rate for input, bad or unsupported Speex header."); control.samplerate = 0; vorbis_info_clear (&vi); ogg_stream_clear (&os); return -1; } control.samplerate = __read_int32_le(op.packet+36); codec = ICES_INPUT_OGG; /* No more headers after this one needed */ need_headers = 1; } else if (op.bytes >= 51 && memcmp(op.packet, "/177FLAC/1/0", 7) == 0 && memcmp(op.packet+9, "fLaC/0", 5) == 0) { control.samplerate = __read_int20_be(op.packet+27); codec = ICES_INPUT_OGG; /* No more headers after this one needed */ need_headers = 1; } else if (codec == ICES_INPUT_UNKNOWN) { LOG_ERROR0("Timing control: can't determine sample rate for input, unsupported input format."); control.samplerate = 0;//.........这里部分代码省略.........
开发者ID:xiph,项目名称:Icecast-IceS,代码行数:101,
示例23: ERR_FAIL_CONDvoid VideoStreamPlaybackTheora::set_file(const String &p_file) { ERR_FAIL_COND(playing); ogg_packet op; th_setup_info *ts = NULL; file_name = p_file; if (file) { memdelete(file); } file = FileAccess::open(p_file, FileAccess::READ); ERR_FAIL_COND(!file);#ifdef THEORA_USE_THREAD_STREAMING thread_exit = false; thread_eof = false; //pre-fill buffer int to_read = ring_buffer.space_left(); int read = file->get_buffer(read_buffer.ptr(), to_read); ring_buffer.write(read_buffer.ptr(), read); thread = Thread::create(_streaming_thread, this);#endif ogg_sync_init(&oy); /* init supporting Vorbis structures needed in header parsing */ vorbis_info_init(&vi); vorbis_comment_init(&vc); /* init supporting Theora structures needed in header parsing */ th_comment_init(&tc); th_info_init(&ti); theora_eos = false; vorbis_eos = false; /* Ogg file open; parse the headers */ /* Only interested in Vorbis/Theora streams */ int stateflag = 0; int audio_track_skip = audio_track; while (!stateflag) { int ret = buffer_data(); if (ret == 0) break; while (ogg_sync_pageout(&oy, &og) > 0) { ogg_stream_state test; /* is this a mandated initial header? If not, stop parsing */ if (!ogg_page_bos(&og)) { /* don't leak the page; get it into the appropriate stream */ queue_page(&og); stateflag = 1; break; } ogg_stream_init(&test, ogg_page_serialno(&og)); ogg_stream_pagein(&test, &og); ogg_stream_packetout(&test, &op); /* identify the codec: try theora */ if (!theora_p && th_decode_headerin(&ti, &tc, &ts, &op) >= 0) { /* it is theora */ copymem(&to, &test, sizeof(test)); theora_p = 1; } else if (!vorbis_p && vorbis_synthesis_headerin(&vi, &vc, &op) >= 0) { /* it is vorbis */ if (audio_track_skip) { vorbis_info_clear(&vi); vorbis_comment_clear(&vc); ogg_stream_clear(&test); vorbis_info_init(&vi); vorbis_comment_init(&vc); audio_track_skip--; } else { copymem(&vo, &test, sizeof(test)); vorbis_p = 1; } } else { /* whatever it is, we don't care about it */ ogg_stream_clear(&test); } } /* fall through to non-bos page parsing */ } /* we're expecting more header packets. */ while ((theora_p && theora_p < 3) || (vorbis_p && vorbis_p < 3)) { int ret; /* look for further theora headers */ while (theora_p && (theora_p < 3) && (ret = ogg_stream_packetout(&to, &op))) { if (ret < 0) { fprintf(stderr, "Error parsing Theora stream headers; " "corrupt stream?/n"); clear();//.........这里部分代码省略.........
开发者ID:Bonfi96,项目名称:godot,代码行数:101,
示例24: mainint main(){ ogg_stream_state os; /* take physical pages, weld into a logical stream of packets */ ogg_page og; /* one Ogg bitstream page. Vorbis packets are inside */ ogg_packet op; /* one raw packet of data for decode */ vorbis_info vi; /* struct that stores all the static vorbis bitstream settings */ vorbis_comment vc; /* struct that stores all the user comments */ vorbis_dsp_state vd; /* central working state for the packet->PCM decoder */ vorbis_block vb; /* local working space for packet->PCM decode */ int eos=0,ret; int i, founddata;#if defined(macintosh) && defined(__MWERKS__) int argc = 0; char **argv = NULL; argc = ccommand(&argv); /* get a "command line" from the Mac user */ /* this also lets the user set stdin and stdout */#endif /* we cheat on the WAV header; we just bypass 44 bytes and never verify that it matches 16bit/stereo/44.1kHz. This is just an example, after all. */#ifdef _WIN32 /* We need to set stdin/stdout to binary mode. Damn windows. */ /* if we were reading/writing a file, it would also need to in binary mode, eg, fopen("file.wav","wb"); */ /* Beware the evil ifdef. We avoid these where we can, but this one we cannot. Don't add any more, you'll probably go to hell if you do. */ _setmode( _fileno( stdin ), _O_BINARY ); _setmode( _fileno( stdout ), _O_BINARY );#endif /* we cheat on the WAV header; we just bypass the header and never verify that it matches 16bit/stereo/44.1kHz. This is just an example, after all. */ readbuffer[0] = '/0'; for (i=0, founddata=0; i<30 && ! feof(stdin) && ! ferror(stdin); i++) { fread(readbuffer,1,2,stdin); if ( ! strncmp((char*)readbuffer, "da", 2) ) { founddata = 1; fread(readbuffer,1,6,stdin); break; } } /********** Encode setup ************/ vorbis_info_init(&vi); /* choose an encoding mode. A few possibilities commented out, one actually used: */ /********************************************************************* Encoding using a VBR quality mode. The usable range is -.1 (lowest quality, smallest file) to 1. (highest quality, largest file). Example quality mode .4: 44kHz stereo coupled, roughly 128kbps VBR ret = vorbis_encode_init_vbr(&vi,2,44100,.4); --------------------------------------------------------------------- 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 *///.........这里部分代码省略.........
开发者ID:John-He-928,项目名称:krkrz,代码行数:101,
示例25: initstatic int init(sh_audio_t *sh){ unsigned int offset, i, length, hsizes[3]; void *headers[3]; unsigned char* extradata; ogg_packet op; vorbis_comment vc; struct ov_struct_st *ov;#define ERROR() { / vorbis_comment_clear(&vc); / vorbis_info_clear(&ov->vi); / free(ov); / return 0; / } /// Init the decoder with the 3 header packets ov = malloc(sizeof(struct ov_struct_st)); vorbis_info_init(&ov->vi); vorbis_comment_init(&vc); if(! sh->wf) { mp_msg(MSGT_DECAUDIO,MSGL_ERR,"ad_vorbis, extradata seems to be absent! exit/n"); ERROR(); } if(! sh->wf->cbSize) { mp_msg(MSGT_DECAUDIO,MSGL_ERR,"ad_vorbis, extradata seems to be absent!, exit/n"); ERROR(); } mp_msg(MSGT_DECAUDIO,MSGL_V,"ad_vorbis, extradata seems is %d bytes long/n", sh->wf->cbSize); extradata = (char*) (sh->wf+1); if(*extradata != 2) { mp_msg (MSGT_DEMUX, MSGL_WARN, "ad_vorbis: Vorbis track does not contain valid headers./n"); ERROR(); } offset = 1; for (i=0; i < 2; i++) { length = 0; while ((extradata[offset] == (unsigned char) 0xFF) && length < sh->wf->cbSize) { length += 255; offset++; } if(offset >= (sh->wf->cbSize - 1)) { mp_msg (MSGT_DEMUX, MSGL_WARN, "ad_vorbis: Vorbis track does not contain valid headers./n"); ERROR(); } length += extradata[offset]; offset++; mp_msg (MSGT_DEMUX, MSGL_V, "ad_vorbis, offset: %u, length: %u/n", offset, length); hsizes[i] = length; } headers[0] = &extradata[offset]; headers[1] = &extradata[offset + hsizes[0]]; headers[2] = &extradata[offset + hsizes[0] + hsizes[1]]; hsizes[2] = sh->wf->cbSize - offset - hsizes[0] - hsizes[1]; mp_msg (MSGT_DEMUX, MSGL_V, "ad_vorbis, header sizes: %d %d %d/n", hsizes[0], hsizes[1], hsizes[2]); for(i=0; i<3; i++) { op.bytes = hsizes[i]; op.packet = headers[i]; op.b_o_s = (i == 0); if(vorbis_synthesis_headerin(&ov->vi,&vc,&op) <0) { mp_msg(MSGT_DECAUDIO,MSGL_ERR,"OggVorbis: header n. %d broken! len=%ld/n", i, op.bytes); ERROR(); } if(i == 2) { float rg_gain=0.f, rg_peak=0.f; char **ptr=vc.user_comments; while(*ptr){ mp_msg(MSGT_DECAUDIO,MSGL_V,"OggVorbisComment: %s/n",*ptr); /* replaygain */ read_vorbis_comment( *ptr, "replaygain_album_gain=", "%f", &rg_gain ); read_vorbis_comment( *ptr, "rg_audiophile=", "%f", &rg_gain ); if( !rg_gain ) { read_vorbis_comment( *ptr, "replaygain_track_gain=", "%f", &rg_gain ); read_vorbis_comment( *ptr, "rg_radio=", "%f", &rg_gain ); } read_vorbis_comment( *ptr, "replaygain_album_peak=", "%f", &rg_peak ); if( !rg_peak ) { read_vorbis_comment( *ptr, "replaygain_track_peak=", "%f", &rg_peak ); read_vorbis_comment( *ptr, "rg_peak=", "%f", &rg_peak ); } ++ptr; } /* replaygain: scale */ if(!rg_gain) ov->rg_scale = 1.f; /* just in case pow() isn't standard-conformant */ else ov->rg_scale = pow(10.f, rg_gain/20); /* replaygain: anticlip */ if(ov->rg_scale * rg_peak > 1.f) ov->rg_scale = 1.f / rg_peak; /* replaygain: security */ if(ov->rg_scale > 15.) ov->rg_scale = 15.;#ifdef CONFIG_TREMOR//.........这里部分代码省略.........
开发者ID:0p1pp1,项目名称:mplayer,代码行数:101,
示例26: main int main(){ ogg_sync_state oy; /* sync and verify incoming physical bitstream */ ogg_stream_state os; /* take physical pages, weld into a logical stream of packets */ ogg_page og; /* one Ogg bitstream page. Vorbis packets are inside */ ogg_packet op; /* one raw packet of data for decode */ vorbis_info vi; /* struct that stores all the static vorbis bitstream settings */ vorbis_comment vc; /* struct that stores all the bitstream user comments */ vorbis_dsp_state vd; /* central working state for the packet->PCM decoder */ vorbis_block vb; /* local working space for packet->PCM decode */ char *buffer; int bytes; FILE *instream; FILE *outstream; char *inname = "01.ogg"; char *outname = "esmith2000-09-28d1t15.raw";//#ifdef _WIN32 /* We need to set stdin/stdout to binary mode. Damn windows. */// /* Beware the evil ifdef. We avoid these where we can, but this one we// cannot. Don't add any more, you'll probably go to hell if you do. */// //_setmode( _fileno( stdin ), _O_BINARY );// //_setmode( _fileno( stdout ), _O_BINARY );//#endif#if defined(macintosh) && defined(__MWERKS__) { int argc; char **argv; argc=ccommand(&argv); /* get a "command line" from the Mac user */ /* this also lets the user set stdin and stdout */ }#endif /********** Decode setup ************/ //opening the file if( fopen_s( &instream, inname, "rb" ) != 0 ) { fprintf(stderr,"Can not open file %s/n", inname); exit(1); }; if( fopen_s( &outstream, outname, "wb" ) != 0 ) { fprintf(stderr,"Can not open file %s/n", outname); exit(1); } ogg_sync_init(&oy); /* Now we can read pages */ while(1){ /* we repeat if the bitstream is chained */ int eos=0; int i; /* grab some data at the head of the stream. We want the first page (which is guaranteed to be small and only contain the Vorbis stream initial header) We need the first page to get the stream serialno. */ /* submit a 4k block to libvorbis' Ogg layer */ buffer=ogg_sync_buffer(&oy,4096); //bytes=fread(buffer,1,4096,stdin); bytes=fread(buffer,1,4096,instream); ogg_sync_wrote(&oy,bytes); /* Get the first page. */ if(ogg_sync_pageout(&oy,&og)!=1){ /* have we simply run out of data? If so, we're done. */ if(bytes<4096)break; /* error case. Must not be Vorbis data */ fprintf(stderr,"Input does not appear to be an Ogg bitstream./n"); exit(1); } /* Get the serial number and set up the rest of decode. */ /* serialno first; use it to set up a logical stream */ ogg_stream_init(&os,ogg_page_serialno(&og)); /* extract the initial header from the first page and verify that the Ogg bitstream is in fact Vorbis data */ /* I handle the initial header first instead of just having the code read all three Vorbis headers at once because reading the initial header is an easy way to identify a Vorbis bitstream and it's useful to see that functionality seperated out. */ vorbis_info_init(&vi); vorbis_comment_init(&vc); if(ogg_stream_pagein(&os,&og)<0){ /* error; stream version mismatch perhaps */ fprintf(stderr,"Error reading first page of Ogg bitstream data./n"); exit(1);//.........这里部分代码省略.........
开发者ID:KolorKode,项目名称:Stg,代码行数:101,
示例27: vorbis_info_initRefPtr<MediaDataDecoder::InitPromise>VorbisDataDecoder::Init(){ vorbis_info_init(&mVorbisInfo); vorbis_comment_init(&mVorbisComment); PodZero(&mVorbisDsp); PodZero(&mVorbisBlock); AutoTArray<unsigned char*,4> headers; AutoTArray<size_t,4> headerLens; if (!XiphExtradataToHeaders(headers, headerLens, mInfo.mCodecSpecificConfig->Elements(), mInfo.mCodecSpecificConfig->Length())) { return InitPromise::CreateAndReject( MediaResult(NS_ERROR_DOM_MEDIA_FATAL_ERR, RESULT_DETAIL("Could not get vorbis header.")), __func__); } for (size_t i = 0; i < headers.Length(); i++) { if (NS_FAILED(DecodeHeader(headers[i], headerLens[i]))) { return InitPromise::CreateAndReject( MediaResult(NS_ERROR_DOM_MEDIA_FATAL_ERR, RESULT_DETAIL("Could not decode vorbis header.")), __func__); } } MOZ_ASSERT(mPacketCount == 3); int r = vorbis_synthesis_init(&mVorbisDsp, &mVorbisInfo); if (r) { return InitPromise::CreateAndReject( MediaResult(NS_ERROR_DOM_MEDIA_FATAL_ERR, RESULT_DETAIL("Systhesis init fail.")), __func__); } r = vorbis_block_init(&mVorbisDsp, &mVorbisBlock); if (r) { return InitPromise::CreateAndReject( MediaResult(NS_ERROR_DOM_MEDIA_FATAL_ERR, RESULT_DETAIL("Block init fail.")), __func__); } if (mInfo.mRate != (uint32_t)mVorbisDsp.vi->rate) { LOG(LogLevel::Warning, ("Invalid Vorbis header: container and codec rate do not match!")); } if (mInfo.mChannels != (uint32_t)mVorbisDsp.vi->channels) { LOG(LogLevel::Warning, ("Invalid Vorbis header: container and codec channels do not match!")); } AudioConfig::ChannelLayout layout(mVorbisDsp.vi->channels); if (!layout.IsValid()) { return InitPromise::CreateAndReject( MediaResult(NS_ERROR_DOM_MEDIA_FATAL_ERR, RESULT_DETAIL("Invalid audio layout.")), __func__); } return InitPromise::CreateAndResolve(TrackInfo::kAudioTrack, __func__);}
开发者ID:luke-chang,项目名称:gecko-1,代码行数:64,
示例28: OGV_StartReadqboolean OGV_StartRead(cinematic_t *cin){ int status; ogg_page og; ogg_packet op; int i; cin->data = Com_Allocate(sizeof(cin_ogv_t)); Com_Memset(cin->data, 0, sizeof(cin_ogv_t)); ogg_sync_init(&g_ogm->oy); /* Now we can read pages */ //FIXME? can serialno be 0 in ogg? (better way to check inited?) //TODO: support for more than one audio stream? / detect files with one stream(or without correct ones) while (!g_ogm->os_audio.serialno || !g_ogm->os_video.serialno) { if (ogg_sync_pageout(&g_ogm->oy, &og) == 1) { if (strstr((char *)(og.body + 1), "vorbis")) { //FIXME? better way to find audio stream if (g_ogm->os_audio.serialno) { Com_Printf(S_COLOR_YELLOW "WARNING: more than one audio stream, in ogm-file(%s) ... we will stay at the first one/n", cin->name); } else { ogg_stream_init(&g_ogm->os_audio, ogg_page_serialno(&og)); ogg_stream_pagein(&g_ogm->os_audio, &og); } } if (strstr((char *)(og.body + 1), "theora")) { if (g_ogm->os_video.serialno) { Com_Printf(S_COLOR_YELLOW "WARNING: more than one video stream, in ogm-file(%s) ... we will stay at the first one/n", cin->name); } else { ogg_stream_init(&g_ogm->os_video, ogg_page_serialno(&og)); ogg_stream_pagein(&g_ogm->os_video, &og); } } } else if (OGV_LoadBlockToSync(cin)) { break; } } if (!g_ogm->os_audio.serialno) { Com_Printf(S_COLOR_YELLOW "WARNING: Haven't found a audio(vorbis) stream in ogm-file (%s)/n", cin->name); return qfalse; } if (!g_ogm->os_video.serialno) { Com_Printf(S_COLOR_YELLOW "WARNING: Haven't found a video stream in ogm-file (%s)/n", cin->name); return qfalse; } //load vorbis header vorbis_info_init(&g_ogm->vi); vorbis_comment_init(&g_ogm->vc); i = 0; while (i < 3) { status = ogg_stream_packetout(&g_ogm->os_audio, &op); if (status < 0) { Com_Printf(S_COLOR_YELLOW "WARNING: Corrupt ogg packet while loading vorbis-headers, ogm-file(%s)/n", cin->name); return qfalse; } if (status > 0) { status = vorbis_synthesis_headerin(&g_ogm->vi, &g_ogm->vc, &op); if (i == 0 && status < 0) { Com_Printf(S_COLOR_YELLOW "WARNING: This Ogg bitstream does not contain Vorbis audio data, ogm-file(%s)/n", cin->name); return qfalse; } ++i; } else if (OGV_LoadPagesToStreams(cin)) { if (OGV_LoadBlockToSync(cin)) { Com_Printf(S_COLOR_YELLOW "WARNING: Couldn't find all vorbis headers before end of ogm-file (%s)/n", cin->name); return qfalse; } } } vorbis_synthesis_init(&g_ogm->vd, &g_ogm->vi); // Do init { theora_info_init(&g_ogm->th_info); theora_comment_init(&g_ogm->th_comment);//.........这里部分代码省略.........
开发者ID:dstaesse,项目名称:etlegacy,代码行数:101,
注:本文中的vorbis_info_init函数示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 C++ vorbis_synthesis函数代码示例 C++ vorbis_dsp_clear函数代码示例 |