Skip to content

Commit

Permalink
Support for interlaced inputs
Browse files Browse the repository at this point in the history
  • Loading branch information
defl committed Jul 22, 2021
1 parent 96f24fb commit efb530d
Show file tree
Hide file tree
Showing 8 changed files with 31 additions and 6 deletions.
6 changes: 5 additions & 1 deletion CHANGELOG.txt
Original file line number Diff line number Diff line change
@@ -1,4 +1,8 @@
next (0.4.0: Upscaling, added MPCVR renderer, HDR controls)
0.4.1
- Fix for interlaced sources

0.4.0: Upscaling, added MPCVR renderer, HDR controls
- re-release of beta3

0.4.0-beta3
- Added V210 to P210 converter for general MPCVR YUV422 duty
Expand Down
4 changes: 2 additions & 2 deletions TODO.txt
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,8 @@ Roadmap
=======

1.0.0: Out of beta
- Put all formatters together under a nice API and refactor the usage a bit
- Make generic SDR and HDR directshow filters
- internal: Put formatters under a nice abstration
- internal: Make generic SDR and HDR directshow filter abstrations

1.1.0: Constant time delay
- Determine baseline latency with external meter
Expand Down
10 changes: 9 additions & 1 deletion src/DisplayMode.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -14,10 +14,12 @@
DisplayMode::DisplayMode(
unsigned int frameWidth,
unsigned int frameHeight,
bool interlaced,
unsigned int timeScale,
unsigned int frameDuration):
m_frameWidth(frameWidth),
m_frameHeight(frameHeight),
m_interlaced(interlaced),
m_timeScale(timeScale),
m_frameDuration(frameDuration)
{
Expand Down Expand Up @@ -54,6 +56,11 @@ CString DisplayMode::ToString() const
// Resolutiion
s.AppendFormat(_T("%ix%i"), m_frameWidth, m_frameHeight);

if (m_interlaced)
s += TEXT("I "); // Interlaced
else
s += TEXT("P "); // Progressive

// Mode name if well-known
// https://en.wikipedia.org/wiki/List_of_common_resolutions
if (m_frameWidth == 1280 && m_frameHeight == 720)
Expand Down Expand Up @@ -84,7 +91,8 @@ bool DisplayMode::operator == (const DisplayMode& other) const
FrameWidth() == other.FrameWidth() &&
FrameHeight() == other.FrameHeight() &&
TimeScale() == other.TimeScale() &&
FrameDuration() == other.FrameDuration();
FrameDuration() == other.FrameDuration() &&
IsInterlaced() == other.IsInterlaced();
}


Expand Down
6 changes: 6 additions & 0 deletions src/DisplayMode.h
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,7 @@ class DisplayMode
DisplayMode(
unsigned int frameWidth,
unsigned int frameHeight,
bool interlaced, // Two field per frame expected
unsigned int timeScale,
unsigned int frameDuration);

Expand All @@ -49,6 +50,10 @@ class DisplayMode
// Ticks per frame (expressed in TimeScale())
unsigned int FrameDuration() const { return m_frameDuration; }

// Frame contains interlaced data
bool IsInterlaced() const { return m_interlaced; }


// Refresh rate in Hz as double
double RefreshRateHz() const;

Expand All @@ -65,6 +70,7 @@ class DisplayMode

const unsigned int m_frameWidth;
const unsigned int m_frameHeight;
const bool m_interlaced;
const unsigned int m_timeScale;
const unsigned int m_frameDuration;
};
Expand Down
1 change: 1 addition & 0 deletions src/Encoding.h
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@


// (Color space) encoding of the signal
// TODO: Rename me to something more understandable and fix line above here so give more details
enum class Encoding
{
UNKNOWN,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -535,6 +535,7 @@ HRESULT STDMETHODCALLTYPE BlackMagicDeckLinkCaptureDevice::VideoInputFrameArrive
m_previousTimingClockFrameTime = timingClockFrameTime;

// Every every so often get the hardware latency.
// TODO: Change to framerate rather than fixed number of frames
if(m_capturedVideoFrameCount % 20 == 0)
{
timingclocktime_t timingClockNow = TimingClockNow();
Expand Down
6 changes: 4 additions & 2 deletions src/blackmagic_decklink/BlackMagicDeckLinkTranslate.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -294,12 +294,14 @@ DisplayModeSharedPtr Translate(BMDDisplayMode displayMode)
if(it == BD_DISPLAY_MODE_DATA.end())
throw std::runtime_error("Unknown BMDDisplayMode");

if (it->second.fieldsPerFrame != 1)
throw std::runtime_error("Interlaced format, not supported");
assert(
it->second.fieldsPerFrame == 1 ||
it->second.fieldsPerFrame == 2);

return std::make_shared<DisplayMode>(
it->second.width,
it->second.height,
(it->second.fieldsPerFrame == 2), // Interlaced?
(unsigned int)it->second.timeScale,
(unsigned int)it->second.frameDuration);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -212,6 +212,9 @@ void DirectShowGenericHDRVideoRenderer::MediaTypeGenerate()
pvi2->dwControlFlags += AMCONTROL_USED;
pvi2->dwControlFlags += AMCONTROL_COLORINFO_PRESENT;

if (m_videoState->displayMode->IsInterlaced())
pvi2->dwInterlaceFlags = AMINTERLACE_IsInterlaced | AMINTERLACE_DisplayModeBobOrWeave;

m_pmt.lSampleSize = DIBSIZE(pvi2->bmiHeader);
}

Expand Down

0 comments on commit efb530d

Please sign in to comment.