MISR Toolkit  1.5.1
MtkDataBufferImport.c
Go to the documentation of this file.
1 /*===========================================================================
2 = =
3 = MtkDataBufferImport =
4 = =
5 =============================================================================
6 
7  Jet Propulsion Laboratory
8  MISR
9  MISR Toolkit
10 
11  Copyright 2005, California Institute of Technology.
12  ALL RIGHTS RESERVED.
13  U.S. Government Sponsorship acknowledged.
14 
15 ============================================================================*/
16 
17 #include "MisrUtil.h"
18 #include <stdlib.h>
19 
36  int nline,
37  int nsample,
39  void *dataptr,
40  MTKt_DataBuffer *databuf )
41 {
42  MTKt_status status_code; /* Return status of this function */
44  /* Data buffer structure */
45  int datasize[] = MTKd_DataSize; /* Data size by data type */
46  int i; /* Index */
47 
48  if (databuf == NULL)
50 
51  if (dataptr == NULL)
53 
54  if (nline < 0)
56 
57  if (nsample < 0)
59 
60  dbuf.nline = nline;
61  dbuf.nsample = nsample;
62  dbuf.datasize = datasize[datatype];
63  dbuf.datatype = datatype;
64  dbuf.imported = MTK_TRUE; /* Data pointer is allocated outside Mtk */
65 
66  /* Allocate 1D Illiffe vector */
67  dbuf.vdata = (void **)calloc(dbuf.nline, sizeof(void *));
68  if (dbuf.vdata == NULL)
70 
71  /* Allocate 2D buffer */
72  dbuf.vdata[0] = dataptr;
73 
74  /* Connect Illiffe vector */
75  for (i = 1; i < nline; i++) {
76  dbuf.vdata[i] = (void *)((unsigned char *)(dbuf.vdata[i-1]) +
77  dbuf.nsample * dbuf.datasize);
78  }
79 
80  /* Hook the union to the void data pointer */
81  dbuf.data.v = dbuf.vdata;
82  /* Hook the data pointer to the data */
83  dbuf.dataptr = dbuf.vdata[0];
84 
85  *databuf = dbuf;
86 
87  return MTK_SUCCESS;
88 
89 ERROR_HANDLE:
90  return status_code;
91 }
MTKt_status MtkDataBufferImport(int nline, int nsample, MTKt_DataType datatype, void *dataptr, MTKt_DataBuffer *databuf)
Import Data Buffer.
HDFFCLIBAPI _fcd _fcd intf intf * datatype
MTKt_DataBufferType data
Definition: MisrUtil.h:104
MTKt_DataType
Definition: MisrUtil.h:36
#define MTK_ERR_CODE_JUMP(code)
Definition: MisrError.h:175
2-dimensional Data Buffer
Definition: MisrUtil.h:98
void ** vdata
Definition: MisrUtil.h:105
#define MTKT_DATABUFFER_INIT
Definition: MisrUtil.h:109
void * dataptr
Definition: MisrUtil.h:106
MTKt_DataType datatype
Definition: MisrUtil.h:102
#define MTKd_DataSize
Definition: MisrUtil.h:34
MTKt_status
Definition: MisrError.h:11
MTKt_boolean imported
Definition: MisrUtil.h:103
int const JOCTET * dataptr
Definition: jpeglib.h:950

MISR Toolkit - Copyright © 2005 - 2020 Jet Propulsion Laboratory
Generated on Fri Jun 19 2020 22:49:51