• Henrik Boström's avatar
    [macOS] In-capturer convert/rescale class: SampleBufferTransformer. · 36d0d6d6
    Henrik Boström authored
    This class supports pixel conversions and rescaling, backed up by both
    libyuv functions for SW conversions and PixelBufferTransferer for HW
    conversions. It supports conversions from all supported capture formats
    (NV12, YUY2, UYVY, MJPEG) to NV12 and I420. (The pixel transfer path
    supports even more destination pixel formats, but libyuv's destination
    must be NV12 or I420, and these are the only two of interest to us.)
    
    Whether HW or SW conversion is used, the resulting buffer is put in an
    IOSurface-backed pixel buffer.
    
    Code paths:
    - When we have a pixel buffer, i.e. this is NOT MJPEG:
      - PixelBufferTransferer: X -> I420/NV12 in a single step.
      - libyuv: X -> I420 in a single step. X -> NV12 may involve an
        intermediate step X -> I420 -> NV12. Conversion and rescaling are
        done in separate steps.
    - MJPEG (when we only have a sample buffer):
      - PixelBufferTransferer: Not supported.
      - libyuv: MJPEG -> I420 in a single step. MJPEG -> NV12 in two steps
        MJPEG -> I420 -> NV12. Conversion and rescaling are done in separate
        steps.
    
    In a follow-up, we will do MJPEG -> NV12 in a single step based on the
    libyuv CL that eshr@ recently landed.
    
    Measurements show that which conversion method is most efficient is
    dependent on input and output pixel formats and may even be affected by
    cache hits/misses. In future CLs, we should wire up and measure the
    optimal SampleBufferTransformer configurations (in which formats to use
    libyuv and in which formats to use pixel transfer).
    
    Bug: chromium:1132299
    Change-Id: I4f6053c65c0c3b02483d130e25bebd1f656abd89
    Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/2498563
    Commit-Queue: Henrik Boström <hbos@chromium.org>
    Reviewed-by: default avatarIlya Nikolaevskiy <ilnik@chromium.org>
    Cr-Commit-Position: refs/heads/master@{#823502}
    36d0d6d6
BUILD.gn 17.5 KB