Leptonica 1.85.0
Image processing and image analysis suite
Loading...
Searching...
No Matches
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)
 
l_ok readResolutionMemJp2k (const l_uint8 *data, size_t nbytes, 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()
         l_int32          readResolutionMemJp2k()

 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.

Macro Definition Documentation

◆ DEBUG_CODEC

#define DEBUG_CODEC   0

Definition at line 55 of file jp2kheader.c.

Function Documentation

◆ fgetJp2kResolution()

l_int32 fgetJp2kResolution ( FILE * fp,
l_int32 * pxres,
l_int32 * pyres )

Definition at line 277 of file jp2kheader.c.

◆ 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 114 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 81 of file jp2kheader.c.

References freadHeaderJp2k().

◆ 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 169 of file jp2kheader.c.

References L_J2K_CODEC, and L_JP2_CODEC.

Referenced by freadHeaderJp2k().

◆ readResolutionMemJp2k()

l_ok readResolutionMemJp2k ( const l_uint8 * data,
size_t nbytes,
l_int32 * pxres,
l_int32 * pyres )

readResolutionMemJp2k()

Parameters
[in]dataconst; jp2k-encoded
[in]nbytesof data
[out]pxres[optional]
[out]pyres[optional]
Returns
0 if OK, 1 on error

Definition at line 309 of file jp2kheader.c.

Variable Documentation

◆ MAX_JP2K_HEIGHT

const l_int32 MAX_JP2K_HEIGHT = 100000
static

Definition at line 64 of file jp2kheader.c.

◆ MAX_JP2K_WIDTH

const l_int32 MAX_JP2K_WIDTH = 100000
static

Definition at line 63 of file jp2kheader.c.