Archive for November, 2022

Looking again at LSVX

Tuesday, November 29th, 2022

Recently Paul B. Mahol asked me to take a look at LSVX codec (aka Lightning Strike Video Codec from Espre). Since the guy is working on Bink2 decoder for all of us, he deserves some respect. So here’s what I found.

Previously I took a glance on it, found that it’s based on tmndec 3.0, kinda the reference decoder for H.263 and concluded it is an ordinary H.263 rip-off and hadn’t looked further. It turned out to be more interesting though.

LSVX frames start with 5-byte header where the second byte tells the frame type (0x01, 0x08 and 0x09 are for normal frames, 0x05 is from skip frames; additionally if the first two bytes of the header are 0x78 0x01 then the header is followed by another eight bytes, usually with “lsvxv2.0” in them). Then almost normal H.263 stream follows—at least on a prolonged glance it seems to be the standard H.263 stream without any modifications of the headers (except maybe in motion vectors decoding). But there’s a catch! Key frames may have picture type 7 (reserved code in the standard) and then they’re coded with wavelets.

The wavelet coding is rather straightforward: you have a picture split into many bands, each of them is quantised and coded with a semi-adaptive binary coder. By that I mean that it uses models with fixed probabilities but it selects different context for different bits depending on previously decoded bits and in some cases the entier sets of probabilities may be switched mid-decoding. Beside that there are no special tricks like zero tree coding or fancy coefficient prediction.

Maybe I’ll write a decoder for it after all.

Looking at KQ6 Mac videos

Friday, November 25th, 2022

The terrorist country proves that it is recognized as one and keeps targeting civilians instead of fighting a war. So nothing new but it would still be nice to see its demise soon. Meanwhile I keep doing small things to distract myself from all this.

Since I have nothing better to do, I watch reviews of various games including the ones I know well. And one of those reviews mentioned that Macintosh version of King’s Quest VI: Heir Today Gone Tomorrow had peculiar intro. Actually every version of the game has something peculiar about its intro: DOS version uses Sierra’s own RLE-based SEQ format, Windows version uses standard MS Video 1 in AVI (it was my first sample with palette change messages), Amiga version is a reimplementation by Revolution Software on their Virtual Theatre engine altogether (maybe ScummVM will support it one day for all three and a half fans waiting for that). So, what’s with Macintosh version?

First of all, the files are QuickTime movies in the original Macintosh format where frame data is stored in the data fork and movie header is stored inside the resource fork. Since not all modern OSes support such files natively (or conveniently), I’ve hacked a support for such movies in MacBinary format that keeps all forks in one file. And what do we have inside?

Inside the files are video streams packed with Cinepak. One of the peculiarities is that they have palette specified in video header in the format different from the conventional MOV color atom format, let alone the fact it should not be present at all. I understand that for Cinepak and even more for Indeo 3 (I really should write an encoder for it one day) it was common to provide a palette so they rendered their output for 256-colour mode but in that mode Cinepak simply coded palette indices and here we have YUV420 output and a palette as a recommendation.

Then there’s a fun case with tracks in KQ6Movie. I understand that they split video and coded it in several tracks so they could use different palettes (and framerates as it turns out) for different segments. And those tracks are not in order. Tracks 0 and 1 seem to be the very beginning, track 2 corresponds to a scene somewhere in the middle and track 3 is the last intro scene. Other ten tracks are not in order either. Maybe there is some information hidden in the header telling the order but I’m too lazy to find it out (let alone implement).

All in all, this was unexpectedly weird.

RV6: a blast from the past

Tuesday, November 8th, 2022

So while various terrorist states try to prove they have better industry than russia, here’s yet another fun distraction.

It turned out that Peter Ross for some unfathomable reason decided to take a look at RealVideo 6. RealPlayer™ has RV11 support (which is FFmpeg with wrappers for calling their proprietary encoder and decoder for RV11), he played a bit with it. And since there’s one opensource decoder for RV6 (should be obvious which one), he contacted me with a list of changes to make it work fine not just on the only sample I had. Many thanks for that!

Beside various small mistakes there are several things that are rather curious:

  • RMVB container version 2 supports 64-bit offsets. Now all is left is to find a person willing to create RMVB files over 4GB in size;
  • chroma motion compensation case (¾,¾) is the same as (¾,½);
  • loop filtering formula was changed from |p0-q0|*lim1 < 512 to ((|p0-q0|*lim1) & ~0x7F) <= 384. They should be equivalent (even if I can't bother to prove it) but the change is still baffling;
  • and it turns out that delta quantisers are once per CU instead once per one row. More about it below.

So what's the deal with delta quantisers? When I REd the code, the binary specification had all debug information left inside. So when you see a function named Decoder::parseBitStream_CUOneCULine() that calls decodeCUQPOffset() once before calling decodeAndReconstructCBTree() in a loop you'd presume it reads DQP once per one row of CUs yet it turned out to be one DQP per CU (also reasonable but not what you expect from the function name). The thread management code that sets various parameters for slice decoding and calls the function is too messy to figure out parameters from it (I tried and got a number of 4 CUs per call unless it's at the end of row—which is obviously wrong).

It's nice to see that RealVideo 6 keeps up the traditions of previous RealVideo versions.

Denazification, or the story my divorce from russian culture

Friday, November 4th, 2022

This is another story that I simply had to write. It may be fun to seek parallels between this and free services of a certain privacy-invading company but the only common points there are that I stopped using them out of disgust and the company helped to make the process easier. So far no matter what it did it hasn’t done even a minuscule amount of harm russia did (and does) to Ukraine and the rest of the world.

So I’m finally writing about russian culture not in general but applied to me. Short summary: I grew up in both russian and Ukrainian cultures and I didn’t hate either, yet there were always some things in russian works that rubbed me the wrong way and I had been slowly drifting from it even before russia demonstrated what a loaded deal it is.

A bit about Kharkiv

Let’s start from my birthplace. I was born and spent two thirds of my life in Kharkiv, the large cultural centre of the East Ukraine. It was founded about four hundred years ago in a territory of border Cossack forces called Slobozhanshchyna (the word comes from the word “freedom” BTW). Kharkiv grew up a large trade and industrial city. First private bank in russian empire was founded there and the best known Soviet tank (along with several others) were designed and produced there, to give just two random examples. It was equally powerful scientific and cultural centre as well—all three Ukrainian Nobel laureates studied at Kharkiv University (which is over two centuries old), and a plethora of people who made great contributions to the Ukrainian culture, from from Kvitka-Osnovianenko to the group known as Executed Renaissance to the modern ones like Serhiy Zhadan (I have actually seen him once at our Literary Museum). There were people living in Kharkiv who later moved elsewhere to make great contributions to russian culture as well (actors, singers and even the scriptwriters of the best Soviet comedies).

As you can see, my home city had a lot to offer. And I sampled a lot of it like visiting a six dozen of different theatres (half of them repeatedly) but more about it later. The main negative property of Kharkiv is being located in less than 50 kilometres from the russian border (and it shows).

My early years and language

Anyway, let’s move to my childhood. I was born in a russian-speaking family, everybody was speaking russian and we had just one topic in school taught in Ukrainian (which is, not surprisingly, was Ukrainian language itself). Side note: during that time the Ukrainian grammar was reformed to make it closer to the actual Ukrainian language instead of russian, for example the letter “ґ” was reintroduced back into Ukrainian language (it’s called “Wallachian g” and used mainly in loanwords that have a sound different from real Ukrainian ‘g’). Yet despite all that people had nothing against Ukrainian language, I used to listen to the radio station “Промінь” that had various kinds of music in Ukrainian (and some retro music in russian as well), I read children magazines in russian or Ukrainian depending on in which language an issue was available (you can guess why Ukrainian periodicals often had versions in two languages; the same applies to books). It was the same in my university years: mostly people spoke russian and we had only two subjects taught in Ukrainian (Ukrainian history and Ukrainian language for business letters). So I could observe it myself that most of the time people spoke russian but nobody was against Ukrainian language (only complaining about not mastering it). The only time I heard somebody saying that she hates Ukrainian language was in Luhansk region…

I had relatives in Luhansk region, my grandparents were from Borivske village and they lived in Lysychansk. Of course I stayed with them in summer and heard different stories about the region. For example, during German occupation in 1940s German soldiers had better attitude to the locals than collaborators (my grandmother remembered how one of them commented it in broken language—”a russian beats brother, what idiot”). My grandpa was involved in building Sieverodonetsk Azot (the large producer of nitrogen-based compounds that became infamous this spring). He said that it started as a German chemical plant that was dismantled and rebuilt in two several sites, namely Sieverodonetsk and somewhere in east russia (maybe Kemerovo but I can’t be sure). Later it was expanded using an equipment bought abroad, so my grandpa worked with prisoners who were laying bricks for the future production sites and with Japanese experts overseeing other construction works. It seems to be a common story when russian or Soviet industry is built by foreigners and prisoners (sometimes they’re the same people). And it demonstrates the problem planted by USSR: since all those large construction works in Donbas area were performed mostly by prisoners, those prisoners had to be brought from somewhere (which means russia) and they were left there afterwards, creating an alien element. That is why this region had the population that refused to speak anything but russian and well-developed criminal culture culminating in yanukovych, the fourth president of Ukraine who still had manners and jargon of an ex-con, and his cronies from Donbas who helped him to rob the country—and a bang in 2014 when Ukrainians got finally tired of this and russia showed its true colours by occupying Crimea and sending people to start an uprising in Donbas. And yes, the pretext was oppression of russian-speaking population (which is probably was a need for them to learn even a bit of Ukrainian). Mind you, that person who said that she hated Ukrainian language was not speaking the perfect russian either. This reminds me also of French language attitude but I’ll leave comparisons of France/French and russia/russians to another time.

The slow move from different kinds of russian culture

That was all mostly about the language itself, what about the other aspects of culture: books, music, plays, mass-media? I’ve written already about radio station I’ve listened to but what about the rest?

Television

As for TV, I watched mostly humour shows (in russian, Ukrainian and even surzhyk which is a mix of both). One of my favourite shows was КВН (“a club of witty and clever ones” which grew out of student sketch shows and competitions where people asked random questions and others tried to answer with a witty response), which had a lot of Ukrainian teams as strong competitors and they even were winning tournaments more than once (two of those teams had a guy who became a famous and comedian, you might’ve heard about Volodymyr Zelensky). In the mid-2000s though the show degraded as it was no longer possible to joke about politics and everything in the show now essentially belongs to the host and his family (not just a trademark, broadcasting rights and the building where the shows are performed, teams wanting to perform in the show have to sign a contract making them virtually slaves)—and considering that this guy is over 80, tries to pretend to be young and shows no desire to leave, it feels like a history of modern russia in a nutshell.

Back in the day Ukrainian TV features a lot of russian soap operas (half of them being the local version of telenovelas and another half being about cops or criminals) and a good deal of them was shot in Ukraine because it was cheaper (in the same way as iconic American movies were shot in England). Once I’ve caught a bit of it while switching channels and acting was so bad that it made me want to puke. So I haven’t missed anything good by not watching them either.

Anyway, I’ve stopped watching TV completely around 2005 out of disgust. Advertisements may be annoying but when the same programme is interrupted with advertisements in five minutes after the first time, it’s too much. So I turned TV set off and haven’t regretted that since. I suppose I should thank certain Ukrainian TV channel for that.

Music

As for the music, I prefer instrumental music that is couple of centuries old (German baroque music played on harpsichord or organ is the best). I heard enough russian composers but I didn’t like their music (except for Glinka for some reason). Ukrainian traditional music, played on bandura, kobza and dulcimer, somehow resonates with my soul though (it was performed sometimes at our philharmonic). And out of many theatres I’ve visited, the russian drama theatre was the one I liked the least (not the repertoire though but the attitude to the watchers). So I’m mostly into classics yet there’s one Ukrainian song from my home city that I know by heart (and it sounds equally good both in russian and Ukrainian).

See, I haven’t had to stop listening to russian music because I haven’t listened much to it in the first place.

Literature

It’s not that I like reading, it’s more that I can’t live without it. We had all kinds of books at home, from russian classics (including two or three complete sets of works by Pushkin) to modern science fiction (including both books by Strugatsky brothers, works by foreign authors and even some science fiction in Ukrainian by local authors). Later I learned other languages and I’ve read a couple of books in each language I know (and probably couple of hundred books in English). I value content and ideas over the presentation so I can forgive some problems to a book if it’s an interesting reading (and not written by a completely illiterate person). Books in russian are plenty and easy to get access to in electronic form for free (and not even via means of piracy) so no wonder I mostly read those. The problem is that many of those books have issues with quality and they get worse every year.

One of the main problems is declining literacy: while the books are still being written, they’re written used poor language (limited vocabulary, primitive sentences, words used at random, lack of punctuation) and the topics are not good either. And it’s increasingly hard to find decent books among the thousands of mediocre and outright bad ones (yeah, like with the information in Internet).

Here’s a short review of the most popular russian genres of fiction (the ones I’ve heard of, most of them I’d rather never touch but reading comments on such works was sometimes entertaining):

  • “ironic detectives” (it’s ironic to call them detectives)—pulp fiction oriented at women and produced in bulk (I still remember when you could rent such books for a nickel per day at some stalls). Considering that the best known author (allegedly) wrote over 250 books in two decades, you can guess how good they are. Pass;
  • “female fantasy” (again, a genre of its own). Comes in three flavours: a young woman gets to study at some magical school where she marries a dean or a prince; a woman in fantasy world gets what she wants (often marrying a prince) by chutzpah; a woman is a wealthy heiress or possess special qualities which makes several powerful males (not necessarily humans or elves, dragons are popular too) compete for her hand. Pass;
  • action—often features weapon porn (where a good deal of book is dedicated to the weapon specifications and what accessories are attached). The stories are usually primitive as it’s more about the amount of enemies killed and women courted with. Pass;
  • popadanets genre (or isekai if you prefer it)—stories about somebody from one world transported/teleported/reincarnated into another (or the same but in different time). By itself it’s a good tool to show a conflict of traditions and beliefs for somebody put into an alien environment. A Connecticut Yankee in King Arthur’s Court is still being read today and Futurama is still fun to watch. The problem is that in russia it degraded into two template stories: a Marty Stu with extraordinary abilities grows riches and harem or somebody gets into the past and does whatever needed to prevent russian empire from collapsing/taking losses in World War II/USSR dissolution. There’s even a saying that every popadanets should warn Stalin about German attack, invent intermediate cartridge and two-hatch version T-34 tank, and sing Vysotsky songs (yes, it’s that formulaic). There were some interesting books there but it’s very hard to find them among the rest;
  • alternative history. The same notion as above: something in russian history does not happen (or happens differently) which leads to russia (in either form) to grow even stronger and larger and to take revenge on real and imaginary enemies. Pass;
  • fantasy in boyar-anime stylistics. This is very alternative history with a setting involving russia staying in feudalism with boyar clans keeping power by having large magical talents (like shooting lightnings or sending storms on their opponents). You can guess from the name where they got some of the ideas. Pass;
  • various “historical” “research” books trying to convince the reader that Stalin did not plan to wage a war and the fact that Soviet Union had very large forces concentrated near its (newly created) borders in June 1941 is just a coincidence. Yuck;
  • the literary RPG genre of (sciency) fiction. The settings are usually either virtual reality MMORPGs where characters spend most of their lives (or even serve their prison sentences) or even “real-world RPGs” where something (nanomachines, son!) re-creates the system with RPG characteristics, levels and skills in the real world. Few adequate books are buried under the tons of usual Marty Stu fantasies and books mostly full of main character game logs and stat sheets printed after each update;
  • there were also series based on a predefined setting of two games, namely S.T.A.L.K.E.R. and Metro 2033 but it’s best to be left to the equivalent of Star Wars Expanded Universe fans.

I’ve missed something for sure (like books in more traditional genres) and there are exceptions but here are the reoccurring themes that turn me off even in more reasonable books:

  • jabs at other nations, sometimes not merely chauvinistic but gratuitous too—it’s one thing when a brave russian protagonist uncovers a plot by evil Britain against his country and another thing when a brave russian protagonist encounters some Ukrainians without any reason and they start insulting him, still without any reason, and when this episode ends it gives absolutely nothing to the story;
  • normalised prison traditions. I’ve written before that it seems to be the only natural part of russian culture (and the rest was invented to bind the empire together), a lot of people in russia believe that you’re not a Real Man™ unless you’ve been to prison, so of course it gets reflected in the literature. It’s not that uncommon to see protagonists enjoying speaking prison argot, to give one example;
  • resentment and revanchist feeling (just look at how many books are about fixing something with the russian past);
  • and finally, the attitude to plagiarism. For example, protagonist has some knowledge (technical or art), passes it as his (or her) own inventions/writings without having any regrets. Bonus points for having such protagonist offended when somebody else does the same with his (or her) stuff. I dropped reading one of the books in disgust after the author copied a well-known humoristic piece verbatim without giving credit.

Again, previously I could write these deficiencies off to the skewed views of individual authors. Now russia demonstrated to the whole world that chauvinism, resentment and thievery are the main virtues there. So why should I even attempt to read new russian books that cause only revulsion and disgust? Why should I read older russian books if they’re either the same or about the topics I have no interest about (i.e. russia and russians). And considering that most of the russian classics were imperialists and chauvinists why should I read them too? Fun fact: back in 1930s during Ukrainisation movement (started by Soviets to make their rule accepted by local population and cut off when it was no longer required) those classics were against their works being translated into Ukrainian (probably culminating in intelligentsia from Leningrad protesting against “traditionally russian” operas being performed in Ukrainian, including Aida). As for the foreign books translated into russian, considering the usual poor quality of the translation it’s better to find and read the originals.

Books were my main connection to russian culture, and this connection is being cut mostly without any efforts on my side. At least there’s enough good literature to replace it. If this makes you think about Nord Stream pipelines, it’s only because there might be something in common here.

Movies

russian movies suffer from the same problems as russian literature. Additionally since shooting a movie is not cheap (in general), one of the important parts of the process is securing funding and finding distributors. Because of certain peculiarities of russian political and economical system it essentially devolved into a system where a cabal formed from large studio owners (that may also act as directors and producers) “help” russian ministry of culture decide which movie to sponsor (usually one of their own). And they use their connections to advertise those movies in prime time on state media channels (or in some cases convincing that the movie should be mandatory to be watched by e.g. children from elementary schools and the orders are made at the ministry of education). The rest of the movies are usually something targeting lowbrow audience to be commercially viable.

As somebody put it, Hollywood movies are for making profit and all about the box office and russian movies are all about securing funding. Unlike Hollywood accounting where the idea is to make movie bring profit without paying taxes, here it’s like in The Producers—make a flop so nobody questions where money for production really went to. That’s why pitching the movie, actors lying how fun it was to shoot and exaggerated advertisement claims are usually the best part of those movies.

Are there exceptions? Yes, but most of those movies are either about criminals or depressing life, sometimes both. And the remaining couple of movies that are clever satire on russian reality I’m not going to re-watch because it’s still about russian reality.

Video games

I don’t play games much and when I find time for them it’s usually adventure games. I’ve made a short review of the games I’m aware of (or played myself). Some of them were actually decent (as they were made before the time when they started make and publish any garbage) but I’ve not played them for a long time and it won’t be hard not to play any them at all.

Internet media

Here the situation is rather simple: most of the sites I visit are in English and at the start of the war a lot of russian sites I visited closed in protest (some may have reopened since but I’ve learned to live without them). The main loss is a webcomic called Depth of Delusion (a deep passionate parody on popular movie franchises with toucans on top). Its author was from Chernihiv so in the best case he simply lost any desire to write it on a russian site (as he said in his last post) and in the worst case he lost his live during the initial state of the 2022 invasion.

As for the videos, I had no interest on what their bloggers can tell me about the russian lifestyle. I watch mostly the videos with humorous reviews of the movies or TV series (so I both be entertained and keep informed about what’s going on). Due to sanctions some of them went to greener pastures (i.e. video hostings that still pay money in russia), others disappeared entirely, yet another one made claims that made me stop watching them out of disgust (those claims may be either outright nationalistic or weaselly shifting the blame from russia). So the amount of channels I’m willing to watch is shrinking steadily and will reach zero eventually. Another thing is that considering the current situation I’m not eager to learn about new russian movies and how awful they are (I’ve explained above why they are) and I can find out stuff about foreign movies from native reviewers.

Meanwhile there’s a vast amount of channels in English offering content good enough for me. And there’s this catalogue for Ukrainian channels which helped me a lot.

Conclusion

There’s a phrase from Soviet times: I’ve not read Pasternak but I condemn him. My situation is opposite: I grew up in a multicultural place with a strong dominance of russian culture and have learned a lot about it. Nevertheless, I had alternatives to choose from and since I have some tastes (I’m not going to claim they’re all good, but they’re there) I don’t mindlessly consume everything but rather pick what I find interesting or entertaining and while I try something new in order to escape filter bubble, there are some things that would make me reject them immediately. And russian culture is one of the things the more you know about the more revolting it is.

As I wrote before, russian culture is an artificial thing created to bind the empire (be it called empire or USSR, doesn’t matter). Initially it was enforced by power (by both suppressing local cultures, including Ukrainian, and leaving the opportunities to work only at russian narratives), later by money (Ukraine has lower reserves of oil, so a lot of Ukrainians moved to russia to get significantly larger payments for their work as actors, singers, writers or even producers). It would be understandable but the imperialist agenda never left it (even in Soviet times they dreamed about uniting the whole world under the wise rule of The Party and praised the leading role of Soviet Russia). So it turned into a mental poison that tries to convince the whole world that Ukraine, Ukrainian language and culture do not exist.

Previously I could ignore those narratives and pick up the better bits, but in 2022 russia demonstrated that those idiocies about defending oppressed russian culture are actually their guidelines and if you do not purge it from your country there may be russian tanks and missiles coming next to “defend” it (again, it’s russian-speaking part of Ukraine that suffered and suffers the most from russian invasion). Taking all this into account, consuming russian culture is like drinking from a spring in Makiivka (this source of potable water at occupied Ukrainian territory got viral a couple of months ago after somebody took a dump into it; considering that this is a thing a russian soldier would do, it’s a very appropriate symbol indeed). Maybe I’m not so smart to cut all possible ties earlier but I can take a hint.