Archive for the ‘Uncategorized’ Category

On Anime

Saturday, September 20th, 2014

I’ve finally bought a DVD with an anime I wanted to watch. And it was awesome. Here are some screenshots.

xine_snapshot-1

xine_snapshot-2

xine_snapshot-3

xine_snapshot-4

xine_snapshot-5

xine_snapshot-6

xine_snapshot-7

xine_snapshot-8

P.S. I should probably visit Småland next summer.

High Priority Libav Projects Revisited

Sunday, August 10th, 2014

More than two years ago I’ve posted what I considered should be high priority Libav projects. Let’s see what has been finished, what’s left and what should probably be added.

User tools

  • Working avserver — fixed in the clean way (by removing it completely);
  • Proper filter system. When I say “proper” I mean the one that allows dynamic reconfiguring, handles errors and works for arbitrary inputs and outputs — some claim it’s been fixed;
  • libswscale replacement. The one that doesn’t sap sanity when you look at its code. Maybe with a nicer API too. And better pixel format support.

RealMedia support

  • Improve RM demuxer or maybe rewrite it from scratch — there’s a demuxer reimplementation from scratch is in the works, hopefully it will succeed;
  • Add proper support for multirate RM streams — hopefully will be handled;
  • Add IVR format demuxer — noone cares;
  • Add ClearVideo decoder (that’s the last codec in RM that we don’t support, hopefully not for long) — noone cares and I lost interest too.

Other Intel codecs support

  • Improve Indeo4 decoder (it still has some features lacking) — B-frames support was added, transparency support is still not there;
  • Improve Intel Audio Coder decoder — fixed too.

On2 codecs support

  • On2 VP7 decoder (we still can implement it faster than certain Baidu rival releases its source code) — nothing to say except “many thanks, Peter!” and “Baidu, I’ve not expected anything else from you”(and indeed we got what we expected, i.e. total lack of support);
  • On2 VP4 decoder;
  • On2 AVC decoder (that stands for “Audio for Video Codec”) — done.

Micro$oft (screen) codecs support

  • Add M$ Screen Codec 1 decoder;
  • Add M$ Screen Codec 2 decoder;
  • Add M$ Expression Encoder Screen Codec decoder;
  • Add beta Windows Media Video 9 interlaced decoding — maybe it’s better left unfixed.
  • Fix beta Windows Media Video 9 P-frames decoding — again, it’s unlikely to ever happen because there are not so many people who can RE intended behaviour and even less people who can RE libavcodec/vc1dec.c to put the fix there.

QuickTime codecs support

  • Add Rottenfruit Intermediate Codec decoder;
  • Add any other codec decoder — noone cares about Pixlet, noone cares enough to add QDesign Music 1 etc..

Other codecs

  • Add GoToMeeting 2-4 decoder — GoToWebinary aka G2M4 is done, the rest is permanently stalled (and I’ve passed stalling duties to Diego);
  • Add more screen codec decoders — someone asked for FIC Video and got it;
  • Add more game format decoders (especially Discworld Noir BMV) — I should return to it;
  • Add more audio (especially speech) codec decoders — Opus decoder is enough.

So, if the tast was moderately interesting it was done, fringe stuff was not taken, serious stuff was not taken either (most people I know agree that swscaler should be replaced yet noone wants to work on the replacement).

And what high priority projects for Libav do I see in the future? None really. Just none.

On Pop Music

Friday, June 13th, 2014

Here’s the only pop song in the last couple of years. It has it all—catchy rhythm and meaningful words. And a bit of nostalgia too.

I hesitated for a long time if it’s worthy blogging about and finally decided it is.

A New Month, Some New Goals

Saturday, June 1st, 2013

As suggested by Anton, it’s the month of overengineered codecs.

The goals are the following (warning: they are subject to change without any notice)

  • work on REing VoxWare MetaSound (the thing aforementioned Anton should have done long time ago — it is only slightly different from stock TwinVQ decoder after all);
  • make proper ClearVideo decoder, currently it supports I-frames only in AVI and RM (samples in QuickTime are welcome BTW);
  • work on REing Discworld III video format;
  • On2 AVC decoder;
  • make Mike M. reverse engineer On2 VP4;
  • add raw mode for IMC/IAC;
  • work on Indeo 4 B-frames support (yeah, very likely);
  • push G2M4 (aka Go2WatchBoringSlideshows, do not confuse it with Go2BoringEnterpriseEvent codec) decoder.

How one marks useless activity

Wednesday, February 6th, 2013

There are many things Ukraine is infamous for, most of them are related to the state. Today I’m going to review the name for one of its main soap opera places (my frient from Kanthalland wanted posts like this).

So, “parliament”. The place where useless people gather to make useless, idiotic or outright harmful legislation (rare exceptions are not listed).

In English and some other languages it’s called by the word coming from French “parle” — “to speak”, the other nations have completely different names for it, let’s see what they are.

  • Talks ­— see above.
  • Gathering — very common too, especially under the names “assembly” or “congress”, quite often local word for “gathering together” is used as well, like “?????????”, “zgromadzenie/sejm” or “??”(the latter one is more like “state meeting” though).
  • (Daily) work — even though some argue it had nothing to do with the word “day”, in Germanic languages it became so. And besides ever-so-funny Diet of Worms(which had nothing to do with either diet or invertebrates) there are Riksdag (in Stockholm) and Bundestag (in Sumpfstadt).
  • Giving a tip — in theory if people consult with each other before passing a decision you can call them a council. In practice such legislative organ is called ????????? ????? (Supreme Council in Russian, the name of Soviet parliament) or ???????? ???? (the same in Ukrainian though Ukrainians think ???????? ????? or Supreme Betrayal is more appropriate since it serves either not national or not Ukrainian interests) or something like Bundesrat.
  • Old geezers — quite popular too, mostly in the form of “senate”.
  • A thing — an old Scandinavic word “ting” (which is still used for local government in Sweden for instance) meant “a thing” (okay, not only that but it’s funnier this way) and in some places it is still used in parliament’s name, e.g. Denmark, Norway and Isle of Man.
  • House — or chamber. Too many obvious examples.

Of course there are some names that do not fit into this category:

  • in Netherlands they still believe in class system and call it “all estates” or Staten-Generaal. The same is true for some English islands. In France they had also tried it and it ended with the traditional French outcome (revolution).
  • in Russia they call it “??????????????? ????” (from the word “??????” — to think) but as it’s common in Russia the name has nothing to do with reality.
  • in Vatican they have a comission with an extra long name.

Moral of the story: no matter how you name your legislative organ it’s still possible to laugh at it.

About some weird coding methods in various codecs

Friday, July 13th, 2012

Today I (not really) want to talk about some weird coding methods employed by two codecs.

Monstrous Go2Meeting. To my very deep surprise its compression method 2 uses ELS coder, a curious binary arithmetic coder replacement. In essence it operates on fraction of bits (called jots by its autor) and uses something like state machine for model (i.e. depending on state and decoded jot value — 0 or 1 — move to one of two possible other states and subtract some state-defined value from input value). This implementation uses 36 jots per byte, has ladder with 174 rungs and operates on 24-bit state instead of 16-bit in the paper.

From a cursory glance on TAK it seems to be more or less ordinary lossless audio codec — i.e. LPC plus residue coding. The only peculiar thing is that residue coding. While other codecs use mostly adaptive coding, this one seems to employ fixed coding parameters for segments of residues and bitstream also contain parameter set indices for all these segments.

Scheme is rather simple: read predefined number of bits, if it’s not the escape value then reinterpret code as signed. For escape value get unary code, if it’s not equal to the secondary escape value then scale that value and reinterpret as signed. Else just read some additional number of bits, scale them and reinterpret as signed. Number of bits to read and escape values make those coding parameters (about 52 total).

Also even if it might provoke small flame war, I publicly say that I’d rather not see TAK supported in opensource. We have enough lossless codecs already, especially with their own containers. And they cover all possible uses already (don’t tell me about insignificantly higher compression ratio).

A Few Words about my ProRes Encoder

Monday, March 19th, 2012

Some people wanted to have ProRes encoder in Libav so I wrote one. And from what I gather it even has one user (not me).

In case someone is interested here is the list of possible options:

  • profile — selects ProRes profile to encode (proxy, lt, standard or hq)
  • quant_mat — selects quantisation matrix from one of profiles (proxy, lt, standard or hq). If you don’t specify it, the matrix will be picked from default profile (or use auto to be really sure). There’s also default matrix which should give the highest quality (it’s default in the sense that when quantisation matrix is not provided in frame decoder defaults to this one).
  • bits_per_mb — how many bits to give for coding one macroblock, different profiles use from 200 bits per macroblock to 2400, one can set it up to 8000.
  • mbs_per_slice — how many macroblocks are there in slice, 1-8. Default value of eight should be good for almost all situations though.
  • vendor — one can put custom vendor ID into frame like apl0 to claim it was produced by Apple encoder.
  • qscale — set fixed quantiser

How to make it encode faster?

In default mode of operation encoder has to honour frame constraints (i.e. not producing frames with size bigger than defined) while still making output picture as good as possible.
If the frame contains lots of small details it’s harder to compress it and encoder spends more time in search for appropriate quantisers for each slice. Thus setting higher bits_per_mb limit will improve the speed.

Or if you don’t care about frame size constraints just set qscale parameter to something (I’d recommend 4) and see it encode MUCH faster.

Feel free to leave wishes for features in comments, hopefully I can implement it when I have time.

P.S. For proper 4444 profile support we need 10-bit YUV with alpha. When it’s in I can add that profile too.

Är du från Norrland?

Saturday, August 6th, 2011

That’s the question you may ask when you see what I’ve eaten. Since it’s August, it’s the best time to try the famous Norrlandish product (if you ever dare, most people don’t).

A Tin of You-Know-What

A Tin of You-Know-What

I would lie if I say that I’ve eaten it all, I’ve managed to eat only two or three bits (with hard bread from Wasa and local milk). That should be enough for a lifetime.

As for common beliefs: yes, it’s easy to open the tin without getting sprayed by fluid (though I wore a T-shirt with FFmpeg logotype just in case); the stench is not that vile (especially if you freeze or cool it before opening and you can bear garbage dumps in heat) though it’s definitely better to open the tin outside and away from houses and maybe catching cold; the taste is rich, salty and quite peculiar so it’s better left to the gourmets.

At least it’s an excuse to drink a bottle of Trocadero.

Some RE anecdotes

Thursday, April 1st, 2010

I think it’s a good day to tell some stories about some peculiarities in codecs that may be a bit funny.

Intel Audio Coder (and maybe IMC) unpacks bitstream into integer array. Yes, one bit into 32 bits. It makes sense for codecs operating on single bits probably but looking how it tries to reconstruct variable in a loop from that bit array is hilarious. And do you know how that codec encodes sound? It loads “iacenc.dll” or something and calls encode function from it. Was it that hard to make it totally separate encoder instead of pretending it can encode but screw it when encoder library is missing?

VoxWare series of codecs (sorry, metacodecs — MetaVoice, MetaSound) features its own codec subsystem. There is main codec library which really can’t do coding or decoding. It loads actual codecs (with “.vwp” extension) and uses its own system of calls to do the work. Entry point in those overlays is appropriately named VoodooQuery.

Now to MetaSound decoder (I call it double messy because it’s named “msms01.vwp”). First, it features quite a lot of arrays of floats. I think it has the biggest relative non-zero data segment I’ve ever seen in binaries. Also it features and additional segment with code named “CODE” and it contains single function for performing FFT. And it has functions for zeroing or copying arrays of floats written quite poorly and nowhere near as good as plain memcpy/memset.

Interplay video player uses self-modifying code for pattern output. It does so by loading two colours into registers and modifying output commands to use either one of those two registers as source. For the record, another popular method is to duplicate value 4 times in the register, apply mask to one register and inverse of that mask to another register, bitwise OR them and output.

And most mind-boggling code I’ve ever seen is Discworld III game engine (which also performs FMV decoding). While REing ADPCM variants used there is relatively easy, video decoding is maybe the most obfuscated code I’ve ever seen. Let just say that decoding function avoids using stack but does a lot of indirect calls to modify register values.

325th Anniversary

Wednesday, March 31st, 2010

Today (new style, otherwise it’s March 21st) is 325 years since The Composer was born.

While there are many composers — gifted, talented, geniuses — there was only one Composer who wrote Music. This Music deserves a capital letter because while it was originally written for certain instruments it is actually can be played on virtually everything (and it’s de facto test for new instruments). While it was a common practice for Baroque music to re-arrange music for whatever instruments were available, this Music can be translated to be played on almost any other instrument — usually exercising all possible sounds that instrument (and player) can provide.

Here is one example (violinist test is even more obvious):

Organist proficiency test

Organist proficiency test

I’m not into music (I don’t play any musical instruments nor even know the musical notation beyond “it’s notes”) but I can value music by certain parameters. Two main factors for me are complexity (here it’s explained formally) and melody. The stuff you can hear on radio here usually lacks both. Contemporary instrumental music usually lacks one of this (yes, it’s mostly either total cacophony to my ears or melodic and quite primitive). And I don’t think it’s a coincidence that I both like to program and reverse-engineer and to listen how melodies get intertwined together, how quite simple tunes form one big piece of music, how the whole theme changes both logically and unpredictably at the same time.

Without The Composer’s Music this world would be much crappier and there would be significantly less happiness. And while 2010 is Chopin Year, every March is The Composer’s month.