Skip to main content

Posts

Showing posts with the label C++

Decoding JPEG image file using libavcodec

I got a chance to work on a video encoding application that decodes series of jpeg files and convert them into ogg theora video file. I used the infamous libavcodec library that is used in FFMPEG . I decided to write blog posts explaining how I decode jpeg images and convert them into ogg video file. This is the first part and in this I will explain how to decode jpeg images using libavcodec. To learn how to write decoded images as a ogg video file please read http://random-stuff-mine.blogspot.com/2017/07/encoding-raw-images-to-ogg-theora-video.html Before reading this blog post you must be aware of using and setting up libavcodec. I highly recommend this tutorial to get basics of using libavcodec http://www.ffmpeg.org/doxygen/0.6/api-example_8c-source.html Allocating input format context We will first allocate input format for reading the file. We will use avformat_open_input function that will allocate AVFormatContext structure passed to it , the function detects input typ...

Understanding pointers in C Part1 - Basics of Pointer

Pointers are one of the most difficult concepts in C language to grasp. Many programmers get confused in pointers.I am one of them. I decided to write series of blog posts covering basic to advance concepts of pointers. This is the first part to understand very basic of pointer that what pointer actually is and how we can store/access data through pointers. Put simply A pointer is a variable that contains the address of a variable Lets try to understand pointers using some code. int x=3; int *ptrToX; ptrToX=&x;  In above code we simply took a variable x of type int . Then we define a pointer ( * denotes that variable is a pointer and it is known as indirection or dereferencing operator ) ptrToX  of type int and assigned address of x to ptrToX . Now ptrToX points to x . Note that ptrToX do not contain value of x ( i.e 3 ) instead it contains memory address of x . Now we can access and manipulate value of x using ptrToX . Accessing value of a variable ...

C Windows API - Enumerate Windows and some manipulation

Few years back I wrote a program in C language using Windows API that displays the list of all "Windows" opened on my PC (Windows) and I can make any of them visible/invisible. I decided to share the part of code which Enumerate windows, find a window and make them visible/invisible. Enumerating Windows Windows API provide a function EnumWindows  which takes a pointer to Callback function which it calls for each window found. Second parameter is a LPARAM which you can use to pass any argument you want, this LPARAM will be passed to our callback function. Here is how to use EnumWindows BOOL isSuccess=EnumWindows(OurAppCallback,(LPARAM)userDefinedVariable); Syntax of callback (OurAppCallback) will be like this BOOL CALLBACK OurAppCallback(HWND h,LPARAM l)  Important Remarks about EnumWindows from MSDN:  The EnumWindows function does not enumerate child windows, with the exception of a few top-level windows owned by the system that have the WS_CHILD style....