Wednesday 24 July 2013

How to view a lib ,exe or dll in windows

We can use dumpbin to view the storage of variables and functions of all these three types of  files lib ,exe and dll.nm is used to show the all function of the dll and lib .nm is not applicable for .exe files.We can use this command in following manner on command prompt:

1)Go to the folder where the the file is available.
2)nm filename.lib



Sunday 21 July 2013

How to use Cmake in windows

firstly run the cmake-gui
a)create a build directory in the src directory
b)put the path to src in first tab
c)put the path  of build directory in build tab
d)click configure
e)click configure again each time you make any change
f)Then click genrerate

Here is the snapshot of the c-make gui:-


Friday 14 June 2013

Different compression techniques

LZ77:-LZ77 algorithms achieve compression by replacing repeated occurrences of data with references to a single copy of that data existing earlier in the input (uncompressed) data stream. A match is encoded by a pair of numbers called a length-distance pair, which is equivalent to the statement "each of the next length characters is equal to the characters exactly distance characters behind it in the uncompressed stream". (The "distance" is sometimes called the "offset" instead.)

LZ78:-LZ78 algorithms achieve compression by replacing repeated occurrences of data with references to a dictionary that is built based on the input data stream. Each dictionary entry is of the form dictionary[...] = {index, character}, where index is the index to a previous dictionary entry, and character is appended to the string represented by dictionary[index]. For example, "abc" would be stored (in reverse order) as follows: dictionary[k] = {j, 'c'}, dictionary[j] = {i, 'b'}, dictionary[i] = {0, 'a'}, where an index of 0 specifies the first character of a string. The algorithm initializes last matching index = 0 and next available index = 1. For each character of the input stream, the dictionary is searched for a match: {last matching index, character}. If a match is found, then last matching index is set to the index of the matching entry, and nothing is output. If a match is not found, then a new dictionary entry is created: dictionary[next available index] = {last matching index, character}, and the algorithm outputs last matching index, followed by character, then resets last matching index = 0 and increments next available index. Once the dictionary is full, no more entries are added. When the end of the input stream is reached, the algorithm outputs last matching index. Note that strings are stored in the dictionary in reverse order, which an LZ78 decoder will have to deal with.

LZW:-Lempel–Ziv–Welch (LZW) is a universal lossless data compression algorithm created by Abraham Lempel, Jacob Ziv, and Terry Welch. It was published by Welch in 1984 as an improved implementation of the LZ78.LZW starts out with a dictionary of 256 characters (in the case of 8 bits) and uses those as the "standard" character set. It then reads data 8 bits at a time (e.g., 't', 'r', etc.) and encodes the data as the number that represents its index in the dictionary. Everytime it comes across a new substring (say, "tr"), it adds it to the dictionary; everytime it comes across a substring it has already seen, it just reads in a new character and concatenates it with the current string to get a new substring. The next time LZW revisits a substring, it will be encoded using a single number. Usually a maximum number of entries (say, 4096) is defined for the dictionary, so that the process doesn't run away with memory. Thus, the codes which are taking place of the substrings in this example are 12 bits long (2^12 = 4096). It is necessary for the codes to be longer in bits than the characters (12 vs. 8 bits), but since many frequently occuring substrings will be replaced by a single code, in the long haul, compression is achieved.

LZSS:-Lempel–Ziv–Storer–Szymanski (LZSS) is a lossless data compression algorithm, a derivative of LZ77, that was created in 1982 by James Storer and Thomas Szymanski. LZSS is a dictionary encoding technique. It attempts to replace a string of symbols with a reference to a dictionary location of the same string.
The main difference between LZ77 and LZSS is that in LZ77 the dictionary reference could actually be longer than the string it was replacing. In LZSS, such references are omitted if the length is less than the "break even" point. Furthermore, LZSS uses one-bit flags to indicate whether the next chunk of data is a literal (byte) or a reference to an offset/length pair.

LZMA:-LZMA is default and general compression method of 7z format. The Lempel–Ziv–Markov chain algorithm (LZMA) is an algorithm used to perform lossless data compression.LZMA compression algorithm is very suitable for embedded applications. LZMA is released under the terms of the GNU LGPL. LZMA is also available under a proprietary license for those who can not use the GNU LGPL in their code. If you want to use LZMA code, you can ask consultations, custom code programming and required developer licenses from page for support: Send message to LZMA developer. Check also information about LZMA SDK.

x264:-x264 is the world’s most popular H.264 video encoder, and is highly optimized with hand written vectorized assembly code.x264 is a free software library for encoding video streams into the H.264/MPEG-4 AVC format. It is released under the terms of the GNU General Public License.

ffmbc:-What we can do with FFmbc:

Import your files in Final Cut Pro, AVID Media Composer, Adobe Premiere
Create XDCAM HD422 files in .mov or .mxf
Create XDCAM IMX/D-10 files in .mov or .mxf
Create AVID DNxHD files in .mov
Create DVCPROHD files in .mov or .mxf
Create ProRes 422 or 4444 files in .mov
Convert V210 Files
Convert HD YUV BT709 to SD BT601 and vice versa
Convert AVCIntra 50 and 100
Convert MPEG-TS files with SMPTE 302M audio
Convert AVCHD files correctly
Convert ProRes 422 and 4444 files
Rewrap IMX/D-10, AVCHD, DVCPROHD to Quicktime for editing in Final Cut Pro
Burn ASS or SRT subtitles files in videos
Merge and split your audio tracks
Create Quicktime files containing time code tracks
Color conversion from HD to SD
Read timecode tracks from MXF, Quicktime
Creating audio files (mp3 and m4a) with cover art
Keep or add covert art when converting your audio files
Faststart MP4 for streaming (replace header in front) automatically

Yasm:-In computing, Yasm is an assembler, a full rewrite of Netwide Assembler (NASM). Yasm can generally be used interchangeably with NASM and supports the x86 and x86-64 architectures. It is licensed under a revision of the BSD licenses. As of 2011 it was developed by Peter Johnson and Michael Urman.It can assemble input with both Intel and AT&T (as) syntax;Library interface for compiler developers.

libmp3lame:-"libmp3lame-3.97" is a encoder that enables you to save/encode the file into Mp3 format. You should this download it so as to export a file to Mp3 which is edited in Audacity.


Tuesday 11 June 2013

Preprocessor Operators/Directives/Macros/Pragmas in c

Here are some preprocessor operators/directives/macros in  c

1) PREPROCESSOR OPERATORS

Stringizing operator (#):-Causes the corresponding actual argument to be enclosed in double quotation marks.

charizing Operator (#@):-Causes the corresponding argument to be enclosed in single quotation marks and to be treated as a character (Microsoft Specific).

Token Pasting Operator (##):-Allows tokens used as actual arguments to be concatenated to form other tokens.

DEFINED operator:-Simplifies the writing of compound expressions in certain macro directives.



2) PREPROCESSOR DIRECTIVES

#                 (NULL DIRECTIVE)
----------------------------------------------------------------------------------------------------------------------------------
#include

#if
#else
#define

Example:-

#include<stdio.h>
#include<conio.h>
#define DLEVEL 1

#if DLEVEL > 5
    #define SIGNAL  1 //this is disable
   
#else
    #define SIGNAL  0  //////////this is enable
  
#endif

void main ()
{

printf("Hi\n");
_getch();
}

------------------------------------------------------------------------------------------------------------
#endif
#elif

Example:-

#include<stdio.h>
#include<conio.h>
#define DLEVEL 1

#if DLEVEL == 0
    #define STACK 0
#elif DLEVEL == 1
    #define STACK 100 //////////only this is enable ,rest of all are disable
#elif DLEVEL > 5
    #define STACK 300
#else
    #define STACK 200
#endif

void main ()
{

printf("Hi\n");
_getch();
}

------------------------------------------------------------------------------------------------------------

#ifdef
#ifndef
#undef

Example:-

#include<stdio.h>
#include<conio.h>
#define DLEVEL 1
#undef DLEVEL ////undefine the DLEVEL


#ifdef DLEVEL
#define SIGNAL //////this is disable
#endif
#ifndef DLEVEL
#define final     //////////this is enable
#endif
void main ()
{

printf("Hi\n");
_getch();
}


-----------------------------------------------------------------------------------------------------------
#line:-The #line directive tells the preprocessor to change the compiler's internally stored line number and filename to a given line number and filename.

#line digit-sequence ["filename"]
#using:-Imports metadata into a program compiled with /clr.

#using file [as_friend]

#import:-Used to incorporate information from a type library. The content of the type library is converted into C++ classes, mostly describing the COM interfaces.

#error:-Error directives produce compiler-time error messages.

Example:-


#include<stdio.h>
#include<conio.h>
#define DLEVEL 1

#undef DLEVEL

#ifndef DLEVEL
#error DLEVEL is not defined
#endif

void main ()
{

printf("Hi\n");
_getch();
}

When we compile this program apart from an intellisense error it displays a compilation error which shows following message:-

error C1189: #error :  DLEVEL is not defined

3) PREDEFINED MACROS

__DATE__:-The compilation date of the current source file. The date is a string literal of the form Mmm dd yyyy. The month name Mmm is the same as for dates generated by the library function asctime declared in TIME.H.

__FILE__:-It returns the name of the current source file.

__LINE__:-It returns the line number in the current source file .

Here is an use of __FILE__ and __LINE__ where we want to know in which file the error occurs and at which line so we use the following syntax.


#define CudaCheckError(cudaStatus) if (cudaStatus != cudaSuccess) {printf("\n%s\t%s\t%d", cudaGetErrorString(cudaGetLastError()),__FILE__,__LINE__);_getch();}

It returns the cuda error was which type ,in which file and in that file at which line.


__TIME__:-The most recent compilation time of the current source file. The time is a string literal of the form hh:mm:ss.

__TIMESTAMP__:-The date and time of the last modification of the current source file, expressed as a string literal in the form Ddd Mmm Date hh:mm:ss yyyy, where Ddd is the abbreviated day of the week and Date is an integer from 1 to 31.


_FUNCTION_:-Valid only within a function and returns the undecorated name of the enclosing function (as a string). 

_cplusplus:-Defined for C++ programs only.

_WIN32:-Defined for applications for Win32 and Win64. Always defined.

_WIN64:-Defined for applications for Win64.

_OPENMP:-Defined when compiling with /openmp, returns an integer representing the date of the OpenMP specification implemented by Visual C++.
// _OPENMP_dir.cpp
// compile with: /openmp 
#include <stdio.h> 
int main() {
   printf("%d\n", _OPENMP);
}


_DEBUG:-Defined when compiling with /LDd, /MDd, and /MTd.

_DLL:-Defined when /MD or /MDd (Multithread DLL) is specified.

_MT:-Defined when /MD or /MDd (Multithreaded DLL) or /MT or /MTd (Multithreaded) is specified.

4) PRAGMA DIRECTIVES

#pragma omp:-It takes one or more OpenMP directives, along with any optional directive clauses.

#pragma omp directive

#pragma pack:-Specifies packing alignment for structure, union, and class members.

#pragma pack( [ show ] | [ push | pop ] [, identifier ] , n  )
-----------------------------------------------------------------------------------------------------------------------------#pragma region:-lets you specify a block of code that you can expand or collapse when using the outlining feature of the Visual Studio Code Editor.

#pragma endregion:-#pragma endregion marks the end of a #pragma region block.

A #region block must be terminated with #pragma endregion.


#pragma region name
#pragma endregion comment

Parameters:-
comment(optional)
A comment that will display in the code editor.
name(optional)
The name of the region. This name will display in the code editor.

------------------------------------------------------------------------------------------------------------------------------

#pragma auto_inline:-Excludes any functions defined within the range where off is specified from being considered as candidates for automatic inline expansion.

#pragma auto_inline( [{on | off}] )

The auto_inline pragma is placed before and immediately after a function defintion.It can not be declare in function definition.The pragma takes effect at the first function defintion after the pragma is seen.

#pragma once:-
Specifies that the file will be included (opened) only once by the compiler when compiling a source code file.This can reduce build times as the compiler will not open and read the file after the first #include of the module.
-- 

Creating XML file in C

We can create a xml file using C language.It is possible to enter values into a xml file through program.We can use fprintf to write into a file.Here is the program for this:-

#include<stdio.h>
#include<conio.h>

#define numcomp 20

void main()
{
int i=0;
    FILE* XMLFile = fopen("output.xml","wb");

fprintf(XMLFile,"<zones count=\"%d\">\n",numcomp);
for(i=1;i<=numcomp;i++)
    {
fprintf(XMLFile,"<zone index=\"%d\">\n",i);
fprintf(XMLFile,"%s","</zone>\n");
    }
fprintf(XMLFile,"</zones>\n",numcomp);
fclose(XMLFile);
printf("file is created");
_getch();
}

Output XML File :-


dll | lib | VS

The .lib in this context is not a static library. It is just a library which loads the dll.

------------------------------
VS project should know the name of .lib and location of .lib
linker ->input->dependencies (.lib)
general -> additional library directory  (directory of .lib)

If .lib is in the same directory as .exe , there is no need to mention directory of lib in VS.

-----------------------------
The dll can be placed in system32 directory.
The dll can be placed in any directory, but that directory should be added in system path.
The dll can be in the same directory as the exe.
---------------------------------

1) .exe and .lib is in same directory and .dll is in 
   a) system32
   b) any directory specified by PATH
   c) same directory as exe and lib

2) .exe is in one directory,  
    .lib is in some other directory (location specified in VS) and 
    .dll is in 
        a) system32
         b) any directory specified by PATH
         c) same directory as exe 
         d) same directory as lib

Setting the PATH environment variable

There are few steps to setting the path of environment variable which are following:-

1)Goto the control panel
2)Control panel -> system
3)System->change settings
4) Change settings -> system properties
5)System properties -> advanced
6)Advanced->  Environment variables
7)Environment variables ->New







We can see here in second image there is two type of environment variables available here .We can edit both of them or create them.Here we need to create a new user variable by clicking new in "user variables for user". Here in the third image we can see there are two text fields  "variable name" and "variable value" .In "variable name  " we assign a name for variable and in "variable path" we assign the path of the variable in system.By clicking ok the user variable is created .With same procedure we can create the system environment variables.