Wednesday, November 11, 2009

Some times I feel like...

Sometimes I feel like
a motherless child
A longway from my home.
oh... My Brothers
A longway from my home

Thursday, June 25, 2009

Learnings


Today I learnt two things:

1.How to load the WMP with local file ?
2.FourCC codes in AVI file format

How to load WMP with local file:
VS2005 debugger :
File path : wmPlayer
command line arguments : file://My documents//incredibles.avi






FourCC codes in AVI file:

FOURCC('0','0','d','c') - video
FOURCC('0','1','w','b') - audio

dc - indicates video stream
wb - indicates audio stream

00 - indicates the Stream number
01 - '' ''

Usually video will be the first stream and audio will be the second stream.
But For Some avi files, (Problematic avi file)

we found the audio as first stream and video as second stream.
So we need to check only the dc or wb to identify the stream type ( video or audio).

Monday, May 11, 2009

waiting for the right chance

உயிர்களைக் கொல்வது பாவம் என என் மனது சொல்லியதால் நான் உயிருடன் இருக்கிறேன்.
I am waiting for the right chance to die.

Friday, April 10, 2009

How to handle seek operation in Splitter or Source Filter ?

How to handle seek operation in Splitter /Source Filter:
-----------------------------------------------------------
1.SetPositions () called multiple times for a Single Seek operation.
2.we have to Set m_bSeeked variable in SetPositions() and Start Seek position
3.We have to store the Previous Seek value.within FillBuffer(), if m_bSeeked set,check for the seeked position and Previous seek position. if they are different, then send a seek request tostack or file parser.
So even Multiple SetPositions () ( 3 times) called for a single seek, operation from our filter we will send a seek request onceby having seeked Flag and Checking the Previous seek position with current seek position.
During Seeking, FillBuffer must not wait for any event... it must be unblocked ... ( Set Positions () fn will call flushing in all the output pins. Flushing will wait for the FillBuffer to complete its operation.

Tuesday, March 31, 2009

How to Assert the thread was closed (dead) or Not ?

How to Assert the thread was closed (dead) or Not ?:

WaitForSingleObject( hThread, INFINITE) ; // This statement will blocks until the thread dies.
if the Thread comes out of the loop, then hThread handle is like signalled.
The Next statement to WaitForSingleObject () will be executed.

How to modify the 3gp streaming filter to read Only rtp data?

How to modify the 3gp streaming filter to read Only rtp data?
================================================
( 3gp streaming stack it will receives the rtsp and rtp data)

Solution:Quick and dirty way to do this:
===============================
Use Some SDP file to create the dummy audio and video output pin. ( We can create it with rtsp:// URL itself);
Hard code the media type, File duration (instead of the file duration configure duration as much as we need to receive data for RTP),config data in a filter .

How to get SDP file for any RTSP file?

How to get SDP file for any RTSP file?
RTSP response will have the SDP description
if we are having rtsp URL, we can open it with Quick time Player and at the same time, we can open the Ethereal to capture the net logs.
RTSP response RTSP/1.1 200 OK will have a SDP description.
Even with this SDP description and save it into SDP file and open it in Quick time, we are able to play it in Quick time

Sunday, March 29, 2009

Audio goes off after seeking several times

Audio goes off after seeking several times :

When I seek several times, the audio goes off.

Reason:

After seeking, negative timestamps are set to video and audio media samples.

In case of video even though it was negative, it was rendered.But In case of audio,

it was not rendered fine because the audio is the reference clock for both video and audio.

Moreover audio and video are synchronized with this audio timestamp.

So the audio timestamp must not be negavtive, after seeking. if it is so, we cant predict the

rendering ( Sometimes it might render and sometimes it may not render)

Solution:

I modified Source filter in such a way to output positive timestamp for video and audio after seeking. Now the issue was resolved.

Wednesday, March 04, 2009

RegSvr32 error

 


I am able to compile the filter ; while registering I  got the following error:

---------------------------
RegSvr32
---------------------------
DllRegisterServer in D:\PushSource\Debug_Unicode\PushSource.dll failed.
Return code was: 0xc0000005
---------------------------
OK  
---------------------------


Solution:
============

 This error will come if any dependency has been removed
The problem is it doesnt have any dependency. I have checked it with depends.exe.

 

CFactoryTemplate g_Templates[3] =
{
    {
      g_wszPushDesktop,               // Name
      &CLSID_RxVideoReceiver,       // CLSID
      CRxReceiver::CreateInstance, // Method to create an instance of MyComponent
      NULL,                           // Initialization function
      &sudPushSourceDesktop           // Set-up information (for filters)
    }
};

 

I modified the above code as


CFactoryTemplate g_Templates[] =
{
    {
      g_wszPushDesktop,               // Name
      &CLSID_RxVideoReceiver,       // CLSID
      CRxReceiver::CreateInstance, // Method to create an instance of MyComponent
      NULL,                           // Initialization function
      &sudPushSourceDesktop           // Set-up information (for filters)
    }
};


Now I am not getting any errors.

 if I g_Templates[3] means, the regsvr32.exe expects the another 2 GUIDs and informations. Since it doesnt have the values,

it gives read violation error.

Tuesday, February 24, 2009

WindowsMobile Microsoft video renderer crashes for Odd resolution width

 
 
WindowsMobile Microsoft video renderer crashes with the following error for RGB565 data with 179x99 video resolution:
 
Data Abort: Thread=8a66da00 Proc=88a8b8b0 'wmplayer'
AKY=00080001 PC=03fa0060(coredll.dll+0x00054060) RA=0305798c(quartz.dll+0x0007398c) BVA=29b9a01c FSR=00000007
Unhandled exception at 0x03fa0060 in wmplayer.exe: 0xC0000005: Access violation reading location 0x01b9a01c.

Unhandled exception at 0x03fa0060 in wmplayer.exe: 0xC0000005: Access violation reading location 0x01b9a01c.
 
Odd Resolution Clip: 179x99 resolution
DecideBufferSize () size as 179x99*2
SetActualDatalength() as 179x99 * 2

Solution :
--------------
if I modified the DecideBufferSize to 180x99*2 then it is working fine.
renderer is doing some alignment for odd resolution clip is it so ?

Before giving the output to the renderer from our decoder, we need to align width and height to multiple's 0f 4 or 2;
 
Alignment to 4 :
----------------
  if( nFrameWidth & 0x03)
  {
   nFrameWidth = nFrameWidth  - ( nFrameWidth & 0x03);
  }
Alignment to 2 :
-----------------
  if(nFrameWidth & 0x01)
  {
   nFrameWidth = nFrameWidth - 1;   
  }
 
Note: I also got the above error if I do the following:
i) allocating memory size as 179x99 in DecideBufferSize()  and set the Width and height as 180x100 .

Monday, February 23, 2009

fatal error LNK1104: cannot open file 'x0__ar10.lib'

problem:

fatal error LNK1104: cannot open file 'x0__ar10.lib'

Solution:
-------------------

Search this library in Visual studio 8 installation folder.In the
following path it has that library.
D:\Program Files\Microsoft Visual Studio 8\VC\ce\bin\x86_arm

Thursday, February 19, 2009

Regarding the how to set the relative path:

Regarding the how to set the relative path:
==================================================

D:\tech\code\fileformats\3gpp\reader

..\..\..\..\inc


it refers the path as follows:
excape from the four directories:

D:\tech\inc


My Current directory is as follows:
D:\tech\code\Apps\Mp4Propertybag_Source\Mp4PropertyPag

common.h file's Current Directory D:\NokiaPCFilters\tech\inc

Relative path: ..\..\..\..\inc

Target directory:

D:\tech\code\fileformats\3gpp\reader\inc


Relative path:
..\..\..\fileformats\3gpp\reader\inc


Target Dir:
-------------
D:\tech\code\fileformats\3gpp\inc

Relative path:
--------------
..\..\..\fileformats\3gpp\inc

Target dir:
--------------
D:\tech\code\filters\inc

Relative path:
--------------
..\..\..\filters\inc

Integer division by error with Audio Decoder filter

while delivering audio data, I got a problem as follows:

i) if I deliver it then I got a crash in Decoder as "Integer division by zero".

So I modified the AvgBytesPerSec member of WAVEFORMATEX structure as follows:


wfx.nBlockAlign = 1 ;
wfx.nAvgBytesPerSec = MP3hdr->bitrate * 1000 / 8;

Solution:
--------------
Assign the proper values for WAVEFORMATEX header.

Modified value as follows Now the Filter is working fine.

wfx.nBlockAlign = 2 * nchannels ;
wfx.nAvgBytesPerSec = pwfxout->wfx.nSamplesPerSec * pwfxout->wfx.nBlockAlign ;

Wednesday, February 18, 2009

How to do dynamic format change from the Decoder Filter?...


 How to do dynamic format change from the Decoder Filter?...


Scenario:
-------------
 Assume that we reading video data from the RTP or from real media file.
we will receive the video with 320x240 resolution. In the middle of the stream, it might give you video data with 640x480

resolution. How will u handle the situation ? we can do it with Dynamic format change.

 


what needs to be done at decoder level:
---------------------------------------
   For getting width and height, we will refer the config data from the Source filter's VIDEOINFOHEADER config data or from
the video frame itself have the config information .

 We have the Create the Decoder with current width and height( 320x240) resolution.


DecodeFrame() fn itself must have the ability to detect new config. if some new config arrived, the DecodeFrame () returns

E_NEW_CONFIG;
 
 
 when the new width and height found, we have to delete/release the decoder ( Not a decoder filter) and we have to
create the new decoder with new resolution and then try to decode the frame.

 Here we need to change Decoder filter's output pin media type as well as the reallocate renderer's allocator with new

resolution.

 Logic is as follows:

 if( DecodeFrame() == E_NEW_CONFIG)
 {
  DeleteDecoder();
  hr =CreateDecoder(newWidth,newHeight);

  //Change the output pin's media type resolution
  //Rellocate the renderer's allocator with new resolution (640x480)

  //DecodeFrame() once again and give it out.

 }
 


 if we want the dynamic format change, we have to use upstream filter's(video renderer) allocator .

 

 

For Windows mobile:
-------------------
  Microsoft video renderer doesnt have the dynamic format change support.
So we can develop the new video renderer.


 if( DecodeFrame() == E_NEW_CONFIG)
 {
  DeleteDecoder();
  hr =CreateDecoder(newWidth,newHeight);

  //Change the output pin's media type resolution
  //Rellocate the renderer's allocator with new resolution (640x480)

  hr = m_pInput->ReceiveConnection(m_pOutput,mediatypeWithNewRes); // m_pInput is just a pointer to upstream

filter's                // input pin ( video renderer input pin


  DecodeFrame();
  Deliver(pSample);
  
 }

 
 In Video renderer:
 -------------------
  upstream filter input pin (Renderer input Pin):

  we have to override the ReceiveConnection() fn;

 HRESULT ReceiveConnection(IPin* m_Connected, AM_MEDIA_TYPE* mtWithNewRes)
 {

  if( m_Connected)
  {
                   // this condition will be satisfied if ReceiveConnection() called from the Decoder manually (while    // the graph was running
   int Width  = getWidth(mtwithNewRes);
   int height = getHeight(mtWithNewRes);

   if( CheckMediaType(mtWithNewRes) != S_OK)
   {
    return E_FAIL;
   }
   SetMediaType(mtWithNewRes);


   m_pAllocator->Decommit();
   m_pAllocator->SetProperties(Width,height);
   m_pAllocator->Commit();
    
   
  }
  else
  {
   return CBasePin::ReceiveConnection();
  }
  
 }

  
 

 
For PC:
----------
 For PC, Video renderer has the support for dynamic format change.
 

 we will do as follows:

within Decoder:
  
  if( DecodeFrame() == E_NEW_CONFIG)
 {
  DeleteDecoder();
  hr =CreateDecoder(newWidth,newHeight);

  //Change the output pin's media type resolution
  //Rellocate the renderer's allocator with new resolution (640x480)

  hr = m_pInput->ReceiveConnection(mediatypeWithNewRes);

  m_pInput->m_pAllocator->Decommit();
  m_pInput->m_pAllocator->SetProperties(new Resolution Size);
  m_pInput->m_pAllocator->Commit();

  DecodeFrame();
  Deliver(pSample);
  
 }
Renderer have the ability to change to new allocated buffer;;

 

Tuesday, February 17, 2009

Kavithai

அவள் கூந்தலில் வழிந்தோடும் மல்லிகைப் பூக்கள் அவள் நடக்கும் போது அவள் கன்னத்தை முத்தமிடத் துடிக்கின்றன.

Tuesday, November 18, 2008

Single Input mediasample and Multiple Output media Sample to be delivered from Transform Filter

Single Input mediasample and Multiple Output media Sample in Transform Filter:
===============================================================================
Solution :
---------

implement the Receive() fn:


HRESULT TransformFilter:: Receive(IMediaSample* pMediaSample)
{
HRESULT hr = S_OK;
do
{
hr = GetDeliveryBuffer(&pOutputSample);
if (FAILED(hr)) return hr;
hr = Transform(pSample,pOutputSample);
if(FAILED(hr)) return hr;

hr = m_pOutput->Deliver(pOutputSample);
pOutputSample->Release();
}while(nOutputSample != 0);

return hr;
}

Error while building PC based Dshow baseclasses:

Error while building PC based Dshow baseclasses:
==================================================

>D:\Program Files\Microsoft Visual Studio 8\VC\PlatformSDK\include\winnt.h(222) : error C2146: syntax error :

missing ';' before identifier 'PVOID64'
1>D:\Program Files\Microsoft Visual Studio
8\VC\PlatformSDK\include\winnt.h(222) : error C4430: missing type

specifier - int assumed. Note: C++ does not support default-int
1>D:\Program Files\Microsoft Visual Studio
8\VC\PlatformSDK\include\winnt.h(5940) : error C2146: syntax error :

missing ';' before identifier 'Buffer'
1>D:\Program Files\Microsoft Visual Studio
8\VC\PlatformSDK\include\winnt.h(5940) : error C4430: missing type

specifier - int assumed. Note: C++ does not support default-int
1>D:\Program Files\Microsoft Visual Studio
8\VC\PlatformSDK\include\winnt.h(5940) : error C4430: missing type

specifier - int assumed. Note: C++ does not support default-int

Solution:
-----------
include the following macro in the the Winnt.h before the following lines

typedef void *PVOID;
typedef void *POINTER_64 PVOID64;


After code change:
#define POINTER_64 __ptr64
typedef void *PVOID;
typedef void *POINTER_64 PVOID64;

AnotherSolution:
====================
Update BaseTsd.h with latest platform SDk file.

Wednesday, November 05, 2008

RenderStream Failure

RenderStream Failure :
========================
hr = CaptureGraphBuilder2->RenderStream(
NULL,NULL,mp4Source,mpeg4videoDecoder,Mpeg4Encoder);

returns the "No combination of intermediate filters found"

Observation:
if we connected the Mpeg1 Encoder that is connecting pins in the
RenderStream as follows:

hr = CaptureGraphBuilder2->RenderStream(
NULL,NULL,SourceFilter,mpeg1VideoDecoder,Mpeg4Encoder);


( Source FIlter might be AddSourceFilter() with URL).

RenderStream is running successfully.


Solution:
============


hr = CaptureGraphBuilder2->RenderStream(
NULL,&MEDIATYPE_Video,mp4Source,mpeg4videoDecoder,Mpeg4Encoder);

if we modified it as follows: it is working fine...

The Reason is RenderStream() media type is NULL means it will
directly connects the Source Filter's First Pin the Video Decoder
Filter.

In case of MPEG1 Source Filter, the First output pin is video so it
is running successfully without any problem.

In case of MP4 Source Filter failure case, First output pin is audio
Pin. So the RenderStream() tries to connect with MP4 Source Audio
output pin with Video decoder. So that causes the error.

if we specified the MediaType as video, RenderStream() will takes the
Source Filter's Video output pin and tries to connect it with video
decoder. So it is working fine...

Friday, October 17, 2008

Problem: Source Filter's Pause() fn was not called and directly Stop() fn was called


Problem;
----------------
  Source Filter's Pause() fn was not called and directly Stop() fn was called.
 
 
Solution steps:
------------------------
         For this problem I tried two approach.
 
          1.I have checked the source filter output pin's GetMediaType() fn and CheckMediaType() fn was succeeded and Decoder filter's CheckInputType() fn and CheckTransform() fn was succeeded. so no problem with pin connection
        2.I have developed the player application and rendered only the video output pin and still I got the same error
 
So there is no
            
 
 
Solution:
------------------
 
Importance of biPlanes in BITMAPINFOHEADER:
-------------------------------------------------------------------------

                In Source filter, we set the GetMediaType() returns media type.
This media type have BITMAPINFOHEADER; BITMAPINFOHEADER have biPlanes variable;
 if we set it to zero, then Source Filter directly goes to Filter's Stop() fn...
   if I modified it to 1, then the video is playing fine.
MSDN DSHOW docs prescribed this variable must be set to 1;
 
            So it is better to make the biPlanes  as 1 in media type returned with GetMediaType() fn in our Decoder.
 
 
 
 
 
 
 

how to find framerate of 3GP file?

 
 
how to find framerate of 3GP file? 
Is there any particular box present in 3gp file to specify framerate?
 
Solution:
--------------
      
3gp is actually QuickTime file. There is no special field for Frames Per Second, so you have to
calculate  by dividing the number of frames in stream and stream time
duration.
 

mDurationInSecs =  pMediaTrkInfo->trackDuration / lMovieInfo.timescale;

fFrameRate = pMediaTrkInfo->totalNumOfFrames/ (*apVidInfoLst)[index].mDurationInSecs;

//Frame Rate calculation if 10 frames r played in 2 secs, then FPS is 5 (10/5)