--- 1/draft-ietf-cellar-ffv1-v4-13.txt 2020-08-21 14:14:35.180366882 -0700 +++ 2/draft-ietf-cellar-ffv1-v4-14.txt 2020-08-21 14:14:35.280369408 -0700 @@ -1,20 +1,20 @@ cellar M. Niedermayer Internet-Draft Intended status: Standards Track D. Rice -Expires: 3 January 2021 +Expires: 22 February 2021 J. Martinez - 2 July 2020 + 21 August 2020 FFV1 Video Coding Format Version 4 - draft-ietf-cellar-ffv1-v4-13 + draft-ietf-cellar-ffv1-v4-14 Abstract This document defines FFV1, a lossless intra-frame video encoding format. FFV1 is designed to efficiently compress video data in a variety of pixel formats. Compared to uncompressed video, FFV1 offers storage compression, frame fixity, and self-description, which makes FFV1 useful as a preservation or intermediate video format. Status of This Memo @@ -25,21 +25,21 @@ Internet-Drafts are working documents of the Internet Engineering Task Force (IETF). Note that other groups may also distribute working documents as Internet-Drafts. The list of current Internet- Drafts is at https://datatracker.ietf.org/drafts/current/. Internet-Drafts are draft documents valid for a maximum of six months and may be updated, replaced, or obsoleted by other documents at any time. It is inappropriate to use Internet-Drafts as reference material or to cite them other than as "work in progress." - This Internet-Draft will expire on 3 January 2021. + This Internet-Draft will expire on 22 February 2021. Copyright Notice Copyright (c) 2020 IETF Trust and the persons identified as the document authors. All rights reserved. This document is subject to BCP 78 and the IETF Trust's Legal Provisions Relating to IETF Documents (https://trustee.ietf.org/ license-info) in effect on the date of publication of this document. Please review these documents carefully, as they describe your rights @@ -55,99 +55,99 @@ 2.1. Definitions . . . . . . . . . . . . . . . . . . . . . . . 4 2.2. Conventions . . . . . . . . . . . . . . . . . . . . . . . 5 2.2.1. Pseudo-code . . . . . . . . . . . . . . . . . . . . . 5 2.2.2. Arithmetic Operators . . . . . . . . . . . . . . . . 6 2.2.3. Assignment Operators . . . . . . . . . . . . . . . . 6 2.2.4. Comparison Operators . . . . . . . . . . . . . . . . 7 2.2.5. Mathematical Functions . . . . . . . . . . . . . . . 7 2.2.6. Order of Operation Precedence . . . . . . . . . . . . 8 2.2.7. Range . . . . . . . . . . . . . . . . . . . . . . . . 8 2.2.8. NumBytes . . . . . . . . . . . . . . . . . . . . . . 8 - 2.2.9. Bitstream Functions . . . . . . . . . . . . . . . . . 8 + 2.2.9. Bitstream Functions . . . . . . . . . . . . . . . . . 9 3. Sample Coding . . . . . . . . . . . . . . . . . . . . . . . . 9 3.1. Border . . . . . . . . . . . . . . . . . . . . . . . . . 9 3.2. Samples . . . . . . . . . . . . . . . . . . . . . . . . . 10 3.3. Median Predictor . . . . . . . . . . . . . . . . . . . . 11 - 3.4. Context . . . . . . . . . . . . . . . . . . . . . . . . . 11 - 3.5. Quantization Table Sets . . . . . . . . . . . . . . . . . 12 + 3.4. Quantization Table Sets . . . . . . . . . . . . . . . . . 12 + 3.5. Context . . . . . . . . . . . . . . . . . . . . . . . . . 12 3.6. Quantization Table Set Indexes . . . . . . . . . . . . . 12 - 3.7. Color spaces . . . . . . . . . . . . . . . . . . . . . . 12 + 3.7. Color spaces . . . . . . . . . . . . . . . . . . . . . . 13 3.7.1. YCbCr . . . . . . . . . . . . . . . . . . . . . . . . 13 3.7.2. RGB . . . . . . . . . . . . . . . . . . . . . . . . . 13 3.8. Coding of the Sample Difference . . . . . . . . . . . . . 15 3.8.1. Range Coding Mode . . . . . . . . . . . . . . . . . . 15 - 3.8.2. Golomb Rice Mode . . . . . . . . . . . . . . . . . . 20 - 4. Bitstream . . . . . . . . . . . . . . . . . . . . . . . . . . 25 - 4.1. Quantization Table Set . . . . . . . . . . . . . . . . . 26 - 4.1.1. quant_tables . . . . . . . . . . . . . . . . . . . . 27 - 4.1.2. context_count . . . . . . . . . . . . . . . . . . . . 28 - 4.2. Parameters . . . . . . . . . . . . . . . . . . . . . . . 28 - 4.2.1. version . . . . . . . . . . . . . . . . . . . . . . . 30 - 4.2.2. micro_version . . . . . . . . . . . . . . . . . . . . 30 - 4.2.3. coder_type . . . . . . . . . . . . . . . . . . . . . 31 - 4.2.4. state_transition_delta . . . . . . . . . . . . . . . 32 - 4.2.5. colorspace_type . . . . . . . . . . . . . . . . . . . 32 - 4.2.6. chroma_planes . . . . . . . . . . . . . . . . . . . . 33 - 4.2.7. bits_per_raw_sample . . . . . . . . . . . . . . . . . 33 - 4.2.8. log2_h_chroma_subsample . . . . . . . . . . . . . . . 34 - 4.2.9. log2_v_chroma_subsample . . . . . . . . . . . . . . . 34 - 4.2.10. extra_plane . . . . . . . . . . . . . . . . . . . . . 34 - 4.2.11. num_h_slices . . . . . . . . . . . . . . . . . . . . 34 - 4.2.12. num_v_slices . . . . . . . . . . . . . . . . . . . . 35 - 4.2.13. quant_table_set_count . . . . . . . . . . . . . . . . 35 - 4.2.14. states_coded . . . . . . . . . . . . . . . . . . . . 35 - 4.2.15. initial_state_delta . . . . . . . . . . . . . . . . . 35 - 4.2.16. ec . . . . . . . . . . . . . . . . . . . . . . . . . 36 - 4.2.17. intra . . . . . . . . . . . . . . . . . . . . . . . . 36 - 4.3. Configuration Record . . . . . . . . . . . . . . . . . . 36 - 4.3.1. reserved_for_future_use . . . . . . . . . . . . . . . 37 - 4.3.2. configuration_record_crc_parity . . . . . . . . . . . 37 - 4.3.3. Mapping FFV1 into Containers . . . . . . . . . . . . 37 - 4.4. Frame . . . . . . . . . . . . . . . . . . . . . . . . . . 38 - 4.5. Slice . . . . . . . . . . . . . . . . . . . . . . . . . . 40 - 4.6. Slice Header . . . . . . . . . . . . . . . . . . . . . . 41 - 4.6.1. slice_x . . . . . . . . . . . . . . . . . . . . . . . 41 - 4.6.2. slice_y . . . . . . . . . . . . . . . . . . . . . . . 41 - 4.6.3. slice_width . . . . . . . . . . . . . . . . . . . . . 41 - 4.6.4. slice_height . . . . . . . . . . . . . . . . . . . . 42 - 4.6.5. quant_table_set_index_count . . . . . . . . . . . . . 42 - 4.6.6. quant_table_set_index . . . . . . . . . . . . . . . . 42 - 4.6.7. picture_structure . . . . . . . . . . . . . . . . . . 42 - 4.6.8. sar_num . . . . . . . . . . . . . . . . . . . . . . . 43 - 4.6.9. sar_den . . . . . . . . . . . . . . . . . . . . . . . 43 - 4.6.10. reset_contexts . . . . . . . . . . . . . . . . . . . 43 - 4.6.11. slice_coding_mode . . . . . . . . . . . . . . . . . . 43 - 4.7. Slice Content . . . . . . . . . . . . . . . . . . . . . . 44 - 4.7.1. primary_color_count . . . . . . . . . . . . . . . . . 44 - 4.7.2. plane_pixel_height . . . . . . . . . . . . . . . . . 44 - 4.7.3. slice_pixel_height . . . . . . . . . . . . . . . . . 45 - 4.7.4. slice_pixel_y . . . . . . . . . . . . . . . . . . . . 45 - 4.8. Line . . . . . . . . . . . . . . . . . . . . . . . . . . 45 - 4.8.1. plane_pixel_width . . . . . . . . . . . . . . . . . . 45 - 4.8.2. slice_pixel_width . . . . . . . . . . . . . . . . . . 46 - 4.8.3. slice_pixel_x . . . . . . . . . . . . . . . . . . . . 46 - 4.8.4. sample_difference . . . . . . . . . . . . . . . . . . 46 - 4.9. Slice Footer . . . . . . . . . . . . . . . . . . . . . . 46 - 4.9.1. slice_size . . . . . . . . . . . . . . . . . . . . . 47 - 4.9.2. error_status . . . . . . . . . . . . . . . . . . . . 47 - 4.9.3. slice_crc_parity . . . . . . . . . . . . . . . . . . 47 - 5. Restrictions . . . . . . . . . . . . . . . . . . . . . . . . 47 - 6. Security Considerations . . . . . . . . . . . . . . . . . . . 48 - 7. Media Type Definition . . . . . . . . . . . . . . . . . . . . 49 - 8. IANA Considerations . . . . . . . . . . . . . . . . . . . . . 50 - 9. Changelog . . . . . . . . . . . . . . . . . . . . . . . . . . 50 - 10. Normative References . . . . . . . . . . . . . . . . . . . . 50 - 11. Informative References . . . . . . . . . . . . . . . . . . . 51 - Appendix A. Multi-theaded decoder implementation suggestions . . 52 + 3.8.2. Golomb Rice Mode . . . . . . . . . . . . . . . . . . 21 + 4. Bitstream . . . . . . . . . . . . . . . . . . . . . . . . . . 26 + 4.1. Quantization Table Set . . . . . . . . . . . . . . . . . 27 + 4.1.1. quant_tables . . . . . . . . . . . . . . . . . . . . 28 + 4.1.2. context_count . . . . . . . . . . . . . . . . . . . . 29 + 4.2. Parameters . . . . . . . . . . . . . . . . . . . . . . . 29 + 4.2.1. version . . . . . . . . . . . . . . . . . . . . . . . 31 + 4.2.2. micro_version . . . . . . . . . . . . . . . . . . . . 31 + 4.2.3. coder_type . . . . . . . . . . . . . . . . . . . . . 32 + 4.2.4. state_transition_delta . . . . . . . . . . . . . . . 33 + 4.2.5. colorspace_type . . . . . . . . . . . . . . . . . . . 33 + 4.2.6. chroma_planes . . . . . . . . . . . . . . . . . . . . 34 + 4.2.7. bits_per_raw_sample . . . . . . . . . . . . . . . . . 34 + 4.2.8. log2_h_chroma_subsample . . . . . . . . . . . . . . . 35 + 4.2.9. log2_v_chroma_subsample . . . . . . . . . . . . . . . 35 + 4.2.10. extra_plane . . . . . . . . . . . . . . . . . . . . . 35 + 4.2.11. num_h_slices . . . . . . . . . . . . . . . . . . . . 35 + 4.2.12. num_v_slices . . . . . . . . . . . . . . . . . . . . 36 + 4.2.13. quant_table_set_count . . . . . . . . . . . . . . . . 36 + 4.2.14. states_coded . . . . . . . . . . . . . . . . . . . . 36 + 4.2.15. initial_state_delta . . . . . . . . . . . . . . . . . 36 + 4.2.16. ec . . . . . . . . . . . . . . . . . . . . . . . . . 37 + 4.2.17. intra . . . . . . . . . . . . . . . . . . . . . . . . 37 + 4.3. Configuration Record . . . . . . . . . . . . . . . . . . 37 + 4.3.1. reserved_for_future_use . . . . . . . . . . . . . . . 38 + 4.3.2. configuration_record_crc_parity . . . . . . . . . . . 38 + 4.3.3. Mapping FFV1 into Containers . . . . . . . . . . . . 38 + 4.4. Frame . . . . . . . . . . . . . . . . . . . . . . . . . . 39 + 4.5. Slice . . . . . . . . . . . . . . . . . . . . . . . . . . 41 + 4.6. Slice Header . . . . . . . . . . . . . . . . . . . . . . 42 + 4.6.1. slice_x . . . . . . . . . . . . . . . . . . . . . . . 42 + 4.6.2. slice_y . . . . . . . . . . . . . . . . . . . . . . . 42 + 4.6.3. slice_width . . . . . . . . . . . . . . . . . . . . . 42 + 4.6.4. slice_height . . . . . . . . . . . . . . . . . . . . 43 + 4.6.5. quant_table_set_index_count . . . . . . . . . . . . . 43 + 4.6.6. quant_table_set_index . . . . . . . . . . . . . . . . 43 + 4.6.7. picture_structure . . . . . . . . . . . . . . . . . . 43 + 4.6.8. sar_num . . . . . . . . . . . . . . . . . . . . . . . 44 + 4.6.9. sar_den . . . . . . . . . . . . . . . . . . . . . . . 44 + 4.6.10. reset_contexts . . . . . . . . . . . . . . . . . . . 44 + 4.6.11. slice_coding_mode . . . . . . . . . . . . . . . . . . 44 + 4.7. Slice Content . . . . . . . . . . . . . . . . . . . . . . 45 + 4.7.1. primary_color_count . . . . . . . . . . . . . . . . . 45 + 4.7.2. plane_pixel_height . . . . . . . . . . . . . . . . . 45 + 4.7.3. slice_pixel_height . . . . . . . . . . . . . . . . . 46 + 4.7.4. slice_pixel_y . . . . . . . . . . . . . . . . . . . . 46 + 4.8. Line . . . . . . . . . . . . . . . . . . . . . . . . . . 46 + 4.8.1. plane_pixel_width . . . . . . . . . . . . . . . . . . 46 + 4.8.2. slice_pixel_width . . . . . . . . . . . . . . . . . . 47 + 4.8.3. slice_pixel_x . . . . . . . . . . . . . . . . . . . . 47 + 4.8.4. sample_difference . . . . . . . . . . . . . . . . . . 47 + 4.9. Slice Footer . . . . . . . . . . . . . . . . . . . . . . 47 + 4.9.1. slice_size . . . . . . . . . . . . . . . . . . . . . 48 + 4.9.2. error_status . . . . . . . . . . . . . . . . . . . . 48 + 4.9.3. slice_crc_parity . . . . . . . . . . . . . . . . . . 48 + 5. Restrictions . . . . . . . . . . . . . . . . . . . . . . . . 48 + 6. Security Considerations . . . . . . . . . . . . . . . . . . . 49 + 7. Media Type Definition . . . . . . . . . . . . . . . . . . . . 50 + 8. IANA Considerations . . . . . . . . . . . . . . . . . . . . . 51 + 9. Changelog . . . . . . . . . . . . . . . . . . . . . . . . . . 51 + 10. Normative References . . . . . . . . . . . . . . . . . . . . 51 + 11. Informative References . . . . . . . . . . . . . . . . . . . 52 + Appendix A. Multi-theaded decoder implementation suggestions . . 54 Appendix B. Future handling of some streams created by non - conforming encoders . . . . . . . . . . . . . . . . . . . 53 - Authors' Addresses . . . . . . . . . . . . . . . . . . . . . . . 53 + conforming encoders . . . . . . . . . . . . . . . . . . . 54 + Authors' Addresses . . . . . . . . . . . . . . . . . . . . . . . 54 1. Introduction This document describes FFV1, a lossless video encoding format. The design of FFV1 considers the storage of image characteristics, data fixity, and the optimized use of encoding time and storage requirements. FFV1 is designed to support a wide range of lossless video applications such as long-term audiovisual preservation, scientific imaging, screen recording, and other video encoding scenarios that seek to avoid the generational loss of lossy video @@ -325,20 +325,24 @@ "max(a,b)" means the largest of two values a and b. "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). "A <== B" means B implies A. "A <==> B" means A <== B , B <== 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 + 2.2.6. Order of Operation Precedence When order of precedence is not indicated explicitly by use of parentheses, operations are evaluated in the following order (from top to bottom, operations of same precedence being evaluated from left to right). This order of operations is based on the order of operations used in Standard C. a++, a-- !a, -a @@ -492,55 +497,56 @@ configuration of all known implementations being impacted is 16-bit YCbCr with no Pixel transformation with Range Coder coder, as other potentially impacted configurations (e.g. 15/16-bit JPEG2000-RCT with Range Coder coder, or 16-bit content with Golomb Rice coder) were implemented nowhere [ISO.15444-1.2016]. In the meanwhile, 16-bit JPEG2000-RCT with Range Coder coder was implemented without this issue in one implementation and validated by one conformance checker. It is expected (to be confirmed) to remove this exception for the median predictor in the next version of the FFV1 bitstream. -3.4. Context - - Relative to any "Sample" "X", the Quantized Sample Differences "L-l", - "l-tl", "tl-t", "T-t", and "t-tr" are used as context: - - context = Q_{0}[l - tl] + - Q_{1}[tl - t] + - Q_{2}[t - tr] + - Q_{3}[L - l] + - Q_{4}[T - t] - Figure 4 - - If "context >= 0" then "context" is used and the difference between - the "Sample" and its predicted value is encoded as is, else - "-context" is used and the difference between the "Sample" and its - predicted value is encoded with a flipped sign. - -3.5. Quantization Table Sets +3.4. Quantization Table Sets The FFV1 bitstream contains one or more Quantization Table Sets. Each Quantization Table Set contains exactly 5 Quantization Tables with each Quantization Table corresponding to one of the five Quantized Sample Differences. For each Quantization Table, both the number of quantization steps and their distribution are stored in the FFV1 bitstream; each Quantization Table has exactly 256 entries, and the 8 least significant bits of the Quantized Sample Difference are used as index: - Q_{j}[k] = quant_tables[i][j][k&255] + Q_(j)[k] = quant_tables[i][j][k&255] - Figure 5 + Figure 4 In this formula, "i" is the Quantization Table Set index, "j" is the Quantized Table index, "k" the Quantized Sample Difference. +3.5. Context + + Relative to any "Sample" "X", the Quantized Sample Differences "L-l", + "l-tl", "tl-t", "T-t", and "t-tr" are used as context: + + context = Q_(0)[l - tl] + + Q_(1)[tl - t] + + Q_(2)[t - tr] + + Q_(3)[L - l] + + Q_(4)[T - t] + + Figure 5 + + If "context >= 0" then "context" is used and the difference between + the "Sample" and its predicted value is encoded as is, else + "-context" is used and the difference between the "Sample" and its + predicted value is encoded with a flipped sign. + 3.6. Quantization Table Set Indexes For each "Plane" of each slice, a Quantization Table Set is selected from an index: * For Y "Plane", "quant_table_set_index[ 0 ]" index is used * For Cb and Cr "Planes", "quant_table_set_index[ 1 ]" index is used * For extra "Plane", "quant_table_set_index[ (version <= 3 || @@ -682,68 +688,68 @@ 3.8.1. Range Coding Mode 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 patent/royalty situation, as well as its slightly worse performance, CABAC was replaced by a Range coder based on an algorithm defined by G. Nigel and N. Martin in 1979 [range-coding]. 3.8.1.1. Range Binary Values - To encode binary digits efficiently a Range coder is used. "C(i)" is - the i-th Context. "B(i)" is the i-th byte of the bytestream. "b(i)" - is the i-th Range coded binary value, "S(0,i)" is the i-th initial + To encode binary digits efficiently a Range coder is used. C_(i) is + the i-th Context. B_(i) is the i-th byte of the bytestream. b_(i) is + the i-th Range coded binary value, S_(0, i) is the i-th initial state. The length of the bytestream encoding n binary symbols is - "j(n)" bytes. + j_(n) bytes. + + r_(i) = floor( ( R_(i) * S_(i, C_(i)) ) / 2 ^ 8 ) - r_{i} = floor( ( R_{i} * S_{i,C_{i}} ) / 2 ^ 8 ) Figure 9 - 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 = 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) = 0 <==> + 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 <== - 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) <== + b_(i) = 1 <==> + L_(i) >= R_(i) - r_(i) Figure 10 - S_{i+1,k} = S_{i,k} <== C_i != k + S_(i + 1, k) = S_(i, k) <== C_(i) != k Figure 11 - 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) = 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} <== - t_{i} >= 2 ^ 8 + R_(i + 1) = t_(i) AND + L_(i + 1) = l_(i) AND + j_(i + 1) = j_(i) <== + t_(i) >= 2 ^ 8 Figure 12 - R_{0} = 65280 + R_(0) = 65280 Figure 13 - L_{0} = 2 ^ 8 * B_{0} + B_{1} - + L_(0) = 2 ^ 8 * B_(0) + B_(1) Figure 14 - j_{0} = 2 + j_(0) = 2 Figure 15 3.8.1.1.1. Termination The range coder can be used in three modes. * In "Open mode" when decoding, every symbol the reader attempts to read is available. In this mode arbitrary data can have been appended without affecting the range coder output. This mode is @@ -817,39 +823,40 @@ return a; } } Figure 16: A pseudo-code description of the contexts of Range Non Binary Values. "get_symbol" is used for the read out of "sample_difference" indicated in Figure 8. - "get_rac" is the process described in Section 3.8.1.1. + "get_rac" returns a boolean, computed from the bytestream as + described in Section 3.8.1.1. 3.8.1.3. Initial Values for the Context Model At keyframes all Range coder state variables are set to their initial state. 3.8.1.4. State Transition Table - one_state_{i} = - default_state_transition_{i} + state_transition_delta_{i} + one_state_(i) = + default_state_transition_(i) + state_transition_delta_(i) Figure 17 - zero_state_{i} = 256 - one_state_{256-i} + zero_state_(i) = 256 - one_state_(256-i) + Figure 18 3.8.1.5. default_state_transition - 0, 0, 0, 0, 0, 0, 0, 0, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30, 31, 32, 33, 34, 35, 36, 37, 37, 38, 39, 40, 41, 42, 43, 44, 45, 46, 47, 48, 49, 50, 51, 52, 53, 54, 55, 56, 56, 57, 58, 59, 60, 61, 62, 63, 64, 65, 66, 67, 68, 69, 70, 71, 72, 73, 74, 75, 75, 76, 77, 78, 79, 80, 81, 82, 83, 84, 85, 86, 87, 88, @@ -2135,27 +2142,29 @@ Implementations of the FFV1 codec need to take appropriate security considerations into account, as outlined in [RFC4732]. It is extremely important for the decoder to be robust against malicious payloads. Malicious payloads must not cause the decoder to overrun its allocated memory or to take an excessive amount of resources to decode. The same applies to the encoder, even though problems in encoders are typically rarer. Malicious video streams must not cause the encoder to misbehave because this would allow an attacker to attack transcoding gateways. A frequent security problem in image - and video codecs is also to not check for integer overflows in - "Pixel" count computations, that is to allocate width * height - without considering that the multiplication result may have - overflowed the arithmetic types range. The range coder could, if - implemented naively, read one byte over the end. The implementation - must ensure that no read outside allocated and initialized memory - occurs. + and video codecs is also to not check for integer overflows, for + example to allocate "frame_pixel_width * frame_pixel_height" in + "Pixel" count computations without considering that the + multiplication result may have overflowed the arithmetic types range. + The range coder could, if implemented naively, read one byte over the + end. The implementation must ensure that no read outside allocated + and initialized memory occurs. + + None of the content carried in FFV1 is intended to be executable. The reference implementation [REFIMPL] contains no known buffer overflow or cases where a specially crafted packet or video segment could cause a significant increase in CPU load. The reference implementation [REFIMPL] was validated in the following conditions: * Sending the decoder valid packets generated by the reference encoder and verifying that the decoder's output matches the @@ -2253,110 +2262,113 @@ [RFC Editor: Please remove this Changelog section prior to publication.] 10. Normative References [RFC2119] Bradner, S., "Key words for use in RFCs to Indicate Requirement Levels", BCP 14, RFC 2119, DOI 10.17487/RFC2119, March 1997, . + [RFC8174] Leiba, B., "Ambiguity of Uppercase vs Lowercase in RFC + 2119 Key Words", BCP 14, RFC 8174, DOI 10.17487/RFC8174, + May 2017, . + + [RFC4732] Handley, M., Ed., Rescorla, E., Ed., and IAB, "Internet + Denial-of-Service Considerations", RFC 4732, + DOI 10.17487/RFC4732, December 2006, + . + + [ISO.9899.2018] + International Organization for Standardization, + "Programming languages - C", ISO Standard 9899, 2018. + + [RFC6838] Freed, N., Klensin, J., and T. Hansen, "Media Type + Specifications and Registration Procedures", BCP 13, + RFC 6838, DOI 10.17487/RFC6838, January 2013, + . + + [ISO.9899.1990] + International Organization for Standardization, + "Programming languages - C", ISO Standard 9899, 1990. + [ISO.15444-1.2016] International Organization for Standardization, "Information technology -- JPEG 2000 image coding system: Core coding system", October 2016. [RFC6716] Valin, JM., Vos, K., and T. Terriberry, "Definition of the Opus Audio Codec", RFC 6716, DOI 10.17487/RFC6716, September 2012, . - [ISO.9899.2018] - International Organization for Standardization, - "Programming languages - C", 2018. - - [Matroska] IETF, "Matroska", 2019, . - - [RFC4732] Handley, M., Ed., Rescorla, E., Ed., and IAB, "Internet - Denial-of-Service Considerations", RFC 4732, - DOI 10.17487/RFC4732, December 2006, - . - [RFC4855] Casner, S., "Media Type Registration of RTP Payload Formats", RFC 4855, DOI 10.17487/RFC4855, February 2007, . - [RFC8174] Leiba, B., "Ambiguity of Uppercase vs Lowercase in RFC - 2119 Key Words", BCP 14, RFC 8174, DOI 10.17487/RFC8174, - May 2017, . - - [ISO.9899.1990] - International Organization for Standardization, - "Programming languages - C", 1990. - - [RFC6838] Freed, N., Klensin, J., and T. Hansen, "Media Type - Specifications and Registration Procedures", BCP 13, - RFC 6838, DOI 10.17487/RFC6838, January 2013, - . + [Matroska] IETF, "Matroska", 2019, . 11. Informative References - [YCbCr] Wikipedia, "YCbCr", undated, - . - [I-D.ietf-cellar-ffv1] Niedermayer, M., Rice, D., and J. Martinez, "FFV1 Video Coding Format Version 0, 1, and 3", Work in Progress, - Internet-Draft, draft-ietf-cellar-ffv1-14, 26 May 2020, - . - - [HuffYUV] Rudiak-Gould, B., "HuffYUV", December 2003, - . - - [AVI] Microsoft, "AVI RIFF File Reference", undated, - . - - [ISO.14496-12.2015] - International Organization for Standardization, - "Information technology -- Coding of audio-visual objects - -- Part 12: ISO base media file format", December 2015. + Internet-Draft, draft-ietf-cellar-ffv1-16, 2 July 2020, + . [ISO.14495-1.1999] International Organization for Standardization, "Information technology -- Lossless and near-lossless compression of continuous-tone still images: Baseline", December 1999. - [VALGRIND] Valgrind Developers, "Valgrind website", undated, - . + [NUT] Niedermayer, M., "NUT Open Container Format", December + 2013, . - [range-coding] - Nigel, G. and N. Martin, "Range encoding: an algorithm for - removing redundancy from a digitised message.", July 1979. + [YCbCr] Wikipedia, "YCbCr", undated, + . [ISO.14496-10.2014] International Organization for Standardization, "Information technology -- Coding of audio-visual objects -- Part 10: Advanced Video Coding", September 2014. + [VALGRIND] Valgrind Developers, "Valgrind website", undated, + . + [REFIMPL] Niedermayer, M., "The reference FFV1 implementation / the FFV1 codec in FFmpeg", undated, . + [HuffYUV] Rudiak-Gould, B., "HuffYUV", December 2003, + . + + [ISO.14496-12.2015] + International Organization for Standardization, + "Information technology -- Coding of audio-visual objects + -- Part 12: ISO base media file format", December 2015. + + [range-coding] + Nigel, G. and N. Martin, "Range encoding: an algorithm for + removing redundancy from a digitised message.", + Proceedings of the Conference on Video and Data + Recording. Institution of Electronic and Radio Engineers, + Hampshire, England, July 1979. + + [AVI] Microsoft, "AVI RIFF File Reference", undated, + . + [Address-Sanitizer] The Clang Team, "ASAN AddressSanitizer website", undated, . - [NUT] Niedermayer, M., "NUT Open Container Format", December - 2013, . - Appendix A. Multi-theaded decoder implementation suggestions This appendix is informative. The FFV1 bitstream is parsable in two ways: in sequential order as described in this document or with the pre-analysis of the footer of each slice. Each slice footer contains a "slice_size" field so the boundary of each slice is computable without having to parse the slice content. That allows multi-threading as well as independence of slice content (a bitstream error in a slice header or slice