void libcedarx_decoder_close(void) { cedarx_decoder_t* decoder = cedarx_decoder; if (decoder) { if (decoder->ve) { libve_flush(0, decoder->ve); libve_close(0, decoder->ve); } if (decoder->init_data) mem_free(decoder->init_data); if (decoder->vbv) { vbv_exit(decoder->vbv); } ve_release(); if (!cedarx_display) mem_exit(); ve_exit(); mem_free(decoder); cedarx_decoder = NULL; } }
/*========================================================================= * FUNCTION: tVM_Exit * TYPE: public interface * OVERVIEW: exit Virtual Machine * INTERFACE: * returns: 0 : exit wrong * 1 : exit success *=======================================================================*/ int tVM_Exit() { tcodefile_release(tVM_codefile); tRunstack_release(tVM_runstack); mem_exit(); return 1; }
static void __exit net_malloc_exit(void) { if (network_thread != NULL) { network_is_running = 0; kthread_stop(network_thread); } mem_exit(); }
void libcedarx_display_close(void) { int time = 20; unsigned long args[4]; cedarx_display_t* display = cedarx_display; if (display) { pthread_mutex_lock(&display->mutex); if (display->info.enable) { args[0] = 0; args[1] = display->info.layer; args[2] = 0; args[3] = 0; if (display->info.init) { if (display->info.start) { while (ioctl(display->fd, DISP_CMD_VIDEO_GET_FRAME_ID, args) != display->info.last_id) { if (--time < 0) break; usleep(1000); } } ioctl(display->fd, DISP_CMD_LAYER_CLOSE, args ); usleep(20000); ioctl(display->fd, DISP_CMD_VIDEO_STOP, args); } ioctl(display->fd, DISP_CMD_LAYER_RELEASE, args); } pthread_mutex_unlock(&display->mutex); pthread_mutex_destroy(&display->mutex); close(display->fd); free(display); if (!cedarx_decoder) mem_exit(); cedarx_display = NULL; } }
cedarx_result_e libcedarx_decoder_open(cedarx_info_t* info) { cedarx_result_e result; vconfig_t config; vstream_info_t stream_info; cedarx_decoder_t* decoder; if (!info) return CEDARX_RESULT_INVALID_ARGS; decoder = (cedarx_decoder_t*)mem_alloc(sizeof(cedarx_decoder_t)); if (!decoder) return CEDARX_RESULT_NO_ENOUGH_MEMORY; mem_set(decoder, 0, sizeof(cedarx_decoder_t)); cedarx_decoder = decoder; result = ve_init(); if (CEDARX_RESULT_OK != result) goto failed2; mem_set(&config, 0, sizeof(vconfig_t)); mem_set(&stream_info, 0, sizeof(vstream_info_t)); config.max_video_width = MAX_SUPPORTED_VIDEO_WIDTH; config.max_video_height = MAX_SUPPORTED_VIDEO_HEIGHT; config.max_output_width = MAX_SUPPORTED_OUTPUT_WIDTH; config.max_output_height = MAX_SUPPORTED_OUTPUT_HEIGHT; switch (info->stream) { case CEDARX_STREAM_FORMAT_MPEG1: stream_info.format = STREAM_FORMAT_MPEG2; stream_info.sub_format = MPEG2_SUB_FORMAT_MPEG1; break; case CEDARX_STREAM_FORMAT_MPEG2: stream_info.format = STREAM_FORMAT_MPEG2; stream_info.sub_format = MPEG2_SUB_FORMAT_MPEG2; break; case CEDARX_STREAM_FORMAT_XVID: stream_info.format = STREAM_FORMAT_MPEG4; stream_info.sub_format = MPEG4_SUB_FORMAT_XVID; break; case CEDARX_STREAM_FORMAT_DIVX1: stream_info.format = STREAM_FORMAT_MPEG4; stream_info.sub_format = MPEG4_SUB_FORMAT_DIVX1; break; case CEDARX_STREAM_FORMAT_DIVX2: stream_info.format = STREAM_FORMAT_MPEG4; stream_info.sub_format = MPEG4_SUB_FORMAT_DIVX2; break; case CEDARX_STREAM_FORMAT_DIVX3: stream_info.format = STREAM_FORMAT_MPEG4; stream_info.sub_format = MPEG4_SUB_FORMAT_DIVX3; break; case CEDARX_STREAM_FORMAT_DIVX4: stream_info.format = STREAM_FORMAT_MPEG4; stream_info.sub_format = MPEG4_SUB_FORMAT_DIVX4; break; case CEDARX_STREAM_FORMAT_DIVX5: stream_info.format = STREAM_FORMAT_MPEG4; stream_info.sub_format = MPEG4_SUB_FORMAT_DIVX5; break; case CEDARX_STREAM_FORMAT_H263: stream_info.format = STREAM_FORMAT_MPEG4; stream_info.sub_format = MPEG4_SUB_FORMAT_H263; break; case CEDARX_STREAM_FORMAT_SORENSSON_H263: stream_info.format = STREAM_FORMAT_MPEG4; stream_info.sub_format = MPEG4_SUB_FORMAT_SORENSSON_H263; break; case CEDARX_STREAM_FORMAT_WMV1: stream_info.format = STREAM_FORMAT_MPEG4; stream_info.sub_format = MPEG4_SUB_FORMAT_WMV1; break; case CEDARX_STREAM_FORMAT_WMV2: stream_info.format = STREAM_FORMAT_MPEG4; stream_info.sub_format = MPEG4_SUB_FORMAT_WMV2; break; case CEDARX_STREAM_FORMAT_VP6: stream_info.format = STREAM_FORMAT_MPEG4; stream_info.sub_format = MPEG4_SUB_FORMAT_VP6; break; case CEDARX_STREAM_FORMAT_REALVIDEO: stream_info.format = STREAM_FORMAT_REALVIDEO; stream_info.sub_format = STREAM_SUB_FORMAT_UNKNOW; break; case CEDARX_STREAM_FORMAT_H264: stream_info.format = STREAM_FORMAT_H264; stream_info.sub_format = STREAM_SUB_FORMAT_UNKNOW; decoder->greedy = 1; break; case CEDARX_STREAM_FORMAT_AVC1: stream_info.format = STREAM_FORMAT_H264; stream_info.sub_format = STREAM_SUB_FORMAT_UNKNOW; decoder->greedy = 1; break; case CEDARX_STREAM_FORMAT_VC1: stream_info.format = STREAM_FORMAT_VC1; stream_info.sub_format = STREAM_SUB_FORMAT_UNKNOW; break; case CEDARX_STREAM_FORMAT_AVS: stream_info.format = STREAM_FORMAT_AVS; stream_info.sub_format = STREAM_SUB_FORMAT_UNKNOW; break; case CEDARX_STREAM_FORMAT_MJPEG: stream_info.format = STREAM_FORMAT_MJPEG; stream_info.sub_format = STREAM_SUB_FORMAT_UNKNOW; break; case CEDARX_STREAM_FORMAT_VP8: stream_info.format = STREAM_FORMAT_VP8; stream_info.sub_format = STREAM_SUB_FORMAT_UNKNOW; break; default: stream_info.format = STREAM_FORMAT_H264; stream_info.sub_format = STREAM_SUB_FORMAT_UNKNOW; break; } switch (info->container) { case CEDARX_CONTAINER_FORMAT_AVI: stream_info.container_format = CONTAINER_FORMAT_AVI; break; case CEDARX_CONTAINER_FORMAT_ASF: stream_info.container_format = CONTAINER_FORMAT_ASF; break; case CEDARX_CONTAINER_FORMAT_DAT: stream_info.container_format = CONTAINER_FORMAT_DAT; break; case CEDARX_CONTAINER_FORMAT_FLV: stream_info.container_format = CONTAINER_FORMAT_FLV; break; case CEDARX_CONTAINER_FORMAT_MKV: stream_info.container_format = CONTAINER_FORMAT_MKV; break; case CEDARX_CONTAINER_FORMAT_MOV: stream_info.container_format = CONTAINER_FORMAT_MOV; break; case CEDARX_CONTAINER_FORMAT_MPG: stream_info.container_format = CONTAINER_FORMAT_MPG; break; case CEDARX_CONTAINER_FORMAT_PMP: stream_info.container_format = CONTAINER_FORMAT_PMP; break; case CEDARX_CONTAINER_FORMAT_RM: stream_info.container_format = CONTAINER_FORMAT_RM; break; case CEDARX_CONTAINER_FORMAT_TS: stream_info.container_format = CONTAINER_FORMAT_TS; stream_info.is_pts_correct = 1; break; case CEDARX_CONTAINER_FORMAT_VOB: stream_info.container_format = CONTAINER_FORMAT_VOB; break; case CEDARX_CONTAINER_FORMAT_WEBM: stream_info.container_format = CONTAINER_FORMAT_WEBM; break; case CEDARX_CONTAINER_FORMAT_OGM: stream_info.container_format = CONTAINER_FORMAT_OGM; break; default: stream_info.container_format = CONTAINER_FORMAT_UNKNOW; break; } stream_info.video_width = info->width; stream_info.video_height = info->height; stream_info.frame_rate = info->frame_rate; stream_info.frame_duration = info->frame_duration; stream_info.aspec_ratio = 1000; if (info->data && (info->data_size > 0)) { decoder->init_data = mem_alloc(info->data_size); if (!decoder->init_data) goto failed2; mem_cpy(decoder->init_data, info->data, info->data_size); stream_info.init_data = decoder->init_data; stream_info.init_data_len = info->data_size; } else { stream_info.init_data_len = 0; stream_info.init_data = NULL; } stream_info._3d_mode = _3D_MODE_NONE; mem_init(decoder->fd); ve_request(); if (info->request_buffer) decoder->request_buffer = info->request_buffer; if (info->update_buffer) decoder->update_buffer = info->update_buffer; if (info->release_buffer) decoder->release_buffer = info->release_buffer; if (info->lock_buffer) decoder->lock_buffer = info->lock_buffer; if (info->unlock_buffer) decoder->unlock_buffer = info->unlock_buffer; decoder->sys = info->sys; decoder->ve = libve_open(&config, &stream_info, decoder); if (!decoder->ve) { result = CEDARX_RESULT_VE_FAILED; goto failed1; } decoder->vbv = vbv_init(); if (!decoder->vbv) { result = CEDARX_RESULT_NO_ENOUGH_MEMORY; goto failed1; } libve_set_vbv(decoder->vbv, decoder->ve); return CEDARX_RESULT_OK; failed1: ve_release(); mem_exit(); ve_exit(); if (decoder->init_data) mem_free(decoder->init_data); failed2: mem_free(decoder); cedarx_decoder = NULL; return result; }