Skip to content

Commit e481fe8

Browse files
committed
PCM-1 manual offset, fixed STC-007 CWD, GUI fixes
Added manual vertical data offset control for PCM-1, fixed PCM-1 stray header line processing as audio, fixed STC-007 CWD, added display for STC-007 address code, moved VU-envelope generation into AudioProcessor to reduce GUI lagging, small AudioProcessor rework to support advanced interpolation modes in the future, visualizer optimizations, added new tooltips and translations.
1 parent 7f335e5 commit e481fe8

42 files changed

Lines changed: 4620 additions & 3338 deletions

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

SDVPCMdecoder.pro

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44
#
55
#-------------------------------------------------
66

7-
QT += core gui winextras
7+
QT += core gui opengl winextras
88

99
greaterThan(QT_MAJOR_VERSION, 4): QT += widgets multimedia concurrent
1010

@@ -28,10 +28,10 @@ QMAKE_CFLAGS_RELEASE += -O3 -march=pentium3m
2828

2929
QMAKE_CXXFLAGS+= -D__STDC_CONSTANT_MACROS -fpermissive
3030

31-
VERSION = 0.99.5
31+
VERSION = 0.99.6
3232
win32: QMAKE_TARGET_COMPANY = Fagear
3333
win32: QMAKE_TARGET_PRODUCT = SD video PCM decoder
34-
win32: QMAKE_TARGET_DESCRIPTION = SD video to digital audio PCM decoder
34+
win32: QMAKE_TARGET_DESCRIPTION = SD video to digital audio decoder
3535
win32: QMAKE_TARGET_COPYRIGHT = (c) Fagear
3636
win32: RC_LANG = 0x0419
3737

SDVPCMdecoder_en.ts

Lines changed: 811 additions & 561 deletions
Large diffs are not rendered by default.

SDVPCMdecoder_pl.ts

Lines changed: 807 additions & 566 deletions
Large diffs are not rendered by default.

about_wnd.ui

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -58,7 +58,7 @@
5858
<bool>true</bool>
5959
</property>
6060
<property name="text">
61-
<string>&lt;html&gt;&lt;head/&gt;&lt;body&gt;&lt;p&gt;+ &lt;span style=&quot; font-weight:600;&quot;&gt;PCM-1&lt;/span&gt; (2 канала, 13 бит, 44056 Гц, Sony Standard B, NTSC)&lt;br/&gt;+ &lt;span style=&quot; font-weight:600;&quot;&gt;PCM-1600&lt;/span&gt; (2 канала, 16 бит, 44056 Гц, Sony Standard A, NTSC)&lt;br/&gt;+ &lt;span style=&quot; font-weight:600;&quot;&gt;PCM-1610&lt;/span&gt; (2 канала, 16 бит, 44056/44100 Гц, NTSC)&lt;br/&gt;+ &lt;span style=&quot; font-weight:600;&quot;&gt;PCM-1630&lt;/span&gt; (2 канала, 16 бит, 44056/44100 Гц, NTSC)&lt;br/&gt;+ &lt;span style=&quot; font-weight:600;&quot;&gt;STC-007&lt;/span&gt; (2 канала, 14 бит, 44056 Гц, EIAJ NTSC)&lt;br/&gt;+ &lt;span style=&quot; font-weight:600;&quot;&gt;STC-008&lt;/span&gt; (2 канала, 14 бит, 44100 Гц, EIAJ PAL)&lt;br/&gt;+ &lt;span style=&quot; font-weight:600;&quot;&gt;PCM-F1&lt;/span&gt; (2 канала, 16 бит, 44056/44100 Гц, NTSC/PAL)&lt;/p&gt;&lt;/body&gt;&lt;/html&gt;</string>
61+
<string>&lt;html&gt;&lt;head/&gt;&lt;body&gt;&lt;p&gt;+ &lt;span style=&quot; font-weight:600;&quot;&gt;PCM-1&lt;/span&gt; (2 канала, 13 бит, 44056 Гц, Sony Standard B, NTSC)&lt;br/&gt;+ &lt;span style=&quot; font-weight:600;&quot;&gt;PCM-1600&lt;/span&gt; (2 канала, 16 бит, 44056 Гц, Sony Standard A, NTSC)&lt;br/&gt;+ &lt;span style=&quot; font-weight:600;&quot;&gt;PCM-1610&lt;/span&gt; (2 канала, 16 бит, 44056/44100 Гц, NTSC)&lt;br/&gt;+ &lt;span style=&quot; font-weight:600;&quot;&gt;PCM-1630&lt;/span&gt; (2 канала, 16 бит, 44056/44100 Гц, NTSC)&lt;br/&gt;+ &lt;span style=&quot; font-weight:600;&quot;&gt;STC-007&lt;/span&gt; (2 канала, 14 бит, 44056 Гц, EIAJ NTSC)&lt;br/&gt;+ &lt;span style=&quot; font-weight:600;&quot;&gt;STC-008&lt;/span&gt; (2 канала, 14 бит, 44100 Гц, EIAJ PAL)&lt;br/&gt;+ &lt;span style=&quot; font-weight:600;&quot;&gt;PCM-F1&lt;/span&gt; (2 канала, 16 бит, 44056/44100 Гц, Sony PCM-F1, NTSC/PAL)&lt;/p&gt;&lt;/body&gt;&lt;/html&gt;</string>
6262
</property>
6363
</widget>
6464
</item>

audioprocessor.cpp

Lines changed: 166 additions & 74 deletions
Large diffs are not rendered by default.

audioprocessor.h

Lines changed: 22 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,7 @@
1515
#include <QString>
1616
#include "config.h"
1717
#include "frametrimset.h"
18+
#include "lookup.h"
1819
#include "pcmsamplepair.h"
1920
#include "samples2audio.h"
2021
#include "samples2wav.h"
@@ -48,7 +49,7 @@ class AudioProcessor : public QObject
4849
MIN_LONG_INVALID = 16, // Minimum length of invalid region to be count as long.
4950
MAX_STRAY_LEN = 24, // Maximum length of valid region to be count as stray.
5051
MIN_VALID_BEFORE = 3, // Minimum number of valid data points to keep at the start of the buffer.
51-
MAX_RAMP_DOWN = 128, // Length of ramp-down to mute region (in data points).
52+
MAX_RAMP_DOWN = 192, // Length of ramp-down to mute region (in data points).
5253
MAX_RAMP_UP = 32, // Length of ramp-up from mute region (in data points).
5354
CHANNEL_CNT = PCMSamplePair::CH_MAX, // Number of channels for processing.
5455
};
@@ -75,21 +76,22 @@ class AudioProcessor : public QObject
7576
private:
7677
SamplesToAudio sc_output; // Handler for soundcard operations.
7778
SamplesToWAV wav_output; // Handler for WAV-file operations.
78-
QString file_path;
79-
QString file_name;
8079
std::deque<PCMSamplePair> *in_samples; // Input sample pair queue (shared).
8180
QMutex *mtx_samples; // Mutex for input queue.
82-
QTimer *tim_outflush;
81+
QTimer *tim_outflush; // Timer for dumping output from cache when input stalles.
82+
QTimer *tim_vu_fade; // Timer for VU levels drop off.
8383
std::deque<PCMSamplePair> prebuffer; // Buffer for input data.
8484
std::deque<PCMSample> channel_bufs[CHANNEL_CNT]; // Per-channel buffers for sample processing.
85-
std::deque<CoordinatePair> long_bads[CHANNEL_CNT];
85+
std::deque<CoordinatePair> long_bads[CHANNEL_CNT]; // Per-channel buffers for regions of long invalid samples.
8686
uint8_t log_level; // Level of debug output.
8787
uint8_t mask_mode; // Mode of masking dropouts.
88-
uint16_t min_valid_before;
89-
uint16_t max_ramp_down;
90-
uint16_t max_ramp_up;
88+
uint16_t min_valid_before; // Minimum number of valid data points at the front of the buffer.
89+
uint16_t max_ramp_down; // Length of ramp-down for interpolation from last valid sample into silence (inside invalid region).
90+
uint16_t max_ramp_up; // Length of ramp-up for interpolation from silence (inside invalid region) into first valid sample.
9191
uint64_t sample_index; // Master index for samples for the current file.
9292
uint16_t sample_rate; // Last sample rate.
93+
uint8_t vu_left; // VU-level for the left channel.
94+
uint8_t vu_right; // VU-level for the right channel.
9395
bool file_end; // Detected end of a file.
9496
bool unprocessed; // Are there unprocessed audio samples?
9597
bool remove_stray; // Invalidate stray VALID samples.
@@ -109,21 +111,25 @@ class AudioProcessor : public QObject
109111
uint16_t setInvalids(std::deque<PCMSample> *samples, CoordinatePair &range);
110112
void fixStraySamples(std::deque<PCMSample> *samples, std::deque<CoordinatePair> *regions);
111113
uint16_t clearInvalids(std::deque<PCMSample> *samples, CoordinatePair &range);
112-
uint16_t performMute(std::deque<PCMSample> *samples, CoordinatePair &range);
113-
uint16_t performLevelHold(std::deque<PCMSample> *samples, CoordinatePair &range);
114-
uint16_t performLinearInterpolation(std::deque<PCMSample> *samples, CoordinatePair &range);
114+
uint16_t sampleMute(std::deque<PCMSample> *samples, int16_t offset);
115+
uint16_t rangeMute(std::deque<PCMSample> *samples, CoordinatePair &range);
116+
uint16_t rangeLevelHold(std::deque<PCMSample> *samples, CoordinatePair &range);
117+
uint16_t rangeLinearInterpolation(std::deque<PCMSample> *samples, CoordinatePair &range);
115118
void fixBadSamples(std::deque<PCMSample> *samples);
116119
void dumpPrebuffer();
117120
void fillBufferForOutput();
121+
void samplesToVU(PCMSamplePair *in_samples);
118122
void outputWordPair(PCMSamplePair *out_samples);
119123
void outputAudio();
120124
bool scanBuffer();
121125
void dumpBuffer();
122126

123127
private slots:
124-
void restartFlushTimer();
125-
void actCloseOutput();
128+
void restartFlushTimer(); // Stop and start flushing timer.
129+
void redirectError(QString); // Receive error message and redirect it.
130+
void actFlushOutput(); // Timer event for flushing buffer.
126131
void livePlayUpdate(bool); // Emit [guiLivePB] signal to report live playback state.
132+
void updateVUMeters(); // Timer event for VU-meters updating and fading.
127133

128134
public slots:
129135
void setLogLevel(uint8_t); // Set logging level.
@@ -139,9 +145,11 @@ public slots:
139145
signals:
140146
void guiAddMask(uint16_t); // Report new masked samples.
141147
void guiLivePB(bool); // Report live playback state.
148+
void mediaError(QString); // Error while processing audio.
142149
void newSource(); // Report about changed source.
143-
void reqTimerRestart();
150+
void reqTimerRestart(); // Deffered call for [restartFlushTimer()].
144151
void outSamples(PCMSamplePair); // Copy of outputting samples.
152+
void outVULevels(uint8_t, uint8_t); // Report VU-meters.
145153
void stopOutput(); // Report about thread terminating.
146154
void finished();
147155
};

binarizer.h

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -9,9 +9,9 @@
99
*
1010
* This module takes one video line (of type [VideoLine]) and performs:
1111
* - AGC (Automatic Gain Control), statistically detecting BLACK and WHITE levels;
12-
* - Automatic reference level detection, detecting the best threshold for binarization;
12+
* - ARLD (Automatic Reference Level Detection), detecting the best threshold for binarization;
1313
* - TBC (Time-Based Correction), detecting horizontal offset of the PCM data in the line;
14-
* - binarization with set mode;
14+
* - Binarization with set mode;
1515
* - Brute force picking bits that were cut off the edge of the video line (for PCM-1 and PCM-16x0).
1616
*
1717
* Binarization itself can be done with different speed/quality ratios,

capt_sel.cpp

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,9 @@ capt_sel::capt_sel(QWidget *parent) :
1313
capt_dev = NULL;
1414
capture_rate = 100;
1515

16+
//ui->viewport->setViewportUpdateMode(QGraphicsView::NoViewportUpdate);
17+
ui->viewport->setOptimizationFlags(QGraphicsView::DontSavePainterState|QGraphicsView::DontAdjustForAntialiasing);
18+
1619
scene = new QGraphicsScene(this);
1720
ui->viewport->setScene(scene);
1821
ui->viewport->setAlignment(Qt::AlignLeft|Qt::AlignTop);
@@ -42,7 +45,7 @@ capt_sel::capt_sel(QWidget *parent) :
4245
connect(capt_dev, SIGNAL(sigInputClosed()), this, SLOT(captureClosed()));
4346
connect(capt_dev, SIGNAL(sigVideoError(uint32_t)), this, SLOT(captureError(uint32_t)));
4447
connect(capt_dev, SIGNAL(newDeviceList(VCapList)), this, SLOT(refillDevList(VCapList)));
45-
ffmpeg_thread->start();
48+
ffmpeg_thread->start(QThread::HighPriority);
4649

4750
connect(ui->btnClose, SIGNAL(clicked(bool)), this, SLOT(usrClose()));
4851
connect(ui->btnSave, SIGNAL(clicked(bool)), this, SLOT(usrSave()));
@@ -466,8 +469,10 @@ void capt_sel::redrawPreview(QImage in_image, bool in_double)
466469
return;
467470
}
468471
draw_rate = capt_meas.elapsed();
472+
// Check if this frame contains dropped frames counter.
469473
if(in_image.height()!=FFMPEGWrapper::DUMMY_HEIGTH)
470474
{
475+
// It's normal frame for displaying.
471476
//qDebug()<<"[CSEL] New image";
472477
// Update pixmap.
473478
pixels->setPixmap(QPixmap::fromImage(in_image.copy()));
@@ -488,6 +493,7 @@ void capt_sel::redrawPreview(QImage in_image, bool in_double)
488493
}
489494
else
490495
{
496+
// It's a dummy, containing dropped frames counter.
491497
qDebug()<<"[CSEL] New dummy image";
492498
// Skip dummy frame and request next one.
493499
pollCapture();

0 commit comments

Comments
 (0)