H264 Encoder / Decoder Writing from Scratch? - h.264

I think about writing a H264 encoder / decoder from scratch to be able to integrate the tech into a composite product. The first implementation would be written in Java.
I am used to implement scientific papers and such so I should at least bring in the basic math understanding.
What would be the best start and what should I focus on. I know that basically H264 is a mix of existing techniques.
What is are the most important things to implement?
Any idea about how much hours of work the first useful version will take.
The main objective is very fast while maintaining good compression.

How many hours? Maybe 20,000. The decoder specification alone is over 750 page document. And the decoder is the easy part.

After consideration :), I now will still use my own solution based on PNG and JPEG while not using motion vectors. I simply wrote a small solution I can compress parts of the image based on those and use filters to degrade the quality by applying sorts of blur or reduce the number of colors or even resolution. Works well enough for now.
If I need better quality I start looking at VP9 in more detail.
The only draw back is no hardware encoding support which might force me / us to look into H264 again.
Currently I can deliver 60+ frames for every days situation and scale down to 15 frames per second for video content along with bad quality but it is good enough to grab a security cam screen and see if something is wrong.

Related

Is Starling worth implementing for my AS3 MMO?

For the past year I have been working on an isometric city builder. So far I have not used any framework apart from a loose PureMVC clone.
I have heard of Starling but only recently have I played with it.
From my research, the performance boost is fenomenal, but this forces me to manage my resource a lot tighter.
At the moment, I am exporting building animations one building at a time, in ~16 frames/pngs. These are cropped, resized and exported in Photoshop by a script and then imported in Flash, then exported as a swf, to be loaded / preloaded / postloaded on demand.
The frames are way too big to make a spritesheet with them, per building. I believe its called an atlas.
These pngs are then blited between lock() and unlock(). After the buildings + actors walking around are sorted, that is.
I am unsure if just using starling.Movieclip for the buildings, where instead of loading the pngs, I would build a MovieClip symbol with its frames. So bliting wouldn't even be necessary. Unless adding bliting on top of Starling would improve performance even more. That would allow fatter features such as particles effects, maybe some lighting.
Google isn't offering me a strait answer, thus I am asking here.
Google isn't offering a straight answer because there isn't such. It depends very very much on what you've done, how much knowledge you've got and what are your goals.
Using Starling gives benefits as well as drawbacks. Your idea of resources will change totally. If you really have enormous amount of assets, then putting them into GPU will be really slow process. You must start from there - learn what Starling does, how resources are managed with it and what you need to change in order to make the transition between the two.
If this is not that hard and time consuming task, you will have some performance optimization. BUT again it depends on your current code. Your current code is really important in this situation as if it's perfectly optimized your gain won't be that much (but commonly would still be).
If you need to switch between graphics regularly or you need to have dynamic assets (as images for example) you must keep in mind that uploading to GPU is the slowest part when talking about Starling and Stage3D.
So again, there is not a straight answer. You must think of GPU memory and limit, GPU upload time, as well as assets management. You also need to think of the way your code is built and if you are going to have any impact if you make the switch (if your code heavily depends on the MovieClip like structure, with all that frames and things) - it will be hard for you. One of the toughest things I fought with Stage3D was the UI implementation - there is almost only Feathers UI which will take you a few weeks to get along with.
On the other hand, Starling performs pretty well, especially on mobile devices. I was able to maintain a stable 45fps on a heavy UI app with a lot of dynamic loading content and multiple screens on an old iPhone 4S, which I find great. Latest mobile devices top at 60fps.
It's up to you to decide, but I'll advise you to have some experimental long-lasting project to test with, and then start applying this approach to your regular projects. I've done the dive to use it in a regular very tightened deadline project, and it was a nightmare. Everything worked out great, but I thought I would have a heart attack - the switch is not that easy :)
I would suggest using DMT for rasterizing your vector assets into Straling sprites at runtime, and it'll also keep your DisplayTree! meaning that you'll still have the parent/child relations that you had in your Flash Assets.
DMT will not duplicate assets, and will rasterize the vectors into texture atlases only one time (Cache is saved)
you can find it here: https://github.com/XTDStudios/DMT

Boosting Audio Above 1 on SoundChannel

I'm dealing with an audio anomalie. I have audio that is mastered quite loud, yet on some systems, it is too quiet. Boosting the audio file anymore causes clipping.
It would be fine, except for the fact that, in my project, a lot of other sounds are in use as well. Lowering the volume of everything to match this would make some stuff impossible to hear. And again, this doesn't happen on all computers, only some.
To compensate, can I boost audio in code? The SoundChannel I'm using is already at 1.0 volume (full), and I know I can't use that property to boost it further. Is there any way to raise the audio further in code?
(I'm using Flash Professional CS5.5, Adobe AIR 3, and ActionScript 3)
After some time, I've concluded that it is apparently not possible to boost sound volume above 1 (that is, to amplify) using Flash's API. While you can set SoundTransform to a number greater than 1, it will coerce to 1 nevertheless.
If anyone has information to the contrary, you are welcome to post the answer and I'll change which answer I've accepted if you solve the problem.
You are correct. Sounds cannot be played at a volume above 1 (100%). However -- You can play two identical sounds simultaneously on different channels. This would effectively give you an audio boost above 1. But depending on the nature of the sound you may get some distortions from synchronization. If you're talking about a sound-effect without a lot of discernable Attack, you may get away with it. If you're talking about speech or percussive sound, your mileage may vary.

What is preferred and less in total weight - CSS3 Gradients/Box Shadow or Sprites?

I am constructing a mobile web app with a requirement of offline use. I am beginning to worry about total weight in code/files.
What is your experience with CSS3 (gradients/box shadow) vs. sprites, is one preferred but heavier? I am going to do some benchmarking but wanted to gather some information before I began.
Thank you in advance.
CSS3 properties are almost always preferred. They don't require an extra HTTP request, and are easier to edit in your text editor, as well as play around with in Firebug/Web Inspector.
However, if you start combining many of these properties together, they can hog down a system pretty much, since they are being computed on the device. So don't overdo it - if you need real fancy stuff, you might be better off using a sprite.

2D Game Design and Optimization tips and tricks

I can see how this might not be a good enough question but I have just embarked on a journey to build the first decent Game Engine for HTML5 canvas that is cross browser and most of all fast. The only problem is I am very new to game design and don't know many tricks of the trade that will help me.
The game I am currently implementing for which the engine will be taken out of is a tile based 2D platformer with MANY tiles (around 3500). I'll start with some tips that I've thus far learnt.
Redraw Regions - only redraw areas that change
Avoid unnecessary function calls (Firefox does not like too many of them)
Use the DOM if you can
Chunk tiles together for quicker access
Other things I am looking for are things like Terrain Generation, Lighting in 2D, Maps, quick server communication. If this is too vague, I will try and close it. Just want to know game design better.
Links/resources would be good. Especially for physics or important maths.
Only draw stuff that's visible, that means only draw the tiles etc. that are currently on the screen. For tiles that's fairly easy, if you got lots of entities you may either want to use a sliding window to keep a list of screen local objects or use such a thing like a quadtree.
Since there's no easy/fast way to copy one canvas to another, redrawing regions is really complicated, since you can't keep a buffered state of (for example) the background if it hasn't changed. So keeping a list of "dirty rectangles" will be a computational overhead for sure.
The whole topic is very broad, even handling the FPS rate can be quite difficult, this question contains some good links and answers on that topic:
https://gamedev.stackexchange.com/questions/1589/fixed-time-step-vs-variable-time-step
You've also mentioned server communication, if you want to do some multiplayer you'll have to care about even more stuff, you can't trust the client, need to worry about bandwidth, synchronization issues, interpolation on the client etc.
I've done some rather simple 2D games in the past, most of them are not in JavaScript but they should give you some hints:
http://github.com/BonsaiDen/Norum
(Platformer engine demo in C, camera zones, moving platforms)
http://github.com/BonsaiDen/Tuff
(2D Platformer in Java, got never finished, powerups and some cool stuff)
http://github.com/BonsaiDen/NodeGame-Shooter
(2D multiplayer space shooter written in JS, using Node.js for the server and WebSockets for communication)
For some final words I'd say that you should start small, like for example just do a scrolling tile map first, then add a player, then rewrite the whole thing. You want write the perfect engine just from scratch it will take many iterations until you find out all the quirks and tricks.
If you want more precise answers you should open questions on the single components you run into troubles with.

Advanced chroma key code samples

I'm working on an application that needs to key out the background from an image taken by a webcam in front of a green screen. I figured this would be a very common task, but to my surprise i'm having trouble finding code samples for anything more advanced than a simple color-threshold and those do not quite cut it quality wise.
I've found a few pdf-papers, but I'm having trouble translating these rather high concepts into actual implementations, I'd much rather look at some code.
Focus here is on quality, having a second or more of processing time is not a problem.
I will be using actionscript 3 (and possibly pixel bender) to implement this, but I'll happily look at other languages aswell.
If you have any good samples doing this, the whole process or parts, please do post them!
If you have no high requirement for chromakey quality, maybe this(http://www.quasimondo.com/archives/000615.php) will be okay.
But for high quality video( i.e, 720*576 video ), it is not easy job.
I have spent a lot time to research high quality chromakey algorithm, finally I have figured out one algorithm(implemented with c/c++) for real time video,which can be used in none-linear video editing system as plugin or standalone application.
I put some demo static images to show at voicethread.com websites, everyone can comment with text, or voice there.
http://voicethread.com/share/801789/