Welcome to mirror list, hosted at ThFree Co, Russian Federation.

SampleCorrection.h « src - github.com/mpc-hc/sanear.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
blob: 42f9432a4ef83b650adde27fce75c1bfe3d08f24 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
#pragma once

#include "DspChunk.h"

namespace SaneAudioRenderer
{
    class SampleCorrection final
    {
    public:

        SampleCorrection() = default;

        void NewFormat(SharedWaveFormat format);
        void NewSegment(double rate);
        void NewDeviceBuffer();

        DspChunk ProcessSample(IMediaSample* pSample, AM_SAMPLE2_PROPERTIES& sampleProps);

        REFERENCE_TIME GetLastFrameEnd()   const { return m_lastFrameEnd; }
        REFERENCE_TIME GetTimeDivergence() const { return m_timeDivergence; }

    private:

        void FillMissingTimings(AM_SAMPLE2_PROPERTIES& sampleProps);
        void AccumulateTimings(AM_SAMPLE2_PROPERTIES& sampleProps, size_t frames);

        uint64_t TimeToFrames(REFERENCE_TIME time);
        REFERENCE_TIME FramesToTime(uint64_t frames);

        SharedWaveFormat m_format;
        bool m_bitstream = false;

        double m_rate = 1.0;

        REFERENCE_TIME m_segmentTimeInPreviousFormats = 0;
        uint64_t m_segmentFramesInCurrentFormat = 0;

        REFERENCE_TIME m_lastFrameEnd = 0;

        REFERENCE_TIME m_timeDivergence = 0;

        bool m_freshBuffer = true;
    };
}