Leptonica  1.82.0
Image processing and image analysis suite
jp2kheader.c File Reference
#include <string.h>
#include <math.h>
#include "allheaders.h"

Go to the source code of this file.

Macros

#define DEBUG_CODEC   0
 

Functions

l_ok readHeaderJp2k (const char *filename, l_int32 *pw, l_int32 *ph, l_int32 *pbps, l_int32 *pspp, l_int32 *pcodec)
 
l_ok freadHeaderJp2k (FILE *fp, l_int32 *pw, l_int32 *ph, l_int32 *pbps, l_int32 *pspp, l_int32 *pcodec)
 
l_ok readHeaderMemJp2k (const l_uint8 *data, size_t size, l_int32 *pw, l_int32 *ph, l_int32 *pbps, l_int32 *pspp, l_int32 *pcodec)
 
l_int32 fgetJp2kResolution (FILE *fp, l_int32 *pxres, l_int32 *pyres)
 

Variables

static const l_int32 MAX_JP2K_WIDTH = 100000
 
static const l_int32 MAX_JP2K_HEIGHT = 100000
 

Detailed Description

     Read header
         l_int32          readHeaderJp2k()
         l_int32          freadHeaderJp2k()
         l_int32          readHeaderMemJp2k()
         l_int32          fgetJp2kResolution()
 Note: these function read image metadata from a jp2k file, without
 using any jp2k libraries.
 To read and write jp2k data, using the OpenJPEG library
 (http://www.openjpeg.org), see jpegio.c.

Definition in file jp2kheader.c.

Function Documentation

◆ freadHeaderJp2k()

l_ok freadHeaderJp2k ( FILE *  fp,
l_int32 *  pw,
l_int32 *  ph,
l_int32 *  pbps,
l_int32 *  pspp,
l_int32 *  pcodec 
)

freadHeaderJp2k()

Parameters
[in]fpfile stream opened for read
[out]pw[optional]
[out]ph[optional]
[out]pbps[optional] bits/sample
[out]pspp[optional] samples/pixel
[out]pcodec[optional] L_JP2_CODEC or L_J2K_CODEC
Returns
0 if OK, 1 on error

Definition at line 115 of file jp2kheader.c.

References readHeaderMemJp2k().

Referenced by readHeaderJp2k().

◆ readHeaderJp2k()

l_ok readHeaderJp2k ( const char *  filename,
l_int32 *  pw,
l_int32 *  ph,
l_int32 *  pbps,
l_int32 *  pspp,
l_int32 *  pcodec 
)

readHeaderJp2k()

Parameters
[in]filename
[out]pw[optional]
[out]ph[optional]
[out]pbps[optional] bits/sample
[out]pspp[optional] samples/pixel
[out]pcodec[optional] L_JP2_CODEC or L_J2K_CODEC
Returns
0 if OK, 1 on error

Definition at line 80 of file jp2kheader.c.

References fopenReadStream(), and freadHeaderJp2k().

Referenced by l_generateJp2kData().

◆ readHeaderMemJp2k()

l_ok readHeaderMemJp2k ( const l_uint8 *  data,
size_t  size,
l_int32 *  pw,
l_int32 *  ph,
l_int32 *  pbps,
l_int32 *  pspp,
l_int32 *  pcodec 
)

readHeaderMemJp2k()

Parameters
[in]data
[in]sizeat least 80
[out]pw[optional]
[out]ph[optional]
[out]pbps[optional] bits/sample
[out]pspp[optional] samples/pixel
[out]pcodec[optional] L_JP2_CODEC or L_J2K_CODEC
Returns
0 if OK, 1 on error
Notes:
     (1) The ISO/IEC reference for jpeg2000 is
              http://www.jpeg.org/public/15444-1annexi.pdf
         and the file format syntax begins at page 127.
     (2) With a image file codec (L_JP2_CODEC), the Image Header Box
         begins with 'ihdr' = 0x69686472 in big-endian order.  This
         typically, but not always, starts on byte 44, with the
         big-endian data fields beginning at byte 48:
              h:    4 bytes
              w:    4 bytes
              spp:  2 bytes
              bps:  1 byte   (contains bps - 1)
     (3) With a codestream codec (L_J2K_CODEC), the first 4 bytes are
         0xff4fff51.  The fields for w and h appear to start on byte 8,
         and the fields for spp and bps appear to start on byte 40.

Definition at line 172 of file jp2kheader.c.

References findFileFormatBuffer(), JbData::h, and JbData::w.

Referenced by freadHeaderJp2k().