static int noop_test_encode () { th_info ti; th_enc_ctx *te; INFO ("+ Initializing th_info struct"); th_info_init (&ti); INFO ("+ Testing encoder context with empty th_info"); te = th_encode_alloc(&ti); if (te != NULL) FAIL("td_encode_alloc accepted an unconfigured th_info"); INFO ("+ Setting 16x16 image size"); ti.frame_width = 16; ti.frame_height = 16; INFO ("+ Allocating encoder context"); te = th_encode_alloc(&ti); if (te == NULL) FAIL("td_encode_alloc returned a null pointer"); INFO ("+ Clearing th_info struct"); th_info_clear (&ti); INFO ("+ Freeing encoder context"); th_encode_free(te); return 0; }
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; };
nsTheoraState::~nsTheoraState() { MOZ_COUNT_DTOR(nsTheoraState); th_setup_free(mSetup); th_decode_free(mCtx); th_comment_clear(&mComment); th_info_clear(&mInfo); }
TheoraVideoStream::TheoraVideoStream(love::filesystem::File *file) : demuxer(file) , headerParsed(false) , decoder(nullptr) , frameReady(false) , lastFrame(0) , nextFrame(0) { if (demuxer.findStream() != OggDemuxer::TYPE_THEORA) throw love::Exception("Invalid video file, video is not theora"); th_info_init(&videoInfo); frontBuffer = new Frame(); backBuffer = new Frame(); try { parseHeader(); } catch (love::Exception &ex) { delete backBuffer; delete frontBuffer; th_info_clear(&videoInfo); throw ex; } frameSync.set(new DeltaSync(), Acquire::NORETAIN); }
TheoraDecoder::~TheoraDecoder() { th_comment_clear(&mTheoraComment); th_info_clear(&mTheoraInfo); th_decode_free(mTheoraState); th_setup_free(mTheoraSetup); }
void krad_theora_decoder_destroy(krad_theora_decoder_t *krad_theora) { th_decode_free(krad_theora->decoder); th_comment_clear(&krad_theora->comment); th_info_clear(&krad_theora->info); free(krad_theora); }
/* * Theora beginning of stream */ nsresult MediaRecorder::SetupTheoraBOS() { int i; nsresult rv; PRUint32 wr; ogg_uint32_t keyframe; if (ogg_stream_init(&vState->os, rand())) { PR_LOG(log, PR_LOG_NOTICE, ("Failed ogg_stream_init\n")); return NS_ERROR_FAILURE; } th_info_init(&vState->ti); /* Must be multiples of 16 */ vState->ti.frame_width = (params->width + 15) & ~0xF; vState->ti.frame_height = (params->height + 15) & ~0xF; vState->ti.pic_width = params->width; vState->ti.pic_height = params->height; vState->ti.pic_x = (vState->ti.frame_width - params->width) >> 1 & ~1; vState->ti.pic_y = (vState->ti.frame_height - params->height) >> 1 & ~1; vState->ti.fps_numerator = params->fps_n; vState->ti.fps_denominator = params->fps_d; /* Are these the right values? */ keyframe = 64 - 1; for (i = 0; keyframe; i++) keyframe >>= 1; vState->ti.quality = (int)(params->qual * 100); vState->ti.colorspace = TH_CS_ITU_REC_470M; vState->ti.pixel_fmt = TH_PF_420; vState->ti.keyframe_granule_shift = i; vState->th = th_encode_alloc(&vState->ti); th_info_clear(&vState->ti); /* Header init */ th_comment_init(&vState->tc); th_comment_add_tag(&vState->tc, (char *)"ENCODER", (char *)"rainbow"); if (th_encode_flushheader( vState->th, &vState->tc, &vState->op) <= 0) { PR_LOG(log, PR_LOG_NOTICE, ("Internal Theora library error\n")); return NS_ERROR_FAILURE; } th_comment_clear(&vState->tc); ogg_stream_packetin(&vState->os, &vState->op); if (ogg_stream_pageout(&vState->os, &vState->og) != 1) { PR_LOG(log, PR_LOG_NOTICE, ("Internal Ogg library error\n")); return NS_ERROR_FAILURE; } rv = WriteData(vState->og.header, vState->og.header_len, &wr); rv = WriteData(vState->og.body, vState->og.body_len, &wr); return NS_OK; }
static GstStateChangeReturn theora_dec_change_state (GstElement * element, GstStateChange transition) { GstTheoraDec *dec = GST_THEORA_DEC (element); GstStateChangeReturn ret; switch (transition) { case GST_STATE_CHANGE_NULL_TO_READY: break; case GST_STATE_CHANGE_READY_TO_PAUSED: th_info_clear (&dec->info); th_comment_clear (&dec->comment); GST_DEBUG_OBJECT (dec, "Setting have_header to FALSE in READY->PAUSED"); dec->have_header = FALSE; dec->have_par = FALSE; gst_theora_dec_reset (dec); break; case GST_STATE_CHANGE_PAUSED_TO_PLAYING: break; default: break; } ret = parent_class->change_state (element, transition); switch (transition) { case GST_STATE_CHANGE_PLAYING_TO_PAUSED: break; case GST_STATE_CHANGE_PAUSED_TO_READY: th_info_clear (&dec->info); th_comment_clear (&dec->comment); th_setup_free (dec->setup); dec->setup = NULL; th_decode_free (dec->decoder); dec->decoder = NULL; gst_theora_dec_reset (dec); break; case GST_STATE_CHANGE_READY_TO_NULL: break; default: break; } return ret; }
TheoraVideoStream::~TheoraVideoStream() { if (decoder) th_decode_free(decoder); th_info_clear(&videoInfo); delete frontBuffer; delete backBuffer; }
/***************************************************************************** * CloseDecoder: theora decoder destruction *****************************************************************************/ static void CloseDecoder( vlc_object_t *p_this ) { decoder_t *p_dec = (decoder_t *)p_this; decoder_sys_t *p_sys = p_dec->p_sys; th_info_clear(&p_sys->ti); th_comment_clear(&p_sys->tc); th_decode_free(p_sys->tcx); free( p_sys ); }
static gboolean theora_enc_set_format (GstVideoEncoder * benc, GstVideoCodecState * state) { GstTheoraEnc *enc = GST_THEORA_ENC (benc); GstVideoInfo *info = &state->info; enc->width = GST_VIDEO_INFO_WIDTH (info); enc->height = GST_VIDEO_INFO_HEIGHT (info); th_info_clear (&enc->info); th_info_init (&enc->info); /* Theora has a divisible-by-sixteen restriction for the encoded video size but * we can define a picture area using pic_width/pic_height */ enc->info.frame_width = GST_ROUND_UP_16 (enc->width); enc->info.frame_height = GST_ROUND_UP_16 (enc->height); enc->info.pic_width = enc->width; enc->info.pic_height = enc->height; switch (GST_VIDEO_INFO_FORMAT (info)) { case GST_VIDEO_FORMAT_I420: enc->info.pixel_fmt = TH_PF_420; break; case GST_VIDEO_FORMAT_Y42B: enc->info.pixel_fmt = TH_PF_422; break; case GST_VIDEO_FORMAT_Y444: enc->info.pixel_fmt = TH_PF_444; break; default: g_assert_not_reached (); } enc->info.fps_numerator = enc->fps_n = GST_VIDEO_INFO_FPS_N (info); enc->info.fps_denominator = enc->fps_d = GST_VIDEO_INFO_FPS_D (info); enc->info.aspect_numerator = GST_VIDEO_INFO_PAR_N (info); enc->info.aspect_denominator = GST_VIDEO_INFO_PAR_D (info); enc->info.colorspace = TH_CS_UNSPECIFIED; /* Save input state */ if (enc->input_state) gst_video_codec_state_unref (enc->input_state); enc->input_state = gst_video_codec_state_ref (state); /* as done in theora */ enc->info.keyframe_granule_shift = _ilog (enc->keyframe_force - 1); GST_DEBUG_OBJECT (enc, "keyframe_frequency_force is %d, granule shift is %d", enc->keyframe_force, enc->info.keyframe_granule_shift); theora_enc_reset (enc); enc->initialised = TRUE; return TRUE; }
/* * uninit driver */ static void uninit(sh_video_t *sh) { theora_struct_t *context = sh->context; if (context) { th_info_clear(&context->ti); th_comment_clear(&context->tc); th_decode_free(context->tctx); free(context); } }
static int noop_test_info () { th_info ti; INFO ("+ Initializing th_info struct"); th_info_init (&ti); INFO ("+ Clearing empty th_info struct"); th_info_clear (&ti); return 0; }
static gboolean theora_dec_start (GstVideoDecoder * decoder) { GstTheoraDec *dec = GST_THEORA_DEC (decoder); GST_DEBUG_OBJECT (dec, "start"); th_info_clear (&dec->info); th_comment_clear (&dec->comment); GST_DEBUG_OBJECT (dec, "Setting have_header to FALSE"); dec->have_header = FALSE; gst_theora_dec_reset (dec); return TRUE; }
void VideoStreamPlaybackTheora::clear() { if (!file) 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); #ifdef THEORA_USE_THREAD_STREAMING thread_exit = true; thread_sem->post(); //just in case Thread::wait_to_finish(thread); memdelete(thread); thread = NULL; ring_buffer.clear(); #endif //file_name = ""; theora_p = 0; vorbis_p = 0; videobuf_ready = 0; frames_pending = 0; videobuf_time = 0; theora_eos = false; vorbis_eos = false; if (file) { memdelete(file); } file = NULL; playing = false; };
void theoraenc_delete (TheoraEnc *enc) { if (!enc) return; if (enc->info) { th_info_clear (enc->info); free (enc->info); } if (enc->comment) { th_comment_clear (enc->comment); free (enc->comment); } if (enc->ctx) th_encode_free (enc->ctx); if (enc->postconv_buffer) free (enc->postconv_buffer); free (enc); }
static void theora_enc_finalize (GObject * object) { GstTheoraEnc *enc = GST_THEORA_ENC (object); GST_DEBUG_OBJECT (enc, "Finalizing"); if (enc->encoder) th_encode_free (enc->encoder); th_comment_clear (&enc->comment); th_info_clear (&enc->info); g_free (enc->multipass_cache_file); theora_enc_clear_multipass_cache (enc); G_OBJECT_CLASS (parent_class)->finalize (object); }
static char * theora_enc_get_supported_formats (void) { th_enc_ctx *encoder; th_info info; struct { th_pixel_fmt pixelformat; const char *fourcc; } formats[] = { { TH_PF_420, "I420" }, { TH_PF_422, "Y42B" }, { TH_PF_444, "Y444" } }; GString *string = NULL; guint i; th_info_init (&info); info.frame_width = 16; info.frame_height = 16; info.fps_numerator = 25; info.fps_denominator = 1; for (i = 0; i < G_N_ELEMENTS (formats); i++) { info.pixel_fmt = formats[i].pixelformat; encoder = th_encode_alloc (&info); if (encoder == NULL) continue; GST_LOG ("format %s is supported", formats[i].fourcc); th_encode_free (encoder); if (string == NULL) { string = g_string_new (formats[i].fourcc); } else { g_string_append (string, ", "); g_string_append (string, formats[i].fourcc); } } th_info_clear (&info); return string == NULL ? NULL : g_string_free (string, FALSE); }
static GstStateChangeReturn theora_parse_change_state (GstElement * element, GstStateChange transition) { GstTheoraParse *parse = GST_THEORA_PARSE (element); GstStateChangeReturn ret; gint i; switch (transition) { case GST_STATE_CHANGE_READY_TO_PAUSED: th_info_init (&parse->info); th_comment_init (&parse->comment); parse->send_streamheader = TRUE; parse->buffer_queue = g_queue_new (); parse->event_queue = g_queue_new (); parse->prev_keyframe = -1; parse->prev_frame = -1; parse->granule_offset = 0; break; default: break; } ret = GST_ELEMENT_CLASS (parent_class)->change_state (element, transition); switch (transition) { case GST_STATE_CHANGE_PAUSED_TO_READY: th_info_clear (&parse->info); th_comment_clear (&parse->comment); theora_parse_clear_queue (parse); g_queue_free (parse->buffer_queue); g_queue_free (parse->event_queue); parse->buffer_queue = NULL; for (i = 0; i < 3; i++) { if (parse->streamheader[i]) { gst_buffer_unref (parse->streamheader[i]); parse->streamheader[i] = NULL; } } parse->streamheader_received = FALSE; break; default: break; } return ret; }
static int close_theora(void * data) { int ret = 1; theora_t * theora; theora = data; #ifdef THEORA_1_1 if(theora->stats_file) fclose(theora->stats_file); if(theora->stats_buf) free(theora->stats_buf); #endif th_comment_clear(&theora->tc); th_info_clear(&theora->ti); th_encode_free(theora->ts); free(theora); return ret; }
static gboolean theora_enc_stop (GstVideoEncoder * benc) { GstTheoraEnc *enc; GST_DEBUG_OBJECT (benc, "stop: clearing theora state"); enc = GST_THEORA_ENC (benc); if (enc->encoder) { th_encode_free (enc->encoder); enc->encoder = NULL; } th_comment_clear (&enc->comment); th_info_clear (&enc->info); enc->initialised = FALSE; return TRUE; }
void krad_theora_encoder_destroy (krad_theora_encoder_t *krad_theora) { while (krad_theora->header_count--) { //printf("krad_theora_encoder_destroy freeing header %d\n", // krad_theora->header_count); free (krad_theora->header[krad_theora->header_count]); } th_info_clear (&krad_theora->info); th_comment_clear (&krad_theora->comment); th_encode_free (krad_theora->encoder); free (krad_theora->header_combined); free (krad_theora->ycbcr[0].data); free (krad_theora->ycbcr[1].data); free (krad_theora->ycbcr[2].data); free (krad_theora); }
VideoClip_Theora::~VideoClip_Theora() { if (this->info.TheoraDecoder != NULL) { th_decode_free(this->info.TheoraDecoder); th_setup_free(this->info.TheoraSetup); if (this->audioInterface != NULL) { vorbis_dsp_clear(&this->info.VorbisDSPState); vorbis_block_clear(&this->info.VorbisBlock); } ogg_stream_clear(&this->info.TheoraStreamState); th_comment_clear(&this->info.TheoraComment); th_info_clear(&this->info.TheoraInfo); ogg_stream_clear(&this->info.VorbisStreamState); vorbis_comment_clear(&this->info.VorbisComment); vorbis_info_clear(&this->info.VorbisInfo); ogg_sync_clear(&this->info.OggSyncState); } }
/* Generate a dummy encoder context for use in th_encode_ctl queries */ th_enc_ctx *dummy_encode_ctx(void) { th_enc_ctx *ctx; th_info info; /* set the minimal video parameters */ th_info_init(&info); info.frame_width=320; info.frame_height=240; info.fps_numerator=1; info.fps_denominator=1; /* allocate and initialize a context object */ ctx = th_encode_alloc(&info); if (ctx == NULL) { fprintf(stderr, "Error allocating encoder context.\n"); } /* clear the info struct */ th_info_clear(&info); return ctx; }
/* Generate a dummy encoder context for use in th_encode_ctl queries Release with th_encode_free() This and the next routine from theora/examples/libtheora_info.c */ static th_enc_ctx * dummy_encode_ctx (void) { th_enc_ctx *ctx; th_info info; /* set the minimal video parameters */ th_info_init (&info); info.frame_width = 320; info.frame_height = 240; info.fps_numerator = 1; info.fps_denominator = 1; /* allocate and initialize a context object */ ctx = th_encode_alloc (&info); if (!ctx) GST_WARNING ("Failed to allocate dummy encoder context."); /* clear the info struct */ th_info_clear (&info); return ctx; }
static gboolean theora_enc_stop (GstVideoEncoder * benc) { GstTheoraEnc *enc; GST_DEBUG_OBJECT (benc, "stop: clearing theora state"); enc = GST_THEORA_ENC (benc); if (enc->encoder) th_encode_free (enc->encoder); enc->encoder = NULL; th_comment_clear (&enc->comment); th_info_clear (&enc->info); if (enc->input_state) gst_video_codec_state_unref (enc->input_state); enc->input_state = NULL; /* Everything else is handled in reset() */ theora_enc_clear_multipass_cache (enc); return TRUE; }
static gboolean theora_dec_stop (GstVideoDecoder * decoder) { GstTheoraDec *dec = GST_THEORA_DEC (decoder); GST_DEBUG_OBJECT (dec, "stop"); th_info_clear (&dec->info); th_comment_clear (&dec->comment); th_setup_free (dec->setup); dec->setup = NULL; th_decode_free (dec->decoder); dec->decoder = NULL; gst_theora_dec_reset (dec); if (dec->input_state) { gst_video_codec_state_unref (dec->input_state); dec->input_state = NULL; } if (dec->output_state) { gst_video_codec_state_unref (dec->output_state); dec->output_state = NULL; } return TRUE; }
void TheoraDecoder::close() { if (_vorbisPacket) { ogg_stream_clear(&_vorbisOut); vorbis_block_clear(&_vorbisBlock); vorbis_dsp_clear(&_vorbisDSP); vorbis_comment_clear(&_vorbisComment); vorbis_info_clear(&_vorbisInfo); g_system->getMixer()->stopHandle(*_audHandle); _audStream = 0; _vorbisPacket = false; } if (_theoraPacket) { ogg_stream_clear(&_theoraOut); th_decode_free(_theoraDecode); th_comment_clear(&_theoraComment); th_info_clear(&_theoraInfo); _theoraDecode = 0; _theoraPacket = false; } if (!_fileStream) return; ogg_sync_clear(&_oggSync); delete _fileStream; _fileStream = 0; _surface.free(); _displaySurface.pixels = 0; _displaySurface.free(); reset(); }
bool CHolly_Theora_Video::Start() { m_bFrameWaiting = false; th_info thInfo; th_info_init( &thInfo ); thInfo.frame_width = Width(); thInfo.frame_height = Height(); thInfo.pic_width = Width(); thInfo.pic_height = Height(); thInfo.pic_x = 0; thInfo.pic_y = 0; thInfo.colorspace = TH_CS_ITU_REC_470BG; thInfo.pixel_fmt = TH_PF_420; // TH_PF_444 thInfo.target_bitrate = BitRate() * 1024; thInfo.quality = 42; thInfo.keyframe_granule_shift = 6; // default value thInfo.fps_numerator = FPS(); thInfo.fps_denominator = 1; thInfo.aspect_numerator = 1; thInfo.aspect_denominator = 1; m_Encoder = th_encode_alloc( &thInfo ); if ( !m_Encoder ) { return false; } th_info_clear( &thInfo ); SetupFrame(); WriteHeader(); return true; }
static int noop_test_decode () { th_info ti; th_dec_ctx *td; INFO ("+ Testing decoder context with null info and setup"); td = th_decode_alloc(NULL, NULL); if (td != NULL) FAIL("td_decode_alloc accepted null info pointers"); INFO ("+ Initializing th_info struct"); th_info_init (&ti); INFO ("+ Testing decoder context with empty info and null setup"); td = th_decode_alloc(&ti, NULL); if (td != NULL) FAIL("td_decode_alloc accepted null info pointers"); INFO ("+ Clearing th_info struct"); th_info_clear (&ti); return 0; }