-
Notifications
You must be signed in to change notification settings - Fork 7
/
Copy pathcxenc.h
185 lines (159 loc) · 6.57 KB
/
cxenc.h
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
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
/**
* Copyright (C) 2021 Jo2003 (olenka.joerg@gmail.com)
* This file is part of cd2netmd_gui
*
* cd2netmd 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 3 of the License, or
* (at your option) any later version.
*
* cd2netmd 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
*/
#pragma once
#include "ccliprocess.h"
#include <QFile>
#include <QTimer>
#include "defines.h"
//------------------------------------------------------------------------------
//! @brief This class describes the atracdenc encoder handling.
//------------------------------------------------------------------------------
class CXEnc : public CCliProcess
{
Q_OBJECT
/// program executable path
#ifdef Q_OS_WIN
static constexpr const char* XENC_CLI = "toolchain/atracdenc.exe";
#elif defined Q_OS_MAC
static constexpr const char* XENC_CLI = "atracdenc";
#else
// hopefully in path
static constexpr const char* XENC_CLI = "atracdenc";
#endif
/// Sony WAVE format
static constexpr uint32_t WAVE_FORMAT_SONY_SCX = 624;
/// atrac3 header size in bytes
static constexpr uint32_t ATRAC3_HEADER_SIZE = 96;
/// atrac (SP) header size in bytes
static constexpr uint32_t ATRAC_SP_HEADER_SIZE = 2048;
/// block alignment for LP2 (used for DAO mode)
static constexpr uint32_t ATRAC3_LP2_BLOCK_ALIGN = 384;
/// block alignment for LP4
static constexpr uint32_t ATRAC3_LP4_BLOCK_ALIGN = 192;
/// block alignment for SP (mono)
static constexpr uint32_t ATRAC_SP_BLOCK_ALIGN = 212;
/// we always copy stereo
static constexpr uint32_t AT_SP_STEREO_BLOCK_SIZE = ATRAC_SP_BLOCK_ALIGN * 2;
public:
/// encoder commands
enum class XEncCmd : uint8_t
{
NONE, ///< nothing
LP2_ENCODE, ///< do LP2 encoding
LP4_ENCODE, ///< do LP4 encoding
DAO_LP2_ENCODE, ///< do DAO LP2 encoding
DAO_SP_ENCODE, ///< do DAO SP encoding
};
//--------------------------------------------------------------------------
//! @brief Constructs a new instance.
//!
//! @param parent The parent
//--------------------------------------------------------------------------
explicit CXEnc(QObject *parent = nullptr);
//--------------------------------------------------------------------------
//! @brief start encoder
//!
//! @param[in] cmd The command
//! @param[in] tmpFileName The temporary file name
//! @param[in] trackLength The track length
//! @param[in] at3tool optional path to alternate encoder
//!
//! @return 0 on success
//--------------------------------------------------------------------------
int start(XEncCmd cmd, const QString& tmpFileName, double trackLength, const QString& at3tool = "");
//--------------------------------------------------------------------------
//! @brief start the encoder
//!
//! @param[in] cmd The command
//! @param[in] queue The queue
//! @param[in] discLength The disc length
//! @param[in] at3tool optional path to alternate encoder
//!
//! @return 0 on success
//--------------------------------------------------------------------------
int start(XEncCmd cmd, const c2n::TransferQueue& queue, double discLength, const QString& at3tool = "");
protected:
//--------------------------------------------------------------------------
//! @brief create atrac3 WAVE header
//!
//! @param waveFile The wave file
//! @param[in] cmd The command
//! @param[in] dataSz The data size
//! @param[in] length The length
//!
//! @return 0 on success
//--------------------------------------------------------------------------
int atrac3WaveHeader(QFile& waveFile, XEncCmd cmd, size_t dataSz, int length);
//--------------------------------------------------------------------------
//! @brief create atrac1 (SP) header
//!
//! @param aeaFile The target file
//! @param[in] cmd The command
//! @param[in] dataSz The data size
//! @param[in] length The length
//!
//! @return 0 on success
//--------------------------------------------------------------------------
int atrac1Header(QFile& aeaFile, XEncCmd cmd, size_t dataSz, int length);
//--------------------------------------------------------------------------
//! @brief Splits an atrac 3.
//!
//! @return 0 on success
//--------------------------------------------------------------------------
int splitAtrac3();
//--------------------------------------------------------------------------
//! @brief Splits an atrac 1 (SP).
//!
//! @return 0 on success
//--------------------------------------------------------------------------
int splitAtrac1();
protected slots:
//--------------------------------------------------------------------------
//! @brief extract percentage from log file
//--------------------------------------------------------------------------
void extractPercent() override;
private slots:
//--------------------------------------------------------------------------
//! @brief Finishes a copy.
//!
//! @param[in] exitCode The exit code
//! @param[in] exitStatus The exit status
//--------------------------------------------------------------------------
void finishCopy(int exitCode, ExitStatus exitStatus);
signals:
//--------------------------------------------------------------------------
//! @brief signals that current file was handled
//!
//! @param[in] <unnamed> false
//--------------------------------------------------------------------------
void fileDone(bool);
protected:
/// current command
XEncCmd mCurrCmd;
/// file name for atrac3 output
QString mAtracFileName;
/// files to be handled
c2n::TransferQueue mQueue;
/// disc- / file - length
double mLength;
/// do we use the alternate encoder?
bool mbAltEnc;
/// stores current progress step
int mProgressIt;
/// used for external encoer for progress update
QTimer mProgUpd;
};