LCOV - code coverage report
Current view: directory - frmts/grib/degrib18/g2clib-1.0.4 - jpcunpack.c (source / functions) Found Hit Coverage
Test: gdal_filtered.info Lines: 16 0 0.0 %
Date: 2010-01-09 Functions: 1 0 0.0 %

       1                 : #include <stdio.h>
       2                 : #include <stdlib.h>
       3                 : #include "grib2.h"
       4                 : 
       5                 :    int dec_jpeg2000(char *,g2int ,g2int *);
       6                 : 
       7               0 : g2int jpcunpack(unsigned char *cpack,g2int len,g2int *idrstmpl,g2int ndpts,
       8                 :                 g2float *fld)
       9                 : //$$$  SUBPROGRAM DOCUMENTATION BLOCK
      10                 : //                .      .    .                                       .
      11                 : // SUBPROGRAM:    jpcunpack
      12                 : //   PRGMMR: Gilbert          ORG: W/NP11    DATE: 2003-08-27
      13                 : //
      14                 : // ABSTRACT: This subroutine unpacks a data field that was packed into a 
      15                 : //   JPEG2000 code stream
      16                 : //   using info from the GRIB2 Data Representation Template 5.40 or 5.40000.
      17                 : //
      18                 : // PROGRAM HISTORY LOG:
      19                 : // 2003-08-27  Gilbert
      20                 : //
      21                 : // USAGE:    jpcunpack(unsigned char *cpack,g2int len,g2int *idrstmpl,g2int ndpts,
      22                 : //                     g2float *fld)
      23                 : //   INPUT ARGUMENT LIST:
      24                 : //     cpack    - The packed data field (character*1 array)
      25                 : //     len      - length of packed field cpack().
      26                 : //     idrstmpl - Pointer to array of values for Data Representation
      27                 : //                Template 5.40 or 5.40000
      28                 : //     ndpts    - The number of data values to unpack
      29                 : //
      30                 : //   OUTPUT ARGUMENT LIST:
      31                 : //     fld[]    - Contains the unpacked data values
      32                 : //
      33                 : // REMARKS: None
      34                 : //
      35                 : // ATTRIBUTES:
      36                 : //   LANGUAGE: C
      37                 : //   MACHINE:  IBM SP
      38                 : //
      39                 : //$$$
      40                 : {
      41                 : 
      42                 :       g2int  *ifld;
      43                 :       g2int  j,nbits,iret;
      44                 :       g2float  ref,bscale,dscale;
      45                 : 
      46               0 :       rdieee(idrstmpl+0,&ref,1);
      47               0 :       bscale = int_power(2.0,idrstmpl[1]);
      48               0 :       dscale = int_power(10.0,-idrstmpl[2]);
      49               0 :       nbits = idrstmpl[3];
      50                 : //
      51                 : //  if nbits equals 0, we have a constant field where the reference value
      52                 : //  is the data value at each gridpoint
      53                 : //
      54               0 :       if (nbits != 0) {
      55                 : 
      56               0 :          ifld=(g2int *)calloc(ndpts,sizeof(g2int));
      57               0 :          if ( ifld == 0 ) {
      58               0 :             fprintf(stderr,"Could not allocate space in jpcunpack.\n  Data field NOT upacked.\n");
      59               0 :             return(1);
      60                 :          }
      61               0 :          iret=(g2int)dec_jpeg2000((char *) cpack,len,ifld);
      62               0 :          for (j=0;j<ndpts;j++) {
      63               0 :            fld[j]=(((g2float)ifld[j]*bscale)+ref)*dscale;
      64                 :          }
      65               0 :          free(ifld);
      66                 :       }
      67                 :       else {
      68               0 :          for (j=0;j<ndpts;j++) fld[j]=ref;
      69                 :       }
      70                 : 
      71               0 :       return(0);
      72                 : }

Generated by: LCOV version 1.7