OB.DAAC Logo
NASA Logo
Ocean Color Science Software

ocssw V2022
extr_bits.c File Reference
#include "PGS_MODIS_35005.h"
#include "PGS_SMF.h"
#include "hdfi.h"
#include "L1A_prototype.h"
Include dependency graph for extr_bits.c:

Go to the source code of this file.

Functions

uint32 extr_bits (uint8 *a, int start_bit, int start_byte, int num_bits)
 

Function Documentation

◆ extr_bits()

uint32 extr_bits ( uint8 *  a,
int  start_bit,
int  start_byte,
int  num_bits 
)

Not able to extract that many bits, so just return error msg

Calculate the end byte and bit

Build the extracted number

Start byte


shift right the hexadecimal constant "Oxff"

(start_bit) times and AND it to a[start_byte],

then ret = the result

Middle byte


shift left ret 8 times and OR it with a[i] and

ret = the result

End byte


shift right a[end_byte] (7 - end_bit) times and

AND it with the hexadecimal constant "0xff",

then OR this with the result of ret shifted

left (end_bit + 1) times, then ret = the result

shift right ret (7 - end_bit) times andi,

ret = the result

Definition at line 6 of file extr_bits.c.