@@ -155,6 +155,37 @@ namespace HWY_NAMESPACE
155155 }
156156 };
157157
158+ /* *
159+ * Apply dc shift for irreversible decompressed image (16-bit path)
160+ * (assumes mono with no MCT)
161+ * NarrowScaleFilter16 has already dequantized T1 output to int16,
162+ * so only integer shift + clamp is needed (same op as DecompressDcShiftRev16).
163+ */
164+ class DecompressDcShiftIrrev16
165+ {
166+ public:
167+ void transform (const ScheduleInfo& info)
168+ {
169+ auto highestResBufferStride =
170+ info.tile ->comps_ [info.compno ].getWindow16 ()->getResWindowBufferHighestStride ();
171+ auto index = (uint64_t )info.yBegin * highestResBufferStride;
172+ auto chunkSize = (uint64_t )(info.yEnd - info.yBegin ) * highestResBufferStride;
173+ const std::vector<ShiftInfo>& shiftInfo = info.shiftInfo ;
174+ auto chan0 =
175+ info.tile ->comps_ [info.compno ].getWindow16 ()->getResWindowBufferHighestSimple ().buf_ ;
176+ const HWY_FULL (int16_t ) di16;
177+ auto vshift = Set (di16, (int16_t )shiftInfo[0 ]._shift );
178+ auto vmin = Set (di16, (int16_t )shiftInfo[0 ]._min );
179+ auto vmax = Set (di16, (int16_t )shiftInfo[0 ]._max );
180+ size_t begin = index;
181+ for (auto j = begin; j < begin + chunkSize; j += Lanes (di16))
182+ {
183+ auto ni = Clamp (Load (di16, chan0 + j) + vshift, vmin, vmax);
184+ Store (ni, di16, chan0 + j);
185+ }
186+ }
187+ };
188+
158189 /* *
159190 * Apply MCT with optional DC shift to reversible decompressed image
160191 */
@@ -614,6 +645,11 @@ namespace HWY_NAMESPACE
614645 }
615646 }
616647
648+ void hwy_schedule_decompress_dc_shift_irrev16 (ScheduleInfo info)
649+ {
650+ vscheduler16<DecompressDcShiftIrrev16>(info);
651+ }
652+
617653 void hwy_schedule_decompress_dc_shift_rev16 (ScheduleInfo info)
618654 {
619655 vscheduler16<DecompressDcShiftRev16>(info);
@@ -640,6 +676,7 @@ HWY_EXPORT(hwy_compress_irrev);
640676HWY_EXPORT (hwy_schedule_decompress_rev);
641677HWY_EXPORT (hwy_schedule_decompress_irrev);
642678HWY_EXPORT (hwy_schedule_decompress_dc_shift_irrev);
679+ HWY_EXPORT (hwy_schedule_decompress_dc_shift_irrev16);
643680HWY_EXPORT (hwy_schedule_decompress_dc_shift_rev);
644681HWY_EXPORT (hwy_schedule_decompress_dc_shift_rev16);
645682HWY_EXPORT (hwy_schedule_decompress_rev16);
@@ -655,7 +692,10 @@ void Mct::schedule_decompress_dc_shift_irrev(FlowComponent* flow, uint16_t compn
655692 ScheduleInfo info (tile_, flow, image_->rows_per_task );
656693 info.compno = compno;
657694 genShift (compno, 1 , info.shiftInfo );
658- HWY_DYNAMIC_DISPATCH (hwy_schedule_decompress_dc_shift_irrev)(info);
695+ if (tile_->comps_ [compno].is16BitDwt ())
696+ HWY_DYNAMIC_DISPATCH (hwy_schedule_decompress_dc_shift_irrev16)(info);
697+ else
698+ HWY_DYNAMIC_DISPATCH (hwy_schedule_decompress_dc_shift_irrev)(info);
659699}
660700/* **
661701 * decompress dc shift only - reversible
0 commit comments