

#ifndef _FOOTAGE_BROWSER_H_
#define _FOOTAGE_BROWSER_H_

#include <stdint.h>
#include <string>
#include <lqt/lqt.h>
#include "LiftGammaGain.H"

typedef struct _frame_rgb {
	unsigned char* data;
	int w;
	int h;
} frame_rgb;

typedef struct _file_list {
	struct _file_list* next;
	std::string filename;
	int64_t length;
	void* this_file_open;
} file_list;

typedef struct _open_file {
	time_t last_used;
	quicktime_t* quicktime;
	file_list* file_entry;
	frame_rgb frame;
	unsigned char* data;
	unsigned char** rows;
	bool empty;
} open_file;


#define MAX_OPEN_FILES 20


class FootageBrowser
{
	public:
		FootageBrowser();
		~FootageBrowser();
		void addFile( const char* );
		void addFolder( const char* );
		frame_rgb* getNextFrame();
		frame_rgb* getFrame( int64_t position ); //Position in frames
		frame_rgb* getFrameFromLastClip( double position );
		int64_t getLength();
		void clear();
		std::string m_current_file;
		double m_position_in_clip;
		void lift( float r, float g, float b );
		void gain( float r, float g, float b );
		void gamma( float r, float g, float b );
		LiftGammaGain m_lgg;
		bool m_bypass;
		void gamma( float v ) {}
		void saturation( float v ) {}
		void brightness( float v ) {}
		void contrast( float v ) {}
	private:
		void apply_lut( frame_rgb* frame );
		int64_t framesInFile( const char* filename );
		void calcLength();
		file_list* m_files;
		open_file m_open_files[MAX_OPEN_FILES];
		open_file* m_last_used_clip;
		int64_t m_length;
		float m_gamma;
		float m_brightness; /* == gain */
		float m_saturation; 
		float m_contrast;
		unsigned char m_lut_gbc[256];
		
};

#endif /* _FOOTAGE_BROWSER_H_ */

