| 1 |
// Copyright (c) the JPEG XL Project Authors. All rights reserved. |
| 2 |
// |
| 3 |
// Use of this source code is governed by a BSD-style |
| 4 |
// license that can be found in the LICENSE file. |
| 5 |
|
| 6 |
#include "lib/jxl/render_pipeline/stage_splines.h" |
| 7 |
|
| 8 |
#include <cstddef> |
| 9 |
#include <memory> |
| 10 |
|
| 11 |
#undef HWY_TARGET_INCLUDE |
| 12 |
#define HWY_TARGET_INCLUDE "lib/jxl/render_pipeline/stage_splines.cc" |
| 13 |
#include <hwy/foreach_target.h> |
| 14 |
#include <hwy/highway.h> |
| 15 |
|
| 16 |
#include "lib/jxl/base/status.h" |
| 17 |
#include "lib/jxl/render_pipeline/render_pipeline_stage.h" |
| 18 |
#include "lib/jxl/splines.h" |
| 19 |
|
| 20 |
HWY_BEFORE_NAMESPACE(); |
| 21 |
namespace jxl { |
| 22 |
namespace HWY_NAMESPACE { |
| 23 |
|
| 24 |
class SplineStage : public RenderPipelineStage { |
| 25 |
public: |
| 26 |
explicit SplineStage(const Splines* splines) |
| 27 |
: RenderPipelineStage(RenderPipelineStage::Settings()), |
| 28 |
splines_(*splines) {} |
| 29 |
|
| 30 |
Status ProcessRow(const RowInfo& input_rows, const RowInfo& output_rows, |
| 31 |
size_t xextra, size_t xsize, size_t xpos, size_t ypos, |
| 32 |
size_t thread_id) const final { |
| 33 |
float* row_x = GetInputRow(input_rows, 0, 0); |
| 34 |
float* row_y = GetInputRow(input_rows, 1, 0); |
| 35 |
float* row_b = GetInputRow(input_rows, 2, 0); |
| 36 |
splines_.AddToRow(row_x, row_y, row_b, ypos, xpos, xpos + xsize); |
| 37 |
return true; |
| 38 |
} |
| 39 |
|
| 40 |
RenderPipelineChannelMode GetChannelMode(size_t c) const final { |
| 41 |
return c < 3 ? RenderPipelineChannelMode::kInPlace |
| 42 |
: RenderPipelineChannelMode::kIgnored; |
| 43 |
} |
| 44 |
|
| 45 |
const char* GetName() const override { return "Splines"; } |
| 46 |
|
| 47 |
private: |
| 48 |
const Splines& splines_; |
| 49 |
}; |
| 50 |
|
| 51 |
std::unique_ptr<RenderPipelineStage> GetSplineStage(const Splines* splines) { |
| 52 |
return jxl::make_unique<SplineStage>(splines); |
| 53 |
} |
| 54 |
|
| 55 |
// NOLINTNEXTLINE(google-readability-namespace-comments) |
| 56 |
} // namespace HWY_NAMESPACE |
| 57 |
} // namespace jxl |
| 58 |
HWY_AFTER_NAMESPACE(); |
| 59 |
|
| 60 |
#if HWY_ONCE |
| 61 |
namespace jxl { |
| 62 |
|
| 63 |
HWY_EXPORT(GetSplineStage); |
| 64 |
|
| 65 |
std::unique_ptr<RenderPipelineStage> GetSplineStage(const Splines* splines) { |
| 66 |
return HWY_DYNAMIC_DISPATCH(GetSplineStage)(splines); |
| 67 |
} |
| 68 |
|
| 69 |
} // namespace jxl |
| 70 |
#endif |