Optimized detection routine by integrating the -inf padding directly after the convolution-accumulation step.