List Info

Thread: compress/extras/dirac_dshow/src/diracsplitter DiracSplitter.cpp, 1.2, 1.3 DiracSplit




compress/extras/dirac_dshow/src/diracsp litter DiracSplitter.cpp, 1.2, 1.3 DiracSplit
user name
2007-09-03 06:31:44
Update of
/cvsroot/dirac/compress/extras/dirac_dshow/src/diracsplitter

In directory
sc8-pr-cvs12.sourceforge.net:/tmp/cvs-serv31326/extras/dirac
_dshow/src/diracsplitter

Modified Files:
	DiracSplitter.cpp DiracSplitterFile.cpp 
Log Message:
Changes to conform with latest Spec.
- Changes to Access Unit Header


Index: DiracSplitterFile.cpp
============================================================
=======
RCS file:
/cvsroot/dirac/compress/extras/dirac_dshow/src/diracsplitter
/DiracSplitterFile.cpp,v
retrieving revision 1.4
retrieving revision 1.5
diff -C2 -d -r1.4 -r1.5
*** DiracSplitterFile.cpp	3 Apr 2007 13:06:02 -0000	1.4
--- DiracSplitterFile.cpp	3 Sep 2007 11:31:42 -0000	1.5
***************
*** 7,83 ****
  
  CDiracSplitterFile::CDiracSplitterFile(IAsyncReader*
pAsyncReader, HRESULT& hr)
! 	: CBaseSplitterFile(pAsyncReader, hr)
! 	, m_rtDuration(0)
  {
! 	if(SUCCEEDED(hr)) hr = Init();
! 	m_pBuff.SetSize(1024, 1024);
  }
  
  HRESULT CDiracSplitterFile::Init()
  {
! 	HRESULT hr = E_FAIL;
  
! 	Seek(0);
      
! 	// Dirac streams are no longer preceded with KW-DIRAC
! 	//UINT64 hdr;
! 	//if(FAILED(Read((BYTE*)&hdr, sizeof(hdr))) || hdr !=
0x43415249442D574Bui64) // KW-DIRAC
! 		//return E_FAIL;
  
! 	dirac_decoder_t* decoder = dirac_decoder_init(0);
  
! 	__int64 limit = min(GetLength(), 2048);
  
! 	while(GetPos() < limit)
! 	{
! 		BYTE b;
! 		if(!Next(b)) {ASSERT(0); break;}
  
! 		if(b == AU_START_CODE)
! 		{
! 			__int64 pos = GetPos() - 13; //Parse info size = 13
! 			if(!Next(b)) {ASSERT(0); break;}
! 			__int64 len = GetPos() - pos;
! 			Seek(pos);
  
! 			m_mt.majortype = MEDIATYPE_Video;
! 			m_mt.subtype = MEDIASUBTYPE_DiracVideo;
! 			m_mt.formattype = FORMAT_DiracVideoInfo;
! 			m_mt.SetSampleSize(1);
  
! 			DIRACINFOHEADER* dvih =
(DIRACINFOHEADER*)m_mt.AllocFormatBuffer(FIELD_OFFSET(DIRACI
NFOHEADER, dwSequenceHeader) + len);
! 			memset(m_mt.Format(), 0, m_mt.FormatLength());
  
! 			dvih->cbSequenceHeader = len;
! 			Read((BYTE*)&dvih->dwSequenceHeader[0], len);
  
! 			dirac_buffer(decoder,
(BYTE*)&dvih->dwSequenceHeader[0],
(BYTE*)&dvih->dwSequenceHeader[0] + len);
              DecoderState dec_state =
dirac_parse(decoder);
! 			if(dec_state != STATE_SEQUENCE) {ASSERT(0); break;}
  
! 			if(decoder->src_params.frame_rate.denominator)
! 			dvih->hdr.AvgTimePerFrame = 10000000i64 *
decoder->src_params.frame_rate.denominator /
decoder->src_params.frame_rate.numerator;
! 			dvih->hdr.bmiHeader.biSize =
sizeof(dvih->hdr.bmiHeader);
! 			dvih->hdr.bmiHeader.biWidth =
decoder->seq_params.width;
! 			dvih->hdr.bmiHeader.biHeight =
decoder->seq_params.height;
! 			dvih->hdr.bmiHeader.biCompression =
m_mt.subtype.Data1;
! 			dvih->hdr.dwInterlaceFlags = 0;
! 			if(decoder->src_params.interlace)
dvih->hdr.dwInterlaceFlags |= AMINTERLACE_IsInterlaced;
! 			if(decoder->src_params.topfieldfirst)
dvih->hdr.dwInterlaceFlags |= AMINTERLACE_Field1First;
! 			dvih->hdr.dwPictAspectRatioX =
dvih->hdr.bmiHeader.biWidth;
! 			dvih->hdr.dwPictAspectRatioY =
dvih->hdr.bmiHeader.biHeight;
  
! 			m_rtDuration = 0;// dvih->hdr.AvgTimePerFrame *
decoder->seq_params.num_frames; // WTF
  
! 			hr = S_OK;
! 			// TESTING
!     		//ASSERT(0);
! 			break;
! 		}
! 	}
  
      dirac_decoder_close(decoder);
  
! 	return hr;
  }
  
--- 7,83 ----
  
  CDiracSplitterFile::CDiracSplitterFile(IAsyncReader*
pAsyncReader, HRESULT& hr)
!     : CBaseSplitterFile(pAsyncReader, hr)
!     , m_rtDuration(0)
  {
!     if(SUCCEEDED(hr)) hr = Init();
!     m_pBuff.SetSize(1024, 1024);
  }
  
  HRESULT CDiracSplitterFile::Init()
  {
!     HRESULT hr = E_FAIL;
  
!     Seek(0);
      
!     // Dirac streams are no longer preceded with KW-DIRAC
!     //UINT64 hdr;
!     //if(FAILED(Read((BYTE*)&hdr, sizeof(hdr))) || hdr
!= 0x43415249442D574Bui64) // KW-DIRAC
!         //return E_FAIL;
  
!     dirac_decoder_t* decoder = dirac_decoder_init(0);
  
!     __int64 limit = min(GetLength(), 2048);
  
!     while(GetPos() < limit)
!     {
!         BYTE b;
!         if(!Next(b)) {ASSERT(0); break;}
  
!         if(b == AU_START_CODE)
!         {
!             __int64 pos = GetPos() - 13; //Parse info size
= 13
!             if(!Next(b)) {ASSERT(0); break;}
!             __int64 len = GetPos() - pos;
!             Seek(pos);
  
!             m_mt.majortype = MEDIATYPE_Video;
!             m_mt.subtype = MEDIASUBTYPE_DiracVideo;
!             m_mt.formattype = FORMAT_DiracVideoInfo;
!             m_mt.SetSampleSize(1);
  
!             DIRACINFOHEADER* dvih =
(DIRACINFOHEADER*)m_mt.AllocFormatBuffer(FIELD_OFFSET(DIRACI
NFOHEADER, dwSequenceHeader) + len);
!             memset(m_mt.Format(), 0,
m_mt.FormatLength());
  
!             dvih->cbSequenceHeader = len;
!             Read((BYTE*)&dvih->dwSequenceHeader[0],
len);
  
!             dirac_buffer(decoder,
(BYTE*)&dvih->dwSequenceHeader[0],
(BYTE*)&dvih->dwSequenceHeader[0] + len);
              DecoderState dec_state =
dirac_parse(decoder);
!             if(dec_state != STATE_SEQUENCE) {ASSERT(0);
break;}
  
!            
if(decoder->src_params.frame_rate.denominator)
!             dvih->hdr.AvgTimePerFrame = 10000000i64 *
decoder->src_params.frame_rate.denominator /
decoder->src_params.frame_rate.numerator;
!             dvih->hdr.bmiHeader.biSize =
sizeof(dvih->hdr.bmiHeader);
!             dvih->hdr.bmiHeader.biWidth =
decoder->src_params.width;
!             dvih->hdr.bmiHeader.biHeight =
decoder->src_params.height;
!             dvih->hdr.bmiHeader.biCompression =
m_mt.subtype.Data1;
!             dvih->hdr.dwInterlaceFlags = 0;
!             if(decoder->src_params.interlace)
dvih->hdr.dwInterlaceFlags |= AMINTERLACE_IsInterlaced;
!             if(decoder->src_params.topfieldfirst)
dvih->hdr.dwInterlaceFlags |= AMINTERLACE_Field1First;
!             dvih->hdr.dwPictAspectRatioX =
dvih->hdr.bmiHeader.biWidth;
!             dvih->hdr.dwPictAspectRatioY =
dvih->hdr.bmiHeader.biHeight;
  
!             m_rtDuration = 0;//
dvih->hdr.AvgTimePerFrame *
decoder->seq_params.num_frames; // WTF
  
!             hr = S_OK;
!             // TESTING
!             //ASSERT(0);
!             break;
!         }
!     }
  
      dirac_decoder_close(decoder);
  
!     return hr;
  }
  
***************
*** 85,164 ****
  {    
      int M = 0;
! 	while(M < 64 && !BitRead(1))
! 		M++;
  
! 	UINT64 info = 0;
      for(int i = 0; i < M; i++)
! 		info |= BitRead(1) << i;
  
! 	return (1ui64<<M)-1 + info;
  }
  
  bool CDiracSplitterFile::Next(BYTE& code, __int64
len)
  {
! 	BitByteAlign();
! 	UINT64 qw = -1;
! 	do
! 	{
! 		if(len-- == 0 || GetPos() >= GetLength())
return(false);
! 		qw = (qw << 8) | (BYTE)BitRead(8);
! 	}
! 	while((qw&0xffffffff00) !=
((UINT64)START_CODE_PREFIX<<8));
! 	int size_bytes = 0;
! 	// Read in the 6 bytes of next and previous parse unit
offsets.
! 	while (size_bytes < 6)
! 	{
! 		if(len-- == 0 || GetPos() >= GetLength())
return(false);
! 		BitRead(8);
! 		size_bytes++;
! 	}
! 	code = (BYTE)(qw & 0xff);
! 	return(true);
  }
  
  const BYTE* CDiracSplitterFile::NextBlock(BYTE& code,
int& size, int& fnum)
  {
! 	BYTE* pBuff = m_pBuff.GetData();
! 	size = 0;
  
! 	// TODO: make sure we are at a start code right now
  
! 	while(GetPos() < GetLength())
! 	{
! 		if(GetPos() <= GetLength() - 5)
! 		{
! 			UINT64 qw = BitRead(40, true);
  
! 			if(size == 0)
! 			{
! 				if((qw & 0xffffffff00) ==
((UINT64)START_CODE_PREFIX<<8) )
! 					code = (BYTE)(qw & 0xff);
  
! 				if(isFrameStartCode(code))
! 				{
! 					__int64 pos = GetPos();
! 					Seek(pos + 5);
! 					//fnum = (int)UnsignedGolombDecode();
! 					Read((BYTE*)&fnum, sizeof(fnum));
! 					Seek(pos);
! 				}
! 			}
! 			else
! 			{
! 				if((qw & 0xffffffff00) ==
((UINT64)START_CODE_PREFIX<<8))
! 					break;
! 			}
! 		}
  
! 		if(size >= m_pBuff.GetSize())
! 		{
! 			int newsize = max(1024, size*2);
! 			m_pBuff.SetSize(newsize, newsize);
! 			pBuff = m_pBuff.GetData();
! 		}
  
! 		pBuff[size++] = (BYTE)BitRead(8);
! 	}
  
! 	return pBuff;
  }
--- 85,164 ----
  {    
      int M = 0;
!     while(M < 64 && !BitRead(1))
!         M++;
  
!     UINT64 info = 0;
      for(int i = 0; i < M; i++)
!         info |= BitRead(1) << i;
  
!     return (1ui64<<M)-1 + info;
  }
  
  bool CDiracSplitterFile::Next(BYTE& code, __int64
len)
  {
!     BitByteAlign();
!     UINT64 qw = -1;
!     do
!     {
!         if(len-- == 0 || GetPos() >= GetLength())
return(false);
!         qw = (qw << 8) | (BYTE)BitRead(8);
!     }
!     while((qw&0xffffffff00) !=
((UINT64)START_CODE_PREFIX<<8));
!     int size_bytes = 0;
!     // Read in the 6 bytes of next and previous parse unit
offsets.
!     while (size_bytes < 6)
!     {
!         if(len-- == 0 || GetPos() >= GetLength())
return(false);
!         BitRead(8);
!         size_bytes++;
!     }
!     code = (BYTE)(qw & 0xff);
!     return(true);
  }
  
  const BYTE* CDiracSplitterFile::NextBlock(BYTE& code,
int& size, int& fnum)
  {
!     BYTE* pBuff = m_pBuff.GetData();
!     size = 0;
  
!     // TODO: make sure we are at a start code right now
  
!     while(GetPos() < GetLength())
!     {
!         if(GetPos() <= GetLength() - 5)
!         {
!             UINT64 qw = BitRead(40, true);
  
!             if(size == 0)
!             {
!                 if((qw & 0xffffffff00) ==
((UINT64)START_CODE_PREFIX<<8) )
!                     code = (BYTE)(qw & 0xff);
  
!                 if(isFrameStartCode(code))
!                 {
!                     __int64 pos = GetPos();
!                     Seek(pos + 5);
!                     //fnum = (int)UnsignedGolombDecode();
!                     Read((BYTE*)&fnum, sizeof(fnum));
!                     Seek(pos);
!                 }
!             }
!             else
!             {
!                 if((qw & 0xffffffff00) ==
((UINT64)START_CODE_PREFIX<<8))
!                     break;
!             }
!         }
  
!         if(size >= m_pBuff.GetSize())
!         {
!             int newsize = max(1024, size*2);
!             m_pBuff.SetSize(newsize, newsize);
!             pBuff = m_pBuff.GetData();
!         }
  
!         pBuff[size++] = (BYTE)BitRead(8);
!     }
  
!     return pBuff;
  }

Index: DiracSplitter.cpp
============================================================
=======
RCS file:
/cvsroot/dirac/compress/extras/dirac_dshow/src/diracsplitter
/DiracSplitter.cpp,v
retrieving revision 1.2
retrieving revision 1.3
diff -C2 -d -r1.2 -r1.3
*** DiracSplitter.cpp	20 Apr 2006 10:41:56 -0000	1.2
--- DiracSplitter.cpp	3 Sep 2007 11:31:42 -0000	1.3
***************
*** 1,5 ****
  /* 
!  *	Copyright (C) 2003-2004 Gabest
!  *	http://www.gabest.org
   *
   *  This Program is free software; you can redistribute it
and/or modify
--- 1,5 ----
  /* 
!  *    Copyright (C) 2003-2004 Gabest
!  *    http://www.gabest.org
   *
[...1142 lines suppressed...]
!     FreeDecoder();
!     return __super::StopStreaming();
  }
  
  HRESULT CDiracVideoDecoder::NewSegment(REFERENCE_TIME
tStart, REFERENCE_TIME tStop, double dRate)
  {
!     CAutoLock cAutoLock(&m_csReceive);
  
!     m_fDropFrames = false;
!     m_tStart = tStart;
  
!     return __super::NewSegment(tStart, tStop, dRate);
  }
  
  HRESULT CDiracVideoDecoder::AlterQuality(Quality q)
  {
!     if(q.Late > 500*10000i64) m_fDropFrames = true;
!     if(q.Late <= 0) m_fDropFrames = false;
!     return E_NOTIMPL;
  }


------------------------------------------------------------
-------------
This SF.net email is sponsored by: Splunk Inc.
Still grepping through log files to find problems?  Stop.
Now Search log events and configuration files using AJAX and
a browser.
Download your FREE copy of Splunk now >>  http://get.splunk.com/
_______________________________________________
Dirac-commits mailing list
Dirac-commitslists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/dirac-com
mits

[1]

about | contact  Other archives ( Real Estate discussion Medical topics )