/********************************************************

	Video encoder interface
	Copyright 2000 Eugene Kuznetsov  (divx@euro.ru)

*********************************************************/
#ifndef __VideoEncoder_H
#define __VideoEncoder_H

#include <videoencoder.h>
//#include <map>
#include "Module.h"
    
class VideoEncoder: public IVideoEncoder
{
public:
//    VideoEncoder(int compressor, const BITMAPINFOHEADER& header);
    VideoEncoder(const CodecInfo& info, fourcc_t compressor, const BITMAPINFOHEADER& header);
    ~VideoEncoder();
    //
    // Starts encoding
    //
    void Start();
    //
    // Stops encoding
    //
    void Stop();
    //
    // Queries encoder about desired buffer size for compression
    // You should allocate at least this much bytes for dest ( arg for EncodeFrame )
    //
    int QueryOutputSize() const;
    const BITMAPINFOHEADER& QueryOutputFormat() const;
    //
    // Encodes single frame
    // On success, is_keyframe contains 0 if frame was encoded into delta frame, otherwise AVIIF_KEYFRAME (?)
    // size receives size of compressed frame
    //
    int EncodeFrame(CImage* src, void* dest, int* is_keyframe, size_t* size, int* lpckid=0);
    //
    // Quality takes values from 0 to 10000, 10000 the best
    //
    int SetQuality(int quality);
    int GetQuality() const;
    int SetKeyFrame(int frequency);
    int GetKeyFrame(){return m_iKfFreq;}
protected:
    // HIC hic; // the heart of encoder
    VideoCodec* codec;
    int m_comp_id;    
    int m_iState;
    BitmapInfo *m_bh;
    BITMAPINFOHEADER *m_obh;
    int m_iFrameNum;
    int m_iQual;
    int m_iKfFreq;
    uint8_t* m_prev;
};

class CodecInfoKeeper
{
public:
    CodecInfoKeeper();
};
    
#endif
