Archive for May, 2010

May 24th, 2010

Overview of WebM Open Video Format and VP8 High-Quality Video Codec

WebM HD Video Example VP8 HTML 5

WebM HD Video Example VP8 HTML 5

The purpose of this post is to provide general information about the new webm open video format and VP8 High-Quality Video Codec.


Define webm

WebM is an open, royalty-free media file format designed for the web. WebM files consist of video streams compressed with the VP8 video codec and audio streams compressed with the Vorbis audio codec. The WebM file structure is based on the Matroska media container.


Define VP8

VP8 is a highly efficient video compression technology that was developed by On2 Technologies. Google acquired On2 in February, 2010.


webm Browser Support

Google Chrome — Currently only available in Chromium
Firefox — Grab a Firefox WebM nightly build
Opera — Opera 10.54 has WebM support


HTML 5 webm Implementation

<video src="video_name.webm" controls="controls">
Your browser does not support the video tag!
</video>


webm VP8 HTML 5 DEMO

Demo Page
Download Sample webm vp8 video


How To Build FFMpeg for Windows and Linux with VP8 WebM Guides

Build FFMpeg for Linux with VP8 WebM support
Build FFMpeg for Windows with VP8 WebM support


Thanks for reading!

May 8th, 2010

C++ Standard Template Library (STL) vector class example

This C++ program illustrates how to use the Standard Template Library (STL) vector class


#include < vector >
#include < iostream >
using namespace std;

int main()
{
    // vector is a template, the <int> means it is a vector of ints
    vector<int> numbers;  

    // push_back() puts a new value at the end (or back) of the vector
    for (int i = 0; i < 10; i++)
        numbers.push_back(i);

    cout << "print all elements in vector" << endl;

    // This is one way to iterate through a vector and print all the values
    for (int i = 0; i < numbers.size(); i++)
        cout << numbers[i] << endl;

    // This is the preferred way to iterate through a vector

    // an iterator is a special object used to keep track of internal structures
    vector<int>::iterator iter;
    for (iter = numbers.begin(); iter != numbers.end(); iter++)
        cout << *iter << endl;

    cout << "now print it backwards" << endl;
    iter = numbers.end();
    for (iter--; iter != numbers.begin(); iter--)
        cout << *iter << endl;
    cout << *iter << endl;
}

// In order to motivate why the iterator mechanism show above is more
// efficient that using the index method (the numbers[i] method)
// consider how you would implement finding a specific element of a
// linked list.  Each time this function is called it has to start
// at the head of the list.

/*
bool List::index(int i, int &value)
{
    Node *ptr;
    for (ptr = m_head; i > 0; ptr = ptr->m_next, i--)
        ;
    if (ptr != NULL)
    {
        value = ptr->m_value;
        return true;
    }
    else return false;
}
*/

Tags:
May 8th, 2010

C++ wait for key press to continue execution example

Simple C++ program that waits for a key to be pressed to continue execution of the program.


#include " stdafx.h "
#include < iostream >

using namespace std;

int _tmain(int argc, _TCHAR* argv[])
{
  cout << "Press 'n' and then ENTER to continue!" << endl;
  while (1)
  {
    if ('n' == getchar())
       break;
  }
}

Tags:
May 8th, 2010

C++ Using the standard template library (STL) map example

This program demonstrates using the standard template library (STL) map it reads pairs of data and inserts them into a map then it reads names and looks those names up in the map
A map stores a collection of pairs For example, consider this collection of data: Tom is 42 years old Sally is 20 years old Fred is 21 years old We can think of this data as three “pairs” A map stores these pairs. For each key (a name in the above example) there is a single value


#include < map >
#include < string >
#include < iostream >
using namespace std;

int main()
{
    // maps are parameterized by two types.  The first is the type of the key,
    // the second is the type of the thing being stored in the map
    map<string, string> my_map;
    string owner_name;
    string pet_name;

    cout << "enter owner names and pet name pairs: " << endl;
    while (cin >> owner_name)
    {
        if (owner_name == "quit")
            break;
        cin >> pet_name;
        // insert the pet_name into the map using the owner_name as the key
        my_map[owner_name] = pet_name;
    }

    cout << "enter owner names to lookup:" << endl;
    while (cin >> owner_name)
    {
        if (owner_name == "quit")
            break;
        // NOTE: this code is not very good.  
        // If an owner_name is not in the map, this code prints an
        // empty string.
        cout << owner_name
             << "'s pet is <"
             << my_map[owner_name]
             << ">"
             << endl;
    }
}

Tags:
May 8th, 2010

c++ Sample program to test compilation

Here is a simple C++ program to test compilation:

// Sample program to test compilation
#include <iostream>
using namespace std;

int main()
{
    cout << "Hello world." << endl;
}