openMSX
SuperImposedVideoFrame.cc
Go to the documentation of this file.
2 #include "LineScalers.hh"
3 #include "MemoryOps.hh"
4 #include "vla.hh"
5 #include "build-info.hh"
6 #include <cstdint>
7 
8 namespace openmsx {
9 
10 template <typename Pixel>
12  const FrameSource& src_, const FrameSource& super_,
13  const PixelOperations<Pixel>& pixelOps_)
14  : FrameSource(pixelOps_.getSDLPixelFormat())
15  , src(src_), super(super_), pixelOps(pixelOps_)
16 {
17  setHeight(src.getHeight());
18 }
19 
20 template <typename Pixel>
21 unsigned SuperImposedVideoFrame<Pixel>::getLineWidth(unsigned line) const
22 {
23  unsigned width = src.getLineWidth(line);
24  return (width == 1) ? 320 : width;
25 }
26 
27 template <typename Pixel>
29  unsigned line, unsigned& width, void* buf1_, unsigned bufWidth) const
30 {
31  auto* buf1 = static_cast<Pixel*>(buf1_);
32  // Return minimum line width of 320.
33  // We could check whether both inputs have width=1 and in that case
34  // also return a line of width=1. But for now (laserdisc) this will
35  // never happen.
36  auto* srcLine = static_cast<const Pixel*>(
37  src.getLineInfo(line, width, buf1, bufWidth));
38  if (width == 1) {
39  width = 320;
41  memset(buf1, 320, srcLine[0]);
42  srcLine = buf1;
43  }
44  // (possibly) srcLine == buf1
45 
46  // Adjust the two inputs to the same height.
47  const Pixel* supLine;
48  VLA_SSE_ALIGNED(Pixel, buf2, width);
49  assert(super.getHeight() == 480); // TODO possibly extend in the future
50  if (src.getHeight() == 240) {
51  VLA_SSE_ALIGNED(Pixel, buf3, width);
52  auto* sup0 = super.getLinePtr(2 * line + 0, width, buf2);
53  auto* sup1 = super.getLinePtr(2 * line + 1, width, buf3);
54  BlendLines<Pixel> blend(pixelOps);
55  blend(sup0, sup1, buf2, width); // possibly sup0 == buf2
56  supLine = buf2;
57  } else {
58  assert(src.getHeight() == super.getHeight());
59  supLine = super.getLinePtr(line, width, buf2); // scale line
60  }
61  // (possibly) supLine == buf2
62 
63  // Actually blend the lines of both frames.
64  AlphaBlendLines<Pixel> blend(pixelOps);
65  blend(srcLine, supLine, buf1, width); // possibly srcLine == buf1
66  return buf1;
67 }
68 
69 // Force template instantiation.
70 #if HAVE_16BPP
72 #endif
73 #if HAVE_32BPP
75 #endif
76 
77 } // namespace openmsx
BlendLines functor Generate an output line that is an iterpolation of two input lines.
Definition: LineScalers.hh:224
This class represents a frame that is the (per-pixel) alpha-blend of a (laser-disc) video frame and a...
uint32_t Pixel
Interface for getting lines from a video frame.
Definition: FrameSource.hh:14
Thanks to enen for testing this on a real cartridge:
Definition: Autofire.cc:5
SuperImposedVideoFrame(const FrameSource &src, const FrameSource &super, const PixelOperations< Pixel > &pixelOps)
const Pixel * getLinePtr(int line, unsigned width, Pixel *buf) const
Gets a pointer to the pixels of the given line number.
Definition: FrameSource.hh:91
unsigned getLineWidth(unsigned line) const override
Gets the number of display pixels on the given line.
void setHeight(unsigned height_)
Definition: FrameSource.hh:198
virtual const void * getLineInfo(unsigned line, unsigned &lineWidth, void *buf, unsigned bufWidth) const =0
Abstract implementation of getLinePtr().
virtual unsigned getLineWidth(unsigned line) const =0
Gets the number of display pixels on the given line.
const void * getLineInfo(unsigned line, unsigned &width, void *buf, unsigned bufWidth) const override
Abstract implementation of getLinePtr().
AlphaBlendLines functor Generate an output line that is a per-pixel-alpha-blend of the two input line...
Definition: LineScalers.hh:256
unsigned getHeight() const
Gets the number of lines in this frame.
Definition: FrameSource.hh:44
#define VLA_SSE_ALIGNED(TYPE, NAME, LENGTH)
Definition: vla.hh:44