Example #1
0
void clean_encoder(struct x264lib_ctx *ctx)
{
	if (ctx->rgb2yuv)
		sws_freeContext(ctx->rgb2yuv);
	if (ctx->encoder)
		x264_encoder_close(ctx->encoder);
}
Example #2
0
//compress end
void compress_end()
{
	struct encoder *en = h264_encoder;

	if (en->picture)
	{
		x264_picture_clean(en->picture);

		en->picture = NULL;
	}

	if (en->param)
	{
		free(en->param);
		en->param = NULL;
	}

	if (en->handle)
	{
		x264_encoder_close(en->handle);
	}

	free(en);
	en = NULL;
}
Example #3
0
int CLiveParser::Deinit()
{
	//* 清除图像区域
	//x264_picture_clean(m_pPicIn);
	//x264_picture_clean(m_pPicOut);

	x264_encoder_close(m_pX264Handle);
	m_pX264Handle = NULL;

	delete m_pPicIn ;
	m_pPicIn = NULL;

	delete m_pPicOut;
	m_pPicOut = NULL;

	delete m_pX264Param;
	m_pX264Param = NULL;

	if (m_pDataBuff != NULL)
	{
		delete m_pDataBuff;
		m_pDataBuff = NULL;
	}


	return J_OK;
}
Example #4
0
static void destructor(void *arg)
{
	struct vidcodec_st *st = arg;

	mem_deref(st->vc);

	mem_deref(st->dec.mb);
	mem_deref(st->enc.mb);
	mem_deref(st->mb_frag);

#ifdef USE_X264
	if (st->x264)
		x264_encoder_close(st->x264);
#endif

	if (st->enc.ctx) {
		if (st->enc.ctx->codec)
			avcodec_close(st->enc.ctx);
		av_free(st->enc.ctx);
	}

	if (st->dec.ctx) {
		if (st->dec.ctx->codec)
			avcodec_close(st->dec.ctx);
		av_free(st->dec.ctx);
	}

	if (st->enc.pict)
		av_free(st->enc.pict);
	if (st->dec.pict)
		av_free(st->dec.pict);
}
/**
    \fn ~x264Encoder
*/
x264Encoder::~x264Encoder()
{
    ADM_info("[x264] Destroying.\n");
    if (handle)
    {
        x264_encoder_close (handle);
        handle = NULL;
    }

    if(extraData)
    {
        delete [] extraData;
        extraData=NULL;
    }

    if(seiUserData)
    {
        delete [] seiUserData;
        seiUserData=NULL;
    }
    if(logFile)
    {
        ADM_dealloc(logFile);
        logFile=NULL;
    }
}
Example #6
0
/*****************************************************************************
 * CloseEncoder: x264 encoder destruction
 *****************************************************************************/
static void Close( vlc_object_t *p_this )
{
    encoder_t     *p_enc = (encoder_t *)p_this;
    encoder_sys_t *p_sys = p_enc->p_sys;

    free( p_sys->psz_stat_name );

    if( p_sys->h )
        x264_encoder_close( p_sys->h );

#ifdef PTW32_STATIC_LIB
    vlc_value_t lock, count;

    var_Get( p_enc->p_libvlc, "pthread_win32_mutex", &lock );
    vlc_mutex_lock( lock.p_address );

    var_Get( p_enc->p_libvlc, "pthread_win32_count", &count );
    count.i_int--;
    var_Set( p_enc->p_libvlc, "pthread_win32_count", count );

    if( count.i_int == 0 )
    {
        pthread_win32_thread_detach_np();
        pthread_win32_process_detach_np();
        msg_Dbg( p_enc, "pthread-win32 deinitialized" );
    }
    vlc_mutex_unlock( lock.p_address );
#endif

    free( p_sys->p_buffer );
    free( p_sys );
}
	~X264Encoder()
	{
		ClearPackets();

		if (x264)
			x264_encoder_close(x264);
	}
/**
 * When compress end, clear some resource
 */
jint
Java_com_livecamera_encoder_h264encoder_CompressEnd( JNIEnv* env, jobject thiz, jlong handle)
{
	Encoder *en = (Encoder*)handle;
	ALOGE("begin free!");
	if (en->picture) {
		ALOGE("begin free picture");
		x264_picture_clean(en->picture);
		free(en->picture);
		en->picture = 0;
	}

	ALOGE("after free picture");

	if (en->param) {
		free(en->param);
		en->param = 0;
	}

	ALOGE("after free param");

	if (en->handle) {
		x264_encoder_close(en->handle);
	}
	ALOGE("after close encoder");

	free(en);

	ALOGE("after free encoder");

	return 0;
}
Example #9
0
EncoderVideoSource::~EncoderVideoSource()
{
	Debug(ckite_log_message, "EncoderVideoSource::~EncoderVideoSource.\n");
#ifdef STARV_TEST
	if (fp)
		fclose(fp);
#endif

	if (fBuffer)
		delete [] fBuffer;
	if (fConfigBytes)
		delete fConfigBytes; 
#ifdef SDKH264 
#ifdef ENC_SOURCE
		x264_encoder_close(x264_handle);
#endif
#endif

#ifdef SDKMPEG4
#ifdef ENC_SOURCE
	if (fEncoderHandle)
		xvid_release(fEncoderHandle);
#endif
#endif
}
Example #10
0
void close_encoder(void)
{
	x264_encoder_close(encoder);
	// close(inf);
	// close(outf);
	free(yuv_buffer);
}
Example #11
0
int vc_close (void *ctx)
{
	Ctx *c = (Ctx*)ctx;
	x264_encoder_close(c->x264);
	free(c->output);
	delete c;
	return 1;
}
void BleX264Encoder::fini()
{
    BleFree(m_pictureIn);
    if (m_x264Encoder) {
        x264_encoder_close(m_x264Encoder);
    }
    BleFree(m_x264Param);
}
Example #13
0
H264Encoder::~H264Encoder() {
    if ( x264_hdl_ == NULL) {
        x264_picture_clean(&x264_picin_);
        x264_picture_clean(&x264_picout_);
        x264_encoder_close(x264_hdl_);
        x264_hdl_ = NULL;
    }
}
Example #14
0
int CX264Encoder::close()
{
	int ret = 0;
	if (h){
		x264_encoder_close(h);
		x264_picture_clean(&pic);
	}
	return ret;
}
Example #15
0
static void enc_postprocess(MSFilter *f){
	EncData *d=(EncData*)f->data;
	if(d->packer!=NULL) {
	    rfc3984_destroy(d->packer);
        d->packer=NULL;
    }
	x264_encoder_free_framebuffer(d->enc);
	x264_encoder_close(d->enc);
}
Example #16
0
bool CH264Encoder::End()
{
    if (m_pic.img.plane[0])
    {
        x264_picture_clean(&m_pic);
    }

    if (m_pSwsContext)
    {
        sws_freeContext(m_pSwsContext);
        m_pSwsContext = NULL;
    }

    if (m_pFlv)
    {
        m_pFlv->WriteTailer();
    }

    if (m_pFlv)
    {
        delete m_pFlv;
        m_pFlv = NULL;
    }

    if (mux_buffer)
    {
        free(mux_buffer);
    }
    mux_buffer = NULL;
    mux_buffer_size = 0;

    if (m_px264)
    {
        x264_encoder_close(m_px264);
        m_px264 = NULL;
    }

    m_pOutDataSink = NULL;

#ifdef YUV_FILE
    if (pYUVFile)
    {
        fclose(pYUVFile);
        pYUVFile = NULL;
    }
#endif

#ifdef H264_FILE
    if (pH264File)
    {
        fclose(pH264File);
        pH264File = NULL;
    }
#endif

    return true;
}
Example #17
0
static void enc_postprocess(MSFilter *f){
	EncData *d=(EncData*)f->data;
	rfc3984_destroy(d->packer);
	d->packer=NULL;
	if (d->enc!=NULL){
		x264_encoder_close(d->enc);
		d->enc=NULL;
	}
}
Example #18
0
H264Exporter::~H264Exporter()
{
  // Flush encoder.
  while (x264_encoder_delayed_frames(_encoder)) {
    add_frame(nullptr);
  }
  x264_picture_clean(&_pic);
  x264_encoder_close(_encoder);
  _file.close();
}
int X264Encoder::Destroy()
{
    if (m_h)
    {
        x264_picture_clean( &m_pic );

        x264_encoder_close(m_h);
    }

    return 0;
}
Example #20
0
void do_clean_encoder(struct x264lib_ctx *ctx)
{
	if (ctx->rgb2yuv) {
		sws_freeContext(ctx->rgb2yuv);
		ctx->rgb2yuv = NULL;
	}
	if (ctx->encoder) {
		x264_encoder_close(ctx->encoder);
		ctx->encoder = NULL;
	}
}
Example #21
0
int H264Encoder::Release() {
    if (x264_hdl_ ) {
        encoding_thread_->Clear(this);
        //x264_picture_clean(&x264_picin_);
        //x264_picture_clean(&x264_picout_);
        x264_encoder_close(x264_hdl_);
        x264_hdl_ = NULL;
    }
    
    return 0;
}
Example #22
0
static void clear_data(struct obs_x264 *obsx264)
{
	if (obsx264->context) {
		x264_encoder_close(obsx264->context);
		bfree(obsx264->sei);
		bfree(obsx264->extra_data);

		obsx264->context    = NULL;
		obsx264->sei        = NULL;
		obsx264->extra_data = NULL;
	}
}
Example #23
0
HRESULT CX264Encoder::UnInit()
{
    if ( m_px264Handle != NULL )
        x264_encoder_close((x264_t*)m_px264Handle);

	m_px264Handle = NULL;

    if ( m_pPic != NULL )
        x264_free( (x264_picture_t*)m_pPic );

    m_pPic = NULL;
    return true;
}
Example #24
0
void video_encoder_destroy(VideoEncoder *enc)
{
    if(enc){
	if(enc->sws)
	    sws_freeContext(enc->sws);
	if(enc->encoder)
	    x264_encoder_close(enc->encoder);
	if(enc->output_buffer)
	    free(enc->output_buffer);

	free(enc);
    }
}
Example #25
0
EncoderVideoSource::~EncoderVideoSource()
{
	Debug(ckite_log_message, "EncoderVideoSource::~EncoderVideoSource.\n");
	if (fp)
		fclose(fp);
	if (fBuffer)
		delete [] fBuffer;
	if (fConfigBytes)
		delete fConfigBytes;
	if (x264_handle)
		x264_encoder_close(x264_handle);
	if (fEncoderHandle)
		xvid_release(fEncoderHandle);
}
bool X264Encoder::closeX264Encoder()
{
    if (pOutput) {
        free(pOutput);
        pOutput = NULL;
    }
    if (pParameter) {
        free(pParameter);
        pParameter = NULL;
    }
    if (x264EncoderHandle) {
        x264_encoder_close(x264EncoderHandle);
        x264EncoderHandle = NULL;
    }
    return true;
}
Example #27
0
void encoder_end(Encoder *encoder) 
{
	if (encoder->picture) {
		x264_picture_clean(encoder->picture);
		free(encoder->picture);
		encoder->picture = 0;
	}
	if (encoder->param) {
		free(encoder->param);
		encoder->param = 0;
	}
	if (encoder->handle) {
		x264_encoder_close(encoder->handle);
	}
	free(g_H264_Buf);
}
Example #28
0
int CH264Encoder::Clean()
{
	if (m_hx264!=NULL)
	{
		m_bIsworking=false;
		int m_inal=0;		
		x264_encoder_encode(m_hx264,&m_x264_nal,&m_inal,NULL,&m_x264_picout);
		x264_encoder_close(m_hx264);
		m_hx264=NULL;
		if (m_x264_picin!=NULL)
		{
			free(m_x264_picin);
			m_x264_picin=NULL;
		}		
	}
	return 0;
}
Example #29
0
msx264::~msx264()
{
//* 清除图像区域
	x264_picture_clean(pPicIn);
	x264_picture_clean(pPicOut);
//* 关闭编码器句柄
	x264_encoder_close(pX264Handle);
	pX264Handle = NULL;

	delete pPicIn;
	pPicIn = NULL;

	delete pPicOut;
	pPicOut = NULL;

    close(file);
	//delete params;
	//params = NULL;
}
Example #30
0
void encode_close()
{
	x264_picture_clean(x264_encode.pic);
	x264_encoder_close(x264_encode.handle);

	if(h264_buf) {
		free(h264_buf);
		h264_buf = NULL;
	}

	if(x264_encode.para) {
		free(x264_encode.para);
		x264_encode.para = NULL;
	}

	if(x264_encode.nal) {
		free(x264_encode.nal);
		x264_encode.nal = NULL;
	}
}