/*!
 * \brief Close a OGG/Vorbis filestream.
 * \param s A OGG/Vorbis filestream.
 */
static void ogg_vorbis_close(struct cw_filestream *s)
{
    if (cw_mutex_lock(&ogg_vorbis_lock)) {
        cw_log(LOG_WARNING, "Unable to lock ogg_vorbis list\n");
        return;
    }
    glistcnt--;
    cw_mutex_unlock(&ogg_vorbis_lock);
    cw_update_use_count();

    if (s->writing) {
        /* Tell the Vorbis encoder that the stream is finished
         * and write out the rest of the data */
        vorbis_analysis_wrote(&s->vd, 0);
        write_stream(s);
    }

    ogg_stream_clear(&s->os);
    vorbis_block_clear(&s->vb);
    vorbis_dsp_clear(&s->vd);
    vorbis_comment_clear(&s->vc);
    vorbis_info_clear(&s->vi);

    if (s->writing) {
        ogg_sync_clear(&s->oy);
    }
    
    fclose(s->fp);
    free(s);
}
Beispiel #2
0
static void ogg_apply_client (format_plugin_t *plugin, client_t *client)
{
    ogg_state_t *state = plugin->_state;

    state->mount = NULL;
    ogg_sync_clear (&state->oy);

    if (client == NULL)
        return;
    plugin->parser = client->parser;
    if (plugin->parser)
    {
        const char *s = httpp_getvar (plugin->parser, "content-type");
        if (s==NULL || strcmp (s, "application/x-ogg") == 0)
            httpp_setvar (plugin->parser, "content-type", "application/ogg");
        s = httpp_getvar (plugin->parser, "content-type");
        if (s)
            plugin->contenttype = strdup (s);
    }

    ogg_sync_init (&state->oy);

    state->mount = plugin->mount;
    state->bos_end = &state->header_pages;
}
Beispiel #3
0
/*!
 * \brief Close a OGG/Speex filestream.
 * \param fs A OGG/Speex filestream.
 */
static void ogg_speex_close(struct ast_filestream *fs)
{
	struct speex_desc *s = (struct speex_desc *)fs->_private;

	ogg_stream_clear(&s->os);
	ogg_sync_clear(&s->oy);
}
Beispiel #4
0
int ogg_sync_destroy(ogg_sync_state *oy){
  if(oy){
    ogg_sync_clear(oy);
    _ogg_free(oy);
  }
  return(0);
}
void Cin_OGM_Shutdown() {
#ifdef USE_CIN_XVID
	int status;

	status = shutdown_xvid();
	if (status)
		Com_Printf("[Xvid]Decore RELEASE problem, return value %d\n", status);
#endif
#ifdef USE_CIN_THEORA
    theora_clear(&g_ogm.th_state);
    theora_comment_clear(&g_ogm.th_comment);
    theora_info_clear(&g_ogm.th_info);
#endif
	if(g_ogm.outputBuffer) free(g_ogm.outputBuffer);
	g_ogm.outputBuffer = NULL;

	vorbis_dsp_clear(&g_ogm.vd);
	vorbis_comment_clear(&g_ogm.vc);
	vorbis_info_clear(&g_ogm.vi);  /* must be called last (comment from vorbis example code) */

	ogg_stream_clear(&g_ogm.os_audio);
	ogg_stream_clear(&g_ogm.os_video);

	ogg_sync_clear(&g_ogm.oy);

	FS_FCloseFile(g_ogm.ogmFile);
	g_ogm.ogmFile = 0;
}
Beispiel #6
0
void format_vorbis_free_plugin(format_plugin_t *self)
{
    int i;
    vstate_t *state = (vstate_t *)self->_state;

    /* free memory associated with this plugin instance */

    /* free state memory */
    ogg_sync_clear(&state->oy);
    ogg_stream_clear(&state->os);
    vorbis_comment_clear(&state->vc);
    vorbis_info_clear(&state->vi);
    
    for (i = 0; i < MAX_HEADER_PAGES; i++) {
        if (state->headbuf[i]) {
            refbuf_release(state->headbuf[i]);
            state->headbuf[i] = NULL;
        }
    }

    free(state);

    /* free the plugin instance */
    free(self);
}
void VideoStreamTheora::clear() {

	if (file_name == "")
		return;

	if(vorbis_p){
		ogg_stream_clear(&vo);
		if (vorbis_p >= 3) {
			vorbis_block_clear(&vb);
			vorbis_dsp_clear(&vd);
		};
		vorbis_comment_clear(&vc);
		vorbis_info_clear(&vi);
		vorbis_p = 0;
	}
	if(theora_p){
		ogg_stream_clear(&to);
		th_decode_free(td);
		th_comment_clear(&tc);
		th_info_clear(&ti);
		theora_p = 0;
	}
	ogg_sync_clear(&oy);

	file_name = "";

	theora_p = 0;
	vorbis_p = 0;
	videobuf_ready = 0;
	frames_pending = 0;
	videobuf_time = 0;

	playing = false;
};
Beispiel #8
0
/* clear out the OggVorbis_File struct */
int ov_clear(OggVorbis_File *vf){
  if(vf){
    vorbis_block_clear(&vf->vb);
    vorbis_dsp_clear(&vf->vd);
    ogg_stream_clear(&vf->os);
    
    if(vf->vi && vf->links){
      int i;
      for(i=0;i<vf->links;i++){
	vorbis_info_clear(vf->vi+i);
	vorbis_comment_clear(vf->vc+i);
      }
      _ogg_free(vf->vi);
      _ogg_free(vf->vc);
    }
    if(vf->dataoffsets)_ogg_free(vf->dataoffsets);
    if(vf->pcmlengths)_ogg_free(vf->pcmlengths);
    if(vf->serialnos)_ogg_free(vf->serialnos);
    if(vf->offsets)_ogg_free(vf->offsets);
    ogg_sync_clear(&vf->oy);
    if(vf->datasource)(vf->callbacks.close_func)(vf->datasource);
    memset(vf,0,sizeof(*vf));
  }
#ifdef DEBUG_LEAKS
  _VDBG_dump();
#endif
  return(0);
}
Beispiel #9
0
static int
ogg_close (SF_PRIVATE *psf)
{
	OGG_PRIVATE *odata = (OGG_PRIVATE *) psf->container_data ;
	VORBIS_PRIVATE *vdata = (VORBIS_PRIVATE *) psf->codec_data ;

	if (odata == NULL || vdata == NULL)
		return 0 ;

	/*	Clean up this logical bitstream ; before exit we shuld see if we're
	**	followed by another [chained]. */

	if (psf->file.mode == SFM_WRITE)
	{
		if (psf->write_current <= 0)
			ogg_write_header (psf, 0) ;

		vorbis_analysis_wrote (&vdata->vd, 0) ;
		while (vorbis_analysis_blockout (&vdata->vd, &vdata->vb) == 1)
		{

		/* analysis, assume we want to use bitrate management */
			vorbis_analysis (&vdata->vb, NULL) ;
			vorbis_bitrate_addblock (&vdata->vb) ;

			while (vorbis_bitrate_flushpacket (&vdata->vd, &odata->op))
			{	/* weld the packet into the bitstream */
				ogg_stream_packetin (&odata->os, &odata->op) ;

				/* write out pages (if any) */
				while (!odata->eos)
				{	int result = ogg_stream_pageout (&odata->os, &odata->og) ;
					if (result == 0) break ;
					psf_fwrite (odata->og.header, 1, odata->og.header_len, psf) ;
					psf_fwrite (odata->og.body, 1, odata->og.body_len, psf) ;

		/* this could be set above, but for illustrative purposes, I do
		   it here (to show that vorbis does know where the stream ends) */

					if (ogg_page_eos (&odata->og)) odata->eos = 1 ;
				}
			}
		}
	}

	/* ogg_page and ogg_packet structs always point to storage in
	   libvorbis.  They are never freed or manipulated directly */

	vorbis_block_clear (&vdata->vb) ;
	vorbis_dsp_clear (&vdata->vd) ;
	vorbis_comment_clear (&vdata->vc) ;
	vorbis_info_clear (&vdata->vi) ;	 /* must be called last */
	/* should look here to reopen if chained */

	/* OK, clean up the framer */
	ogg_sync_clear (&odata->oy) ;
	ogg_stream_clear (&odata->os) ;

	return 0 ;
} /* ogg_close */
Beispiel #10
0
	/* clear the ogg/vorbis decoder */
static void oggamp_vorbis_sync_clear(t_oggamp *x)
{
		/* OK, clean up the framer */
	ogg_sync_clear(&(x->x_oy));
	x->x_sync = 0;
	post("oggamp~: decoder cleared");
}
Beispiel #11
0
static sf_count_t
vorbis_length_aux (SF_PRIVATE * psf)
{	ogg_sync_state osync ;
	ogg_page page ;
	sf_count_t len = 0 ;
	stream_set *processors ;

	processors = create_stream_set () ;
	if (processors == NULL)
		return 0 ;	// out of memory?

	ogg_sync_init (&osync) ;

	while (vorbis_length_get_next_page (psf, &osync, &page))
	{	stream_processor *p = find_stream_processor (processors, &page) ;

		if (!p)
		{	len = 0 ;
			break ;
		} ;

		if (p->isillegal && !p->shownillegal)
		{	p->shownillegal = 1 ;
			/* If it's a new stream, we want to continue processing this page
			** anyway to suppress additional spurious errors
			*/
			if (!p->isnew) continue ;
		} ;

		if (!p->isillegal)
		{	ogg_packet packet ;
			int header = 0 ;

			ogg_stream_pagein (&p->ostream, &page) ;
			if (p->doneheaders < 3)
				header = 1 ;

			while (ogg_stream_packetout (&p->ostream, &packet) > 0)
			{	if (p->doneheaders < 3)
				{	if (vorbis_synthesis_headerin (&p->vinfo, &p->vcomment, &packet) < 0)
						continue ;
					p->doneheaders ++ ;
				} ;
			} ;
			if (!header)
			{	sf_count_t gp = ogg_page_granulepos (&page) ;
				if (gp > 0) p->lastgranulepos = gp ;
			} ;
			if (p->end)
			{	vorbis_end (p, &len) ;
				p->isillegal = 1 ;
			} ;
		} ;
	} ;

	ogg_sync_clear (&osync) ;
	free_stream_set (processors, &len) ;

	return len ;
} /* vorbis_length_aux */
Beispiel #12
0
static void vcedit_clear_internals(vcedit_state *state)
{
	if(state->vc)
	{
		vorbis_comment_clear(state->vc);
		free(state->vc);
		state->vc=NULL;
	}
	if(state->os)
	{
		ogg_stream_clear(state->os);
		free(state->os);
		state->os=NULL;
	}
	if(state->oy)
	{
		ogg_sync_clear(state->oy);
		free(state->oy);
		state->oy=NULL;
	}
	if(state->vendor)
	{
		free(state->vendor);
		state->vendor=NULL;
	}
}
Beispiel #13
0
static void vcedit_clear_internals(vcedit_state *state)
{
	if(state->vc)
	{
		vorbis_comment_clear(state->vc);
		free(state->vc);
	}
	if(state->os)
	{
		ogg_stream_clear(state->os);
		free(state->os);
	}
	if(state->oy)
	{
		ogg_sync_clear(state->oy);
		free(state->oy);
	}
	if(state->vendor)
		free(state->vendor);
    if(state->mainbuf)
	free(state->mainbuf);
    if(state->bookbuf)
	free(state->bookbuf);
    if(state->vi) {
	vorbis_info_clear(state->vi);
	free(state->vi);
    }

    memset(state, 0, sizeof(*state));
}
Beispiel #14
0
static struct spx_data *spx_open_internal (struct io_stream *stream)
{
	struct spx_data *data;
	SpeexStereoState stereo = SPEEX_STEREO_STATE_INIT;

	data = (struct spx_data *)xmalloc (sizeof(struct spx_data));

	decoder_error_init (&data->error);
	data->stream = stream;

	data->st = NULL;
	data->stereo = stereo;
	data->header = NULL;
	data->output = NULL;
	data->comment_packet = NULL;
	data->bitrate = -1;
	ogg_sync_init (&data->oy);
	speex_bits_init (&data->bits);

	if (!read_speex_header(data)) {
		ogg_sync_clear (&data->oy);
		speex_bits_destroy (&data->bits);
		data->ok = 0;
	}
	else
		data->ok = 1;

	return data;
}
Beispiel #15
0
void DGVideo::unload() {
    if (_isLoaded) {
        _isLoaded = false;
        _state = DGVideoInitial;
        
        _theoraInfo->videobuf_ready = 0;
        _theoraInfo->videobuf_granulepos -= 1;
        _theoraInfo->videobuf_time = 0;
        
        if (_theoraInfo->theora_p) {
            // Rewind and reset
            fseek(_handle, (long)_theoraInfo->bos * 8, SEEK_SET);
            ogg_stream_reset(&_theoraInfo->to);
            ogg_stream_clear(&_theoraInfo->to);
            theora_clear(&_theoraInfo->td);
            theora_comment_clear(&_theoraInfo->tc);
            theora_info_clear(&_theoraInfo->ti);
        }
        
        ogg_sync_clear(&_theoraInfo->oy);
        
        _theoraInfo->theora_p = 0;
        
        free(_currentFrame.data);
        fclose(_handle);
    }
}
Beispiel #16
0
static PyObject * py_ogg_ogg_sync_clear(PyObject *self, PyObject *args) {
  int c_out;
  int size;
  ogg_sync_state * oy;
  PyArg_ParseTuple(args, "s#", &oy, &size);
  c_out = ogg_sync_clear(oy);
  return Py_BuildValue("i", c_out);
};
Beispiel #17
0
static int ogg_read_close(AVFormatContext *avfcontext) {
    OggContext *context = avfcontext->priv_data ;

    ogg_stream_clear(&context->os) ;
    ogg_sync_clear(&context->oy) ;

    return 0 ;
}
Beispiel #18
0
int main()
{
  ogg_sync_state oy;
  ogg_stream_state os;
  int init=0;
  ogg_packet op;
  kate_state k;
  kate_info ki;
  kate_comment kc;
  const kate_event *ev;

  /* for the benefit of windows, which mangles data otherwise */
  set_binary_file(stdin);

  /* we initialize ogg and kate info/comment structures */
  ogg_sync_init(&oy);
  kate_info_init(&ki);
  kate_comment_init(&kc);

  /*
    First, read the headers, which must appear first in a Kate stream. When
    kate_decode_header returns a positive number, all headers have been seen
    and we're ready to decode data.
    */
  do {
    get_packet(&oy,&os,&init,&op);
  } while (kate_ogg_decode_headerin(&ki,&kc,&op)==0);

  /*
    We now have all the information we need from the headers, so we can
    initialize kate for decoding
    */
  kate_decode_init(&k,&ki);

  /*
    We can now read data, until kate_decode_packetin returns a positive
    number, signaling the end of the stream
    */
  while (1) {
    if (get_packet(&oy,&os,&init,&op)) break;
    if (kate_ogg_decode_packetin(&k,&op)>0) break;

    /* we may have an event (eg, text) */
    if (kate_decode_eventout(&k,&ev)==0) {
      printf("Kate stream has text: %s\n",ev->text);
    }
  }

  /* That's it, we can now cleanup */
  ogg_stream_clear(&os);
  ogg_sync_clear(&oy);

  kate_clear(&k);
  kate_info_clear(&ki);
  kate_comment_clear(&kc);

  return 0;
}
Beispiel #19
0
flac_header_extractor_c::~flac_header_extractor_c() {
  FLAC__stream_decoder_reset(decoder);
  FLAC__stream_decoder_delete(decoder);

  ogg_sync_clear(&oy);
  ogg_stream_clear(&os);

  delete file;
}
Beispiel #20
0
static int
ogg_close (SF_PRIVATE *psf)
{	OGG_PRIVATE* odata = psf->container_data ;

	ogg_sync_clear (&odata->osync) ;
	ogg_stream_clear (&odata->ostream) ;

	return 0 ;
} /* ogg_close */
Beispiel #21
0
int player_example_close_input(player_example *player) {
  int ret;
  if (player == NULL) return -1;
  if ((player->input == stdin) || (player->input == NULL)) return -1;
  ret = fclose(player->input);
  player->input = NULL;
  ogg_sync_clear(&player->oy);
  if (ret != 0) return -1;
  return 0;
}
Beispiel #22
0
void TheoraClose()
{
  ogg_stream_clear      ( &m_StreamState );
  theora_clear          ( &m_State       );
  theora_comment_clear  ( &m_Comment     );
  theora_info_clear     ( &m_Info        );
  ogg_sync_clear        ( &m_SyncState   );

  fclose( m_File );
}
/*
 * Class:     org_tritonus_lowlevel_ogg_SyncState
 * Method:    clear
 * Signature: ()V
 */
JNIEXPORT void JNICALL
Java_org_tritonus_lowlevel_ogg_SyncState_clear
(JNIEnv* env, jobject obj)
{
	ogg_sync_state*	handle;

	if (debug_flag) { fprintf(debug_file, "Java_org_tritonus_lowlevel_ogg_SyncState_clear(): begin\n"); }
	handle = getHandle(env, obj);
	ogg_sync_clear(handle);
	if (debug_flag) { fprintf(debug_file, "Java_org_tritonus_lowlevel_ogg_SyncState_clear(): end\n"); }
}
Beispiel #24
0
OggReader::~OggReader()
{
	TRACE("OggReader::~OggReader\n");
	serialno_OggTrack_map::iterator i = fTracks.begin();
	while (i != fTracks.end()) {
		serialno_OggTrack_map::iterator j = i;
		i++;
		delete j->second;
	}
	ogg_sync_clear(&fSync);
}
Beispiel #25
0
static void
gst_ogg_avi_parse_finalize (GObject * object)
{
  GstOggAviParse *ogg = GST_OGG_AVI_PARSE (object);

  GST_LOG_OBJECT (ogg, "Disposing of object %p", ogg);

  ogg_sync_clear (&ogg->sync);
  ogg_stream_clear (&ogg->stream);

  G_OBJECT_CLASS (parent_class)->finalize (object);
}
Beispiel #26
0
int
mm_close(mm_file *mf)
{
    assert(mf);

    if (mf->file) {
        fclose(mf->file);
        mf->file = NULL;
    }

    if (mf->audio) {
        ogg_stream_destroy(mf->audio);
        mf->audio = NULL;
    }

    if (mf->video) {
        ogg_stream_destroy(mf->video);
        mf->video = NULL;
    }

    if (mf->video_ctx) {
        theora_clear(mf->video_ctx);
        free(mf->video_ctx);
        mf->video_ctx = NULL;
    }

    if (mf->video_info) {
        theora_info_clear(mf->video_info);
        free(mf->video_info);
        mf->video_info = NULL;
    }

    if (mf->audio_blk) {
        vorbis_block_clear(mf->audio_blk);
        free(mf->audio_blk);
        mf->audio_blk = NULL;
    }

    if (mf->audio_ctx) {
        vorbis_dsp_clear(mf->audio_ctx);
        free(mf->audio_ctx);
        mf->audio_ctx = NULL;
    }

    if (mf->audio_info) {
        vorbis_info_clear(mf->audio_info);
        free(mf->audio_info);
        mf->audio_info = NULL;
    }

    ogg_sync_clear(&mf->sync);
    return 0;
}
Beispiel #27
0
static void format_ogg_free_plugin (format_plugin_t *plugin, client_t *client)
{
    ogg_state_t *state = plugin->_state;

    /* free memory associated with this plugin instance */
    free_ogg_codecs (state);
    free (state->artist);
    free (state->title);

    ogg_sync_clear (&state->oy);
    free (state);
}
Beispiel #28
0
static void close_module(input_module_t *mod)
{
    if (mod == NULL) return;

    if (mod->internal) 
    {
        playlist_state_t *pl = (playlist_state_t *)mod->internal;
        pl->clear(pl->data);
        ogg_sync_clear(&pl->oy);
        free(pl);
    }
    free(mod);
}
Beispiel #29
0
bool Oggeyman::shutdown() {
	// shutdown in the reverse order of intialization
	theora_clear(&theo_state);
	ogg_stream_clear(&ogg_theora_stream_state);
	theora_comment_clear(&theo_comment);
	theora_info_clear(&theo_info);
	ogg_sync_clear(&overall_sync_state);

	if (infptr)
		fclose(infptr);

	return true;
}
Beispiel #30
0
static void ogg_decend(GETSND snd) {

	__OV	*ov;

	ov = (__OV *)snd->snd;

	ogg_stream_clear(&ov->os);
	vorbis_block_clear(&ov->vb);
	vorbis_dsp_clear(&ov->vd);
	vorbis_comment_clear(&ov->vc);
	vorbis_info_clear(&ov->vi);
	ogg_sync_clear(&ov->oy);
	_MFREE(ov);
}