dslinux/user/pixil/packages/dvdview/dvdview/src/tests memalloc.cc memalloc.hh system1.cc system1.hh vidaccess.cc vidaccess.hh videodec.cc videodec.hh
amadeus
dslinux_amadeus at user.in-berlin.de
Tue Oct 3 13:26:01 CEST 2006
Update of /cvsroot/dslinux/dslinux/user/pixil/packages/dvdview/dvdview/src/tests
In directory antilope:/tmp/cvs-serv11916/packages/dvdview/dvdview/src/tests
Added Files:
memalloc.cc memalloc.hh system1.cc system1.hh vidaccess.cc
vidaccess.hh videodec.cc videodec.hh
Log Message:
adding pristine copy of pixil to HEAD so I can branch from it
--- NEW FILE: vidaccess.cc ---
/********************************************************************************
Copyright (C) 1999 Dirk Farin
This program is distributed under GNU Public License (GPL) as
outlined in the COPYING file that comes with the source distribution.
This program is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation; either version 2 of the License, or
(at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program; if not, write to the Free Software
Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
********************************************************************************/
#include "tests/vidaccess.hh"
#include "input/streamsrc_istr.hh"
#include "input/errors.hh"
#include "system/sysdec1.hh"
#include "system/resync.hh"
#include "system/sysdemux.hh"
#include "system/videoauconv.hh"
#include "error.hh"
#include <iostream.h>
#include <iomanip.h>
void ShowVideoAccessUnitPackets(istream& istr)
{
StreamSource_IStream strsrc;
strsrc.SetIStream(istr);
ShowVideoAccessUnitPackets(strsrc);
}
extern void PrintDataHex(uint8* data,uint32 len);
void ShowVideoAccessUnitPackets(class StreamSource& strsrc)
{
SystemDecoder_MPEG1 sysdec;
sysdec.SetSource(strsrc);
cout << "Stream is ";
switch (sysdec.AskStreamType())
{
case SystemDecoder_MPEG1::System: cout << "a system stream\n"; break;
case SystemDecoder_MPEG1::Audio: cout << "an audio stream\n"; break;
case SystemDecoder_MPEG1::Video: cout << "a video stream\n"; break;
case SystemDecoder_MPEG1::Illegal: cout << "an illegal MPEG stream\n"; return; break;
}
cout << endl;
SystemResyncer resync;
resync.SetSource(&sysdec);
SystemDemux demux(resync);
demux.EnableChannel(StreamIDBase_Video|0);
SystemDemuxExtractor extract;
extract.SetSource(&demux);
extract.SetChannel(StreamIDBase_Video|0);
VideoAUConverter vidcon(extract);
for (;;)
{
SysPacket_Packet* pck = vidcon.GetNextPacket();
if (pck==NULL)
return;
cout << "-------------------------------------------------------\n";
cout << "abs.pos: $" << hex << pck->absolute_filepos << dec << endl;
cout << "PTS: "; if (pck->timing.HasPTS) cout << pck->timing.pts << endl; else cout << "none\n";
cout << "DTS: "; if (pck->timing.HasDTS) cout << pck->timing.dts << endl; else cout << "none\n";
cout << endl;
PrintDataHex(pck->data.AskContents(),
pck->data.AskLength());
delete pck;
}
}
--- NEW FILE: system1.cc ---
/********************************************************************************
Copyright (C) 1999 Dirk Farin
This program is distributed under GNU Public License (GPL) as
outlined in the COPYING file that comes with the source distribution.
This program is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation; either version 2 of the License, or
(at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program; if not, write to the Free Software
Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
********************************************************************************/
#include "tests/system1.hh"
#include "input/streamsrc_istr.hh"
#include "input/errors.hh"
#include "system/sysdec1.hh"
#include "error.hh"
#include <iostream.h>
#include <iomanip.h>
void ShowSystemPackets(istream& istr)
{
StreamSource_IStream strsrc;
strsrc.SetIStream(istr);
ShowSystemPackets(strsrc);
}
void ShowSystemPackets(StreamSource& strsrc)
{
SystemDecoder_MPEG1 sysdec;
sysdec.SetSource(strsrc);
cout << "Stream is ";
switch (sysdec.AskStreamType())
{
case SystemDecoder_MPEG1::System: cout << "a system stream\n"; break;
case SystemDecoder_MPEG1::Audio: cout << "an audio stream\n"; break;
case SystemDecoder_MPEG1::Video: cout << "a video stream\n"; break;
case SystemDecoder_MPEG1::Illegal: cout << "an illegal MPEG stream\n"; return; break;
}
cout << endl;
for (;;)
{
try
{
SysPacket* syspck = sysdec.GetNextPacket();
if (syspck==NULL)
break;
cout << "pck: " << setw(5) << syspck->pck_nr
<< " abs.pos: " << hex << setw(6) << syspck->absolute_filepos << dec;
SysPacket_Packet* syspck_packet = dynamic_cast<SysPacket_Packet*>(syspck);
if (syspck_packet)
{
cout << " Packet, stream: " << hex << ((int)syspck_packet->Channel) << dec;
switch (syspck_packet->Channel & 0xF0)
{
case 0xC0:
case 0xD0: cout << " (audio " << ((int)syspck_packet->Channel&0x1F) << ")"; break;
case 0xE0: cout << " (video " << ((int)syspck_packet->Channel&0x0F) << ")"; break;
}
if (syspck_packet->Channel == 0xBE)
cout << " (padding)";
cout << " length: " << syspck_packet->data.AskLength();
}
SysPacket_Pack* syspck_pack = dynamic_cast<SysPacket_Pack*>(syspck);
if (syspck_pack)
{
cout << " Pack";
}
SysPacket_SystemHeader* syspck_hdr = dynamic_cast<SysPacket_SystemHeader*>(syspck);
if (syspck_hdr)
{
cout << " SystemHeader";
}
if (dynamic_cast<SysPacket_Iso11172EndCode*>(syspck))
{
cout << " ISO11172 end code";
}
cout << endl;
delete syspck;
}
catch(Excpt_Error_InvalidData& e)
{
MessageDisplay::Show(ErrSev_Warning,e.m_text);
sysdec.Resync();
}
catch(Excpt_Error_UnexpectedEndOfStream& e)
{
MessageDisplay::Show(ErrSev_Warning,e.m_text);
break; // stop decoding
}
}
}
--- NEW FILE: system1.hh ---
/********************************************************************************
tests/system1.hh
purpose:
MPEG-1 system decoder tests.
notes:
to do:
author(s):
- Dirk Farin, farin at ti.uni-mannheim.de
modifications:
28/Sep/1999 - Dirk Farin - first implementation
********************************************************************************
Copyright (C) 1999 Dirk Farin
This program is distributed under GNU Public License (GPL) as
outlined in the COPYING file that comes with the source distribution.
This program is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation; either version 2 of the License, or
(at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program; if not, write to the Free Software
Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
********************************************************************************/
#ifndef DVDVIEW_TESTS_SYSTEM1_HH
#define DVDVIEW_TESTS_SYSTEM1_HH
// Show headers of system stream.
void ShowSystemPackets(class StreamSource&);
void ShowSystemPackets(class istream&);
#endif
--- NEW FILE: vidaccess.hh ---
/********************************************************************************
tests/vidaccess.hh
purpose:
Dumps video access units of first video stream.
notes:
to do:
author(s):
- Dirk Farin, farin at ti.uni-mannheim.de
modifications:
30/Sep/1999 - Dirk Farin - first revision
********************************************************************************
Copyright (C) 1999 Dirk Farin
This program is distributed under GNU Public License (GPL) as
outlined in the COPYING file that comes with the source distribution.
This program is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation; either version 2 of the License, or
(at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program; if not, write to the Free Software
Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
********************************************************************************/
#ifndef DVDVIEW_TESTS_VIDACCESS_HH
#define DVDVIEW_TESTS_VIDACCESS_HH
// Dump video access units
void ShowVideoAccessUnitPackets(class StreamSource&);
void ShowVideoAccessUnitPackets(class istream&);
#endif
--- NEW FILE: videodec.hh ---
/********************************************************************************
tests/videodec.hh
purpose:
Tests parts of the video decoder.
notes:
to do:
author(s):
- Dirk Farin, farin at ti.uni-mannheim.de
modifications:
01/Oct/1999 - Dirk Farin - first revision
********************************************************************************
Copyright (C) 1999 Dirk Farin
This program is distributed under GNU Public License (GPL) as
outlined in the COPYING file that comes with the source distribution.
This program is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation; either version 2 of the License, or
(at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program; if not, write to the Free Software
Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
********************************************************************************/
#ifndef DVDVIEW_TESTS_VIDEODEC_HH
#define DVDVIEW_TESTS_VIDEODEC_HH
// Show decoded video syntax elements
void ShowVideoSyntax(class StreamSource&);
void ShowVideoSyntax(class istream&);
// Standard video decoder
void DecodeVideo(class StreamSource&);
void DecodeVideo(class istream&);
#endif
--- NEW FILE: videodec.cc ---
/********************************************************************************
Copyright (C) 1999 Dirk Farin
This program is distributed under GNU Public License (GPL) as
outlined in the COPYING file that comes with the source distribution.
This program is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation; either version 2 of the License, or
(at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program; if not, write to the Free Software
Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
********************************************************************************/
#include "tests/videodec.hh"
#include "input/streamsrc_istr.hh"
#include "input/errors.hh"
#include "system/sysdec1.hh"
#include "system/resync.hh"
#include "system/sysdemux.hh"
#include "system/videoauconv.hh"
#include "system/syncer.hh"
//#include "video12/vidsyndec.hh"
//#include "video12/viddec_std.hh"
#include "video12/vdecoder.hh"
#include "vpostproc/buffer.hh"
#include "vpostproc/pp_mblks.hh"
#include "error.hh"
#include "libvideogfx/nanox/imgwin.hh"
#include <iostream.h>
#include <iomanip.h>
void ShowVideoSyntax(istream& istr)
{
StreamSource_IStream strsrc;
strsrc.SetIStream(istr);
ShowVideoSyntax(strsrc);
}
void ShowVideoSyntax(class StreamSource& strsrc)
{
#if 0
SystemDecoder_MPEG1 sysdec;
sysdec.SetSource(strsrc);
SystemResyncer resync;
resync.SetSource(&sysdec);
SystemDemux demux(resync);
demux.EnableChannel(StreamIDBase_Video|0);
SystemDemuxExtractor extract;
extract.SetSource(&demux);
extract.SetChannel(StreamIDBase_Video|0);
VideoAUConverter vidcon(extract);
VideoDecoder_Log dec_log;
VideoSyntaxDecoder vidsyndec(vidcon,dec_log);
while (vidsyndec.DecodeAFrame())
{
}
#endif
}
#if 0
void DecodeVideo(class istream& istr)
{
StreamSource_IStream strsrc;
strsrc.SetIStream(istr);
DecodeVideo(strsrc);
}
void DecodeVideo(class StreamSource& strsrc)
{
SystemDecoder_MPEG1 sysdec;
sysdec.SetSource(strsrc);
SystemResyncer resync;
resync.SetSource(&sysdec);
SystemDemux demux(resync);
demux.EnableChannel(StreamIDBase_Video|0);
SystemDemuxExtractor extract;
extract.SetSource(&demux);
extract.SetChannel(StreamIDBase_Video|0);
VideoAUConverter vidcon(extract);
VideoDecoder_Standard dec_std;
VideoSyntaxDecoder vidsyndec(vidcon,dec_std);
ImageWindow_Autorefresh_X11 imgwin;
bool first=true;
int w,h;
int nframes=0;
while (1) //nframes>0)
{
if (dec_std.BufferEmpty())
{
bool more = vidsyndec.DecodeAFrame();
if (!more)
break;
}
else
{
DecodedImageData dimg;
dimg = dec_std.GetNextImage();
#if 1
if (first)
{
first=false;
ImageParam_YUV param;
dimg.m_image.GetParam(param);
imgwin.Create(w=param.width,h=param.height,
"DVDview DecodeVideo-TEST (c) Dirk Farin");
}
imgwin.Display(dimg.m_image);
#endif
nframes++;
}
}
cout << "Decoded " << nframes << " frames.\n";
}
#endif
void DecodeVideo(class istream& istr)
{
StreamSource_IStream strsrc;
strsrc.SetIStream(istr);
DecodeVideo(strsrc);
}
#include <fstream.h>
#define USEDGA 0
#if USEDGA
#include "output/xf86dga.hh"
#endif
void DecodeVideo(class StreamSource& strsrc)
{
SystemDecoder_MPEG1 sysdec;
sysdec.SetSource(strsrc);
SystemResyncer resync;
resync.SetSource(&sysdec);
SystemDemux demux(resync);
demux.EnableChannel(StreamIDBase_Video|0);
SystemDemuxExtractor extract;
extract.SetSource(&demux);
extract.SetChannel(StreamIDBase_Video|0);
VideoAUConverter vidcon(extract);
VideoDecoder dec_fast(vidcon);
Syncer_Realtime syncer;
//dec_fast.SetSyncer(&syncer);
VideoPostprocessor_MBBoundaries pp_mblks;
VideoImageBuffer bufprov;
pp_mblks.SetNext(&bufprov);
dec_fast.SetBufferProvider(pp_mblks);
//pp_mblks.SetBigMarks();
pp_mblks.SetStaticMode();
#if USEDGA
xf86out_init();
#else
ImageWindow_Autorefresh_X11 imgwin;
#endif
bool first=true;
int w,h;
int nframes=0;
try
{
while (1) //nframes>0)
{
#if 1
if (bufprov.BufferEmpty())
{
//cout << "DECODE\n";
bool more = dec_fast.DecodeAFrame();
if (!more)
break;
}
else
#endif
{
DecodedImageData* dimg;
dimg = bufprov.GetNextImage();
//cout << "SHOW\n";
if (first)
{
first=false;
ImageParam_YUV param;
dimg->m_image.GetParam(param);
cout << "w,h: " << param.width << "," << param.height << endl;
#if !USEDGA
imgwin.Create(w=param.width,h=param.height,
"DVDview DecodeVideo-TEST");
#endif
}
#if USEDGA
xf86out_display(dimg->m_image);
#else
imgwin.Display(dimg->m_image);
#endif
bufprov.FreeImage(dimg);
//getchar();
nframes++;
}
}
}
catch(...)
{
cout << "Unexpected end. Decoded up to frame: " << nframes << endl;
throw;
}
cout << "Frame: " << nframes << endl;
#if USEDGA
xf86out_close();
#endif
cout << "Decoded " << nframes << " frames.\n";
}
--- NEW FILE: memalloc.hh ---
/********************************************************************************
tests/memalloc.hh
purpose:
Test correctness of fast memory allocation routines.
notes:
to do:
author(s):
- Dirk Farin, farin at ti.uni-mannheim.de
modifications:
28/Sep/1999 - Dirk Farin - first implementation
********************************************************************************
Copyright (C) 1999 Dirk Farin
This program is distributed under GNU Public License (GPL) as
outlined in the COPYING file that comes with the source distribution.
This program is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation; either version 2 of the License, or
(at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program; if not, write to the Free Software
Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
********************************************************************************/
#ifndef DVDVIEW_TESTS_MEMALLOC_HH
#define DVDVIEW_TESTS_MEMALLOC_HH
void CheckMemAlloc(bool log=false);
#endif
--- NEW FILE: memalloc.cc ---
/********************************************************************************
Copyright (C) 1999 Dirk Farin
This program is distributed under GNU Public License (GPL) as
outlined in the COPYING file that comes with the source distribution.
This program is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation; either version 2 of the License, or
(at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program; if not, write to the Free Software
Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
********************************************************************************/
#include "tests/memalloc.hh"
#include "utility/fastalloc.hh"
#include "error.hh"
#include <iostream.h>
#include <stdlib.h>
#include <time.h>
void CheckMemAlloc(bool log)
{
srand(time(0));
MemoryAllocator al(100,25);
#define ArraySize 20
void* a[ArraySize];
for (int i=0;i<ArraySize;i++)
a[i]=NULL;
for (int i=0;i<100000;i++)
{
int idx = rand()%ArraySize;
if (a[idx])
{
if (log) cout << "freeing " << a[idx] << endl;
al.Free(a[idx]);
a[idx]=NULL;
}
else
{
int size = (rand()%1000)+100;
a[idx]=al.Alloc(size);
Assert(a[idx] != NULL);
if (log) cout << "allocating " << size << " bytes -> " << a[idx] << endl;
for (int x=0;x<size;x++)
((uint8*)(a[idx]))[x]=0xF0;
}
}
for (int i=0;i<ArraySize;i++)
if (a[i])
al.Free(a[i]);
}
More information about the dslinux-commit
mailing list