OpenJPEG 2.3.0

Macros | Functions
box_manager.c File Reference
`#include <stdio.h>`
`#include <string.h>`
`#include <stdlib.h>`
`#include <ctype.h>`
`#include <assert.h>`
`#include "box_manager.h"`
`#include "opj_inttypes.h"`

## Macros
#define | FCGI_stdout stdout
#define | FCGI_stderr stderr
#define | logstream stderr

## Functions
boxlist_param_t * | gene_boxlist (void)
| generate a box list More...
boxlist_param_t * | get_boxstructure (int fd, OPJ_OFF_T offset, OPJ_SIZE_T length)
| get box structure of JP2 file More...
box_param_t * | gene_boxbyOffset (int fd, OPJ_OFF_T offset)
| generate box from JP2 file at the given offset More...
box_param_t * | gene_boxbyOffinStream (Byte_t *stream, OPJ_OFF_T offset)
| generate box from code stream (JPP or JPT stream) at the given offset More...
box_param_t * | gene_boxbyType (int fd, OPJ_OFF_T offset, OPJ_SIZE_T length, const char TBox[])
| generate(search) box from JP2 file More...
box_param_t * | gene_boxbyTypeinStream (Byte_t *stream, OPJ_OFF_T offset, OPJ_SIZE_T length, const char TBox[])
| generate(search) box from code stream More...
box_param_t * | gene_childboxbyOffset (box_param_t *superbox, OPJ_OFF_T offset)
| generate child box from JP2 file at the given offset More...
box_param_t * | gene_childboxbyType (box_param_t *superbox, OPJ_OFF_T offset, const char TBox[])
| generate(search) box from JP2 file More...
OPJ_OFF_T | get_DBoxoff (box_param_t *box)
| get DBox offset More...
OPJ_SIZE_T | get_DBoxlen (box_param_t *box)
| get DBox length More...
Byte_t * | fetch_headbytes (box_param_t *box)
| fetch header bytes in file stream More...
Byte_t * | fetch_DBoxbytes (box_param_t *box, OPJ_OFF_T offset, OPJ_SIZE_T size)
| fetch DBox (Box Contents) bytes of data in file stream More...
Byte_t | fetch_DBox1byte (box_param_t *box, OPJ_OFF_T offset)
| fetch DBox (Box Contents) 1-byte Byte codes in file stream More...
Byte2_t | fetch_DBox2bytebigendian (box_param_t *box, OPJ_OFF_T offset)
| fetch DBox (Box Contents) 2-byte big endian Byte codes in file stream More...
Byte4_t | fetch_DBox4bytebigendian (box_param_t *box, OPJ_OFF_T offset)
| fetch DBox (Box Contents) 4-byte big endian Byte codes in file stream More...
Byte8_t | fetch_DBox8bytebigendian (box_param_t *box, OPJ_OFF_T offset)
| fetch DBox (Box Contents) 8-byte big endian Byte codes in file stream More...
box_param_t * | search_box (const char type[], boxlist_param_t *boxlist)
| search a box by box type More...
void | print_box (box_param_t *box)
| print box parameters More...
void | print_allbox (boxlist_param_t *boxlist)
| print all box parameters More...
void | delete_box_in_list (box_param_t **box, boxlist_param_t *boxlist)
| delete a box in list More...
void | delete_box_in_list_by_type (const char type[], boxlist_param_t *boxlist)
| delete a box in list by Type More...
void | delete_boxlist (boxlist_param_t **boxlist)
| delete box list More...
void | insert_box_into_list (box_param_t *box, boxlist_param_t *boxlist)
| insert a box into list More...

## Macro Definition Documentation

## ◆ FCGI_stderr

#define FCGI_stderr stderr

Referenced by gene_boxbyOffset(), gene_boxbyType(), gene_boxbyTypeinStream(), gene_childboxbyType(), and search_box().

## ◆ FCGI_stdout

#define FCGI_stdout stdout

## ◆ logstream

#define logstream stderr

Referenced by print_allbox(), and print_box().

## Function Documentation

## ◆ delete_box_in_list()

void delete_box_in_list | ( | box_param_t ** | box,
|  | boxlist_param_t * | boxlist
| ) |  |

delete a box in list

Parameters

  [in,out] | box | address of the deleting box pointer
  [in] | boxlist | box list pointer

References boxlist_param::first, boxlist_param::last, and box_param::next.

Referenced by const_metadatalist(), and delete_box_in_list_by_type().

## ◆ delete_box_in_list_by_type()

void delete_box_in_list_by_type | ( | const char | type[],
|  | boxlist_param_t * | boxlist
| ) |  |

delete a box in list by Type

Parameters

  [in,out] | type | box type
  [in] | boxlist | box list pointer

References delete_box_in_list(), and search_box().

## ◆ delete_boxlist()

void delete_boxlist | ( | boxlist_param_t ** | boxlist | ) |

delete box list

Parameters

  [in,out] | boxlist | address of the box list pointer

References box_param::next.

Referenced by delete_metadata(), and parse_jp2file().

## ◆ fetch_DBox1byte()

Byte_t fetch_DBox1byte | ( | box_param_t * | box,
|  | OPJ_OFF_T | offset
| ) |  |

fetch DBox (Box Contents) 1-byte Byte codes in file stream

Parameters

  [in] | box | box pointer
  [in] | offset | start Byte position in DBox

Returns
  fetched code

References box_param::fd, fetch_1byte(), and get_DBoxoff().

Referenced by check_JP2boxidx(), and gene_faixbox().

## ◆ fetch_DBox2bytebigendian()

Byte2_t fetch_DBox2bytebigendian | ( | box_param_t * | box,
|  | OPJ_OFF_T | offset
| ) |  |

fetch DBox (Box Contents) 2-byte big endian Byte codes in file stream

Parameters

  [in] | box | box pointer
  [in] | offset | start Byte position in DBox

Returns
  fetched code

References box_param::fd, fetch_2bytebigendian(), and get_DBoxoff().

Referenced by gene_mhixbox(), and set_cptrdata().

## ◆ fetch_DBox4bytebigendian()

Byte4_t fetch_DBox4bytebigendian | ( | box_param_t * | box,
|  | OPJ_OFF_T | offset
| ) |  |

fetch DBox (Box Contents) 4-byte big endian Byte codes in file stream

Parameters

  [in] | box | box pointer
  [in] | offset | start Byte position in DBox

Returns
  fetched code

References box_param::fd, fetch_4bytebigendian(), and get_DBoxoff().

Referenced by gene_faixbox().

## ◆ fetch_DBox8bytebigendian()

Byte8_t fetch_DBox8bytebigendian | ( | box_param_t * | box,
|  | OPJ_OFF_T | offset
| ) |  |

fetch DBox (Box Contents) 8-byte big endian Byte codes in file stream

Parameters

  [in] | box | box pointer
  [in] | offset | start Byte position in DBox

Returns
  fetched code

References box_param::fd, fetch_8bytebigendian(), and get_DBoxoff().

Referenced by check_JP2boxidx(), gene_faixbox(), gene_mhixbox(), set_cptrdata(), and set_mainmhixdata().

## ◆ fetch_DBoxbytes()

Byte_t* fetch_DBoxbytes | ( | box_param_t * | box,
|  | OPJ_OFF_T | offset,
|  | OPJ_SIZE_T | size
| ) |  |

fetch DBox (Box Contents) bytes of data in file stream

Parameters

  [in] | box | box pointer
  [in] | offset | start Byte position in DBox
  [in] | size | Byte length

Returns
  pointer to the fetched data

References box_param::fd, fetch_bytes(), and get_DBoxoff().

## ◆ fetch_headbytes()

Byte_t* fetch_headbytes | ( | box_param_t * | box | ) |

fetch header bytes in file stream

Parameters

  [in] | box | box pointer

Returns
  pointer to the fetched bytes

References box_param::fd, fetch_bytes(), box_param::headlen, and box_param::offset.

Referenced by gene_placeholder().

## ◆ gene_boxbyOffinStream()

box_param_t* gene_boxbyOffinStream | ( | Byte_t * | stream,
|  | OPJ_OFF_T | offset
| ) |  |

generate box from code stream (JPP or JPT stream) at the given offset

Parameters

  [in] | stream | code stream of a box
  [in] | offset | Box offset of the whole stream

Returns
  pointer to the structure of generate box parameters

References big4(), big8(), box_param::fd, box_param::headlen, box_param::length, box_param::next, box_param::offset, and box_param::type.

Referenced by parse_metadata().

## ◆ gene_boxbyOffset()

box_param_t* gene_boxbyOffset | ( | int | fd,
|  | OPJ_OFF_T | offset
| ) |  |

generate box from JP2 file at the given offset

Parameters

  [in] | fd | file discriptor of the JP2 file
  [in] | offset | Box offset

Returns
  pointer to the structure of generate box parameters

References big4(), big8(), FCGI_stderr, box_param::fd, fetch_bytes(), box_param::headlen, box_param::length, box_param::next, box_param::offset, and box_param::type.

Referenced by gene_childboxbyOffset(), get_boxstructure(), and set_ppixdata().

## ◆ gene_boxbyType()

box_param_t* gene_boxbyType | ( | int | fd,
|  | OPJ_OFF_T | offset,
|  | OPJ_SIZE_T | length,
|  | const char | TBox[]
| ) |  |

generate(search) box from JP2 file

Parameters

  [in] | fd | file discriptor of the JP2 file
  [in] | offset | start Byte position of the search
  [in] | length | Byte length of the search, if 0, size to the end of file
  [in] | TBox | Box Type

Returns
  pointer to the structure of generate/found box parameters

References big4(), big8(), FCGI_stderr, box_param::fd, fetch_bytes(), get_filesize(), box_param::headlen, box_param::length, box_param::next, box_param::offset, and box_param::type.

Referenced by gene_childboxbyType(), set_cidxdata(), set_cptrdata(), set_mainmhixdata(), set_ppixdata(), set_thixdata(), and set_tpixdata().

## ◆ gene_boxbyTypeinStream()

box_param_t* gene_boxbyTypeinStream | ( | Byte_t * | stream,
|  | OPJ_OFF_T | offset,
|  | OPJ_SIZE_T | length,
|  | const char | TBox[]
| ) |  |

generate(search) box from code stream

Parameters

  [in] | stream | code stream ( from the first byte)
  [in] | offset | start Byte position of the search
  [in] | length | Byte length of the search, if 0, size to the end of file
  [in] | TBox | Box Type

Returns
  pointer to the structure of generate/found box parameters

References big4(), big8(), FCGI_stderr, box_param::fd, box_param::headlen, box_param::length, box_param::next, box_param::offset, and box_param::type.

Referenced by gene_ihdrbox().

## ◆ gene_boxlist()

boxlist_param_t* gene_boxlist | ( | void |  | ) |

generate a box list

Returns
  pointer to the generated box list

References boxlist_param::first, and boxlist_param::last.

Referenced by get_boxstructure(), and parse_metadata().

## ◆ gene_childboxbyOffset()

box_param_t* gene_childboxbyOffset | ( | box_param_t * | superbox,
|  | OPJ_OFF_T | offset
| ) |  |

generate child box from JP2 file at the given offset

Parameters

  [in] | superbox | super box pointer
  [in] | offset | offset from DBox first byte of superbox

Returns
  pointer to the structure of generate box parameters

References box_param::fd, gene_boxbyOffset(), and get_DBoxoff().

## ◆ gene_childboxbyType()

box_param_t* gene_childboxbyType | ( | box_param_t * | superbox,
|  | OPJ_OFF_T | offset,
|  | const char | TBox[]
| ) |  |

generate(search) box from JP2 file

Parameters

  [in] | superbox | super box pointer
  [in] | offset | offset from DBox first byte of superbox
  [in] | TBox | Box Type

Returns
  pointer to the structure of generate/found box parameters

References FCGI_stderr, box_param::fd, gene_boxbyType(), get_DBoxlen(), and get_DBoxoff().

Referenced by check_JP2boxidx().

## ◆ get_boxstructure()

boxlist_param_t* get_boxstructure | ( | int | fd,
|  | OPJ_OFF_T | offset,
|  | OPJ_SIZE_T | length
| ) |  |

get box structure of JP2 file

Parameters

  [in] | fd | file descriptor
  [in] | offset | offset of the decomposing region
  [in] | length | length of the decomposing region

Returns
  pointer to the generated boxlist

References gene_boxbyOffset(), gene_boxlist(), insert_box_into_list(), and box_param::length.

Referenced by const_metadatalist(), and parse_jp2file().

## ◆ get_DBoxlen()

OPJ_SIZE_T get_DBoxlen | ( | box_param_t * | box | ) |

get DBox length

Parameters

  [in] | box | box pointer

Returns
  DBox length ( content length)

References box_param::headlen, and box_param::length.

Referenced by const_metadatalist(), gene_childboxbyType(), gene_ihdrbox(), gene_manfbox(), gene_mhixbox(), set_cidxdata(), set_cptrdata(), set_mainmhixdata(), set_ppixdata(), set_thixdata(), and set_tpixdata().

## ◆ get_DBoxoff()

OPJ_OFF_T get_DBoxoff | ( | box_param_t * | box | ) |

get DBox offset

Parameters

  [in] | box | box pointer

Returns
  DBox offset (byte position) in the file

References box_param::headlen, and box_param::offset.

Referenced by const_metadatalist(), fetch_DBox1byte(), fetch_DBox2bytebigendian(), fetch_DBox4bytebigendian(), fetch_DBox8bytebigendian(), fetch_DBoxbytes(), gene_childboxbyOffset(), gene_childboxbyType(), gene_childboxheader(), gene_ihdrbox(), set_cidxdata(), set_cptrdata(), set_mainmhixdata(), set_ppixdata(), set_thixdata(), and set_tpixdata().

## ◆ insert_box_into_list()

void insert_box_into_list | ( | box_param_t * | box,
|  | boxlist_param_t * | boxlist
| ) |  |

insert a box into list

Parameters

  [in] | box | box pointer
  [in] | boxlist | box list pointer

References boxlist_param::first, boxlist_param::last, and box_param::next.

Referenced by get_boxstructure(), and parse_metadata().

## ◆ print_allbox()

void print_allbox | ( | boxlist_param_t * | boxlist | ) |

print all box parameters

Parameters

  [in] | boxlist | box list pointer

References boxlist_param::first, logstream, box_param::next, and print_box().

Referenced by print_metadata().

## ◆ print_box()

void print_box | ( | box_param_t * | box | ) |

print box parameters

Parameters

  [in] | box | box pointer

References box_param::headlen, box_param::length, logstream, box_param::offset, and box_param::type.

Referenced by print_allbox().

## ◆ search_box()

box_param_t* search_box | ( | const char | type[],
|  | boxlist_param_t * | boxlist
| ) |  |

search a box by box type

Parameters

  [in] | type | box type
  [in] | boxlist | box list pointer

Returns
  found box pointer

References FCGI_stderr, boxlist_param::first, box_param::next, and box_param::type.

Referenced by check_JP2boxidx(), delete_box_in_list_by_type(), gene_ihdrbox(), and parse_jp2file().