1 /*****************************************************************************
2 * Copyright (C) 2013 x265 project
4 * Authors: Deepthi Nandakumar <deepthi@multicorewareinc.com>
5 * Steve Borho <steve@borho.org>
7 * This program is free software; you can redistribute it and/or modify
8 * it under the terms of the GNU General Public License as published by
9 * the Free Software Foundation; either version 2 of the License, or
10 * (at your option) any later version.
12 * This program is distributed in the hope that it will be useful,
13 * but WITHOUT ANY WARRANTY; without even the implied warranty of
14 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15 * GNU General Public License for more details.
17 * You should have received a copy of the GNU General Public License
18 * along with this program; if not, write to the Free Software
19 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02111, USA.
21 * This program is also available under a commercial proprietary license.
22 * For more information, contact us at license @ x265.com.
23 *****************************************************************************/
25 #ifndef X265_ANALYSIS_H
26 #define X265_ANALYSIS_H
43 class Analysis
: public Search
59 PRED_INTRA_NxN
, /* 4x4 intra PU blocks for 8x8 CU */
60 PRED_LOSSLESS
, /* lossless encode of best mode */
66 Mode pred
[MAX_PRED_TYPES
];
69 CUDataMemPool cuMemPool
;
72 ModeDepth m_modeDepth
[NUM_CU_DEPTH
];
76 bool create(ThreadLocalData
* tld
);
78 Search::Mode
& compressCTU(CUData
& ctu
, Frame
& frame
, const CUGeom
& cuGeom
, const Entropy
& initialContext
);
82 /* mode analysis distribution */
84 volatile int m_numAcquiredJobs
;
85 volatile int m_numCompletedJobs
;
86 Event m_modeCompletionEvent
;
87 bool findJob(int threadId
);
88 void parallelModeAnalysis(int threadId
, int jobId
);
89 void parallelME(int threadId
, int meId
);
91 /* full analysis for an I-slice CU */
92 void compressIntraCU(const CUData
& parentCTU
, const CUGeom
& cuGeom
, x265_intra_data
* sdata
, uint32_t &zOrder
);
94 /* full analysis for a P or B slice CU */
95 void compressInterCU_dist(const CUData
& parentCTU
, const CUGeom
& cuGeom
);
96 void compressInterCU_rd0_4(const CUData
& parentCTU
, const CUGeom
& cuGeom
);
97 void compressInterCU_rd5_6(const CUData
& parentCTU
, const CUGeom
& cuGeom
);
99 /* measure merge and skip */
100 void checkMerge2Nx2N_rd0_4(Mode
& skip
, Mode
& merge
, const CUGeom
& cuGeom
);
101 void checkMerge2Nx2N_rd5_6(Mode
& skip
, Mode
& merge
, const CUGeom
& cuGeom
);
103 /* measure inter options */
104 void checkInter_rd0_4(Mode
& interMode
, const CUGeom
& cuGeom
, PartSize partSize
);
105 void checkInter_rd5_6(Mode
& interMode
, const CUGeom
& cuGeom
, PartSize partSize
, bool bMergeOnly
);
107 /* measure intra options */
108 void checkIntraInInter_rd0_4(Mode
& intraMode
, const CUGeom
& cuGeom
);
109 void encodeIntraInInter(Mode
& intraMode
, const CUGeom
& cuGeom
);
111 /* encode current bestMode losslessly, pick best RD cost */
112 void tryLossless(const CUGeom
& cuGeom
);
114 void checkDQP(CUData
& cu
, const CUGeom
& cuGeom
);
115 void addSplitFlagCost(Mode
& mode
, uint32_t depth
);
116 void checkBestMode(Mode
& mode
, uint32_t depth
);
117 uint32_t topSkipMinDepth(const CUData
& parentCTU
, const CUGeom
& cuGeom
);
118 bool recursionDepthCheck(const CUData
& parentCTU
, const CUGeom
& cuGeom
, const Mode
& bestMode
);
120 void encodeResidue(const CUData
& parentCTU
, const CUGeom
& cuGeom
);
123 struct ThreadLocalData
127 void destroy() { analysis
.destroy(); }
132 #endif // ifndef X265_ANALYSIS_H