Alien-FreeImage

 view release on metacpan or  search on metacpan

src/Source/LibOpenJPEG/j2k.c  view on Meta::CPAN

                                                if (p < parameters->res_spec) {

                                                        if (parameters->prcw_init[p] < 1) {
                                                                tccp->prcw[it_res] = 1;
                                                        } else {
                                                                tccp->prcw[it_res] = (OPJ_UINT32)opj_int_floorlog2(parameters->prcw_init[p]);
                                                        }

                                                        if (parameters->prch_init[p] < 1) {
                                                                tccp->prch[it_res] = 1;
                                                        }else {
                                                                tccp->prch[it_res] = (OPJ_UINT32)opj_int_floorlog2(parameters->prch_init[p]);
                                                        }

                                                } else {
                                                        OPJ_INT32 res_spec = parameters->res_spec;
                                                        OPJ_INT32 size_prcw = 0;
                                                        OPJ_INT32 size_prch = 0;

                                                        assert(res_spec>0); /* issue 189 */
                                                        size_prcw = parameters->prcw_init[res_spec - 1] >> (p - (res_spec - 1));
                                                        size_prch = parameters->prch_init[res_spec - 1] >> (p - (res_spec - 1));


                                                        if (size_prcw < 1) {
                                                                tccp->prcw[it_res] = 1;
                                                        } else {
                                                                tccp->prcw[it_res] = (OPJ_UINT32)opj_int_floorlog2(size_prcw);
                                                        }

                                                        if (size_prch < 1) {
                                                                tccp->prch[it_res] = 1;
                                                        } else {
                                                                tccp->prch[it_res] = (OPJ_UINT32)opj_int_floorlog2(size_prch);
                                                        }
                                                }
                                                p++;
                                                /*printf("\nsize precinct for level %d : %d,%d\n", it_res,tccp->prcw[it_res], tccp->prch[it_res]); */
                                        }       /*end for*/
                                } else {
                                        for (j = 0; j < tccp->numresolutions; j++) {
                                                tccp->prcw[j] = 15;
                                                tccp->prch[j] = 15;
                                        }
                                }

                        opj_dwt_calc_explicit_stepsizes(tccp, image->comps[i].prec);
                }
        }

        if (parameters->mct_data) {
                opj_free(parameters->mct_data);
                parameters->mct_data = 00;
        }
}

static OPJ_BOOL opj_j2k_add_mhmarker(opj_codestream_index_t *cstr_index, OPJ_UINT32 type, OPJ_OFF_T pos, OPJ_UINT32 len)
{
        assert(cstr_index != 00);

        /* expand the list? */
        if ((cstr_index->marknum + 1) > cstr_index->maxmarknum) {
                opj_marker_info_t *new_marker;
                cstr_index->maxmarknum = (OPJ_UINT32)(100 + (OPJ_FLOAT32) cstr_index->maxmarknum);
                new_marker = (opj_marker_info_t *) opj_realloc(cstr_index->marker, cstr_index->maxmarknum *sizeof(opj_marker_info_t));
                if (! new_marker) {
                        opj_free(cstr_index->marker);
                        cstr_index->marker = NULL;
                        cstr_index->maxmarknum = 0;
                        cstr_index->marknum = 0;
                        /* opj_event_msg(p_manager, EVT_ERROR, "Not enough memory to add mh marker\n"); */
                        return OPJ_FALSE;
                }
                cstr_index->marker = new_marker;
        }

        /* add the marker */
        cstr_index->marker[cstr_index->marknum].type = (OPJ_UINT16)type;
        cstr_index->marker[cstr_index->marknum].pos = (OPJ_INT32)pos;
        cstr_index->marker[cstr_index->marknum].len = (OPJ_INT32)len;
        cstr_index->marknum++;
        return OPJ_TRUE;
}

static OPJ_BOOL opj_j2k_add_tlmarker(OPJ_UINT32 tileno, opj_codestream_index_t *cstr_index, OPJ_UINT32 type, OPJ_OFF_T pos, OPJ_UINT32 len)
{
        assert(cstr_index != 00);
        assert(cstr_index->tile_index != 00);

        /* expand the list? */
        if ((cstr_index->tile_index[tileno].marknum + 1) > cstr_index->tile_index[tileno].maxmarknum) {
                opj_marker_info_t *new_marker;
                cstr_index->tile_index[tileno].maxmarknum = (OPJ_UINT32)(100 + (OPJ_FLOAT32) cstr_index->tile_index[tileno].maxmarknum);
                new_marker = (opj_marker_info_t *) opj_realloc(
                                cstr_index->tile_index[tileno].marker,
                                cstr_index->tile_index[tileno].maxmarknum *sizeof(opj_marker_info_t));
                if (! new_marker) {
                        opj_free(cstr_index->tile_index[tileno].marker);
                        cstr_index->tile_index[tileno].marker = NULL;
                        cstr_index->tile_index[tileno].maxmarknum = 0;
                        cstr_index->tile_index[tileno].marknum = 0;
                        /* opj_event_msg(p_manager, EVT_ERROR, "Not enough memory to add tl marker\n"); */
                        return OPJ_FALSE;
                }
                cstr_index->tile_index[tileno].marker = new_marker;
        }

        /* add the marker */
        cstr_index->tile_index[tileno].marker[cstr_index->tile_index[tileno].marknum].type = (OPJ_UINT16)type;
        cstr_index->tile_index[tileno].marker[cstr_index->tile_index[tileno].marknum].pos = (OPJ_INT32)pos;
        cstr_index->tile_index[tileno].marker[cstr_index->tile_index[tileno].marknum].len = (OPJ_INT32)len;
        cstr_index->tile_index[tileno].marknum++;

        if (type == J2K_MS_SOT) {
                OPJ_UINT32 l_current_tile_part = cstr_index->tile_index[tileno].current_tpsno;

                if (cstr_index->tile_index[tileno].tp_index)
                        cstr_index->tile_index[tileno].tp_index[l_current_tile_part].start_pos = pos;

        }
        return OPJ_TRUE;
}

/*
 * -----------------------------------------------------------------------
 * -----------------------------------------------------------------------
 * -----------------------------------------------------------------------
 */

OPJ_BOOL opj_j2k_end_decompress(opj_j2k_t *p_j2k,
                                opj_stream_private_t *p_stream,
                                opj_event_mgr_t * p_manager
                                )
{
    (void)p_j2k;
    (void)p_stream;
    (void)p_manager;
    return OPJ_TRUE;
}

OPJ_BOOL opj_j2k_read_header(   opj_stream_private_t *p_stream,
                                                            opj_j2k_t* p_j2k,
                                                            opj_image_t** p_image,
                                                            opj_event_mgr_t* p_manager )
{
        /* preconditions */
        assert(p_j2k != 00);
        assert(p_stream != 00);
        assert(p_manager != 00);



( run in 0.668 second using v1.01-cache-2.11-cpan-5b529ec07f3 )