draft-ietf-cellar-ffv1-v4-13.txt | draft-ietf-cellar-ffv1-v4-14.txt | |||
---|---|---|---|---|
cellar M. Niedermayer | cellar M. Niedermayer | |||
Internet-Draft | Internet-Draft | |||
Intended status: Standards Track D. Rice | Intended status: Standards Track D. Rice | |||
Expires: 3 January 2021 | Expires: 22 February 2021 | |||
J. Martinez | J. Martinez | |||
2 July 2020 | 21 August 2020 | |||
FFV1 Video Coding Format Version 4 | FFV1 Video Coding Format Version 4 | |||
draft-ietf-cellar-ffv1-v4-13 | draft-ietf-cellar-ffv1-v4-14 | |||
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 3 January 2021. | This Internet-Draft will expire on 22 February 2021. | |||
Copyright Notice | Copyright Notice | |||
Copyright (c) 2020 IETF Trust and the persons identified as the | Copyright (c) 2020 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 | |||
skipping to change at page 2, line 28 ¶ | skipping to change at page 2, line 28 ¶ | |||
2.1. Definitions . . . . . . . . . . . . . . . . . . . . . . . 4 | 2.1. Definitions . . . . . . . . . . . . . . . . . . . . . . . 4 | |||
2.2. Conventions . . . . . . . . . . . . . . . . . . . . . . . 5 | 2.2. Conventions . . . . . . . . . . . . . . . . . . . . . . . 5 | |||
2.2.1. Pseudo-code . . . . . . . . . . . . . . . . . . . . . 5 | 2.2.1. Pseudo-code . . . . . . . . . . . . . . . . . . . . . 5 | |||
2.2.2. Arithmetic Operators . . . . . . . . . . . . . . . . 6 | 2.2.2. Arithmetic Operators . . . . . . . . . . . . . . . . 6 | |||
2.2.3. Assignment Operators . . . . . . . . . . . . . . . . 6 | 2.2.3. Assignment Operators . . . . . . . . . . . . . . . . 6 | |||
2.2.4. Comparison Operators . . . . . . . . . . . . . . . . 7 | 2.2.4. Comparison Operators . . . . . . . . . . . . . . . . 7 | |||
2.2.5. Mathematical Functions . . . . . . . . . . . . . . . 7 | 2.2.5. Mathematical Functions . . . . . . . . . . . . . . . 7 | |||
2.2.6. Order of Operation Precedence . . . . . . . . . . . . 8 | 2.2.6. Order of Operation Precedence . . . . . . . . . . . . 8 | |||
2.2.7. Range . . . . . . . . . . . . . . . . . . . . . . . . 8 | 2.2.7. Range . . . . . . . . . . . . . . . . . . . . . . . . 8 | |||
2.2.8. NumBytes . . . . . . . . . . . . . . . . . . . . . . 8 | 2.2.8. NumBytes . . . . . . . . . . . . . . . . . . . . . . 8 | |||
2.2.9. Bitstream Functions . . . . . . . . . . . . . . . . . 8 | 2.2.9. Bitstream Functions . . . . . . . . . . . . . . . . . 9 | |||
3. Sample Coding . . . . . . . . . . . . . . . . . . . . . . . . 9 | 3. Sample Coding . . . . . . . . . . . . . . . . . . . . . . . . 9 | |||
3.1. Border . . . . . . . . . . . . . . . . . . . . . . . . . 9 | 3.1. Border . . . . . . . . . . . . . . . . . . . . . . . . . 9 | |||
3.2. Samples . . . . . . . . . . . . . . . . . . . . . . . . . 10 | 3.2. Samples . . . . . . . . . . . . . . . . . . . . . . . . . 10 | |||
3.3. Median Predictor . . . . . . . . . . . . . . . . . . . . 11 | 3.3. Median Predictor . . . . . . . . . . . . . . . . . . . . 11 | |||
3.4. Context . . . . . . . . . . . . . . . . . . . . . . . . . 11 | 3.4. Quantization Table Sets . . . . . . . . . . . . . . . . . 12 | |||
3.5. Quantization Table Sets . . . . . . . . . . . . . . . . . 12 | 3.5. Context . . . . . . . . . . . . . . . . . . . . . . . . . 12 | |||
3.6. Quantization Table Set Indexes . . . . . . . . . . . . . 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.1. YCbCr . . . . . . . . . . . . . . . . . . . . . . . . 13 | |||
3.7.2. RGB . . . . . . . . . . . . . . . . . . . . . . . . . 13 | 3.7.2. RGB . . . . . . . . . . . . . . . . . . . . . . . . . 13 | |||
3.8. Coding of the Sample Difference . . . . . . . . . . . . . 15 | 3.8. Coding of the Sample Difference . . . . . . . . . . . . . 15 | |||
3.8.1. Range Coding Mode . . . . . . . . . . . . . . . . . . 15 | 3.8.1. Range Coding Mode . . . . . . . . . . . . . . . . . . 15 | |||
3.8.2. Golomb Rice Mode . . . . . . . . . . . . . . . . . . 20 | 3.8.2. Golomb Rice Mode . . . . . . . . . . . . . . . . . . 21 | |||
4. Bitstream . . . . . . . . . . . . . . . . . . . . . . . . . . 25 | 4. Bitstream . . . . . . . . . . . . . . . . . . . . . . . . . . 26 | |||
4.1. Quantization Table Set . . . . . . . . . . . . . . . . . 26 | 4.1. Quantization Table Set . . . . . . . . . . . . . . . . . 27 | |||
4.1.1. quant_tables . . . . . . . . . . . . . . . . . . . . 27 | 4.1.1. quant_tables . . . . . . . . . . . . . . . . . . . . 28 | |||
4.1.2. context_count . . . . . . . . . . . . . . . . . . . . 28 | 4.1.2. context_count . . . . . . . . . . . . . . . . . . . . 29 | |||
4.2. Parameters . . . . . . . . . . . . . . . . . . . . . . . 28 | 4.2. Parameters . . . . . . . . . . . . . . . . . . . . . . . 29 | |||
4.2.1. version . . . . . . . . . . . . . . . . . . . . . . . 30 | 4.2.1. version . . . . . . . . . . . . . . . . . . . . . . . 31 | |||
4.2.2. micro_version . . . . . . . . . . . . . . . . . . . . 30 | 4.2.2. micro_version . . . . . . . . . . . . . . . . . . . . 31 | |||
4.2.3. coder_type . . . . . . . . . . . . . . . . . . . . . 31 | 4.2.3. coder_type . . . . . . . . . . . . . . . . . . . . . 32 | |||
4.2.4. state_transition_delta . . . . . . . . . . . . . . . 32 | 4.2.4. state_transition_delta . . . . . . . . . . . . . . . 33 | |||
4.2.5. colorspace_type . . . . . . . . . . . . . . . . . . . 32 | 4.2.5. colorspace_type . . . . . . . . . . . . . . . . . . . 33 | |||
4.2.6. chroma_planes . . . . . . . . . . . . . . . . . . . . 33 | 4.2.6. chroma_planes . . . . . . . . . . . . . . . . . . . . 34 | |||
4.2.7. bits_per_raw_sample . . . . . . . . . . . . . . . . . 33 | 4.2.7. bits_per_raw_sample . . . . . . . . . . . . . . . . . 34 | |||
4.2.8. log2_h_chroma_subsample . . . . . . . . . . . . . . . 34 | 4.2.8. log2_h_chroma_subsample . . . . . . . . . . . . . . . 35 | |||
4.2.9. log2_v_chroma_subsample . . . . . . . . . . . . . . . 34 | 4.2.9. log2_v_chroma_subsample . . . . . . . . . . . . . . . 35 | |||
4.2.10. extra_plane . . . . . . . . . . . . . . . . . . . . . 34 | 4.2.10. extra_plane . . . . . . . . . . . . . . . . . . . . . 35 | |||
4.2.11. num_h_slices . . . . . . . . . . . . . . . . . . . . 34 | 4.2.11. num_h_slices . . . . . . . . . . . . . . . . . . . . 35 | |||
4.2.12. num_v_slices . . . . . . . . . . . . . . . . . . . . 35 | 4.2.12. num_v_slices . . . . . . . . . . . . . . . . . . . . 36 | |||
4.2.13. quant_table_set_count . . . . . . . . . . . . . . . . 35 | 4.2.13. quant_table_set_count . . . . . . . . . . . . . . . . 36 | |||
4.2.14. states_coded . . . . . . . . . . . . . . . . . . . . 35 | 4.2.14. states_coded . . . . . . . . . . . . . . . . . . . . 36 | |||
4.2.15. initial_state_delta . . . . . . . . . . . . . . . . . 35 | 4.2.15. initial_state_delta . . . . . . . . . . . . . . . . . 36 | |||
4.2.16. ec . . . . . . . . . . . . . . . . . . . . . . . . . 36 | 4.2.16. ec . . . . . . . . . . . . . . . . . . . . . . . . . 37 | |||
4.2.17. intra . . . . . . . . . . . . . . . . . . . . . . . . 36 | 4.2.17. intra . . . . . . . . . . . . . . . . . . . . . . . . 37 | |||
4.3. Configuration Record . . . . . . . . . . . . . . . . . . 36 | 4.3. Configuration Record . . . . . . . . . . . . . . . . . . 37 | |||
4.3.1. reserved_for_future_use . . . . . . . . . . . . . . . 37 | 4.3.1. reserved_for_future_use . . . . . . . . . . . . . . . 38 | |||
4.3.2. configuration_record_crc_parity . . . . . . . . . . . 37 | 4.3.2. configuration_record_crc_parity . . . . . . . . . . . 38 | |||
4.3.3. Mapping FFV1 into Containers . . . . . . . . . . . . 37 | 4.3.3. Mapping FFV1 into Containers . . . . . . . . . . . . 38 | |||
4.4. Frame . . . . . . . . . . . . . . . . . . . . . . . . . . 38 | 4.4. Frame . . . . . . . . . . . . . . . . . . . . . . . . . . 39 | |||
4.5. Slice . . . . . . . . . . . . . . . . . . . . . . . . . . 40 | 4.5. Slice . . . . . . . . . . . . . . . . . . . . . . . . . . 41 | |||
4.6. Slice Header . . . . . . . . . . . . . . . . . . . . . . 41 | 4.6. Slice Header . . . . . . . . . . . . . . . . . . . . . . 42 | |||
4.6.1. slice_x . . . . . . . . . . . . . . . . . . . . . . . 41 | 4.6.1. slice_x . . . . . . . . . . . . . . . . . . . . . . . 42 | |||
4.6.2. slice_y . . . . . . . . . . . . . . . . . . . . . . . 41 | 4.6.2. slice_y . . . . . . . . . . . . . . . . . . . . . . . 42 | |||
4.6.3. slice_width . . . . . . . . . . . . . . . . . . . . . 41 | 4.6.3. slice_width . . . . . . . . . . . . . . . . . . . . . 42 | |||
4.6.4. slice_height . . . . . . . . . . . . . . . . . . . . 42 | 4.6.4. slice_height . . . . . . . . . . . . . . . . . . . . 43 | |||
4.6.5. quant_table_set_index_count . . . . . . . . . . . . . 42 | 4.6.5. quant_table_set_index_count . . . . . . . . . . . . . 43 | |||
4.6.6. quant_table_set_index . . . . . . . . . . . . . . . . 42 | 4.6.6. quant_table_set_index . . . . . . . . . . . . . . . . 43 | |||
4.6.7. picture_structure . . . . . . . . . . . . . . . . . . 42 | 4.6.7. picture_structure . . . . . . . . . . . . . . . . . . 43 | |||
4.6.8. sar_num . . . . . . . . . . . . . . . . . . . . . . . 43 | 4.6.8. sar_num . . . . . . . . . . . . . . . . . . . . . . . 44 | |||
4.6.9. sar_den . . . . . . . . . . . . . . . . . . . . . . . 43 | 4.6.9. sar_den . . . . . . . . . . . . . . . . . . . . . . . 44 | |||
4.6.10. reset_contexts . . . . . . . . . . . . . . . . . . . 43 | 4.6.10. reset_contexts . . . . . . . . . . . . . . . . . . . 44 | |||
4.6.11. slice_coding_mode . . . . . . . . . . . . . . . . . . 43 | 4.6.11. slice_coding_mode . . . . . . . . . . . . . . . . . . 44 | |||
4.7. Slice Content . . . . . . . . . . . . . . . . . . . . . . 44 | 4.7. Slice Content . . . . . . . . . . . . . . . . . . . . . . 45 | |||
4.7.1. primary_color_count . . . . . . . . . . . . . . . . . 44 | 4.7.1. primary_color_count . . . . . . . . . . . . . . . . . 45 | |||
4.7.2. plane_pixel_height . . . . . . . . . . . . . . . . . 44 | 4.7.2. plane_pixel_height . . . . . . . . . . . . . . . . . 45 | |||
4.7.3. slice_pixel_height . . . . . . . . . . . . . . . . . 45 | 4.7.3. slice_pixel_height . . . . . . . . . . . . . . . . . 46 | |||
4.7.4. slice_pixel_y . . . . . . . . . . . . . . . . . . . . 45 | 4.7.4. slice_pixel_y . . . . . . . . . . . . . . . . . . . . 46 | |||
4.8. Line . . . . . . . . . . . . . . . . . . . . . . . . . . 45 | 4.8. Line . . . . . . . . . . . . . . . . . . . . . . . . . . 46 | |||
4.8.1. plane_pixel_width . . . . . . . . . . . . . . . . . . 45 | 4.8.1. plane_pixel_width . . . . . . . . . . . . . . . . . . 46 | |||
4.8.2. slice_pixel_width . . . . . . . . . . . . . . . . . . 46 | 4.8.2. slice_pixel_width . . . . . . . . . . . . . . . . . . 47 | |||
4.8.3. slice_pixel_x . . . . . . . . . . . . . . . . . . . . 46 | 4.8.3. slice_pixel_x . . . . . . . . . . . . . . . . . . . . 47 | |||
4.8.4. sample_difference . . . . . . . . . . . . . . . . . . 46 | 4.8.4. sample_difference . . . . . . . . . . . . . . . . . . 47 | |||
4.9. Slice Footer . . . . . . . . . . . . . . . . . . . . . . 46 | 4.9. Slice Footer . . . . . . . . . . . . . . . . . . . . . . 47 | |||
4.9.1. slice_size . . . . . . . . . . . . . . . . . . . . . 47 | 4.9.1. slice_size . . . . . . . . . . . . . . . . . . . . . 48 | |||
4.9.2. error_status . . . . . . . . . . . . . . . . . . . . 47 | 4.9.2. error_status . . . . . . . . . . . . . . . . . . . . 48 | |||
4.9.3. slice_crc_parity . . . . . . . . . . . . . . . . . . 47 | 4.9.3. slice_crc_parity . . . . . . . . . . . . . . . . . . 48 | |||
5. Restrictions . . . . . . . . . . . . . . . . . . . . . . . . 47 | 5. Restrictions . . . . . . . . . . . . . . . . . . . . . . . . 48 | |||
6. Security Considerations . . . . . . . . . . . . . . . . . . . 48 | 6. Security Considerations . . . . . . . . . . . . . . . . . . . 49 | |||
7. Media Type Definition . . . . . . . . . . . . . . . . . . . . 49 | 7. Media Type Definition . . . . . . . . . . . . . . . . . . . . 50 | |||
8. IANA Considerations . . . . . . . . . . . . . . . . . . . . . 50 | 8. IANA Considerations . . . . . . . . . . . . . . . . . . . . . 51 | |||
9. Changelog . . . . . . . . . . . . . . . . . . . . . . . . . . 50 | 9. Changelog . . . . . . . . . . . . . . . . . . . . . . . . . . 51 | |||
10. Normative References . . . . . . . . . . . . . . . . . . . . 50 | 10. Normative References . . . . . . . . . . . . . . . . . . . . 51 | |||
11. Informative References . . . . . . . . . . . . . . . . . . . 51 | 11. Informative References . . . . . . . . . . . . . . . . . . . 52 | |||
Appendix A. Multi-theaded decoder implementation suggestions . . 52 | Appendix A. Multi-theaded decoder implementation suggestions . . 54 | |||
Appendix B. Future handling of some streams created by non | Appendix B. Future handling of some streams created by non | |||
conforming encoders . . . . . . . . . . . . . . . . . . . 53 | conforming encoders . . . . . . . . . . . . . . . . . . . 54 | |||
Authors' Addresses . . . . . . . . . . . . . . . . . . . . . . . 53 | Authors' Addresses . . . . . . . . . . . . . . . . . . . . . . . 54 | |||
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 8, line 14 ¶ | skipping to change at page 8, line 14 ¶ | |||
"max(a,b)" means the largest of two values a and b. | "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, | "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 B implies A. | |||
"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,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. | |||
a++, a-- | a++, a-- | |||
!a, -a | !a, -a | |||
skipping to change at page 11, line 43 ¶ | skipping to change at page 12, line 5 ¶ | |||
configuration of all known implementations being impacted is 16-bit | configuration of all known implementations being impacted is 16-bit | |||
YCbCr with no Pixel transformation with Range Coder coder, as other | YCbCr with no Pixel transformation with Range Coder coder, as other | |||
potentially impacted configurations (e.g. 15/16-bit JPEG2000-RCT with | potentially impacted configurations (e.g. 15/16-bit JPEG2000-RCT with | |||
Range Coder coder, or 16-bit content with Golomb Rice coder) were | Range Coder coder, or 16-bit content with Golomb Rice coder) were | |||
implemented nowhere [ISO.15444-1.2016]. In the meanwhile, 16-bit | implemented nowhere [ISO.15444-1.2016]. In the meanwhile, 16-bit | |||
JPEG2000-RCT with Range Coder coder was implemented without this | JPEG2000-RCT with Range Coder coder was implemented without this | |||
issue in one implementation and validated by one conformance checker. | issue in one implementation and validated by one conformance checker. | |||
It is expected (to be confirmed) to remove this exception for the | It is expected (to be confirmed) to remove this exception for the | |||
median predictor in the next version of the FFV1 bitstream. | median predictor in the next version of the FFV1 bitstream. | |||
3.4. Context | 3.4. Quantization Table Sets | |||
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 | ||||
The FFV1 bitstream contains one or more Quantization Table Sets. | The FFV1 bitstream contains one or more Quantization Table Sets. | |||
Each Quantization Table Set contains exactly 5 Quantization Tables | Each Quantization Table Set contains exactly 5 Quantization Tables | |||
with each Quantization Table corresponding to one of the five | with each Quantization Table corresponding to one of the five | |||
Quantized Sample Differences. For each Quantization Table, both the | Quantized Sample Differences. For each Quantization Table, both the | |||
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 5 | 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. | |||
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 | 3.6. Quantization Table Set Indexes | |||
For each "Plane" of each slice, a Quantization Table Set is selected | For each "Plane" of each slice, a Quantization Table Set is selected | |||
from an index: | from an index: | |||
* For Y "Plane", "quant_table_set_index[ 0 ]" index is used | * 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 Cb and Cr "Planes", "quant_table_set_index[ 1 ]" index is used | |||
* For extra "Plane", "quant_table_set_index[ (version <= 3 || | * For extra "Plane", "quant_table_set_index[ (version <= 3 || | |||
skipping to change at page 15, line 45 ¶ | skipping to change at page 16, line 7 ¶ | |||
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 and N. Martin in 1979 [range-coding]. | G. Nigel and 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. C_(i) is | |||
the i-th Context. "B(i)" is the i-th byte of the bytestream. "b(i)" | the i-th Context. B_(i) is the i-th byte of the bytestream. b_(i) is | |||
is the i-th Range coded binary value, "S(0,i)" is the i-th initial | 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 | 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 | Figure 9 | |||
S_{i+1,C_{i}} = zero_state_{S_{i,C_{i}}} AND | S_(i + 1, C_(i)) = zero_state_(S_(i, C_(i))) AND | |||
l_i = L_i AND | l_(i) = L_(i) AND | |||
t_i = R_i - r_i <== | t_(i) = R_(i) - r_(i) <== | |||
b_i = 0 <==> | b_(i) = 0 <==> | |||
L_i < R_i - r_i | L_(i) < R_(i) - r_(i) | |||
S_{i+1,C_{i}} = one_state_{S_{i,C_{i}}} AND | S_(i + 1, C_(i)) = one_state_(S_(i, C_(i))) AND | |||
l_i = L_i - R_i + r_i AND | l_(i) = L_(i) - R_(i) + r_(i) AND | |||
t_i = r_i <== | t_(i) = r_(i) <== | |||
b_i = 1 <==> | b_(i) = 1 <==> | |||
L_i >= R_i - r_i | L_(i) >= R_(i) - r_(i) | |||
Figure 10 | Figure 10 | |||
S_{i+1,k} = S_{i,k} <== C_i != k | S_(i + 1, k) = S_(i, k) <== C_(i) != k | |||
Figure 11 | Figure 11 | |||
R_{i+1} = 2 ^ 8 * t_{i} AND | R_(i + 1) = 2 ^ 8 * t_(i) AND | |||
L_{i+1} = 2 ^ 8 * l_{i} + B_{j_{i}} AND | L_(i + 1) = 2 ^ 8 * l_(i) + B_(j_(i)) AND | |||
j_{i+1} = j_{i} + 1 <== | j_(i + 1) = j_(i) + 1 <== | |||
t_{i} < 2 ^ 8 | t_(i) < 2 ^ 8 | |||
R_{i+1} = t_{i} AND | R_(i + 1) = t_(i) AND | |||
L_{i+1} = l_{i} AND | L_(i + 1) = l_(i) AND | |||
j_{i+1} = j_{i} <== | j_(i + 1) = j_(i) <== | |||
t_{i} >= 2 ^ 8 | t_(i) >= 2 ^ 8 | |||
Figure 12 | Figure 12 | |||
R_{0} = 65280 | R_(0) = 65280 | |||
Figure 13 | Figure 13 | |||
L_{0} = 2 ^ 8 * B_{0} + B_{1} | L_(0) = 2 ^ 8 * B_(0) + B_(1) | |||
Figure 14 | Figure 14 | |||
j_{0} = 2 | j_(0) = 2 | |||
Figure 15 | Figure 15 | |||
3.8.1.1.1. Termination | 3.8.1.1.1. Termination | |||
The range coder can be used in three modes. | The range coder can be used in three modes. | |||
* In "Open mode" when decoding, every symbol the reader attempts to | * In "Open mode" when decoding, every symbol the reader attempts to | |||
read is available. In this mode arbitrary data can have been | read is available. In this mode arbitrary data can have been | |||
appended without affecting the range coder output. This mode is | appended without affecting the range coder output. This mode is | |||
skipping to change at page 18, line 37 ¶ | skipping to change at page 18, line 51 ¶ | |||
return a; | return a; | |||
} | } | |||
} | } | |||
Figure 16: A pseudo-code description of the contexts of Range Non | Figure 16: 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 8. | 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 | 3.8.1.3. Initial Values for the Context Model | |||
At keyframes all Range coder state variables are set to their initial | At keyframes all Range coder state variables are set to their initial | |||
state. | state. | |||
3.8.1.4. State Transition Table | 3.8.1.4. State Transition Table | |||
one_state_{i} = | one_state_(i) = | |||
default_state_transition_{i} + state_transition_delta_{i} | default_state_transition_(i) + state_transition_delta_(i) | |||
Figure 17 | Figure 17 | |||
zero_state_{i} = 256 - one_state_{256-i} | zero_state_(i) = 256 - one_state_(256-i) | |||
Figure 18 | Figure 18 | |||
3.8.1.5. default_state_transition | 3.8.1.5. default_state_transition | |||
0, 0, 0, 0, 0, 0, 0, 0, 20, 21, 22, 23, 24, 25, 26, 27, | 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, | 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, | 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, | 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, | 74, 75, 75, 76, 77, 78, 79, 80, 81, 82, 83, 84, 85, 86, 87, 88, | |||
skipping to change at page 48, line 29 ¶ | skipping to change at page 49, line 29 ¶ | |||
Implementations of the FFV1 codec need to take appropriate security | Implementations of the FFV1 codec need to take appropriate security | |||
considerations into account, as outlined in [RFC4732]. It is | considerations into account, as outlined in [RFC4732]. It is | |||
extremely important for the decoder to be robust against malicious | extremely important for the decoder to be robust against malicious | |||
payloads. Malicious payloads must not cause the decoder to overrun | payloads. Malicious payloads must not cause the decoder to overrun | |||
its allocated memory or to take an excessive amount of resources to | its allocated memory or to take an excessive amount of resources to | |||
decode. The same applies to the encoder, even though problems in | decode. The same applies to the encoder, even though problems in | |||
encoders are typically rarer. Malicious video streams must not cause | encoders are typically rarer. Malicious video streams must not cause | |||
the encoder to misbehave because this would allow an attacker to | the encoder to misbehave because this would allow an attacker to | |||
attack transcoding gateways. A frequent security problem in image | attack transcoding gateways. A frequent security problem in image | |||
and video codecs is also to not check for integer overflows in | and video codecs is also to not check for integer overflows, for | |||
"Pixel" count computations, that is to allocate width * height | example to allocate "frame_pixel_width * frame_pixel_height" in | |||
without considering that the multiplication result may have | "Pixel" count computations without considering that the | |||
overflowed the arithmetic types range. The range coder could, if | multiplication result may have overflowed the arithmetic types range. | |||
implemented naively, read one byte over the end. The implementation | The range coder could, if implemented naively, read one byte over the | |||
must ensure that no read outside allocated and initialized memory | end. The implementation must ensure that no read outside allocated | |||
occurs. | and initialized memory occurs. | |||
None of the content carried in FFV1 is intended to be executable. | ||||
The reference implementation [REFIMPL] contains no known buffer | The reference implementation [REFIMPL] contains no known buffer | |||
overflow or cases where a specially crafted packet or video segment | overflow or cases where a specially crafted packet or video segment | |||
could cause a significant increase in CPU load. | could cause a significant increase in CPU load. | |||
The reference implementation [REFIMPL] was validated in the following | The reference implementation [REFIMPL] was validated in the following | |||
conditions: | conditions: | |||
* Sending the decoder valid packets generated by the reference | * Sending the decoder valid packets generated by the reference | |||
encoder and verifying that the decoder's output matches the | encoder and verifying that the decoder's output matches the | |||
skipping to change at page 51, line 5 ¶ | skipping to change at page 52, line 5 ¶ | |||
[RFC Editor: Please remove this Changelog section prior to | [RFC Editor: Please remove this Changelog section prior to | |||
publication.] | publication.] | |||
10. Normative References | 10. Normative References | |||
[RFC2119] Bradner, S., "Key words for use in RFCs to Indicate | [RFC2119] Bradner, S., "Key words for use in RFCs to Indicate | |||
Requirement Levels", BCP 14, RFC 2119, | Requirement Levels", BCP 14, RFC 2119, | |||
DOI 10.17487/RFC2119, March 1997, | DOI 10.17487/RFC2119, March 1997, | |||
<https://www.rfc-editor.org/info/rfc2119>. | <https://www.rfc-editor.org/info/rfc2119>. | |||
[RFC8174] Leiba, B., "Ambiguity of Uppercase vs Lowercase in RFC | ||||
2119 Key Words", BCP 14, RFC 8174, DOI 10.17487/RFC8174, | ||||
May 2017, <https://www.rfc-editor.org/info/rfc8174>. | ||||
[RFC4732] Handley, M., Ed., Rescorla, E., Ed., and IAB, "Internet | ||||
Denial-of-Service Considerations", RFC 4732, | ||||
DOI 10.17487/RFC4732, December 2006, | ||||
<https://www.rfc-editor.org/info/rfc4732>. | ||||
[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, | ||||
<https://www.rfc-editor.org/info/rfc6838>. | ||||
[ISO.9899.1990] | ||||
International Organization for Standardization, | ||||
"Programming languages - C", ISO Standard 9899, 1990. | ||||
[ISO.15444-1.2016] | [ISO.15444-1.2016] | |||
International Organization for Standardization, | International Organization for Standardization, | |||
"Information technology -- JPEG 2000 image coding system: | "Information technology -- JPEG 2000 image coding system: | |||
Core coding system", October 2016. | Core coding system", October 2016. | |||
[RFC6716] Valin, JM., Vos, K., and T. Terriberry, "Definition of the | [RFC6716] Valin, JM., Vos, K., and T. Terriberry, "Definition of the | |||
Opus Audio Codec", RFC 6716, DOI 10.17487/RFC6716, | Opus Audio Codec", RFC 6716, DOI 10.17487/RFC6716, | |||
September 2012, <https://www.rfc-editor.org/info/rfc6716>. | September 2012, <https://www.rfc-editor.org/info/rfc6716>. | |||
[ISO.9899.2018] | ||||
International Organization for Standardization, | ||||
"Programming languages - C", 2018. | ||||
[Matroska] IETF, "Matroska", 2019, <https://datatracker.ietf.org/doc/ | ||||
draft-ietf-cellar-matroska/>. | ||||
[RFC4732] Handley, M., Ed., Rescorla, E., Ed., and IAB, "Internet | ||||
Denial-of-Service Considerations", RFC 4732, | ||||
DOI 10.17487/RFC4732, December 2006, | ||||
<https://www.rfc-editor.org/info/rfc4732>. | ||||
[RFC4855] Casner, S., "Media Type Registration of RTP Payload | [RFC4855] Casner, S., "Media Type Registration of RTP Payload | |||
Formats", RFC 4855, DOI 10.17487/RFC4855, February 2007, | Formats", RFC 4855, DOI 10.17487/RFC4855, February 2007, | |||
<https://www.rfc-editor.org/info/rfc4855>. | <https://www.rfc-editor.org/info/rfc4855>. | |||
[RFC8174] Leiba, B., "Ambiguity of Uppercase vs Lowercase in RFC | [Matroska] IETF, "Matroska", 2019, <https://datatracker.ietf.org/doc/ | |||
2119 Key Words", BCP 14, RFC 8174, DOI 10.17487/RFC8174, | draft-ietf-cellar-matroska/>. | |||
May 2017, <https://www.rfc-editor.org/info/rfc8174>. | ||||
[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, | ||||
<https://www.rfc-editor.org/info/rfc6838>. | ||||
11. Informative References | 11. Informative References | |||
[YCbCr] Wikipedia, "YCbCr", undated, | ||||
<https://en.wikipedia.org/w/index.php?title=YCbCr>. | ||||
[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-14, 26 May 2020, | Internet-Draft, draft-ietf-cellar-ffv1-16, 2 July 2020, | |||
<https://tools.ietf.org/html/draft-ietf-cellar-ffv1-14>. | <https://tools.ietf.org/html/draft-ietf-cellar-ffv1-16>. | |||
[HuffYUV] Rudiak-Gould, B., "HuffYUV", December 2003, | ||||
<https://web.archive.org/web/20040402121343/ | ||||
http://cultact-server.novi.dk/kpo/huffyuv/huffyuv.html>. | ||||
[AVI] Microsoft, "AVI RIFF File Reference", undated, | ||||
<https://msdn.microsoft.com/en-us/library/windows/desktop/ | ||||
dd318189%28v=vs.85%29.aspx>. | ||||
[ISO.14496-12.2015] | ||||
International Organization for Standardization, | ||||
"Information technology -- Coding of audio-visual objects | ||||
-- Part 12: ISO base media file format", December 2015. | ||||
[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. | |||
[VALGRIND] Valgrind Developers, "Valgrind website", undated, | [NUT] Niedermayer, M., "NUT Open Container Format", December | |||
<https://valgrind.org/>. | 2013, <https://ffmpeg.org/~michael/nut.txt>. | |||
[range-coding] | [YCbCr] Wikipedia, "YCbCr", undated, | |||
Nigel, G. and N. Martin, "Range encoding: an algorithm for | <https://en.wikipedia.org/w/index.php?title=YCbCr>. | |||
removing redundancy from a digitised message.", July 1979. | ||||
[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 | |||
-- Part 10: Advanced Video Coding", September 2014. | -- Part 10: Advanced Video Coding", September 2014. | |||
[VALGRIND] Valgrind Developers, "Valgrind website", undated, | ||||
<https://valgrind.org/>. | ||||
[REFIMPL] Niedermayer, M., "The reference FFV1 implementation / the | [REFIMPL] Niedermayer, M., "The reference FFV1 implementation / the | |||
FFV1 codec in FFmpeg", undated, <https://ffmpeg.org>. | FFV1 codec in FFmpeg", undated, <https://ffmpeg.org>. | |||
[HuffYUV] Rudiak-Gould, B., "HuffYUV", December 2003, | ||||
<https://web.archive.org/web/20040402121343/ | ||||
http://cultact-server.novi.dk/kpo/huffyuv/huffyuv.html>. | ||||
[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, | ||||
<https://msdn.microsoft.com/en-us/library/windows/desktop/ | ||||
dd318189%28v=vs.85%29.aspx>. | ||||
[Address-Sanitizer] | [Address-Sanitizer] | |||
The Clang Team, "ASAN AddressSanitizer website", undated, | The Clang Team, "ASAN AddressSanitizer website", undated, | |||
<https://clang.llvm.org/docs/AddressSanitizer.html>. | <https://clang.llvm.org/docs/AddressSanitizer.html>. | |||
[NUT] Niedermayer, M., "NUT Open Container Format", December | ||||
2013, <https://ffmpeg.org/~michael/nut.txt>. | ||||
Appendix A. Multi-theaded decoder implementation suggestions | Appendix A. Multi-theaded decoder implementation suggestions | |||
This appendix is informative. | This appendix is informative. | |||
The FFV1 bitstream is parsable in two ways: in sequential order as | 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 | 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 | each slice. Each slice footer contains a "slice_size" field so the | |||
boundary of each slice is computable without having to parse the | boundary of each slice is computable without having to parse the | |||
slice content. That allows multi-threading as well as independence | slice content. That allows multi-threading as well as independence | |||
of slice content (a bitstream error in a slice header or slice | of slice content (a bitstream error in a slice header or slice | |||
End of changes. 40 change blocks. | ||||
183 lines changed or deleted | 194 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/ |