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 APNG Encode Support #93

Closed
wants to merge 3 commits into from
Closed

Add APNG Encode Support #93

wants to merge 3 commits into from

Conversation

rrbutani
Copy link
Contributor

@rrbutani rrbutani commented Oct 31, 2018

Missing support for a couple of features, but seems to work.

This probably isn't ready to merge as is, but I thought I'd make the PR anyways to get some feedback.

@abonander abonander mentioned this pull request Jan 11, 2019
2 tasks
@abonander
Copy link
Contributor

@rrbutani can you rebase against latest master? Looks like there's some merge conflicts.

@bvssvni @nox I've run into a use-case for this, I'd like to see some movement on it. I'll be testing this fork myself to see how it works once it's been rebased.

@bvssvni
Copy link
Contributor

bvssvni commented Jan 11, 2019

@abonander Nice if you can get a look.

@abonander
Copy link
Contributor

@rrbutani FrameControl should be on a per-frame basis since each frame can have configurable parameters. In fact, I would almost suggest an entirely different Encoder struct that's constructed directly with an AnimationControl instance.

let ret = if self.separate_default_image { // If we've already written the default image we can write frames the normal way
// fcTL + fdAT

self.write_fcTL().and(self.write_fdAT(data))
Copy link
Contributor

@abonander abonander Jan 11, 2019

Choose a reason for hiding this comment

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

This kind of chaining could lead to data corruption as the write_fdAT() operation will be executed regardless of whether or not write_fcTL() succeeds. Since some I/O errors are transient, the fdAT chunk could be written without an fcTL chunk which would confuse the decoder.

These should instead be wrapped with try!() like all the other fallible operations (although the ? operator has been stable for a long time now, try!() would be consistent with the rest of the crate).


#[allow(non_snake_case)]
fn write_fdAT(&mut self, data: &[u8]) -> Result<()> {
// println!("Writing fdAT:{:?}", self.info.frame_control.unwrap().sequence_number+1);
Copy link
Contributor

Choose a reason for hiding this comment

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

These printlns should be removed once the PR is ready to be merged.

@rrbutani
Copy link
Contributor Author

rrbutani commented Jan 11, 2019

Thanks for the feedback @abonander; I'll rebase and make the suggested changes
.

@fintelia
Copy link
Contributor

Is this ready to be merged? (Other than the couple conflicts)

@HeroicKatora
Copy link
Member

There seem to be two potentially independent changes here:

  • Interpreting DisposeOp and BlendOp and erroring accordingly during decoding.
  • Support writing animated data stream and encode fcTL block.

As far as I can see only the former is SemVer relevant while the latter can be done in a point-release after the first has landed. I'd like to release a new version of image-png and image relatively soon so it would be nice to either get this merged but only having the public representation changes ready is also fine.

It mostly works except that sequence numbers are still (somehow) wrong
The right way to do this is with a Parameter, but I'm a little pressed for time so I'll go back and do it the right way later.
@Rimpampa
Copy link
Contributor

Rimpampa commented Nov 11, 2020

I opened a pull request on the @rrbutani fork: rrbutani#1

I made it work but some features are missing, like the option to set a different framerate for each frame or dividing each frame image into more fdAT chunks (like with the StreamWriter)

I'm willing to continue contribuiting on this but I'd like to hear some opinions on how to make it better, as right now it doesn't feel right.

@HeroicKatora
Copy link
Member

@Rimpampa I think you should make your own PR so we don't need to wait on the fork's author to respond (it's been quite a while). Then also rebase those commits to resolve the merge conflict. Let me know if you'd like any help with that, I've done it once before on this one :)

@Rimpampa Rimpampa mentioned this pull request Nov 22, 2020
7 tasks
@HeroicKatora
Copy link
Member

Closed/Moved to #255

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.

None yet

6 participants