Werbung: SecurityConsole.de verwaltet Ihre Computer mit Security Essentails aus der Cloud!
30 Tage kostenfrei testen und 20% Rabatt für Ihre Bestellung mit Promocode: WBF2685582
(Promocode gültig bis 31.12.2011)

Group:  English: Entertainment » microsoft.public.windowsmedia.sdk
Thread: ASF - Video Stream with 8 bpp

HTVi
TV Discussion Newsgroups

ASF - Video Stream with 8 bpp
Damiox 12/23/2008 4:48:01 AM
Hello guys,

I'm creating ASF files with a Video Stream of 8bpp, and a third party
codec that was created by my team.

When I create the Video Stream, there is no error but then the ASF Viewer
shows me that the WMSDK is adding an "Extra Data Size" of 1024 bytes which
are garbage bytes (the information of the audio streams).

If I change from 8bpp to 16bpp, this behaviour disappears (I meant, there
is no an "Extra Data Size" field). I think that this 1024 extra bytes are
related to the palette, but why do I have to add information of a palette? I
don't know what palette it will be used :/, this information changes for each
image that I create and that I introduce into the ASF files.

So, where do I need to reserve these bytes? and what is the reason to do
that?

Regards
Damiox


Re: ASF - Video Stream with 8 bpp
"Alessandro Angeli" <nobody[ at ]nowhere.in.the.net> 12/23/2008 6:35:15 AM
From: "Damiox"

[Quoted Text]
> If I change from 8bpp to 16bpp, this behaviour
> disappears (I meant, there is no an "Extra Data Size"
> field). I think that this 1024 extra bytes are related to
> the palette, but why do I have to add information of a
> palette? I don't know what palette it will be used :/,
> this information changes for each image that I create and
> that I introduce into the ASF files.
>
> So, where do I need to reserve these bytes? and what is
> the reason to do that?

That depends on what you specifying in the BITMAPINFOHEADER.
Are you storing pre-compressed data? What are the exact
contents of the input and profile WM_MEDIA_TYPE's, including
the pbFormat block?



--
// Alessandro Angeli
// MVP :: DirectShow / MediaFoundation
// mvpnews at riseoftheants dot com
// http://www.riseoftheants.com/mmx/faq.htm


Re: ASF - Video Stream with 8 bpp
Damiox 12/23/2008 1:27:01 PM
Thanks for your reply.
Here is you asked for.

// What is the size of the WM_MEDIA_TYPE structure ?
hr = mediaProps->GetMediaType(NULL, &cbMediaType);

WM_MEDIA_TYPE* mediaType = (WM_MEDIA_TYPE*) new BYTE[cbMediaType];

// We obtain the actual media type.
hr = mediaProps->GetMediaType(mediaType, &cbMediaType);

WMVIDEOINFOHEADER *dataVideo = (WMVIDEOINFOHEADER*)(mediaType->pbFormat);

unsigned int Width = GetSystemMetrics(SM_CXSCREEN);
unsigned int Height = GetSystemMetrics(SM_CYSCREEN);
unsigned int Fps = 3
unsigned int BitCount = 8

WMVIDEOINFOHEADER {

BITMAPINFOHEADER bmiHeader {

DWORD biSize = sizeof(BITMAPINFOHEADER)
LONG biWidth = Width
LONG biHeight = Height
WORD biPlanes = 1
WORD biBitCount = BitCount
DWORD biCompression = mmioFOURCC('E', 'Y', 'E', 'Z')
DWORD biSizeImage = Width * Height
LONG biXPelsPerMeter = 0
LONG biYPelsPerMeter = 0
DWORD biClrUsed = 0
DWORD biClrImportant = 0
}

RECT rcSource = {0, 0, dataVideo->bmiHeader.biWidth,
dataVideo->bmiHeader.biHeight};
RECT rcTarget = {0, 0, dataVideo->bmiHeader.biWidth,
dataVideo->bmiHeader.biHeight};
DWORD dwBitRate = 1 // I use VBR.
DWORD dwBitErrorRate = 0
LONGLONG AvgTimePerFrame = ((QWORD)1) * 10000 * 1000 / Fps;

}

// We clear the WM_MEDIA_TYPE structure.
memset(mediaType, 0, sizeof(WM_MEDIA_TYPE));

// We build our GUID variable.
GUID myguid;

myguid = WMMEDIASUBTYPE_Base;
myguid.Data1 = (DWORD)mmioFOURCC('E','Y','E','Z');

mediaType->majortype = WMMEDIATYPE_Video;
mediaType->subtype = myguid;
mediaType->formattype = WMFORMAT_VideoInfo;

mediaType->pbFormat = (BYTE*)dataVideo;
mediaType->cbFormat = sizeof(WMVIDEOINFOHEADER);





"Alessandro Angeli" wrote:

[Quoted Text]
> From: "Damiox"
>
> > If I change from 8bpp to 16bpp, this behaviour
> > disappears (I meant, there is no an "Extra Data Size"
> > field). I think that this 1024 extra bytes are related to
> > the palette, but why do I have to add information of a
> > palette? I don't know what palette it will be used :/,
> > this information changes for each image that I create and
> > that I introduce into the ASF files.
> >
> > So, where do I need to reserve these bytes? and what is
> > the reason to do that?
>
> That depends on what you specifying in the BITMAPINFOHEADER.
> Are you storing pre-compressed data? What are the exact
> contents of the input and profile WM_MEDIA_TYPE's, including
> the pbFormat block?
>
>
>
> --
> // Alessandro Angeli
> // MVP :: DirectShow / MediaFoundation
> // mvpnews at riseoftheants dot com
> // http://www.riseoftheants.com/mmx/faq.htm
>
>
>
Re: ASF - Video Stream with 8 bpp
Damiox 12/23/2008 2:35:01 PM
Obviously this is a pseudo-code.

"Damiox" wrote:

[Quoted Text]
> Thanks for your reply.
> Here is you asked for.
>
> // What is the size of the WM_MEDIA_TYPE structure ?
> hr = mediaProps->GetMediaType(NULL, &cbMediaType);
>
> WM_MEDIA_TYPE* mediaType = (WM_MEDIA_TYPE*) new BYTE[cbMediaType];
>
> // We obtain the actual media type.
> hr = mediaProps->GetMediaType(mediaType, &cbMediaType);
>
> WMVIDEOINFOHEADER *dataVideo = (WMVIDEOINFOHEADER*)(mediaType->pbFormat);
>
> unsigned int Width = GetSystemMetrics(SM_CXSCREEN);
> unsigned int Height = GetSystemMetrics(SM_CYSCREEN);
> unsigned int Fps = 3
> unsigned int BitCount = 8
>
> WMVIDEOINFOHEADER {
>
> BITMAPINFOHEADER bmiHeader {
>
> DWORD biSize = sizeof(BITMAPINFOHEADER)
> LONG biWidth = Width
> LONG biHeight = Height
> WORD biPlanes = 1
> WORD biBitCount = BitCount
> DWORD biCompression = mmioFOURCC('E', 'Y', 'E', 'Z')
> DWORD biSizeImage = Width * Height
> LONG biXPelsPerMeter = 0
> LONG biYPelsPerMeter = 0
> DWORD biClrUsed = 0
> DWORD biClrImportant = 0
> }
>
> RECT rcSource = {0, 0, dataVideo->bmiHeader.biWidth,
> dataVideo->bmiHeader.biHeight};
> RECT rcTarget = {0, 0, dataVideo->bmiHeader.biWidth,
> dataVideo->bmiHeader.biHeight};
> DWORD dwBitRate = 1 // I use VBR.
> DWORD dwBitErrorRate = 0
> LONGLONG AvgTimePerFrame = ((QWORD)1) * 10000 * 1000 / Fps;
>
> }
>
> // We clear the WM_MEDIA_TYPE structure.
> memset(mediaType, 0, sizeof(WM_MEDIA_TYPE));
>
> // We build our GUID variable.
> GUID myguid;
>
> myguid = WMMEDIASUBTYPE_Base;
> myguid.Data1 = (DWORD)mmioFOURCC('E','Y','E','Z');
>
> mediaType->majortype = WMMEDIATYPE_Video;
> mediaType->subtype = myguid;
> mediaType->formattype = WMFORMAT_VideoInfo;
>
> mediaType->pbFormat = (BYTE*)dataVideo;
> mediaType->cbFormat = sizeof(WMVIDEOINFOHEADER);
>
>
>
>
>
> "Alessandro Angeli" wrote:
>
> > From: "Damiox"
> >
> > > If I change from 8bpp to 16bpp, this behaviour
> > > disappears (I meant, there is no an "Extra Data Size"
> > > field). I think that this 1024 extra bytes are related to
> > > the palette, but why do I have to add information of a
> > > palette? I don't know what palette it will be used :/,
> > > this information changes for each image that I create and
> > > that I introduce into the ASF files.
> > >
> > > So, where do I need to reserve these bytes? and what is
> > > the reason to do that?
> >
> > That depends on what you specifying in the BITMAPINFOHEADER.
> > Are you storing pre-compressed data? What are the exact
> > contents of the input and profile WM_MEDIA_TYPE's, including
> > the pbFormat block?
> >
> >
> >
> > --
> > // Alessandro Angeli
> > // MVP :: DirectShow / MediaFoundation
> > // mvpnews at riseoftheants dot com
> > // http://www.riseoftheants.com/mmx/faq.htm
> >
> >
> >
Re: ASF - Video Stream with 8 bpp
"Alessandro Angeli" <nobody[ at ]nowhere.in.the.net> 12/26/2008 2:42:08 AM
From: "Damiox"

[Quoted Text]
> Thanks for your reply.
> Here is you asked for.
[...]

Sorry for the late reply. Here is your answer:

http://msdn.microsoft.com/en-us/library/ms779712(VS.85).aspx
<<<If biCompression is a video FOURCC, the presence of a
color table is implied by the video format. You should not
assume that a color table exists when the bit depth is 8 bpp
or less. However, some legacy components might assume that a
color table is present. Therefore, if you are allocating a
BITMAPINFOHEADER structure, it is recommended to allocate
space for a color table when the bit depth is 8 bpp or less,
even if the color table is not used.>>>


--
// Alessandro Angeli
// MVP :: DirectShow / MediaFoundation
// mvpnews at riseoftheants dot com
// http://www.riseoftheants.com/mmx/faq.htm



Re: ASF - Video Stream with 8 bpp
Damiox 12/26/2008 5:42:00 AM
Ok, got it. I'm using WMSDK 9.5.

The problem is the following:

1) First test.

a) The WMVIDEOINFOHEADER does not have a pointer to BITMAPINFO (just
BITMAPINFOHEADER, and it is not a pointer), so... the pointer of the
structure WMVIDEOINFOHEADER needs to be reserved with a total of bytes
according to: sizeof(WMVIDEOHEADER) + 1024 (color palette).
As I don't use this palette (due to the palette is introduced in each
image), I filled with zero. Then I link this pointer with the field pbFormat
of the WM_MEDIA_TYPE structure, and I set the cbFormat field as
sizeof(WMVIDEOHEADER).

b) By generating the ASF file, the "Extra data size" shows me 1024, with the
same garbage info that I told you in the previous posts. So, it's the same.

----------------------------------------

2) Second test.
a) I change the cbFormat field and I put the value: sizeof(WMVIDEOHEADER) +
1024.
b) By generating the ASF file, the "Extra data size" shows me 2048, with the
2048 bytes filled with zero.

So... I don't understand this behaviour of the WMSDK. Why 2048?

Is it OK to have the 2048 bytes in the "Extra data size" ?


"Alessandro Angeli" wrote:

[Quoted Text]
> Community Message Not Available
Re: ASF - Video Stream with 8 bpp
"Alessandro Angeli" <nobody[ at ]nowhere.in.the.net> 12/26/2008 9:52:31 PM
From: "Damiox"

[Quoted Text]
> a) The WMVIDEOINFOHEADER does not have a pointer to
> BITMAPINFO (just BITMAPINFOHEADER, and it is not a
> pointer), so... the pointer of the structure
> WMVIDEOINFOHEADER needs to be reserved with a total of
> bytes according to: sizeof(WMVIDEOHEADER) + 1024 (color
> palette).
> As I don't use this palette (due to the palette is
> introduced in each image), I filled with zero. Then I
> link this pointer with the field pbFormat of the
> WM_MEDIA_TYPE structure, and I set the cbFormat field as
> sizeof(WMVIDEOHEADER).

cbFormat must be the size of the whole block you allocated,
otherwise the extra data following the VIDEOINFOHEADER will
not be copied into the profile.

> a) I change the cbFormat field and I put the value:
> sizeof(WMVIDEOHEADER) + 1024.
> b) By generating the ASF file, the "Extra data size"
> shows me 2048, with the 2048 bytes filled with zero.
>
> So... I don't understand this behaviour of the WMSDK. Why
> 2048?

Whar is the value of VIDEOINFOHEADER::bmiHeader.cbSize? Have
you tried setting it to sizeof(BITMAPINFOHEADER) + 1024?

> Is it OK to have the 2048 bytes in the "Extra data size" ?

Since you are not using it, it really doesn't matter.



--
// Alessandro Angeli
// MVP :: DirectShow / MediaFoundation
// mvpnews at riseoftheants dot com
// http://www.riseoftheants.com/mmx/faq.htm


Home | Search | Terms | Imprint Contact
Newsgroups Reader - provided by WiredBox.Net
Suche nach Orten, Städten, Postleitzahlen, Vorwahlen, Kfz-Kennzeichen