• Tom Anderson's avatar
    Avoid memcpy after converting YUV to RGB pixels for video frames · bec0951d
    Tom Anderson authored
    This CL avoids using "canvas->drawImage()" in PaintCanvasVideoRenderer::Paint().
    Most of the time (when the video isn't rotated etc), all that's necessary is to
    convert YUV to RGB pixels. But the drawImage() call will first create a
    temporary SkBitmap, copy the frame into that, and then redundantly memcpy() the
    bitmap to the resulting canvas.
    
    The memcpy() is very expensive and results in a lot of dropped frames when
    playing back 8K video. A single 8K frame is 145MiB, so at 60fps we'd be copying
    8.24GiB/s, which uses up most of the RAM bandwidth.
    
    With this change, I can playback 8K video at 60fps with only 49% dropped frames
    when I was getting 76% dropped before.
    
    The remaining bottleneck is in ConvertVideoFrameToRGBPixels(): if I remove that
    function, I can playback 8K video at 75fps with zero dropped frames (but with no
    video :P), so the current plan is to try to parallelize that function after
    landing this CL.
    
    BUG=1001207
    
    Change-Id: I0f69988e224d28cd06973beedf00d461ebd5e67e
    Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/1788320
    Commit-Queue: Thomas Anderson <thomasanderson@chromium.org>
    Reviewed-by: default avatarKhushal <khushalsagar@chromium.org>
    Reviewed-by: default avatarDale Curtis <dalecurtis@chromium.org>
    Cr-Commit-Position: refs/heads/master@{#696919}
    bec0951d
skia_paint_canvas.h 6.04 KB