Apply 01-misc-fixes patch from debian libjasper-dev (1.900.1-13) package

This commit is contained in:
Andrey Kamaev
2012-08-29 01:55:20 +04:00
parent d28af08ef3
commit 4157a640ba
23 changed files with 274 additions and 122 deletions

View File

@@ -5,6 +5,11 @@
* All rights reserved.
*/
/*
* Modified by Andrey Kiselev <dron@remotesensing.org> to handle UUID
* box properly.
*/
/* __START_OF_JASPER_LICENSE__
*
* JasPer License Version 2.0
@@ -127,6 +132,9 @@ static void jp2_pclr_destroy(jp2_box_t *box);
static int jp2_pclr_getdata(jp2_box_t *box, jas_stream_t *in);
static int jp2_pclr_putdata(jp2_box_t *box, jas_stream_t *out);
static void jp2_pclr_dumpdata(jp2_box_t *box, FILE *out);
static void jp2_uuid_destroy(jp2_box_t *box);
static int jp2_uuid_getdata(jp2_box_t *box, jas_stream_t *in);
static int jp2_uuid_putdata(jp2_box_t *box, jas_stream_t *out);
/******************************************************************************\
* Local data.
@@ -164,7 +172,7 @@ jp2_boxinfo_t jp2_boxinfos[] = {
{JP2_BOX_XML, "XML", 0,
{0, 0, 0, 0, 0}},
{JP2_BOX_UUID, "UUID", 0,
{0, 0, 0, 0, 0}},
{0, jp2_uuid_destroy, jp2_uuid_getdata, jp2_uuid_putdata, 0}},
{JP2_BOX_UINF, "UINF", JP2_BOX_SUPER,
{0, 0, 0, 0, 0}},
{JP2_BOX_ULST, "ULST", 0,
@@ -372,7 +380,7 @@ static int jp2_bpcc_getdata(jp2_box_t *box, jas_stream_t *in)
jp2_bpcc_t *bpcc = &box->data.bpcc;
unsigned int i;
bpcc->numcmpts = box->datalen;
if (!(bpcc->bpcs = jas_malloc(bpcc->numcmpts * sizeof(uint_fast8_t)))) {
if (!(bpcc->bpcs = jas_alloc2(bpcc->numcmpts, sizeof(uint_fast8_t)))) {
return -1;
}
for (i = 0; i < bpcc->numcmpts; ++i) {
@@ -416,7 +424,7 @@ static int jp2_colr_getdata(jp2_box_t *box, jas_stream_t *in)
break;
case JP2_COLR_ICC:
colr->iccplen = box->datalen - 3;
if (!(colr->iccp = jas_malloc(colr->iccplen * sizeof(uint_fast8_t)))) {
if (!(colr->iccp = jas_alloc2(colr->iccplen, sizeof(uint_fast8_t)))) {
return -1;
}
if (jas_stream_read(in, colr->iccp, colr->iccplen) != colr->iccplen) {
@@ -453,7 +461,7 @@ static int jp2_cdef_getdata(jp2_box_t *box, jas_stream_t *in)
if (jp2_getuint16(in, &cdef->numchans)) {
return -1;
}
if (!(cdef->ents = jas_malloc(cdef->numchans * sizeof(jp2_cdefchan_t)))) {
if (!(cdef->ents = jas_alloc2(cdef->numchans, sizeof(jp2_cdefchan_t)))) {
return -1;
}
for (channo = 0; channo < cdef->numchans; ++channo) {
@@ -766,7 +774,7 @@ static int jp2_cmap_getdata(jp2_box_t *box, jas_stream_t *in)
unsigned int i;
cmap->numchans = (box->datalen) / 4;
if (!(cmap->ents = jas_malloc(cmap->numchans * sizeof(jp2_cmapent_t)))) {
if (!(cmap->ents = jas_alloc2(cmap->numchans, sizeof(jp2_cmapent_t)))) {
return -1;
}
for (i = 0; i < cmap->numchans; ++i) {
@@ -828,10 +836,10 @@ static int jp2_pclr_getdata(jp2_box_t *box, jas_stream_t *in)
return -1;
}
lutsize = pclr->numlutents * pclr->numchans;
if (!(pclr->lutdata = jas_malloc(lutsize * sizeof(int_fast32_t)))) {
if (!(pclr->lutdata = jas_alloc2(lutsize, sizeof(int_fast32_t)))) {
return -1;
}
if (!(pclr->bpc = jas_malloc(pclr->numchans * sizeof(uint_fast8_t)))) {
if (!(pclr->bpc = jas_alloc2(pclr->numchans, sizeof(uint_fast8_t)))) {
return -1;
}
for (i = 0; i < pclr->numchans; ++i) {
@@ -876,6 +884,56 @@ static void jp2_pclr_dumpdata(jp2_box_t *box, FILE *out)
}
}
static void jp2_uuid_destroy(jp2_box_t *box)
{
jp2_uuid_t *uuid = &box->data.uuid;
if (uuid->data)
{
jas_free(uuid->data);
uuid->data = NULL;
}
}
static int jp2_uuid_getdata(jp2_box_t *box, jas_stream_t *in)
{
jp2_uuid_t *uuid = &box->data.uuid;
int i;
for (i = 0; i < 16; i++)
{
if (jp2_getuint8(in, &uuid->uuid[i]))
return -1;
}
uuid->datalen = box->datalen - 16;
uuid->data = jas_malloc(uuid->datalen * sizeof(uint_fast8_t));
for (i = 0; i < uuid->datalen; i++)
{
if (jp2_getuint8(in, &uuid->data[i]))
return -1;
}
return 0;
}
static int jp2_uuid_putdata(jp2_box_t *box, jas_stream_t *out)
{
jp2_uuid_t *uuid = &box->data.uuid;
int i;
for (i = 0; i < 16; i++)
{
if (jp2_putuint8(out, uuid->uuid[i]))
return -1;
}
for (i = 0; i < uuid->datalen; i++)
{
if (jp2_putuint8(out, uuid->data[i]))
return -1;
}
return 0;
}
static int jp2_getint(jas_stream_t *in, int s, int n, int_fast32_t *val)
{
int c;