473,787 Members | 2,928 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

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 CheckAudioHeade r(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 1911
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.its c.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 CheckAudioHeade r(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.merke rk(at)dse.nl
Jul 22 '05 #3
Thank you very much~
This function is actually for checking MP3 frame header!
"Peter van Merkerk" <me*****@deadsp am.com> ¦b¶l¥ó
news:c5******** ****@ID-133164.news.uni-berlin.de ¤¤¼¶¼g...
"Skyhorse" <vi*******@cuhk .edu.hk> wrote in message
news:c5******** ***@justice.its c.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 CheckAudioHeade r(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.merke rk(at)dse.nl

Jul 22 '05 #4

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

6
22274
by: Zhang Weiwu | last post by:
Hello. I am working with a php software project, in it (www.egroupware.org) Chinese simplified locate is "zh" while Traditional Chinese "tw". I wish to send correct language attribute in http header, I found "zh" is not standard. I found this line in apache2's default httpd.conf # Simplified Chinese (zh-CN) AddLanguage zh-CN .zh-cn
16
3955
by: Fao, Sean | last post by:
As far as I can tell, the standard has defined three portable return codes from function main() (0, EXIT_SUCCESS, EXIT_FAILURE). Personally, on all platforms I have worked with, EXIT_SUCCESS is, "#define EXIT_SUCCESS 0" and EXIT_FAILURE is, "#define EXIT_FAILURE 1". I have, however, been told that a few platforms define the two in reverse (#define EXIT_SUCCESS 1 and #define EXIT_FAILURE 0). If this is true, I would expect that it would...
16
2700
by: thenightfly | last post by:
Ok, I know all about how binary numbers translate into text characters. My question is what exactly IS a text character? Is it a bitmap?
39
3235
by: windandwaves | last post by:
Hi Folk I have to store up to eight boolean bits of information about an item in my database. e.g. with restaurant drive-through facility yellow windows
9
3270
by: esakal | last post by:
Hello, I'm programming an application based on CAB infrastructure in the client side (c# .net 2005) Since my application must be sequencally, i wrote all the code in the UI thread. my problem occurs when i try to show a progress bar. The screen freezes. I know i'm not the first one to ask about it. but i'm looking
9
2692
by: Cao Yi | last post by:
Hi, here's a fract of codes, and what's the line "scanf("%lf%*", &cvi)" doing? ============================= do { printf("\nCoefficient: "); scanf("%lf%*", &cvi); getchar(); } while (cvi <= 0.0);
1
1441
by: =?Utf-8?B?VGFtbXkgTmVqYWRpYW4=?= | last post by:
Hi, Could someone please et me know how I can convert the below codes from Visual Basic to C# using Visual studio. When each button clicked they create list box and Radio Button. I want to convert those codes into C# doing same action. The codes are: Private Sub bAddListbox_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles bAddListbox.Click Dim lb As New ListBox lb.Height = 75 lb.Width = 70 lb.Items.Add("listbox")
3
8010
by: jake | last post by:
I am new to xml. I have a routine that parses xml files using a regular XmlReader class. Unfortunately, the XmlReader chokes (throws an exception) on character codes such as "&Eacute;". I resorted to streaming the file first and replacing all the character codes with their corresponding characters (copying the file while replacing character codes at the same time) just to get things going. In the case of &Eacute; I replaced it with...
5
13498
by: =?GB2312?B?17/HvyBaaHVvLCBRaWFuZw==?= | last post by:
Hi, I would like to have someone comments on what's the best practice defining error codes in C. Here's what I think: solution A: using enum pros: type safe. better for debug (some debugger will show the name not only the value) cons: enum can not be forward declared which makes all error codes
0
10363
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
0
10169
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
1
10110
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
0
9964
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
0
8993
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
0
5398
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
0
5534
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
4067
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
2
3670
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.