23 void operator()(std::span<const Pixel> in0, std::span<const Pixel> in1, std::span<const Pixel> in2,
24 std::span<Pixel> out0, std::span<Pixel> out1,
25 std::span<uint16_t> edgeBuf,
EdgeHQ edgeOp);
30 void operator()(std::span<const Pixel> in0, std::span<const Pixel> in1, std::span<const Pixel> in2,
31 std::span<Pixel> out0, std::span<Pixel> out1,
32 std::span<uint16_t> edgeBuf,
EdgeHQ edgeOp);
35template<std::
unsigned_
integral Pixel>
37 std::span<const Pixel> in0, std::span<const Pixel> in1, std::span<const Pixel> in2,
38 std::span<Pixel> out0, std::span<Pixel> out1,
39 std::span<uint16_t> edgeBuf,
42 auto srcWidth = edgeBuf.size();
43 assert(in0.size() == srcWidth);
44 assert(in1.size() == srcWidth);
45 assert(in2.size() == srcWidth);
46 assert(out0.size() == 2 * srcWidth);
47 assert(out1.size() == 2 * srcWidth);
49 auto c2 =
readPixel(in0[0]);
auto c3 = c2;
50 auto c5 =
readPixel(in1[0]);
auto c6 = c5;
51 auto c8 =
readPixel(in2[0]);
auto c9 = c8;
54 if (edgeOp(c5, c8)) pattern |= 3 << 6;
55 if (edgeOp(c5, c2)) pattern |= 3 << 9;
57 for (
auto x :
xrange(srcWidth)) {
64 if (x != srcWidth - 1) {
70 pattern = (pattern >> 6) & 0x001F;
79 if (edgeOp(c5, c8)) pattern |= 1 << 5;
80 if (edgeOp(c5, c9)) pattern |= 1 << 6;
81 if (edgeOp(c6, c8)) pattern |= 1 << 7;
82 if (edgeOp(c5, c6)) pattern |= 1 << 8;
87 pattern |= ((edgeBuf[x] & (1 << 5) ) << 6) |
88 ((edgeBuf[x] & ((1 << 6) | (1 << 7))) << 3);
89 edgeBuf[x] = narrow_cast<uint16_t>(pattern);
91 unsigned pixel0, pixel1, pixel2, pixel3;
93#include "HQ2xScaler-1x1to2x2.nn"
95 out0[2 * x + 0] = writePixel<Pixel>(pixel0);
96 out0[2 * x + 1] = writePixel<Pixel>(pixel1);
97 out1[2 * x + 0] = writePixel<Pixel>(pixel2);
98 out1[2 * x + 1] = writePixel<Pixel>(pixel3);
102template<std::
unsigned_
integral Pixel>
104 std::span<const Pixel> in0, std::span<const Pixel> in1, std::span<const Pixel> in2,
105 std::span<Pixel> out0, std::span<Pixel> out1,
106 std::span<uint16_t> edgeBuf,
116 auto srcWidth = edgeBuf.size();
117 assert(in0.size() == srcWidth);
118 assert(in1.size() == srcWidth);
119 assert(in2.size() == srcWidth);
120 assert(out0.size() == srcWidth);
121 assert(out1.size() == srcWidth);
123 auto c2 =
readPixel(in0[0]);
auto c3 = c2;
124 auto c5 =
readPixel(in1[0]);
auto c6 = c5;
125 auto c8 =
readPixel(in2[0]);
auto c9 = c8;
127 unsigned pattern = 0;
128 if (edgeOp(c5, c8)) pattern |= 3 << 6;
129 if (edgeOp(c5, c2)) pattern |= 3 << 9;
131 for (
auto x :
xrange(srcWidth)) {
138 if (x != srcWidth - 1) {
144 pattern = (pattern >> 6) & 0x001F;
153 if (edgeOp(c5, c8)) pattern |= 1 << 5;
154 if (edgeOp(c5, c9)) pattern |= 1 << 6;
155 if (edgeOp(c6, c8)) pattern |= 1 << 7;
156 if (edgeOp(c5, c6)) pattern |= 1 << 8;
161 pattern |= ((edgeBuf[x] & (1 << 5) ) << 6) |
162 ((edgeBuf[x] & ((1 << 6) | (1 << 7))) << 3);
163 edgeBuf[x] = narrow_cast<uint16_t>(pattern);
165 unsigned pixel0, pixel1;
167#include "HQ2xScaler-1x1to1x2.nn"
169 out0[x] = writePixel<Pixel>(pixel0);
170 out1[x] = writePixel<Pixel>(pixel1);
176template<std::
unsigned_
integral Pixel>
179 , pixelOps(pixelOps_)
183template<std::
unsigned_
integral Pixel>
185 unsigned srcStartY,
unsigned srcEndY,
unsigned srcWidth,
191 src, srcStartY, srcEndY, srcWidth,
192 dst, dstStartY, dstEndY);
195template<std::
unsigned_
integral Pixel>
197 unsigned srcStartY,
unsigned srcEndY,
unsigned srcWidth,
203 src, srcStartY, srcEndY, srcWidth,
204 dst, dstStartY, dstEndY);
207template<std::
unsigned_
integral Pixel>
209 unsigned srcStartY,
unsigned srcEndY,
unsigned srcWidth,
215 src, srcStartY, srcEndY, srcWidth,
216 dst, dstStartY, dstEndY);
219template<std::
unsigned_
integral Pixel>
221 unsigned srcStartY,
unsigned srcEndY,
unsigned srcWidth,
227 src, srcStartY, srcEndY, srcWidth,
228 dst, dstStartY, dstEndY);
231template<std::
unsigned_
integral Pixel>
233 unsigned srcStartY,
unsigned srcEndY,
unsigned srcWidth,
239 src, srcStartY, srcEndY, srcWidth,
240 dst, dstStartY, dstEndY);
243template<std::
unsigned_
integral Pixel>
245 unsigned srcStartY,
unsigned srcEndY,
unsigned srcWidth,
251 src, srcStartY, srcEndY, srcWidth,
252 dst, dstStartY, dstEndY);
Interface for getting lines from a video frame.
Runs the hq2x scaler algorithm.
void scale1x1to3x2(FrameSource &src, unsigned srcStartY, unsigned srcEndY, unsigned srcWidth, ScalerOutput< Pixel > &dst, unsigned dstStartY, unsigned dstEndY) override
void scale1x1to2x2(FrameSource &src, unsigned srcStartY, unsigned srcEndY, unsigned srcWidth, ScalerOutput< Pixel > &dst, unsigned dstStartY, unsigned dstEndY) override
HQ2xScaler(const PixelOperations< Pixel > &pixelOps)
void scale2x1to3x2(FrameSource &src, unsigned srcStartY, unsigned srcEndY, unsigned srcWidth, ScalerOutput< Pixel > &dst, unsigned dstStartY, unsigned dstEndY) override
void scale1x1to1x2(FrameSource &src, unsigned srcStartY, unsigned srcEndY, unsigned srcWidth, ScalerOutput< Pixel > &dst, unsigned dstStartY, unsigned dstEndY) override
void scale4x1to3x2(FrameSource &src, unsigned srcStartY, unsigned srcEndY, unsigned srcWidth, ScalerOutput< Pixel > &dst, unsigned dstStartY, unsigned dstEndY) override
void scale2x1to1x2(FrameSource &src, unsigned srcStartY, unsigned srcEndY, unsigned srcWidth, ScalerOutput< Pixel > &dst, unsigned dstStartY, unsigned dstEndY) override
Polymorphic wrapper around another line scaler.
Base class for 2x scalers.
This file implemented 3 utility functions:
EdgeHQ createEdgeHQ(const PixelOperations< Pixel > &pixelOps)
uint32_t readPixel(Pixel p)
void operator()(std::span< const Pixel > in0, std::span< const Pixel > in1, std::span< const Pixel > in2, std::span< Pixel > out0, std::span< Pixel > out1, std::span< uint16_t > edgeBuf, EdgeHQ edgeOp)
void operator()(std::span< const Pixel > in0, std::span< const Pixel > in1, std::span< const Pixel > in2, std::span< Pixel > out0, std::span< Pixel > out1, std::span< uint16_t > edgeBuf, EdgeHQ edgeOp)
constexpr auto xrange(T e)