Skip to content

Commit

Permalink
Merge pull request #390 from atsampson/blackfields
Browse files Browse the repository at this point in the history
Fix piped TBC input with 3D chroma decoders
  • Loading branch information
Simon Inns authored Dec 30, 2019
2 parents 9b403be + b5016ae commit 12b8944
Showing 1 changed file with 18 additions and 4 deletions.
22 changes: 18 additions & 4 deletions tools/ld-chroma-decoder/sourcefield.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -24,8 +24,18 @@

#include "sourcefield.h"

#include <algorithm>

#include "sourcevideo.h"

// Fill a SourceField's data with a colour
static void fillField(SourceField &field, quint16 colour)
{
quint16 *start = reinterpret_cast<quint16 *>(field.data.data());
quint16 *end = start + (field.data.size() / 2);
std::fill(start, end, colour);
}

void SourceField::loadFields(SourceVideo &sourceVideo, LdDecodeMetaData &ldDecodeMetaData,
qint32 firstFrameNumber, qint32 numFrames,
qint32 lookBehindFrames, qint32 lookAheadFrames,
Expand All @@ -52,15 +62,19 @@ void SourceField::loadFields(SourceVideo &sourceVideo, LdDecodeMetaData &ldDecod

// Fetch the input metadata
fields[i].field = ldDecodeMetaData.getField(firstFieldNumber);
fields[i].data = sourceVideo.getVideoField(firstFieldNumber);
fields[i + 1].field = ldDecodeMetaData.getField(secondFieldNumber);
fields[i + 1].data = sourceVideo.getVideoField(secondFieldNumber);

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

frameNumber++;
Expand Down

0 comments on commit 12b8944

Please sign in to comment.