OSDN Git Service

Updated copyright year.
[x264-launcher/x264-launcher.git] / src / encoder_factory.cpp
1 ///////////////////////////////////////////////////////////////////////////////
2 // Simple x264 Launcher
3 // Copyright (C) 2004-2022 LoRd_MuldeR <MuldeR2@GMX.de>
4 //
5 // This program is free software; you can redistribute it and/or modify
6 // it under the terms of the GNU General Public License as published by
7 // the Free Software Foundation; either version 2 of the License, or
8 // (at your option) any later version.
9 //
10 // This program is distributed in the hope that it will be useful,
11 // but WITHOUT ANY WARRANTY; without even the implied warranty of
12 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
13 // GNU General Public License for more details.
14 //
15 // You should have received a copy of the GNU General Public License along
16 // with this program; if not, write to the Free Software Foundation, Inc.,
17 // 51 Franklin Street, Fifth Floory, Boston, MA 02110-1301 USA.
18 //
19 // http://www.gnu.org/licenses/gpl-2.0.txt
20 ///////////////////////////////////////////////////////////////////////////////
21
22 #include "encoder_factory.h"
23
24 //Internal
25 #include "global.h"
26 #include "model_options.h"
27 #include "encoder_x264.h"
28 #include "encoder_x265.h"
29 #include "encoder_nvencc.h"
30
31 //MUtils
32 #include <MUtils/Exception.h>
33
34 AbstractEncoder *EncoderFactory::createEncoder(JobObject *jobObject, const OptionsModel *options, const SysinfoModel *const sysinfo, const PreferencesModel *const preferences, JobStatus &jobStatus, volatile bool *abort, volatile bool *pause, QSemaphore *semaphorePause, const QString &sourceFile, const QString &outputFile)
35 {
36         AbstractEncoder *encoder = NULL;
37
38         switch(options->encType())
39         {
40         case OptionsModel::EncType_X264:
41                 encoder = new X264Encoder(jobObject, options, sysinfo, preferences, jobStatus, abort, pause, semaphorePause, sourceFile, outputFile);
42                 break;
43         case OptionsModel::EncType_X265:
44                 encoder = new X265Encoder(jobObject, options, sysinfo, preferences, jobStatus, abort, pause, semaphorePause, sourceFile, outputFile);
45                 break;
46         case OptionsModel::EncType_NVEnc:
47                 encoder = new NVEncEncoder(jobObject, options, sysinfo, preferences, jobStatus, abort, pause, semaphorePause, sourceFile, outputFile);
48                 break;
49         default:
50                 MUTILS_THROW("Unknown encoder type encountered!");
51         }
52
53         return encoder;
54 }
55
56 const AbstractEncoderInfo& EncoderFactory::getEncoderInfo(const OptionsModel::EncType &encoderType)
57 {
58         switch(encoderType)
59         {
60         case OptionsModel::EncType_X264:
61                 return X264Encoder::encoderInfo();
62         case OptionsModel::EncType_X265:
63                 return X265Encoder::encoderInfo();
64         case OptionsModel::EncType_NVEnc:
65                 return NVEncEncoder::encoderInfo();
66         default:
67                 MUTILS_THROW("Unknown encoder type encountered!");
68         }
69
70         return *((AbstractEncoderInfo*)NULL);
71 }