    return yuv420.clip(0, 255).astype('uint8')
  
  
  def decompress_video_data(rawdat, vid_fmt, w, h, pix_fmt):
    # using a tempfile is much faster than proc.communicate for some reason
  
    with tempfile.TemporaryFile() as tmpf:
 
</s> remove   yuv420 = np.empty(y_len + 2 * uv_len, dtype=img.dtype)
 </s> add   return ys, us, vs


def rgb24toyuv420(rgb):
  ys, us, vs = rgb24toyuv(rgb)

  y_len = rgb.shape[0] * rgb.shape[1]
  uv_len = y_len // 4

  yuv420 = np.empty(y_len + 2 * uv_len, dtype=rgb.dtype) </s> remove     if pix_fmt not in ("yuv420p", "rgb24"):
 </s> add     if pix_fmt not in ("nv12", "yuv420p", "rgb24"): </s> remove def rgb24toyuv420(rgb):
 </s> add def rgb24toyuv(rgb): </s> remove         img = fr.get(i, pix_fmt='yuv420p')[0]
 </s> add         img = fr.get(i, pix_fmt='nv12')[0]
def rgb24tonv12(rgb):
  ys, us, vs = rgb24toyuv(rgb)

  y_len = rgb.shape[0] * rgb.shape[1]
  uv_len = y_len // 4

  nv12 = np.empty(y_len + 2 * uv_len, dtype=rgb.dtype)
  nv12[:y_len] = ys.reshape(-1)
  nv12[y_len::2] = us.reshape(-1)
  nv12[y_len+1::2] = vs.reshape(-1)

  return nv12.clip(0, 255).astype('uint8')


    return yuv420.clip(0, 255).astype('uint8')
  
  
def rgb24tonv12(rgb):
  ys, us, vs = rgb24toyuv(rgb)

  y_len = rgb.shape[0] * rgb.shape[1]
  uv_len = y_len // 4

  nv12 = np.empty(y_len + 2 * uv_len, dtype=rgb.dtype)
  nv12[:y_len] = ys.reshape(-1)
  nv12[y_len::2] = us.reshape(-1)
  nv12[y_len+1::2] = vs.reshape(-1)

  return nv12.clip(0, 255).astype('uint8')


  def decompress_video_data(rawdat, vid_fmt, w, h, pix_fmt):
    # using a tempfile is much faster than proc.communicate for some reason
  
    with tempfile.TemporaryFile() as tmpf:
keep keep add keep keep keep keep
 nv12: encoderd avoids a full frame copy (#24519)

* rgb to nv12

* nv12 works (w memcpy)

* correct now

* no copy

* fix nv12 with fast debayer

* reverts of unused stuff

* ui use nv12

* comment out thumbnails for now

* rebase fix

* dm read nv12

* model read nv12

* fix ffmpeg encoder

* thumbnails from nv12

* replay to nv12

* python framereader support nv12

* remove hardcoded frame/buffer sizes

* fix build

* ffmpeg encoder fix buffers

* small cleanup

* reduce power usage test

* fix cpu usage test

* fix snapshot

* fix loggerd test

* bump cereal

Co-authored-by: Comma Device <device@comma.ai>
Co-authored-by: Joost Wooning <jwooning@gmail.com> 
tools/lib/framereader.py