#ifndef X265_FRAMEFILTER_H
#define X265_FRAMEFILTER_H
#include "common.h"
#include "frame.h"
#include "deblock.h"
#include "sao.h"
#include "threadpool.h"
namespace X265_NS {
class Encoder;
class Entropy;
class FrameEncoder;
struct ThreadLocalData;
class FrameFilter
{
public:
x265_param* m_param;
Frame* m_frame;
FrameEncoder* m_frameEncoder;
int m_hChromaShift;
int m_vChromaShift;
int m_pad[2];
int m_numRows;
int m_numCols;
int m_saoRowDelay;
int m_lastHeight;
int m_lastWidth;
ThreadSafeInteger integralCompleted;
void* m_ssimBuf;
#define MAX_PFILTER_CUS (4)
class ParallelFilter : public BondedTaskGroup, public Deblock
{
public:
uint32_t m_rowHeight;
int m_row;
uint32_t m_rowAddr;
FrameFilter* m_frameFilter;
FrameData* m_encData;
ParallelFilter* m_prevRow;
SAO m_sao;
ThreadSafeInteger m_lastCol;
ThreadSafeInteger m_allowedCol;
ThreadSafeInteger m_lastDeblocked;
ParallelFilter()
: m_rowHeight(0)
, m_row(0)
, m_rowAddr(0)
, m_frameFilter(NULL)
, m_encData(NULL)
, m_prevRow(NULL)
{
}
~ParallelFilter()
{ }
void processTasks(int workerThreadId);
void processSaoCTU(SAOParam *saoParam, int col);
void copySaoAboveRef(const CUData *ctu, PicYuv* reconPic, uint32_t cuAddr, int col);
void processPostCu(int col) const;
uint32_t getCUHeight() const
{
return m_rowHeight;
}
protected:
ParallelFilter operator=(const ParallelFilter&);
};
ParallelFilter* m_parallelFilter;
FrameFilter()
: m_param(NULL)
, m_frame(NULL)
, m_frameEncoder(NULL)
, m_ssimBuf(NULL)
, m_parallelFilter(NULL)
{
}
uint32_t getCUWidth(int colNum) const
{
return (colNum == (int)m_numCols - 1) ? m_lastWidth : m_param->maxCUSize;
}
void init(Encoder *top, FrameEncoder *frame, int numRows, uint32_t numCols);
void destroy();
void start(Frame *pic, Entropy& initState);
void processRow(int row);
void processPostRow(int row);
void computeMEIntegral(int row);
};
}
#endif