Skip to content
Snippets Groups Projects

opengl: simplify TexCoordsMaps in sampler

Merged Romain Vimont requested to merge rom1v/vlc:opengl_texcoordsmaps into master
  1. Sep 23, 2021
    • Romain Vimont's avatar
      opengl: simplify TexCoordsMaps in sampler · 499b7ef7
      Romain Vimont authored and Romain Vimont's avatar Romain Vimont committed
      The input picture may contain padding, for two reasons:
       1. the rectangle defined by the picture_t offset and visible width and
          height may not cover the whole picture size;
       2. if the OpenGL API does not support NPOT textures, textures are
          created with power-of-two dimensions.
      
      As a consequence, for sampling, the coordinates (between 0 and 1 in both
      dimensions) must be transformed to take the padding into account.
      
      These transformations were computed and performed per-plane. Therefore,
      there were _n_ "TexCoordsMaps" matrices for a picture with _n_ planes.
      
      However, these transformations are necessarily the same for all planes:
       1. the picture_t offset/sizes are defined for the whole picture (then
          scaled appropriately for each plane);
       2. since the ratio between different planes of the same pictures is
          always a power of two (e.g. in YUV 4:2:0, the size of U and V planes
          are half the size of the Y plane in both dimensions), this property
          holds even if we align the dimensions of each plane texture to the
          next power-of-two.
      
      Therefore, use a single transformation matrix.
      499b7ef7
    • Romain Vimont's avatar
      opengl: simplify TexSize multiplication · 893aa567
      Romain Vimont authored and Romain Vimont's avatar Romain Vimont committed
      Multiply two vec2 directly instead of multiplying their components
      separately.
      893aa567
Loading