VideoCodec/Modules/Pipeline/Pipeline.h
#ifndef PIPELINE_H_
#define PIPELINE_H_
#include <Magick++.h>
#include <sys/time.h>
#include <map>
#include <utility>
#include "../../Logger.h"
#include "../../Configuration/ConfigurationElement.h"
#include "../../Data/FrameHeader.h"
#include "../../Data/Constants.h"
#include "../../Data/StreamHeader.h"
#include "../../Decoder/BinaryStreamReader.h"
#include "../../Encoder/BinaryStreamBuilder.h"
#include "../../Codec.h"
#include "../Module.h"
#include "../Input/FrameInputModule.h"
#include "../Input/StreamInputModule.h"
#include "../Output/FrameOutputModule.h"
#include "../Output/StreamOutputModule.h"
#include "../StreamCoding/HuffmanEntropyEncoder.h"
#include "../StreamFormat/StreamFormatter.h"
#include "../StreamFormat/StreamParser.h"
#include "../Transform/DCT.h"
// Normally, pipeline diagnostics would be disabled when debug is off, but they can be enabled here.
#ifdef DEBUG
// Options for debug build.
#define PERFORMANCE_TIMING_IN_LOOP
#define PIPELINE_DIAGNOSTICS
#define PERFORMANCE_BITS_ENABLED
#else
// Options for release build.
#undef PERFORMANCE_TIMING_IN_LOOP
#undef PIPELINE_DIAGNOSTICS
#define PERFORMANCE_BITS_ENABLED
#endif
// Blank definitions if diagnostics are off, for speed.
// x is an index into the array of temporary timing variables. A value should be used which is not equal to those of any other timers going at the same time.
// i is an index and y is a string, uniquely identifying the timer in the performance statistics map.
#ifdef PERFORMANCE_TIMING_IN_LOOP
#define PERFORMANCE_TIMING_IN_LOOP_BEFORE(x) if (this->diagnosticPerformanceTimingInLoop) startTimes[x] = this->getTime();
#define PERFORMANCE_TIMING_IN_LOOP_AFTER(x,y,i) if (this->diagnosticPerformanceTimingInLoop) performanceDetails[pair<const char*,unsigned char>(y,i)] = this->getTime() - startTimes[x];
#else
#define PERFORMANCE_TIMING_IN_LOOP_BEFORE(x)
#define PERFORMANCE_TIMING_IN_LOOP_AFTER(x,y,i)
#endif
// Always define performance timing for outside loop, as this will not have a significant impact on performance.
#define PERFORMANCE_TIMING_BEFORE(x) startTimes[x] = this->getTime();
#define PERFORMANCE_TIMING_AFTER(x,y,i) performanceDetails[pair<const char*,unsigned char>(y,i)] = this->getTime() - startTimes[x];
// Measure the stream bit count per frame and for the entire stream.
#ifdef PERFORMANCE_BITS_ENABLED
#define PERFORMANCE_BITS(x,y,i) performanceDetails[pair<const char*,unsigned char>(y,i)] = (x); performanceStreamBits += (x);
#else
#define PERFORMANCE_BITS(x,y,i)
#endif
namespace VideoCodec
{
class Codec;
class Pipeline : public Module
{
public:
Pipeline();
virtual ~Pipeline();
ConfigurationStatus Configure(ConfigurationElement* configuration);
void Run(Codec* codec);
private:
void codeFrame(PictureInfo* picture, FrameDataBitLength codedLength, StreamFormatter* formatter, HuffmanEntropyEncoder* entropyEncoder, DCTCoefficientQuantizationMethod quantizationMethod, UnsignedByte quantizationScale, bool mv4);
void encodePath(Codec* codec);
void decodePath(Codec* codec);
int64_t getTime(void);
void monitoringCheckpoint(double* values, unsigned char pointNumber);
int type;
int64_t tempTimingValue;
bool diagnosticOutputResiduals;
bool diagnosticShowVectors;
bool diagnosticPerformanceTimingInLoop;
bool diagnosticPerformanceTimingPerLoop;
bool diagnosticPerformanceTimingGlobal;
bool diagnosticPerformanceBits;
bool mv4;
};
}
#endif /*PIPELINE_H_*/