My thoughts on decompiling

July 18th, 2007

Here I want to present my thoughts on decompiler techniques I’d like to see. Maybe a lot of this is implemented somewhere but I haven’t seen working decompiler.

  • Possibility to load disassembly instead of disassembling by itself.
  • Good flow analyzer. REC, for example, produces a lot of silly gotos. Is it so hard to build directed graph for blocks, separate out conditional code and loops? IDA does so. And it’s pretty easy to recognize typical schemes like do{}while;
    if(){}else{} and detect break; in loop.
  • Watching ‘live’ registers. Each instruction may affect some registers and flags but some of them won’t be needed later (for example, sometimes substraction is used to modify some value and sometimes also result flags are checked too). And block of instructions may depend on some register values set before (if they are not modified before using). Boomerang had something like this but resulting code was too LISPy.
  • Reiterations – if decompiler finds out that function uses registers for passing parameters then code must be changed to reflect this.
  • Pattern recognition – it would be very nice if decompiler could recognize the same patterns over the code (in form: A = B+ constant; B = A | constant; ). And if it also could automatically label bitreading functions… But I fear that this is AI-complete problem.

Well, my rant ends here. Back to work.

Monkey Audio

June 10th, 2007

Thanks to Peter Lemenkov who pointed me to this Monkey’s Audio decoder implementation. It has four strong points: GPL, C, small and clean. Oh, it also takes less memory too.

The only drawback is that old APE files are not supported (but nothing can play them on PPC anyway without x86 emulator) so I’m eager see APE support in MPlayer, Xine, VLC (or maybe it’s there already?). Preferably via libavcodec 😉

Samples

April 29th, 2007

Looks like the best way to collect a lot of samples is to become a developer and maintain demuxer/decoder. You may receive a lot of samples that do not decode with it 😉

I’d like to thank three major contributors (from Dania, Netherlands and Japan) of VC-1 in HD-DVD/Blu-Ray samples. It is because of them VC-1 video playback is less buggy than it was before (I know it still is but at least it’s improving).

Why we should have another Monkey’s Audio decoder implementation

March 25th, 2007

Why should I bother about Monkey’s Audio? Because many pirates good people offer classical music in this format (FLAC is quite rare and I’ve seen WavPack only once).

What I consider wrong in Monkey’s Audio design:

  • No verson compatibility – each version alters decoding process
  • Huge blocks – some megabytes is huge indeed (WavPack – 64k, FLAC – even less), hence inaccurate seeking and big memory requirements
  • “Insane” profile – if it does not decode in realtime on my CPU that is unusable

What I consider wrong in MA implementation:

  1. There is only one implementation (with two known ports)
  2. It is not endian-safe (both generated WAV headers and < 3.92 decoding)
  3. OO in that case means “Object-Obfuscated” (i.e. too many files where you can’t easily find required code)
  4. Custom license

Maybe during GSoC somebody will write easily understandable portable decoder in Lavc that will allow playback of .APE in FFplay,MPlayer,VLC,Xine,etc. Otherwise I’ll have to do it myself.

VC-1: Some Bugs Squashed

March 25th, 2007

This and last weekend I fixed some bugs in my decoder so now watching HD-DVD/BluRay movies will be a bit more pleasant ;-). But for the whole watching and listening experience you should wait for E-AC3 decoder (maybe it will be implemented during Google Summer of Code).

As for me, my systems neither are fast enough to decode it in realtime (1.42Ghz PPC G4 and PII 266Mhz) nor can even display full picture (max. resolution is 1280×1024 but I’m fine with it). So you may conclude I’m not interested in watching HD and you will be right. But I care for decoder and will fix bugs in it as I do already.

VC-1: Complex Profile is supported a bit

February 28th, 2007

I’ve just added some support for WMV3 Complex Profile (aka old Advanced Profile).
I don’t know why most samples (users complaining about) I’ve met are anime. It’s a good chance they will work now.

And here is updated list of CP features explained:

  • RES_X8 – additional bit at the end of I-frame header pointing if this is normal I-frame or this is special coded frame (I’m sure that’s exactly WMV2/8 J-frame with different header)
  • RES_FASTTX – somehow interferes with P-frames but bitstream is not changed
  • RES_RTM – old P-frame format (header should be the same but some additions on macroblock level). This is also quite common in old WMV3 files. Not RE’d yet

VC-1: Blu-Ray is now supported too

February 10th, 2007

Now FFmpeg and MPlayer support VC-1 in MPEG2-TS streams which can be found on Blu-Ray discs.

Thanks to Martin for providing sample and Nico Sabbi for implementing handling of this in both FFmpeg and MPlayer.

HD-DVD decoding

February 7th, 2007

For those whom it may interest.
What are the things needed to play HD-DVD movies in open-source multimedia player?

  • Decrypted movie (use this tool)
  • Demuxer support
  • Video decoder
  • Audio decoder

EVO demuxer is really just slightly modified MPEG stream demuxer. FFmpeg and MPlayer fresh SVN versions support it (MPlayer was there first). I don’t know about other multimedia players but that’s quite easy to implement.

Video decoding: there are three possible choices – MPEG-2, H.264 and VC-1. First two should work fine, the last one should work but with some bugs (I will fix them eventually).

Audio decoding: is also tricky – standard AC3 audio will work, DTS is supported via libdca and E-AC3 is still to be figured out.

Conclusion – try current SVN of MPlayer and see if it works to you. And if you care about Blu-Ray support (and it does not work) – please provide a sample.

VC-1: Process continues

January 24th, 2007

See this picture?

I don’t know why it appears in quite a few VC-1 Advanced Profile official test samples (the rest I could decode are football trainings as in SP/MP samples).

Yesterday I’ve written VC-1 Elementary Stream demuxer and now have enough material to test interlaced decoding and other AP features (when I implement them).

And another task – make work VC-1 embedded in .EVO – official format of BlueRay/HD-DVD.

Plans for the Future

January 13th, 2007

Let’s see what I have done in 2006:

  1. Fraps (FPS1) version 2/4 decoder
  2. Intel Music Coder decoder (some cleaning and lavc’ization)
  3. KMVC (video codec for FMV used in Worms games) decoder
  4. Musepack SV7 demuxer and decoder
  5. Smacker demuxer and decoder implementation (no, I haven’t RE’d it)
  6. VMWare capture codec (VMnc) decoder (implementation and some RE work)
  7. Wavpack decoder
  8. ZMBV (DosBox capture codec) decoder and encoder (encoder for palettized format only)
  9. Some image formats reading support (TGA, TIFF)
  10. 16-bit grayscale support for some image formats
  11. And finally – VC-1 decoder (with some WMV3 support)

And here are my plans for this year. Warning! This is not the final list and may be changed in process.

  • Make some lossless audio decoders (MPEG-4 ALS and Monkey’s Audio)
  • Implement missing VC-1 Simple/Main profile features (there are few of them which nobody uses but who knows)
  • Implement VC-1 Advanced profile interlaced mode (looks like it will be needed in future)
  • Help with some other projects – DCA implementation and maybe even finish RE for Xan v4 (looks like Mike forgot to do this)
  • And ultimate goal – take participation in GSoC 2007 and write JPEG-2000 decoder (in very distant future – even encoder)