view release on metacpan or search on metacpan
src/Source/FreeImage/PluginG3.cpp view on Meta::CPAN
stretch = 1;
break;
case 'v': // -v for info
verbose++;
break;
}
}
*/
// open a temporary memory buffer to save decoded scanlines
memory = FreeImage_OpenMemory();
if(!memory) throw FI_MSG_ERROR_MEMORY;
// wrap the raw fax file
faxTIFF = TIFFClientOpen("(FakeInput)", "w",
// TIFFClientOpen() fails if we don't set existing value here
NULL,
_g3ReadProc, _g3WriteProc,
_g3SeekProc, _g3CloseProc,
_g3SizeProc, _g3MapProc,
src/Source/FreeImage/PluginG3.cpp view on Meta::CPAN
pal[0].rgbRed = pal[0].rgbGreen = pal[0].rgbBlue = 255;
pal[1].rgbRed = pal[1].rgbGreen = pal[1].rgbBlue = 0;
} else {
pal[0].rgbRed = pal[0].rgbGreen = pal[0].rgbBlue = 0;
pal[1].rgbRed = pal[1].rgbGreen = pal[1].rgbBlue = 255;
}
// ... resolution
FreeImage_SetDotsPerMeterX(dib, (unsigned)(resX/0.0254000 + 0.5));
FreeImage_SetDotsPerMeterY(dib, (unsigned)(resY/0.0254000 + 0.5));
// read the decoded scanline and fill the bitmap data
FreeImage_SeekMemory(memory, 0, SEEK_SET);
BYTE *bits = FreeImage_GetScanLine(dib, rows - 1);
for(int k = 0; k < rows; k++) {
FreeImage_ReadMemory(bits, linesize, 1, memory);
bits -= pitch;
}
// free the TIFF wrapper
TIFFClose(faxTIFF);
src/Source/FreeImage/PluginJ2K.cpp view on Meta::CPAN
}
// ----------------------------------------------------------
static FIBITMAP * DLL_CALLCONV
Load(FreeImageIO *io, fi_handle handle, int page, int flags, void *data) {
J2KFIO_t *fio = (J2KFIO_t*)data;
if (handle && fio) {
opj_codec_t *d_codec = NULL; // handle to a decompressor
opj_dparameters_t parameters; // decompression parameters
opj_image_t *image = NULL; // decoded image
FIBITMAP *dib = NULL;
// check the file format
if(!Validate(io, handle)) {
return NULL;
}
BOOL header_only = (flags & FIF_LOAD_NOPIXELS) == FIF_LOAD_NOPIXELS;
src/Source/FreeImage/PluginJP2.cpp view on Meta::CPAN
}
// ----------------------------------------------------------
static FIBITMAP * DLL_CALLCONV
Load(FreeImageIO *io, fi_handle handle, int page, int flags, void *data) {
J2KFIO_t *fio = (J2KFIO_t*)data;
if (handle && fio) {
opj_codec_t *d_codec = NULL; // handle to a decompressor
opj_dparameters_t parameters; // decompression parameters
opj_image_t *image = NULL; // decoded image
FIBITMAP *dib = NULL;
// check the file format
if(!Validate(io, handle)) {
return NULL;
}
BOOL header_only = (flags & FIF_LOAD_NOPIXELS) == FIF_LOAD_NOPIXELS;
src/Source/FreeImage/PluginJXR.cpp view on Meta::CPAN
@param flags FreeImage load flags
*/
static void
SetDecoderParameters(PKImageDecode *pDecoder, int flags) {
// load image & alpha for formats with alpha
pDecoder->WMP.wmiSCP.uAlphaMode = 2;
// more options to come ...
}
/**
Copy or convert & copy decoded pixels into the dib
@param pDecoder Decoder handle
@param out_guid_format Target guid format
@param dib Output dib
@param width Image width
@param height Image height
@return Returns 0 if successful, returns ERR otherwise
*/
static ERR
CopyPixels(PKImageDecode *pDecoder, PKPixelFormatGUID out_guid_format, FIBITMAP *dib, int width, int height) {
PKFormatConverter *pConverter = NULL; // pixel format converter
src/Source/FreeImage/PluginPICT.cpp view on Meta::CPAN
return FALSE;
}
static BOOL DLL_CALLCONV
SupportsICCProfiles() {
return FALSE;
}
/**
This plugin decodes macintosh PICT files with 1,2,4,8,16 and 32 bits per pixel as well as PICT/JPEG.
If an alpha channel is present in a 32-bit-PICT, it is decoded as well.
The PICT format is a general picture file format and can contain a lot of other elements besides bitmaps.
These elements are ignored.
*/
static FIBITMAP * DLL_CALLCONV
Load(FreeImageIO *io, fi_handle handle, int page, int flags, void *data) {
char outputMessage[ outputMessageSize ] = "";
FIBITMAP* dib = NULL;
try {
// Skip empty 512 byte header.
if ( !io->seek_proc(handle, 512, SEEK_CUR) == 0 )
src/Source/FreeImage/PluginPICT.cpp view on Meta::CPAN
float vres_ppm = vRes * ((float)39.4 / (float)65536.0);
FreeImage_SetDotsPerMeterX( dib, (LONG)hres_ppm );
FreeImage_SetDotsPerMeterY( dib, (LONG)vres_ppm );
switch( pictType ) {
case op9a:
DecodeOp9a( io, handle, dib, &pixMap );
break;
case jpeg:
// Already decoded if the embedded format was valid.
break;
case pixmap:
DecodePixmap( io, handle, dib, isRegion, &pixMap, rowBytes );
break;
case bitmap:
DecodeBitmap( io, handle, dib, isRegion, &bounds, rowBytes );
break;
default:
throw "invalid pict type";
}
src/Source/FreeImage/PluginPNG.cpp view on Meta::CPAN
}
static BOOL DLL_CALLCONV
SupportsNoPixels() {
return TRUE;
}
// --------------------------------------------------------------------------
/**
Configure the decoder so that decoded pixels are compatible with a FREE_IMAGE_TYPE format.
Set conversion instructions as needed.
@param png_ptr PNG handle
@param info_ptr PNG info handle
@param flags Decoder flags
@param output_image_type Returned FreeImage converted image type
@return Returns TRUE if successful, returns FALSE otherwise
@see png_read_update_info
*/
static BOOL
ConfigureDecoder(png_structp png_ptr, png_infop info_ptr, int flags, FREE_IMAGE_TYPE *output_image_type) {
src/Source/FreeImage/PluginWebP.cpp view on Meta::CPAN
// ---
// decode the input stream, taking 'config' into account.
webp_status = WebPDecode(data, data_size, &decoder_config);
if(webp_status != VP8_STATUS_OK) {
throw FI_MSG_ERROR_PARSING;
}
// fill the dib with the decoded data
const BYTE *src_bitmap = output_buffer->u.RGBA.rgba;
const unsigned src_pitch = (unsigned)output_buffer->u.RGBA.stride;
switch(bpp) {
case 24:
for(unsigned y = 0; y < height; y++) {
const BYTE *src_bits = src_bitmap + y * src_pitch;
BYTE *dst_bits = (BYTE*)FreeImage_GetScanLine(dib, height-1-y);
for(unsigned x = 0; x < width; x++) {
src/Source/LibJPEG/jutils.c view on Meta::CPAN
35, 36, 48, 49, 57, 58, 62, 63
};
#endif
/*
* jpeg_natural_order[i] is the natural-order position of the i'th element
* of zigzag order.
*
* When reading corrupted data, the Huffman decoders could attempt
* to reference an entry beyond the end of this array (if the decoded
* zero run length reaches past the end of the block). To prevent
* wild stores without adding an inner-loop test, we put some extra
* "63"s after the real entries. This will cause the extra coefficient
* to be stored in location 63 of the block, not somewhere random.
* The worst case would be a run-length of 15, which means we need 16
* fake entries.
*/
const int jpeg_natural_order[DCTSIZE2+16] = {
0, 1, 8, 16, 9, 2, 3, 10,
src/Source/LibJPEG/libjpeg.txt view on Meta::CPAN
identical to that of a regular (sequential) JPEG file of the same quality
setting. Progressive JPEG files are often slightly smaller than equivalent
sequential JPEG files, but the possibility of incremental display is the main
reason for using progressive JPEG.
The IJG encoder library generates progressive JPEG files when given a
suitable "scan script" defining how to divide the data into scans.
Creation of progressive JPEG files is otherwise transparent to the encoder.
Progressive JPEG files can also be read transparently by the decoder library.
If the decoding application simply uses the library as defined above, it
will receive a final decoded image without any indication that the file was
progressive. Of course, this approach does not allow incremental display.
To perform incremental display, an application needs to use the decoder
library's "buffered-image" mode, in which it receives a decoded image
multiple times.
Each displayed scan requires about as much work to decode as a full JPEG
image of the same size, so the decoder must be fairly fast in relation to the
data transmission rate in order to make incremental display useful. However,
it is possible to skip displaying the image and simply add the incoming bits
to the decoder's coefficient buffer. This is fast because only Huffman
decoding need be done, not IDCT, upsampling, colorspace conversion, etc.
The IJG decoder library allows the application to switch dynamically between
displaying the image and simply absorbing the incoming bits. A properly
src/Source/LibJPEG/libjpeg.txt view on Meta::CPAN
multiple-scan output cannot be created with a suspending data destination
manager, since jpeg_finish_compress() does not support suspension. We
should also note that the compressor currently forces Huffman optimization
mode when creating a progressive JPEG file, because the default Huffman
tables are unsuitable for progressive files.
Progressive decompression:
When buffered-image mode is not used, the decoder library will read all of
a multi-scan file during jpeg_start_decompress(), so that it can provide a
final decoded image. (Here "multi-scan" means either progressive or
multi-scan sequential.) This makes multi-scan files transparent to the
decoding application. However, existing applications that used suspending
input with version 5 of the IJG library will need to be modified to check
for a suspension return from jpeg_start_decompress().
To perform incremental display, an application must use the library's
buffered-image mode. This is described in the next section.
Buffered-image mode
-------------------
In buffered-image mode, the library stores the partially decoded image in a
coefficient buffer, from which it can be read out as many times as desired.
This mode is typically used for incremental display of progressive JPEG files,
but it can be used with any JPEG file. Each scan of a progressive JPEG file
adds more data (more detail) to the buffered image. The application can
display in lockstep with the source file (one display pass per input scan),
or it can allow input processing to outrun display processing. By making
input and display processing run independently, it is possible for the
application to adapt progressive display to a wide range of data transmission
rates.
src/Source/LibJXR/image/sys/windowsmediaphoto.h view on Meta::CPAN
With REENTRANT_MODE defined, the function PKImageDecode_Copy_WMP()
decodes only as far as the pRect parameter indicates. The width of the rectangle must be the width
of the image, but on each call, this function will decode the image up to the end of the MB Row
which contains the i-th pixel row, where i = pRect->Y.
A target use of this version would be to have PKImageDecode_Copy_WMP() called in a loop, once for
each MB row. On each call, pRect would specify a 1-MB-Row-tall rectangle that is the width of the
image. The decoder state is preserved until the Decoder finishes decoding the image.
If, at a certain point, a request is made for a rectangle _above_ the last row decoded, then the
decoder instance is terminated and re-initiated, and decoding re-starts, going from the beginning
of the image to the end of the current rectangle.
***
We've chosen to uncomment-out this definition in this header file. An alternate method would be
to allow the user to define this in the PREPROCESSOR DEFINITIONS section of the properties page
for each of the following projects: CommonLib, DecodeLib, JXRDecApp and JXRGlueLib.
*/
src/Source/LibJXR/image/sys/windowsmediaphoto.h view on Meta::CPAN
// Perf measurement
Bool fMeasurePerf;
} CWMIStrCodecParam;
typedef struct tagCWMImageBufferInfo {
void* pv; // pointer to scanline buffer
size_t cLine; // count of scanlines
size_t cbStride; // count of BYTE for stride
#ifdef REENTRANT_MODE
unsigned int uiFirstMBRow; // Current First MB Row being decoded
unsigned int uiLastMBRow; // Current Last MB Row being decoded
size_t cLinesDecoded; // Number of lines decoded and returned in low-mem mode
#endif // REENTRANT_MODE
} CWMImageBufferInfo;
/****************************************************************/
/* Encode API */
/****************************************************************/
EXTERN_C Int ImageStrEncInit(
src/Source/LibOpenJPEG/j2k.c view on Meta::CPAN
i, l_image->comps[i].dx);
}
if (!l_image->comps[i].dy) {
l_image->comps[i].dy = 1;
opj_event_msg(p_manager, EVT_WARNING, "- setting YRsiz_%d to %d => HYPOTHESIS!!!\n",
i, l_image->comps[i].dy);
}
}
}
#endif /* USE_JPWL */
l_img_comp->resno_decoded = 0; /* number of resolution decoded */
l_img_comp->factor = l_cp->m_specific_param.m_dec.m_reduce; /* reducing factor per component */
++l_img_comp;
}
/* Compute the number of tiles */
l_cp->tw = (OPJ_UINT32)opj_int_ceildiv((OPJ_INT32)(l_image->x1 - l_cp->tx0), (OPJ_INT32)l_cp->tdx);
l_cp->th = (OPJ_UINT32)opj_int_ceildiv((OPJ_INT32)(l_image->y1 - l_cp->ty0), (OPJ_INT32)l_cp->tdy);
/* Check that the number of tiles is valid */
if (l_cp->tw == 0 || l_cp->th == 0 || l_cp->tw > 65535 / l_cp->th) {
opj_event_msg( p_manager, EVT_ERROR,
"Invalid number of tiles : %u x %u (maximum fixed by jpeg2000 norm is 65535 tiles)\n",
l_cp->tw, l_cp->th);
return OPJ_FALSE;
}
l_nb_tiles = l_cp->tw * l_cp->th;
/* Define the tiles which will be decoded */
if (p_j2k->m_specific_param.m_decoder.m_discard_tiles) {
p_j2k->m_specific_param.m_decoder.m_start_tile_x = (p_j2k->m_specific_param.m_decoder.m_start_tile_x - l_cp->tx0) / l_cp->tdx;
p_j2k->m_specific_param.m_decoder.m_start_tile_y = (p_j2k->m_specific_param.m_decoder.m_start_tile_y - l_cp->ty0) / l_cp->tdy;
p_j2k->m_specific_param.m_decoder.m_end_tile_x = (OPJ_UINT32)opj_int_ceildiv((OPJ_INT32)(p_j2k->m_specific_param.m_decoder.m_end_tile_x - l_cp->tx0), (OPJ_INT32)l_cp->tdx);
p_j2k->m_specific_param.m_decoder.m_end_tile_y = (OPJ_UINT32)opj_int_ceildiv((OPJ_INT32)(p_j2k->m_specific_param.m_decoder.m_end_tile_y - l_cp->ty0), (OPJ_INT32)l_cp->tdy);
}
else {
p_j2k->m_specific_param.m_decoder.m_start_tile_x = 0;
p_j2k->m_specific_param.m_decoder.m_start_tile_y = 0;
p_j2k->m_specific_param.m_decoder.m_end_tile_x = l_cp->tw;
src/Source/LibOpenJPEG/j2k.c view on Meta::CPAN
/* Try to read 2 bytes (the next marker ID) from stream and copy them into the buffer */
if (opj_stream_read_data(p_stream,p_j2k->m_specific_param.m_decoder.m_header_data,2,p_manager) != 2) {
opj_event_msg(p_manager, EVT_ERROR, "Stream too short\n");
return OPJ_FALSE;
}
/* read 2 bytes as the new marker ID */
opj_read_bytes(p_j2k->m_specific_param.m_decoder.m_header_data,&l_current_marker,2);
}
opj_event_msg(p_manager, EVT_INFO, "Main header has been correctly decoded.\n");
/* Position of the last element if the main header */
p_j2k->cstr_index->main_head_end = (OPJ_UINT32) opj_stream_tell(p_stream) - 2;
/* Next step: read a tile-part header */
p_j2k->m_specific_param.m_decoder.m_state = J2K_STATE_TPHSOT;
return OPJ_TRUE;
}
src/Source/LibOpenJPEG/j2k.c view on Meta::CPAN
if (! opj_tcd_init_decode_tile(p_j2k->m_tcd, p_j2k->m_current_tile_number)) {
opj_event_msg(p_manager, EVT_ERROR, "Cannot decode tile, memory error\n");
return OPJ_FALSE;
}
opj_event_msg(p_manager, EVT_INFO, "Header of tile %d / %d has been read.\n",
p_j2k->m_current_tile_number, (p_j2k->m_cp.th * p_j2k->m_cp.tw) - 1);
*p_tile_index = p_j2k->m_current_tile_number;
*p_go_on = OPJ_TRUE;
*p_data_size = opj_tcd_get_decoded_tile_size(p_j2k->m_tcd);
*p_tile_x0 = p_j2k->m_tcd->tcd_image->tiles->x0;
*p_tile_y0 = p_j2k->m_tcd->tcd_image->tiles->y0;
*p_tile_x1 = p_j2k->m_tcd->tcd_image->tiles->x1;
*p_tile_y1 = p_j2k->m_tcd->tcd_image->tiles->y1;
*p_nb_comps = p_j2k->m_tcd->tcd_image->tiles->numcomps;
p_j2k->m_specific_param.m_decoder.m_state |= 0x0080;/* FIXME J2K_DEC_STATE_DATA;*/
return OPJ_TRUE;
}
src/Source/LibOpenJPEG/j2k.c view on Meta::CPAN
opj_j2k_tcp_destroy(l_tcp);
p_j2k->m_specific_param.m_decoder.m_state |= 0x8000;/*FIXME J2K_DEC_STATE_ERR;*/
opj_event_msg(p_manager, EVT_ERROR, "Failed to decode.\n");
return OPJ_FALSE;
}
if (! opj_tcd_update_tile_data(p_j2k->m_tcd,p_data,p_data_size)) {
return OPJ_FALSE;
}
/* To avoid to destroy the tcp which can be useful when we try to decode a tile decoded before (cf j2k_random_tile_access)
* we destroy just the data which will be re-read in read_tile_header*/
/*opj_j2k_tcp_destroy(l_tcp);
p_j2k->m_tcd->tcp = 0;*/
opj_j2k_tcp_data_destroy(l_tcp);
p_j2k->m_specific_param.m_decoder.m_can_decode = 0;
p_j2k->m_specific_param.m_decoder.m_state &= (~ (0x0080u));/* FIXME J2K_DEC_STATE_DATA);*/
if(opj_stream_get_number_byte_left(p_stream) == 0
&& p_j2k->m_specific_param.m_decoder.m_state == J2K_STATE_NEOC){
src/Source/LibOpenJPEG/j2k.c view on Meta::CPAN
/* Allocate output component buffer if necessary */
if (!l_img_comp_dest->data) {
l_img_comp_dest->data = (OPJ_INT32*) opj_calloc(l_img_comp_dest->w * l_img_comp_dest->h, sizeof(OPJ_INT32));
if (! l_img_comp_dest->data) {
return OPJ_FALSE;
}
}
/* Copy info from decoded comp image to output image */
l_img_comp_dest->resno_decoded = l_img_comp_src->resno_decoded;
/*-----*/
/* Compute the precision of the output buffer */
l_size_comp = l_img_comp_src->prec >> 3; /*(/ 8)*/
l_remaining = l_img_comp_src->prec & 7; /* (%8) */
l_res = l_tilec->resolutions + l_img_comp_src->resno_decoded;
if (l_remaining) {
++l_size_comp;
}
if (l_size_comp == 3) {
l_size_comp = 4;
}
/*-----*/
src/Source/LibOpenJPEG/j2k.c view on Meta::CPAN
l_x1_dest = l_x0_dest + l_img_comp_dest->w;
l_y1_dest = l_y0_dest + l_img_comp_dest->h;
/*if (i == 0) {
fprintf(stdout, "DEST: l_x0_dest=%d, l_x1_dest=%d, l_y0_dest=%d, l_y1_dest=%d (%d)\n",
l_x0_dest, l_x1_dest, l_y0_dest, l_y1_dest, l_img_comp_dest->factor );
}*/
/*-----*/
/* Compute the area (l_offset_x0_src, l_offset_y0_src, l_offset_x1_src, l_offset_y1_src)
* of the input buffer (decoded tile component) which will be move
* in the output buffer. Compute the area of the output buffer (l_start_x_dest,
* l_start_y_dest, l_width_dest, l_height_dest) which will be modified
* by this input area.
* */
assert( l_res->x0 >= 0);
assert( l_res->x1 >= 0);
if ( l_x0_dest < (OPJ_UINT32)l_res->x0 ) {
l_start_x_dest = (OPJ_UINT32)l_res->x0 - l_x0_dest;
l_offset_x0_src = 0;
src/Source/LibOpenJPEG/j2k.c view on Meta::CPAN
OPJ_INT32 l_comp_x1, l_comp_y1;
opj_image_comp_t* l_img_comp = NULL;
/* Check if we are read the main header */
if (p_j2k->m_specific_param.m_decoder.m_state != J2K_STATE_TPHSOT) { /* FIXME J2K_DEC_STATE_TPHSOT)*/
opj_event_msg(p_manager, EVT_ERROR, "Need to decode the main header before begin to decode the remaining codestream");
return OPJ_FALSE;
}
if ( !p_start_x && !p_start_y && !p_end_x && !p_end_y){
opj_event_msg(p_manager, EVT_INFO, "No decoded area parameters, set the decoded area to the whole image\n");
p_j2k->m_specific_param.m_decoder.m_start_tile_x = 0;
p_j2k->m_specific_param.m_decoder.m_start_tile_y = 0;
p_j2k->m_specific_param.m_decoder.m_end_tile_x = l_cp->tw;
p_j2k->m_specific_param.m_decoder.m_end_tile_y = l_cp->th;
return OPJ_TRUE;
}
/* ----- */
/* Check if the positions provided by the user are correct */
/* Left */
assert(p_start_x >= 0 );
assert(p_start_y >= 0 );
if ((OPJ_UINT32)p_start_x > l_image->x1 ) {
opj_event_msg(p_manager, EVT_ERROR,
"Left position of the decoded area (region_x0=%d) is outside the image area (Xsiz=%d).\n",
p_start_x, l_image->x1);
return OPJ_FALSE;
}
else if ((OPJ_UINT32)p_start_x < l_image->x0){
opj_event_msg(p_manager, EVT_WARNING,
"Left position of the decoded area (region_x0=%d) is outside the image area (XOsiz=%d).\n",
p_start_x, l_image->x0);
p_j2k->m_specific_param.m_decoder.m_start_tile_x = 0;
p_image->x0 = l_image->x0;
}
else {
p_j2k->m_specific_param.m_decoder.m_start_tile_x = ((OPJ_UINT32)p_start_x - l_cp->tx0) / l_cp->tdx;
p_image->x0 = (OPJ_UINT32)p_start_x;
}
/* Up */
if ((OPJ_UINT32)p_start_y > l_image->y1){
opj_event_msg(p_manager, EVT_ERROR,
"Up position of the decoded area (region_y0=%d) is outside the image area (Ysiz=%d).\n",
p_start_y, l_image->y1);
return OPJ_FALSE;
}
else if ((OPJ_UINT32)p_start_y < l_image->y0){
opj_event_msg(p_manager, EVT_WARNING,
"Up position of the decoded area (region_y0=%d) is outside the image area (YOsiz=%d).\n",
p_start_y, l_image->y0);
p_j2k->m_specific_param.m_decoder.m_start_tile_y = 0;
p_image->y0 = l_image->y0;
}
else {
p_j2k->m_specific_param.m_decoder.m_start_tile_y = ((OPJ_UINT32)p_start_y - l_cp->ty0) / l_cp->tdy;
p_image->y0 = (OPJ_UINT32)p_start_y;
}
/* Right */
assert((OPJ_UINT32)p_end_x > 0);
assert((OPJ_UINT32)p_end_y > 0);
if ((OPJ_UINT32)p_end_x < l_image->x0) {
opj_event_msg(p_manager, EVT_ERROR,
"Right position of the decoded area (region_x1=%d) is outside the image area (XOsiz=%d).\n",
p_end_x, l_image->x0);
return OPJ_FALSE;
}
else if ((OPJ_UINT32)p_end_x > l_image->x1) {
opj_event_msg(p_manager, EVT_WARNING,
"Right position of the decoded area (region_x1=%d) is outside the image area (Xsiz=%d).\n",
p_end_x, l_image->x1);
p_j2k->m_specific_param.m_decoder.m_end_tile_x = l_cp->tw;
p_image->x1 = l_image->x1;
}
else {
p_j2k->m_specific_param.m_decoder.m_end_tile_x = (OPJ_UINT32)opj_int_ceildiv(p_end_x - (OPJ_INT32)l_cp->tx0, (OPJ_INT32)l_cp->tdx);
p_image->x1 = (OPJ_UINT32)p_end_x;
}
/* Bottom */
if ((OPJ_UINT32)p_end_y < l_image->y0) {
opj_event_msg(p_manager, EVT_ERROR,
"Bottom position of the decoded area (region_y1=%d) is outside the image area (YOsiz=%d).\n",
p_end_y, l_image->y0);
return OPJ_FALSE;
}
if ((OPJ_UINT32)p_end_y > l_image->y1){
opj_event_msg(p_manager, EVT_WARNING,
"Bottom position of the decoded area (region_y1=%d) is outside the image area (Ysiz=%d).\n",
p_end_y, l_image->y1);
p_j2k->m_specific_param.m_decoder.m_end_tile_y = l_cp->th;
p_image->y1 = l_image->y1;
}
else{
p_j2k->m_specific_param.m_decoder.m_end_tile_y = (OPJ_UINT32)opj_int_ceildiv(p_end_y - (OPJ_INT32)l_cp->ty0, (OPJ_INT32)l_cp->tdy);
p_image->y1 = (OPJ_UINT32)p_end_y;
}
/* ----- */
src/Source/LibOpenJPEG/j2k.c view on Meta::CPAN
l_img_comp->x0 = (OPJ_UINT32)opj_int_ceildiv((OPJ_INT32)p_image->x0, (OPJ_INT32)l_img_comp->dx);
l_img_comp->y0 = (OPJ_UINT32)opj_int_ceildiv((OPJ_INT32)p_image->y0, (OPJ_INT32)l_img_comp->dy);
l_comp_x1 = opj_int_ceildiv((OPJ_INT32)p_image->x1, (OPJ_INT32)l_img_comp->dx);
l_comp_y1 = opj_int_ceildiv((OPJ_INT32)p_image->y1, (OPJ_INT32)l_img_comp->dy);
l_w = opj_int_ceildivpow2(l_comp_x1, (OPJ_INT32)l_img_comp->factor)
- opj_int_ceildivpow2((OPJ_INT32)l_img_comp->x0, (OPJ_INT32)l_img_comp->factor);
if (l_w < 0){
opj_event_msg(p_manager, EVT_ERROR,
"Size x of the decoded component image is incorrect (comp[%d].w=%d).\n",
it_comp, l_w);
return OPJ_FALSE;
}
l_img_comp->w = (OPJ_UINT32)l_w;
l_h = opj_int_ceildivpow2(l_comp_y1, (OPJ_INT32)l_img_comp->factor)
- opj_int_ceildivpow2((OPJ_INT32)l_img_comp->y0, (OPJ_INT32)l_img_comp->factor);
if (l_h < 0){
opj_event_msg(p_manager, EVT_ERROR,
"Size y of the decoded component image is incorrect (comp[%d].h=%d).\n",
it_comp, l_h);
return OPJ_FALSE;
}
l_img_comp->h = (OPJ_UINT32)l_h;
l_img_comp++;
}
opj_event_msg( p_manager, EVT_INFO,"Setting decoding area to %d,%d,%d,%d\n",
p_image->x0, p_image->y0, p_image->x1, p_image->y1);
src/Source/LibOpenJPEG/j2k.c view on Meta::CPAN
}
l_current_data = l_new_current_data;
l_max_data_size = l_data_size;
}
if (! opj_j2k_decode_tile(p_j2k,l_current_tile_no,l_current_data,l_data_size,p_stream,p_manager)) {
opj_free(l_current_data);
opj_event_msg(p_manager, EVT_ERROR, "Failed to decode tile %d/%d\n", l_current_tile_no +1, p_j2k->m_cp.th * p_j2k->m_cp.tw);
return OPJ_FALSE;
}
opj_event_msg(p_manager, EVT_INFO, "Tile %d/%d has been decoded.\n", l_current_tile_no +1, p_j2k->m_cp.th * p_j2k->m_cp.tw);
if (! opj_j2k_update_image_data(p_j2k->m_tcd,l_current_data, p_j2k->m_output_image)) {
opj_free(l_current_data);
return OPJ_FALSE;
}
opj_event_msg(p_manager, EVT_INFO, "Image data has been updated with tile %d.\n\n", l_current_tile_no + 1);
if(opj_stream_get_number_byte_left(p_stream) == 0
&& p_j2k->m_specific_param.m_decoder.m_state == J2K_STATE_NEOC)
break;
src/Source/LibOpenJPEG/j2k.c view on Meta::CPAN
return OPJ_FALSE;
}
l_current_data = l_new_current_data;
l_max_data_size = l_data_size;
}
if (! opj_j2k_decode_tile(p_j2k,l_current_tile_no,l_current_data,l_data_size,p_stream,p_manager)) {
opj_free(l_current_data);
return OPJ_FALSE;
}
opj_event_msg(p_manager, EVT_INFO, "Tile %d/%d has been decoded.\n", l_current_tile_no, (p_j2k->m_cp.th * p_j2k->m_cp.tw) - 1);
if (! opj_j2k_update_image_data(p_j2k->m_tcd,l_current_data, p_j2k->m_output_image)) {
opj_free(l_current_data);
return OPJ_FALSE;
}
opj_event_msg(p_manager, EVT_INFO, "Image data has been updated with tile %d.\n\n", l_current_tile_no);
if(l_current_tile_no == l_tile_no_to_dec)
{
/* move into the codestream to the the first SOT (FIXME or not move?)*/
src/Source/LibOpenJPEG/j2k.c view on Meta::CPAN
/* Decode the codestream */
if (! opj_j2k_exec (p_j2k,p_j2k->m_procedure_list,p_stream,p_manager)) {
opj_image_destroy(p_j2k->m_private_image);
p_j2k->m_private_image = NULL;
return OPJ_FALSE;
}
/* Move data and copy one information from codec to output image*/
for (compno = 0; compno < p_image->numcomps; compno++) {
p_image->comps[compno].resno_decoded = p_j2k->m_output_image->comps[compno].resno_decoded;
p_image->comps[compno].data = p_j2k->m_output_image->comps[compno].data;
#if 0
char fn[256];
sprintf( fn, "/tmp/%d.raw", compno );
FILE *debug = fopen( fn, "wb" );
fwrite( p_image->comps[compno].data, sizeof(OPJ_INT32), p_image->comps[compno].w * p_image->comps[compno].h, debug );
fclose( debug );
#endif
p_j2k->m_output_image->comps[compno].data = NULL;
}
src/Source/LibOpenJPEG/j2k.c view on Meta::CPAN
/* Decode the codestream */
if (! opj_j2k_exec (p_j2k,p_j2k->m_procedure_list,p_stream,p_manager)) {
opj_image_destroy(p_j2k->m_private_image);
p_j2k->m_private_image = NULL;
return OPJ_FALSE;
}
/* Move data and copy one information from codec to output image*/
for (compno = 0; compno < p_image->numcomps; compno++) {
p_image->comps[compno].resno_decoded = p_j2k->m_output_image->comps[compno].resno_decoded;
if (p_image->comps[compno].data)
opj_free(p_image->comps[compno].data);
p_image->comps[compno].data = p_j2k->m_output_image->comps[compno].data;
p_j2k->m_output_image->comps[compno].data = NULL;
}
return OPJ_TRUE;
}
OPJ_BOOL opj_j2k_set_decoded_resolution_factor(opj_j2k_t *p_j2k,
OPJ_UINT32 res_factor,
opj_event_mgr_t * p_manager)
{
OPJ_UINT32 it_comp;
p_j2k->m_cp.m_specific_param.m_dec.m_reduce = res_factor;
if (p_j2k->m_private_image) {
if (p_j2k->m_private_image->comps) {
if (p_j2k->m_specific_param.m_decoder.m_default_tcp) {
src/Source/LibOpenJPEG/j2k.h view on Meta::CPAN
OPJ_UINT32 m_fixed_alloc : 1;
/** add fixed_quality */
OPJ_UINT32 m_fixed_quality : 1;
/** Enabling Tile part generation*/
OPJ_UINT32 m_tp_on : 1;
}
opj_encoding_param_t;
typedef struct opj_decoding_param
{
/** if != 0, then original dimension divided by 2^(reduce); if == 0 or not used, image is decoded to the full resolution */
OPJ_UINT32 m_reduce;
/** if != 0, then only the first "layer" layers are decoded; if == 0 or not used, all the quality layers are decoded */
OPJ_UINT32 m_layer;
}
opj_decoding_param_t;
/**
* Coding parameters
*/
typedef struct opj_cp
{
src/Source/LibOpenJPEG/j2k.h view on Meta::CPAN
/** locate in which part of the codestream the decoder is (main header, tile header, end) */
OPJ_UINT32 m_state;
/**
* store decoding parameters common to all tiles (information like COD, COC in main header)
*/
opj_tcp_t *m_default_tcp;
OPJ_BYTE *m_header_data;
OPJ_UINT32 m_header_data_size;
/** to tell the tile part length */
OPJ_UINT32 m_sot_length;
/** Only tiles index in the correct range will be decoded.*/
OPJ_UINT32 m_start_tile_x;
OPJ_UINT32 m_start_tile_y;
OPJ_UINT32 m_end_tile_x;
OPJ_UINT32 m_end_tile_y;
/**
* Decoded area set by the user
*/
OPJ_UINT32 m_DA_x0;
OPJ_UINT32 m_DA_y0;
OPJ_UINT32 m_DA_x1;
src/Source/LibOpenJPEG/j2k.h view on Meta::CPAN
OPJ_INT32 m_tile_ind_to_dec;
/** Position of the last SOT marker read */
OPJ_OFF_T m_last_sot_read_pos;
/**
* Indicate that the current tile-part is assume as the last tile part of the codestream.
* It is useful in the case of PSot is equal to zero. The sot length will be compute in the
* SOD reader function. FIXME NOT USED for the moment
*/
OPJ_BOOL m_last_tile_part;
/** to tell that a tile can be decoded. */
OPJ_UINT32 m_can_decode : 1;
OPJ_UINT32 m_discard_tiles : 1;
OPJ_UINT32 m_skip_data : 1;
} opj_j2k_dec_t;
typedef struct opj_j2k_enc
{
/** Tile part number, regardless of poc, for each new poc, tp is reset to 1*/
OPJ_UINT32 m_current_poc_tile_part_number; /* tp_num */
src/Source/LibOpenJPEG/j2k.h view on Meta::CPAN
} opj_j2k_enc_t;
struct opj_tcd;
/**
JPEG-2000 codestream reader/writer
*/
typedef struct opj_j2k
{
/* J2K codestream is decoded*/
OPJ_BOOL m_is_decoder;
/* FIXME DOC*/
union
{
opj_j2k_dec_t m_decoder;
opj_j2k_enc_t m_encoder;
}
m_specific_param;
/** pointer to the internal/private encoded / decoded image */
opj_image_t* m_private_image;
/* pointer to the output image (decoded)*/
opj_image_t* m_output_image;
/** Coding parameters */
opj_cp_t m_cp;
/** the list of procedures to exec **/
opj_procedure_list_t * m_procedure_list;
/** the list of validation procedures to follow to make sure the code is valid **/
opj_procedure_list_t * m_validation_list;
src/Source/LibOpenJPEG/j2k.h view on Meta::CPAN
OPJ_INT32 * p_tile_y0,
OPJ_INT32 * p_tile_x1,
OPJ_INT32 * p_tile_y1,
OPJ_UINT32 * p_nb_comps,
OPJ_BOOL * p_go_on,
opj_stream_private_t *p_stream,
opj_event_mgr_t * p_manager );
/**
* Sets the given area to be decoded. This function should be called right after opj_read_header and before any tile header reading.
*
* @param p_j2k the jpeg2000 codec.
* @param p_image FIXME DOC
* @param p_start_x the left position of the rectangle to decode (in image coordinates).
* @param p_start_y the up position of the rectangle to decode (in image coordinates).
* @param p_end_x the right position of the rectangle to decode (in image coordinates).
* @param p_end_y the bottom position of the rectangle to decode (in image coordinates).
* @param p_manager the user event manager
*
* @return true if the area could be set.
src/Source/LibOpenJPEG/j2k.h view on Meta::CPAN
opj_image_t *p_image,
opj_event_mgr_t *p_manager);
OPJ_BOOL opj_j2k_get_tile( opj_j2k_t *p_j2k,
opj_stream_private_t *p_stream,
opj_image_t* p_image,
opj_event_mgr_t * p_manager,
OPJ_UINT32 tile_index );
OPJ_BOOL opj_j2k_set_decoded_resolution_factor(opj_j2k_t *p_j2k,
OPJ_UINT32 res_factor,
opj_event_mgr_t * p_manager);
/**
* Writes a tile.
* @param p_j2k the jpeg2000 codec.
* @param p_tile_index FIXME DOC
* @param p_data FIXME DOC
* @param p_data_size FIXME DOC
src/Source/LibOpenJPEG/jp2.c view on Meta::CPAN
opj_codestream_index_t* jp2_get_cstr_index(opj_jp2_t* p_jp2)
{
return j2k_get_cstr_index(p_jp2->j2k);
}
opj_codestream_info_v2_t* jp2_get_cstr_info(opj_jp2_t* p_jp2)
{
return j2k_get_cstr_info(p_jp2->j2k);
}
OPJ_BOOL opj_jp2_set_decoded_resolution_factor(opj_jp2_t *p_jp2,
OPJ_UINT32 res_factor,
opj_event_mgr_t * p_manager)
{
return opj_j2k_set_decoded_resolution_factor(p_jp2->j2k, res_factor, p_manager);
}
/* JPIP specific */
#ifdef USE_JPIP
static OPJ_BOOL opj_jpip_write_iptr(opj_jp2_t *jp2,
opj_stream_private_t *cio,
opj_event_mgr_t * p_manager )
{
OPJ_OFF_T j2k_codestream_exit;
src/Source/LibOpenJPEG/jp2.h view on Meta::CPAN
*/
void opj_jp2_setup_decoder(opj_jp2_t *jp2, opj_dparameters_t *parameters);
/**
* Decode an image from a JPEG-2000 file stream
* @param jp2 JP2 decompressor handle
* @param p_stream FIXME DOC
* @param p_image FIXME DOC
* @param p_manager FIXME DOC
*
* @return Returns a decoded image if successful, returns NULL otherwise
*/
OPJ_BOOL opj_jp2_decode(opj_jp2_t *jp2,
opj_stream_private_t *p_stream,
opj_image_t* p_image,
opj_event_mgr_t * p_manager);
/**
* Setup the encoder parameters using the current image and using user parameters.
* Coding parameters are returned in jp2->j2k->cp.
*
src/Source/LibOpenJPEG/jp2.h view on Meta::CPAN
opj_jp2_t* opj_jp2_create (OPJ_BOOL p_is_decoder);
/**
Destroy a JP2 decompressor handle
@param jp2 JP2 decompressor handle to destroy
*/
void opj_jp2_destroy(opj_jp2_t *jp2);
/**
* Sets the given area to be decoded. This function should be called right after opj_read_header and before any tile header reading.
*
* @param p_jp2 the jpeg2000 codec.
* @param p_image FIXME DOC
* @param p_start_x the left position of the rectangle to decode (in image coordinates).
* @param p_start_y the up position of the rectangle to decode (in image coordinates).
* @param p_end_x the right position of the rectangle to decode (in image coordinates).
* @param p_end_y the bottom position of the rectangle to decode (in image coordinates).
* @param p_manager the user event manager
*
* @return true if the area could be set.
src/Source/LibOpenJPEG/jp2.h view on Meta::CPAN
OPJ_BOOL opj_jp2_get_tile( opj_jp2_t *p_jp2,
opj_stream_private_t *p_stream,
opj_image_t* p_image,
opj_event_mgr_t * p_manager,
OPJ_UINT32 tile_index );
/**
*
*/
OPJ_BOOL opj_jp2_set_decoded_resolution_factor(opj_jp2_t *p_jp2,
OPJ_UINT32 res_factor,
opj_event_mgr_t * p_manager);
/* TODO MSD: clean these 3 functions */
/**
* Dump some elements from the JP2 decompression structure .
*
*@param p_jp2 the jp2 codec.
*@param flag flag to describe what elments are dump.
src/Source/LibOpenJPEG/mqc.h view on Meta::CPAN
/**
Initialize the decoder
@param mqc MQC handle
@param bp Pointer to the start of the buffer from which the bytes will be read
@param len Length of the input buffer
*/
OPJ_BOOL opj_mqc_init_dec(opj_mqc_t *mqc, OPJ_BYTE *bp, OPJ_UINT32 len);
/**
Decode a symbol
@param mqc MQC handle
@return Returns the decoded symbol (0 or 1)
*/
OPJ_INT32 opj_mqc_decode(opj_mqc_t * const mqc);
/* ----------------------------------------------------------------------- */
/*@}*/
/*@}*/
#endif /* __MQC_H */
src/Source/LibOpenJPEG/openjpeg.c view on Meta::CPAN
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_INT32, OPJ_INT32, OPJ_INT32, OPJ_INT32,
struct opj_event_mgr *)) opj_j2k_set_decode_area;
l_codec->m_codec_data.m_decompression.opj_get_decoded_tile =
(OPJ_BOOL (*) ( void *p_codec,
opj_stream_private_t *p_cio,
opj_image_t *p_image,
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_UINT32 res_factor,
struct opj_event_mgr * p_manager)) opj_j2k_set_decoded_resolution_factor;
l_codec->m_codec = opj_j2k_create_decompress();
if (! l_codec->m_codec) {
opj_free(l_codec);
return NULL;
}
break;
src/Source/LibOpenJPEG/openjpeg.c view on Meta::CPAN
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_INT32,OPJ_INT32,OPJ_INT32,OPJ_INT32,
struct opj_event_mgr * )) opj_jp2_set_decode_area;
l_codec->m_codec_data.m_decompression.opj_get_decoded_tile =
(OPJ_BOOL (*) ( void *p_codec,
opj_stream_private_t *p_cio,
opj_image_t *p_image,
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_UINT32 res_factor,
opj_event_mgr_t * p_manager)) opj_jp2_set_decoded_resolution_factor;
l_codec->m_codec = opj_jp2_create(OPJ_TRUE);
if (! l_codec->m_codec) {
opj_free(l_codec);
return 00;
}
break;
case OPJ_CODEC_UNKNOWN:
src/Source/LibOpenJPEG/openjpeg.c view on Meta::CPAN
return l_codec->m_codec_data.m_decompression.opj_decode_tile_data( l_codec->m_codec,
p_tile_index,
p_data,
p_data_size,
l_stream,
&(l_codec->m_event_mgr) );
}
return OPJ_FALSE;
}
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)
{
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;
if (! l_codec->is_decompressor) {
return OPJ_FALSE;
}
return l_codec->m_codec_data.m_decompression.opj_get_decoded_tile( l_codec->m_codec,
l_stream,
p_image,
&(l_codec->m_event_mgr),
tile_index);
}
return OPJ_FALSE;
}
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;
if ( !l_codec ){
fprintf(stderr, "[ERROR] Input parameters of the setup_decoder function are incorrect.\n");
return OPJ_FALSE;
}
l_codec->m_codec_data.m_decompression.opj_set_decoded_resolution_factor(l_codec->m_codec,
res_factor,
&(l_codec->m_event_mgr) );
return OPJ_TRUE;
}
/* ---------------------------------------------------------------------- */
/* COMPRESSION FUNCTIONS*/
opj_codec_t* OPJ_CALLCONV opj_create_compress(OPJ_CODEC_FORMAT p_format)
{
src/Source/LibOpenJPEG/openjpeg.h view on Meta::CPAN
/**
* Decompression parameters
* */
typedef struct opj_dparameters {
/**
Set the number of highest resolution levels to be discarded.
The image resolution is effectively divided by 2 to the power of the number of discarded levels.
The reduce factor is limited by the smallest total number of decomposition levels among tiles.
if != 0, then original dimension divided by 2^(reduce);
if == 0 or not used, image is decoded to the full resolution
*/
OPJ_UINT32 cp_reduce;
/**
Set the maximum number of quality layers to decode.
If there are less quality layers than the specified number, all the quality layers are decoded.
if != 0, then only the first "layer" layers are decoded;
if == 0 or not used, all the quality layers are decoded
*/
OPJ_UINT32 cp_layer;
/**@name command line decoder parameters (not used inside the library) */
/*@{*/
/** input file name */
char infile[OPJ_PATH_LEN];
/** output file name */
char outfile[OPJ_PATH_LEN];
/** input file format 0: J2K, 1: JP2, 2: JPT */
src/Source/LibOpenJPEG/openjpeg.h view on Meta::CPAN
OPJ_UINT32 DA_x0;
/** Decoding area right boundary */
OPJ_UINT32 DA_x1;
/** Decoding area up boundary */
OPJ_UINT32 DA_y0;
/** Decoding area bottom boundary */
OPJ_UINT32 DA_y1;
/** Verbose mode */
OPJ_BOOL m_verbose;
/** tile number ot the decoded tile*/
OPJ_UINT32 tile_index;
/** Nb of tile to decode */
OPJ_UINT32 nb_tile_to_decode;
/*@}*/
/* UniPG>> */ /* NOT YET USED IN THE V2 VERSION OF OPENJPEG */
/**@name JPWL decoding parameters */
/*@{*/
/** activates the JPWL correction capabilities */
src/Source/LibOpenJPEG/openjpeg.h view on Meta::CPAN
/** x component offset compared to the whole image */
OPJ_UINT32 x0;
/** y component offset compared to the whole image */
OPJ_UINT32 y0;
/** precision */
OPJ_UINT32 prec;
/** image depth in bits */
OPJ_UINT32 bpp;
/** signed (1) / unsigned (0) */
OPJ_UINT32 sgnd;
/** number of decoded resolution */
OPJ_UINT32 resno_decoded;
/** number of division by 2 of the out image compared to the original size of image */
OPJ_UINT32 factor;
/** image component data */
OPJ_INT32 *data;
/** alpha channel */
OPJ_UINT16 alpha;
} opj_image_comp_t;
/**
* Defines image data and characteristics
src/Source/LibOpenJPEG/openjpeg.h view on Meta::CPAN
* @param p_codec the jpeg2000 codec to read.
* @param p_image the image structure initialized with the characteristics of encoded image.
*
* @return true if the main header of the codestream and the JP2 header is correctly read.
*/
OPJ_API OPJ_BOOL OPJ_CALLCONV opj_read_header ( opj_stream_t *p_stream,
opj_codec_t *p_codec,
opj_image_t **p_image);
/**
* Sets the given area to be decoded. This function should be called right after opj_read_header and before any tile header reading.
*
* @param p_codec the jpeg2000 codec.
* @param p_image the decoded image previously setted by opj_read_header
* @param p_start_x the left position of the rectangle to decode (in image coordinates).
* @param p_end_x the right position of the rectangle to decode (in image coordinates).
* @param p_start_y the up position of the rectangle to decode (in image coordinates).
* @param p_end_y the bottom position of the rectangle to decode (in image coordinates).
*
* @return true if the area could be set.
*/
OPJ_API OPJ_BOOL OPJ_CALLCONV opj_set_decode_area( opj_codec_t *p_codec,
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 );
/**
* Decode an image from a JPEG-2000 codestream
*
* @param p_decompressor decompressor handle
* @param p_stream Input buffer stream
* @param p_image the decoded image
* @return true if success, otherwise false
* */
OPJ_API OPJ_BOOL OPJ_CALLCONV opj_decode( opj_codec_t *p_decompressor,
opj_stream_t *p_stream,
opj_image_t *p_image);
/**
* Get the decoded tile from the codec
*
* @param p_codec the jpeg2000 codec.
* @param p_stream input streamm
* @param p_image output image
* @param tile_index index of the tile which will be decode
*
* @return true if success, otherwise false
*/
OPJ_API 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);
/**
* Set the resolution factor of the decoded image
* @param p_codec the jpeg2000 codec.
* @param res_factor resolution factor to set
*
* @return true if success, otherwise false
*/
OPJ_API OPJ_BOOL OPJ_CALLCONV opj_set_decoded_resolution_factor(opj_codec_t *p_codec, OPJ_UINT32 res_factor);
/**
* Writes a tile with the given data.
*
* @param p_codec the jpeg2000 codec.
* @param p_tile_index the index of the tile to write. At the moment, the tiles must be written from 0 to n-1 in sequence.
* @param p_data pointer to the data to write. Data is arranged in sequence, data_comp0, then data_comp1, then ... NO INTERLEAVING should be set.
* @param p_data_size this value os used to make sure the data being written is correct. The size must be equal to the sum for each component of
* tile_width * tile_height * component_size. component_size can be 1,2 or 4 bytes, depending on the precision of the given component.
* @param p_stream the stream to write data to.
*
* @return true if the data could be written.
*/
OPJ_API OPJ_BOOL OPJ_CALLCONV opj_write_tile ( opj_codec_t *p_codec,
OPJ_UINT32 p_tile_index,
OPJ_BYTE * p_data,
OPJ_UINT32 p_data_size,
opj_stream_t *p_stream );
/**
* Reads a tile header. This function is compulsory and allows one to know the size of the tile thta will be decoded.
* The user may need to refer to the image got by opj_read_header to understand the size being taken by the tile.
*
* @param p_codec the jpeg2000 codec.
* @param p_tile_index pointer to a value that will hold the index of the tile being decoded, in case of success.
* @param p_data_size pointer to a value that will hold the maximum size of the decoded data, in case of success. In case
* of truncated codestreams, the actual number of bytes decoded may be lower. The computation of the size is the same
* as depicted in opj_write_tile.
* @param p_tile_x0 pointer to a value that will hold the x0 pos of the tile (in the image).
* @param p_tile_y0 pointer to a value that will hold the y0 pos of the tile (in the image).
* @param p_tile_x1 pointer to a value that will hold the x1 pos of the tile (in the image).
* @param p_tile_y1 pointer to a value that will hold the y1 pos of the tile (in the image).
* @param p_nb_comps pointer to a value that will hold the number of components in the tile.
* @param p_should_go_on pointer to a boolean that will hold the fact that the decoding should go on. In case the
* codestream is over at the time of the call, the value will be set to false. The user should then stop
* the decoding.
* @param p_stream the stream to decode.
* @return true if the tile header could be decoded. In case the decoding should end, the returned value is still true.
* returning false may be the result of a shortage of memory or an internal error.
*/
OPJ_API 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 );
/**
* Reads a tile data. This function is compulsory and allows one to decode tile data. opj_read_tile_header should be called before.
* The user may need to refer to the image got by opj_read_header to understand the size being taken by the tile.
*
* @param p_codec the jpeg2000 codec.
* @param p_tile_index the index of the tile being decoded, this should be the value set by opj_read_tile_header.
* @param p_data pointer to a memory block that will hold the decoded data.
* @param p_data_size size of p_data. p_data_size should be bigger or equal to the value set by opj_read_tile_header.
* @param p_stream the stream to decode.
*
* @return true if the data could be decoded.
*/
OPJ_API OPJ_BOOL OPJ_CALLCONV opj_decode_tile_data( opj_codec_t *p_codec,
OPJ_UINT32 p_tile_index,
OPJ_BYTE * p_data,
OPJ_UINT32 p_data_size,
opj_stream_t *p_stream );
/* COMPRESSION FUNCTIONS*/
/**
src/Source/LibOpenJPEG/opj_codec.h view on Meta::CPAN
/** Set decode area function handler */
OPJ_BOOL (*opj_set_decode_area) ( void * p_codec,
opj_image_t * p_image,
OPJ_INT32 p_start_x,
OPJ_INT32 p_end_x,
OPJ_INT32 p_start_y,
OPJ_INT32 p_end_y,
struct opj_event_mgr * p_manager);
/** Get tile function */
OPJ_BOOL (*opj_get_decoded_tile) ( void *p_codec,
opj_stream_private_t * p_cio,
opj_image_t *p_image,
struct opj_event_mgr * p_manager,
OPJ_UINT32 tile_index);
/** Set the decoded resolution factor */
OPJ_BOOL (*opj_set_decoded_resolution_factor) ( void * p_codec,
OPJ_UINT32 res_factor,
opj_event_mgr_t * p_manager);
} m_decompression;
/**
* Compression handler. FIXME DOC
*/
struct opj_compression
{
OPJ_BOOL (* opj_start_compress) ( void *p_codec,
src/Source/LibOpenJPEG/raw.h view on Meta::CPAN
with the corresponding mode switch.
*/
/** @defgroup RAW RAW - Implementation of operations for raw encoding */
/*@{*/
/**
RAW encoding operations
*/
typedef struct opj_raw {
/** temporary buffer where bits are coded or decoded */
OPJ_BYTE c;
/** number of bits already read or free to write */
OPJ_UINT32 ct;
/** maximum length to decode */
OPJ_UINT32 lenmax;
/** length decoded */
OPJ_UINT32 len;
/** pointer to the current position in the buffer */
OPJ_BYTE *bp;
/** pointer to the start of the buffer */
OPJ_BYTE *start;
/** pointer to the end of the buffer */
OPJ_BYTE *end;
} opj_raw_t;
/** @name Exported functions */
src/Source/LibOpenJPEG/raw.h view on Meta::CPAN
/**
Initialize the decoder
@param raw RAW handle
@param bp Pointer to the start of the buffer from which the bytes will be read
@param len Length of the input buffer
*/
void opj_raw_init_dec(opj_raw_t *raw, OPJ_BYTE *bp, OPJ_UINT32 len);
/**
Decode a symbol using raw-decoder. Cfr p.506 TAUBMAN
@param raw RAW handle
@return Returns the decoded symbol (0 or 1)
*/
OPJ_UINT32 opj_raw_decode(opj_raw_t *raw);
/* ----------------------------------------------------------------------- */
/*@}*/
/*@}*/
#endif /* __RAW_H */
src/Source/LibOpenJPEG/t2.c view on Meta::CPAN
}
l_current_pi = l_pi;
for (pino = 0; pino <= l_tcp->numpocs; ++pino) {
/* if the resolution needed is too low, one dim of the tilec could be equal to zero
* and no packets are used to decode this resolution and
* l_current_pi->resno is always >= p_tile->comps[l_current_pi->compno].minimum_num_resolutions
* and no l_img_comp->resno_decoded are computed
*/
OPJ_BOOL* first_pass_failed = (OPJ_BOOL*)opj_malloc(l_image->numcomps * sizeof(OPJ_BOOL));
if (!first_pass_failed)
{
opj_pi_destroy(l_pi,l_nb_pocs);
return OPJ_FALSE;
}
memset(first_pass_failed, OPJ_TRUE, l_image->numcomps * sizeof(OPJ_BOOL));
while (opj_pi_next(l_current_pi)) {
src/Source/LibOpenJPEG/t2.c view on Meta::CPAN
first_pass_failed[l_current_pi->compno] = OPJ_FALSE;
if (! opj_t2_decode_packet(p_t2,p_tile,l_tcp,l_current_pi,l_current_data,&l_nb_bytes_read,p_max_len,l_pack_info)) {
opj_pi_destroy(l_pi,l_nb_pocs);
opj_free(first_pass_failed);
return OPJ_FALSE;
}
l_img_comp = &(l_image->comps[l_current_pi->compno]);
l_img_comp->resno_decoded = opj_uint_max(l_current_pi->resno, l_img_comp->resno_decoded);
}
else {
l_nb_bytes_read = 0;
if (! opj_t2_skip_packet(p_t2,p_tile,l_tcp,l_current_pi,l_current_data,&l_nb_bytes_read,p_max_len,l_pack_info)) {
opj_pi_destroy(l_pi,l_nb_pocs);
opj_free(first_pass_failed);
return OPJ_FALSE;
}
}
if (first_pass_failed[l_current_pi->compno]) {
l_img_comp = &(l_image->comps[l_current_pi->compno]);
if (l_img_comp->resno_decoded == 0)
l_img_comp->resno_decoded = p_tile->comps[l_current_pi->compno].minimum_num_resolutions - 1;
}
l_current_data += l_nb_bytes_read;
p_max_len -= l_nb_bytes_read;
/* INDEX >> */
#ifdef TODO_MSD
if(p_cstr_info) {
opj_tile_info_v2_t *info_TL = &p_cstr_info->tile[p_tile_no];
opj_packet_info_t *info_PK = &info_TL->packet[p_cstr_info->packno];
src/Source/LibOpenJPEG/tcd.c view on Meta::CPAN
p_code_block->m_current_max_segs = OPJ_J2K_DEFAULT_NB_SEGS;
/*fprintf(stderr, "m_current_max_segs of code_block->data = %d\n", p_code_block->m_current_max_segs);*/
}
/* TODO */
/*p_code_block->numsegs = 0; */
return OPJ_TRUE;
}
OPJ_UINT32 opj_tcd_get_decoded_tile_size ( opj_tcd_t *p_tcd )
{
OPJ_UINT32 i;
OPJ_UINT32 l_data_size = 0;
opj_image_comp_t * l_img_comp = 00;
opj_tcd_tilecomp_t * l_tile_comp = 00;
opj_tcd_resolution_t * l_res = 00;
OPJ_UINT32 l_size_comp, l_remaining;
l_tile_comp = p_tcd->tcd_image->tiles->comps;
l_img_comp = p_tcd->image->comps;
src/Source/LibOpenJPEG/tcd.c view on Meta::CPAN
OPJ_UINT32 p_dest_length
)
{
OPJ_UINT32 i,j,k,l_data_size = 0;
opj_image_comp_t * l_img_comp = 00;
opj_tcd_tilecomp_t * l_tilec = 00;
opj_tcd_resolution_t * l_res;
OPJ_UINT32 l_size_comp, l_remaining;
OPJ_UINT32 l_stride, l_width,l_height;
l_data_size = opj_tcd_get_decoded_tile_size(p_tcd);
if (l_data_size > p_dest_length) {
return OPJ_FALSE;
}
l_tilec = p_tcd->tcd_image->tiles->comps;
l_img_comp = p_tcd->image->comps;
for (i=0;i<p_tcd->image->numcomps;++i) {
l_size_comp = l_img_comp->prec >> 3; /*(/ 8)*/
l_remaining = l_img_comp->prec & 7; /* (%8) */
l_res = l_tilec->resolutions + l_img_comp->resno_decoded;
l_width = (OPJ_UINT32)(l_res->x1 - l_res->x0);
l_height = (OPJ_UINT32)(l_res->y1 - l_res->y0);
l_stride = (OPJ_UINT32)(l_tilec->x1 - l_tilec->x0) - l_width;
if (l_remaining) {
++l_size_comp;
}
if (l_size_comp == 3) {
l_size_comp = 4;
src/Source/LibOpenJPEG/tcd.c view on Meta::CPAN
{
OPJ_UINT32 compno;
opj_tcd_tile_t * l_tile = p_tcd->tcd_image->tiles;
opj_tcd_tilecomp_t * l_tile_comp = l_tile->comps;
opj_tccp_t * l_tccp = p_tcd->tcp->tccps;
opj_image_comp_t * l_img_comp = p_tcd->image->comps;
for (compno = 0; compno < l_tile->numcomps; compno++) {
/*
if (tcd->cp->reduce != 0) {
tcd->image->comps[compno].resno_decoded =
tile->comps[compno].numresolutions - tcd->cp->reduce - 1;
if (tcd->image->comps[compno].resno_decoded < 0)
{
return false;
}
}
numres2decode = tcd->image->comps[compno].resno_decoded + 1;
if(numres2decode > 0){
*/
if (l_tccp->qmfbid == 1) {
if (! opj_dwt_decode(l_tile_comp, l_img_comp->resno_decoded+1)) {
return OPJ_FALSE;
}
}
else {
if (! opj_dwt_decode_real(l_tile_comp, l_img_comp->resno_decoded+1)) {
return OPJ_FALSE;
}
}
++l_tile_comp;
++l_img_comp;
++l_tccp;
}
return OPJ_TRUE;
src/Source/LibOpenJPEG/tcd.c view on Meta::CPAN
OPJ_INT32 * l_current_ptr;
OPJ_INT32 l_min, l_max;
OPJ_UINT32 l_stride;
l_tile = p_tcd->tcd_image->tiles;
l_tile_comp = l_tile->comps;
l_tccp = p_tcd->tcp->tccps;
l_img_comp = p_tcd->image->comps;
for (compno = 0; compno < l_tile->numcomps; compno++) {
l_res = l_tile_comp->resolutions + l_img_comp->resno_decoded;
l_width = (OPJ_UINT32)(l_res->x1 - l_res->x0);
l_height = (OPJ_UINT32)(l_res->y1 - l_res->y0);
l_stride = (OPJ_UINT32)(l_tile_comp->x1 - l_tile_comp->x0) - l_width;
assert(l_height == 0 || l_width + l_stride <= l_tile_comp->data_size / l_height); /*MUPDF*/
if (l_img_comp->sgnd) {
l_min = -(1 << (l_img_comp->prec - 1));
l_max = (1 << (l_img_comp->prec - 1)) - 1;
}
src/Source/LibOpenJPEG/tcd.h view on Meta::CPAN
/** Current Packet iterator number */
OPJ_UINT32 cur_pino;
/** info on each image tile */
opj_tcd_image_t *tcd_image;
/** image header */
opj_image_t *image;
/** coding parameters */
opj_cp_t *cp;
/** coding/decoding parameters common to all tiles */
opj_tcp_t *tcp;
/** current encoded/decoded tile */
OPJ_UINT32 tcd_tileno;
/** tell if the tcd is a decoder. */
OPJ_UINT32 m_is_decoder : 1;
} opj_tcd_t;
/** @name Exported functions */
/*@{*/
/* ----------------------------------------------------------------------- */
/**
src/Source/LibOpenJPEG/tcd.h view on Meta::CPAN
OPJ_FLOAT64 thresh,
OPJ_UINT32 final);
OPJ_BOOL opj_tcd_rateallocate( opj_tcd_t *tcd,
OPJ_BYTE *dest,
OPJ_UINT32 * p_data_written,
OPJ_UINT32 len,
opj_codestream_info_t *cstr_info);
/**
* Gets the maximum tile size that will be taken by the tile once decoded.
*/
OPJ_UINT32 opj_tcd_get_decoded_tile_size (opj_tcd_t *p_tcd );
/**
* Encodes a tile from the raw image into the given buffer.
* @param p_tcd Tile Coder handle
* @param p_tile_no Index of the tile to encode.
* @param p_dest Destination buffer
* @param p_data_written pointer to an int that is incremented by the number of bytes really written on p_dest
* @param p_len Maximum length of the destination buffer
* @param p_cstr_info Codestream information structure
* @return true if the coding is successfull.
src/Source/LibOpenJPEG/tcd.h view on Meta::CPAN
OPJ_UINT32 * p_data_written,
OPJ_UINT32 p_len,
struct opj_codestream_info *p_cstr_info);
/**
Decode a tile from a buffer into a raw image
@param tcd TCD handle
@param src Source buffer
@param len Length of source buffer
@param tileno Number that identifies one of the tiles to be decoded
@param cstr_info FIXME DOC
*/
OPJ_BOOL opj_tcd_decode_tile( opj_tcd_t *tcd,
OPJ_BYTE *src,
OPJ_UINT32 len,
OPJ_UINT32 tileno,
opj_codestream_index_t *cstr_info);
/**
src/Source/LibPNG/libpng-manual.txt view on Meta::CPAN
transformations, for example both adding and removing the alpha channel, you
cannot predict the final result.
The color used for the transparency values should be supplied in the same
format/depth as the current image data. It is stored in the same format/depth
as the image data in a tRNS chunk, so this is what libpng expects for this data.
The color used for the background value depends on the need_expand argument as
described below.
Data will be decoded into the supplied row buffers packed into bytes
unless the library has been told to transform it into another format.
For example, 4 bit/pixel paletted or grayscale data will be returned
2 pixels/byte with the leftmost pixel in the high-order bits of the
byte, unless png_set_packing() is called. 8-bit RGB data will be stored
in RGB RGB RGB format unless png_set_filler() or png_set_add_alpha()
is called to insert filler bytes, either before or after each RGB triplet.
16-bit RGB data will be returned RRGGBB RRGGBB, with the most significant
byte of the color value first, unless png_set_scale_16() is called to
transform it to regular RGB RGB triplets, or png_set_filler() or
png_set_add alpha() is called to insert filler bytes, either before or
src/Source/LibPNG/libpng-manual.txt view on Meta::CPAN
png_set_check_for_invalid_index(png_ptr, allowed);
allowed - one of
0: disable benign error (accept the
invalid data without warning).
1: enable benign error (treat the
invalid data as an error or a
warning).
If the error is ignored, or if png_benign_error() treats it as a warning,
any invalid pixels are decoded as opaque black by the decoder and written
as-is by the encoder.
Retrieving the maximum palette index found was added at libpng-1.5.15.
This statement must appear after png_read_png() or png_read_image() while
reading, and after png_write_png() or png_write_image() while writing.
int max_palette = png_get_palette_max(png_ptr, info_ptr);
This will return the maximum palette index found in the image, or "-1" if
the palette was not checked, or "0" if no palette was found. Note that this
src/Source/LibPNG/libpng.3 view on Meta::CPAN
transformations, for example both adding and removing the alpha channel, you
cannot predict the final result.
The color used for the transparency values should be supplied in the same
format/depth as the current image data. It is stored in the same format/depth
as the image data in a tRNS chunk, so this is what libpng expects for this data.
The color used for the background value depends on the need_expand argument as
described below.
Data will be decoded into the supplied row buffers packed into bytes
unless the library has been told to transform it into another format.
For example, 4 bit/pixel paletted or grayscale data will be returned
2 pixels/byte with the leftmost pixel in the high-order bits of the
byte, unless png_set_packing() is called. 8-bit RGB data will be stored
in RGB RGB RGB format unless png_set_filler() or png_set_add_alpha()
is called to insert filler bytes, either before or after each RGB triplet.
16-bit RGB data will be returned RRGGBB RRGGBB, with the most significant
byte of the color value first, unless png_set_scale_16() is called to
transform it to regular RGB RGB triplets, or png_set_filler() or
png_set_add alpha() is called to insert filler bytes, either before or
src/Source/LibPNG/libpng.3 view on Meta::CPAN
png_set_check_for_invalid_index(png_ptr, allowed);
allowed - one of
0: disable benign error (accept the
invalid data without warning).
1: enable benign error (treat the
invalid data as an error or a
warning).
If the error is ignored, or if png_benign_error() treats it as a warning,
any invalid pixels are decoded as opaque black by the decoder and written
as-is by the encoder.
Retrieving the maximum palette index found was added at libpng-1.5.15.
This statement must appear after png_read_png() or png_read_image() while
reading, and after png_write_png() or png_write_image() while writing.
int max_palette = png_get_palette_max(png_ptr, info_ptr);
This will return the maximum palette index found in the image, or "\-1" if
the palette was not checked, or "0" if no palette was found. Note that this
src/Source/LibPNG/pngstruct.h view on Meta::CPAN
#if defined(PNG_READ_SHIFT_SUPPORTED) || defined(PNG_WRITE_SHIFT_SUPPORTED)
png_color_8 shift; /* shift for significant bit tranformation */
#endif
#if defined(PNG_tRNS_SUPPORTED) || defined(PNG_READ_BACKGROUND_SUPPORTED) \
|| defined(PNG_READ_EXPAND_SUPPORTED) || defined(PNG_READ_BACKGROUND_SUPPORTED)
png_bytep trans_alpha; /* alpha values for paletted files */
png_color_16 trans_color; /* transparent color for non-paletted files */
#endif
png_read_status_ptr read_row_fn; /* called after each row is decoded */
png_write_status_ptr write_row_fn; /* called after each row is encoded */
#ifdef PNG_PROGRESSIVE_READ_SUPPORTED
png_progressive_info_ptr info_fn; /* called after header data fully read */
png_progressive_row_ptr row_fn; /* called after a prog. row is decoded */
png_progressive_end_ptr end_fn; /* called after image is complete */
png_bytep save_buffer_ptr; /* current location in save_buffer */
png_bytep save_buffer; /* buffer for previously read data */
png_bytep current_buffer_ptr; /* current location in current_buffer */
png_bytep current_buffer; /* buffer for recently used data */
png_uint_32 push_length; /* size of current input chunk */
png_uint_32 skip_length; /* bytes to skip in input data */
png_size_t save_buffer_size; /* amount of data now in save_buffer */
png_size_t save_buffer_max; /* total size of save_buffer */
png_size_t buffer_size; /* total amount of available input data */
src/Source/LibRawLite/Changelog.txt view on Meta::CPAN
* More metadata parsing/extraction:
- XMP packet extracted (if exists)
- DNG Color information parsed
- GPS data (partially) parsed
- EXIF/Makernotes parsed for used optics (for both RAW files and DNG converted by Adobe convertor).
* Exif/Makernotes parser callback (called for each processed tag)
* Sony ARW2.3 decoder:
- params.sony_arw2_hack removed, decoded data are always in 0...17k range (note the difference with dcraw!)
- Additional processing options for Sony lossy compression techincal analysis.
* Dcraw 9.24 imported (but some changes not approved because Libraw do it better).
* Many improvements in data decoding/processing:
- Correct decoding of black level values from metadata for many formats, LibRaw do not rely on hardcoded black levels.
* 196 camera models added to supported camera list.
Some of them are new (released since LibRaw 0.16 come out), some was supported before, but missed from the list.
Added cameras are:
src/Source/LibRawLite/dcraw/dcraw.1.html view on Meta::CPAN
<H2>GENERAL OPTIONS</H2>
<DL COMPACT>
<DT><B>-v</B>
<DD>
Print verbose messages, not just warnings and errors.
<DT><B>-c</B>
<DD>
Write decoded images or thumbnails to standard output.
<DT><B>-e</B>
<DD>
Extract the camera-generated thumbnail, not the raw image.
You'll get either a JPEG or a PPM file, depending on the camera.
<DT><B>-z</B>
<DD>
Change the access and modification times of an AVI, JPEG, TIFF or raw
file to when the photo was taken, assuming that the camera clock
src/Source/LibRawLite/internal/libraw_x3f.cpp view on Meta::CPAN
uint32_t data_size;
} x3f_image_data_t;
typedef struct camf_entry_s {
uint32_t id;
uint32_t version;
uint32_t entry_size;
uint32_t name_offset;
uint32_t value_offset;
void *entry; /* pointer into decoded data */
/* computed values */
uint8_t *name_address;
void *value_address;
} camf_entry_t;
typedef struct camf_entry_table_s {
uint32_t size;
camf_entry_t *element;
} camf_entry_table_t;
src/Source/LibRawLite/internal/libraw_x3f.cpp view on Meta::CPAN
/* The encrypted raw data */
void *data;
uint32_t data_size;
/* Help data for type 4 Huffman compression */
x3f_true_huffman_t table;
x3f_hufftree_t tree;
uint8_t *decoding_start;
/* The decrypted data */
void *decoded_data;
uint32_t decoded_data_size;
/* Pointers into the decrypted data */
camf_entry_table_t entry_table;
} x3f_camf_t;
typedef struct x3f_directory_entry_header_s {
uint32_t identifier; /* Should be ´SECp´, "SECi", ... */
uint32_t version; /* 0x00020001 is version 2.1 */
union {
x3f_property_list_t property_list;
src/Source/LibRawLite/internal/libraw_x3f.cpp view on Meta::CPAN
GET4(CAMF->tN.val3);
/* Set all not read data block pointers to NULL */
CAMF->data = NULL;
CAMF->data_size = 0;
/* Set all not allocated help pointers to NULL */
CAMF->table.element = NULL;
CAMF->table.size = 0;
CAMF->tree.nodes = NULL;
CAMF->decoded_data = NULL;
CAMF->decoded_data_size = 0;
CAMF->entry_table.element = NULL;
CAMF->entry_table.size = 0;
}
/* Reset the file pointer back to the directory */
infile->seek(save_dir_pos, SEEK_SET);
}
return x3f;
}
src/Source/LibRawLite/internal/libraw_x3f.cpp view on Meta::CPAN
FREE(ID->data);
}
if (DEH->identifier == X3F_SECc) {
x3f_camf_t *CAMF = &DEH->data_subsection.camf;
FREE(CAMF->data);
FREE(CAMF->table.element);
cleanup_huffman_tree(&CAMF->tree);
FREE(CAMF->decoded_data);
FREE(CAMF->entry_table.element);
}
}
FREE(DS->directory_entry);
FREE(x3f);
return X3F_OK;
}
src/Source/LibRawLite/internal/libraw_x3f.cpp view on Meta::CPAN
#endif
break;
}
}
static void x3f_load_camf_decode_type2(x3f_camf_t *CAMF)
{
uint32_t key = CAMF->t2.crypt_key;
int i;
CAMF->decoded_data_size = CAMF->data_size;
CAMF->decoded_data = malloc(CAMF->decoded_data_size);
for (i=0; i<CAMF->data_size; i++) {
uint8_t old, _new;
uint32_t tmp;
old = ((uint8_t *)CAMF->data)[i];
key = (key * 1597 + 51749) % 244944;
tmp = (uint32_t)(key * ((int64_t)301593171) >> 24);
_new = (uint8_t)(old ^ (uint8_t)(((((key << 8) - tmp) >> 1) + tmp) >> 17));
((uint8_t *)CAMF->decoded_data)[i] = _new;
}
}
/* NOTE: the unpacking in this code is in big respects identical to
true_decode_one_color(). The difference is in the output you
build. It might be possible to make some parts shared. NOTE ALSO:
This means that the meta data is obfuscated using an image
compression algorithm. */
src/Source/LibRawLite/internal/libraw_x3f.cpp view on Meta::CPAN
uint8_t *dst;
bool_t odd_dst = 0;
x3f_hufftree_t *tree = &CAMF->tree;
bit_state_t BS;
int32_t row_start_acc[2][2];
uint32_t rows = CAMF->t4.block_count;
uint32_t cols = CAMF->t4.block_size;
CAMF->decoded_data_size = (cols * rows * 3) / 2;
CAMF->decoded_data = malloc(CAMF->decoded_data_size);
dst = (uint8_t *)CAMF->decoded_data;
set_bit_state(&BS, CAMF->decoding_start);
row_start_acc[0][0] = seed;
row_start_acc[0][1] = seed;
row_start_acc[1][0] = seed;
row_start_acc[1][1] = seed;
for (row = 0; row < rows; row++) {
int col;
src/Source/LibRawLite/internal/libraw_x3f.cpp view on Meta::CPAN
#ifdef DBG_PRNT
print_huffman_tree(CAMF->tree.nodes, 0, 0);
#endif
camf_decode_type4(CAMF);
}
static void x3f_setup_camf_entries(x3f_camf_t *CAMF)
{
uint8_t *p = (uint8_t *)CAMF->decoded_data;
uint8_t *end = p + CAMF->decoded_data_size;
camf_entry_t *table = NULL;
int i;
for (i=0; p < end; i++) {
uint32_t *p4 = (uint32_t *)p;
if ((*p4 & 0xffffff) != X3F_CMb) {
/* TODO: whats this all about ? Is it OK to just terminate if
you find an invalid entry ? */
#ifdef DCRAW_VERBOSE
src/Source/LibRawLite/internal/libraw_x3f.cpp view on Meta::CPAN
case 4: /* TRUE DP1-... */
x3f_load_camf_decode_type4(CAMF);
break;
default:
#ifdef DCRAW_VERBOSE
fprintf(stderr, "Unknown CAMF type\n");
#endif
break;
}
if (CAMF->decoded_data != NULL)
x3f_setup_camf_entries(CAMF);
#ifdef DCRAW_VERBOSE
else
fprintf(stderr, "No decoded CAMF data\n");
#endif
}
/* extern */ x3f_return_t x3f_load_data(x3f_t *x3f, x3f_directory_entry_t *DE)
{
x3f_info_t *I = &x3f->info;
if (DE == NULL)
return X3F_ARGUMENT_ERROR;
src/Source/LibRawLite/libraw/libraw_types.h view on Meta::CPAN
}libraw_output_params_t;
typedef struct
{
/* really allocated bitmap */
void *raw_alloc;
/* alias to single_channel variant */
ushort *raw_image;
/* alias to 4-channel variant */
ushort (*color4_image)[4] ;
/* alias to 3-color variand decoded by RawSpeed */
ushort (*color3_image)[3];
/* Phase One black level data; */
short (*ph1_cblack)[2];
short (*ph1_rblack)[2];
/* save color and sizes here, too.... */
libraw_iparams_t iparams;
libraw_image_sizes_t sizes;
libraw_internal_output_params_t ioparams;
libraw_colordata_t color;
src/Source/LibRawLite/src/libraw_cxx.cpp view on Meta::CPAN
(this->*load_raw)();
if(load_raw == &LibRaw::unpacked_load_raw && !strcasecmp(imgdata.idata.make,"Nikon"))
C.maximum = m_save;
if(decoder_info.decoder_flags & LIBRAW_DECODER_OWNALLOC)
{
// x3f foveon decoder only: do nothing
}
else if (!(imgdata.idata.filters || P1.colors == 1))
{
// successfully decoded legacy image, attach image to raw_alloc
imgdata.rawdata.raw_alloc = imgdata.image;
imgdata.image = 0;
// Restore saved values. Note: Foveon have masked frame
// Other 4-color legacy data: no borders
S.raw_width = S.width;
S.left_margin = 0;
S.raw_height = S.height;
S.top_margin = 0;
}
}