aboutsummaryrefslogtreecommitdiff
path: root/sys/imio/iki/fxf/fxfpak.x
blob: 01db148df1d0600054a5cf24279bbe1397b25827 (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
# Copyright(c) 1986 Association of Universities for Research in Astronomy Inc.
 
include	<syserr.h>
include <mach.h>
include "fxf.h"


# FXF_PAK_DATA -- Convert npix elements of type pixtype as needed for storage
# in a FITS file.  All floating point data will be converted to IEEE format.
# The input and output buffers may be the same if desired.

procedure fxf_pak_data (ibuf, obuf, npix, pixtype)

char    ibuf[ARB]		#I input data buffer
char    obuf[ARB]		#I output data buffer
int	npix			#I number of pixels in buffer
int	pixtype			#I input pixel datatype

int	nbytes, nchars
errchk	syserr

include <szpixtype.inc>

begin
	### Possibly the MII conversion routines should be used here as
	### they handle all these datatypes (except maybe ushort).

	nchars = npix * pix_size[pixtype]
	nbytes = nchars * SZB_CHAR

	switch (pixtype) {
	case TY_USHORT:
	    call fxf_altmu (ibuf, obuf, npix)
	    if (BYTE_SWAP2 == YES)
		call bswap2 (obuf, 1, obuf, 1, nbytes)

	case TY_SHORT:
	    if (BYTE_SWAP2 == YES)
		call bswap2 (ibuf, 1, obuf, 1, nbytes)
	    else
		call amovc (ibuf, obuf, nchars)

	case TY_INT, TY_LONG:
	    if (BYTE_SWAP4 == YES)
		call bswap4 (ibuf, 1, obuf, 1, nbytes)
	    else
		call amovc (ibuf, obuf, nchars)

	case TY_REAL:
	    call ieevpakr (ibuf, obuf, npix)

	case TY_DOUBLE:
	    call ieevpakd (ibuf, obuf, npix)

	default:
	   call syserr (SYS_FXFPKDTYP)
	}
end