[FFmpeg-devel] [PATCH] FFV1 specification: Merge of FrameHeader01() and GlobalHeader()

Jerome Martinez jerome at mediaarea.net
Mon May 18 21:04:01 CEST 2015


-------------- next part --------------
From c6f16e561d40972e058f4e163ff753bce8fc8acc Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?J=C3=A9r=C3=B4me=20Martinez?= <jerome at mediaarea.net>
Date: Mon, 18 May 2015 20:59:09 +0200
Subject: [PATCH] Merge of FrameHeader01() and GlobalHeader()

FrameHeader01() and GlobalHeader() have a lot of common fields
and having a common function + default value for fields unused
in previous versions is less complex and more coherent than repeating
the common part.
---
 ffv1.lyx | 530 ++++++++++++++++++++++++---------------------------------------
 1 file changed, 204 insertions(+), 326 deletions(-)

diff --git a/ffv1.lyx b/ffv1.lyx
index 01f7308..e38389a 100644
--- a/ffv1.lyx
+++ b/ffv1.lyx
@@ -2557,6 +2557,10 @@ In the case of a bitstream with version >= 2, a configuration record is
 \begin_inset Newline newline
 \end_inset
 
+It contains the frame header used for all frames.
+\begin_inset Newline newline
+\end_inset
+
 The size of the configuration record, NumBytes, is supplied by the underlying
  container.
 \end_layout
@@ -2642,7 +2646,7 @@ ConfigurationRecordIsPresent = 1
 \begin_inset space ~
 \end_inset
 
-GlobalHeader( )
+FrameHeader( )
 \end_layout
 
 \end_inset
@@ -3172,7 +3176,7 @@ if( keyframe && !ConfigurationRecordIsPresent)
 \begin_inset space ~
 \end_inset
 
-FrameHeader01( )
+FrameHeader( )
 \end_layout
 
 \end_inset
@@ -5155,16 +5159,12 @@ reserved for future use
 \end_layout
 
 \begin_layout Subsection
-Header
-\end_layout
-
-\begin_layout Subsubsection
-Version 0 and 1
+Frame Header
 \end_layout
 
 \begin_layout Standard
 \begin_inset Tabular
-<lyxtabular version="3" rows="15" columns="2">
+<lyxtabular version="3" rows="34" columns="2">
 <features rotate="0" tabularvalignment="middle">
 <column alignment="left" valignment="top">
 <column alignment="center" valignment="top">
@@ -5173,7 +5173,7 @@ Version 0 and 1
 \begin_inset Text
 
 \begin_layout Plain Layout
-FrameHeader01( ) {
+FrameHeader( ) {
 \end_layout
 
 \end_inset
@@ -5224,6 +5224,92 @@ ur
 </cell>
 </row>
 <row>
+<cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
+\begin_inset Text
+
+\begin_layout Plain Layout
+\begin_inset space ~
+\end_inset
+
+
+\begin_inset space ~
+\end_inset
+
+
+\begin_inset space ~
+\end_inset
+
+
+\begin_inset space ~
+\end_inset
+
+if( version > 2 )
+\end_layout
+
+\end_inset
+</cell>
+<cell alignment="center" valignment="top" topline="true" leftline="true" rightline="true" usebox="none">
+\begin_inset Text
+
+\begin_layout Plain Layout
+
+\end_layout
+
+\end_inset
+</cell>
+</row>
+<row>
+<cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
+\begin_inset Text
+
+\begin_layout Plain Layout
+\begin_inset space ~
+\end_inset
+
+
+\begin_inset space ~
+\end_inset
+
+
+\begin_inset space ~
+\end_inset
+
+
+\begin_inset space ~
+\end_inset
+
+
+\begin_inset space ~
+\end_inset
+
+
+\begin_inset space ~
+\end_inset
+
+
+\begin_inset space ~
+\end_inset
+
+
+\begin_inset space ~
+\end_inset
+
+micro_version
+\end_layout
+
+\end_inset
+</cell>
+<cell alignment="center" valignment="top" topline="true" leftline="true" rightline="true" usebox="none">
+\begin_inset Text
+
+\begin_layout Plain Layout
+ur
+\end_layout
+
+\end_inset
+</cell>
+</row>
+<row>
 <cell alignment="left" valignment="top" topline="true" leftline="true" usebox="none">
 \begin_inset Text
 
@@ -5482,7 +5568,7 @@ if( version > 0 )
 </cell>
 </row>
 <row>
-<cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
+<cell alignment="left" valignment="top" topline="true" leftline="true" usebox="none">
 \begin_inset Text
 
 \begin_layout Plain Layout
@@ -5692,7 +5778,7 @@ br
 \begin_inset space ~
 \end_inset
 
-QuantizationTable( 0 )
+if ( version > 1 ) {
 \end_layout
 
 \end_inset
@@ -5708,52 +5794,42 @@ QuantizationTable( 0 )
 </cell>
 </row>
 <row>
-<cell alignment="center" valignment="top" topline="true" bottomline="true" leftline="true" usebox="none">
+<cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
 \begin_inset Text
 
 \begin_layout Plain Layout
-}
-\end_layout
+\begin_inset space ~
+\end_inset
+
 
+\begin_inset space ~
 \end_inset
-</cell>
-<cell alignment="center" valignment="top" topline="true" bottomline="true" leftline="true" rightline="true" usebox="none">
-\begin_inset Text
 
-\begin_layout Plain Layout
 
-\end_layout
+\begin_inset space ~
+\end_inset
 
+
+\begin_inset space ~
 \end_inset
-</cell>
-</row>
-</lyxtabular>
 
+
+\begin_inset space ~
 \end_inset
 
 
-\end_layout
+\begin_inset space ~
+\end_inset
 
-\begin_layout Subsubsection
-Version 3
-\end_layout
 
-\begin_layout Standard
-Version 2 and later files use a global header and a per frame header.
-\end_layout
+\begin_inset space ~
+\end_inset
 
-\begin_layout Standard
-\begin_inset Tabular
-<lyxtabular version="3" rows="28" columns="2">
-<features rotate="0" tabularvalignment="middle">
-<column alignment="left" valignment="top">
-<column alignment="center" valignment="top">
-<row>
-<cell alignment="left" valignment="top" topline="true" leftline="true" usebox="none">
-\begin_inset Text
 
-\begin_layout Plain Layout
-GlobalHeader( ) {
+\begin_inset space ~
+\end_inset
+
+num_h_slices - 1
 \end_layout
 
 \end_inset
@@ -5762,7 +5838,7 @@ GlobalHeader( ) {
 \begin_inset Text
 
 \begin_layout Plain Layout
-type
+ur
 \end_layout
 
 \end_inset
@@ -5788,7 +5864,23 @@ type
 \begin_inset space ~
 \end_inset
 
-version
+
+\begin_inset space ~
+\end_inset
+
+
+\begin_inset space ~
+\end_inset
+
+
+\begin_inset space ~
+\end_inset
+
+
+\begin_inset space ~
+\end_inset
+
+num_v_slices - 1
 \end_layout
 
 \end_inset
@@ -5823,26 +5915,7 @@ ur
 \begin_inset space ~
 \end_inset
 
-micro_version
-\end_layout
-
-\end_inset
-</cell>
-<cell alignment="center" valignment="top" topline="true" leftline="true" rightline="true" usebox="none">
-\begin_inset Text
-
-\begin_layout Plain Layout
-ur
-\end_layout
-
-\end_inset
-</cell>
-</row>
-<row>
-<cell alignment="left" valignment="top" topline="true" leftline="true" usebox="none">
-\begin_inset Text
 
-\begin_layout Plain Layout
 \begin_inset space ~
 \end_inset
 
@@ -5858,7 +5931,7 @@ ur
 \begin_inset space ~
 \end_inset
 
-coder_type
+quant_table_count
 \end_layout
 
 \end_inset
@@ -5893,7 +5966,7 @@ ur
 \begin_inset space ~
 \end_inset
 
-if( coder_type > 1 )
+}
 \end_layout
 
 \end_inset
@@ -5928,23 +6001,7 @@ if( coder_type > 1 )
 \begin_inset space ~
 \end_inset
 
-
-\begin_inset space ~
-\end_inset
-
-
-\begin_inset space ~
-\end_inset
-
-
-\begin_inset space ~
-\end_inset
-
-
-\begin_inset space ~
-\end_inset
-
-for( i = 1; i < 256; i++ )
+for( i = 0; i < quant_table_count; i++ )
 \end_layout
 
 \end_inset
@@ -5995,23 +6052,7 @@ for( i = 1; i < 256; i++ )
 \begin_inset space ~
 \end_inset
 
-
-\begin_inset space ~
-\end_inset
-
-
-\begin_inset space ~
-\end_inset
-
-
-\begin_inset space ~
-\end_inset
-
-
-\begin_inset space ~
-\end_inset
-
-state_transition_delta[ i ]
+QuantizationTable( i )
 \end_layout
 
 \end_inset
@@ -6020,14 +6061,14 @@ state_transition_delta[ i ]
 \begin_inset Text
 
 \begin_layout Plain Layout
-sr
+
 \end_layout
 
 \end_inset
 </cell>
 </row>
 <row>
-<cell alignment="left" valignment="top" topline="true" leftline="true" usebox="none">
+<cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
 \begin_inset Text
 
 \begin_layout Plain Layout
@@ -6046,7 +6087,7 @@ sr
 \begin_inset space ~
 \end_inset
 
-colorspace_type
+if ( version > 1 ) {
 \end_layout
 
 \end_inset
@@ -6055,14 +6096,14 @@ colorspace_type
 \begin_inset Text
 
 \begin_layout Plain Layout
-ur
+
 \end_layout
 
 \end_inset
 </cell>
 </row>
 <row>
-<cell alignment="left" valignment="top" topline="true" leftline="true" usebox="none">
+<cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
 \begin_inset Text
 
 \begin_layout Plain Layout
@@ -6081,26 +6122,7 @@ ur
 \begin_inset space ~
 \end_inset
 
-bits_per_raw_sample
-\end_layout
-
-\end_inset
-</cell>
-<cell alignment="center" valignment="top" topline="true" leftline="true" rightline="true" usebox="none">
-\begin_inset Text
-
-\begin_layout Plain Layout
-ur
-\end_layout
-
-\end_inset
-</cell>
-</row>
-<row>
-<cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
-\begin_inset Text
 
-\begin_layout Plain Layout
 \begin_inset space ~
 \end_inset
 
@@ -6116,7 +6138,7 @@ ur
 \begin_inset space ~
 \end_inset
 
-chroma_planes
+for( i = 0; i < quant_table_count; i++ ) {
 \end_layout
 
 \end_inset
@@ -6125,7 +6147,7 @@ chroma_planes
 \begin_inset Text
 
 \begin_layout Plain Layout
-br
+
 \end_layout
 
 \end_inset
@@ -6151,26 +6173,7 @@ br
 \begin_inset space ~
 \end_inset
 
-log2( h_chroma_subsample )
-\end_layout
-
-\end_inset
-</cell>
-<cell alignment="center" valignment="top" topline="true" leftline="true" rightline="true" usebox="none">
-\begin_inset Text
-
-\begin_layout Plain Layout
-ur
-\end_layout
-
-\end_inset
-</cell>
-</row>
-<row>
-<cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
-\begin_inset Text
 
-\begin_layout Plain Layout
 \begin_inset space ~
 \end_inset
 
@@ -6186,26 +6189,7 @@ ur
 \begin_inset space ~
 \end_inset
 
-log2( v_chroma_subsample )
-\end_layout
-
-\end_inset
-</cell>
-<cell alignment="center" valignment="top" topline="true" leftline="true" rightline="true" usebox="none">
-\begin_inset Text
-
-\begin_layout Plain Layout
-ur
-\end_layout
-
-\end_inset
-</cell>
-</row>
-<row>
-<cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
-\begin_inset Text
 
-\begin_layout Plain Layout
 \begin_inset space ~
 \end_inset
 
@@ -6221,7 +6205,7 @@ ur
 \begin_inset space ~
 \end_inset
 
-alpha_plane
+states_coded
 \end_layout
 
 \end_inset
@@ -6256,26 +6240,7 @@ br
 \begin_inset space ~
 \end_inset
 
-num_h_slices - 1
-\end_layout
-
-\end_inset
-</cell>
-<cell alignment="center" valignment="top" topline="true" leftline="true" rightline="true" usebox="none">
-\begin_inset Text
-
-\begin_layout Plain Layout
-ur
-\end_layout
-
-\end_inset
-</cell>
-</row>
-<row>
-<cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
-\begin_inset Text
 
-\begin_layout Plain Layout
 \begin_inset space ~
 \end_inset
 
@@ -6291,26 +6256,7 @@ ur
 \begin_inset space ~
 \end_inset
 
-num_v_slices - 1
-\end_layout
-
-\end_inset
-</cell>
-<cell alignment="center" valignment="top" topline="true" leftline="true" rightline="true" usebox="none">
-\begin_inset Text
-
-\begin_layout Plain Layout
-ur
-\end_layout
-
-\end_inset
-</cell>
-</row>
-<row>
-<cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
-\begin_inset Text
 
-\begin_layout Plain Layout
 \begin_inset space ~
 \end_inset
 
@@ -6326,7 +6272,7 @@ ur
 \begin_inset space ~
 \end_inset
 
-quant_table_count
+if( states_coded )
 \end_layout
 
 \end_inset
@@ -6335,7 +6281,7 @@ quant_table_count
 \begin_inset Text
 
 \begin_layout Plain Layout
-ur
+
 \end_layout
 
 \end_inset
@@ -6361,26 +6307,19 @@ ur
 \begin_inset space ~
 \end_inset
 
-for( i = 0; i < quant_table_count; i++ )
-\end_layout
 
+\begin_inset space ~
 \end_inset
-</cell>
-<cell alignment="center" valignment="top" topline="true" leftline="true" rightline="true" usebox="none">
-\begin_inset Text
 
-\begin_layout Plain Layout
 
-\end_layout
+\begin_inset space ~
+\end_inset
 
+
+\begin_inset space ~
 \end_inset
-</cell>
-</row>
-<row>
-<cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
-\begin_inset Text
 
-\begin_layout Plain Layout
+
 \begin_inset space ~
 \end_inset
 
@@ -6412,7 +6351,11 @@ for( i = 0; i < quant_table_count; i++ )
 \begin_inset space ~
 \end_inset
 
-QuantizationTable( i )
+
+\begin_inset space ~
+\end_inset
+
+for( j = 0; j < context_count[ i ]; j++ )
 \end_layout
 
 \end_inset
@@ -6447,26 +6390,7 @@ QuantizationTable( i )
 \begin_inset space ~
 \end_inset
 
-for( i = 0; i < quant_table_count; i++ ) {
-\end_layout
-
-\end_inset
-</cell>
-<cell alignment="center" valignment="top" topline="true" leftline="true" rightline="true" usebox="none">
-\begin_inset Text
-
-\begin_layout Plain Layout
-
-\end_layout
-
-\end_inset
-</cell>
-</row>
-<row>
-<cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
-\begin_inset Text
 
-\begin_layout Plain Layout
 \begin_inset space ~
 \end_inset
 
@@ -6498,26 +6422,7 @@ for( i = 0; i < quant_table_count; i++ ) {
 \begin_inset space ~
 \end_inset
 
-states_coded
-\end_layout
-
-\end_inset
-</cell>
-<cell alignment="center" valignment="top" topline="true" leftline="true" rightline="true" usebox="none">
-\begin_inset Text
-
-\begin_layout Plain Layout
-br
-\end_layout
-
-\end_inset
-</cell>
-</row>
-<row>
-<cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
-\begin_inset Text
 
-\begin_layout Plain Layout
 \begin_inset space ~
 \end_inset
 
@@ -6549,7 +6454,7 @@ br
 \begin_inset space ~
 \end_inset
 
-if( states_coded )
+for( k = 0; k < CONTEXT_SIZE; k++ )
 \end_layout
 
 \end_inset
@@ -6616,41 +6521,6 @@ if( states_coded )
 \begin_inset space ~
 \end_inset
 
-for( j = 0; j < context_count[ i ]; j++ )
-\end_layout
-
-\end_inset
-</cell>
-<cell alignment="center" valignment="top" topline="true" leftline="true" rightline="true" usebox="none">
-\begin_inset Text
-
-\begin_layout Plain Layout
-
-\end_layout
-
-\end_inset
-</cell>
-</row>
-<row>
-<cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
-\begin_inset Text
-
-\begin_layout Plain Layout
-\begin_inset space ~
-\end_inset
-
-
-\begin_inset space ~
-\end_inset
-
-
-\begin_inset space ~
-\end_inset
-
-
-\begin_inset space ~
-\end_inset
-
 
 \begin_inset space ~
 \end_inset
@@ -6699,7 +6569,7 @@ for( j = 0; j < context_count[ i ]; j++ )
 \begin_inset space ~
 \end_inset
 
-for( k = 0; k < CONTEXT_SIZE; k++ )
+initial_state_delta[ i ][ j ][ k ]
 \end_layout
 
 \end_inset
@@ -6708,7 +6578,7 @@ for( k = 0; k < CONTEXT_SIZE; k++ )
 \begin_inset Text
 
 \begin_layout Plain Layout
-
+sr
 \end_layout
 
 \end_inset
@@ -6750,23 +6620,26 @@ for( k = 0; k < CONTEXT_SIZE; k++ )
 \begin_inset space ~
 \end_inset
 
+}
+\end_layout
 
-\begin_inset space ~
-\end_inset
-
-
-\begin_inset space ~
 \end_inset
+</cell>
+<cell alignment="center" valignment="top" topline="true" leftline="true" rightline="true" usebox="none">
+\begin_inset Text
 
+\begin_layout Plain Layout
 
-\begin_inset space ~
-\end_inset
-
+\end_layout
 
-\begin_inset space ~
 \end_inset
+</cell>
+</row>
+<row>
+<cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
+\begin_inset Text
 
-
+\begin_layout Plain Layout
 \begin_inset space ~
 \end_inset
 
@@ -6798,7 +6671,7 @@ for( k = 0; k < CONTEXT_SIZE; k++ )
 \begin_inset space ~
 \end_inset
 
-initial_state_delta[ i ][ j ][ k ]
+ec
 \end_layout
 
 \end_inset
@@ -6807,7 +6680,7 @@ initial_state_delta[ i ][ j ][ k ]
 \begin_inset Text
 
 \begin_layout Plain Layout
-sr
+ur
 \end_layout
 
 \end_inset
@@ -6833,26 +6706,7 @@ sr
 \begin_inset space ~
 \end_inset
 
-}
-\end_layout
-
-\end_inset
-</cell>
-<cell alignment="center" valignment="top" topline="true" leftline="true" rightline="true" usebox="none">
-\begin_inset Text
-
-\begin_layout Plain Layout
-
-\end_layout
-
-\end_inset
-</cell>
-</row>
-<row>
-<cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
-\begin_inset Text
 
-\begin_layout Plain Layout
 \begin_inset space ~
 \end_inset
 
@@ -6868,7 +6722,7 @@ sr
 \begin_inset space ~
 \end_inset
 
-ec
+intra
 \end_layout
 
 \end_inset
@@ -6903,7 +6757,7 @@ ur
 \begin_inset space ~
 \end_inset
 
-intra
+}
 \end_layout
 
 \end_inset
@@ -6912,7 +6766,7 @@ intra
 \begin_inset Text
 
 \begin_layout Plain Layout
-ur
+
 \end_layout
 
 \end_inset
@@ -7838,14 +7692,26 @@ transparency plane is present
 
 \begin_layout Description
 num_h_slices indicates the number of horizontal elements of the slice raster.
+\begin_inset Newline newline
+\end_inset
+
+Inferred to be 1 if not present.
 \end_layout
 
 \begin_layout Description
 num_v_slices indicates the number of vertical elements of the slice raster.
+\begin_inset Newline newline
+\end_inset
+
+Inferred to be 1 if not present.
 \end_layout
 
 \begin_layout Description
 quant_table_count indicates the number of quantization table sets.
+\begin_inset Newline newline
+\end_inset
+
+Inferred to be 1 if not present.
 \end_layout
 
 \begin_layout Description
@@ -7854,6 +7720,10 @@ states_coded indicates if the respective quantization table set has the
 \begin_inset Newline newline
 \end_inset
 
+Inferred to be 0 if not present.
+\begin_inset Newline newline
+\end_inset
+
 
 \begin_inset Tabular
 <lyxtabular version="3" rows="3" columns="2">
@@ -7939,6 +7809,10 @@ pred = j ? initial_states[ i ][j - 1][ k ] : 128
 
 initial_state[ i ][ j ][ k ] = ( pred + initial_state_delta[ i ][ j ][ k
  ] ) & 255
+\begin_inset Newline newline
+\end_inset
+
+Inferred to be 0 if not present.
 \end_layout
 
 \begin_layout Description
@@ -8049,6 +7923,10 @@ intra indicates the relationship between frames.
 \begin_inset Newline newline
 \end_inset
 
+Inferred to be 0 if not present.
+\begin_inset Newline newline
+\end_inset
+
 
 \begin_inset Tabular
 <lyxtabular version="3" rows="4" columns="2">
-- 
1.9.5.msysgit.1


More information about the ffmpeg-devel mailing list