• “Full range” refers to the YUV component values being in the range 0–255, whereas “restricted range” has values between 16–235
  • XYZ色彩空间是一个基于人眼视觉特征的

FFmpeg stores all these properties in the AVFrame struct:

  • The format (type and bit-depth), in AVFrame->format
  • The signal range, in AVFrame->color_range
  • The YUV/RGB transformation matrix, in AVFrame->colorspace
  • The linearization function (a.k.a. transformation characteristics), in AVFrame->color_trc
  • The RGB/XYZ matrix, in AVFrame->color_primaries

    ffmpeg对colorspace转换的支持

    Conversion between RGB/YUV is typically done using swscale. Conversion between different color properties (bit-depth, range, matrix, transfer characteristics, primaries) can be done using the colorspace or colormatrix video filter. There’s also a filter using the external library zscale. (for both aforementioned purposes) (…and seems to be a more reliable choice for all these swscale hazards)

colormatrix和colorspace 不同点

Video filter colorspace, colormatrix have the following relationship:

  • They both do only YUV to YUV colorspace conversion; YUV to RGB, and scaling requires swscale.
  • colormatrix supports only 8bpc (8-bit per component) pixel formats, whereas colorspace supports 10bpc, 12bpc also.
  • colormatrix does not apply gamma (primaries) correction, whereas colorspace does (it has an option fast=1 to disable this if you want faster conversion, or compatible output with that produced by colormatrix). (Note: With fast=0 (default) it seems to produce significantly worse quality (discoloration)… gamma miscorrection?..)
  • colormatrix is C only, whereas colorspace uses x86 SIMD (i.e. it’s faster).
  • Anyway for 8bpc… colorspace still seems to produce slightly better quality than colormatrix

    Color Signal Range

    image.png
    不是所有的颜色都是从1到255呦

https://trac.ffmpeg.org/wiki/colorspace