배속재생인 경우 SampleGrabber 에서 정확한 SampleTime 얻기

일단 DirectShow Filter Graph 는 다음과 같이 구성되였다.
SourceFilter->DecoderFilters->SampleGrabber->NullRenderer
이경우 Graph 에 IMediaSeeking::SetRate 로 배속을 설정하고 재생하는 경우 SampleGrabber 의 BufferCB 나 SampleCB 로 들어오는 SampleTime 이 정확한 시간이 아니다.

정확한 시간을 얻기 위해서는 우선 BufferCB 가 아니라 SampleCB 를 이용하여야 한다.
ISampleGrabber::SetCallback( &videoAdapter, 0);

다음 ISampleGrabberCB::SampleCB(double SampleTime,    IMediaSample *pSample) 에서 다음과 같은 식으로 정확한 시간을 얻을수 있다.

    LONGLONG        nTimeStart;
    LONGLONG        nTimeEnd;
    REFERENCE_TIME    rTimeStart;
    REFERENCE_TIME    rTimeEnd;
    REFERENCE_TIME    rSegStart;
    HRESULT hr;

    hr = pSample->GetMediaTime(&nTimeStart, &nTimeEnd);
    hr = pSample->GetTime(&rTimeStart, &rTimeEnd);
    rSegStart = (REFERENCE_TIME)(SampleTime * UNITS) - rTimeStart;
    SampleTime = ((rTimeStart * m_dblRate) + rSegStart) / UNITS;

참조로 http://www.tech-archive.net/Archive/Development/microsoft.public.win32.programmer.directx.audio/2008-01/msg00013.html 에 보면
        The SampleGrabber simply does this:

        IMediaSample::GetTime(&start,&stop);
        SampleTime = (double)(start + segStart) /
        REFTIME_UNITS_PER_SEC;

        where segStart is the segment starting position after a seek
        (which you have no other way of knowing).

        Where the sample timestamp comes from is beyond the
        SampleGrabber and depends on the exact topology of your
        graph.

로 되여 있다.

by 아폴로 | 2008/07/25 10:06 | 컴퓨터 | 트랙백 | 덧글(0)

트랙백 주소 : http://corapollo.egloos.com/tb/622109
☞ 내 이글루에 이 글과 관련된 글 쓰기 (트랙백 보내기) [도움말]

:         :

:

비공개 덧글

◀ 이전 페이지          다음 페이지 ▶