Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add parsing of pxfm boxes #1176

Open
wants to merge 2 commits into
base: master
Choose a base branch
from

Conversation

DerouineauNicolas
Copy link

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.

assert(p_manager != 00);
(void)p_pxfm_header_size;

opj_read_bytes(p_pxfm_header_data, &l_value,
Copy link
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

"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
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
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
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

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
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...

@@ -143,6 +144,31 @@ typedef struct opj_jp2_comps {
OPJ_UINT32 bpcc;
} opj_jp2_comps_t;


typedef enum {
Copy link
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