On 11/4/2012 6:10 AM, Thomas Richter wrote:
> Am 03.11.2012 20:20, schrieb BGB:
>
>> > The codestream syntax is different, but the philosophy is pretty close
>> > to JPEG plus motion compensation. It is a simple DCT based video
>> codec.
>> >
>>
>> yes, but it is apparently confined to specific resolutions (CIF and
>> QCIF).
>
> Yes, that goes for many video codecs, but again, nevermind about this.
> I'm not talking about this specific codec, but the world of video
> compression in general. HEVC, for example, is very flexible in the
> resolutions it supports.
>
> My question would really be: Why invest time into that given that many
> video codecs already exist and are strong in the market?
>
basically, just hacking something onto JPEG requires writing less code,
and not depending on OS-specific codec mechanisms, and doesn't require
redesigning existing features to fit onto a new bitstream.
JPEG pretty much supports any resolution up to around 65535 x 65535
apparently, but for images this size and larger, it may well be more
efficient to split the image up into tiles or similar.
(meanwhile, my 3D engine doesn't currently support any textures larger
than around 4096x4096 anyways...).
it also potentially allows the same codec code for both still-image and
video compression.
also, as-is, AFAICT there shouldn't be any patent issues with this codec.
>> most tend to lack support for things like user-defined layers or
>> metadata, ...
>
> HEVC certainly does.
>
but, I meant simpler (and not patent-encumbered) ones, like MPEG-1 and
friends.
it is like, originally there was JPEG, and it was fairly straightforward
and generic, albeit maybe a little over-engineered in some areas (hence,
why there was JFIF).
in this case, the imagined codec is basically a JFIF-like subset of
JPEG, but with an optional feature to enable motion vectors and residual
encoding (at the cost of breaking decoder compatibility).
as-is, if residual encoding is used without motion vectors, it would
simply encode a delta of the images (and if residual encoding is not
enabled, it will simply store the frame as a raw image).
basically, as-is, most of the stuff about how the image is encoded
depends on various factors, namely which buffer-arrays and flags were
passed into the encoder, ...
say, buffer arrays:
RGBA;
Normal XYZ;
Luma, Specular, ...
some flags indicate the color-transform and whether or not to use RDCT,
or encode the quality-level for lossy images (the quality level is in
the low 8-bits, and the remaining bits are encoder flags).
probably another flag for "enable residual encoding" could exist
(probably controlled via a command-line option to the "AVI compiler").
things like whether or not to encode an alpha-channel are detected
automatically (based on whether or not all of the alpha values are 255,
in which case it will conclude that no alpha channel is needed).
note that images would probably be delta'ed against other images in the
same layer, like it wouldn't make much sense to delta the normal-map
against the RGB layer or the RGB-layer by the normal map.
in the informal spec written thus far, the video-header adds a "layer
ID" field, which is basically an 8-bit value which indicates which
"layer" contains the relevant I-Frame (or, alternatively, where the
contents of the current I-Frame are supposed to go to). theoretically, I
could use a 16-bit value "just in case", but this would probably be
overkill (and I would likely restrict it to a subset of this range anyways).
any existing videos will be essentially "grandfathered in" in such a
system as well.
>> > And what would be the use case for that, given that H.261 and an
>> entire
>> > family of considerably more powerful video codecs already exist?
>>
>> mostly for animated textures and similar.
>
> First question: Why isn't that covered by with the existing codecs?
> Second question: If it is just texture, why a video codec?
>
because it is an *animated* texture.
an animated texture may have multiple frames which have a fair amount of
nearly-identical areas, or border on being a short video sequence, so
there is something to gain from supporting residual encoding.
granted, since most of these sequences are typically very short, the
existence or absence of motion compensation is not really a deal-breaker.
but, in any case, with a several MB animated texture file, if a person
can shave it down by say, 500kB, this may still be a worthwhile gain.
an animated texture is sort of in the middle ground between a normal
texture-map and a video file, generally because:
it is mapped directly onto OpenGL textures;
it is typically decoded/streamed in real-time into said textures (and
generally looped).
(these textures are then generally/presumably used on pieces of scene
geometry).
likewise, for animated textures, compatibility with other applications
is a lower priority, partly as the programs which would actually be
convenient to be able to interact with (like GIMP or Paint.NET) don't
really understand animated images anyways, and apps which understand
video (like video-editors or media players) have little real use-case
for animated textures (they would only display a small amount of the
information anyways, just looking like a very short video clip).
otherwise, it would require a very specialized video player or editor to
make much use of the data contained in an animated texture anyways (so
basically, its main use-case is more for the original development to be
done using a bunch of PNGs and text-files, and then "compiling" these
into the animated texture file).
theoretically, there could be a case for "decompiling" an animated
texture into a collection of text files and PNGs again, but as-of-yet, I
haven't ran into a use-case for needing to do this.
having a thumbnail could be helpful sometimes, but this isn't really
critical.
basically, it is sort of like the use-case for the id Software RoQ
format, except that this codec would support more layers (unlike RoQ
which was pretty much RGB only, and otherwise very limited).
I didn't use RoQ personally, as I didn't want to have to try to figure
it out enough to write my own decoder for it (the only decoders for it
commonly available are GPL, which is sort of a no-go in my case).
http://www.modwiki.net/wiki/ROQ_%28file_format%29
>> the main reason for adding motion compensation would be hopefully to be
>> able to make these sequences take up a little less space, and whether or
>> not it is applied to the Base-RGB layer can left as an open question.
>
> What about "use a video codec"? I just don't see the problem you have
> with existing technology?
>
the main issue is mostly not wanting to depend on other peoples' code,
or having to significantly change the existing code (because, well,
there is hardly an unlimited amount of time to invest into these things).
I also have a fair amount of code which works on a specific set of
extensions (basically, MJPEG AVIs with a bunch of extension features
into the image).
staying with the same basic technology avoids needing to significantly
alter the existing code (although, enabling the motion compensation may
imply also changing the AVI FOURCC to avoid confusing existing decoders).
(I may or may not consider eventually dropping the AVI containers, more
likely this would be for a more customized container format, possibly a
little more like SWF or similar).
note that the 3D engine also makes heavy use of PNG-based textures, but
these are generally loaded via an alternate code-path (and the use cases
for PNG, standard JPEG, and "BGBTech JPEG", are different...).
admittedly, yeah, some of this may be a bit jurry-rigged, like the code
for decoding and playing back the videos is sort of tangled up with
OpenGL calls, and with the JPEG codec internals, but whatever sometimes...
sometimes, there are things to be said from having lower levels of
abstraction as well.