Archive for the ‘Uncategorized’ Category

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.

A private history of prank that failed

Saturday, March 27th, 2010

How would you call the following situation: a man who has never travelled alone and never been abroad suddenly appears in a foreign country. He does not know local language nor customs. And all that happens on 1st of April.

Well, sounds like a prank indeed but it were the best days of my life. I don’t remember whose idea it was but I quite suddenly decided to visit Sweden (okay, blame those subtitles in Monty Python and the Holy Grail ) and first half of April was the time when I could do that.

What’s a first thing any tourist should do in Stockholm? In my case it was wandering in Sundbyberg. I did a lot of things every tourist should do — visiting a dozen of museums (first two of them were Post Museum and Royal Coin Cabinet) and no art galleries,going to Skärholmen and not visiting any big shops there, not buying any elk toys or T-shirts with silly inscriptions, going to churches to listen to organ music, being at city centre and shopping only at two places there (Teknik Magasinet and Hemköp); as an extra I’ve been to Copenhagen for a day and have not seen any mermaids or castle interiors.

Also I’ve attended FFmpeg developers conference (Swedish branch). It was very nice to see all those people in person. One of them was very kind to give me a short tour on Stockholm (Odenplan – KTH – Stureplan – Norrmalmstorg).

I’ve lost my heart at Sweden. This country style is “simple, beautiful and effective” applied everywhere. And if you heard the saying “the way to a man’s heart is through his stomach”, it took place too (a sure sign is that when other developers’ commit messages start with “10l cola: …” mine start with “10l trocadero: …” and thinking of Emmentaler as “Swiss version of Grevé”).

And I can’t fully express my gratitude to Benjamin Larsson without whom all of this could not happen.


Enough with reminiscences, I’ll try to produce some codec material to write about.

Anthems

Wednesday, December 30th, 2009

Once I wondered about different anthems. Looks like one of the things Wikipedia misses on them is classification by content.

Personally I can split them into those categories:

  1. praise of the land — many anthems tell about features of the country like mountains, rivers, lakes, green meadows, whatever.
  2. praising love to the land — a lot of anthems say something like “we love this country”
  3. praising freedom — some anthems are mostly about defending freedom or how the land is good after getting freedom
  4. praising some symbol — mostly sovereigns or flags or people
  5. religious prayers or oaths to save or protect the country

One subgroup is anthems inspired or influenced by Polish anthem. They say virtually “That is not dead which can eternal lie.
And with strange aeons even death may die.”
ahem, sorry “our land is not dead while we live”. Ukraine and Israel have such anthems.

So, here are interesting ones:

  • Polish anthem — known for its dance music
  • anthem of Andorra — not so many anthems are sung from the first person view (i.e. like the country itself tells its story)
  • anthem of Moldova praises its language

My favourite is unofficial anthem of Sweden (since there is no officially approved anthem there). The ending of verse two is rather dear to me:


Jag vet att Du är och Du blir vad Du var.
Ja, jag vill leva jag vill dö i Norden.

Translation:


I know that you are and you will be as you were,
Yes, I want to live I want to die in the North

Indeed, I live in a country which sucks greatly, sucked and I know it will suck; I also want to live in some civilised country at North (especially Sweden). Någon, ta mig till Norden, är du snäll.