# I Implemented Video and GIF Playback with FFmpeg
I started my music visualization project with a possibility to load a collection of static images, accompanied with metadata that describe their parameters like dominant colors, whether it uses alpha transparency or whether it is tileable (description of these parameters could be a topic of another blog post). I then render them as textures, moving, rotating and changing colors randomly, blended together, with a possibility of feedback from previous frame. This mathod may sometimes generate quite interesting images, but it has its own limitations and becomes boring after some time.
Generating some interesting graphics procedurally from scratch is my ultimate goal. But while writing shaders is fun and can give amazing results (as we can see on ShaderToy), it's also the hard way. So to be able to show something interesting, for now I've implemented playback of videos and animated GIFs, using FFmpeg library.
FFmpeg is a free tool that contains its own codecs for various video and audio formats (so it doesn't use the codecs installed in Windows). It is known as a command-line program that can convert about any video format, but it's also a software library that offers this encoding/decoding features to developers. I learned to use this library because I needed to implement video playback for one of my shows.
Later I discovered that it can play animated GIFs as well. This is a great feature, because having hundreds of such GIFs downloaded and being able to switch between them in an instant can make quite interesting visuals. There are many abstract, geometric, psychedelic animations shared all around the Internet, like on Op Art or Fractalgasm Facebook pages. At the same time, possibility to play all popular video formats is much more comfortable than what Resolume offers, which requires converting all the footage to its own codec, called DXDI (by the way, FFmpeg is able to play this as well).
I won't show any source code this time, but if you are a developer and consider implementing support for video playback or encoding, I recommend FFmpeg library. Other option is libVLC - a library behind popular VLC media player, which also has its own set of codecs. I also used it some time ago. Playing anmimated GIF-s is also possible through Windows Imaging Component (WIC), which is part of standard Windows API.
# New Job at AMD
It's already 3 months after I started a new job, so I think I can write something about it. Before that I've spent last 5 years living in Gdańsk and working at Intel. I've been developing shader compiler, which is part of the driver for Intel integrated GPU-s.
Now I moved back to Warsaw and I work at AMD. My position is called Developer Technology Engineer. (Other name is SMTS Software Developer Engineer - Senior Member of Technical Staff. You can find my colleagues on LinkedIn specifying one or the other.) This job is quite different. I'm responsible for cooperation with game development studios to make sure their PC games work well on AMD graphics cards. On the other hand, it's similar in the way that I still work with native C++ code, graphics APIs (like DirectX, Vulkan), shaders, and low-level GPU stuff, yet it's not a work strictly in the game industry - so a very unique position.
# Revision 2017
I just came back from Revision - world's biggest pure demoscene party. It was held in Saarbrücken, Germany. That was first time I attended a demoparty abroad, as I've been going only to the ones in Poland so far, like RiverWash, WeCan, Silly Venture, or AmiWaWa.
I don't like the fact that it happens during Easter, when I usually go visit my parents, but I wanted to see it at least once. Revision was big, with around 700 participants, according to the page with non-mandatory registration - Visitors. There were various kinds of activities - from Seminars to techno party, and of course most importantly - competitions. Revision is a multiplatform demoparty, so there were compo categories dedicated to retro platforms (like Amiga, pixel art or tracker music), as well as modern PCs (like modern graphics, streaming music, PC 4K/8K/64K intro and demo). Entries can be found here: Revision 2017 @ pouet.net.
Many people said that PC 4K Intro category had best quality this year, so it's worth checking. Other than that, productions that I remembered the most are:
Most exciting for me was watching Shader Showdown - a competition where two programmers had to write a pixel shader live on stage, without any documentation or other help, in a time frame of 25 minutes per round. Winner moved on to semifinals and then the final. During each round a DJ was playing some music and its live FFT was available as one of the inputs to the shader. It's amazing to see how good knowledge of programming, graphics and math allows to develop some nice looking visualizations in such a short period of time. I've also heard opinions that watching it gave a good glimpse of how graphics programming looks like and what does it take to make a demo, even for non-technical people.
Here is a gallery of my photos from the event:
# EditorConfig to the Rescue for Multiple Projects
I was once asked to participate in a project where coding standard required to use indentation of 3 spaces - different than what I do normally, when I use 4 spaces. I was searching Internet for answer whether Visual Studio supports per-project settings for this and I've found out that it doesn't, but came across this instead: EditorConfig.
This technology is so simple you can learn all about it in just few minutes, still very useful for cases like mine. You can basically create text file called
.editorconfig in root directory of your project and describe configuration for editors using a simple language. For example:
root = true
charset = utf-8
indent_style = space
indent_size = 3
Of course your text editor must support that. It turns out many of them support this standard natively. Editors I care about have plugins for that available. Unfortunately the one for jEdit doesn't seem to work (I've reported this issue), but the one for Visual Studio works perfectly. Now I could have per-project configuration for text editor, including character set, line ending type, and indentation type (tabs versus spaces and the number of spaces).
# There are Too Many Messaging Apps
I can remember time when Internet was still young and the basic mean of communication was e-mail. Real-time chat was possible through IRC protocol. Later, changes came with the appearance of Instant Messaging (IM) apps, from which ICQ was probably the first. There were many of them, all having similar, basic functionality - list of contacts, seeing their status (available, away, offline) and chat. Gadu-Gadu (renamed later to GG) was local one very popular in Poland, but others were also in use, like AOL, MSN, Jabber.
Over time clients for those networks became bloated with more or less useful features, fancy skins and emoticons, and of course lots of ads - which all consumed additional RAM and CPU time, not to mention just being annoying. Then, something wonderful happened - alternative clients started to appear. Whether based on open protocols (like Jabber) or reverse-engineering others, these multi-communicators were often lightweight, supported alternative platforms (like Pidgin working on Linux) and integrated support for many protocols in a single app, with single list of contacts and unified user interface. My favorite one was Konnekt and later AQQ.
New era started probably with Skype, which for most of us was an introduction to new features like audio- and videochat. Next generation communication apps became more complex, provide more useful features, but at the same time they are even more resource-heavy and (in case of smartphones) drain battery. For some reasons they have no alternative clients (probably because their protocols are more complex, proprietary, and encrypted). And there are many of them. So here I am today, having multiple messaging apps installed on my smartphone. I do most of chatting with my friends via Facebook Messenger these days, but some of them prefer other program, so I ocasionally use also: Skype, Telegram, WhatsApp, Signal, Slack, Google Talk and Hangouts, plus of course the old good phone calls, SMS, and e-mail. What a mess!
At the same time I can see they all start to converge. They look similar as it becomes more and more clear what's the optimal user interface for such app. Features added to some of them quickly appear in others, like end-to-end encryption or (most recently) commenting others' messages with a smiley. So I think the future is once again to have a single messaging app. I only hope it will be just a GUI supporting multiple protocols, and not one of those "Big Brother" corporations (who already know everything about as) dominating all the messaging, just like Gmail dominated market of e-mail servers and readers.
# Vulkan Bits and Pieces: Writing to an Attachment
One of the reasons why new generation graphics APIs (DirectX 12 and Vulkan) are so complicated, is that they have so many levels of indirection in referring to anything. For example, when you render pixels to a color attachment (also known as “render target” in other APIs), the path is as follows:
outColor = vec4(1.0, 0.0, 0.0, 1.0);
layout(location = 0) out vec4 outColor;
VkSubpassDescription::pColorAttachments- member of the structure that describes rendering subpass.
VkAttachmentReference::attachmentprovides another INDEX, this time to an array pointed by
VkRenderPassCreateInfo::pAttachments- member of the structure that describes rendering pass.
VkAttachmentDescriptionprovide just few parameters, like format.
VkFramebufferCreateInfo::pAttachments- member of a structure filled when creating a framebuffer that is going to be pointed by
VkRenderPassBeginInfo::framebufferwhen starting actual execution of the render pass.
VkImageView, so each of them is a VIEW to an image, pointed by
VkImageViewCreateInfo::image- member of a structure used when creating the view.
VkImage) is either obtained from swap chain using function
vkGetSwapchainImagesKHR, or created manually using function
VkDeviceMemory) with function
vkAllocateMemoryand bind its fragment to the image using function
vkBindImageMemory. This is the memory that will be actually written.
Yeah, Vuklan is hard…