#pragma once

#include "kpi_decoder.h"
#include "kpi_impl.h"

class CChunkChunk;
class CHeaderManager;
#include "tvqdec/twinvq.h"
#include "tvqdec/tvqdec.h"
#pragma warning (disable: 4786)

#include "tvqdec/bfile.h"
#include "tvqdec/bstream.h"
#include "tvqdec/HeaderManager.h"

class KbTvqDecoder : public KbKpiUnknownImpl<IKpiDecoder>
{
private:
    KPI_MEDIAINFO  m_MediaInfo;
    IKpiFile      *m_pFile;
    CChunkChunk *m_Chunk;
    CHeaderManager *m_Manager;
    INDEX m_Index;
    BFILE *m_bfp;
    float *m_Frame;
    int   m_FrameSize;
    int   m_FirstDecode;
    int   m_Bits;

    static KbTvqDecoder *s_pActive;
public:
    DWORD  __fastcall Open(const KPI_MEDIAINFO *cpRequest,
                           IKpiFile   *pFile,
                           IKpiFolder *pFolder);
    DWORD  WINAPI Select(DWORD dwNumber,
                         const KPI_MEDIAINFO **ppMediaInfo,
                         IKpiTagInfo *pTagInfo,
                         DWORD dwTagGetFlags);
    DWORD  WINAPI Render(BYTE *pBuffer, DWORD dwSizeSample);
    UINT64 WINAPI Seek(UINT64 qwPosSample, DWORD dwFlag);
    DWORD  WINAPI UpdateConfig(void *pvReserved){return 0;}
    KbTvqDecoder(void);
    ~KbTvqDecoder(void);
};
