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_patches.h"
7
8 namespace jxl {
9 namespace {
10 class PatchDictionaryStage : public RenderPipelineStage {
11 public:
PatchDictionaryStage(const PatchDictionary * patches)12 explicit PatchDictionaryStage(const PatchDictionary* patches)
13 : RenderPipelineStage(RenderPipelineStage::Settings()),
14 patches_(*patches) {}
15
ProcessRow(const RowInfo & input_rows,const RowInfo & output_rows,size_t xextra,size_t xsize,size_t xpos,size_t ypos,float * JXL_RESTRICT temp) const16 void ProcessRow(const RowInfo& input_rows, const RowInfo& output_rows,
17 size_t xextra, size_t xsize, size_t xpos, size_t ypos,
18 float* JXL_RESTRICT temp) const final {
19 PROFILER_ZONE("RenderPatches");
20 std::vector<float*> row_ptrs(input_rows.size());
21 for (size_t i = 0; i < row_ptrs.size(); i++) {
22 row_ptrs[i] = GetInputRow(input_rows, i, 0) - xextra;
23 }
24 patches_.AddOneRow(row_ptrs.data(), ypos, xpos - xextra,
25 xsize + 2 * xextra);
26 }
27
GetChannelMode(size_t c) const28 RenderPipelineChannelMode GetChannelMode(size_t c) const final {
29 return RenderPipelineChannelMode::kInPlace;
30 }
31
32 private:
33 const PatchDictionary& patches_;
34 };
35 } // namespace
36
GetPatchesStage(const PatchDictionary * patches)37 std::unique_ptr<RenderPipelineStage> GetPatchesStage(
38 const PatchDictionary* patches) {
39 return jxl::make_unique<PatchDictionaryStage>(patches);
40 }
41
42 } // namespace jxl
43