code: def maxpp(cp, size):
      _check_params(len(cp), size)
      sample_count = _sample_count(cp, size)
  
      prevextremevalid = False
      prevextreme = None
      max = 0
  
      prevval = getsample(cp, size, 0)
      val = getsample(cp, size, 1)
  
      prevdiff = val - prevval
  
      for i in range(1, sample_count):
          val = getsample(cp, size, i)
          diff = val - prevval
  
          if diff * prevdiff < 0:
              if prevextremevalid:
                  extremediff = abs(prevval - prevextreme)
                  if extremediff > max:
                      max = extremediff
              prevextremevalid = True
              prevextreme = prevval
  
          prevval = val
          if diff != 0:
              prevdiff = diff
  
      return max
  
imports: import math
  import struct
  from ctypes import create_string_buffer
label_desc: Use image node_id 22 for calling a global function with example usage: maxpp(cp, size) and returns: max