469,272 Members | 1,482 Online
Bytes | Developer Community
New Post

Home Posts Topics Members FAQ

Post your question to a community of 469,272 developers. It's quick & easy.

What are the codes doing?

What are the following codes doing? What are the meaning of & 0xffe00000, &
3, 0xf, 0x3?
Is there any difference between & 3 and & 0x3?

inline BOOL CheckAudioHeader(DWORD dwHeader)
{
if ( (dwHeader & 0xffe00000) != 0xffe00000)
return FALSE;
if (!((dwHeader >> 17) & 3))
return FALSE;
if ( ((dwHeader >> 12) & 0xf) == 0xf)
return FALSE;
if ( ((dwHeader >> 10) & 0x3) == 0x3)
return FALSE;

#ifdef _WIN32_WCE
if ( ((dwHeader >> 12) & 0xf) == 0x0)
return FALSE;
#endif

return TRUE;
}

Thanks
Jul 22 '05 #1
3 1742
Hi!

"Skyhorse" <vi*******@cuhk.edu.hk> writes:
What are the following codes doing? What are the meaning of & 0xffe00000, &
3, 0xf, 0x3?
Is there any difference between & 3 and & 0x3?


These are hexadecimal numbers. 3 == 0x3 but this is no longer true if
numbers get larger than nine. 10 == 0xa, 11 == 0xb, ..., 15 == 0xf,
16 == 0x10, 17 == 0x11, 18 == 0x12, ..., 21 == 0x1f and so on.

Bye,
Chris Dams
Jul 22 '05 #2
"Skyhorse" <vi*******@cuhk.edu.hk> wrote in message
news:c5***********@justice.itsc.cuhk.edu.hk...
What are the following codes doing? What are the meaning of & 0xffe00000, & 3, 0xf, 0x3?
Is there any difference between & 3 and & 0x3?

inline BOOL CheckAudioHeader(DWORD dwHeader)
{
if ( (dwHeader & 0xffe00000) != 0xffe00000)
return FALSE;
if (!((dwHeader >> 17) & 3))
return FALSE;
if ( ((dwHeader >> 12) & 0xf) == 0xf)
return FALSE;
if ( ((dwHeader >> 10) & 0x3) == 0x3)
return FALSE;


Let me guess: a MPEG audio (MP3) header check?
Hexadecimal numbers are prefixed by 0x. And you are right hexadecimal 3
equals decimal 3. 0xffe00000 represents a hexadecimal number with the 11
most significant bits set. The header of every MPEG audio frame always
start with at least 11 ones. So that is what the first if is for. The bit
fields that follow in an MPEG header never have all bits set, and that is
what is being checked in the if's that follow.

--
Peter van Merkerk
peter.van.merkerk(at)dse.nl
Jul 22 '05 #3
Thank you very much~
This function is actually for checking MP3 frame header!
"Peter van Merkerk" <me*****@deadspam.com> bl
news:c5************@ID-133164.news.uni-berlin.de g...
"Skyhorse" <vi*******@cuhk.edu.hk> wrote in message
news:c5***********@justice.itsc.cuhk.edu.hk...
What are the following codes doing? What are the meaning of &
0xffe00000, &
3, 0xf, 0x3?
Is there any difference between & 3 and & 0x3?

inline BOOL CheckAudioHeader(DWORD dwHeader)
{
if ( (dwHeader & 0xffe00000) != 0xffe00000)
return FALSE;
if (!((dwHeader >> 17) & 3))
return FALSE;
if ( ((dwHeader >> 12) & 0xf) == 0xf)
return FALSE;
if ( ((dwHeader >> 10) & 0x3) == 0x3)
return FALSE;


Let me guess: a MPEG audio (MP3) header check?
Hexadecimal numbers are prefixed by 0x. And you are right hexadecimal 3
equals decimal 3. 0xffe00000 represents a hexadecimal number with the 11
most significant bits set. The header of every MPEG audio frame always
start with at least 11 ones. So that is what the first if is for. The bit
fields that follow in an MPEG header never have all bits set, and that is
what is being checked in the if's that follow.

--
Peter van Merkerk
peter.van.merkerk(at)dse.nl

Jul 22 '05 #4

This discussion thread is closed

Replies have been disabled for this discussion.

Similar topics

16 posts views Thread by Fao, Sean | last post: by
16 posts views Thread by thenightfly | last post: by
39 posts views Thread by windandwaves | last post: by
9 posts views Thread by Cao Yi | last post: by
1 post views Thread by =?Utf-8?B?VGFtbXkgTmVqYWRpYW4=?= | last post: by
5 posts views Thread by =?GB2312?B?17/HvyBaaHVvLCBRaWFuZw==?= | last post: by
1 post views Thread by CARIGAR | last post: by
reply views Thread by zhoujie | last post: by
reply views Thread by suresh191 | last post: by
By using this site, you agree to our Privacy Policy and Terms of Use.