s32 libcedarv_exit(cedarv_decoder_t* p) { video_decoder_t* decoder; if(p == NULL) return CEDARV_RESULT_ERR_INVALID_PARAM; decoder = (video_decoder_t*)p; if(decoder->stream_info.init_data != NULL) { mem_free(decoder->stream_info.init_data); decoder->stream_info.init_data = NULL; } if(decoder->vbv != NULL) { vbv_release(decoder->vbv); decoder->vbv = NULL; } if(decoder->ve != NULL) { libve_close(0, decoder->ve); decoder->ve = NULL; decoder->fbm = NULL; } mem_free(decoder); g_vdecoder = NULL; cedardev_exit(); return CEDARV_RESULT_OK; }
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; } }
static s32 vdecoder_close(cedarv_decoder_t* p) { video_decoder_t* decoder; if(p == NULL) return CEDARV_RESULT_ERR_INVALID_PARAM; decoder = (video_decoder_t*)p; libve_reset(0, decoder->ve); if(decoder->stream_info.init_data != NULL) { mem_free(decoder->stream_info.init_data); decoder->stream_info.init_data = NULL; } if(decoder->ve != NULL) { libve_close(0, decoder->ve); decoder->ve = NULL; decoder->fbm = NULL; } if(decoder->vbv != NULL) { vbv_release(decoder->vbv); decoder->vbv = NULL; } return CEDARV_RESULT_OK; }
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; if ((info->width > MAX_SUPPORTED_VIDEO_WIDTH) || \ (info->height > MAX_SUPPORTED_VIDEO_HEIGHT)) 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 failed3; 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; stream_info.is_pts_correct = 1; 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: result = CEDARX_RESULT_INVALID_ARGS; goto failed2; } 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) { result = CEDARX_RESULT_NO_ENOUGH_MEMORY; 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; } libve_reset(0, decoder->ve); decoder->vbv = vbv_init(); if (!decoder->vbv) { result = CEDARX_RESULT_NO_ENOUGH_MEMORY; goto failed0; } libve_set_vbv(decoder->vbv, decoder->ve); return CEDARX_RESULT_OK; failed0: libve_close(0, decoder->ve); failed1: ve_release(); mem_exit(); if (decoder->init_data) mem_free(decoder->init_data); failed2: ve_exit(); failed3: mem_free(decoder); cedarx_decoder = NULL; return result; }