コード例 #1
0
ファイル: openjpeg.c プロジェクト: MakersF/BlenderDev
opj_cinfo_t* OPJ_CALLCONV opj_create_compress(OPJ_CODEC_FORMAT format) {
	opj_cinfo_t *cinfo = (opj_cinfo_t*)opj_malloc(sizeof(opj_cinfo_t));
	if(!cinfo) return NULL;
	cinfo->is_decompressor = false;
	switch(format) {
		case CODEC_J2K:
			/* get a J2K coder handle */
			cinfo->j2k_handle = (void*)j2k_create_compress((opj_common_ptr)cinfo);
			if(!cinfo->j2k_handle) {
				opj_free(cinfo);
				return NULL;
			}
			break;
		case CODEC_JP2:
			/* get a JP2 coder handle */
			cinfo->jp2_handle = (void*)jp2_create_compress((opj_common_ptr)cinfo);
			if(!cinfo->jp2_handle) {
				opj_free(cinfo);
				return NULL;
			}
			break;
		case CODEC_JPT:
		case CODEC_UNKNOWN:
		default:
			opj_free(cinfo);
			return NULL;
	}

	cinfo->codec_format = format;

	return cinfo;
}
コード例 #2
0
ファイル: openjpeg.c プロジェクト: antonin07130/ITK
opj_codec_t* OPJ_CALLCONV opj_create_compress(OPJ_CODEC_FORMAT p_format)
{
  opj_codec_private_t *l_info = 00;

  l_info = (opj_codec_private_t*)opj_calloc(1, sizeof(opj_codec_private_t));
  if
    (!l_info)
  {
    return 00;
  }
  memset(l_info, 0, sizeof(opj_codec_private_t));
  l_info->is_decompressor = 0;
  switch
    (p_format)
  {
    case CODEC_J2K:
      l_info->m_codec_data.m_compression.opj_encode = (bool (*) (void *, struct opj_stream_private *, struct opj_event_mgr * )) j2k_encode;
      l_info->m_codec_data.m_compression.opj_end_compress = (bool (*) (void *, struct opj_stream_private *, struct opj_event_mgr *)) j2k_end_compress;
      l_info->m_codec_data.m_compression.opj_start_compress = (bool (*) (void *,struct opj_stream_private *,struct opj_image * ,  struct opj_event_mgr *)) j2k_start_compress;
      l_info->m_codec_data.m_compression.opj_write_tile = (bool (*) (void *,OPJ_UINT32,OPJ_BYTE*,OPJ_UINT32,struct opj_stream_private *,  struct opj_event_mgr *)) j2k_write_tile;
      l_info->m_codec_data.m_compression.opj_destroy = (void (*) (void *)) j2k_destroy;
      l_info->m_codec_data.m_compression.opj_setup_encoder = (void (*) (void *,opj_cparameters_t *,struct opj_image *, struct opj_event_mgr * )) j2k_setup_encoder;

      l_info->m_codec = j2k_create_compress();
      if
        (! l_info->m_codec)
      {
        opj_free(l_info);
        return 00;
      }
      break;

    case CODEC_JP2:
      /* get a JP2 decoder handle */
      l_info->m_codec_data.m_compression.opj_encode = (bool (*) (void *, struct opj_stream_private *, struct opj_event_mgr * )) jp2_encode;
      l_info->m_codec_data.m_compression.opj_end_compress = (bool (*) (void *, struct opj_stream_private *, struct opj_event_mgr *)) jp2_end_compress;
      l_info->m_codec_data.m_compression.opj_start_compress = (bool (*) (void *,struct opj_stream_private *,struct opj_image * ,  struct opj_event_mgr *))  jp2_start_compress;
      l_info->m_codec_data.m_compression.opj_write_tile = (bool (*) (void *,OPJ_UINT32,OPJ_BYTE*,OPJ_UINT32,struct opj_stream_private *,  struct opj_event_mgr *)) jp2_write_tile;
      l_info->m_codec_data.m_compression.opj_destroy = (void (*) (void *)) jp2_destroy;
      l_info->m_codec_data.m_compression.opj_setup_encoder = (void (*) (void *,opj_cparameters_t *,struct opj_image *, struct opj_event_mgr * )) jp2_setup_encoder;

      l_info->m_codec = jp2_create(false);
      if
        (! l_info->m_codec)
      {
        opj_free(l_info);
        return 00;
      }
      break;
    case CODEC_UNKNOWN:
    case CODEC_JPT:
    default:
      opj_free(l_info);
      return 00;
  }
  set_default_event_handler(&(l_info->m_event_mgr));
  return (opj_codec_t*) l_info;
}
コード例 #3
0
ファイル: jp2.c プロジェクト: ArphonePei/PDFConverter
opj_jp2_t* jp2_create_compress(opj_common_ptr cinfo) {
	opj_jp2_t *jp2 = (opj_jp2_t*)opj_malloc(sizeof(opj_jp2_t));
	if(jp2) {
		jp2->cinfo = cinfo;
		/* create the J2K codec */
		jp2->j2k = j2k_create_compress(cinfo);
		if(jp2->j2k == NULL) {
			jp2_destroy_compress(jp2);
			return NULL;
		}
	}
	return jp2;
}