Archive for the ‘CEmpeg’ Category

All codecs roads lead to FFmpeg

Saturday, February 6th, 2010

This is written mainly as a response to some flamewars.

All codecs may be divided into two categories — mature codecs and developing codecs. In the first case we have frozen bitstream format and not so many enhancements to codebase supporting that codec. In the second case we have codec that may change bitstream format and (what is quite important) encoder features.

FFmpeg itself went that way — from highly experimental H.26x encoder and decoder to rather stable set of almost all decoders available around and several encoders. Since there are some coding rules and conventions and existing framework in it, it makes it very convenient place to implement decoders — you can reuse a lot of code optimised for many platforms (so you don’t have to care about DCT speed, for example) and users don’t have to worry about adding new decoding interface and new lines in configure script, it’s all handled inside libavcodec. And “NIH syndrome” also gives a benefit here — you don’t have to worry about additional libraries (and original codec devs will have their codec specs tested as well).
You know the other advantages of this approach too.

In the same time those features make FFmpeg a bad place for having still evolving encoders for they are not likely to fit into existing framework so easy. The best this tension could be viewed in our interaction with certain encoder. They constantly modify this encoder, so existing FFmpeg options and presets are not good for them and it’s hard to tell how well it will work. Now let’s see what happens if x264 code will be merged into FFmpeg. It will put a rather harsh constraint on x264 developers because it’s hard to tell what change breaks other codecs (changes behaviour, whatever) or vice versa. The same applies to codec-specific features (like muxer using some encoder information, think H.264+MPEG-TS).

On the other hand, it is much easier to incorporate into FFmpeg an encoder not changing so much — some compromises should be made on common interface, some parts replaced with standard FFmpeg routines and voila!

I think that’s the reason we have a lot of decoders and not so many lossy encoders (especially not so many lossy encoders with good quality) in last N years. And it’s the reason why encoder should be originated as standalone projects and merged when they are stable. I’d also like to note that FFmpeg has standing issues with providing better framework for non-H.261 based codecs and descendants (where is codec-independent rate control and motion estimation?), maybe this affected Snow development as well. Anyway, let’s live and see how all these things will be resolved.

2009 — a Year of Hopes

Thursday, December 31st, 2009

Well, I think it’s time to look at FFmpeg achievements for this year.
Main achievement is without any doubt breeding Sus Scrofa Avionica — FFmpeg 0.5 release. It took only 5 or so years.

What has been added (mostly from Changelog):

  1. FunCom ISS demuxer and decoder
  2. various Electronic Arts formats support
  3. Gopher protocol
  4. MXF D-10 muxer
  5. Ogg muxer improvements
  6. VQF decoding support
  7. PCX encoder
  8. Cook multichannel support
  9. DPX decoder
  10. ALS decoder
  11. WMAPro decoder
  12. Atrac 1 decoder
  13. many other smaller additions and enhancements

What I did:

  1. out WavPack decoder now support hybrid coding as well
  2. PB-frames support for H.263 decoder, so Intel I263 files are played more or less fine
  3. some RTMP support
  4. Aura 1 and 2 decoders
  5. fixed long-standing bug in Interplay Video MVE — now it detects 16-bit variant of video (and decodes it)
  6. some improvements on SwScaler — 48-bit RGB support and rewriting our YUV to RGB conversion code, so SwScaler could be used under LGPL

But mostly this year gave us hopes for a lot of even more important things:

  1. there is hope that our AAC encoder will work
  2. there is hope that our AAC decoder will support SBR (and we can remove libfaad2 support)
  3. there is hope that RTMP input will work with all commercial servers as supposed
  4. Bink support is at least 90% complete, it’s mostly cleanup and bugfixing left to do
  5. Indeo 4 and Indeo 5 decoders. Boy, how I miss them!
  6. Apple codecs (ProRes, Intermediate codec).
  7. Sipro decoder will be hopefully committed
  8. hopefully, Windows Media codec family support will be almost full too, the only things left to RE are their speech codec, lossless audio codec, screen capture codecs and some WMV3 leftovers
  9. There is hope that some other unfinished work will be completed. For example, I have almost working LucasArts SMUSH video player based on some older work by somebody from ScummVM, MS Video 1 encoder. Other people for sure have some unfinished stuff too.
  10. I have a faint hope that Discworld 3 FMV will be playable with something opensourced. And then by FFmpeg.
  11. Finally, I hope Mike will finish his Xan WC4 decoder.

Gdium optimizations

Tuesday, November 24th, 2009

Since I’m not going to work at this soon (have more stuff to do), I publish that stuff I did. Grab
tgzipped sources here. Most of it does not give any significant speedup because of internal Loongson structure, so it’s just proof of a concept.

F2 40 01 2A (some notes on SIMD, instruction sets and everything)

Tuesday, September 15th, 2009

I’ve been following the steps of Måns and got myself Gdium too. Since it’s no fun just owning less-spread computer architecture and not writing anything on it, I’ve tried SIMDifying the easiest operations one can do on it — vector sum, vector subtraction and vector scalar product. And I have a decoder that uses those operations extensively, so why not try to benchmark it a bit?

Test sample was first 26 seconds of Monkey Audio file with insane compression since this mode uses longest filters and benefits from SIMD most (and is slow enough even for short samples ;). In all cases I’m the one who has written SIMD code, so it’s fair 🙂

PowerPC (Freescale 7447A 1.42 GHz): 25 seconds and 6 seconds
MIPS (Loongson 2F 900 MHz): 37 seconds and 7 seconds
ARM (Cortex A8 600 MHz): 138 seconds and 22 seconds
x86 (Intel Atom N270 800 MHz): 50 seconds and 9 seconds

Mind you, SIMD instructions in Loongson are custom for that CPU and modelled after MMX (64-bit registers, actually reusing FPU regs, similar names) but at least they are done in RISC fashion, i.e. you can store result in some other register.


I’ve also looked out of interest at binary representation of SIMD. On x86 the principle is to prefix SIMD instruction (usually with 0x66 “opcode for CPU with half of current bits” byte) so SSE7 instructions will look like instructions for 1-bit FPU on Intel 4004 predecessor and will take 8-16 bytes to represent.

Other architectures use simple 32-bit word for any instruction. NEON (on ARM) and AltiVec (PowerPC) use some opcodes in general instruction space, Loongson 2 SIMD are custom calls to the second co-processor.

Talking about instruction sets I cannot omit the fact that IDA 5.2 sucks at disassembling PowerPC code (not only AltiVec but some of the core instructions too) and objdump sucks at disassembling MacOSX format (it ignores internal structure and disassembles it as raw file), that looks like the reason why we don’t have Apple Intermediate Codec RE’d yet.


P.S. Jag vill gärna få AVR32, BlackFin, ColdFire och andra exotisk CPU:ar. Alpha eller Sparc är bra ochså men det är bara orealistisk, tror jag.

FFmpeg: providing better alternative since 2000

Friday, September 4th, 2009

Few days ago FFmpeg finally got WMA3 decoder. This event gives me an opportunity to look at our achievements.

  1. Popular and/or standard codecs — supported except for the newest stuff (AAC-HE[2], H.264 interlaced modes, VC-1 interlaced modes).
  2. Windows Media — WMV1-WMV3 are supported (except for beta version of WMV3 and other WMV3 spinoffs). WMA1-WMA3 is supported too. We still have WMA Lossless and WMA Voice to RE and our top men are working on it (did you remember “Raiders of the Ark” ending? Neither did I).
  3. Real Media — RV1-RV4 are supported, from the variety of audio codecs only Sipro and Real Lossless support are missing. Sipro is in the works and nobody (including RealNetworks itself) cares about RALF.
  4. Intel codecs — Indeo 1-3 is supported, patch for Indeo 4-5 is available, IMC is supported, IAC is not REd (and not in queue).
  5. RAD codecs — REd, there are still some issues with Bink to sort out before inclusion.
  6. AVI codecs — that’s a mess. There are simply too many very codecs and new ones still continue to appear. Some are supported, most are not.
  7. Lossless audio codecs — some are supported, some are not. Again, looks like everybody writes own lossless audio or video codec. I’d like to get support for TAK though.
  8. Game video codecs — we still have a lot of them to RE. Personally I want Discworld III video (BMV, but it differs from the format used in Discworld II) support. *sigh*

If you think there’s some codec we definitely should support, please tell us (preferably with specification or decoder sources 😉 If you just want to have some codec support in FFmpeg — make us interested in it, some codecs support appeared in FFmpeg after somebody had said “can play that file?”.

My proposal on roadmap for FFmpeg

Tuesday, March 17th, 2009

Here’s the thing either Compn, known for his passion to document codecs, or Mike, known for his passion to diagrams, charts and codecs, should have done loooooong time ago.

While the same information may be obtained from Multimedia Wiki, a graphical layout should be more handy for claims like “… include reverse-engineering of all Real video formats” here. I am also aware of list of supported codecs in MPlayer documentation but it’s also boring and not very useful as a reference.

Here’s how I like it — green status for supported codecs, red for unsupported. But from a glance on it you can see what’s missing and what should be added to my beloved video conversion tool.

scheme

Note: I know that we have to enhance FFmpeg in other areas than different formats support (filter system, for example). Patches welcome.

A bit of news

Tuesday, March 3rd, 2009

Looks like I’ve neglected my blog for some time. In order to improve situation a bit here are some assorted pieces of news:

  • FFmpeg release — probably we will have one Really Soon Now. Previous release was before I started developing for FFmpeg.
  • RV3/4 is improving bit by bit. For now most troubles lie in incorrect motion vector predictions for B-frames. I hope to fix it one day (or preferably that someone else will fix it but that’s even more unlikely).
  • SwScaler is slowly moving to be usable under LGPL. Probably it will be only x86 SIMD code that will be left under GPL.
  • PB-frames support was added. So the only one who cares about Intel codecs (Benjamin, son of Lars) can watch i263 with lavc decoder now.
  • I took some time to understand ELBG code in lavc and wrote simple 15bit MS Video1 encoder. Patch pending.
  • I’ve tried to RE BMV (video format employed in Discworld II and Discworld Noir). Discworld II decoder is in ScummVM sources, so I give a shot on DW Noir which is unlikely to be supported by any opensource engine. While figuring out header and container format was piece of cake, finding out audio compression scheme was easy (boy, they do like SWAR!), I have troubles determining which function is used for video decoding.

More news will follow eventually.

The end-of-year summary

Monday, December 29th, 2008

Ok, let’s see what I’ve done this year:

  • simple IMA ADPCM encoder – Apple variant
  • worked a bit on different codecs – BMP, Fraps, Monkey’s Audio, TIFF, VC-1
  • got RV40 and RV30 finally working more or less as supposed (some garbage still occurs on some B-frames, but mostly both decoders produce watchable video)

So, what are the plans for the next year:

  • Find more time for FFmpeg development
  • Take part in GSoC (it gives a good reason to work on FFmpeg and also makes a good source of T-shirts)
  • Go abroad
  • And, of course, make FFmpeg closer to the world domination

For the last step I need:

  • Add more formats support to FFmpeg (WavPack lossy, Lucas Arts games formats, Bink, etc.)
  • Convince Mike finish his Xan4 decoder
  • Convince Robert finish his AMR-NB decoder (unless somebody beats him to it) and AAC-HE decoding support (those messages about SBR not supported are really nagging me)
  • Convince Kostya finish AAC encoder (hey, that’s me!)

So, let’s see what we get in the upcoming year.

FFmpeg Hall of Shame

Wednesday, April 2nd, 2008

Following Mike’s example and with intention to spread the word, I welcome you to look at our Hall of Shame where you can find those, who use FFmpeg and probably other products but fail to comply to (L)GPL, giving no credit and/or sources.

So, if you want a bit of publicity follow their example. But don’t be surprised later.

Profiles and FFmpeg

Wednesday, March 26th, 2008

I think I ought to tell about the idea that fellow FFmpeg participant Robert Swain (I still wait for him to complete AMR-NB decoder) tries to champion. I mean encoding profiles.

The idea is quite simple – allow users use convenient presets instead of command line black magic, so simple commands like

ffmpeg -i input.vob -preset dvdrip -preset hq_mp3 output.avi
ffmpeg -i input.avi -preset flash_youtube output.flv
ffmpeg -i input.vob -preset ipod_vid output.mp4

can be used without bothering about bitrate/flags/gop size/whatever.

I also think this will be useful. It will be easier to change options meaning without making additional complications (we still get questions from users that do not know recent ffmpeg expects bitrate to be specified in bits, not in kilobits as before). Just don’t make frontend for it named ffclippy, okay?