__fastcall TMainForm::TMainForm(TComponent* Owner)
: TForm(Owner)
{
Buffer = new TBitmap32();
Buffer->StretchFilter = sfDraft;
}
//---------------------------------------------------------------------------
void __fastcall TMainForm::Button1Click(TObject *Sender)
{
if (OpenDialog->Execute())
{
FilterGraph->Stop();
FilterGraph->ClearGraph();
FilterGraph->Active = false;
FilterGraph->Active = true;
FilterGraph->RenderFile(OpenDialog->FileName);
IBasicVideo* BV;
FilterGraph->QueryInterface(IID_IBasicVideo, &BV);
long w, h;
BV->get_VideoWidth(&w);
BV->get_VideoHeight(&h);
BV->Release();
Buffer->SetSize(w, h);
Caption = String(w) + " x " + h;
FilterGraph->Play();
}
}
//---------------------------------------------------------------------------
void __fastcall TMainForm::FormClose(TObject *Sender, TCloseAction &Action)
{
FilterGraph->Stop();
FilterGraph->Active = false;
delete Buffer;
}
//---------------------------------------------------------------------------
void __fastcall TMainForm::SampleGrabberBuffer(TObject *sender,
double SampleTime, Pointer pBuffer, int BufferLen)
{
TColor32* src = (TColor32*)pBuffer
+ (Buffer->Height - 1) * Buffer->Width;
TColor32* tgt = Buffer->Bits;
for(int y = 0; y < Buffer->Height; y++)
{
for(int x = 0; x < Buffer->Width; x++) tgt[x] = src[x];
src -= Buffer->Width;
tgt += Buffer->Width;
}
Stage1->Invalidate();
Stage2->Invalidate();
Stage3->Invalidate();
}
//---------------------------------------------------------------------------
void __fastcall TMainForm::PaintBuffer(TObject *Sender)
{
if (!Buffer->Width) return;
Types::TRect dstRect;
TPaintBox32* stage = (TPaintBox32*)Sender;
double srcAspectRatio = (double)Buffer->Height / Buffer->Width;
if (srcAspectRatio > (double)stage->Height / stage->Width)
{
int w = stage->Height / srcAspectRatio;
int l = stage->Width - w >> 1;
dstRect = Rect(l, 0, l + w, stage->Height);
}
else
{
int h = stage->Width * srcAspectRatio;
int t = stage->Height - h >> 1;
dstRect = Rect(0, t, stage->Width, t + h);
}
stage->Buffer->Clear(0); // Tuning point
Buffer->DrawTo(stage->Buffer, dstRect);
}
//---------------------------------------------------------------------------
void __fastcall TMainForm::FormResize(TObject *Sender)
{
Panel3->Width = ClientWidth / 2;
Panel2->Height = ClientHeight / 2;
VideoWindow->Height = Panel2->Height / 2;
}
//---------------------------------------------------------------------------
길게 짜는건 싫어하는 Nibble입니다.
몇 몇 Decoder 필터에선 SampleGrabber 에게 rgb32 형태의 샘플을 주지 않아 연결이 안되는 경우가 있고,
manual 로 pin connection 하는건 코딩량이 많아져서 간단히 AVI Splitter와 AVI Decompressor를 얹어버렸습니다.
Graphics32의 TPaintBox32를 이용해 다중 출력을 구현했으니 성능도 좋고 마음껏 수정하기도 좋지요.
* 게으른 코드 때문에 몇 몇 자막 필터와 연결이 원활하지 않을 수 있습니다.
|
void __fastcall TMainForm::SampleGrabberBuffer(TObject *sender,
double SampleTime, Pointer pBuffer, int BufferLen) 여기까지는 해보았습니다.
그리고 TBitmap에 복사를 해서... StretchBlt()로 바닥에 뿌리니... 색들의 경계지점에 알록달록 선들이 그어지고... 문제는 어느 정도 시간이 가면 Error가 발생... 이 방법도 안되겠구나 했는 데... GR32에서 표현이 잘 되는 것 같군요... 역시 소문대로 GR32가 빠른 모양입니다. GR32도 왠만하면 잘 사용하지 않는 편이라... 이번에도 아예 TEST 대상에서 제외했는데..
TFilter AVIDecompressor, AviSplitter 이놈들 용도는 뭔지 잘 모르겠네요... 아직 DS에 대해 아는 것이 없어서...?
DSPack에 대한 자료가 너무 부족한 것 같습니다. 저같은 초보를 위해 시간 나시면 연재라도 부탁드립니다. 감사합니다 ^^