draft-ietf-cellar-ffv1-v4-16.txt   draft-ietf-cellar-ffv1-v4-17.txt 
cellar M. Niedermayer cellar M. Niedermayer
Internet-Draft Internet-Draft
Intended status: Standards Track D. Rice Intended status: Standards Track D. Rice
Expires: 4 June 2021 Expires: 26 November 2021
J. Martinez J. Martinez
1 December 2020 25 May 2021
FFV1 Video Coding Format Version 4 FFV1 Video Coding Format Version 4
draft-ietf-cellar-ffv1-v4-16 draft-ietf-cellar-ffv1-v4-17
Abstract Abstract
This document defines FFV1, a lossless intra-frame video encoding This document defines FFV1, a lossless intra-frame video encoding
format. FFV1 is designed to efficiently compress video data in a format. FFV1 is designed to efficiently compress video data in a
variety of pixel formats. Compared to uncompressed video, FFV1 variety of pixel formats. Compared to uncompressed video, FFV1
offers storage compression, frame fixity, and self-description, which offers storage compression, frame fixity, and self-description, which
makes FFV1 useful as a preservation or intermediate video format. makes FFV1 useful as a preservation or intermediate video format.
Status of This Memo Status of This Memo
skipping to change at page 1, line 36 skipping to change at page 1, line 36
Internet-Drafts are working documents of the Internet Engineering Internet-Drafts are working documents of the Internet Engineering
Task Force (IETF). Note that other groups may also distribute Task Force (IETF). Note that other groups may also distribute
working documents as Internet-Drafts. The list of current Internet- working documents as Internet-Drafts. The list of current Internet-
Drafts is at https://datatracker.ietf.org/drafts/current/. Drafts is at https://datatracker.ietf.org/drafts/current/.
Internet-Drafts are draft documents valid for a maximum of six months Internet-Drafts are draft documents valid for a maximum of six months
and may be updated, replaced, or obsoleted by other documents at any and may be updated, replaced, or obsoleted by other documents at any
time. It is inappropriate to use Internet-Drafts as reference time. It is inappropriate to use Internet-Drafts as reference
material or to cite them other than as "work in progress." material or to cite them other than as "work in progress."
This Internet-Draft will expire on 4 June 2021. This Internet-Draft will expire on 26 November 2021.
Copyright Notice Copyright Notice
Copyright (c) 2020 IETF Trust and the persons identified as the Copyright (c) 2021 IETF Trust and the persons identified as the
document authors. All rights reserved. document authors. All rights reserved.
This document is subject to BCP 78 and the IETF Trust's Legal This document is subject to BCP 78 and the IETF Trust's Legal
Provisions Relating to IETF Documents (https://trustee.ietf.org/ Provisions Relating to IETF Documents (https://trustee.ietf.org/
license-info) in effect on the date of publication of this document. license-info) in effect on the date of publication of this document.
Please review these documents carefully, as they describe your rights Please review these documents carefully, as they describe your rights
and restrictions with respect to this document. Code Components and restrictions with respect to this document. Code Components
extracted from this document must include Simplified BSD License text extracted from this document must include Simplified BSD License text
as described in Section 4.e of the Trust Legal Provisions and are as described in Section 4.e of the Trust Legal Provisions and are
provided without warranty as described in the Simplified BSD License. provided without warranty as described in the Simplified BSD License.
skipping to change at page 2, line 42 skipping to change at page 2, line 42
3.3. Median Predictor . . . . . . . . . . . . . . . . . . . . 11 3.3. Median Predictor . . . . . . . . . . . . . . . . . . . . 11
3.3.1. Exception . . . . . . . . . . . . . . . . . . . . . . 11 3.3.1. Exception . . . . . . . . . . . . . . . . . . . . . . 11
3.4. Quantization Table Sets . . . . . . . . . . . . . . . . . 12 3.4. Quantization Table Sets . . . . . . . . . . . . . . . . . 12
3.5. Context . . . . . . . . . . . . . . . . . . . . . . . . . 12 3.5. Context . . . . . . . . . . . . . . . . . . . . . . . . . 12
3.6. Quantization Table Set Indexes . . . . . . . . . . . . . 13 3.6. Quantization Table Set Indexes . . . . . . . . . . . . . 13
3.7. Color spaces . . . . . . . . . . . . . . . . . . . . . . 13 3.7. Color spaces . . . . . . . . . . . . . . . . . . . . . . 13
3.7.1. YCbCr . . . . . . . . . . . . . . . . . . . . . . . . 13 3.7.1. YCbCr . . . . . . . . . . . . . . . . . . . . . . . . 13
3.7.2. RGB . . . . . . . . . . . . . . . . . . . . . . . . . 14 3.7.2. RGB . . . . . . . . . . . . . . . . . . . . . . . . . 14
3.8. Coding of the Sample Difference . . . . . . . . . . . . . 16 3.8. Coding of the Sample Difference . . . . . . . . . . . . . 16
3.8.1. Range Coding Mode . . . . . . . . . . . . . . . . . . 16 3.8.1. Range Coding Mode . . . . . . . . . . . . . . . . . . 16
3.8.2. Golomb Rice Mode . . . . . . . . . . . . . . . . . . 22 3.8.2. Golomb Rice Mode . . . . . . . . . . . . . . . . . . 23
4. Bitstream . . . . . . . . . . . . . . . . . . . . . . . . . . 28 4. Bitstream . . . . . . . . . . . . . . . . . . . . . . . . . . 29
4.1. Quantization Table Set . . . . . . . . . . . . . . . . . 29 4.1. Quantization Table Set . . . . . . . . . . . . . . . . . 30
4.1.1. quant_tables . . . . . . . . . . . . . . . . . . . . 30 4.1.1. quant_tables . . . . . . . . . . . . . . . . . . . . 31
4.1.2. context_count . . . . . . . . . . . . . . . . . . . . 31 4.1.2. context_count . . . . . . . . . . . . . . . . . . . . 32
4.2. Parameters . . . . . . . . . . . . . . . . . . . . . . . 31 4.2. Parameters . . . . . . . . . . . . . . . . . . . . . . . 32
4.2.1. version . . . . . . . . . . . . . . . . . . . . . . . 33 4.2.1. version . . . . . . . . . . . . . . . . . . . . . . . 34
4.2.2. micro_version . . . . . . . . . . . . . . . . . . . . 33 4.2.2. micro_version . . . . . . . . . . . . . . . . . . . . 34
4.2.3. coder_type . . . . . . . . . . . . . . . . . . . . . 34 4.2.3. coder_type . . . . . . . . . . . . . . . . . . . . . 35
4.2.4. state_transition_delta . . . . . . . . . . . . . . . 35 4.2.4. state_transition_delta . . . . . . . . . . . . . . . 36
4.2.5. colorspace_type . . . . . . . . . . . . . . . . . . . 35 4.2.5. colorspace_type . . . . . . . . . . . . . . . . . . . 36
4.2.6. chroma_planes . . . . . . . . . . . . . . . . . . . . 36 4.2.6. chroma_planes . . . . . . . . . . . . . . . . . . . . 37
4.2.7. bits_per_raw_sample . . . . . . . . . . . . . . . . . 36 4.2.7. bits_per_raw_sample . . . . . . . . . . . . . . . . . 37
4.2.8. log2_h_chroma_subsample . . . . . . . . . . . . . . . 37 4.2.8. log2_h_chroma_subsample . . . . . . . . . . . . . . . 38
4.2.9. log2_v_chroma_subsample . . . . . . . . . . . . . . . 37 4.2.9. log2_v_chroma_subsample . . . . . . . . . . . . . . . 38
4.2.10. extra_plane . . . . . . . . . . . . . . . . . . . . . 37 4.2.10. extra_plane . . . . . . . . . . . . . . . . . . . . . 38
4.2.11. num_h_slices . . . . . . . . . . . . . . . . . . . . 37 4.2.11. num_h_slices . . . . . . . . . . . . . . . . . . . . 38
4.2.12. num_v_slices . . . . . . . . . . . . . . . . . . . . 38 4.2.12. num_v_slices . . . . . . . . . . . . . . . . . . . . 39
4.2.13. quant_table_set_count . . . . . . . . . . . . . . . . 38 4.2.13. quant_table_set_count . . . . . . . . . . . . . . . . 39
4.2.14. states_coded . . . . . . . . . . . . . . . . . . . . 38 4.2.14. states_coded . . . . . . . . . . . . . . . . . . . . 39
4.2.15. initial_state_delta . . . . . . . . . . . . . . . . . 38 4.2.15. initial_state_delta . . . . . . . . . . . . . . . . . 39
4.2.16. ec . . . . . . . . . . . . . . . . . . . . . . . . . 39 4.2.16. ec . . . . . . . . . . . . . . . . . . . . . . . . . 40
4.2.17. intra . . . . . . . . . . . . . . . . . . . . . . . . 39 4.2.17. intra . . . . . . . . . . . . . . . . . . . . . . . . 40
4.3. Configuration Record . . . . . . . . . . . . . . . . . . 39 4.3. Configuration Record . . . . . . . . . . . . . . . . . . 40
4.3.1. reserved_for_future_use . . . . . . . . . . . . . . . 40 4.3.1. reserved_for_future_use . . . . . . . . . . . . . . . 41
4.3.2. configuration_record_crc_parity . . . . . . . . . . . 40 4.3.2. configuration_record_crc_parity . . . . . . . . . . . 41
4.3.3. Mapping FFV1 into Containers . . . . . . . . . . . . 40 4.3.3. Mapping FFV1 into Containers . . . . . . . . . . . . 41
4.4. Frame . . . . . . . . . . . . . . . . . . . . . . . . . . 41 4.4. Frame . . . . . . . . . . . . . . . . . . . . . . . . . . 42
4.5. Slice . . . . . . . . . . . . . . . . . . . . . . . . . . 43 4.5. Slice . . . . . . . . . . . . . . . . . . . . . . . . . . 44
4.6. Slice Header . . . . . . . . . . . . . . . . . . . . . . 44 4.6. Slice Header . . . . . . . . . . . . . . . . . . . . . . 45
4.6.1. slice_x . . . . . . . . . . . . . . . . . . . . . . . 44 4.6.1. slice_x . . . . . . . . . . . . . . . . . . . . . . . 45
4.6.2. slice_y . . . . . . . . . . . . . . . . . . . . . . . 44 4.6.2. slice_y . . . . . . . . . . . . . . . . . . . . . . . 45
4.6.3. slice_width . . . . . . . . . . . . . . . . . . . . . 44 4.6.3. slice_width . . . . . . . . . . . . . . . . . . . . . 45
4.6.4. slice_height . . . . . . . . . . . . . . . . . . . . 45 4.6.4. slice_height . . . . . . . . . . . . . . . . . . . . 46
4.6.5. quant_table_set_index_count . . . . . . . . . . . . . 45 4.6.5. quant_table_set_index_count . . . . . . . . . . . . . 46
4.6.6. quant_table_set_index . . . . . . . . . . . . . . . . 45 4.6.6. quant_table_set_index . . . . . . . . . . . . . . . . 46
4.6.7. picture_structure . . . . . . . . . . . . . . . . . . 45 4.6.7. picture_structure . . . . . . . . . . . . . . . . . . 46
4.6.8. sar_num . . . . . . . . . . . . . . . . . . . . . . . 46 4.6.8. sar_num . . . . . . . . . . . . . . . . . . . . . . . 47
4.6.9. sar_den . . . . . . . . . . . . . . . . . . . . . . . 46 4.6.9. sar_den . . . . . . . . . . . . . . . . . . . . . . . 47
4.6.10. reset_contexts . . . . . . . . . . . . . . . . . . . 46 4.6.10. reset_contexts . . . . . . . . . . . . . . . . . . . 47
4.6.11. slice_coding_mode . . . . . . . . . . . . . . . . . . 46 4.6.11. slice_coding_mode . . . . . . . . . . . . . . . . . . 47
4.7. Slice Content . . . . . . . . . . . . . . . . . . . . . . 47 4.7. Slice Content . . . . . . . . . . . . . . . . . . . . . . 48
4.7.1. primary_color_count . . . . . . . . . . . . . . . . . 47 4.7.1. primary_color_count . . . . . . . . . . . . . . . . . 48
4.7.2. plane_pixel_height . . . . . . . . . . . . . . . . . 47 4.7.2. plane_pixel_height . . . . . . . . . . . . . . . . . 48
4.7.3. slice_pixel_height . . . . . . . . . . . . . . . . . 48 4.7.3. slice_pixel_height . . . . . . . . . . . . . . . . . 49
4.7.4. slice_pixel_y . . . . . . . . . . . . . . . . . . . . 48 4.7.4. slice_pixel_y . . . . . . . . . . . . . . . . . . . . 49
4.8. Line . . . . . . . . . . . . . . . . . . . . . . . . . . 48 4.8. Line . . . . . . . . . . . . . . . . . . . . . . . . . . 49
4.8.1. plane_pixel_width . . . . . . . . . . . . . . . . . . 48 4.8.1. plane_pixel_width . . . . . . . . . . . . . . . . . . 49
4.8.2. slice_pixel_width . . . . . . . . . . . . . . . . . . 49 4.8.2. slice_pixel_width . . . . . . . . . . . . . . . . . . 50
4.8.3. slice_pixel_x . . . . . . . . . . . . . . . . . . . . 49 4.8.3. slice_pixel_x . . . . . . . . . . . . . . . . . . . . 50
4.8.4. sample_difference . . . . . . . . . . . . . . . . . . 49 4.8.4. sample_difference . . . . . . . . . . . . . . . . . . 50
4.9. Slice Footer . . . . . . . . . . . . . . . . . . . . . . 49 4.9. Slice Footer . . . . . . . . . . . . . . . . . . . . . . 50
4.9.1. slice_size . . . . . . . . . . . . . . . . . . . . . 50 4.9.1. slice_size . . . . . . . . . . . . . . . . . . . . . 51
4.9.2. error_status . . . . . . . . . . . . . . . . . . . . 50 4.9.2. error_status . . . . . . . . . . . . . . . . . . . . 51
4.9.3. slice_crc_parity . . . . . . . . . . . . . . . . . . 50 4.9.3. slice_crc_parity . . . . . . . . . . . . . . . . . . 51
5. Restrictions . . . . . . . . . . . . . . . . . . . . . . . . 50 5. Restrictions . . . . . . . . . . . . . . . . . . . . . . . . 51
6. Security Considerations . . . . . . . . . . . . . . . . . . . 51 6. Security Considerations . . . . . . . . . . . . . . . . . . . 52
7. IANA Considerations . . . . . . . . . . . . . . . . . . . . . 51 7. IANA Considerations . . . . . . . . . . . . . . . . . . . . . 52
7.1. Media Type Definition . . . . . . . . . . . . . . . . . . 51 7.1. Media Type Definition . . . . . . . . . . . . . . . . . . 52
8. Changelog . . . . . . . . . . . . . . . . . . . . . . . . . . 53 8. Changelog . . . . . . . . . . . . . . . . . . . . . . . . . . 54
9. Normative References . . . . . . . . . . . . . . . . . . . . 53 9. Normative References . . . . . . . . . . . . . . . . . . . . 54
10. Informative References . . . . . . . . . . . . . . . . . . . 54 10. Informative References . . . . . . . . . . . . . . . . . . . 55
Appendix A. Multi-theaded decoder implementation suggestions . . 55 Appendix A. Multi-theaded decoder implementation suggestions . . 56
Appendix B. Future handling of some streams created by non Appendix B. Future handling of some streams created by non
conforming encoders . . . . . . . . . . . . . . . . . . . 56 conforming encoders . . . . . . . . . . . . . . . . . . . 57
Appendix C. FFV1 Implementations . . . . . . . . . . . . . . . . 56 Appendix C. FFV1 Implementations . . . . . . . . . . . . . . . . 57
C.1. FFmpeg FFV1 Codec . . . . . . . . . . . . . . . . . . . . 56 C.1. FFmpeg FFV1 Codec . . . . . . . . . . . . . . . . . . . . 57
C.2. FFV1 Decoder in Go . . . . . . . . . . . . . . . . . . . 56 C.2. FFV1 Decoder in Go . . . . . . . . . . . . . . . . . . . 57
C.3. MediaConch . . . . . . . . . . . . . . . . . . . . . . . 57 C.3. MediaConch . . . . . . . . . . . . . . . . . . . . . . . 58
Authors' Addresses . . . . . . . . . . . . . . . . . . . . . . . 57 Authors' Addresses . . . . . . . . . . . . . . . . . . . . . . . 58
1. Introduction 1. Introduction
This document describes FFV1, a lossless video encoding format. The This document describes FFV1, a lossless video encoding format. The
design of FFV1 considers the storage of image characteristics, data design of FFV1 considers the storage of image characteristics, data
fixity, and the optimized use of encoding time and storage fixity, and the optimized use of encoding time and storage
requirements. FFV1 is designed to support a wide range of lossless requirements. FFV1 is designed to support a wide range of lossless
video applications such as long-term audiovisual preservation, video applications such as long-term audiovisual preservation,
scientific imaging, screen recording, and other video encoding scientific imaging, screen recording, and other video encoding
scenarios that seek to avoid the generational loss of lossy video scenarios that seek to avoid the generational loss of lossy video
skipping to change at page 5, line 7 skipping to change at page 5, line 7
2. Notation and Conventions 2. Notation and Conventions
The key words "MUST", "MUST NOT", "REQUIRED", "SHALL", "SHALL NOT", The key words "MUST", "MUST NOT", "REQUIRED", "SHALL", "SHALL NOT",
"SHOULD", "SHOULD NOT", "RECOMMENDED", "NOT RECOMMENDED", "MAY", and "SHOULD", "SHOULD NOT", "RECOMMENDED", "NOT RECOMMENDED", "MAY", and
"OPTIONAL" in this document are to be interpreted as described in BCP "OPTIONAL" in this document are to be interpreted as described in BCP
14 [RFC2119] [RFC8174] when, and only when, they appear in all 14 [RFC2119] [RFC8174] when, and only when, they appear in all
capitals, as shown here. capitals, as shown here.
2.1. Definitions 2.1. Definitions
"FFV1": choosen name of this video encoding format, short version of "FFV1": chosen name of this video encoding format, short version of
"FF Video 1", the letters "FF" coming from "FFmpeg", the name of the "FF Video 1", the letters "FF" coming from "FFmpeg", the name of the
reference decoder, whose the first letters originaly means "Fast reference decoder, whose first letters originally meant "Fast
Forward". Forward".
"Container": Format that encapsulates Frames (see Section 4.4) and "Container": Format that encapsulates Frames (see Section 4.4) and
(when required) a "Configuration Record" into a bitstream. (when required) a "Configuration Record" into a bitstream.
"Sample": The smallest addressable representation of a color "Sample": The smallest addressable representation of a color
component or a luma component in a Frame. Examples of Sample are component or a luma component in a Frame. Examples of Sample are
Luma (Y), Blue-difference Chroma (Cb), Red-difference Chroma (Cr), Luma (Y), Blue-difference Chroma (Cb), Red-difference Chroma (Cr),
Transparency, Red, Green, and Blue. Transparency, Red, Green, and Blue.
skipping to change at page 8, line 20 skipping to change at page 8, line 20
"log2(a)" means the base-two logarithm of a. "log2(a)" means the base-two logarithm of a.
"min(a,b)" means the smaller of two values a and b. "min(a,b)" means the smaller of two values a and b.
"max(a,b)" means the larger of two values a and b. "max(a,b)" means the larger of two values a and b.
"median(a,b,c)" means the numerical middle value in a data set of a, "median(a,b,c)" means the numerical middle value in a data set of a,
b, and c, i.e. a+b+c-min(a,b,c)-max(a,b,c). b, and c, i.e. a+b+c-min(a,b,c)-max(a,b,c).
"A <== B" means B implies A. "A ==> B" means A implies B.
"A <==> B" means A <== B , B <== A. "A <==> B" means A ==> B , B ==> A.
a_(b) means the b-th value of a sequence of a a_b means the b-th value of a sequence of a
a_(b,c) means the 'b,c'-th value of a sequence of a a_(b,c) means the 'b,c'-th value of a sequence of a
2.2.6. Order of Operation Precedence 2.2.6. Order of Operation Precedence
When order of precedence is not indicated explicitly by use of When order of precedence is not indicated explicitly by use of
parentheses, operations are evaluated in the following order (from parentheses, operations are evaluated in the following order (from
top to bottom, operations of same precedence being evaluated from top to bottom, operations of same precedence being evaluated from
left to right). This order of operations is based on the order of left to right). This order of operations is based on the order of
operations used in Standard C. operations used in Standard C.
skipping to change at page 12, line 30 skipping to change at page 12, line 30
number of quantization steps and their distribution are stored in the number of quantization steps and their distribution are stored in the
FFV1 bitstream; each Quantization Table has exactly 256 entries, and FFV1 bitstream; each Quantization Table has exactly 256 entries, and
the 8 least significant bits of the Quantized Sample Difference are the 8 least significant bits of the Quantized Sample Difference are
used as index: used as index:
Q_(j)[k] = quant_tables[i][j][k&255] Q_(j)[k] = quant_tables[i][j][k&255]
Figure 4 Figure 4
In this formula, "i" is the Quantization Table Set index, "j" is the In this formula, "i" is the Quantization Table Set index, "j" is the
Quantized Table index, "k" the Quantized Sample Difference. Quantized Table index, "k" the Quantized Sample Difference (see
Section 4.1.1).
3.5. Context 3.5. Context
Relative to any Sample "X", the Quantized Sample Differences "L-l", Relative to any Sample "X", the Quantized Sample Differences "L-l",
"l-tl", "tl-t", "T-t", and "t-tr" are used as context: "l-tl", "tl-t", "T-t", and "t-tr" are used as context:
context = Q_(0)[l - tl] + context = Q_(0)[l - tl] +
Q_(1)[tl - t] + Q_(1)[tl - t] +
Q_(2)[t - tr] + Q_(2)[t - tr] +
Q_(3)[L - l] + Q_(3)[L - l] +
skipping to change at page 16, line 30 skipping to change at page 16, line 30
3.8.1. Range Coding Mode 3.8.1. Range Coding Mode
Early experimental versions of FFV1 used the CABAC Arithmetic coder Early experimental versions of FFV1 used the CABAC Arithmetic coder
from H.264 as defined in [ISO.14496-10.2014] but due to the uncertain from H.264 as defined in [ISO.14496-10.2014] but due to the uncertain
patent/royalty situation, as well as its slightly worse performance, patent/royalty situation, as well as its slightly worse performance,
CABAC was replaced by a Range coder based on an algorithm defined by CABAC was replaced by a Range coder based on an algorithm defined by
G. Nigel N. Martin in 1979 [range-coding]. G. Nigel N. Martin in 1979 [range-coding].
3.8.1.1. Range Binary Values 3.8.1.1. Range Binary Values
To encode binary digits efficiently a Range coder is used. C_(i) is To encode binary digits efficiently a Range coder is used. A Range
the i-th Context. B_(i) is the i-th byte of the bytestream. b_(i) is coder encodes a series of binary symbols by using a probability
the i-th Range coded binary value, S_(0, i) is the i-th initial estimation within each context. The sizes of each of the 2 sub-
state. The length of the bytestream encoding n binary symbols is ranges are proportional to their estimated probability. The
j_(n) bytes. quantization table is used to choose the context used from the
surrounding image sample values for the case of coding the sample
differences. Coding integers is done by coding multiple binary
values. The range decoder will read bytes until it can determine
which sub-range the input falls into to return the next binary
symbol.
r_(i) = floor( ( R_(i) * S_(i, C_(i)) ) / 2 ^ 8 ) To describe Range coding for FFV1 the following values are used:
Figure 11: A formula of the read of a binary value in Range C_i the i-th Context.
Binary mode.
S_(i + 1, C_(i)) = zero_state_(S_(i, C_(i))) AND B_i the i-th byte of the bytestream.
l_(i) = L_(i) AND
t_(i) = R_(i) - r_(i) <==
b_(i) = 0 <==>
L_(i) < R_(i) - r_(i)
S_(i + 1, C_(i)) = one_state_(S_(i, C_(i))) AND R_i the Range at the i-th symbol.
l_(i) = L_(i) - R_(i) + r_(i) AND
t_(i) = r_(i) <==
b_(i) = 1 <==>
L_(i) >= R_(i) - r_(i)
Figure 12
S_(i + 1, k) = S_(i, k) <== C_(i) != k r_i the boundary between two sub-ranges of R_i: a sub-range of r_i
values and a sub-range R_i - r_i values.
Figure 13: The "i+1,k"-th State is equal to the "i,k"-th State if L_i the Low value of the Range at the i-th symbol.
the value of "k" is unequal to the i-th value of Context.
R_(i + 1) = 2 ^ 8 * t_(i) AND l_i a temporary variable to carry-over or adjust the Low value of
L_(i + 1) = 2 ^ 8 * l_(i) + B_(j_(i)) AND the Range between range coding operations.
j_(i + 1) = j_(i) + 1 <==
t_(i) < 2 ^ 8
R_(i + 1) = t_(i) AND t_i a temporary variable to transmit sub-ranges between range coding
L_(i + 1) = l_(i) AND operations.
j_(i + 1) = j_(i) <==
t_(i) >= 2 ^ 8
Figure 14: The "i+1"-th values for "Range", "Low", and the length b_i the i-th Range coded binary value.
of the bytestream encoding are conditionally set depending on the
"i-th" value of "t". S_(0, i) the i-th initial state.
j_n the length of the bytestream encoding n binary symbols.
The following Range coder state variables are initialized to the
following values. The Range is initialized to a value of 65,280
(expressed in base 16 as 0xFF00) as depicted in Figure 11. The Low
is initialized according to the value of the first two bytes as
depicted in Figure 12. j_i tracks the length of the bytestream
encoding while incremening from an initial value of j_0 to a final
value of j_n. j_0 is initialized to 2 as depicted in Figure 13.
R_(0) = 65280 R_(0) = 65280
Figure 15: The initial value for "Range". Figure 11: The initial value for "Range".
L_(0) = 2 ^ 8 * B_(0) + B_(1) L_(0) = 2 ^ 8 * B_(0) + B_(1)
Figure 16: The initial value for "Low" is set according to the Figure 12: The initial value for "Low" is set according to the
first two bytes of the bytestream. first two bytes of the bytestream.
j_(0) = 2 j_(0) = 2
Figure 17: The initial value for "j", the length of the Figure 13: The initial value for "j", the length of the
bytestream encoding. bytestream encoding.
The following equations define how the Range coder variables evolve
as it reads or writes symbols.
r_(i) = floor( ( R_(i) * S_(i, C_(i)) ) / 2 ^ 8 )
Figure 14: This formula shows the positioning of range split
based on the State.
b_(i) = 0 <==>
L_(i) < R_(i) - r_(i) ==>
S_(i + 1, C_(i)) = zero_state_(S_(i, C_(i))) AND
l_(i) = L_(i) AND
t_(i) = R_(i) - r_(i)
b_(i) = 1 <==>
L_(i) >= R_(i) - r_(i) ==>
S_(i + 1, C_(i)) = one_state_(S_(i, C_(i))) AND
l_(i) = L_(i) - R_(i) + r_(i) AND
t_(i) = r_(i)
Figure 15: This formula shows the linking of the decoded symbol
(represented as b_i), the updated State (represented as
S_(i+1,C_(i))), and the updated range (represented as a range
from l_i to t_i).
C_(i) != k ==> S_(i + 1, k) = S_(i, k)
Figure 16: If the value of "k" is unequal to the i-th value of
Context, in other words if the State is unchanged from the last
symbol coding, then the value of the State is carried over to the
next symbol coding.
t_(i) < 2 ^ 8 ==>
R_(i + 1) = 2 ^ 8 * t_(i) AND
L_(i + 1) = 2 ^ 8 * l_(i) + B_(j_(i)) AND
j_(i + 1) = j_(i) + 1
t_(i) >= 2 ^ 8 ==>
R_(i + 1) = t_(i) AND
L_(i + 1) = l_(i) AND
j_(i + 1) = j_(i)
Figure 17: This formula shows the linking of the Range coder with
the reading or writing of the bytestream.
range = 0xFF00; range = 0xFF00;
end = 0; end = 0;
low = get_bits(16); low = get_bits(16);
if (low >= range) { if (low >= range) {
low = range; low = range;
end = 1; end = 1;
} }
Figure 18: A pseudo-code description of the initial states in Figure 18: A pseudo-code description of the initialization of
Range Binary mode. Range coder variables in Range Binary mode.
refill() { refill() {
if (range < 256) { if (range < 256) {
range = range * 256; range = range * 256;
low = low * 256; low = low * 256;
if (!end) { if (!end) {
c.low += get_bits(8); c.low += get_bits(8);
if (remaining_bits_in_bitstream( NumBytes ) == 0) { if (remaining_bits_in_bitstream( NumBytes ) == 0) {
end = 1; end = 1;
} }
skipping to change at page 20, line 38 skipping to change at page 21, line 38
} }
} }
Figure 21: A pseudo-code description of the contexts of Range Non Figure 21: A pseudo-code description of the contexts of Range Non
Binary Values. Binary Values.
"get_symbol" is used for the read out of "sample_difference" "get_symbol" is used for the read out of "sample_difference"
indicated in Figure 10. indicated in Figure 10.
"get_rac" returns a boolean, computed from the bytestream as "get_rac" returns a boolean, computed from the bytestream as
described in Figure 11 as a formula and in Figure 20 as pseudo-code. described in Figure 14 as a formula and in Figure 20 as pseudo-code.
3.8.1.3. Initial Values for the Context Model 3.8.1.3. Initial Values for the Context Model
When "keyframe" (see Section 4.4) value is 1, all Range coder state When "keyframe" (see Section 4.4) value is 1, all Range coder state
variables are set to their initial state. variables are set to their initial state.
3.8.1.4. State Transition Table 3.8.1.4. State Transition Table
In this mode a State Transition Table is used, indicating in which In this mode a State Transition Table is used, indicating in which
state the decoder will move to, based on the current state and the state the decoder will move to, based on the current state and the
skipping to change at page 28, line 17 skipping to change at page 29, line 17
diff++; diff++;
} }
Note, this is different from JPEG-LS, which doesn't use prediction in Note, this is different from JPEG-LS, which doesn't use prediction in
run mode and uses a different encoding and context model for the last run mode and uses a different encoding and context model for the last
difference. On a small set of test Samples the use of prediction difference. On a small set of test Samples the use of prediction
slightly improved the compression rate. slightly improved the compression rate.
3.8.2.5. Initial Values for the VLC context state 3.8.2.5. Initial Values for the VLC context state
When "keyframe" (see Section 4.4) value is 1, all coder state When "keyframe" (see Section 4.4) value is 1, all VLC coder state
variables are set to their initial state. variables are set to their initial state.
drift = 0; drift = 0;
error_sum = 4; error_sum = 4;
bias = 0; bias = 0;
count = 1; count = 1;
4. Bitstream 4. Bitstream
An FFV1 bitstream is composed of a series of one or more Frames and An FFV1 bitstream is composed of a series of one or more Frames and
skipping to change at page 30, line 47 skipping to change at page 31, line 47
quant_tables[ i ][ j ][ 256 - k ] = \ | quant_tables[ i ][ j ][ 256 - k ] = \ |
-quant_tables[ i ][ j ][ k ] | -quant_tables[ i ][ j ][ k ] |
} | } |
quant_tables[ i ][ j ][ 128 ] = \ | quant_tables[ i ][ j ][ 128 ] = \ |
-quant_tables[ i ][ j ][ 127 ] | -quant_tables[ i ][ j ][ 127 ] |
len_count[ i ][ j ] = v | len_count[ i ][ j ] = v |
} | } |
4.1.1. quant_tables 4.1.1. quant_tables
"quant_tables[ i ][ j ][ k ]" indicates the quantification table "quant_tables[ i ][ j ][ k ]" indicates the quantization table value
value of the Quantized Sample Difference "k" of the Quantization of the Quantized Sample Difference "k" of the Quantization Table "j"
Table "j" of the Set Quantization Table Set "i". of the Quantization Table Set "i".
4.1.2. context_count 4.1.2. context_count
"context_count[ i ]" indicates the count of contexts for Quantization "context_count[ i ]" indicates the count of contexts for Quantization
Table Set "i". "context_count[ i ]" MUST be less than or equal to Table Set "i". "context_count[ i ]" MUST be less than or equal to
32768. 32768.
4.2. Parameters 4.2. Parameters
The "Parameters" section contains significant characteristics about The "Parameters" section contains significant characteristics about
skipping to change at page 49, line 5 skipping to change at page 50, line 5
sample_difference[ p ][ y ][ x ] | sd sample_difference[ p ][ y ][ x ] | sd
} | } |
} | } |
} | } |
4.8.1. plane_pixel_width 4.8.1. plane_pixel_width
"plane_pixel_width[ p ]" is the width in Pixels of Plane p of the "plane_pixel_width[ p ]" is the width in Pixels of Plane p of the
"Slice". It is defined as: "Slice". It is defined as:
chroma\_planes == 1 && (p == 1 || p == 2) chroma_planes == 1 && (p == 1 || p == 2)
? ceil( slice_pixel_width / (1 << log2_h_chroma_subsample) ) ? ceil( slice_pixel_width / (1 << log2_h_chroma_subsample) )
: slice_pixel_width. : slice_pixel_width.
4.8.2. slice_pixel_width 4.8.2. slice_pixel_width
"slice_pixel_width" is the width in Pixels of the slice. It is "slice_pixel_width" is the width in Pixels of the slice. It is
defined as: defined as:
floor( floor(
( slice_x + slice_width ) ( slice_x + slice_width )
skipping to change at page 54, line 38 skipping to change at page 55, line 38
[FFV1GO] Buitenhuis, D., "FFV1 Decoder in Go", 2019, [FFV1GO] Buitenhuis, D., "FFV1 Decoder in Go", 2019,
<https://github.com/dwbuiten/go-ffv1>. <https://github.com/dwbuiten/go-ffv1>.
[HuffYUV] Rudiak-Gould, B., "HuffYUV", December 2003, [HuffYUV] Rudiak-Gould, B., "HuffYUV", December 2003,
<https://web.archive.org/web/20040402121343/ <https://web.archive.org/web/20040402121343/
http://cultact-server.novi.dk/kpo/huffyuv/huffyuv.html>. http://cultact-server.novi.dk/kpo/huffyuv/huffyuv.html>.
[I-D.ietf-cellar-ffv1] [I-D.ietf-cellar-ffv1]
Niedermayer, M., Rice, D., and J. Martinez, "FFV1 Video Niedermayer, M., Rice, D., and J. Martinez, "FFV1 Video
Coding Format Version 0, 1, and 3", Work in Progress, Coding Format Version 0, 1, and 3", Work in Progress,
Internet-Draft, draft-ietf-cellar-ffv1-18, 7 October 2020, Internet-Draft, draft-ietf-cellar-ffv1-20, 23 February
<https://tools.ietf.org/html/draft-ietf-cellar-ffv1-18>. 2021,
<https://tools.ietf.org/html/draft-ietf-cellar-ffv1-20>.
[ISO.14495-1.1999] [ISO.14495-1.1999]
International Organization for Standardization, International Organization for Standardization,
"Information technology -- Lossless and near-lossless "Information technology -- Lossless and near-lossless
compression of continuous-tone still images: Baseline", compression of continuous-tone still images: Baseline",
December 1999. December 1999.
[ISO.14496-10.2014] [ISO.14496-10.2014]
International Organization for Standardization, International Organization for Standardization,
"Information technology -- Coding of audio-visual objects "Information technology -- Coding of audio-visual objects
 End of changes. 34 change blocks. 
126 lines changed or deleted 174 lines changed or added

This html diff was produced by rfcdiff 1.48. The latest version is available from http://tools.ietf.org/tools/rfcdiff/