  #include "common/modeldata.h"
  #include "common/swaglog.h"
  #include "common/util.h"
  #include "selfdrive/hardware/hw.h"
  
  #ifdef QCOM2
  #include "CL/cl_ext_qcom.h"
  #include "selfdrive/camerad/cameras/camera_qcom2.h"
  #else
  #include "selfdrive/camerad/test/camera_test.h"
 
</s> remove   "uniform sampler2D uTextureU;\n"
  "uniform sampler2D uTextureV;\n"
 </s> add   "uniform sampler2D uTextureUV;\n" </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     crop_yuv((uint8_t *)stream_buf, width, height, mirror_y, mirror_u, mirror_v, crop_rect);
 </s> add     crop_nv12_to_yuv((uint8_t *)stream_buf, stride, uv_offset, mirror_y, mirror_u, mirror_v, crop_rect); </s> remove   CL_CHECK(clSetKernelArg(s->krnl, 1, sizeof(cl_int), &in_uv_width));
  CL_CHECK(clSetKernelArg(s->krnl, 2, sizeof(cl_int), &in_u_offset));
  CL_CHECK(clSetKernelArg(s->krnl, 3, sizeof(cl_int), &in_uv_height));
  CL_CHECK(clSetKernelArg(s->krnl, 4, sizeof(cl_int), &in_uv_width));
  CL_CHECK(clSetKernelArg(s->krnl, 5, sizeof(cl_mem), &out_u));
  CL_CHECK(clSetKernelArg(s->krnl, 6, sizeof(cl_int), &out_uv_width));
  CL_CHECK(clSetKernelArg(s->krnl, 7, sizeof(cl_int), &zero));
  CL_CHECK(clSetKernelArg(s->krnl, 8, sizeof(cl_int), &out_uv_height));
  CL_CHECK(clSetKernelArg(s->krnl, 9, sizeof(cl_int), &out_uv_width));
  CL_CHECK(clSetKernelArg(s->krnl, 10, sizeof(cl_mem), &s->m_uv_cl));
  
 </s> add   CL_CHECK(clSetKernelArg(s->krnl, 2, sizeof(cl_int), &in_uv_px_stride));  // src_px_stride
  CL_CHECK(clSetKernelArg(s->krnl, 3, sizeof(cl_int), &in_u_offset));  // src_offset
  CL_CHECK(clSetKernelArg(s->krnl, 4, sizeof(cl_int), &in_uv_height));  // src_rows
  CL_CHECK(clSetKernelArg(s->krnl, 5, sizeof(cl_int), &in_uv_width));  // src_cols
  CL_CHECK(clSetKernelArg(s->krnl, 6, sizeof(cl_mem), &out_u));  // dst
  CL_CHECK(clSetKernelArg(s->krnl, 7, sizeof(cl_int), &out_uv_width));  // dst_row_stride
  CL_CHECK(clSetKernelArg(s->krnl, 8, sizeof(cl_int), &zero));  // dst_offset
  CL_CHECK(clSetKernelArg(s->krnl, 9, sizeof(cl_int), &out_uv_height));  // dst_rows
  CL_CHECK(clSetKernelArg(s->krnl, 10, sizeof(cl_int), &out_uv_width));  // dst_cols
  CL_CHECK(clSetKernelArg(s->krnl, 11, sizeof(cl_mem), &s->m_uv_cl));  // M
 </s> remove   CL_CHECK(clSetKernelArg(s->krnl, 2, sizeof(cl_int), &in_v_offset));
  CL_CHECK(clSetKernelArg(s->krnl, 5, sizeof(cl_mem), &out_v));
 </s> add   CL_CHECK(clSetKernelArg(s->krnl, 3, sizeof(cl_int), &in_v_offset));  // src_ofset
  CL_CHECK(clSetKernelArg(s->krnl, 6, sizeof(cl_mem), &out_v));  // dst
#include "msm_media_info.h"
  #include "common/modeldata.h"
  #include "common/swaglog.h"
  #include "common/util.h"
  #include "selfdrive/hardware/hw.h"
#include "msm_media_info.h"
  
  #ifdef QCOM2
  #include "CL/cl_ext_qcom.h"
  #include "selfdrive/camerad/cameras/camera_qcom2.h"
  #else
  #include "selfdrive/camerad/test/camera_test.h"
keep keep keep add keep 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/camerad/cameras/camera_common.cc