Skip to content

Commit

Permalink
Merge pull request #470 from atsampson/sclocked
Browse files Browse the repository at this point in the history
Initial support for subcarrier-locked sampling.
  • Loading branch information
Simon Inns authored Mar 8, 2020
2 parents 8954a19 + 3736ab0 commit 0c641fc
Show file tree
Hide file tree
Showing 4 changed files with 23 additions and 1 deletion.
1 change: 1 addition & 0 deletions tools/ld-chroma-decoder/encoder/palencoder.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -54,6 +54,7 @@ PALEncoder::PALEncoder(QFile &_rgbFile, QFile &_tbcFile, LdDecodeMetaData &_meta
// Initialise video parameters based on ld-decode's usual output.
// numberOfSequentialFields will be computed automatically.
videoParameters.isSourcePal = true;
videoParameters.isSubcarrierLocked = false;
videoParameters.colourBurstStart = 98;
videoParameters.colourBurstEnd = 138;
videoParameters.activeVideoStart = 185;
Expand Down
20 changes: 19 additions & 1 deletion tools/ld-chroma-decoder/sourcefield.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,8 @@ void SourceField::loadFields(SourceVideo &sourceVideo, LdDecodeMetaData &ldDecod
qint32 lookBehindFrames, qint32 lookAheadFrames,
QVector<SourceField> &fields, qint32 &startIndex, qint32 &endIndex)
{
const LdDecodeMetaData::VideoParameters &videoParameters = ldDecodeMetaData.getVideoParameters();

// Work out indexes.
// fields will contain {lookbehind fields... [startIndex] real fields... [endIndex] lookahead fields...}.
startIndex = 2 * lookBehindFrames;
Expand All @@ -54,15 +56,31 @@ void SourceField::loadFields(SourceVideo &sourceVideo, LdDecodeMetaData &ldDecod
fields[i].field = ldDecodeMetaData.getField(firstFieldNumber);
fields[i + 1].field = ldDecodeMetaData.getField(secondFieldNumber);

const quint16 black = videoParameters.black16bIre;

if (useBlankFrame) {
// Fill both fields with black
const quint16 black = ldDecodeMetaData.getVideoParameters().black16bIre;
fields[i].data.fill(black, sourceVideo.getFieldLength());
fields[i + 1].data.fill(black, sourceVideo.getFieldLength());
} else {
// Fetch the input fields
fields[i].data = sourceVideo.getVideoField(firstFieldNumber);
fields[i + 1].data = sourceVideo.getVideoField(secondFieldNumber);

if (videoParameters.isSourcePal && videoParameters.isSubcarrierLocked) {
// With subcarrier-locked 4fSC PAL sampling, we have four
// "extra" samples over the course of the frame, so the two
// fields will be horizontally misaligned by two samples. Shift
// the second field to the left to compensate.
//
// XXX This should be done elsewhere, as it affects other tools
// too.

fields[i + 1].data.remove(0, 2);
for (int j = 0; j < 2; j++) {
fields[i + 1].data.append(black);
}
}
}

frameNumber++;
Expand Down
2 changes: 2 additions & 0 deletions tools/library/tbc/lddecodemetadata.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -71,6 +71,7 @@ LdDecodeMetaData::VideoParameters LdDecodeMetaData::getVideoParameters()
if (json.size({"videoParameters"}) > 0) {
videoParameters.numberOfSequentialFields = json.value({"videoParameters", "numberOfSequentialFields"}).toInt();
videoParameters.isSourcePal = json.value({"videoParameters", "isSourcePal"}).toBool();
videoParameters.isSubcarrierLocked = json.value({"videoParameters", "isSubcarrierLocked"}).toBool();

videoParameters.colourBurstStart = json.value({"videoParameters", "colourBurstStart"}).toInt();
videoParameters.colourBurstEnd = json.value({"videoParameters", "colourBurstEnd"}).toInt();
Expand Down Expand Up @@ -121,6 +122,7 @@ void LdDecodeMetaData::setVideoParameters (LdDecodeMetaData::VideoParameters _vi
// Write the video parameters
json.setValue({"videoParameters", "numberOfSequentialFields"}, getNumberOfFields());
json.setValue({"videoParameters", "isSourcePal"}, _videoParameters.isSourcePal);
json.setValue({"videoParameters", "isSubcarrierLocked"}, _videoParameters.isSubcarrierLocked);

json.setValue({"videoParameters", "colourBurstStart"}, _videoParameters.colourBurstStart);
json.setValue({"videoParameters", "colourBurstEnd"}, _videoParameters.colourBurstEnd);
Expand Down
1 change: 1 addition & 0 deletions tools/library/tbc/lddecodemetadata.h
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,7 @@ class LdDecodeMetaData
qint32 numberOfSequentialFields;

bool isSourcePal;
bool isSubcarrierLocked;

qint32 colourBurstStart;
qint32 colourBurstEnd;
Expand Down

0 comments on commit 0c641fc

Please sign in to comment.