1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137
|
/*****************************************************************************
* Copyright (C) 2013-2020 MulticoreWare, Inc
*
* Authors: Chung Shin Yee <shinyee@multicorewareinc.com>
* Min Chen <chenm003@163.com>
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02111, USA.
*
* This program is also available under a commercial proprietary license.
* For more information, contact us at license @ x265.com.
*****************************************************************************/
#ifndef X265_FRAMEFILTER_H
#define X265_FRAMEFILTER_H
#include "common.h"
#include "frame.h"
#include "deblock.h"
#include "sao.h"
#include "threadpool.h" // class BondedTaskGroup
namespace X265_NS {
// private x265 namespace
class Encoder;
class Entropy;
class FrameEncoder;
struct ThreadLocalData;
// Manages the processing of a single frame loopfilter
class FrameFilter
{
public:
x265_param* m_param;
Frame* m_frame;
int m_useSao;
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; /* check if integral calculation is completed in this row */
void* m_ssimBuf; /* Temp storage for ssim computation */
#define MAX_PFILTER_CUS (4) /* maximum CUs for every thread */
class ParallelFilter : 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; /* The column that next to process */
ThreadSafeInteger m_allowedCol; /* The column that processed from Encode pipeline */
ThreadSafeInteger m_lastDeblocked; /* The column that finished all of Deblock stages */
ParallelFilter()
: m_rowHeight(0)
, m_row(0)
, m_rowAddr(0)
, m_frameFilter(NULL)
, m_encData(NULL)
, m_prevRow(NULL)
{
}
~ParallelFilter()
{ }
void processTasks(int workerThreadId);
// Apply SAO on a CU in current row
void processSaoCTU(SAOParam *saoParam, int col);
// Copy and Save SAO reference pixels for SAO Rdo decide
void copySaoAboveRef(const CUData *ctu, PicYuv* reconPic, uint32_t cuAddr, int col);
// Post-Process (Border extension)
void processPostCu(int col) const;
uint32_t getCUHeight() const
{
return m_rowHeight;
}
};
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, int layer);
void processPostRow(int row, int layer);
void computeMEIntegral(int row, int layer);
};
}
#endif // ifndef X265_FRAMEFILTER_H
|