Different type of Makefile
- Default/legacy make file -> GNU Makefile
- Cmake
- Autotool -> Makefile.am -> Makefile.in
- Linux kernel special Makefile
- Android.mk
Build system/tool
- Ninja and Meson
- Yocto
- Cerbero
C/C++ programming, Linux Programming, Android native application, Embedded systems
The volatile keyword is a type qualifier which tells compiler to not to optimize/cache any operation with these variable.
Value of this variable can change between two read or two write by external forces or event
The volatile keyword is mainly used where we directly deal with GPIO, interrupt or flag Register. It is also used with a global variable or buffer which shared between the threads.
- Write a program to Draw circle
- Write a program for Matrix multiplication
- Write a program to reverse bitstream. (bit by bit reverse in 1 byte of data)
https://stackoverflow.com/questions/22004690/print-odd-and-even-numbers-using-2-threads-using-mutex-in-c
#define my_sizeof(type) (char *)(&type+1)-(char*)(&type)
Little and big endian are two ways of storing multibyte data-types.
Suppose integer is stored as 4 bytes then a variable x with value 0x01234567 will be stored as following in Big Endian
Big Endian:
01, 23, 45, 67
0x100 0x101 0x102 0x103
Little Endian
67, 45, 23, 01
0x100 0x101 0x102 0x103
Sample C program to check this.,
int main() { unsigned int i = 1; char *c = (char*)&i; if (*c) cout<<"Little endian"; else cout<<"Big endian"; return 0; } const int* ptr;
is a pointer to constant (content). You are allowed to modify the pointer. e.g. ptr = NULL, ptr++, but modification of the content is not possible.
int * const ptr;
Is a constant pointer. The opposite is possible. You are not allowed to modify the pointer, but you are allowed to modify what it points to e.g. *ptr += 5.
1-D and 2-D array pointers.
// Pointer to an integer
int *p;
// Pointer to an array of 5 integers
int (*ptr)[5];
// Pointer to an array of 5x2
int (*ptr1)[5][2];
int arr[5];
int arr1[5][2];
// Points to 0th element of the arr.
p = arr;
// Points to the whole array arr.
ptr = &arr;
// Points to the while 5x2 array
ptr1 = &arry1;
==========
Function Pointers
void fun(int a)
{
printf("Value of a is %d\n", a);
}
int main()
{
// fun_ptr is a pointer to function fun()
void (*fun_ptr)(int) = &fun;
// OR
void (*fun_ptr)(int) = fun;
/* The above line is equivalent of following two
void (*fun_ptr)(int);
fun_ptr = &fun;
*/
// Invoking fun() using fun_ptr
(*fun_ptr)(10);
//OR
fun_ptr(10);
return 0;
}
color space system.
-> RGB
-> YCbCR (YPbPr in analog system)
-> HSB hue satuaration brightness
-> CMYK
=================
4:2:2 (Horizontal sub sampling) 8 bytes used for 4 pixel.
Y Y Y Y
cb cb
cr cr
4:1:1 (Horizontal sub sampling) 6 bytes used for 4 pixel.
Y Y Y Y
cb
cr
4:2:0 (Horizontal + Vertical sub sampling) 6 bytes used for 4 pixel.
y Y
cb,
cr,
y y
================
YUV formats (8 bits only)
1) Planner
-> All Y would be in one array/plane, then all U would be in one array/plane and then V would be in once array/plane
-> Here all 3 array can be at different offset in single buffer also.
I420, I422
-> reversed planners
YV12 is exactly like I420, but the order of the U and V planes is reversed
2) Semi Planner
-> Semi planar formats have two planes instead of three, one plane for luminance, and one plane for both chrominance components.
-> NV12, NV16
-> reveresed semi planners
-> NV21, NV61
3)Packed formats
In packed formats, you usually have only one plane. (This is something like RGB)
( packet formats cannot normally deal with vertical sub-sampling.)
UYVY or Y422
YUY2 or V422 (reversed format)
Gstreamer state handling
NULL -> Default state. NO resources are allocated in this state.
READY -> Element has allocated its all global resources. Element open the devices allocate the buffers. But stream is still not openened. NO stream specific allocation.
PAUSED -> Elemened has openned the stream but its actively processing stream. Audio/Video o/p pushed into buffers and queued to play it right after state change. Video sink element display first frame and paused.
Playing -> same as paused except clock is running and data is being processing
OMX-IL state
Loaded:
WaitingForResources
IDLE
Executiting
paused
There are couple of well known methods to communicate from user space to kernel space.
Below are some good points about inline function to keep in mind.
inline funcation are good than macro becuase, macro does not perform any type checking/usual error checking while compilation.
Macro are like find and replace while preprocessing steps.
While Linux interrupt handling, To perform "bottom half", There are couple of methods used as below.
DECLARE_TASKLET(name, func, data) or can also be allocated dynamically and initialized at runtime using tasklet_init(name, func, data)Tasklets are actually run from a softirqHere is the brief summary of detail C program compilation process.
Source File (.c file)
|
Preprocessing (Include all header file code in main source code, Expand all Macro and #define) (.i file)
|
Compilation (Convert the program into assembly code) (.s file)
|
Assembling (Convert the assembly code into machine code called object) (.obj or .o file)
|
Linking (Links different object file/module and system library together and create final executable object code) (.exe or .out file)