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

RgbaInputFile: Multipart support #1194

Merged
merged 1 commit into from
Dec 2, 2021

Conversation

ignus2
Copy link
Contributor

@ignus2 ignus2 commented Oct 29, 2021

The simplest way to add multipart support to RgbaInputFile. I needed this in a project and this was the easiest solution I found.
It might be useful, please take a look and comment if this is worthwhile for integration.

@linux-foundation-easycla
Copy link

linux-foundation-easycla bot commented Oct 29, 2021

CLA Signed

The committers are authorized under a signed CLA.

_fromYca (0),
_channelNamePrefix ("")
{
_multiPartFile = new MultiPartInputFile(name, numThreads);
Copy link
Contributor

Choose a reason for hiding this comment

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

This will cause a memory leak if any of the following lines throw an exception, since the destructor won't be called to delete the _multiPartFile.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Indeed. Does the same apply to _inputFile in the other existing constructor as well? Here _inputFile is simply new'd too, that's what I used as a basis basically:

RgbaInputFile::RgbaInputFile (const char name[], int numThreads):
    _inputFile (new InputFile (name, numThreads)),
    _fromYca (0),
    _channelNamePrefix ("")
{
    RgbaChannels rgbaChannels = channels();

    if (rgbaChannels & WRITE_C)
	_fromYca = new FromYca (*_inputFile, rgbaChannels);
}

@@ -440,6 +444,7 @@ class RgbaInputFile
InputFile * _inputFile;
Copy link
Contributor

Choose a reason for hiding this comment

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

I don't think it's too much burden to switch this to an InputPart, and use the MultiPart API for all constructors.
That also means you don't need the 'friend' in the header

@@ -320,6 +320,10 @@ class RgbaInputFile
RgbaInputFile (const char name[], int numThreads = globalThreadCount());


IMF_EXPORT
RgbaInputFile (int partNumber, const char name[], int numThreads = globalThreadCount());
Copy link
Contributor

Choose a reason for hiding this comment

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

The disadvantage of this approach is that you need to know how many parts are in the file. You also cannot use this API to scan through the parts of a file without reopening the file each time with a different partNumber

A more complete API might provide a 'parts()' method to return the number of parts, and a 'setPart' method to change the part used for subsequent reads, as setLayerName() does.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Yes, this also ties into your previous comment regarding using the MultiPart API for all constructors.
I'm not sure if I'm the best person for this task, maybe this should have been a feature request (with my code shown as a proof of concept) rather than a pull request.
What do you think/propose?

Copy link
Contributor

Choose a reason for hiding this comment

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

I think it's a great addition, and I like your approach. If you'd like to go ahead and fix the DCO and CLA issues, we can merge it as is. I'm happy to make extra tweaks on top of that. Otherwise, I guess we can start again?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I'd say take the code and run. I could go about the DCO/CLA stuff but if it's OK with you just take the commit, cherry pick or copy or use a basis, as you prefer. From my perspective I proposed this because I need this in a project, and it's not convenient to maintain a fork.
Let me know what you think.

Copy link
Contributor

Choose a reason for hiding this comment

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

Technically, that's against the spirit behind the DCO/CLA. The PR is your code, so "take it and run" is really just another way of saying "commit it without a DCO or CLA," right? Somebody else re-typing it doesn't change the original authorship or ownership of the code. It's the DCO/CLA that is the formality that certifies to us that it is indeed ok with the owner of the code to incorporate it into the project under the project's license terms.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

DCO/CLA done. Now you can legally take the code and run ;)

Copy link
Contributor

Choose a reason for hiding this comment

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

Thanks!

Signed-off-by: Balazs OROSZI <orobalage@gmail.com>
@cary-ilm
Copy link
Member

Following up on this, @peterhillman and @lgritz, you indicated it's ok as is but didn't formally approve the review. You want to give it a formal approval?

@lgritz
Copy link
Contributor

lgritz commented Nov 12, 2021

I was only chiming in on whether the CLA was needed. I don't know enough about the internals of RgbaInputFile to have an opinion about the code.

@peterhillman
Copy link
Contributor

I've done a little work extending this PR further in #1201.
If #1201 is approved, we should approve #1194 then merge it first and #1201 straight afterwards.

@cary-ilm cary-ilm merged commit 4cc01e5 into AcademySoftwareFoundation:master Dec 2, 2021
cary-ilm pushed a commit to cary-ilm/openexr that referenced this pull request Jan 19, 2022
Signed-off-by: Balazs OROSZI <orobalage@gmail.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

4 participants