Пример #1
0
/*-------------------------------------------------------------------------
 * Function:  h5_szip_can_encode
 *
 * Purpose:  Retrieve the filter config flags for szip, tell if
 *              encoder is available.
 *
 * Return:  1:  decode+encode is enabled
 *    0:  only decode is enabled
 *              -1: other
 *
 * Programmer:
 *
 * Modifications:
 *
 *-------------------------------------------------------------------------
 */
int h5_szip_can_encode(void )
{
    unsigned int filter_config_flags;

    H5Zget_filter_info(H5Z_FILTER_SZIP, &filter_config_flags);
    if ((filter_config_flags &
            (H5Z_FILTER_CONFIG_ENCODE_ENABLED|H5Z_FILTER_CONFIG_DECODE_ENABLED)) == 0) {
        /* filter present but neither encode nor decode is supported (???) */
        return -1;
    } else if ((filter_config_flags &
            (H5Z_FILTER_CONFIG_ENCODE_ENABLED|H5Z_FILTER_CONFIG_DECODE_ENABLED)) ==
            H5Z_FILTER_CONFIG_DECODE_ENABLED) {
        /* decoder only: read but not write */
        return 0;
    } else if ((filter_config_flags &
            (H5Z_FILTER_CONFIG_ENCODE_ENABLED|H5Z_FILTER_CONFIG_DECODE_ENABLED)) ==
            H5Z_FILTER_CONFIG_ENCODE_ENABLED) {
        /* encoder only: write but not read (???) */
        return -1;
    } else if ((filter_config_flags &
            (H5Z_FILTER_CONFIG_ENCODE_ENABLED|H5Z_FILTER_CONFIG_DECODE_ENABLED)) ==
            (H5Z_FILTER_CONFIG_ENCODE_ENABLED|H5Z_FILTER_CONFIG_DECODE_ENABLED)) {
        return 1;
    }
   return(-1);
}
Пример #2
0
JNIEXPORT jint JNICALL
Java_hdf_hdf5lib_H5_H5Zget_1filter_1info
    (JNIEnv *env, jclass clss, jint filter)
{
    unsigned int flags = 0;

    if (H5Zget_filter_info ((H5Z_filter_t) filter, (unsigned *) &flags) < 0)
        h5libraryError(env);

    return (jint)flags;
} /* end Java_hdf_hdf5lib_H5_H5Zget_1filter_1info */
Пример #3
0
int_f
nh5zget_filter_info_c ( int_f *filter , int_f *flag )
/******/
{
  int ret_value = 0;
  H5Z_filter_t c_filter;
  unsigned int c_flag;

  c_filter = (H5Z_filter_t)*filter;
  ret_value = H5Zget_filter_info(c_filter, &c_flag);
  *flag = (int_f)c_flag;

  return ret_value;
}
Пример #4
0
//=========================================================================
void mexFunction( int nlhs, mxArray *plhs[], int nrhs, const mxArray *prhs[])
{
    if (nrhs < 1 || !mxIsChar(prhs[0])) 
        mexErrMsgTxt("First parameter must be the command (a string)");
    
    char cmd[100];
	mxGetString(prhs[0],cmd,100);
    
    if (!strcmp("H5Fcreate",cmd)){
       //See h5f
       //
       //file_id = hdf5_mex('H5Fcreate',file_name);
       //
       //TODO: Eventually this will be changed to allow
       //all inputs, not just the file
       hid_t file;
       file = H5Fcreate("Attributes.h5", H5F_ACC_TRUNC, H5P_DEFAULT, H5P_DEFAULT);
       
    } else if (!strcmp("H5Fopen",cmd)){
        
	} else if (!strcmp("H5Fclose",cmd)){
        
    } else if (!strcmp("H5Zfilter_avail",cmd)){
      //http://www.hdfgroup.org/HDF5/doc/RM/RM_H5Z.html#Compression-FilterAvail
      //
      //    status = hdf5_mex('H5Zfilter_avail',filter_id);    
        
      htri_t status;
      //TODO: Remove hard coded filter values
      // - this requires enumeration support
      status = H5Zfilter_avail(H5Z_FILTER_SZIP);
      
      setInt8Output(plhs,0,(int8)status); 
    } else if (!strcmp("H5Zget_filter_info",cmd)){
      //http://www.hdfgroup.org/HDF5/doc/RM/RM_H5Z.html#Compression-GetFilterInfo
      //H5Z_filter_t filter, unsigned int *filter_config   
      //
      //    [err,config] = hdf5_mex('H5Zget_filter_info',filter_id);  
        
      unsigned int filter_config = 0;
      herr_t function_error;
      //TODO: Replace hardcoded value
      function_error = H5Zget_filter_info(H5Z_FILTER_SZIP,&filter_config);
      setInt8Output(plhs,0,(int8)function_error);
      setInt8Output(plhs,0,(int8)filter_config);
    } else if (!strcmp("H5MLget_constant_value",cmd)){
        char *enum_string;
        enum_string = mxArrayToString(prhs[1]);
        
        //TODO: I'm still working on this. Once this code works I'll need
        //to create a function that will support translation of a given
        //input with the following features
        // - handling string or number
        // - handling invalid options - i.e. bad strings - throw error
        // - handling all number types
        //mexPrintf("Test: %d\n",ENUM_MAP.at("H5D_CHUNKED"));
        
        //map<string, int>::iterator p;
        //p = ENUM_MAP.find("H5D_CHUNKED");
        //mexPrintf("Test: %d",ENUM_MAP["H5D_CHUNKED"]);
        setDoubleOutput(plhs,0,(double)(ENUM_MAP[enum_string]));  
    }
    
    //herr_t  ret;
    
    
    //ret  = H5Fclose(file);
}
Пример #5
0
/*-------------------------------------------------------------------------
 * Function: h5tools_canwritef
 *
 * Purpose: check if the filter is available and can write data.
 * At this time, all filters that are available can write data,
 * except SZIP, which may be configured decoder-only.
 *
 * Return: 1, can write, 0, cannot, -1 error
 *
 * Programmer:
 *
 * Date: October 5, 2004
 *
 *-------------------------------------------------------------------------
 */
int h5tools_can_encode( H5Z_filter_t filtn)
{

 int          have_deflate=0; /* assume initially we do not have filters */
 int          have_szip=0;
 int          have_shuffle=0;
 int          have_fletcher=0;
 unsigned int filter_config_flags;

#ifdef H5_HAVE_FILTER_DEFLATE
 have_deflate=1;
#endif
#ifdef H5_HAVE_FILTER_SZIP
 have_szip=1;
#endif
#ifdef H5_HAVE_FILTER_SHUFFLE
 have_shuffle=1;
#endif
#ifdef H5_HAVE_FILTER_FLETCHER32
 have_fletcher=1;
#endif

  switch (filtn)
  {
    /* user defined filter     */
  default:
    return 0;

  case H5Z_FILTER_DEFLATE:
   if (!have_deflate)
   {
    return 0;
   }
   break;
  case H5Z_FILTER_SZIP:
   if (!have_szip)
   {
    return 0;
   }
   if(H5Zget_filter_info(filtn, &filter_config_flags)<0)
       return -1;
   if ((filter_config_flags &
          (H5Z_FILTER_CONFIG_ENCODE_ENABLED|H5Z_FILTER_CONFIG_DECODE_ENABLED)) == 0) {
    /* filter present but neither encode nor decode is supported (???) */
    return -1;
   } else if ((filter_config_flags &
          (H5Z_FILTER_CONFIG_ENCODE_ENABLED|H5Z_FILTER_CONFIG_DECODE_ENABLED)) ==
    H5Z_FILTER_CONFIG_DECODE_ENABLED) {
     /* decoder only: read but not write */
    return 0;
   } else if ((filter_config_flags &
          (H5Z_FILTER_CONFIG_ENCODE_ENABLED|H5Z_FILTER_CONFIG_DECODE_ENABLED)) ==
    H5Z_FILTER_CONFIG_ENCODE_ENABLED) {
     /* encoder only: write but not read (???) */
     return -1;
   } else if ((filter_config_flags &
          (H5Z_FILTER_CONFIG_ENCODE_ENABLED|H5Z_FILTER_CONFIG_DECODE_ENABLED)) ==
          (H5Z_FILTER_CONFIG_ENCODE_ENABLED|H5Z_FILTER_CONFIG_DECODE_ENABLED)) {
    return 1;
   }
   break;
  case H5Z_FILTER_SHUFFLE:
   if (!have_shuffle)
   {
    return 0;
   }
   break;
  case H5Z_FILTER_FLETCHER32:
   if (!have_fletcher)
   {
    return 0;
   }
   break;
  }/*switch*/

 return 1;
}
Пример #6
0
/*-------------------------------------------------------------------------
 * Function: h5tools_canwritef
 *
 * Purpose: check if the filter is available and can write data.
 * At this time, all filters that are available can write data,
 * except SZIP, which may be configured decoder-only.
 *
 * Return: 1, can write, 0, cannot, -1 error
 *
 * Programmer:
 *
 * Date: October 5, 2004
 *
 *-------------------------------------------------------------------------
 */
int h5tools_can_encode( H5Z_filter_t filtn)
{
    switch (filtn)
    {
    /* user defined filter     */
    default:
        return 0;

    case H5Z_FILTER_DEFLATE:
#ifndef H5_HAVE_FILTER_DEFLATE
        return 0;
#endif
        break;
    case H5Z_FILTER_SZIP:
#ifndef H5_HAVE_FILTER_SZIP
        return 0;
#else
        {
            unsigned int filter_config_flags;

            if(H5Zget_filter_info(filtn, &filter_config_flags)<0)
                return -1;
            if ((filter_config_flags &
                    (H5Z_FILTER_CONFIG_ENCODE_ENABLED|H5Z_FILTER_CONFIG_DECODE_ENABLED)) == 0) {
                /* filter present but neither encode nor decode is supported (???) */
                return -1;
            } else if ((filter_config_flags &
                        (H5Z_FILTER_CONFIG_ENCODE_ENABLED|H5Z_FILTER_CONFIG_DECODE_ENABLED)) ==
                       H5Z_FILTER_CONFIG_DECODE_ENABLED) {
                /* decoder only: read but not write */
                return 0;
            } else if ((filter_config_flags &
                        (H5Z_FILTER_CONFIG_ENCODE_ENABLED|H5Z_FILTER_CONFIG_DECODE_ENABLED)) ==
                       H5Z_FILTER_CONFIG_ENCODE_ENABLED) {
                /* encoder only: write but not read (???) */
                return -1;
            } else if ((filter_config_flags &
                        (H5Z_FILTER_CONFIG_ENCODE_ENABLED|H5Z_FILTER_CONFIG_DECODE_ENABLED)) ==
                       (H5Z_FILTER_CONFIG_ENCODE_ENABLED|H5Z_FILTER_CONFIG_DECODE_ENABLED)) {
                return 1;
            }
        }
#endif
        break;
    case H5Z_FILTER_SHUFFLE:
#ifndef H5_HAVE_FILTER_SHUFFLE
        return 0;
#endif
        break;
    case H5Z_FILTER_FLETCHER32:
#ifndef H5_HAVE_FILTER_FLETCHER32
        return 0;
#endif
        break;
    case H5Z_FILTER_NBIT:
#ifndef H5_HAVE_FILTER_NBIT
        return 0;
#endif
        break;
    case H5Z_FILTER_SCALEOFFSET:
#ifndef H5_HAVE_FILTER_SCALEOFFSET
        return 0;
#endif
        break;
    }/*switch*/

    return 1;
}