Mercurial > hg > forks > libbpg
comparison x265/source/encoder/encoder.h @ 0:772086c29cc7
Initial import.
author | Matti Hamalainen <ccr@tnsp.org> |
---|---|
date | Wed, 16 Nov 2016 11:16:33 +0200 |
parents | |
children |
comparison
equal
deleted
inserted
replaced
-1:000000000000 | 0:772086c29cc7 |
---|---|
1 /***************************************************************************** | |
2 * Copyright (C) 2013 x265 project | |
3 * | |
4 * Authors: Steve Borho <steve@borho.org> | |
5 * | |
6 * This program is free software; you can redistribute it and/or modify | |
7 * it under the terms of the GNU General Public License as published by | |
8 * the Free Software Foundation; either version 2 of the License, or | |
9 * (at your option) any later version. | |
10 * | |
11 * This program is distributed in the hope that it will be useful, | |
12 * but WITHOUT ANY WARRANTY; without even the implied warranty of | |
13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | |
14 * GNU General Public License for more details. | |
15 * | |
16 * You should have received a copy of the GNU General Public License | |
17 * along with this program; if not, write to the Free Software | |
18 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02111, USA. | |
19 * | |
20 * This program is also available under a commercial proprietary license. | |
21 * For more information, contact us at license @ x265.com. | |
22 *****************************************************************************/ | |
23 | |
24 #ifndef X265_ENCODER_H | |
25 #define X265_ENCODER_H | |
26 | |
27 #include "common.h" | |
28 #include "slice.h" | |
29 #include "scalinglist.h" | |
30 #include "x265.h" | |
31 #include "nal.h" | |
32 | |
33 struct x265_encoder {}; | |
34 | |
35 namespace X265_NS { | |
36 // private namespace | |
37 extern const char g_sliceTypeToChar[3]; | |
38 | |
39 class Entropy; | |
40 | |
41 struct EncStats | |
42 { | |
43 double m_psnrSumY; | |
44 double m_psnrSumU; | |
45 double m_psnrSumV; | |
46 double m_globalSsim; | |
47 double m_totalQp; | |
48 uint64_t m_accBits; | |
49 uint32_t m_numPics; | |
50 uint16_t m_maxCLL; | |
51 double m_maxFALL; | |
52 | |
53 EncStats() | |
54 { | |
55 m_psnrSumY = m_psnrSumU = m_psnrSumV = m_globalSsim = 0; | |
56 m_accBits = 0; | |
57 m_numPics = 0; | |
58 m_totalQp = 0; | |
59 m_maxCLL = 0; | |
60 m_maxFALL = 0; | |
61 } | |
62 | |
63 void addQP(double aveQp); | |
64 | |
65 void addPsnr(double psnrY, double psnrU, double psnrV); | |
66 | |
67 void addBits(uint64_t bits); | |
68 | |
69 void addSsim(double ssim); | |
70 }; | |
71 | |
72 class FrameEncoder; | |
73 class DPB; | |
74 class Lookahead; | |
75 class RateControl; | |
76 class ThreadPool; | |
77 | |
78 class Encoder : public x265_encoder | |
79 { | |
80 public: | |
81 | |
82 int m_pocLast; // time index (POC) | |
83 int m_encodedFrameNum; | |
84 int m_outputCount; | |
85 | |
86 int m_bframeDelay; | |
87 int64_t m_firstPts; | |
88 int64_t m_bframeDelayTime; | |
89 int64_t m_prevReorderedPts[2]; | |
90 | |
91 ThreadPool* m_threadPool; | |
92 FrameEncoder* m_frameEncoder[X265_MAX_FRAME_THREADS]; | |
93 DPB* m_dpb; | |
94 | |
95 Frame* m_exportedPic; | |
96 | |
97 int m_numPools; | |
98 int m_curEncoder; | |
99 | |
100 /* Collect statistics globally */ | |
101 EncStats m_analyzeAll; | |
102 EncStats m_analyzeI; | |
103 EncStats m_analyzeP; | |
104 EncStats m_analyzeB; | |
105 int64_t m_encodeStartTime; | |
106 | |
107 // weighted prediction | |
108 int m_numLumaWPFrames; // number of P frames with weighted luma reference | |
109 int m_numChromaWPFrames; // number of P frames with weighted chroma reference | |
110 int m_numLumaWPBiFrames; // number of B frames with weighted luma reference | |
111 int m_numChromaWPBiFrames; // number of B frames with weighted chroma reference | |
112 FILE* m_analysisFile; | |
113 int m_conformanceMode; | |
114 VPS m_vps; | |
115 SPS m_sps; | |
116 PPS m_pps; | |
117 NALList m_nalList; | |
118 ScalingList m_scalingList; // quantization matrix information | |
119 | |
120 bool m_emitCLLSEI; | |
121 int m_lastBPSEI; | |
122 uint32_t m_numDelayedPic; | |
123 | |
124 x265_param* m_param; | |
125 x265_param* m_latestParam; | |
126 RateControl* m_rateControl; | |
127 Lookahead* m_lookahead; | |
128 Window m_conformanceWindow; | |
129 | |
130 bool m_bZeroLatency; // x265_encoder_encode() returns NALs for the input picture, zero lag | |
131 bool m_aborted; // fatal error detected | |
132 bool m_reconfigured; // reconfigure of encoder detected | |
133 | |
134 uint32_t m_residualSumEmergency[MAX_NUM_TR_CATEGORIES][MAX_NUM_TR_COEFFS]; | |
135 uint16_t (*m_offsetEmergency)[MAX_NUM_TR_CATEGORIES][MAX_NUM_TR_COEFFS]; | |
136 uint32_t m_countEmergency[MAX_NUM_TR_CATEGORIES]; | |
137 | |
138 Encoder(); | |
139 ~Encoder() {} | |
140 | |
141 void create(); | |
142 void stopJobs(); | |
143 void destroy(); | |
144 | |
145 int encode(const x265_picture* pic, x265_picture *pic_out); | |
146 | |
147 int reconfigureParam(x265_param* encParam, x265_param* param); | |
148 | |
149 void getStreamHeaders(NALList& list, Entropy& sbacCoder, Bitstream& bs); | |
150 | |
151 void fetchStats(x265_stats* stats, size_t statsSizeBytes); | |
152 | |
153 void printSummary(); | |
154 | |
155 char* statsString(EncStats&, char*); | |
156 | |
157 void configure(x265_param *param); | |
158 | |
159 void updateVbvPlan(RateControl* rc); | |
160 | |
161 void allocAnalysis(x265_analysis_data* analysis); | |
162 | |
163 void freeAnalysis(x265_analysis_data* analysis); | |
164 | |
165 void readAnalysisFile(x265_analysis_data* analysis, int poc); | |
166 | |
167 void writeAnalysisFile(x265_analysis_data* pic); | |
168 | |
169 void finishFrameStats(Frame* pic, FrameEncoder *curEncoder, uint64_t bits, x265_frame_stats* frameStats); | |
170 | |
171 protected: | |
172 | |
173 void initVPS(VPS *vps); | |
174 void initSPS(SPS *sps); | |
175 void initPPS(PPS *pps); | |
176 }; | |
177 } | |
178 | |
179 #endif // ifndef X265_ENCODER_H |