@@ -37,11 +37,13 @@ ConvertToXXXX function
3737 ConvertToPlanarRGB(clip, [ string matrix, bool interlaced,
3838 string ChromaInPlacement,
3939 string chromaresample,
40- float param1, float param2, float param3 ] )
40+ float param1, float param2, float param3,
41+ int bits] )
4142 ConvertToPlanarRGBA(clip, [ string matrix, bool interlaced,
4243 string ChromaInPlacement,
4344 string chromaresample,
44- float param1, float param2, float param3 ] )
45+ float param1, float param2, float param3,
46+ int bits] )
4547
4648
4749*YUV444, YUVA444 *
@@ -221,8 +223,8 @@ How conversion detects whether full or limited (narrow range for RGB) conversion
221223 - ``limited `` for YUV or Y (greyscale) sources
222224
223225 is assumed.
224- - Along with frame properties, the matrix string can contain additional "hints", such as ``:f `` or ``:l ``.
225- - When no other hint is given, some old-style Avisynth matrix name can specify limited/full: e.g. Rec.709 implies limited range.
226+ - Along with frame properties, the matrix string can contain additional "hints", such as ``:f ``, ``:l ``, , `` :auto ``, `` :same ``.
227+ - When no other hint is given, some old-style Avisynth matrix name can specify limited/full: e.g. `` " Rec.709" `` implies limited range.
226228 Note: unlike ``PC.709 `` or ``PC.601 ``: these matrix names do not force the clip being full or limited.
227229
228230See also: :doc: `ConvertBits <convertbits >` to convert between bit depths and/or between full-limited range.
@@ -249,7 +251,7 @@ Syntax and parameters
249251 Additional matrix constants:
250252
251253 New syntax: more matrix string constants with separate full/limited range markers.
252- ``"matrixname:full_or_limited " `` where
254+ ``"matrixname:full_or_limited_or_auto_or_same " `` where
253255 ``"matrixname" `` can be set as (for developers, internal _Matrix integer constant are given in parenthesys)
254256
255257 - "rgb" (0 - AVS_MATRIX_RGB)
@@ -269,21 +271,32 @@ Syntax and parameters
269271 - "chromancl" (12 - AVS_MATRIX_CHROMATICITY_DERIVED_NCL not supported)
270272 - "ictcp" (14 - AVS_MATRIX_ICTCP not supported)
271273
272- The above "matrix" parameters can be followed by a ``"full" `` or ``"f" `` and ``"limited" `` or ``"l" `` or
273- ``"auto" `` marker after a ``":" ``
274+ The above "matrix" parameters can be followed by a
275+
276+ - ``"full" `` or ``"f" ``
277+ - ``"limited" `` or ``"l" ``
278+ - ``"auto" ``
279+ - ``"same" ``
280+
281+ marker after a ``":" ``.
274282
275- e.g. ``"709:l" `` means the same as the old "Rec709"
283+ e.g. ``"709:l" `` means the same as the old "Rec709", since it defaults to limited to full conversion.
276284
277- When there is no limited-ness marker, or is set to "auto" then value of _ColorRange frame property is used
285+ When there is no limited-ness marker, or is set to "auto" then value of _ColorRange frame property is used.
286+ Using "same" will assume the input range for the output's range.
278287
279- Note: old-style "matrix" parameters are kept, their name indicate the full/limited except ``"PC.601" `` and ``"PC.709" ``
288+ Note: Avisynth+ defines a new matrix syntax, but old-style "matrix" parameter names are still valid.
289+ Using old-style matrix names imply the full/limited range, except ``"PC.601" `` and ``"PC.709" `` which
290+ do not alter the input's range.
280291
281292 For memo and the similar new string
282293
283- - "rec601" same as "470bg:l"
284- - "rec709" "709:l"
285- - "pc.601" and "pc601" "470bg:f" - but only if source has _ColorRange = 0 (full)
286- - "pc.709" and "pc709" "709:f" - but only if source has _ColorRange = 0 (full)
294+ - "rec601" same as "470bg:l" (limited to full)
295+ - "rec709" "709:l" (limited to full)
296+ - "pc.601" and "pc601" same as "470bg:f" - but only if source has _ColorRange = 0 (full)
297+ - "pc.709" and "pc709" same as "709:f" - but only if source has _ColorRange = 0 (full)
298+ - "pc.601" and "pc601" same as "470bg:same" (keep input range)
299+ - "pc.709" and "pc709" same as "709:same" (keep input range)
287300 - "average" - kept for compatibility, really it has no standard _Matrix equivalent
288301 - "rec2020" "2020cl:l"
289302 - "pc.2020" and "pc2020" "2020cl:f" - but only if source has _ColorRange = 0 (full)
@@ -354,7 +367,24 @@ Syntax and parameters
354367 resamplers. Some resizer algorithms would need and can be fine tuned with up to 3 parameters.
355368 Their default values depend on the selected chromaresample resizer kernel,
356369
357-
370+ .. describe :: bits
371+
372+ Used by ConvertToPlanarRGB(A) to perform on-the-fly output bit-depth conversion.
373+
374+ **Internal calculation methods: ** (when conversion is needed)
375+
376+ ======================== =================== ================================
377+ Target Range Internal Math Output Handling
378+ ======================== =================== ================================
379+ Full-range 32-bit float Direct output
380+ Limited-range → integer S18.13 fixed-point Truncated to target bit depth
381+ Limited-range → float S18.13 fixed-point Converted to float (no truncation)
382+ ======================== =================== ================================
383+
384+ Note: Limited-range to float conversion preserves the full precision of the
385+ S18.13 fixed-point calculation by converting directly to 32-bit float without
386+ the truncation that occurs with integer targets.
387+
358388Frame properties
359389----------------
360390
@@ -434,6 +464,9 @@ Color conversions
434464+----------+------------------------------------------------------------+
435465| Changes: | |
436466+==========+============================================================+
467+ | v3.7.6 || Add "bits" parameter to ConvertToPlanarRGB() |
468+ | || Document ":same" in matrix specifier |
469+ +----------+------------------------------------------------------------+
437470| v3.7.3 || Added "sinpow", "sinclin2" and "userdefined2" to |
438471| | chromaresampler options |
439472| || Add "param1", "param2" and "param3" to ConvertToXXXX where|
@@ -454,4 +487,4 @@ Color conversions
454487| v2.50 | ConvertToYV12 |
455488+----------+------------------------------------------------------------+
456489
457- $Date: 2024/12/18 13:23 :00 $
490+ $Date: 2026/02/12 10:44 :00 $
0 commit comments