Reuse matching ispe box if one exists.
Reusing identical properties will help clean up the ipco box. It becomes cumbersome when there are many images like this:
I like the concept, but it seems like we should do it for more than just ispe. For example, adding pixi would also make it simpler, and hvcC would likely save significant space.
I haven't got all the way through the process, but maybe we can always make the box, and do an operator == implementation on the box class to check if its the same. The complexity would be to check equivalence, but having it in the box implementation would encapsulate it for changes (e.g. if a new version got added, we wouldn't forget to update the check over in file.cc.
If that worked out, we could change:
int index = m_ipco_box->append_child_box(ispe_clap_pixi_whatever);
to be something like:
int index = m_ipco_box->find_or_append_child_box(ispe_clap_pixi_whatever);
Thoughts?
This absolutely makes sense. I also think that there should be an operator== to do this check for all box types. Maybe the equivalence could be tested directly on the binary data. Then we have it automatically for every box and there is no need to maintain the operator== for each class.
@dukesook Looks good. Maybe you could test short_type for equivalence before writing out both boxes to increase efficiency.
Thank you. That looks good. I'll have a closer look and merge this in the coming days.
I updated the PR with the provided feedback.
The Box class now:
- Overrides the == operator
- Provides an equal() function to work with shared_ptrs
- Provides a generic find_or_append_child_box() function to prevent redundant boxes. (This works great with pixi & ispe, but the hvcC box is added first and later populated with values)
LGTM. I think it would be worth unit testing, so sent a PR for that.
Thank you. This is great to have.
I've made the operator== virtual so that we can still add more efficient equality comparisons.