Merge branch 'associated_data_support' of https://github.com/HWiman/openjpeg into associated_data_support

This commit is contained in:
hw 2018-05-28 14:09:45 +02:00
commit ec4aec11e2
4 changed files with 53 additions and 46 deletions

View File

@ -2676,7 +2676,8 @@ static OPJ_BOOL opj_jp2_read_asoc( opj_jp2_t *jp2,
assert(p_manager != 00); assert(p_manager != 00);
if (p_header_size < 8) { if (p_header_size < 8) {
opj_event_msg(p_manager, EVT_ERROR, "Cannot handle ASOC box of less than 8 bytes\n"); opj_event_msg(p_manager, EVT_ERROR,
"Cannot handle ASOC box of less than 8 bytes\n");
return OPJ_FALSE; return OPJ_FALSE;
} }
@ -2685,7 +2686,8 @@ static OPJ_BOOL opj_jp2_read_asoc( opj_jp2_t *jp2,
p_header_size -= 4; p_header_size -= 4;
if (p_header_size < asoc_size) { if (p_header_size < asoc_size) {
opj_event_msg(p_manager, EVT_ERROR, "ASOC super box is smaller than containing sub box\n"); opj_event_msg(p_manager, EVT_ERROR,
"ASOC super box is smaller than containing sub box\n");
return OPJ_FALSE; return OPJ_FALSE;
} }
@ -2696,7 +2698,8 @@ static OPJ_BOOL opj_jp2_read_asoc( opj_jp2_t *jp2,
if (label_tag != JP2_LBL) { if (label_tag != JP2_LBL) {
/* TODO: Verify that ASOC must have a following label ? */ /* TODO: Verify that ASOC must have a following label ? */
opj_event_msg(p_manager, EVT_WARNING, "ASOC data does not have a label (LBL)\n"); opj_event_msg(p_manager, EVT_WARNING,
"ASOC data does not have a label (LBL)\n");
return OPJ_TRUE; // No error if we could not parse return OPJ_TRUE; // No error if we could not parse
} }
@ -2711,7 +2714,9 @@ static OPJ_BOOL opj_jp2_read_asoc( opj_jp2_t *jp2,
} }
asoc = &(jp2->asoc[jp2->numasoc - 1]); asoc = &(jp2->asoc[jp2->numasoc - 1]);
asoc->level = jp2->numasoc-1; /* TODO: This is not correct if a parent asoc contains multiple child asocs! */
/* TODO: This is not correct if a parent asoc contains multiple child asocs! */
asoc->level = jp2->numasoc - 1;
asoc->label_length = asoc_size + 1; asoc->label_length = asoc_size + 1;
asoc->label = opj_malloc(asoc->label_length); asoc->label = opj_malloc(asoc->label_length);
memcpy(asoc->label, p_header_data, asoc_size); memcpy(asoc->label, p_header_data, asoc_size);
@ -2723,7 +2728,8 @@ static OPJ_BOOL opj_jp2_read_asoc( opj_jp2_t *jp2,
p_header_size -= asoc_size; p_header_size -= asoc_size;
if (p_header_size < 4) { if (p_header_size < 4) {
opj_event_msg(p_manager, EVT_ERROR, "Cannot handle ASOC sub box of less than 4 bytes\n"); opj_event_msg(p_manager, EVT_ERROR,
"Cannot handle ASOC sub box of less than 4 bytes\n");
return OPJ_FALSE; return OPJ_FALSE;
} }
@ -3381,7 +3387,7 @@ opj_codestream_info_v2_t* jp2_get_cstr_info(opj_jp2_t* p_jp2)
return p_info; return p_info;
} }
opj_jp2_metadata_t* jp2_get_metadata(opj_jp2_t* p_jp2) OPJ_BOOL jp2_copy_asoc_data(opj_jp2_t* p_jp2, opj_codestream_info_v2_t* p_info)
{ {
opj_jp2_metadata_t* p_metadata = opj_malloc(sizeof(opj_jp2_metadata_t)); opj_jp2_metadata_t* p_metadata = opj_malloc(sizeof(opj_jp2_metadata_t));
jp2_copy_asoc_data( p_jp2, p_metadata ); jp2_copy_asoc_data( p_jp2, p_metadata );
@ -3392,6 +3398,7 @@ OPJ_BOOL jp2_copy_asoc_data( opj_jp2_t* p_jp2, opj_jp2_metadata_t* p_jp2_metadat
{ {
OPJ_UINT32 i; OPJ_UINT32 i;
opj_jp2_asoc_t *asoc, *to_asoc; opj_jp2_asoc_t *asoc, *to_asoc;
p_jp2_metadata->nbasoc = p_jp2->numasoc; p_jp2_metadata->nbasoc = p_jp2->numasoc;
p_jp2_metadata->asoc_info = opj_malloc(p_jp2_metadata->nbasoc * sizeof(opj_jp2_asoc_t)); p_jp2_metadata->asoc_info = opj_malloc(p_jp2_metadata->nbasoc * sizeof(opj_jp2_asoc_t));
for (i=0; i<p_jp2_metadata->nbasoc; i++) { for (i=0; i<p_jp2_metadata->nbasoc; i++) {