Skip to content

Add parsing of pxfm boxes#1176

Open
DerouineauNicolas wants to merge 2 commits into
uclouvain:masterfrom
DerouineauNicolas:pxfm
Open

Add parsing of pxfm boxes#1176
DerouineauNicolas wants to merge 2 commits into
uclouvain:masterfrom
DerouineauNicolas:pxfm

Conversation

@DerouineauNicolas
Copy link
Copy Markdown

This PR adds the parsing of pxfm boxes defined in 15444-2:2004/Amd.3:2015.

I'm not sure about the design of the opj_jp2_pixel_format_values_t. I have been thinking about using an Union instead of a Struct, as the standard is only defining either mantissa, exponent or number of fractionnal bits.

Comment thread src/lib/openjp2/jp2.c
assert(p_manager != 00);
(void)p_pxfm_header_size;

opj_read_bytes(p_pxfm_header_data, &l_value,
Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

there should be cautious sanitfy checks in that function that p_pxfm_header_size is large enough, otherwise fuzzy testers will trigger crashes with malformed boxes

Comment thread src/lib/openjp2/jp2.c
"Mismatch between num comps and PXFM number of channel \n");
return OPJ_FALSE;
}
jp2->pixel_format = (opj_jp2_pixel_format_t*) opj_malloc(jp2->numcomps * sizeof(
Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

in the event (likely illegal) that there are 2 PFXM boxes, this will cause a memory leak. An error should likely be emitted if pixel_format is already allocated

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

pixel_format should be tested against NULL

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

opj_calloc() should be used so that all members are 0 initialized

Comment thread src/lib/openjp2/jp2.c
jp2->pixel_format[Channel_index].pixel_format_type = ((OPJ_UINT16) l_value) &
0xF000;

if (jp2->pixel_format[Channel_index].pixel_format_type == 0 ||
Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

given the above masking, it is not possible to have pixel_format_type being 0 or 4...

Comment thread src/lib/openjp2/jp2.h
} opj_jp2_comps_t;


typedef enum {
Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

this enumeration type appears to be unused ?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants