fitsbody.c 33.5 KB
Newer Older
1001
1002
1003
1004
1005
1006
1007
1008
1009
        {
        if (spoonful>size)
          spoonful = size;
        switch(tab->bitpix)
          {
          case BP_BYTE:
            if (tab->bitsgn)
              {
               char	*bufdata = (char *)cbufdata0;
1010
#pragma ivdep
1011
1012
1013
1014
1015
1016
              for (i=spoonful; i--;)
                *(bufdata++) = (char)*(ptr++);
              }
            else
              {
               unsigned char	*bufdata = (unsigned char *)cbufdata0;
1017
#pragma ivdep
1018
1019
1020
1021
1022
1023
1024
1025
1026
              for (i=spoonful; i--;)
                *(bufdata++) = (unsigned char)*(ptr++);
              }
            break;

          case BP_SHORT:
            if (tab->bitsgn)
              {
               short	*bufdata = (short *)cbufdata0;
1027
#pragma ivdep
1028
1029
1030
1031
1032
1033
              for (i=spoonful; i--;)
                *(bufdata++) = (short)*(ptr++);
              }
            else
              {
               unsigned short	*bufdata = (unsigned short *)cbufdata0;
1034
#pragma ivdep
1035
1036
1037
1038
1039
1040
1041
1042
1043
1044
1045
              for (i=spoonful; i--;)
                *(bufdata++) = (unsigned short)*(ptr++);
              }
            if (bswapflag)
              swapbytes(cbufdata0, 2, spoonful);
            break;

          case BP_LONG:
           if (tab->bitsgn)
              {
               int	*bufdata = (int *)cbufdata0;
1046
#pragma ivdep
1047
1048
1049
1050
1051
1052
              for (i=spoonful; i--;)
                *(bufdata++) = (int)*(ptr++);
              }
            else
              {
               unsigned int	*bufdata = (unsigned int *)cbufdata0;
1053
#pragma ivdep
1054
1055
1056
1057
1058
1059
1060
1061
1062
1063
1064
              for (i=spoonful; i--;)
                *(bufdata++) = (unsigned int)*(ptr++);
              }
            if (bswapflag)
              swapbytes(cbufdata0, 4, spoonful);
            break;

#ifdef HAVE_LONG_LONG_INT
          case BP_LONGLONG:
           if (tab->bitsgn)
              {
1065
               SLONGLONG	*bufdata = (SLONGLONG *)cbufdata0;
1066
#pragma ivdep
1067
              for (i=spoonful; i--;)
1068
                *(bufdata++) = (SLONGLONG)*(ptr++);
1069
1070
1071
1072
              }
            else
              {
               ULONGLONG	*bufdata = (ULONGLONG *)cbufdata0;
1073
#pragma ivdep
1074
1075
1076
1077
1078
1079
1080
1081
1082
1083
              for (i=spoonful; i--;)
                *(bufdata++) = (ULONGLONG)*(ptr++);
              }
            if (bswapflag)
              swapbytes(cbufdata0, 8, spoonful);
            break;
#endif
          case BP_FLOAT:
            {
             float	*bufdata = (float *)cbufdata0;
1084
#pragma ivdep
1085
1086
1087
1088
1089
1090
1091
1092
1093
1094
            for (i=spoonful; i--;)
              *(bufdata++) = (float)((double)*(ptr++)-bz)/bs;
            if (bswapflag)
              swapbytes(cbufdata0, 4, spoonful);
            }
            break;

          case BP_DOUBLE:
            {
             double	*bufdata = (double *)cbufdata0;
1095
#pragma ivdep
1096
1097
1098
1099
1100
1101
1102
1103
            for (i=spoonful; i--;)
              *(bufdata++) = ((double)*(ptr++)-bz)/bs;
            if (bswapflag)
              swapbytes(cbufdata0, 8, spoonful);
            }
            break;

          default:
Emmanuel Bertin's avatar
Emmanuel Bertin committed
1104
1105
1106
1107
1108
1109
1110
1111
1112
1113
1114
1115
1116
1117
1118
1119
1120
1121
1122
1123
1124
1125
1126
1127
1128
1129
1130
1131
1132
1133
1134
1135
1136
1137
1138
1139
1140
1141
1142
1143
1144
1145
1146
1147
1148
1149
1150
1151
1152
1153
1154
1155
1156
1157
1158
1159
1160
1161
1162
1163
1164
1165
1166
1167
1168
1169
1170
1171
1172
1173
1174
1175
1176
1177
1178
1179
1180
1181
1182
1183
1184
1185
1186
1187
1188
1189
1190
1191
1192
1193
            error(EXIT_FAILURE,"*FATAL ERROR*: unknown BITPIX type in ",
                                "read_body()");
            break;
          }
        QFWRITE(cbufdata0, spoonful*tab->bytepix, cat->file, cat->filename);
        }
      break;

/*-- Compressed image */
    case COMPRESS_BASEBYTE:
      break;

    case COMPRESS_PREVPIX:
      break;

    default:
      error(EXIT_FAILURE,"*Internal Error*: unknown compression mode in ",
                                "read_body()");
    }

  return;
  }


/******* set_maxram ***********************************************************
PROTO	int set_maxram(size_t maxram)
PURPOSE	Set the maximum amount of silicon memory that can be allocated for
	storing FITS body data.
INPUT	The maximum amount of RAM (in bytes).
OUTPUT	RETURN_OK if within limits, RETURN_ERROR otherwise.
NOTES	.
AUTHOR	E. Bertin (IAP)
VERSION	19/12/99
 ***/
int set_maxram(size_t maxram)
  {

  if (maxram<1)
    return RETURN_ERROR;

  body_maxram = maxram;

  return RETURN_OK;
  }


/******* set_maxvram **********************************************************
PROTO	int set_maxvram(size_t maxram)
PURPOSE	Set the maximum amount of total virtual memory that can be used for
	storing FITS body data.
INPUT	The maximum amount of VRAM (in bytes).
OUTPUT	RETURN_OK if within limits, RETURN_ERROR otherwise.
NOTES	.
AUTHOR	E. Bertin (IAP)
VERSION	08/02/2000
 ***/
int set_maxvram(size_t maxvram)
  {

  if (maxvram<1)
    return RETURN_ERROR;

  body_maxvram = maxvram;

  return RETURN_OK;
  }


/******* set_swapdir **********************************************************
PROTO	int set_swapdir(char *dirname)
PURPOSE	Set the path name of the directory that will be used for storing
	memory swap files.
INPUT	The pointer to the path string.
OUTPUT	RETURN_OK if path appropriate, RETURN_ERROR otherwise.
NOTES	.
AUTHOR	E. Bertin (IAP)
VERSION	19/12/99
 ***/
int set_swapdir(char *dirname)
  {

  if (!dirname)
    return RETURN_ERROR;

  strcpy(body_swapdirname, dirname);

  return RETURN_OK;
  }

For faster browsing, not all history is shown. View entire blame