A cursory glance at Daniel codecs

July 10th, 2022

Recently Paul B. Mahol turned my attention to the fact there are codecs with human names so why not take a look at them?

The first disappointing thing is that you need to register in order to receive a link for downloading that software. Oh well, throwaway mail services exist and it’s not the first codec I’ve seen doing that (though I’ve forgotten its name already like I’ll forget about this codec). Then it’s the binary size. I remember thinking that Go2Somewhere single 15MB .dll is too much but here’s is even larger (because they’ve decided to bundle a bunch of other decoders and demuxers instead of just one codec).

In either case, what can I say about the codec? Nothing much really. They both seem to be DCT-based intermediate codecs that group blocks into slices. Daniel2 uses larger tiles in slices, probably to accommodate for the wider variety of supported chroma formats (unlike its predecessor it supports different colourspaces, chroma subsamplings and bitdepths). The claimed high (de)coding speed comes from the same approach as in VBLE (does anybody remember it? I still remember how Derek introduced its author to me at one of VDDs). Yes, they simply store coefficients in fixed amount of bits and transmit bit length for each tile to use.

The only really curious thing I’ve found is some combinatorial coding approach I’ve never seen anywhere else. Essentially it stores something like sum in a table and for each value only the number of table entries is transmitted. Actual value is decoded as (max(table[0], ..., table[len - 1]) + min(table[0], ..., table[len - 1]) + 1) / 2 and then the decoded value is subtracted from all table elements used in the calculation. I have no idea why it’s there and what it’s good for but it exists.

Overall, it was not a complete waste of time.

Spectral Band Replication in various audio codecs

July 7th, 2022

While the war continues I try to distract myself with something less unpleasant, recently it was implementing SBR support for AAC decoder in NihAV. And since I’ve done that why not talk about this technology and its varieties?

The idea of saving bits in lossy codec by coding less important high frequencies in an approximate way is not very new, the first case that comes to mind was aacPlus codec from Coding Technologies that served as a base for AAC SBR (and MP3Pro if you remember such thing). It allows to code the upper part of the spectrum very efficiently compared to the normal AAC codec (I’d say it takes 4-12kbps for that compared to 50-60kbps used for the lower frequencies) which allowed to cut audio bitrate significantly comparing to AAC-LC of similar quality. And since it was a good idea, other codecs used it as well but in different format (because patent infringements are fun when both parties employ hordes of lawyers).

So, let’s look at how it’s done in the codecs I can remember (if you know more feel free to comment):

  • AAC SBR (also mp3PRO but who cares)—the original that inspired other implementations. It works by splitting frame into series of 64-band slots (using complex numbers unless it’s a coarse low-power SBR that uses only real numbers), copying lower frequencies into high ones using a certain shape and adding scaled noise or tones (those two are mutually exclusive). For transmission efficiency lots of those parameters are derived from the configuration (that is transmitted once for couple frames) and essentially only envelopes used to shape coefficients and noise plus some flags are coded. You have to generate a lot of tables (like how QMF bands are grouped for four modes of operation, what gains to use on coefficients/noise/tones for each QMF band in each slot and so on). Eventually there were other variants developed (because there are other AAC codecs that could use it) but the approach remains the same;
  • E-AC-3—this codec has SPectral eXtension which divides frame into fixed sub-bands and copies data from lowed sub-bands, applies a specific scale to that data and blends it with noise scaled with another scale;
  • AC-4—this one has A-SPX that looks a lot like the original SBR (and considering that D*lby got the team behind it it’s not that surprising). I can’t be bothered to look at the finer details but from a quick glance it looks very similar (starting with all those FixVar and VarFix envelopes). If you want to know more about the implementation just ask Paul B. Mahol, it should be more fun than the usual questions about AC-4 he gets;
  • ATRAC9 (but not earlier)—this codec seems to split spectrum into four parts, fills them either with mirrored coefficients from below or with noise and applies coarser or finer scaling to those bands;
  • WMA9 (or was it WMAPro or WMA3?)—as usual it’s “we should overengineer AAC” approach. There’s not much known about how it really functions but it seems to split higher frequencies into variable-length bands and code motion vectors for each band telling from which position to copy (and since audio frames in MDCT-based codec are essentially P-frames, this is too close to being a video codec for my taste). There are three modes of operation for the bands too: copy data, fill with noise, or copy only the large coefficients and fill the rest with noise. I have an impression they tried to make it less computation-heavy than AAC SBR while having the similar or larger amount of features.

I guess you can see how these approaches are different yet alike at the same time and why it was not much fun to implement it. Yet I still don’t consider this time wasted as I gained more understanding on how it works (and why I didn’t want to touch it before). Now maybe it’s time to finally play with inline assembly in Rust.

World War III: origins, short history, possible outcomes

June 28th, 2022

Every generation has its own war. That’s what my granddad used to say. Before 2014 it seemed like a rather pessimistic thing to say but sadly he turned out to be true.

What happens now is World War III even if formally only three countries are “directly” involved—the rest of the world is fighting a proxy war (somewhat like Spanish Civil War was an excuse for certain countries to exercise their troops and test their weapons before WWII officially started).

This is yet another post on the topic I’m not so eager to discuss but the one I can’t stay silent about either. So here are my views on how and why it started, how it went and how it might end for the whole world.

WWIII origins

Usually it’s hard to pinpoint all reasons behind a large war but usually there are some large tendencies making a war possible (usually it’s some ideas, state of the countries and such) and actual trigger that gives a pretext to start it.

For instance, World War I happened because there were large empires not satisfied with their state (not enough territory, powerful neighbours not allowing to grab more territory and so on) but the actual trigger was Black Hand—a Serbian terrorist organisation responsible for a coup in Serbia and the assassination of the archduke Franz Ferdinand (so the war started because Serbia refused to let a proper investigation to be conducted; I’m pretty sure that if they did the war would start regardless but maybe a bit later).

World War II happened because of the resentment in at least two ex-empires (German and russian) let alone several existing empires still striving for more power and control (like Japan). Yet I’d rather name Turkey as the trigger: it demonstrated the whole world that you can commit genocide unpunished (and a certain Austrian guy has learned from that). And we should not forget the role of macrons of their time who pressured Czechoslovakia to cede Sudety in order to save the same Austrian face.

World War III happens because of the resentment in an ex-empire and because other non-democratic country also wants to bring back parts that never belonged to it and take more power and control over the world from the decaying United States and Europe. And in this case it was triggered by three factors: one mad russian dictator, one People’s Republic of China that encouraged and supported him (plus demonstrated that if you deliver cheap goods you can get away with a genocide) and macrons of our time who decided to pretend that nothing has happened in 2008 and hardly anything important has happened in 2014.

An abridged history of war up till now

Essentially the war started in 2014 triggered by political instability in Ukraine (caused by the decision of then acting president to join russian economic union instead of European one—because russia gave him bribes while EU didn’t). As the result Crimea was taken by russian troops that were secretly accumulated there (and for a while russia denied their presence during the events) and Donetsk and Lughansk region were half-captured by bands of local and russian criminals under informal control of russian authorities. And when Ukrainian forces started to push those people away, destroying their weapons (“you can buy those in any shop”), russian forces that had “definitely” nothing to do with the situation (if you don’t count sending “volunteers” and weaponry) had attacked Ukrainian army across the border (Ilovaisk is the best-known example but not the only one). Yet after some time the situation came to a stalemate: Ukrainians had made a fortified line after which they could not pass (both for the lack of weaponry and because unlike russia Ukraine values its people lives). And it remained like this until 2022…

In late 2021 there were rumours going about russia going to occupy Ukraine but nobody could tell for sure if it’ll happen and when. Personally I saw russian military exercises and their usual way of bargaining for something and started to worry only when they officially claimed they’re pulling those forces back (it’s the same principle as with the lawyers—you can recognize that they’re lying by their mouth being open). But nobody had predicted what had really happened.

On February 24th russia had started the next phase of war exactly the same way as German invasion of Soviet Union in 1941—in early morning, without a warning, by bombing cities. The invaders quickly occupied a significant part of Ukraine, both Northern and Southern parts (but not so much success in the East because it was the expected direction and there’re good fortifications there). Fun fact: captured documents show that they planned to start operation couple of days earlier, during the Winter Olympics in China but unlike 2014 they’ve decided to wait until it’s over (and China has nothing to do with it at all, right?).

After the initial couple days of panic Ukraine started to show resistance and the invasion was halted. Since russia has amassed significant forces it was hard to defeat them, but Ukraine has two good allies that helped it: russian incompetence and russian corruption. Because of those two factors russian army had a lot of barely functioning vehicles that broke down before arriving anywhere, and that’s why they moved in columns using roads—which made it much easier to block them and destroy. In those days about a thousand of russian soldiers was killed every day compared to measly 100-150 soldiers killed daily now. And before you say it’s not humane to wish for their deaths, remember that those “people” shot at working nuclear power plants, killed fleeing unarmed civilians and Bucha was not the worst example of what they did in the occupied towns at that time. You really need to work hard to lose the title of human being and they worked hard on that indeed.

Then, when they realized their plan has essentially failed, they withdrew most of the forces to concentrate them in one place in order to have at least some victories (just look how long it took them to overtake Mariupol and Azovstal). They called it “a gesture of good will” like they had anything good in them (also see above how to spot that they’re lying). At least this allowed Ukrainian forces to free Kyiv, Chernihiv, Sumy regions and part of Kharkiv region.

So the invaders concentrated their efforts on conquering the remaining parts of Lughansk and Donetsk regions. They tried to cut off the region by crossing the Siversky Donets river near Bilohorivka and failed spectacularly. They tried to capture Sieverodonetsk and it took them over six weeks while they suffered heavy losses and it allowed Ukrainian forces to perform counteroffensive in the direction of Kherson.

What’s next?

It is hard to predict how long and how intensive it will go. Most likely scenario IMO is that it will keep going the same as it does now—Ukrainians slowly reclaiming their territory while russia wastes its forces trying to achieve some non-military goal and trying to kill as much of Ukrainians as possible with its missiles—until one day it ends suddenly for some internal russian reason (probably a lack of something like missiles or vehicles).

In Ukraine most people don’t doubt the war will end by Ukraine reclaiming all of its territories but nobody know when it will happen. Unlike russia in Ukraine president is elected and has to listen to the will of people, the officials said it before that if they’d decide to stop the war before its logical conclusion then people won’t understand that and keep fighting anyway.

Characteristics of the war

It can be called a war mostly because there are military forces involved and war crimes are committed. russia refuses to call it war (they have special legislation for people who “defame the russian armed forces” so saying or even not saying anything can give you prison time). In theory after first two world wars it was decided that war should be conducted in civilised manner: you do not target civilians, you do not use certain kinds of weapons and other things mentioned in the Geneva Conventions. And there you have a country that tries hard to violate every article of those and other conventions. Using forbidden weapons like anti-personnel landmines, cassette bombs and phosphor bombs? Check. Deliberately targeting civilians? Check. Deporting civilians, forced labour, keeping them as hostages? All check. The worst thing is that it’s not some atrocity committed by a random band, it’s done systematically and by the official orders. russia is committing genocide of the Ukrainian people and looting the Ukraine, it’s war only by a formal definition.

But what makes it a world war instead of a local conflict? Despite formally having just one participant (russia performing its “special operation”), there are significantly more countries involved:

  • Ukraine—even if russia does not really believe there’s such country;
  • belarus—a semi-involuntary ally of russia that provides its bases for russian troops and places to launch russian missiles at Ukraine;
  • Türkiye—it controls the entry to the Black Sea and pursues its own interests even if it does not fight itself;
  • Syria—both an ally and a burden. Russia tried to recruit people there to fight for them and had to withdraw some troops stationed there (to support local dictator). Türkiye was so amused that it forbade russian military planes to fly through its airspace to Syria;
  • People’s Republic of China—while pretending to be neutral it supported its fellow dictator. I heard rumours that it even made clones of Soviet equipment which russia could use and pretend it’s from old reserves but I’ve seen no confirmation of that. Recently it seems to reduce support though;
  • European Union—some countries provided substantial support (military equipment and even bases) for Ukraine, some countries are corrupted by cheap russian gas and try to do nothing that angers it. And there’s Hungary which of course supports its fellow dictator;
  • the UK and the USA—provide substantial military aid that helps destroying russian invaders.

Additionally since the way the wars are fought has changed, cutting off access to the technologies and finances is a very important part of it since the best specimens of russian technology are made using Western parts and technologies.

And I think it’s worth expanding my thought about two main Ukrainian allies. russia is essentially a state run by criminals using criminal approaches. So everybody with a bit of power uses it to extort money in some way—steal money on governmental projects, steal companies producing something valuable, becoming an unnecessary middle man, or simply taking “protection” money from businessmen. Usually it’s organised as a system where you have to share with higher-ups and honest people are expunged. This way stealing becomes a norm and nobody sees anything wrong with it (but it’s easy to get rid of a person later if required). Similarly if you’re loyal to your higher-ups you won’t be punished for lying to other people (or if it makes it easier to steal and you don’t forget their share you can lie to the higher-ups as well).

In result everything works ineffectively and the only visible outcome of “perspective” military programs is usually some villas on remote tropical islands. That is why a lot of their tanks and other vehicles could not reach the destination—they broke down on the way there or were inoperable right from the start (either being used for spare parts or unmaintained for a long time). That’s why their super-advanced laser weapons announced a month ago have no following mentions. That’s why their super-advanced passenger planes still don’t have domestic engines. Essentially all the stuff they’re really using was either made in the USSR or is a modernisation of that Soviet stuff.

There’s a downside though. It’s claimed the second phase of war started in 2022 because their minister of “defence” and his people got under investigation for embezzling of extraordinary scale (we’re talking about billions or even tens of billions USD) so he urged the dictator to start a war as an attempt for both delaying the investigation and writing off stolen money as used for e.g. munition that was shot in full during the conflict. During Chechen war it was common to give money for rebuilding something e.g. a hospital or a school, reporting that it was blown up during fighting insurgents and ask for more money to rebuild it again (actual rebuilding is not necessary).

Equally they don’t care what their missiles hit, you can be a Texas sharpshooter and claim that whatever you hit was a legitimate military goal or a hide-out of Ukrainian forces (because a mall full of civilians in Kremenchuk hundreds of kilometres from any front line is definitely one of those).

What will be the aftermath?

On 24th of February I said “welcome to the new world” in one IRC channel and indeed the world has changed. One country demonstrated that it does not consider itself bound by any rules, another country demonstrated that it’s not as weak as others believed it was, NATO demonstrated that it failed its mission of protecting democracy in Europe (there was a joke that if russia would invade Estonia then NATO would react in minutes and revoke Estonian membership; the fact that Türkiye is a dictatorship yet still a member of NATO blocking Finland and Sweden from joining is not very reassuring either). Europe demonstrated that it’s mostly spineless and full of corrupt politicians (just look at Gazprom Schröder, his party and the decisions they’ve made throughout these years; essentially it began to change only when russia started to cut down gas for Germany). PRC tried not to demonstrate that it sees it as a model of what happens if it tries to conquer Republic of China.

So what I expect from all of this:

  • Ukraine wins this war;
  • Ukraine will eventually become a member of the European Union;
  • there will be changes and shifts of power in the EU as the consequence of the current actions (maybe SPD will lose its position, maybe unanimous decisions won’t be needed because appeasing Hungary is humiliating and there’s a faint hope that the politicians who enabled russia will be tried for corruption and state treason);
  • the same applies to NATO;
  • Winnie the Xi will either have to rethink the invasion of Taiwan or rush it or get eaten alive by other party members;
  • various Asian countries (those ending with -stan) will fall from russian sphere of influence and come under Chinese and Turkish influence (some like Kazakhstan has done that already);
  • Armenia might get it the worst as russia won’t be able to defend it and Türkiye and Azerbaijan don’t like its existence at all so it’ll be worse for them than in 2020. Asking for russian protection was a worse decision than plans for urban development of Spitak;
  • as for russia, I see three possible outcomes:
    • nuclear suicide. They’ve been talking so long about nuking other countries that they might finally believe in their lies and attempt to do that. For the two reasons mentioned above it’s not likely most of them would work but it should be enough to have a reason to retaliate and put an end to that shame of a country. Or they might apply their usual strategy and attack some NATO/EU country to divert attention from their current war—but looks like everybody is fed up with them already and the outcome will be the same;
    • terrorist country. They might withdraw the remaining pieces of their troops and declare victory (anybody who doubts it will be prosecuted). The rest of the world will treat them as DPRK or Iran—a terrorist state that they don’t want to deal with (and for China it’s a resource colony). Considering the history of that country I don’t expect it to improve and get accepted back in the following decades at least (maybe ever). Israel demonstrates how to deal with such neighbours though;
    • the best scenario for everybody. The “federation” dissolves creating many independent states. Some of them may turn into shitholes, others may finally get a chance to develop. Currently everything is done through Moscow and both money and power are concentrated there. With many independent states people might finally be able to elect their own leaders (in some regions at least) and develop it according to their own wishes. And those states will pose less threat to the rest of the world too (the question of nukes can be resolved since there won’t be russia to sign a new Budapest memorandum in that case).

P.S. I write this post as russia increased the number of missiles it fires daily. Yet somehow it feels like an agony when a mad führer orders strikes to have at least some semblance of victory. Ukraine will survive, as for russia—one wise guy said that when they say “but you’ll have to deal with us when it’s all over” the only proper answer is “why do you think you’ll be there to deal with?”. russia has done enough to sever any ties with it so I hope Ukraine will get reparations from it in one way or another and we will forget about its existence. And it won’t be too soon!

E-mail address changed

April 27th, 2022

Some time ago Baidu sent me a warning that they’re going to force two-factor authentication on my account at the end of May. This was rather expected from them since they’ve announced those plans earlier and I had some time to prepare for that, but another thing was rather unexpected.

My Internet access was switched from one provider to another (no idea why) and after the switch fetchmail was banned from accessing my Baidu account. Since I do not want to change the ways I work with email (which is fetchmail+mutt+msmtp combination), I’ve finally bought some simple hosting and switched email on various accounts around the Web (surprisingly enough only one webshop did not allow to change it).

Now the mail link in the right column will lead to a picture of my new e-mail address (this should annoy bots and people with taste). Feel free to ignore it as you did with my previous address.

P.S. I’ll try to check my Baidumail account while it’s possible (i.e. for a month) a couple of times but after that it’s as good as dead for me.

P.P.S. Considering that their mail was the only service I logged into and the only other service I use is BaidUTube (usually with yt-dlp) you can consider me degoogled—and it happened mostly because of their push to keep people logged in all the time. After they introduced those unskippable “I agree” windows I’ve finally switched to On2On2Go for search (in case you didn’t know duck.com used to belong to On2 back in the day) and OpenStreetMap for maps. At least they made it gradual so there was enough time to switch.

Russia, Ukraine and 1939v2

April 5th, 2022

I’m trying not to express my political views publicly because who cares about them, but this is an occasion when I have to write something because I cannot abstain from that.

I was born in Kharkiv in Ukraine, I spent two thirds of my life there and I had a chance to travel throughout it, from visiting my grandparents in Lysychans’k in the East to seeing Lviv and Uzhhorod in the West, from Chernihiv in the North to Odessa and Crimea in the South (back when it was just some Russian military bases there and not the full-scale occupation of course). For you it may be just random places on the map, for me it’s very real places, in some cases places where my relatives live. So call me biased.

Anyway, the only way I can characterise the current situation is 1939 repeating again though this time you have one country to represent both National-Socialistic Germany and International-Socialistic Soviet Union (yes, IMO the main difference between them is what people they regarded as lower races—all but their own or simply all).

The reason for the current war is the same as in 1939: a power-mad dictator convinced himself that he and his country were denied the Lebensraum they believe should belong to them and that it’s the foreign threat that made them start the war.

And since Russian Reichspropaganda (in July 2014 putin said that Goebbels was a talented man—at the meeting with Jewish diaspora representatives—so I guess they see him as their teacher indeed) claims that Ukraine is not a real country and never has existed let’s start with a very condensed history of Ukraine.

History of Ukraine

The origin of Ukraine lies in the times when Scandinavians discovered they can organise a trade route to the East Roman Empire (the famous route from the Varangians to the Greeks) and built some outposts to control it with Kyiv becoming the main one. Time passed, the rulers (called knyaz which roughly corresponds to prince, duke or (war)lord) started to develop territory and thus Kievan Rus’ was created. It became a European country by accepting Christianity as the state religion (it was before East-West Schism so Volodymyr I is the saint both in Orthodox and Catholic branches of Christianity) and strengthening ties with the East Roman Empire while having ties with the Western Europe as well (Yaroslav the Wise had a daughter of Swedish king for wife, he helped one of his sons-in-law to become a Norwegian king, his other daughters were married to the kings as well and one of them even was a French regent for a while).

It’s worth noting that there was another trade centre in the North—Novgorod—which was a member of Hanseatic League and a democracy akin to Venetian one. Yet it played the second role to Kyiv and was eventually squashed by Moscow czar Ivan IV.

The main problem of Kievan Rus’ was the power struggle and very complicated inheritance rules so it was essentially lots of duchies competing for a throne in Kyiv. On the outskirts of Kievan Rus’ there was so-called Украина Залесская which translates to Beyond-forests Mark or Transylvanian Ukraine. Yes, word “ukraine” initially meant a borderland territory (but Ukrainians made it sound proud nevertheless). And yes, it’s bloodsuckers from wrong Transylvania who got all the fame. Anyway, on this territory there was a duchy of Suzdal and its ruler, Yuriy Dolgorukiy, founded a settlement called Moscow. And yet he wanted to be a ruler of Kyiv instead (and he was kicked out from there the first time out).

This internal struggle proved fatal when Mongolian hordes came. Disunited rulers could not unite even against the common threat and the land fell prey to the invaders. IMO that’s where the real story of Russia starts. While Ukraine struggled against the invaders, rulers from the Northern parts were happy to integrate with the khans, marry their daughters and competed for a permit to rule the whole region (which included collecting taxes and contribution to the Great Khan). Eventually a huge chunk was united under one rules who drove Mongols away by being a loyalist and supporting a different pretender to the post of the Great Khan (who later thanked them by coming and burning Moscow down). Ukraine meanwhile went a different route.

A lot of Ukrainian lands (and Belarusian lands as well) were taken by the Grand Duchy of Lithuania (even to this day Belarusians are calling themselves litvin because of that). In that time so-called Ruthenian language (a Slavic language that local population would understand) was used as one of the official languages. The problems started to arise after the union between Lithuania and Poland that created Rzeczpospolita—Lithuanians did not care about certain things like religion while Poland started to force Catholicism (which led to the creation of a rather unique Ukrainian Greek Catholic Church). And it was the time when cossacks started to play an important role. They were an independent group with democratic traditions (hetman, the highest military commander, was elected at the officers council, to give one example) but they also enjoyed being employed by Polish government. The tensions between them and the Polish government (let alone the oppression of Ukrainian people by Polish noble landowners) resulted in an uprising led by Bohdan Khmelnytsky that resulted in unfortunate casualties. Side note: in Russian history until XX century there were no uprisings by Russians against the government except when led by the pretenders claiming to be czars. In either case, Khmelnytsky had to seek an ally to help him against Poland and he chose Muscovia (it was renamed to Russia much later) for being culturally similar.

But this protectorate has not lasted well since czars demanded each new hetman to make a new treaty with fewer and fewer freedoms left until in late XVIII century all pretence was dropped and that part of Ukraine was annexed, cossacks expelled and serfdom introduced (if you don’t know what serfdom is, it’s not that different from slavery). Another part of Ukraine went along with Poland to Austro-Hungary.

Let’s skip to XX century. After the February revolution of 1917 Ukrainian people formed a congress and made declaration of independence—before the October revolution of 1917 (and it had started before Lenin decided to return to Russia). The same way like some Soviet republics declared independence before the formal dissolution of USSR (mostly Baltic states and Ukraine). And since bolsheviks refused to recognize election results in Ukraine (where they got a minority of votes), they created a Ukrainian Soviet Socialistic Republic and used the army (pretending to be a Ukrainian one) to conquer as much of Ukrainian territory as they could (Western Ukraine was left under Polish rule at that time). Then in 1939 World War II started and Ukraine was one of the bloodiest battlefields that was first fully occupied by the USSR, then by Germany and then by USSR again. During that was USSR fought mostly with troops from Ukraine and Belarus (with enormous losses because the commandment did not care) which was later used as a pretext to introduce both republics as founding members of the United Nations and allow Russians to claim that it was them who won the war (and who cares that USSR would not be able to fight without British supplies and American lend-lease program).

And here’s another small detail: after the war Crimea was devastated, its inhabitants deported to Middle Asia, so it was decided to “make a gift” to Ukraine which should provide it with the fresh water from the Dnieper and restore its agriculture, all while various distinguished Russians would get a piece of land at a scenic Southern Crimean Coast.

In the beginning of the XXI century Ukraine was slowly failing state (especially considering the corruption around natural gas but Europe turned out to be not that different in that aspect) that started to unite and get the national identity after several incidents all related to Russia: 2003 attempt to seize Tuzla island by building a dam to it (IIRC China has managed to get several islands from Russia in that way; this attempt has failed though), occupation of Tuzla island along with the rest of Crimea in 2014 and the war of 2022.

Now with that background let’s move to the common myths instigated by Russians.

Russian myths about Ukraine

Here’s a short list of what I can remember. Probably there are more but I’d feel queasy if I have to search for more.

  • Ukraine is not a real country. I hope from that condensed version of Ukrainian history you could see that Ukraine was a country, always wanted to be an independent country, and remains an independent country despite Russian best efforts;
  • Ukrainian language is not a real one (or even: Ukrainian language was invented at Austrian General Staff). I think that’s the case of projecting. Ukrainian language remains rather similar to Old Ukrainian language used in Kievan Rus’ and to Polish and Belarusian languages so you can more or less understand them if you know Ukrainian. Russian language is quite different, based on Old Ukrainian and Church Slavonic with some features not found in Ukrainian or Belarusian language like heavy stress (but you can find it in Mongolian language). Even funnier is that the first Russian grammar was made by a Ukrainian and later the language rules were mostly revised and updated by people of German origin;
  • Ukrainian culture does not exist. Despite the best efforts of Russians (just see for yourself what Ems Ukaz was and that it was not the first of its kind either), Ukrainian culture existed back then even if a lot of it was appropriated by Russians (I dare you to look what Yevhen Hrebinka is famous for). Or there’s another fun episode: in the beginning of XX century Hnat Hotkevych re-discovered some bandura players and revived the art of bandura playing. In 1930 most of the bandurists were dead (many believe they were gathered in one place under pretence of some conference and shot) and the monument to them installed in Kharkiv in 1997 gets vandalised rather regularly. So this myth is more of a wishful thinking plus covering up a theft (the same as they did with history);
  • Russia brought civilisation to Ukraine. As usual, it was the other way round. For the majority of time Ukrainians were more literate than Russians, centuries ago Ukraine supplied Russians with clergy and officials (and see the example with Russian language grammar above). And even in Soviet times a good deal of engineers were Ukrainians or had Ukrainian origin;
  • Ukrainian nationalists were Nazi collaborators and are very active up to this day. It is true that Ukrainian nationalists collaborated with Germany, but after they’ve declared Ukrainian republic in Lviv they were arrested and mostly killed. Some of the leaders were kept alive in the concentration camps in case they can be useful later. It’s mostly thanks to Soviet propaganda that demonised Stepan Bandera that many Ukrainians remember him, otherwise it would be “well, there was such historic figure but he’s no longer relevant”. And nationalistic parties have never gained much influence in the parliament after the independence. Similarly nobody was oppressing Russian-speaking people in Ukraine, not even in the Western part. Now the things might change but I guess people speaking German were not popular in Europe in 1950s either;
  • Russia liberated Ukraine from Nazis and it’s so ungrateful. As mentioned in the history section, it was Ukrainian forces that had to hold the defence and be waster during counter-offence. And people have not forgotten the other nice things like Holodomor and other famines of 1930s and 1940s, how Russians behaved in 1939 in “liberated” part of Ukraine, how lots of valuables from museums and factories were evacuated during the war and never returned or only a part of it was returned (just read the history of Uralvagonzavod), there are other cases that demonstrate that Russians have not earned gratitude;
  • Ukraine survived only because of Russian gas. And as usual it’s a mix of lies and covering up for the theft. In 1950s Moscow used natural gas from the West Ukraine (and they even had to disguise it as something else so that Ukrainian resistance wouldn’t blow it up). There are gas deposits in Kharkiv region as well (and some oil was pumped in Okhtyrka district in addition to the oil deposits in Western Ukraine). The situation around gas in 1990s-2000s was complicated and caused (IMO) by both countries profiting off cheap gas and the differences in gas prices for the population and for the industry. After the 2014 events Ukraine started to buy gas at European market and it was not much worse than before (except maybe for certain oligarchs);
  • Russians are the elder brethren of Ukrainians. First of all, Ukrainians as a nation are older. Second, your actions have shown what kind of people you are so you’re disowned relatives at best. Go after your warship!

So what do I think about it in general?

Final thoughts about Russia

Russia has been a prison at almost any period of its existence. Wikipedia quotes the state census of 1857 that out of 62.5 millions of total population 23 millions were private serfs and about the same number of people were state peasants who were not much different from private serfs either.

In Soviet times after the initial period of freedom they’ve decided to re-introduce internal passports and the system of propiska which restricted internal migration (and going abroad for a trip let alone emigrating was extremely hard). Additionally the country in Stalin’s times was characterised as a bus—one man driving, half of people sitting (in the camps) and the other half of people shaking (or watching over the first half in other variant of the joke). It was a mass system of forced labour and rather ineffective at that. To give one example, Salekhard-Igarka railway was built by camp prisoners with an effective rate of one dead prisoner per one sleeper tie laid—and the best part is that this railway turned out to be rather useless. So thanks to such wonderful state system being a prisoner was not shameful.

Then in 1990s it was a turmoil and the economics was not functioning properly. Those who could sold leftovers of the Soviet legacy or natural resources, those who could not in many cases became bandits and since they had money it was seemed as an attractive occupation. Many of the bands were formed by ex-military, ex-policemen or ex-KGB people (and thanks to Andropov there were too many KGB agents for any meaningful job). And one ex-KGB agent from one of those gangs later became a dictator and brought both his cronies and ways of dealing with others to the state level.

It’s hard to believe but criminal way of living has been romanticised there (even if 2000s were rather good and wealthy years for Russia) to the point that most Russians may not recite any poem of their classic poets but know prison jargon quite well and the answer to a riddle about two chairs that’s supposedly asked to an each new prisoner by older inmates. Their police works like legalised criminal gang, their army is not that different from the prison either, their political system resembles prison hierarchy as well.

And then comes the ideology…

The claim that Moscow is the third Rome is about as old as Russia itself (while in Kievan Rus’ knyaz could have a daughter of Byzantine emperor for a wife, they were proud to be who they were and not somebody else). Considering what other countries made claims to be a successor of Roman Empire it puts Russia into a nice company already.

Then you have a schizophrenic chauvinism, where they both claim to be the greatest nation of the world and having no regard for their own people (one writer explained it by Russian community being large but too vague to define so the definition of “own people” changes depending on purpose).

Then you have imperialistic ambitions for more and more territory—instead of developing already enormous chunk of landmass they have. In Russian empire times they tried to conquer more and more land but were afraid to have external colonies in fear they go independent (that’s why they were eager to sell Alaska and Fort Ross colony for a rather small sum of money). In Soviet times they tried to bring back countries lost after 1917 (did not work with Finland thankfully) and tried to get more countries into Socialistic (concentration) camp. Now they’re trying to restore Soviet glory (which makes it the third empire or the third Reich more precisely).

Then you have a fascistic ideology based on worshipping World War II (or rather the part of it that does not paint USSR in a bad light) with random outbursts against other nations (like Poles, Czechs or Estonians) in the best traditions of Orwell’s two minutes hate. This is partly because it was the apex moment of Soviet glory (good reputations, a lot of influence and large territories conquered from the neighbours) partly because (as it turned out) they wanted to repeat a war in the same fashion.

Then you have a mindset of a typical criminal, believing that you can say any lie no matter how easily disprovable it is and if you’re caught you can simply say another lie and another. The same mindset gives the following fine strategy as well: at first you demand proofs and if those are delivered you simply say “so what?” and keep doing what you were doing while your opponent is shocked by your chutzpah.

And finally you have both yearning for the great past and dissatisfaction with the reality resulting in a willingness to revise the reality by starting a war. 1930s Germany was in the same situation but it was caused by losing the previous war and bad economic situation because of that, now it’s caused by a bad economic situation from the mismanagement (if you’re a gang extracting rent from natural resources while your underlings extract rent by extorting private businesses you have an ideal case of trickle-down economy that works good only so long as gas/oil price is high enough).

As the result you get war done in the best traditions of both the Red Army trying to conquer Finland (with equal incompetence and losses) and the SS troops (they got infamous not for their military prowess either).

And one last final thing I want to mention that is related to the current topic: how Russians are keeping words, contracts or treaties. European countries operate on reputation and keeping your word no matter now matter what. In Russia it seems to be the opposite: you’re more respected if you’ve managed to swindle somebody with your contract. On the one side they think they can denounce any treaties at any time their conditions are not good enough for them, on the other side when they provide something they behave worse than any copyright holder. That was the case with Crimea when they decided that it’s been long enough a part of Ukraine and should be taken back (because it was theirs by some treaty with Turkey in XVIII century), this is the case with UN where they recognize its activity only when it either favours them or they can veto it. That was the case with their natural gas and the peculiar “take it or pay regardless” scheme where you were supposed to pay for a fixed amount of natural gas no matter if you’ve used it in full or just part of it or none at all—and you were forbidden to re-sell the leftovers. After 2014 when Ukraine stopped buying gas from Russia and started to buy (the same) gas on European market they wanted to forbid other countries to sell it to Ukraine. Sounds like a licensing scheme instead of commodity sell, doesn’t it?


Despite all that I don’t hate Russia or Russians, I’m merely deeply disgusted by them. But I’d have nothing about them living in whatever way they like in their own country without trying to threaten let alone invade any other country. It would be nice if they’re taught that what they’re doing is wrong (like Germans were about seventy years ago) but it’s too unrealistic.

P.S. I’ve never asked for money (because I’d started earning myself before I had this blog) but in this situation I ask to help Ukrainian Armed Forces by sending some money (here is the official page of the National Bank of Ukraine). There are enough kind people willing to help Ukrainian refugees and Ukrainians suffering from Russian attacks but somebody has to fight so those people will have a place to return to and live in safety. I’ve transferred over 30k€ and keep sending more, maybe you can help too?

Looking at Voyeur II videos

March 26th, 2022

Here’s a result of another attempt to distract myself from the thoughts whether Ukraine will kick out the invaders in a steady manner or if the führer will resort to chemical or nuclear weapons.

So I decided to take a look at random FMV game and Voyeur II came to my attention. From what I know the first instalment uses RL2 videos and is supported by ScummVM. The second game, however, uses a completely different format and packs most of the data into few volumes (80% of the data on CD is in single diskN.vol and the rest of the data is mostly in endings.vol and slides.vol).

Those volume files turned out to be archives as expected, and the content of those archives turned out to be kinda archives too.

The data stored in volume files is bits of video usually one or two seconds long but the way they’re stored is somewhat peculiar. The header defines (always?) four streams, two of which are dummy ones and the other two are audio and video correspondingly (and they can turn up in any order). The rest of the file is a collection of blocks with 8-byte header defining block size and to which stream it belongs to—and yes, blocks for different streams may be interleaved. Audio stream seems to be plain PCM and video stream is a sequence of frames (thankfully, 14-byte frame header contains packed frame size).

So, what about video compression? It’s RLE with a small twist: there are intra- and inter-frame RLE variants and they can use double-pixel mode (i.e. where you skip or fill the doubled amount of pixels and for raw pixel data each pixel is repeated twice on output). Inter-frame RLE compression has skip codes (i.e. at first you read how many pixels you need to skip, then you read either raw pixels to update the frame with or RLE data depending on opcode, and then you read next skip code and repeat it until the end of frame). Additionally it seems the video is always 320×160 and only video height is stored in the files.

All in all, the most interesting part there turned out to be the logical organisation of data and not the RLE compression or actual videos (I checked random couple of dozens of samples from over two thousands total videos and nothing piqued my interest). Maybe I’ll find something more interesting next time.

Revisiting legendary video format

March 22nd, 2022

So Ukraine is still holding against self-proclaimed second army of the world (though by this time it has earned the title of the most atrocious and hateful military force in the world, the title that had to be taken from the SS troops). And while I can’t stop worrying about my relatives, home city and home country in general, I still need something to distract me at least for a while.

While watching some video about video games, I spotted something surprising in it: a cutscene in Callahan’s Crosstime Saloon. While I worked on supporting Q video format in Legend Entertainment games I remember seeing just one video from that game (the animated title). So I tracked a full CD version of the game and discovered some surprising things about it.

First of all, it turned out to be version 7 of the format (and I’ve seen only versions 3-5 before). Second, it turned out to be mostly the same as version 5 but with F8 opcode in use. This opcode turned out to be used for compact representation of the colours where a code either introduces a cache of up to 15 colours or reuses some previous table and then tile colours are stored in a nibble. Third, beside cutscenes there are a couple of videos of some lady with a small child that look like a home video sneaked in by some developer.

There’s still a lot of work to be done to support it properly (because of the various quirks of the format) but I’ve managed to decode all of the videos from the game already, some of them even without artefacts. This is a pointless but fun distraction after all.

vp6enc: slightly faster encoding mode

March 12th, 2022

As I mentioned before, I wanted to try to apply the macroblock selection approach from VP7 encoder in VP6 encoder. Well, it was easy to implement: instead of preparing all macroblock modes and then trying which is the best one now it tries macroblock modes (starting with inter mode now) and stops when the result is good enough. In this mode encoding seems to go couple percent faster and the resulting size at the same quantiser can differ somewhat in both directions. You can try it yourself by using fast encoder option.

The encoder is still a failure though.

VP7 encoder release

March 3rd, 2022

While a certain country cosplays the Third Reich and conducts talvisota simultaneously—and tries to bomb my home city to debris, I still need some distraction…

borrowed from vp7.de

Since I’m rather bored with VP7 encoder I’ve decided to release it and move to something else. It should work about the same as VP6 encoder (i.e. poorly and nobody should care about it) but if you want to know what knobs you can turn just invoke nihav-encoder --query-encoder-options vp7 (but I guess the only useful options are to set bitrate/quantiser and keyframe interval).

Have fun!

Update from March 4: encoding with low quantisers should now work as well.

VP7 encoder: various bits

February 27th, 2022

As the world tries to avert attention from an insane dictator re-enacting 1939 (it gets funnier since I observe it from Germany), I should also do something to take my mind off constant worrying about my parents and other relatives in one of the Ukrainian cities under attack. Hence this significantly less unpleasant thing.

Now my encoder is conceptually done, all that is left to do is to fix a leftover bug or two, improve a thing of two, clean the code up and integrate it nicely with the rest of nihav-duck crate by splitting off common parts with VP6 encoder. Meanwhile I can talk about some things implemented since the last time and what wasn’t.
Read the rest of this entry »