By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
440,320 Members | 2,109 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 440,320 IT Pros & Developers. It's quick & easy.

What are the codes doing?

P: n/a
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
Share this Question
Share on Google+
3 Replies


P: n/a
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

P: n/a
"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

P: n/a
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.