  
          if msg.which() in VIPC_STREAM:
            msg = msg.as_builder()
            camera_state = getattr(msg, msg.which())
            img = frs[msg.which()].get(frame_idxs[msg.which()], pix_fmt="yuv420p")[0]
            frame_idxs[msg.which()] += 1
  
            # send camera state and frame
            camera_state.frameId = frame_idxs[msg.which()]
            pm.send(msg.which(), msg)
 
</s> remove         for stream_type, frame_size, state in streams:
          dat = np.empty(int(frame_size[0]*frame_size[1]*3/2), dtype=np.uint8)
 </s> add         for stream_type, frame_spec, state in streams:
          if TICI:
            dat = np.empty(frame_spec[2], dtype=np.uint8)
          else:
            dat = np.empty(int(frame_spec[0]*frame_spec[1]*3/2), dtype=np.uint8) </s> remove         img = fr.get(i, pix_fmt='yuv420p')[0]
 </s> add         img = fr.get(i, pix_fmt='nv12')[0] </s> remove     if pix_fmt not in ("yuv420p", "rgb24"):
 </s> add     if pix_fmt not in ("nv12", "yuv420p", "rgb24"): </s> remove   y_len = img.shape[0] * img.shape[1]
  uv_len = y_len // 4
 </s> add 
          img = frs[msg.which()].get(frame_idxs[msg.which()], pix_fmt="nv12")[0]
  
          if msg.which() in VIPC_STREAM:
            msg = msg.as_builder()
            camera_state = getattr(msg, msg.which())
          img = frs[msg.which()].get(frame_idxs[msg.which()], pix_fmt="nv12")[0]
            frame_idxs[msg.which()] += 1
  
            # send camera state and frame
            camera_state.frameId = frame_idxs[msg.which()]
            pm.send(msg.which(), msg)
keep keep keep keep replace keep 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> 
selfdrive/test/process_replay/model_replay.py