Poll

How much would you be willing to contribute towards a joint HLP pledge? ($2500 is the target)

$1
6 (5.6%)
$3
5 (4.7%)
$5
12 (11.2%)
$10
21 (19.6%)
$20
27 (25.2%)
$50
20 (18.7%)
$75
1 (0.9%)
$100
9 (8.4%)
$200
4 (3.7%)
More (Please Post)
2 (1.9%)

Total Members Voted: 93

Author Topic: This makes me giddy  (Read 70772 times)

0 Members and 1 Guest are viewing this topic.

Offline niffiwan

  • 211
  • Eluder Class
Another update; I've got some of the non-streaming use cases working, including support for certain visual novel scripts ;7  Still needs a few more updates, but I think we're almost there.  Testing & feedback will be much appreciated!

Executable:
http://www.mediafire.com/download/v5khf2l65kk2dsa/fs2_open_3_7_3_SSE2_apng.7z

Code:
https://github.com/niffiwan/fs2open.github.com/tree/apng

Known Issues:
Odd behaviour seems to occur after playing several campaign missions in a row
Creating a fs2_open.log | Red Alert Bug = Hex Edit | MediaVPs 2014: Bigger HUD gauges | 32bit libs for 64bit Ubuntu
----
Debian Packages (testing/unstable): Freespace2 | wxLauncher
----
m|m: I think I'm suffering from Stockholm syndrome. Bmpman is starting to make sense and it's actually written reasonably well...

 

Offline m!m

  • 211
Nice work!

I looked through the code and noticed a few minor issues (some memory leaks, nothing major). I can't comment on a branch comparison so I'll wait until you submit the PR and then comment there.

 

Offline niffiwan

  • 211
  • Eluder Class
Finally, apng support is done! (ignoring any bugs which may still be present in the code ofc :nervous:)


Builds

*** See the nightlies for current builds ***
Here are builds including FRED (because, why not now that I can compile it, hurrah for 2015 community edition :))
http://www.mediafire.com/download/dpyiizm5ncnityg/fso_apng.7z

The code is now in a PR if there's anyone else interested in looking at it:
https://github.com/scp-fs2open/fs2open.github.com/pull/537


Simple APNG creation

Here's steps on how to create simple APNGs.

1) Create your animation in your favourite animation application and save it as a PNG file stream. It'll be easiest if the frames are named in ascending order; e.g. anim_0000.png, anim_0001.png, etc (not strictly needed but much easier). Remember you have 24 bit colour & 8 bit alpha available, there's no need for any custom palette's or special transparency colours.

2) Get an apng assembler. There's a bunch available on the internet, online only versions, local installs, command line and GUI. I've personally used the apngasm command line version so that's what I'll use in my example.

Latest apngasm source (3.1.6)
Latest Windows 64bit executable (3.1.3)
For OSX they say use homebrew; I have no idea how to do this, sorry!

Note that the Japng Editor allows you to open up apngs and see exactly what each frame is doing, e.g. when the assembler has chosen to use delta frames vs complete frames, etc.

3) Use the assembler to create your apng

You need to know what frame delay you want between all frames... and that's it for a simple animation.

Here's an example using frames exported from the mediavps_2014 intelligence ANI file for "Earth" (I used aniview32 to export the frames to BMPs, then imagemagick to convert them to 24bit PNGs). The FPS for the ani is 15.

Code: [Select]
apngasm -d 67 -o 2_intel_earth.png 2_intel_earth_0*.png

-d specifies the default frame delay for each frame
-o specifies the output name, for FSO we'll use the .png extension
The last set of arguments is all the frames in animation order

4) Configure the apng within FSO

In my example, copy 2_intel_earth.png to FSO/mod/data/intelanims

And that's it!


Using APNGs in FSO

The places in FSO where I think APNGs make most sense are:

  • Command Brief Anims
  • Intel Anims (techroom)
  • Loading Screen Anim
  • HUD Anims (e.g. headz, lock, etc)
  • Mainhall animations

You CAN use apngs for any other animation if you wish, e.g. animated glows, weapon impact effects, explosions, shield anims, etc. However, EFF with DDS would generally be a better choice because they're compressed in a format your video card can use, and thus they use much less video RAM.

Having said that, in many cases the apng files on disk (only) will be smaller than other animation formats which can mean reduced modpack sizes. e.g. the 2_intel_earth.png file is 7.5MB, compared with 15MB for the mediavps_2014 ANI file. Likewise a certain EFF+PNG headani was 3.8MB as png frames, the apng was 2.1MB. Note that this reduction heavily depends on the content of the apng. From some rough tests done by Axem & myself it seems that apngs with a transparent background, and an object moving through said background will probably fair poorly. One such example was only reduced from 11MB to 9.9MB. This is because the best compression method is diff/delta frames composed over the previous frame, and it can't draw a transparent pixel over top a non-transparent one. Therefore with a transparent background the frame needs to get completely redrawn, making the filesize larger.

Lastly, FSO uses the .png extension for apngs, not .apng (see here for more info on why if you're curious)


Advanced APNG creation

There are some more advanced options for creating apngs which may be of use in certain circumstances.

1) Per Frame Delays

You can give each frame in the animation it's own delay, different to every other frame in the animation. To do this, just put the individual frame delay after the frames source image.

i.e.
Code: [Select]
apngasm -d 67 -s -o 2_intel_earth.png 2_intel_earth_renamed_0000.png 500 2_intel_earth_0*.png

This makes the 1st frame play for 500 ms, and all the other frames have a 67ms delay.

Note that the most recent versions of apngasm will do this for you if you include duplicated frames in your sequence. i.e. if you have 50 frames and two sequential frames are the same, then apngasm will create an apng with 49 frames, where one frame has double the frame delay of the rest.

2) Loading APNGs as PNGs

FSO will happily load an apng as a static image if you load it as an image rather than an animation. This is a bit hard to control for stuff internal to FSO, but you've got full control over this in LUA. Anyway, this could save you putting extra files in your mod, by default the 1st frame of the animation will be loaded as the static image. Or you can put any frame you like as the "1st frame" and tell apngasm to skip than frame when playing back as an animation.     

i.e.
Code: [Select]
apngasm -d 67 -s -o 2_intel_earth.png special_1st_frame.png 2_intel_earth_0*.png

-s is the option to skip the 1st frame
special_1st_frame.png is the 1st argument without a preceeding option and thus is the 1st frame processed by apngasm

Maybe this could be of use if you wanted to (e.g.) have a selectable pilot image that's also the 1st frame in that pilots head ani (I dunno, I'm not sure if there's any real use cases for this or not, but as long as everyone knows about the option then people could think up tricky uses for it).

3) Looping

APNG's can set the number of times that they will loop. However, FSO ignores this in favour of the code controlling how any given animation will loop (e.g. cbanims always loop, headanis never loop, etc). So don't worry about the loop value as FSO will ignore it.

So, I think that's enough words from me; please post if you have any questions, or if you have used any other apng assembers with good results.

edit: updated formatting & merged in useful info from Axem
« Last Edit: July 06, 2016, 03:33:12 am by niffiwan »
Creating a fs2_open.log | Red Alert Bug = Hex Edit | MediaVPs 2014: Bigger HUD gauges | 32bit libs for 64bit Ubuntu
----
Debian Packages (testing/unstable): Freespace2 | wxLauncher
----
m|m: I think I'm suffering from Stockholm syndrome. Bmpman is starting to make sense and it's actually written reasonably well...

 

Offline zookeeper

  • *knock knock* Who's there? Poe. Poe who?
  • 210
So, this is probably something that can be found out somewhere, but maybe good to have for reference: if I'm assembling an apng, does it matter how well-compressed the source frames are? Assuming that something like PNGGauntlet can't handle apng's (I haven't tried), does it decrease the final filesize if I crunch the frames before assembling, or does the assembler re-encode the individual frames anyway?

 

Offline Axem

  • 211
Niffiwan: I know you and some other coders were talking about the apng file extension. Do we need to use the apng file extension everywhere in FS to make them animated or just in certain parts?

zookeeper: I believe it does re-encode them to some degree, since the primary method of compression is overlapping diff frames over a source. There's compression options within apngasm that optimize the palette and compression such as zlib to push the filesize down as much as possible.

Images with a solid background I've found compress really well, around 50%. But images with a transparent background do not compress well in apng. This is because since the compression method is diff frames over a source, it can't draw a transparent pixel over top a non-transparent one, so the frame needs to get completely redrawn, making the filesize larger.

Here are some other apng tools I've been using. http://littlesvr.ca/apng/ Japng Editor allows you to open up apngs and see exactly what each frame is doing if you're curious.

 
Niffiwan: I know you and some other coders were talking about the apng file extension. Do we need to use the apng file extension everywhere in FS to make them animated or just in certain parts?
Well, from I read in the pull request discussion, you shouldn't use the .apng file extension at all (the code assumes a file extension is 3 characters apparently), so apngs should have a .png file extension.

https://github.com/scp-fs2open/fs2open.github.com/pull/537#discussion_r53765499
Quote from: niffiwan
From a reasonably trivial search through the code I have identified a number of areas where it is assumed that file extensions are 3 chars long. And to be sure you get all of them it'll probably require checking every single instance where filenames are handled :s

 

Offline chief1983

  • Still lacks a custom title
  • Moderator
  • 212
  • ⬇️⬆️⬅️⬅️🅰➡️⬇️
    • Minecraft
    • Skype
    • Steam
    • Twitter
    • Fate of the Galaxy
An OS X standalone package installer would be nice for those who don't want to mess with homebrew/fink/macports/etc.  Wonder if there's any plans for that.
Fate of the Galaxy - Now Hiring!  Apply within | Diaspora | SCP Home | Collada Importer for PCS2
Karajorma's 'How to report bugs' | Mantis
#freespace | #scp-swc | #diaspora | #SCP | #hard-light on EsperNet

"You may not sell or otherwise commercially exploit the source or things you created based on the source." -- Excerpt from FSO license, for reference

Nuclear1:  Jesus Christ zack you're a little too hamyurger for HLP right now...
iamzack:  i dont have hamynerge i just want ptatoc hips D:
redsniper:  Platonic hips?!
iamzack:  lays

 

Offline Axem

  • 211
Niffiwan: I know you and some other coders were talking about the apng file extension. Do we need to use the apng file extension everywhere in FS to make them animated or just in certain parts?
Well, from I read in the pull request discussion, you shouldn't use the .apng file extension at all (the code assumes a file extension is 3 characters apparently), so apngs should have a .png file extension.

https://github.com/scp-fs2open/fs2open.github.com/pull/537#discussion_r53765499
Quote from: niffiwan
From a reasonably trivial search through the code I have identified a number of areas where it is assumed that file extensions are 3 chars long. And to be sure you get all of them it'll probably require checking every single instance where filenames are handled :s

Ah well, last I heard there was a problem with having still images and animations share the same file extension. I guess that got changed back...
« Last Edit: February 24, 2016, 10:14:05 am by Axem »

 

Offline AdmiralRalwood

  • 211
  • The Cthulhu programmer himself!
    • Skype
    • Steam
    • Twitter
The problem was leaking cfile handles which was actually caused by an exception in the constructor leaving the file handle in use; this would've been a problem regardless of the extension, so given that it's been solved and supporting 4-character file extensions would be a lot of effort for not a lot of gain... .png it is.
Ph'nglui mglw'nafh Codethulhu GitHub wgah'nagl fhtagn.

schrödinbug (noun) - a bug that manifests itself in running software after a programmer notices that the code should never have worked in the first place.

When you gaze long into BMPMAN, BMPMAN also gazes into you.

"I am one of the best FREDders on Earth" -General Battuta

<Aesaar> literary criticism is vladimir putin

<MageKing17> "There's probably a reason the code is the way it is" is a very dangerous line of thought. :P
<MageKing17> Because the "reason" often turns out to be "nobody noticed it was wrong".
(the very next day)
<MageKing17> this ****ing code did it to me again
<MageKing17> "That doesn't really make sense to me, but I'll assume it was being done for a reason."
<MageKing17> **** ME
<MageKing17> THE REASON IS PEOPLE ARE STUPID
<MageKing17> ESPECIALLY ME

<MageKing17> God damn, I do not understand how this is breaking.
<MageKing17> Everything points to "this should work fine", and yet it's clearly not working.
<MjnMixael> 2 hours later... "God damn, how did this ever work at all?!"
(...)
<MageKing17> so
<MageKing17> more than two hours
<MageKing17> but once again we have reached the inevitable conclusion
<MageKing17> How did this code ever work in the first place!?

<@The_E> Welcome to OpenGL, where standards compliance is optional, and error reporting inconsistent

<MageKing17> It was all working perfectly until I actually tried it on an actual mission.

<IronWorks> I am useful for FSO stuff again. This is a red-letter day!
* z64555 erases "Thursday" and rewrites it in red ink

<MageKing17> TIL the entire homing code is held up by shoestrings and duct tape, basically.

 

Offline niffiwan

  • 211
  • Eluder Class
FYI, I've updated the builds linked above with a version of FRED that'll allow you select *.png files in the campaign, event & cmdbrief editors (I also added *.eff where missing, and removed *.avi where present).  No need to redownload unless you want the FRED changes, FSO is unchanged.
Creating a fs2_open.log | Red Alert Bug = Hex Edit | MediaVPs 2014: Bigger HUD gauges | 32bit libs for 64bit Ubuntu
----
Debian Packages (testing/unstable): Freespace2 | wxLauncher
----
m|m: I think I'm suffering from Stockholm syndrome. Bmpman is starting to make sense and it's actually written reasonably well...

 

Offline mjn.mixael

  • Cutscene Master
  • 212
  • Chopped liver
    • Steam
    • Twitter
wait, removed .avi?
Cutscene Upgrade Project - Mainhall Remakes - Between the Ashes
Youtube Channel - P3D Model Box
Between the Ashes is looking for committed testers, PM me for details.
Freespace Upgrade Project See what's happening.

 

Offline niffiwan

  • 211
  • Eluder Class
I didn't think that FSO supported avi's, except maybe for cutscenes (but they are only mve/ogg)? And when I mean "removed" I mean just that the FRED file select dialog boxes won't show them anymore.

Regardless, if I've made a mistake let me know and I'll add them back in.
Creating a fs2_open.log | Red Alert Bug = Hex Edit | MediaVPs 2014: Bigger HUD gauges | 32bit libs for 64bit Ubuntu
----
Debian Packages (testing/unstable): Freespace2 | wxLauncher
----
m|m: I think I'm suffering from Stockholm syndrome. Bmpman is starting to make sense and it's actually written reasonably well...

 

Offline mjn.mixael

  • Cutscene Master
  • 212
  • Chopped liver
    • Steam
    • Twitter
Derp. You did a correct thing. I was thinking .ani.
Cutscene Upgrade Project - Mainhall Remakes - Between the Ashes
Youtube Channel - P3D Model Box
Between the Ashes is looking for committed testers, PM me for details.
Freespace Upgrade Project See what's happening.

 

Offline The E

  • He's Ebeneezer Goode
  • Moderator
  • 213
  • Nothing personal, just tech support.
    • Steam
    • Twitter
I didn't think that FSO supported avi's, except maybe for cutscenes (but they are only mve/ogg)? And when I mean "removed" I mean just that the FRED file select dialog boxes won't show them anymore.

Regardless, if I've made a mistake let me know and I'll add them back in.

ISTR there being avi support at some point in FSO's history. It got removed ages ago though.
If I'm just aching this can't go on
I came from chasing dreams to feel alone
There must be changes, miss to feel strong
I really need lifе to touch me
--Evergrey, Where August Mourns

 

Offline mjn.mixael

  • Cutscene Master
  • 212
  • Chopped liver
    • Steam
    • Twitter
There was. It was way back in 2004-06 I think.
Cutscene Upgrade Project - Mainhall Remakes - Between the Ashes
Youtube Channel - P3D Model Box
Between the Ashes is looking for committed testers, PM me for details.
Freespace Upgrade Project See what's happening.

 

Offline Goober5000

  • HLP Loremaster
  • Moderator
  • 214
    • Goober5000 Productions
I think niffiwan is omitting some important clarifying information -- he means the drop-down box for command-briefing ANI files and message head ANI files.  He's not talking about cutscenes.

Way back in FS1's development, :v: supported AVI as an option for heads and cbriefs.  This capability was removed before release, but the dropdown was never updated to remove AVI.  Niffiwan simply removed the obsolete dropdown entry.

All of this is completely independent of AVI support for cutscenes, which was indeed supported in 2004-2006 or thereabouts.

(Niffiwan, please correct me if I misinterpreted what you wrote.)

 

Offline niffiwan

  • 211
  • Eluder Class
nah, you've got what I meant  :yes:

(sorry all about the confusion)
Creating a fs2_open.log | Red Alert Bug = Hex Edit | MediaVPs 2014: Bigger HUD gauges | 32bit libs for 64bit Ubuntu
----
Debian Packages (testing/unstable): Freespace2 | wxLauncher
----
m|m: I think I'm suffering from Stockholm syndrome. Bmpman is starting to make sense and it's actually written reasonably well...

 

Offline niffiwan

  • 211
  • Eluder Class
FYI; builds have been updated with some teeny tiny performance improvements, and a bugfix regarding correct interpretation of the apng format.
Creating a fs2_open.log | Red Alert Bug = Hex Edit | MediaVPs 2014: Bigger HUD gauges | 32bit libs for 64bit Ubuntu
----
Debian Packages (testing/unstable): Freespace2 | wxLauncher
----
m|m: I think I'm suffering from Stockholm syndrome. Bmpman is starting to make sense and it's actually written reasonably well...

 

Offline niffiwan

  • 211
  • Eluder Class
The APNG code has been committed to master and is available from this nightly onwards. Enjoy :)
Creating a fs2_open.log | Red Alert Bug = Hex Edit | MediaVPs 2014: Bigger HUD gauges | 32bit libs for 64bit Ubuntu
----
Debian Packages (testing/unstable): Freespace2 | wxLauncher
----
m|m: I think I'm suffering from Stockholm syndrome. Bmpman is starting to make sense and it's actually written reasonably well...

 

Offline Spoon

  • 212
  • ヾ(´︶`♡)ノ
All of this money should have gone to Niffiwan instead.
Urutorahappī!!

[02:42] <@Axem> spoon somethings wrong
[02:42] <@Axem> critically wrong
[02:42] <@Axem> im happy with these missions now
[02:44] <@Axem> well
[02:44] <@Axem> with 2 of them