Log in

View Full Version : AVIREADFORMAT and colorspace


Cyberia
31st January 2005, 23:04
I am using AVISTREAMREADFORMAT to return the biBitCount parameter for a given avi. This seems to work fine, and always returns a valid value of 12, 16, 24 or 32.

The problem is that it appears to be unreliable.

XVID files seem to be able to return any colorspace (RGB24, YUV2, YV12) I thought all XVID's were YV12? I have seen this for DX50 also.

Is there another way (or another utility) to determine the colorspace of an avi? I would like to be able to cross check my results.

IanB
1st February 2005, 02:47
Cyberia,

Unfortunately there is no way to truely know the encoding technology used inside any AVI codec. The codec's return a preferred generic colour space, which one might expect to be the least amount of work to decode (i.e. fastest), but you are at the mercy of the codec author.

If you really need to know, I guess you could request RGB output, convert it to YUV24 and do some profile analysis of how the UV data changes.

Have a play with the old Indeo codecs, internally they are reputed to be (9,1,1), [3x3]chroma and (8,2,1), [4x2]chroma.

Maybe someone else has some good lateral thinking on how to get this info.

IanB

Wilbert
1st February 2005, 10:09
Have a play with the old Indeo codecs, internally they are reputed to be (9,1,1), [3x3]chroma and (8,2,1), [4x2]chroma.
? Indeo is 4:1:0, meaning chroma is shared among 4x4 luma pixels.

I am using AVISTREAMREADFORMAT to return the biBitCount parameter for a given avi. This seems to work fine, and always returns a valid value of 12, 16, 24 or 32.
Isn't this the number of bits of the video that is delivered to VDub. Ie if you feed it with RGB32 and encode it to XviD, it will be 32 bit. Or am I confusing things?

XVID files seem to be able to return any colorspace (RGB24, YUV2, YV12) I thought all XVID's were YV12? I have seen this for DX50 also.
Yup all XviD/DivX5 is YV12 internally.

Cyberia
1st February 2005, 16:43
Originally posted by Wilbert Isn't this the number of bits of the video that is delivered to VDub. Ie if you feed it with RGB32 and encode it to XviD, it will be 32 bit. Or am I confusing things?

Yup all XviD/DivX5 is YV12 internally. [/B]

biBitCount is the number of bits/pixel.

I would think if you encoded anything to XVID, then biBitCount would be 12. If Xvid is YV12 only, then XVID=12 right?

Or are you saying the codec stores it as YV12 internally, but will decode it to whatever the application wants? In which case, biBitCount corresponds to the output colorspace, regardless of internal format?

Wilbert
1st February 2005, 21:20
Or are you saying the codec stores it as YV12 internally, but will decode it to whatever the application wants?
That's true (as long as the corresponding internal conversions are present in the decoder), but it has nothing to do with biBitCount.

I was saying this:

"Isn't this the number of bits/pixel of the video that is delivered to VDub. Ie if you feed it with RGB32 and encode it to XviD, it will be 32 bit."

There should be thread about this in the XviD forum, but I can't find them.

stephanV
1st February 2005, 21:37
What Wilbert says is true, I've tested this using AVIsynth and different compressing modes in VirtualDubMod.

So basically this is the bpp-value of the colorspace the encoder receives.

Cyberia
3rd February 2005, 00:01
So biBitCount indicates the colorspace of the video fed into the encoder. Well, I must be dumb, because I can't imagine how that information would help ANYONE.

Who cares what colorspace it originated as? I want to know what it is right now. That should be YV12.

Why would you want to know what the source CS was? You aren't going to convert it back and suffer another CS conversion (probably not).

Do all codecs behave this way, or is this an XVID quirk?

squid_80
3rd February 2005, 03:30
I think I can remember reading somewhere that this is a virtualdub quirk. It has to put something in biBitCount but it only knows what colorspace it is giving to the encoder (just like you said). It doesn't know what the codec does with it after that.

stephanV
3rd February 2005, 10:43
Originally posted by Cyberia
So biBitCount indicates the colorspace of the video fed into the encoder. Well, I must be dumb, because I can't imagine how that information would help ANYONE.
Neither can I, but on the other hand I'm not sure how an encoding application could know what a codec uses internally.

Other than that:

What does 24 really mean? or 16? or 12? Is there only one colorspace with a average bpp-value of 12? (I'm not even sure if 12 is an allowed value for biBitcount) Even if you got it correct it would still leave you a few guesses.

I think that the value only has a purpose if you are storing uncompressed data in AVI.


Do all codecs behave this way, or is this an XVID quirk?
At least VirtualDub behaves this way, i cannot give guarantees for other encoding apps.