parent
9c1cfb034a
commit
d028260053
|
@ -42,7 +42,7 @@ if(WIN32)
|
|||
endif()
|
||||
|
||||
# Loop over all executables:
|
||||
foreach(exe opj_decompress opj_compress opj_dump)
|
||||
foreach(exe opj_decompress opj_decompress_c_vector opj_compress opj_dump)
|
||||
add_executable(${exe} ${exe}.c ${common_SRCS})
|
||||
if(NOT ${CMAKE_VERSION} VERSION_LESS "2.8.12")
|
||||
target_compile_options(${exe} PRIVATE ${OPENJP2_COMPILE_OPTIONS})
|
||||
|
|
File diff suppressed because it is too large
Load Diff
|
@ -93,6 +93,7 @@ int imagetotga(opj_image_t * image, const char *outfile);
|
|||
/* BMP conversion */
|
||||
opj_image_t* bmptoimage(const char *filename, opj_cparameters_t *parameters);
|
||||
int imagetobmp(opj_image_t *image, const char *outfile);
|
||||
int imagetobmp_c_vector(opj_image_t *image, c_vector *outfile);
|
||||
|
||||
/* TIFF conversion*/
|
||||
opj_image_t* tiftoimage(const char *filename, opj_cparameters_t *parameters);
|
||||
|
@ -117,6 +118,8 @@ opj_image_t* rawtoimage(const char *filename, opj_cparameters_t *parameters,
|
|||
opj_image_t* rawltoimage(const char *filename, opj_cparameters_t *parameters,
|
||||
raw_cparameters_t *raw_cp);
|
||||
|
||||
extern int imagetoraw_c_vector(opj_image_t * image, c_vector *outfile,
|
||||
OPJ_BOOL big_endian);
|
||||
/* PNG conversion*/
|
||||
extern int imagetopng(opj_image_t *image, const char *write_idf);
|
||||
extern opj_image_t* pngtoimage(const char *filename,
|
||||
|
|
File diff suppressed because it is too large
Load Diff
File diff suppressed because it is too large
Load Diff
|
@ -32,6 +32,8 @@ set(OPENJPEG_SRCS
|
|||
${CMAKE_CURRENT_SOURCE_DIR}/mqc.c
|
||||
${CMAKE_CURRENT_SOURCE_DIR}/mqc.h
|
||||
${CMAKE_CURRENT_SOURCE_DIR}/mqc_inl.h
|
||||
${CMAKE_CURRENT_SOURCE_DIR}/c_vector.h
|
||||
${CMAKE_CURRENT_SOURCE_DIR}/c_vector.c
|
||||
${CMAKE_CURRENT_SOURCE_DIR}/openjpeg.c
|
||||
${CMAKE_CURRENT_SOURCE_DIR}/openjpeg.h
|
||||
${CMAKE_CURRENT_SOURCE_DIR}/opj_clock.c
|
||||
|
|
|
@ -0,0 +1,228 @@
|
|||
//
|
||||
// Created by caesar kekxv on 2020/4/17.
|
||||
//
|
||||
|
||||
#include "c_vector.h"
|
||||
|
||||
typedef struct c_vector {
|
||||
void *items;
|
||||
size_t total;
|
||||
size_t index;
|
||||
} c_vector;
|
||||
|
||||
|
||||
/**
|
||||
* init
|
||||
* @param cVector
|
||||
*/
|
||||
int c_vector_init(c_vector **cVector) {
|
||||
if (!cVector)return -1;
|
||||
if (NULL != (*cVector))return -2;
|
||||
*cVector = (c_vector *) malloc(sizeof(c_vector));
|
||||
(*cVector)->index = 0;
|
||||
(*cVector)->total = 0;
|
||||
(*cVector)->items = NULL;
|
||||
return 0;
|
||||
}
|
||||
|
||||
/**
|
||||
* get c_vector size
|
||||
* @param cVector
|
||||
* @return
|
||||
*/
|
||||
size_t c_vector_size(c_vector *cVector) {
|
||||
if (!cVector)return -1;
|
||||
return cVector->total;
|
||||
}
|
||||
|
||||
/**
|
||||
* resize c_vector
|
||||
* @param cVector
|
||||
*/
|
||||
static int c_vector_resize(c_vector *cVector, size_t count) {
|
||||
if (!cVector)return -1;
|
||||
if (cVector->items) {
|
||||
void *items = (void *) realloc(cVector->items, sizeof(void) * count);
|
||||
if (items) {
|
||||
cVector->items = items;
|
||||
cVector->total = count;
|
||||
return 0;
|
||||
}
|
||||
return -1;
|
||||
} else {
|
||||
cVector->items = (void *) malloc(sizeof(void) * count);
|
||||
if (cVector->items == NULL) {
|
||||
return -1;
|
||||
} else {
|
||||
cVector->total = count;
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* push back c_vector
|
||||
* @param cVector
|
||||
* @param data
|
||||
* @param offset
|
||||
* @param count
|
||||
*/
|
||||
int c_vector_push_back(c_vector *cVector, void *data, size_t offset, size_t count) {
|
||||
size_t index = cVector->total;
|
||||
size_t new_size = count + cVector->total;
|
||||
if (c_vector_resize(cVector, new_size) < 0) {
|
||||
// error realloc
|
||||
return -1;
|
||||
}
|
||||
memcpy(&(cVector->items[index]), &data[offset], count);
|
||||
return 0;
|
||||
}
|
||||
|
||||
/**
|
||||
* push zero to c_vector
|
||||
* @param cVector
|
||||
* @return
|
||||
*/
|
||||
int c_vector_push_back_zero(c_vector *cVector) {
|
||||
unsigned char data[1] = {0};
|
||||
return c_vector_push_back(cVector, data, 0, 1);
|
||||
}
|
||||
|
||||
/**
|
||||
* set c_vector data
|
||||
* @param cVector
|
||||
* @param offset
|
||||
* @param data
|
||||
* @param count
|
||||
* @return
|
||||
*/
|
||||
size_t c_vector_set(c_vector *cVector, size_t index, void *data, size_t offset, size_t count) {
|
||||
if (cVector->total <= index || index + count >= cVector->total) {
|
||||
return -1;
|
||||
}
|
||||
memcpy(&(cVector->items[index]), &data[offset], count);
|
||||
return 0;
|
||||
}
|
||||
|
||||
/**
|
||||
* insert data
|
||||
* @param cVector
|
||||
* @param index
|
||||
* @param data
|
||||
* @param offset
|
||||
* @param count
|
||||
* @return
|
||||
*/
|
||||
size_t c_vector_insert(c_vector *cVector, size_t index, void *data, size_t offset, size_t count) {
|
||||
if (cVector->total <= index) {
|
||||
return -1;
|
||||
}
|
||||
size_t last_total = cVector->total;
|
||||
size_t new_size = count + cVector->total;
|
||||
if (c_vector_resize(cVector, new_size) < 0) {
|
||||
// error realloc
|
||||
return -1;
|
||||
}
|
||||
size_t len = last_total - index;
|
||||
for (size_t i = 1; i <= len; i++) {
|
||||
memcpy(&cVector->items[new_size - i], &cVector->items[last_total - i], 1);
|
||||
}
|
||||
memcpy(&(cVector->items[index]), &data[offset], count);
|
||||
return 0;
|
||||
}
|
||||
|
||||
/**
|
||||
* get c_vector data
|
||||
* @param cVector
|
||||
* @param offset
|
||||
* @return
|
||||
*/
|
||||
void *c_vector_get(c_vector *cVector, size_t offset) {
|
||||
if (cVector->total <= offset) {
|
||||
return NULL;
|
||||
}
|
||||
return &cVector->items[offset];
|
||||
}
|
||||
|
||||
/**
|
||||
* get c_vector data
|
||||
* @param cVector
|
||||
* @return
|
||||
*/
|
||||
void *c_vector_data(c_vector *cVector) {
|
||||
return c_vector_get(cVector, 0);
|
||||
}
|
||||
|
||||
/**
|
||||
* c_vector delete
|
||||
* @param cVector
|
||||
* @param offset
|
||||
* @param count
|
||||
*/
|
||||
size_t c_vector_delete(c_vector *cVector, size_t offset, size_t count) {
|
||||
if (cVector->total <= offset) {
|
||||
return -1;
|
||||
}
|
||||
if (count + offset >= cVector->total) {
|
||||
cVector->total = cVector->total - offset;
|
||||
return 0;
|
||||
}
|
||||
memcpy(&(cVector->items[offset]), &(cVector->items[offset + count]), cVector->total - count - offset);
|
||||
cVector->total = cVector->total - count;
|
||||
return 0;
|
||||
}
|
||||
|
||||
/**
|
||||
* free c_vector
|
||||
* @param cVector
|
||||
*/
|
||||
void c_vector_free(c_vector **cVector) {
|
||||
if (!cVector)return;
|
||||
if (!*cVector)return;
|
||||
if ((*cVector)->items)free((*cVector)->items);
|
||||
(*cVector)->items = NULL;
|
||||
free(*cVector);
|
||||
*cVector = NULL;
|
||||
}
|
||||
|
||||
int c_vector_seekg(size_t offset, c_vector *cVector) {
|
||||
return c_vector_seek(cVector, offset, SEEK_SET);
|
||||
}
|
||||
|
||||
int c_vector_skip(size_t offset, c_vector *cVector) {
|
||||
return c_vector_seek(cVector, offset, SEEK_CUR);
|
||||
}
|
||||
|
||||
int c_vector_seek(c_vector *cVector, size_t offset, int whence) {
|
||||
if (whence != SEEK_SET && whence != SEEK_CUR && whence != SEEK_END) {
|
||||
return -1;
|
||||
}
|
||||
if (SEEK_SET == whence) {
|
||||
cVector->index = offset;
|
||||
} else if (SEEK_END == whence) {
|
||||
cVector->index = cVector->total - 1 - offset;
|
||||
} else if (SEEK_CUR == whence) {
|
||||
cVector->index = cVector->total + offset;
|
||||
}
|
||||
return -1;
|
||||
}
|
||||
|
||||
size_t c_vector_read(void *p_buffer, size_t p_nb_bytes, c_vector *v) {
|
||||
if (v->total - v->index < p_nb_bytes) {
|
||||
p_nb_bytes = v->total - v->index;
|
||||
}
|
||||
memcpy(p_buffer, &(v->items[v->index]), p_nb_bytes);
|
||||
v->index += p_nb_bytes;
|
||||
return p_nb_bytes;
|
||||
}
|
||||
|
||||
size_t c_vector_write(void *p_buffer, size_t p_nb_bytes,
|
||||
c_vector *v) {
|
||||
if (v->index + p_nb_bytes > v->total) {
|
||||
c_vector_resize(v, v->index + p_nb_bytes);
|
||||
}
|
||||
c_vector_set(v, v->index, p_buffer, 0, p_nb_bytes);
|
||||
v->index += p_nb_bytes;
|
||||
return p_nb_bytes;
|
||||
}
|
||||
|
|
@ -0,0 +1,110 @@
|
|||
//
|
||||
// Created by caesar kekxv on 2020/4/17.
|
||||
//
|
||||
|
||||
#ifndef CLANGTOOLS_VECTOR_H
|
||||
#define CLANGTOOLS_VECTOR_H
|
||||
|
||||
#include <stdio.h>
|
||||
#include <string.h>
|
||||
#include <stdlib.h>
|
||||
|
||||
struct c_vector;
|
||||
typedef struct c_vector c_vector;
|
||||
|
||||
/**
|
||||
* init
|
||||
* @param cVector
|
||||
*/
|
||||
int c_vector_init(c_vector **cVector);
|
||||
|
||||
/**
|
||||
* get c_vector size
|
||||
* @param cVector
|
||||
* @return
|
||||
*/
|
||||
size_t c_vector_size(c_vector *cVector);
|
||||
|
||||
/**
|
||||
* resize c_vector
|
||||
* @param cVector
|
||||
*/
|
||||
static int c_vector_resize(c_vector *cVector, size_t count);
|
||||
|
||||
/**
|
||||
* push back c_vector
|
||||
* @param cVector
|
||||
* @param data
|
||||
* @param offset
|
||||
* @param count
|
||||
*/
|
||||
int c_vector_push_back(c_vector *cVector, void *data, size_t offset, size_t count);
|
||||
|
||||
/**
|
||||
* push zero to c_vector
|
||||
* @param cVector
|
||||
* @return
|
||||
*/
|
||||
int c_vector_push_back_zero(c_vector *cVector);
|
||||
|
||||
/**
|
||||
* set data
|
||||
* @param cVector
|
||||
* @param index
|
||||
* @param data
|
||||
* @param offset
|
||||
* @param count
|
||||
* @return
|
||||
*/
|
||||
size_t c_vector_set(c_vector *cVector, size_t index, void *data, size_t offset, size_t count);
|
||||
|
||||
/**
|
||||
* insert data
|
||||
* @param cVector
|
||||
* @param index
|
||||
* @param data
|
||||
* @param offset
|
||||
* @param count
|
||||
* @return
|
||||
*/
|
||||
size_t c_vector_insert(c_vector *cVector, size_t index, void *data, size_t offset, size_t count);
|
||||
|
||||
/**
|
||||
* get c_vector data
|
||||
* @param cVector
|
||||
* @param offset
|
||||
* @return
|
||||
*/
|
||||
void *c_vector_get(c_vector *cVector, size_t offset);
|
||||
|
||||
/**
|
||||
* get c_vector data
|
||||
* @param cVector
|
||||
* @return
|
||||
*/
|
||||
void *c_vector_data(c_vector *cVector);
|
||||
|
||||
/**
|
||||
* c_vector delete
|
||||
* @param cVector
|
||||
* @param offset
|
||||
* @param count
|
||||
*/
|
||||
size_t c_vector_delete(c_vector *cVector, size_t offset, size_t count);
|
||||
|
||||
/**
|
||||
* free c_vector
|
||||
* @param cVector
|
||||
*/
|
||||
void c_vector_free(c_vector **cVector);
|
||||
|
||||
int c_vector_seek(c_vector *cVector, size_t offset, int whence);
|
||||
int c_vector_seekg(size_t offset,c_vector *cVector);
|
||||
int c_vector_skip(size_t offset,c_vector *cVector);
|
||||
|
||||
size_t c_vector_read(void *p_buffer, size_t p_nb_bytes, c_vector *v);
|
||||
|
||||
size_t c_vector_write(void *p_buffer, size_t p_nb_bytes, c_vector *v);
|
||||
|
||||
|
||||
#endif //CLANGTOOLS_VECTOR_H
|
|
@ -41,12 +41,11 @@
|
|||
/* ---------------------------------------------------------------------- */
|
||||
/* Functions to set the message handlers */
|
||||
|
||||
OPJ_BOOL OPJ_CALLCONV opj_set_info_handler(opj_codec_t * p_codec,
|
||||
OPJ_BOOL OPJ_CALLCONV opj_set_info_handler(opj_codec_t *p_codec,
|
||||
opj_msg_callback p_callback,
|
||||
void * p_user_data)
|
||||
{
|
||||
opj_codec_private_t * l_codec = (opj_codec_private_t *) p_codec;
|
||||
if (! l_codec) {
|
||||
void *p_user_data) {
|
||||
opj_codec_private_t *l_codec = (opj_codec_private_t *) p_codec;
|
||||
if (!l_codec) {
|
||||
return OPJ_FALSE;
|
||||
}
|
||||
|
||||
|
@ -56,12 +55,11 @@ OPJ_BOOL OPJ_CALLCONV opj_set_info_handler(opj_codec_t * p_codec,
|
|||
return OPJ_TRUE;
|
||||
}
|
||||
|
||||
OPJ_BOOL OPJ_CALLCONV opj_set_warning_handler(opj_codec_t * p_codec,
|
||||
OPJ_BOOL OPJ_CALLCONV opj_set_warning_handler(opj_codec_t *p_codec,
|
||||
opj_msg_callback p_callback,
|
||||
void * p_user_data)
|
||||
{
|
||||
opj_codec_private_t * l_codec = (opj_codec_private_t *) p_codec;
|
||||
if (! l_codec) {
|
||||
void *p_user_data) {
|
||||
opj_codec_private_t *l_codec = (opj_codec_private_t *) p_codec;
|
||||
if (!l_codec) {
|
||||
return OPJ_FALSE;
|
||||
}
|
||||
|
||||
|
@ -71,12 +69,11 @@ OPJ_BOOL OPJ_CALLCONV opj_set_warning_handler(opj_codec_t * p_codec,
|
|||
return OPJ_TRUE;
|
||||
}
|
||||
|
||||
OPJ_BOOL OPJ_CALLCONV opj_set_error_handler(opj_codec_t * p_codec,
|
||||
OPJ_BOOL OPJ_CALLCONV opj_set_error_handler(opj_codec_t *p_codec,
|
||||
opj_msg_callback p_callback,
|
||||
void * p_user_data)
|
||||
{
|
||||
opj_codec_private_t * l_codec = (opj_codec_private_t *) p_codec;
|
||||
if (! l_codec) {
|
||||
void *p_user_data) {
|
||||
opj_codec_private_t *l_codec = (opj_codec_private_t *) p_codec;
|
||||
if (!l_codec) {
|
||||
return OPJ_FALSE;
|
||||
}
|
||||
|
||||
|
@ -88,32 +85,28 @@ OPJ_BOOL OPJ_CALLCONV opj_set_error_handler(opj_codec_t * p_codec,
|
|||
|
||||
/* ---------------------------------------------------------------------- */
|
||||
|
||||
static OPJ_SIZE_T opj_read_from_file(void * p_buffer, OPJ_SIZE_T p_nb_bytes,
|
||||
FILE * p_file)
|
||||
{
|
||||
static OPJ_SIZE_T opj_read_from_file(void *p_buffer, OPJ_SIZE_T p_nb_bytes,
|
||||
FILE *p_file) {
|
||||
OPJ_SIZE_T l_nb_read = fread(p_buffer, 1, p_nb_bytes, p_file);
|
||||
return l_nb_read ? l_nb_read : (OPJ_SIZE_T) - 1;
|
||||
return l_nb_read ? l_nb_read : (OPJ_SIZE_T) -1;
|
||||
}
|
||||
|
||||
static OPJ_UINT64 opj_get_data_length_from_file(FILE * p_file)
|
||||
{
|
||||
static OPJ_UINT64 opj_get_data_length_from_file(FILE *p_file) {
|
||||
OPJ_OFF_T file_length = 0;
|
||||
|
||||
OPJ_FSEEK(p_file, 0, SEEK_END);
|
||||
file_length = (OPJ_OFF_T)OPJ_FTELL(p_file);
|
||||
file_length = (OPJ_OFF_T) OPJ_FTELL(p_file);
|
||||
OPJ_FSEEK(p_file, 0, SEEK_SET);
|
||||
|
||||
return (OPJ_UINT64)file_length;
|
||||
return (OPJ_UINT64) file_length;
|
||||
}
|
||||
|
||||
static OPJ_SIZE_T opj_write_from_file(void * p_buffer, OPJ_SIZE_T p_nb_bytes,
|
||||
FILE * p_file)
|
||||
{
|
||||
static OPJ_SIZE_T opj_write_from_file(void *p_buffer, OPJ_SIZE_T p_nb_bytes,
|
||||
FILE *p_file) {
|
||||
return fwrite(p_buffer, 1, p_nb_bytes, p_file);
|
||||
}
|
||||
|
||||
static OPJ_OFF_T opj_skip_from_file(OPJ_OFF_T p_nb_bytes, FILE * p_user_data)
|
||||
{
|
||||
static OPJ_OFF_T opj_skip_from_file(OPJ_OFF_T p_nb_bytes, FILE *p_user_data) {
|
||||
if (OPJ_FSEEK(p_user_data, p_nb_bytes, SEEK_CUR)) {
|
||||
return -1;
|
||||
}
|
||||
|
@ -121,8 +114,7 @@ static OPJ_OFF_T opj_skip_from_file(OPJ_OFF_T p_nb_bytes, FILE * p_user_data)
|
|||
return p_nb_bytes;
|
||||
}
|
||||
|
||||
static OPJ_BOOL opj_seek_from_file(OPJ_OFF_T p_nb_bytes, FILE * p_user_data)
|
||||
{
|
||||
static OPJ_BOOL opj_seek_from_file(OPJ_OFF_T p_nb_bytes, FILE *p_user_data) {
|
||||
if (OPJ_FSEEK(p_user_data, p_nb_bytes, SEEK_SET)) {
|
||||
return OPJ_FALSE;
|
||||
}
|
||||
|
@ -157,19 +149,17 @@ DllMain(HINSTANCE hModule, DWORD ul_reason_for_call, LPVOID lpReserved)
|
|||
|
||||
/* ---------------------------------------------------------------------- */
|
||||
|
||||
const char* OPJ_CALLCONV opj_version(void)
|
||||
{
|
||||
const char *OPJ_CALLCONV opj_version(void) {
|
||||
return OPJ_PACKAGE_VERSION;
|
||||
}
|
||||
|
||||
/* ---------------------------------------------------------------------- */
|
||||
/* DECOMPRESSION FUNCTIONS*/
|
||||
|
||||
opj_codec_t* OPJ_CALLCONV opj_create_decompress(OPJ_CODEC_FORMAT p_format)
|
||||
{
|
||||
opj_codec_t *OPJ_CALLCONV opj_create_decompress(OPJ_CODEC_FORMAT p_format) {
|
||||
opj_codec_private_t *l_codec = 00;
|
||||
|
||||
l_codec = (opj_codec_private_t*) opj_calloc(1, sizeof(opj_codec_private_t));
|
||||
l_codec = (opj_codec_private_t *) opj_calloc(1, sizeof(opj_codec_private_t));
|
||||
if (!l_codec) {
|
||||
return 00;
|
||||
}
|
||||
|
@ -178,18 +168,18 @@ opj_codec_t* OPJ_CALLCONV opj_create_decompress(OPJ_CODEC_FORMAT p_format)
|
|||
|
||||
switch (p_format) {
|
||||
case OPJ_CODEC_J2K:
|
||||
l_codec->opj_dump_codec = (void (*)(void*, OPJ_INT32, FILE*)) j2k_dump;
|
||||
l_codec->opj_dump_codec = (void (*)(void *, OPJ_INT32, FILE *)) j2k_dump;
|
||||
|
||||
l_codec->opj_get_codec_info = (opj_codestream_info_v2_t* (*)(
|
||||
void*)) j2k_get_cstr_info;
|
||||
l_codec->opj_get_codec_info = (opj_codestream_info_v2_t *(*)(
|
||||
void *)) j2k_get_cstr_info;
|
||||
|
||||
l_codec->opj_get_codec_index = (opj_codestream_index_t* (*)(
|
||||
void*)) j2k_get_cstr_index;
|
||||
l_codec->opj_get_codec_index = (opj_codestream_index_t *(*)(
|
||||
void *)) j2k_get_cstr_index;
|
||||
|
||||
l_codec->m_codec_data.m_decompression.opj_decode =
|
||||
(OPJ_BOOL(*)(void *,
|
||||
struct opj_stream_private *,
|
||||
opj_image_t*, struct opj_event_mgr *)) opj_j2k_decode;
|
||||
opj_image_t *, struct opj_event_mgr *)) opj_j2k_decode;
|
||||
|
||||
l_codec->m_codec_data.m_decompression.opj_end_decompress =
|
||||
(OPJ_BOOL(*)(void *,
|
||||
|
@ -203,33 +193,33 @@ opj_codec_t* OPJ_CALLCONV opj_create_decompress(OPJ_CODEC_FORMAT p_format)
|
|||
struct opj_event_mgr *)) opj_j2k_read_header;
|
||||
|
||||
l_codec->m_codec_data.m_decompression.opj_destroy =
|
||||
(void (*)(void *))opj_j2k_destroy;
|
||||
(void (*)(void *)) opj_j2k_destroy;
|
||||
|
||||
l_codec->m_codec_data.m_decompression.opj_setup_decoder =
|
||||
(void (*)(void *, opj_dparameters_t *)) opj_j2k_setup_decoder;
|
||||
|
||||
l_codec->m_codec_data.m_decompression.opj_read_tile_header =
|
||||
(OPJ_BOOL(*)(void *,
|
||||
OPJ_UINT32*,
|
||||
OPJ_UINT32*,
|
||||
OPJ_INT32*, OPJ_INT32*,
|
||||
OPJ_INT32*, OPJ_INT32*,
|
||||
OPJ_UINT32*,
|
||||
OPJ_BOOL*,
|
||||
OPJ_UINT32 *,
|
||||
OPJ_UINT32 *,
|
||||
OPJ_INT32 *, OPJ_INT32 *,
|
||||
OPJ_INT32 *, OPJ_INT32 *,
|
||||
OPJ_UINT32 *,
|
||||
OPJ_BOOL *,
|
||||
struct opj_stream_private *,
|
||||
struct opj_event_mgr *)) opj_j2k_read_tile_header;
|
||||
|
||||
l_codec->m_codec_data.m_decompression.opj_decode_tile_data =
|
||||
(OPJ_BOOL(*)(void *,
|
||||
OPJ_UINT32,
|
||||
OPJ_BYTE*,
|
||||
OPJ_BYTE *,
|
||||
OPJ_UINT32,
|
||||
struct opj_stream_private *,
|
||||
struct opj_event_mgr *)) opj_j2k_decode_tile;
|
||||
|
||||
l_codec->m_codec_data.m_decompression.opj_set_decode_area =
|
||||
(OPJ_BOOL(*)(void *,
|
||||
opj_image_t*,
|
||||
opj_image_t *,
|
||||
OPJ_INT32, OPJ_INT32, OPJ_INT32, OPJ_INT32,
|
||||
struct opj_event_mgr *)) opj_j2k_set_decode_area;
|
||||
|
||||
|
@ -237,26 +227,26 @@ opj_codec_t* OPJ_CALLCONV opj_create_decompress(OPJ_CODEC_FORMAT p_format)
|
|||
(OPJ_BOOL(*)(void *p_codec,
|
||||
opj_stream_private_t *p_cio,
|
||||
opj_image_t *p_image,
|
||||
struct opj_event_mgr * p_manager,
|
||||
struct opj_event_mgr *p_manager,
|
||||
OPJ_UINT32 tile_index)) opj_j2k_get_tile;
|
||||
|
||||
l_codec->m_codec_data.m_decompression.opj_set_decoded_resolution_factor =
|
||||
(OPJ_BOOL(*)(void * p_codec,
|
||||
(OPJ_BOOL(*)(void *p_codec,
|
||||
OPJ_UINT32 res_factor,
|
||||
struct opj_event_mgr * p_manager)) opj_j2k_set_decoded_resolution_factor;
|
||||
struct opj_event_mgr *p_manager)) opj_j2k_set_decoded_resolution_factor;
|
||||
|
||||
l_codec->m_codec_data.m_decompression.opj_set_decoded_components =
|
||||
(OPJ_BOOL(*)(void * p_codec,
|
||||
(OPJ_BOOL(*)(void *p_codec,
|
||||
OPJ_UINT32 numcomps,
|
||||
const OPJ_UINT32 * comps_indices,
|
||||
struct opj_event_mgr * p_manager)) opj_j2k_set_decoded_components;
|
||||
const OPJ_UINT32 *comps_indices,
|
||||
struct opj_event_mgr *p_manager)) opj_j2k_set_decoded_components;
|
||||
|
||||
l_codec->opj_set_threads =
|
||||
(OPJ_BOOL(*)(void * p_codec, OPJ_UINT32 num_threads)) opj_j2k_set_threads;
|
||||
(OPJ_BOOL(*)(void *p_codec, OPJ_UINT32 num_threads)) opj_j2k_set_threads;
|
||||
|
||||
l_codec->m_codec = opj_j2k_create_decompress();
|
||||
|
||||
if (! l_codec->m_codec) {
|
||||
if (!l_codec->m_codec) {
|
||||
opj_free(l_codec);
|
||||
return NULL;
|
||||
}
|
||||
|
@ -265,18 +255,18 @@ opj_codec_t* OPJ_CALLCONV opj_create_decompress(OPJ_CODEC_FORMAT p_format)
|
|||
|
||||
case OPJ_CODEC_JP2:
|
||||
/* get a JP2 decoder handle */
|
||||
l_codec->opj_dump_codec = (void (*)(void*, OPJ_INT32, FILE*)) jp2_dump;
|
||||
l_codec->opj_dump_codec = (void (*)(void *, OPJ_INT32, FILE *)) jp2_dump;
|
||||
|
||||
l_codec->opj_get_codec_info = (opj_codestream_info_v2_t* (*)(
|
||||
void*)) jp2_get_cstr_info;
|
||||
l_codec->opj_get_codec_info = (opj_codestream_info_v2_t *(*)(
|
||||
void *)) jp2_get_cstr_info;
|
||||
|
||||
l_codec->opj_get_codec_index = (opj_codestream_index_t* (*)(
|
||||
void*)) jp2_get_cstr_index;
|
||||
l_codec->opj_get_codec_index = (opj_codestream_index_t *(*)(
|
||||
void *)) jp2_get_cstr_index;
|
||||
|
||||
l_codec->m_codec_data.m_decompression.opj_decode =
|
||||
(OPJ_BOOL(*)(void *,
|
||||
struct opj_stream_private *,
|
||||
opj_image_t*,
|
||||
opj_image_t *,
|
||||
struct opj_event_mgr *)) opj_jp2_decode;
|
||||
|
||||
l_codec->m_codec_data.m_decompression.opj_end_decompress =
|
||||
|
@ -292,10 +282,10 @@ opj_codec_t* OPJ_CALLCONV opj_create_decompress(OPJ_CODEC_FORMAT p_format)
|
|||
|
||||
l_codec->m_codec_data.m_decompression.opj_read_tile_header =
|
||||
(OPJ_BOOL(*)(void *,
|
||||
OPJ_UINT32*,
|
||||
OPJ_UINT32*,
|
||||
OPJ_INT32*,
|
||||
OPJ_INT32*,
|
||||
OPJ_UINT32 *,
|
||||
OPJ_UINT32 *,
|
||||
OPJ_INT32 *,
|
||||
OPJ_INT32 *,
|
||||
OPJ_INT32 *,
|
||||
OPJ_INT32 *,
|
||||
OPJ_UINT32 *,
|
||||
|
@ -305,19 +295,19 @@ opj_codec_t* OPJ_CALLCONV opj_create_decompress(OPJ_CODEC_FORMAT p_format)
|
|||
|
||||
l_codec->m_codec_data.m_decompression.opj_decode_tile_data =
|
||||
(OPJ_BOOL(*)(void *,
|
||||
OPJ_UINT32, OPJ_BYTE*, OPJ_UINT32,
|
||||
OPJ_UINT32, OPJ_BYTE *, OPJ_UINT32,
|
||||
struct opj_stream_private *,
|
||||
struct opj_event_mgr *)) opj_jp2_decode_tile;
|
||||
|
||||
l_codec->m_codec_data.m_decompression.opj_destroy = (void (*)(
|
||||
void *))opj_jp2_destroy;
|
||||
void *)) opj_jp2_destroy;
|
||||
|
||||
l_codec->m_codec_data.m_decompression.opj_setup_decoder =
|
||||
(void (*)(void *, opj_dparameters_t *)) opj_jp2_setup_decoder;
|
||||
|
||||
l_codec->m_codec_data.m_decompression.opj_set_decode_area =
|
||||
(OPJ_BOOL(*)(void *,
|
||||
opj_image_t*,
|
||||
opj_image_t *,
|
||||
OPJ_INT32, OPJ_INT32, OPJ_INT32, OPJ_INT32,
|
||||
struct opj_event_mgr *)) opj_jp2_set_decode_area;
|
||||
|
||||
|
@ -325,26 +315,26 @@ opj_codec_t* OPJ_CALLCONV opj_create_decompress(OPJ_CODEC_FORMAT p_format)
|
|||
(OPJ_BOOL(*)(void *p_codec,
|
||||
opj_stream_private_t *p_cio,
|
||||
opj_image_t *p_image,
|
||||
struct opj_event_mgr * p_manager,
|
||||
struct opj_event_mgr *p_manager,
|
||||
OPJ_UINT32 tile_index)) opj_jp2_get_tile;
|
||||
|
||||
l_codec->m_codec_data.m_decompression.opj_set_decoded_resolution_factor =
|
||||
(OPJ_BOOL(*)(void * p_codec,
|
||||
(OPJ_BOOL(*)(void *p_codec,
|
||||
OPJ_UINT32 res_factor,
|
||||
opj_event_mgr_t * p_manager)) opj_jp2_set_decoded_resolution_factor;
|
||||
opj_event_mgr_t *p_manager)) opj_jp2_set_decoded_resolution_factor;
|
||||
|
||||
l_codec->m_codec_data.m_decompression.opj_set_decoded_components =
|
||||
(OPJ_BOOL(*)(void * p_codec,
|
||||
(OPJ_BOOL(*)(void *p_codec,
|
||||
OPJ_UINT32 numcomps,
|
||||
const OPJ_UINT32 * comps_indices,
|
||||
struct opj_event_mgr * p_manager)) opj_jp2_set_decoded_components;
|
||||
const OPJ_UINT32 *comps_indices,
|
||||
struct opj_event_mgr *p_manager)) opj_jp2_set_decoded_components;
|
||||
|
||||
l_codec->opj_set_threads =
|
||||
(OPJ_BOOL(*)(void * p_codec, OPJ_UINT32 num_threads)) opj_jp2_set_threads;
|
||||
(OPJ_BOOL(*)(void *p_codec, OPJ_UINT32 num_threads)) opj_jp2_set_threads;
|
||||
|
||||
l_codec->m_codec = opj_jp2_create(OPJ_TRUE);
|
||||
|
||||
if (! l_codec->m_codec) {
|
||||
if (!l_codec->m_codec) {
|
||||
opj_free(l_codec);
|
||||
return 00;
|
||||
}
|
||||
|
@ -358,12 +348,11 @@ opj_codec_t* OPJ_CALLCONV opj_create_decompress(OPJ_CODEC_FORMAT p_format)
|
|||
}
|
||||
|
||||
opj_set_default_event_handler(&(l_codec->m_event_mgr));
|
||||
return (opj_codec_t*) l_codec;
|
||||
return (opj_codec_t *) l_codec;
|
||||
}
|
||||
|
||||
void OPJ_CALLCONV opj_set_default_decoder_parameters(opj_dparameters_t
|
||||
*parameters)
|
||||
{
|
||||
*parameters) {
|
||||
if (parameters) {
|
||||
memset(parameters, 0, sizeof(opj_dparameters_t));
|
||||
/* default decoding parameters */
|
||||
|
@ -385,24 +374,22 @@ void OPJ_CALLCONV opj_set_default_decoder_parameters(opj_dparameters_t
|
|||
|
||||
|
||||
OPJ_BOOL OPJ_CALLCONV opj_codec_set_threads(opj_codec_t *p_codec,
|
||||
int num_threads)
|
||||
{
|
||||
int num_threads) {
|
||||
if (p_codec && (num_threads >= 0)) {
|
||||
opj_codec_private_t * l_codec = (opj_codec_private_t *) p_codec;
|
||||
opj_codec_private_t *l_codec = (opj_codec_private_t *) p_codec;
|
||||
|
||||
return l_codec->opj_set_threads(l_codec->m_codec, (OPJ_UINT32)num_threads);
|
||||
return l_codec->opj_set_threads(l_codec->m_codec, (OPJ_UINT32) num_threads);
|
||||
}
|
||||
return OPJ_FALSE;
|
||||
}
|
||||
|
||||
OPJ_BOOL OPJ_CALLCONV opj_setup_decoder(opj_codec_t *p_codec,
|
||||
opj_dparameters_t *parameters
|
||||
)
|
||||
{
|
||||
) {
|
||||
if (p_codec && parameters) {
|
||||
opj_codec_private_t * l_codec = (opj_codec_private_t *) p_codec;
|
||||
opj_codec_private_t *l_codec = (opj_codec_private_t *) p_codec;
|
||||
|
||||
if (! l_codec->is_decompressor) {
|
||||
if (!l_codec->is_decompressor) {
|
||||
opj_event_msg(&(l_codec->m_event_mgr), EVT_ERROR,
|
||||
"Codec provided to the opj_setup_decoder function is not a decompressor handler.\n");
|
||||
return OPJ_FALSE;
|
||||
|
@ -417,13 +404,12 @@ OPJ_BOOL OPJ_CALLCONV opj_setup_decoder(opj_codec_t *p_codec,
|
|||
|
||||
OPJ_BOOL OPJ_CALLCONV opj_read_header(opj_stream_t *p_stream,
|
||||
opj_codec_t *p_codec,
|
||||
opj_image_t **p_image)
|
||||
{
|
||||
opj_image_t **p_image) {
|
||||
if (p_codec && p_stream) {
|
||||
opj_codec_private_t* l_codec = (opj_codec_private_t*) p_codec;
|
||||
opj_stream_private_t* l_stream = (opj_stream_private_t*) p_stream;
|
||||
opj_codec_private_t *l_codec = (opj_codec_private_t *) p_codec;
|
||||
opj_stream_private_t *l_stream = (opj_stream_private_t *) p_stream;
|
||||
|
||||
if (! l_codec->is_decompressor) {
|
||||
if (!l_codec->is_decompressor) {
|
||||
opj_event_msg(&(l_codec->m_event_mgr), EVT_ERROR,
|
||||
"Codec provided to the opj_read_header function is not a decompressor handler.\n");
|
||||
return OPJ_FALSE;
|
||||
|
@ -441,13 +427,12 @@ OPJ_BOOL OPJ_CALLCONV opj_read_header(opj_stream_t *p_stream,
|
|||
|
||||
OPJ_BOOL OPJ_CALLCONV opj_set_decoded_components(opj_codec_t *p_codec,
|
||||
OPJ_UINT32 numcomps,
|
||||
const OPJ_UINT32* comps_indices,
|
||||
OPJ_BOOL apply_color_transforms)
|
||||
{
|
||||
const OPJ_UINT32 *comps_indices,
|
||||
OPJ_BOOL apply_color_transforms) {
|
||||
if (p_codec) {
|
||||
opj_codec_private_t * l_codec = (opj_codec_private_t *) p_codec;
|
||||
opj_codec_private_t *l_codec = (opj_codec_private_t *) p_codec;
|
||||
|
||||
if (! l_codec->is_decompressor) {
|
||||
if (!l_codec->is_decompressor) {
|
||||
opj_event_msg(&(l_codec->m_event_mgr), EVT_ERROR,
|
||||
"Codec provided to the opj_set_decoded_components function is not a decompressor handler.\n");
|
||||
return OPJ_FALSE;
|
||||
|
@ -470,13 +455,12 @@ OPJ_BOOL OPJ_CALLCONV opj_set_decoded_components(opj_codec_t *p_codec,
|
|||
|
||||
OPJ_BOOL OPJ_CALLCONV opj_decode(opj_codec_t *p_codec,
|
||||
opj_stream_t *p_stream,
|
||||
opj_image_t* p_image)
|
||||
{
|
||||
opj_image_t *p_image) {
|
||||
if (p_codec && p_stream) {
|
||||
opj_codec_private_t * l_codec = (opj_codec_private_t *) p_codec;
|
||||
opj_stream_private_t * l_stream = (opj_stream_private_t *) p_stream;
|
||||
opj_codec_private_t *l_codec = (opj_codec_private_t *) p_codec;
|
||||
opj_stream_private_t *l_stream = (opj_stream_private_t *) p_stream;
|
||||
|
||||
if (! l_codec->is_decompressor) {
|
||||
if (!l_codec->is_decompressor) {
|
||||
return OPJ_FALSE;
|
||||
}
|
||||
|
||||
|
@ -490,15 +474,14 @@ OPJ_BOOL OPJ_CALLCONV opj_decode(opj_codec_t *p_codec,
|
|||
}
|
||||
|
||||
OPJ_BOOL OPJ_CALLCONV opj_set_decode_area(opj_codec_t *p_codec,
|
||||
opj_image_t* p_image,
|
||||
opj_image_t *p_image,
|
||||
OPJ_INT32 p_start_x, OPJ_INT32 p_start_y,
|
||||
OPJ_INT32 p_end_x, OPJ_INT32 p_end_y
|
||||
)
|
||||
{
|
||||
) {
|
||||
if (p_codec) {
|
||||
opj_codec_private_t * l_codec = (opj_codec_private_t *) p_codec;
|
||||
opj_codec_private_t *l_codec = (opj_codec_private_t *) p_codec;
|
||||
|
||||
if (! l_codec->is_decompressor) {
|
||||
if (!l_codec->is_decompressor) {
|
||||
return OPJ_FALSE;
|
||||
}
|
||||
|
||||
|
@ -513,19 +496,18 @@ OPJ_BOOL OPJ_CALLCONV opj_set_decode_area(opj_codec_t *p_codec,
|
|||
}
|
||||
|
||||
OPJ_BOOL OPJ_CALLCONV opj_read_tile_header(opj_codec_t *p_codec,
|
||||
opj_stream_t * p_stream,
|
||||
OPJ_UINT32 * p_tile_index,
|
||||
OPJ_UINT32 * p_data_size,
|
||||
OPJ_INT32 * p_tile_x0, OPJ_INT32 * p_tile_y0,
|
||||
OPJ_INT32 * p_tile_x1, OPJ_INT32 * p_tile_y1,
|
||||
OPJ_UINT32 * p_nb_comps,
|
||||
OPJ_BOOL * p_should_go_on)
|
||||
{
|
||||
opj_stream_t *p_stream,
|
||||
OPJ_UINT32 *p_tile_index,
|
||||
OPJ_UINT32 *p_data_size,
|
||||
OPJ_INT32 *p_tile_x0, OPJ_INT32 *p_tile_y0,
|
||||
OPJ_INT32 *p_tile_x1, OPJ_INT32 *p_tile_y1,
|
||||
OPJ_UINT32 *p_nb_comps,
|
||||
OPJ_BOOL *p_should_go_on) {
|
||||
if (p_codec && p_stream && p_data_size && p_tile_index) {
|
||||
opj_codec_private_t * l_codec = (opj_codec_private_t *) p_codec;
|
||||
opj_stream_private_t * l_stream = (opj_stream_private_t *) p_stream;
|
||||
opj_codec_private_t *l_codec = (opj_codec_private_t *) p_codec;
|
||||
opj_stream_private_t *l_stream = (opj_stream_private_t *) p_stream;
|
||||
|
||||
if (! l_codec->is_decompressor) {
|
||||
if (!l_codec->is_decompressor) {
|
||||
return OPJ_FALSE;
|
||||
}
|
||||
|
||||
|
@ -545,16 +527,15 @@ OPJ_BOOL OPJ_CALLCONV opj_read_tile_header(opj_codec_t *p_codec,
|
|||
|
||||
OPJ_BOOL OPJ_CALLCONV opj_decode_tile_data(opj_codec_t *p_codec,
|
||||
OPJ_UINT32 p_tile_index,
|
||||
OPJ_BYTE * p_data,
|
||||
OPJ_BYTE *p_data,
|
||||
OPJ_UINT32 p_data_size,
|
||||
opj_stream_t *p_stream
|
||||
)
|
||||
{
|
||||
) {
|
||||
if (p_codec && p_data && p_stream) {
|
||||
opj_codec_private_t * l_codec = (opj_codec_private_t *) p_codec;
|
||||
opj_stream_private_t * l_stream = (opj_stream_private_t *) p_stream;
|
||||
opj_codec_private_t *l_codec = (opj_codec_private_t *) p_codec;
|
||||
opj_stream_private_t *l_stream = (opj_stream_private_t *) p_stream;
|
||||
|
||||
if (! l_codec->is_decompressor) {
|
||||
if (!l_codec->is_decompressor) {
|
||||
return OPJ_FALSE;
|
||||
}
|
||||
|
||||
|
@ -572,13 +553,12 @@ OPJ_BOOL OPJ_CALLCONV opj_decode_tile_data(opj_codec_t *p_codec,
|
|||
OPJ_BOOL OPJ_CALLCONV opj_get_decoded_tile(opj_codec_t *p_codec,
|
||||
opj_stream_t *p_stream,
|
||||
opj_image_t *p_image,
|
||||
OPJ_UINT32 tile_index)
|
||||
{
|
||||
OPJ_UINT32 tile_index) {
|
||||
if (p_codec && p_stream) {
|
||||
opj_codec_private_t * l_codec = (opj_codec_private_t *) p_codec;
|
||||
opj_stream_private_t * l_stream = (opj_stream_private_t *) p_stream;
|
||||
opj_codec_private_t *l_codec = (opj_codec_private_t *) p_codec;
|
||||
opj_stream_private_t *l_stream = (opj_stream_private_t *) p_stream;
|
||||
|
||||
if (! l_codec->is_decompressor) {
|
||||
if (!l_codec->is_decompressor) {
|
||||
return OPJ_FALSE;
|
||||
}
|
||||
|
||||
|
@ -594,9 +574,8 @@ OPJ_BOOL OPJ_CALLCONV opj_get_decoded_tile(opj_codec_t *p_codec,
|
|||
}
|
||||
|
||||
OPJ_BOOL OPJ_CALLCONV opj_set_decoded_resolution_factor(opj_codec_t *p_codec,
|
||||
OPJ_UINT32 res_factor)
|
||||
{
|
||||
opj_codec_private_t * l_codec = (opj_codec_private_t *) p_codec;
|
||||
OPJ_UINT32 res_factor) {
|
||||
opj_codec_private_t *l_codec = (opj_codec_private_t *) p_codec;
|
||||
|
||||
if (!l_codec) {
|
||||
return OPJ_FALSE;
|
||||
|
@ -611,11 +590,10 @@ OPJ_BOOL OPJ_CALLCONV opj_set_decoded_resolution_factor(opj_codec_t *p_codec,
|
|||
/* ---------------------------------------------------------------------- */
|
||||
/* COMPRESSION FUNCTIONS*/
|
||||
|
||||
opj_codec_t* OPJ_CALLCONV opj_create_compress(OPJ_CODEC_FORMAT p_format)
|
||||
{
|
||||
opj_codec_t *OPJ_CALLCONV opj_create_compress(OPJ_CODEC_FORMAT p_format) {
|
||||
opj_codec_private_t *l_codec = 00;
|
||||
|
||||
l_codec = (opj_codec_private_t*)opj_calloc(1, sizeof(opj_codec_private_t));
|
||||
l_codec = (opj_codec_private_t *) opj_calloc(1, sizeof(opj_codec_private_t));
|
||||
if (!l_codec) {
|
||||
return 00;
|
||||
}
|
||||
|
@ -639,7 +617,7 @@ opj_codec_t* OPJ_CALLCONV opj_create_compress(OPJ_CODEC_FORMAT p_format)
|
|||
|
||||
l_codec->m_codec_data.m_compression.opj_write_tile = (OPJ_BOOL(*)(void *,
|
||||
OPJ_UINT32,
|
||||
OPJ_BYTE*,
|
||||
OPJ_BYTE *,
|
||||
OPJ_UINT32,
|
||||
struct opj_stream_private *,
|
||||
struct opj_event_mgr *)) opj_j2k_write_tile;
|
||||
|
@ -653,7 +631,7 @@ opj_codec_t* OPJ_CALLCONV opj_create_compress(OPJ_CODEC_FORMAT p_format)
|
|||
struct opj_event_mgr *)) opj_j2k_setup_encoder;
|
||||
|
||||
l_codec->m_codec = opj_j2k_create_compress();
|
||||
if (! l_codec->m_codec) {
|
||||
if (!l_codec->m_codec) {
|
||||
opj_free(l_codec);
|
||||
return 00;
|
||||
}
|
||||
|
@ -677,7 +655,7 @@ opj_codec_t* OPJ_CALLCONV opj_create_compress(OPJ_CODEC_FORMAT p_format)
|
|||
|
||||
l_codec->m_codec_data.m_compression.opj_write_tile = (OPJ_BOOL(*)(void *,
|
||||
OPJ_UINT32,
|
||||
OPJ_BYTE*,
|
||||
OPJ_BYTE *,
|
||||
OPJ_UINT32,
|
||||
struct opj_stream_private *,
|
||||
struct opj_event_mgr *)) opj_jp2_write_tile;
|
||||
|
@ -691,7 +669,7 @@ opj_codec_t* OPJ_CALLCONV opj_create_compress(OPJ_CODEC_FORMAT p_format)
|
|||
struct opj_event_mgr *)) opj_jp2_setup_encoder;
|
||||
|
||||
l_codec->m_codec = opj_jp2_create(OPJ_FALSE);
|
||||
if (! l_codec->m_codec) {
|
||||
if (!l_codec->m_codec) {
|
||||
opj_free(l_codec);
|
||||
return 00;
|
||||
}
|
||||
|
@ -706,12 +684,11 @@ opj_codec_t* OPJ_CALLCONV opj_create_compress(OPJ_CODEC_FORMAT p_format)
|
|||
}
|
||||
|
||||
opj_set_default_event_handler(&(l_codec->m_event_mgr));
|
||||
return (opj_codec_t*) l_codec;
|
||||
return (opj_codec_t *) l_codec;
|
||||
}
|
||||
|
||||
void OPJ_CALLCONV opj_set_default_encoder_parameters(opj_cparameters_t
|
||||
*parameters)
|
||||
{
|
||||
*parameters) {
|
||||
if (parameters) {
|
||||
memset(parameters, 0, sizeof(opj_cparameters_t));
|
||||
/* default coding parameters */
|
||||
|
@ -772,12 +749,11 @@ void OPJ_CALLCONV opj_set_default_encoder_parameters(opj_cparameters_t
|
|||
|
||||
OPJ_BOOL OPJ_CALLCONV opj_setup_encoder(opj_codec_t *p_codec,
|
||||
opj_cparameters_t *parameters,
|
||||
opj_image_t *p_image)
|
||||
{
|
||||
opj_image_t *p_image) {
|
||||
if (p_codec && parameters && p_image) {
|
||||
opj_codec_private_t * l_codec = (opj_codec_private_t *) p_codec;
|
||||
opj_codec_private_t *l_codec = (opj_codec_private_t *) p_codec;
|
||||
|
||||
if (! l_codec->is_decompressor) {
|
||||
if (!l_codec->is_decompressor) {
|
||||
return l_codec->m_codec_data.m_compression.opj_setup_encoder(l_codec->m_codec,
|
||||
parameters,
|
||||
p_image,
|
||||
|
@ -789,14 +765,13 @@ OPJ_BOOL OPJ_CALLCONV opj_setup_encoder(opj_codec_t *p_codec,
|
|||
}
|
||||
|
||||
OPJ_BOOL OPJ_CALLCONV opj_start_compress(opj_codec_t *p_codec,
|
||||
opj_image_t * p_image,
|
||||
opj_stream_t *p_stream)
|
||||
{
|
||||
opj_image_t *p_image,
|
||||
opj_stream_t *p_stream) {
|
||||
if (p_codec && p_stream) {
|
||||
opj_codec_private_t * l_codec = (opj_codec_private_t *) p_codec;
|
||||
opj_stream_private_t * l_stream = (opj_stream_private_t *) p_stream;
|
||||
opj_codec_private_t *l_codec = (opj_codec_private_t *) p_codec;
|
||||
opj_stream_private_t *l_stream = (opj_stream_private_t *) p_stream;
|
||||
|
||||
if (! l_codec->is_decompressor) {
|
||||
if (!l_codec->is_decompressor) {
|
||||
return l_codec->m_codec_data.m_compression.opj_start_compress(l_codec->m_codec,
|
||||
l_stream,
|
||||
p_image,
|
||||
|
@ -807,13 +782,12 @@ OPJ_BOOL OPJ_CALLCONV opj_start_compress(opj_codec_t *p_codec,
|
|||
return OPJ_FALSE;
|
||||
}
|
||||
|
||||
OPJ_BOOL OPJ_CALLCONV opj_encode(opj_codec_t *p_info, opj_stream_t *p_stream)
|
||||
{
|
||||
OPJ_BOOL OPJ_CALLCONV opj_encode(opj_codec_t *p_info, opj_stream_t *p_stream) {
|
||||
if (p_info && p_stream) {
|
||||
opj_codec_private_t * l_codec = (opj_codec_private_t *) p_info;
|
||||
opj_stream_private_t * l_stream = (opj_stream_private_t *) p_stream;
|
||||
opj_codec_private_t *l_codec = (opj_codec_private_t *) p_info;
|
||||
opj_stream_private_t *l_stream = (opj_stream_private_t *) p_stream;
|
||||
|
||||
if (! l_codec->is_decompressor) {
|
||||
if (!l_codec->is_decompressor) {
|
||||
return l_codec->m_codec_data.m_compression.opj_encode(l_codec->m_codec,
|
||||
l_stream,
|
||||
&(l_codec->m_event_mgr));
|
||||
|
@ -825,13 +799,12 @@ OPJ_BOOL OPJ_CALLCONV opj_encode(opj_codec_t *p_info, opj_stream_t *p_stream)
|
|||
}
|
||||
|
||||
OPJ_BOOL OPJ_CALLCONV opj_end_compress(opj_codec_t *p_codec,
|
||||
opj_stream_t *p_stream)
|
||||
{
|
||||
opj_stream_t *p_stream) {
|
||||
if (p_codec && p_stream) {
|
||||
opj_codec_private_t * l_codec = (opj_codec_private_t *) p_codec;
|
||||
opj_stream_private_t * l_stream = (opj_stream_private_t *) p_stream;
|
||||
opj_codec_private_t *l_codec = (opj_codec_private_t *) p_codec;
|
||||
opj_stream_private_t *l_stream = (opj_stream_private_t *) p_stream;
|
||||
|
||||
if (! l_codec->is_decompressor) {
|
||||
if (!l_codec->is_decompressor) {
|
||||
return l_codec->m_codec_data.m_compression.opj_end_compress(l_codec->m_codec,
|
||||
l_stream,
|
||||
&(l_codec->m_event_mgr));
|
||||
|
@ -842,13 +815,12 @@ OPJ_BOOL OPJ_CALLCONV opj_end_compress(opj_codec_t *p_codec,
|
|||
}
|
||||
|
||||
OPJ_BOOL OPJ_CALLCONV opj_end_decompress(opj_codec_t *p_codec,
|
||||
opj_stream_t *p_stream)
|
||||
{
|
||||
opj_stream_t *p_stream) {
|
||||
if (p_codec && p_stream) {
|
||||
opj_codec_private_t * l_codec = (opj_codec_private_t *) p_codec;
|
||||
opj_stream_private_t * l_stream = (opj_stream_private_t *) p_stream;
|
||||
opj_codec_private_t *l_codec = (opj_codec_private_t *) p_codec;
|
||||
opj_stream_private_t *l_stream = (opj_stream_private_t *) p_stream;
|
||||
|
||||
if (! l_codec->is_decompressor) {
|
||||
if (!l_codec->is_decompressor) {
|
||||
return OPJ_FALSE;
|
||||
}
|
||||
|
||||
|
@ -862,11 +834,10 @@ OPJ_BOOL OPJ_CALLCONV opj_end_decompress(opj_codec_t *p_codec,
|
|||
}
|
||||
|
||||
OPJ_BOOL OPJ_CALLCONV opj_set_MCT(opj_cparameters_t *parameters,
|
||||
OPJ_FLOAT32 * pEncodingMatrix,
|
||||
OPJ_INT32 * p_dc_shift, OPJ_UINT32 pNbComp)
|
||||
{
|
||||
OPJ_UINT32 l_matrix_size = pNbComp * pNbComp * (OPJ_UINT32)sizeof(OPJ_FLOAT32);
|
||||
OPJ_UINT32 l_dc_shift_size = pNbComp * (OPJ_UINT32)sizeof(OPJ_INT32);
|
||||
OPJ_FLOAT32 *pEncodingMatrix,
|
||||
OPJ_INT32 *p_dc_shift, OPJ_UINT32 pNbComp) {
|
||||
OPJ_UINT32 l_matrix_size = pNbComp * pNbComp * (OPJ_UINT32) sizeof(OPJ_FLOAT32);
|
||||
OPJ_UINT32 l_dc_shift_size = pNbComp * (OPJ_UINT32) sizeof(OPJ_INT32);
|
||||
OPJ_UINT32 l_mct_total_size = l_matrix_size + l_dc_shift_size;
|
||||
|
||||
/* add MCT capability */
|
||||
|
@ -880,7 +851,7 @@ OPJ_BOOL OPJ_CALLCONV opj_set_MCT(opj_cparameters_t *parameters,
|
|||
/* use array based MCT */
|
||||
parameters->tcp_mct = 2;
|
||||
parameters->mct_data = opj_malloc(l_mct_total_size);
|
||||
if (! parameters->mct_data) {
|
||||
if (!parameters->mct_data) {
|
||||
return OPJ_FALSE;
|
||||
}
|
||||
|
||||
|
@ -893,13 +864,12 @@ OPJ_BOOL OPJ_CALLCONV opj_set_MCT(opj_cparameters_t *parameters,
|
|||
|
||||
OPJ_BOOL OPJ_CALLCONV opj_write_tile(opj_codec_t *p_codec,
|
||||
OPJ_UINT32 p_tile_index,
|
||||
OPJ_BYTE * p_data,
|
||||
OPJ_BYTE *p_data,
|
||||
OPJ_UINT32 p_data_size,
|
||||
opj_stream_t *p_stream)
|
||||
{
|
||||
opj_stream_t *p_stream) {
|
||||
if (p_codec && p_stream && p_data) {
|
||||
opj_codec_private_t * l_codec = (opj_codec_private_t *) p_codec;
|
||||
opj_stream_private_t * l_stream = (opj_stream_private_t *) p_stream;
|
||||
opj_codec_private_t *l_codec = (opj_codec_private_t *) p_codec;
|
||||
opj_stream_private_t *l_stream = (opj_stream_private_t *) p_stream;
|
||||
|
||||
if (l_codec->is_decompressor) {
|
||||
return OPJ_FALSE;
|
||||
|
@ -918,10 +888,9 @@ OPJ_BOOL OPJ_CALLCONV opj_write_tile(opj_codec_t *p_codec,
|
|||
|
||||
/* ---------------------------------------------------------------------- */
|
||||
|
||||
void OPJ_CALLCONV opj_destroy_codec(opj_codec_t *p_codec)
|
||||
{
|
||||
void OPJ_CALLCONV opj_destroy_codec(opj_codec_t *p_codec) {
|
||||
if (p_codec) {
|
||||
opj_codec_private_t * l_codec = (opj_codec_private_t *) p_codec;
|
||||
opj_codec_private_t *l_codec = (opj_codec_private_t *) p_codec;
|
||||
|
||||
if (l_codec->is_decompressor) {
|
||||
l_codec->m_codec_data.m_decompression.opj_destroy(l_codec->m_codec);
|
||||
|
@ -938,10 +907,9 @@ void OPJ_CALLCONV opj_destroy_codec(opj_codec_t *p_codec)
|
|||
|
||||
void OPJ_CALLCONV opj_dump_codec(opj_codec_t *p_codec,
|
||||
OPJ_INT32 info_flag,
|
||||
FILE* output_stream)
|
||||
{
|
||||
FILE *output_stream) {
|
||||
if (p_codec) {
|
||||
opj_codec_private_t* l_codec = (opj_codec_private_t*) p_codec;
|
||||
opj_codec_private_t *l_codec = (opj_codec_private_t *) p_codec;
|
||||
|
||||
l_codec->opj_dump_codec(l_codec->m_codec, info_flag, output_stream);
|
||||
return;
|
||||
|
@ -952,10 +920,9 @@ void OPJ_CALLCONV opj_dump_codec(opj_codec_t *p_codec,
|
|||
return;
|
||||
}
|
||||
|
||||
opj_codestream_info_v2_t* OPJ_CALLCONV opj_get_cstr_info(opj_codec_t *p_codec)
|
||||
{
|
||||
opj_codestream_info_v2_t *OPJ_CALLCONV opj_get_cstr_info(opj_codec_t *p_codec) {
|
||||
if (p_codec) {
|
||||
opj_codec_private_t* l_codec = (opj_codec_private_t*) p_codec;
|
||||
opj_codec_private_t *l_codec = (opj_codec_private_t *) p_codec;
|
||||
|
||||
return l_codec->opj_get_codec_info(l_codec->m_codec);
|
||||
}
|
||||
|
@ -963,8 +930,7 @@ opj_codestream_info_v2_t* OPJ_CALLCONV opj_get_cstr_info(opj_codec_t *p_codec)
|
|||
return NULL;
|
||||
}
|
||||
|
||||
void OPJ_CALLCONV opj_destroy_cstr_info(opj_codestream_info_v2_t **cstr_info)
|
||||
{
|
||||
void OPJ_CALLCONV opj_destroy_cstr_info(opj_codestream_info_v2_t **cstr_info) {
|
||||
if (cstr_info) {
|
||||
|
||||
if ((*cstr_info)->m_default_tile_info.tccp_info) {
|
||||
|
@ -980,10 +946,9 @@ void OPJ_CALLCONV opj_destroy_cstr_info(opj_codestream_info_v2_t **cstr_info)
|
|||
}
|
||||
}
|
||||
|
||||
opj_codestream_index_t * OPJ_CALLCONV opj_get_cstr_index(opj_codec_t *p_codec)
|
||||
{
|
||||
opj_codestream_index_t *OPJ_CALLCONV opj_get_cstr_index(opj_codec_t *p_codec) {
|
||||
if (p_codec) {
|
||||
opj_codec_private_t* l_codec = (opj_codec_private_t*) p_codec;
|
||||
opj_codec_private_t *l_codec = (opj_codec_private_t *) p_codec;
|
||||
|
||||
return l_codec->opj_get_codec_index(l_codec->m_codec);
|
||||
}
|
||||
|
@ -991,31 +956,28 @@ opj_codestream_index_t * OPJ_CALLCONV opj_get_cstr_index(opj_codec_t *p_codec)
|
|||
return NULL;
|
||||
}
|
||||
|
||||
void OPJ_CALLCONV opj_destroy_cstr_index(opj_codestream_index_t **p_cstr_index)
|
||||
{
|
||||
void OPJ_CALLCONV opj_destroy_cstr_index(opj_codestream_index_t **p_cstr_index) {
|
||||
if (*p_cstr_index) {
|
||||
j2k_destroy_cstr_index(*p_cstr_index);
|
||||
(*p_cstr_index) = NULL;
|
||||
}
|
||||
}
|
||||
|
||||
opj_stream_t* OPJ_CALLCONV opj_stream_create_default_file_stream(
|
||||
const char *fname, OPJ_BOOL p_is_read_stream)
|
||||
{
|
||||
opj_stream_t *OPJ_CALLCONV opj_stream_create_default_file_stream(
|
||||
const char *fname, OPJ_BOOL p_is_read_stream) {
|
||||
return opj_stream_create_file_stream(fname, OPJ_J2K_STREAM_CHUNK_SIZE,
|
||||
p_is_read_stream);
|
||||
}
|
||||
|
||||
opj_stream_t* OPJ_CALLCONV opj_stream_create_file_stream(
|
||||
opj_stream_t *OPJ_CALLCONV opj_stream_create_file_stream(
|
||||
const char *fname,
|
||||
OPJ_SIZE_T p_size,
|
||||
OPJ_BOOL p_is_read_stream)
|
||||
{
|
||||
opj_stream_t* l_stream = 00;
|
||||
OPJ_BOOL p_is_read_stream) {
|
||||
opj_stream_t *l_stream = 00;
|
||||
FILE *p_file;
|
||||
const char *mode;
|
||||
|
||||
if (! fname) {
|
||||
if (!fname) {
|
||||
return NULL;
|
||||
}
|
||||
|
||||
|
@ -1027,12 +989,12 @@ opj_stream_t* OPJ_CALLCONV opj_stream_create_file_stream(
|
|||
|
||||
p_file = fopen(fname, mode);
|
||||
|
||||
if (! p_file) {
|
||||
if (!p_file) {
|
||||
return NULL;
|
||||
}
|
||||
|
||||
l_stream = opj_stream_create(p_size, p_is_read_stream);
|
||||
if (! l_stream) {
|
||||
if (!l_stream) {
|
||||
fclose(p_file);
|
||||
return NULL;
|
||||
}
|
||||
|
@ -1051,15 +1013,49 @@ opj_stream_t* OPJ_CALLCONV opj_stream_create_file_stream(
|
|||
}
|
||||
|
||||
|
||||
void* OPJ_CALLCONV opj_image_data_alloc(OPJ_SIZE_T size)
|
||||
{
|
||||
void* ret = opj_aligned_malloc(size);
|
||||
opj_stream_t *OPJ_CALLCONV opj_stream_create_default_c_vector(
|
||||
c_vector *fname, OPJ_BOOL p_is_read_stream) {
|
||||
return opj_stream_create_c_vector(fname, OPJ_J2K_STREAM_CHUNK_SIZE,
|
||||
p_is_read_stream);
|
||||
}
|
||||
|
||||
/** Create a stream from a file identified with c_vector
|
||||
* @param v c_vector
|
||||
* @param p_buffer_size size of the chunk used to stream
|
||||
* @param p_is_read_stream whether the stream is a read stream (true) or not (false)
|
||||
*/
|
||||
OPJ_API opj_stream_t *OPJ_CALLCONV opj_stream_create_c_vector(
|
||||
c_vector *v,
|
||||
OPJ_SIZE_T p_size,
|
||||
OPJ_BOOL p_is_read_stream) {
|
||||
opj_stream_t *l_stream = 00;
|
||||
if (!v) {
|
||||
return NULL;
|
||||
}
|
||||
|
||||
l_stream = opj_stream_create(p_size, p_is_read_stream);
|
||||
if (!l_stream) {
|
||||
return NULL;
|
||||
}
|
||||
|
||||
opj_stream_set_user_data(l_stream, v, NULL);
|
||||
opj_stream_set_user_data_length(l_stream, c_vector_size(v));
|
||||
opj_stream_set_read_function(l_stream, (opj_stream_read_fn) c_vector_read);
|
||||
opj_stream_set_write_function(l_stream, (opj_stream_write_fn) c_vector_write);
|
||||
opj_stream_set_seek_function(l_stream, (opj_stream_seek_fn) c_vector_seekg);
|
||||
opj_stream_set_skip_function(l_stream, (opj_stream_skip_fn) c_vector_skip);
|
||||
|
||||
return l_stream;
|
||||
}
|
||||
|
||||
|
||||
void *OPJ_CALLCONV opj_image_data_alloc(OPJ_SIZE_T size) {
|
||||
void *ret = opj_aligned_malloc(size);
|
||||
/* printf("opj_image_data_alloc %p\n", ret); */
|
||||
return ret;
|
||||
}
|
||||
|
||||
void OPJ_CALLCONV opj_image_data_free(void* ptr)
|
||||
{
|
||||
void OPJ_CALLCONV opj_image_data_free(void *ptr) {
|
||||
/* printf("opj_image_data_free %p\n", ptr); */
|
||||
opj_aligned_free(ptr);
|
||||
}
|
||||
|
|
|
@ -130,6 +130,7 @@ typedef uint64_t OPJ_UINT64;
|
|||
typedef int64_t OPJ_OFF_T; /* 64-bit file offset type */
|
||||
|
||||
#include <stdio.h>
|
||||
#include "c_vector.h"
|
||||
typedef size_t OPJ_SIZE_T;
|
||||
|
||||
/* Avoid compile-time warning because parameter is not used */
|
||||
|
@ -1252,6 +1253,24 @@ OPJ_API opj_stream_t* OPJ_CALLCONV opj_stream_create_file_stream(
|
|||
OPJ_SIZE_T p_buffer_size,
|
||||
OPJ_BOOL p_is_read_stream);
|
||||
|
||||
/**
|
||||
*
|
||||
* @param fname
|
||||
* @param p_is_read_stream
|
||||
* @return
|
||||
*/
|
||||
opj_stream_t *OPJ_CALLCONV opj_stream_create_default_c_vector(
|
||||
c_vector *fname, OPJ_BOOL p_is_read_stream);
|
||||
/** Create a stream from a file identified with c_vector
|
||||
* @param v c_vector
|
||||
* @param p_buffer_size size of the chunk used to stream
|
||||
* @param p_is_read_stream whether the stream is a read stream (true) or not (false)
|
||||
*/
|
||||
OPJ_API opj_stream_t* OPJ_CALLCONV opj_stream_create_c_vector(
|
||||
c_vector *v,
|
||||
OPJ_SIZE_T p_buffer_size,
|
||||
OPJ_BOOL p_is_read_stream);
|
||||
|
||||
/*
|
||||
==========================================================
|
||||
event manager functions definitions
|
||||
|
|
Loading…
Reference in New Issue