[FFmpeg-devel] [PATCH 1/4] FFV1 specification: Change formatting of pseudo-code

Jerome Martinez jerome at mediaarea.net
Fri May 1 14:25:37 CEST 2015


Le 01/05/2015 13:49, Michael Niedermayer a écrit :
> On Fri, May 01, 2015 at 12:13:22PM +0200, Jerome Martinez wrote:
>
>>   
>>   
>> -if (keyframe) {
>> +if ( keyframe ) {
> [...]
>> -if(version<2)
>> +if( version < 2 )
> that doesnt look consistent to me

Fixed (I missed this one and several other "if (" and "for (", all fixed).



>
> -for(i=0; i<slice_count; i++)
> +for( i = 0; i < slice_count; i++)
> should there be a spae before )

Fixed.

>
> are you sure your patch makes things more and not less consistent ?


I apologized not to have caught all of them.

>
> [...]
>> @@ -8047,7 +8047,7 @@ QuantizationTablePerContext(i, j, scale)
>>   \begin_inset space ~
>>   \end_inset
>>   
>> -scale*=2*len_count[i][j]-1
>> +scale *= 2 * len_count[i][j] - 1
> here you leave [] in other cases you replace [] by () for arrays
> that mix is alot worse than just leaving C syntax

I don't understand: I let "[]" for data. "()" is used for function 
calls, for more coherency. I plan to define LyX Document LumaLine( y ) 
and all other line-related lines (which are function calls, they are not 
data in the bitstream) in future patches, as I did for 
QuantizationTable(). Do you prefer I let "[]" for now?
BTW, I also changed to "[ i ]" formating as found in other specifications.

New patch attached.
-------------- next part --------------
>From b9fc2a09c5875ed81adc4b81ed42475c2c30fdf8 Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?J=C3=A9r=C3=B4me=20Martinez?= <jerome at mediaarea.net>
Date: Fri, 1 May 2015 14:19:44 +0200
Subject: [PATCH 1/4] Change formatting of pseudo-code.

In order to have the same formatting everywhere.
Formatting is the same as in some ISO or ITU specifications.
---
 ffv1.lyx | 149 ++++++++++++++++++++++++++++++++-------------------------------
 1 file changed, 75 insertions(+), 74 deletions(-)

diff --git a/ffv1.lyx b/ffv1.lyx
index d4911cd..c30ad67 100644
--- a/ffv1.lyx
+++ b/ffv1.lyx
@@ -1957,7 +1957,7 @@ Frame
 \begin_inset Text
 
 \begin_layout Plain Layout
-Frame {
+Frame( ) {
 \end_layout
 
 \end_inset
@@ -2027,7 +2027,7 @@ br
 \begin_inset space ~
 \end_inset
 
-if (keyframe) {
+if( keyframe ) {
 \end_layout
 
 \end_inset
@@ -2078,7 +2078,7 @@ if (keyframe) {
 \begin_inset space ~
 \end_inset
 
-if(version<2)
+if( version < 2 )
 \end_layout
 
 \end_inset
@@ -2145,7 +2145,7 @@ if(version<2)
 \begin_inset space ~
 \end_inset
 
-FrameHeader01
+FrameHeader01( )
 \end_layout
 
 \end_inset
@@ -2215,7 +2215,7 @@ FrameHeader01
 \begin_inset space ~
 \end_inset
 
-for(i=0; i<slice_count; i++)
+for( i = 0; i < slice_count; i++ )
 \end_layout
 
 \end_inset
@@ -2266,7 +2266,7 @@ for(i=0; i<slice_count; i++)
 \begin_inset space ~
 \end_inset
 
-Slice(i)
+Slice( i )
 \end_layout
 
 \end_inset
@@ -2323,7 +2323,7 @@ Slice
 \begin_inset Text
 
 \begin_layout Plain Layout
-Slice(i) {
+Slice( i ) {
 \end_layout
 
 \end_inset
@@ -2358,7 +2358,7 @@ type
 \begin_inset space ~
 \end_inset
 
-if(version>2)
+if( version > 2 )
 \end_layout
 
 \end_inset
@@ -2409,7 +2409,7 @@ if(version>2)
 \begin_inset space ~
 \end_inset
 
-SliceHeader(i)
+SliceHeader( i )
 \end_layout
 
 \end_inset
@@ -2444,7 +2444,7 @@ SliceHeader(i)
 \begin_inset space ~
 \end_inset
 
-if (colorspace_type == 1) {
+if( colorspace_type == 1) {
 \end_layout
 
 \end_inset
@@ -2495,15 +2495,15 @@ if (colorspace_type == 1) {
 \begin_inset space ~
 \end_inset
 
-for (y=0;
+for( y = 0;
 \begin_inset space ~
 \end_inset
 
-y<height;
+y < height;
 \begin_inset space ~
 \end_inset
 
-y++) {
+y++ ) {
 \end_layout
 
 \end_inset
@@ -2570,7 +2570,7 @@ y++) {
 \begin_inset space ~
 \end_inset
 
-LumaLine[y]
+LumaLine( y )
 \end_layout
 
 \end_inset
@@ -2637,7 +2637,7 @@ LumaLine[y]
 \begin_inset space ~
 \end_inset
 
-CbLine[y]
+CbLine( y )
 \end_layout
 
 \end_inset
@@ -2704,7 +2704,7 @@ CbLine[y]
 \begin_inset space ~
 \end_inset
 
-CrLine[y]
+CrLine( y )
 \end_layout
 
 \end_inset
@@ -2771,7 +2771,7 @@ CrLine[y]
 \begin_inset space ~
 \end_inset
 
-if (alpha_plane)
+if( alpha_plane )
 \end_layout
 
 \end_inset
@@ -2854,7 +2854,7 @@ if (alpha_plane)
 \begin_inset space ~
 \end_inset
 
-AlphaLine[y]
+AlphaLine( y )
 \end_layout
 
 \end_inset
@@ -2991,7 +2991,7 @@ AlphaLine[y]
 \begin_inset space ~
 \end_inset
 
-LumaPlane
+LumaPlane( )
 \end_layout
 
 \end_inset
@@ -3042,7 +3042,7 @@ LumaPlane
 \begin_inset space ~
 \end_inset
 
-if (chroma_planes) {
+if( chroma_planes ) {
 \end_layout
 
 \end_inset
@@ -3109,7 +3109,7 @@ if (chroma_planes) {
 \begin_inset space ~
 \end_inset
 
-CbPlane
+CbPlane( )
 \end_layout
 
 \end_inset
@@ -3176,7 +3176,7 @@ CbPlane
 \begin_inset space ~
 \end_inset
 
-CrPlane
+CrPlane( )
 \end_layout
 
 \end_inset
@@ -3278,7 +3278,7 @@ CrPlane
 \begin_inset space ~
 \end_inset
 
-if (alpha_plane)
+if( alpha_plane )
 \end_layout
 
 \end_inset
@@ -3345,7 +3345,7 @@ if (alpha_plane)
 \begin_inset space ~
 \end_inset
 
-AlphaPlane
+AlphaPlane( )
 \end_layout
 
 \end_inset
@@ -3415,7 +3415,7 @@ AlphaPlane
 \begin_inset space ~
 \end_inset
 
-if(i || version>2)
+if( i || version > 2 )
 \end_layout
 
 \end_inset
@@ -3501,7 +3501,7 @@ u(24)
 \begin_inset space ~
 \end_inset
 
-if(ec){
+if( ec ) {
 \end_layout
 
 \end_inset
@@ -3981,7 +3981,7 @@ Slice Header
 \begin_inset Text
 
 \begin_layout Plain Layout
-SliceHeader(i) {
+SliceHeader( i ) {
 \end_layout
 
 \end_inset
@@ -4086,7 +4086,7 @@ ur
 \begin_inset space ~
 \end_inset
 
-slice_width-1
+slice_width - 1
 \end_layout
 
 \end_inset
@@ -4121,7 +4121,7 @@ ur
 \begin_inset space ~
 \end_inset
 
-slice_height-1
+slice_height - 1
 \end_layout
 
 \end_inset
@@ -4156,7 +4156,7 @@ ur
 \begin_inset space ~
 \end_inset
 
-for(j=0; j<plane_count; j++)
+for( j = 0; j < plane_count; j++)
 \end_layout
 
 \end_inset
@@ -4207,7 +4207,7 @@ for(j=0; j<plane_count; j++)
 \begin_inset space ~
 \end_inset
 
-quant_table_index[i][j]
+quant_table_index[ i ][ j ]
 \end_layout
 
 \end_inset
@@ -4347,7 +4347,7 @@ ur
 \begin_inset space ~
 \end_inset
 
-if (version > 3)
+if( version > 3 )
 \end_layout
 
 \end_inset
@@ -4827,7 +4827,7 @@ Version 0 and 1
 \begin_inset Text
 
 \begin_layout Plain Layout
-FrameHeader01 {
+FrameHeader01( ) {
 \end_layout
 
 \end_inset
@@ -4932,7 +4932,7 @@ ur
 \begin_inset space ~
 \end_inset
 
-if(coder_type>1)
+if( coder_type > 1 )
 \end_layout
 
 \end_inset
@@ -4983,7 +4983,7 @@ if(coder_type>1)
 \begin_inset space ~
 \end_inset
 
-for(i=1; i<256; i++)
+for( i = 1; i < 256; i++ )
 \end_layout
 
 \end_inset
@@ -5050,7 +5050,7 @@ for(i=1; i<256; i++)
 \begin_inset space ~
 \end_inset
 
-state_transition_delta[i]
+state_transition_delta[ i ]
 \end_layout
 
 \end_inset
@@ -5120,7 +5120,7 @@ ur
 \begin_inset space ~
 \end_inset
 
-if(version>0)
+if( version > 0 )
 \end_layout
 
 \end_inset
@@ -5241,7 +5241,7 @@ br
 \begin_inset space ~
 \end_inset
 
-log2(h_chroma_subsample)
+log2( h_chroma_subsample )
 \end_layout
 
 \end_inset
@@ -5276,7 +5276,7 @@ ur
 \begin_inset space ~
 \end_inset
 
-log2(v_chroma_subsample)
+log2( v_chroma_subsample )
 \end_layout
 
 \end_inset
@@ -5346,7 +5346,7 @@ br
 \begin_inset space ~
 \end_inset
 
-QuantizationTable(0)
+QuantizationTable( 0 )
 \end_layout
 
 \end_inset
@@ -5407,7 +5407,7 @@ Version 2 and later files use a global header and a per frame header.
 \begin_inset Text
 
 \begin_layout Plain Layout
-GlobalHeader {
+GlobalHeader( ) {
 \end_layout
 
 \end_inset
@@ -5547,7 +5547,7 @@ ur
 \begin_inset space ~
 \end_inset
 
-if(coder_type>1)
+if( coder_type > 1 )
 \end_layout
 
 \end_inset
@@ -5598,7 +5598,7 @@ if(coder_type>1)
 \begin_inset space ~
 \end_inset
 
-for(i=1; i<256; i++)
+for( i = 1; i < 256; i++ )
 \end_layout
 
 \end_inset
@@ -5665,7 +5665,7 @@ for(i=1; i<256; i++)
 \begin_inset space ~
 \end_inset
 
-state_transition_delta[i]
+state_transition_delta[ i ]
 \end_layout
 
 \end_inset
@@ -5805,7 +5805,7 @@ br
 \begin_inset space ~
 \end_inset
 
-log2(h_chroma_subsample)
+log2( h_chroma_subsample )
 \end_layout
 
 \end_inset
@@ -5840,7 +5840,7 @@ ur
 \begin_inset space ~
 \end_inset
 
-log2(v_chroma_subsample)
+log2( v_chroma_subsample )
 \end_layout
 
 \end_inset
@@ -5910,7 +5910,7 @@ br
 \begin_inset space ~
 \end_inset
 
-num_h_slices-1
+num_h_slices - 1
 \end_layout
 
 \end_inset
@@ -5945,7 +5945,7 @@ ur
 \begin_inset space ~
 \end_inset
 
-num_v_slices-1
+num_v_slices - 1
 \end_layout
 
 \end_inset
@@ -6015,7 +6015,7 @@ ur
 \begin_inset space ~
 \end_inset
 
-for(i=0; i<quant_table_count; i++)
+for( i = 0; i < quant_table_count; i++ )
 \end_layout
 
 \end_inset
@@ -6066,7 +6066,7 @@ for(i=0; i<quant_table_count; i++)
 \begin_inset space ~
 \end_inset
 
-QuantizationTable(i)
+QuantizationTable( i )
 \end_layout
 
 \end_inset
@@ -6101,7 +6101,7 @@ QuantizationTable(i)
 \begin_inset space ~
 \end_inset
 
-for(i=0; i<quant_table_count; i++) {
+for( i = 0; i < quant_table_count; i++ ) {
 \end_layout
 
 \end_inset
@@ -6203,7 +6203,7 @@ br
 \begin_inset space ~
 \end_inset
 
-if(states_coded)
+if( states_coded )
 \end_layout
 
 \end_inset
@@ -6270,7 +6270,7 @@ if(states_coded)
 \begin_inset space ~
 \end_inset
 
-for(j=0; j<context_count[i];j++)
+for( j = 0; j < context_count[ i ]; j++ )
 \end_layout
 
 \end_inset
@@ -6353,7 +6353,7 @@ for(j=0; j<context_count[i];j++)
 \begin_inset space ~
 \end_inset
 
-for(k=0; k<CONTEXT_SIZE;k++)
+for( k = 0; k < CONTEXT_SIZE; k++ )
 \end_layout
 
 \end_inset
@@ -6452,7 +6452,7 @@ for(k=0; k<CONTEXT_SIZE;k++)
 \begin_inset space ~
 \end_inset
 
-initial_state_delta[i][j][k]
+initial_state_delta[ i ][ j ][ k ]
 \end_layout
 
 \end_inset
@@ -7607,16 +7607,17 @@ initial states are present
 \end_layout
 
 \begin_layout Description
-initial_state_delta[i][j][k] indicates the initial range coder state, it
- is encoded using k as context index and
+initial_state_delta[ i ][ j ][ k ] indicates the initial range coder state,
+ it is encoded using k as context index and
 \begin_inset Newline newline
 \end_inset
 
-pred= j ? initial_states[i][j-1][k] : 128
+pred = j ? initial_states[ i ][j - 1][ k ] : 128
 \begin_inset Newline newline
 \end_inset
 
-initial_state[i][j][k]= (pred+initial_state_delta[i][j][k])&255
+initial_state[ i ][ j ][ k ] = ( pred + initial_state_delta[ i ][ j ][ k
+ ] ) & 255
 \end_layout
 
 \begin_layout Description
@@ -7875,7 +7876,7 @@ Stored values: 1, 3, 1
 \begin_inset Text
 
 \begin_layout Plain Layout
-QuantizationTable(i) {
+QuantizationTable( i ) {
 \end_layout
 
 \end_inset
@@ -7910,7 +7911,7 @@ type
 \begin_inset space ~
 \end_inset
 
-scale=1
+scale = 1
 \end_layout
 
 \end_inset
@@ -7945,7 +7946,7 @@ scale=1
 \begin_inset space ~
 \end_inset
 
-for(j=0; j<MAX_CONTEXT_INPUTS; j++) {
+for( j = 0; j < MAX_CONTEXT_INPUTS; j++ ) {
 \end_layout
 
 \end_inset
@@ -7996,7 +7997,7 @@ for(j=0; j<MAX_CONTEXT_INPUTS; j++) {
 \begin_inset space ~
 \end_inset
 
-QuantizationTablePerContext(i, j, scale)
+QuantizationTablePerContext( i, j, scale )
 \end_layout
 
 \end_inset
@@ -8047,7 +8048,7 @@ QuantizationTablePerContext(i, j, scale)
 \begin_inset space ~
 \end_inset
 
-scale*=2*len_count[i][j]-1
+scale *= 2 * len_count[ i ][ j ] - 1
 \end_layout
 
 \end_inset
@@ -8117,7 +8118,7 @@ scale*=2*len_count[i][j]-1
 \begin_inset space ~
 \end_inset
 
-context_count[i]=(scale+1)/2
+context_count[ i ] = ( scale + 1 ) / 2
 \end_layout
 
 \end_inset
@@ -8209,7 +8210,7 @@ type
 \begin_inset space ~
 \end_inset
 
-v=0
+v = 0
 \end_layout
 
 \end_inset
@@ -8244,7 +8245,7 @@ v=0
 \begin_inset space ~
 \end_inset
 
-for(k= 0; k<128;) {
+for( k = 0; k < 128; ) {
 \end_layout
 
 \end_inset
@@ -8295,7 +8296,7 @@ for(k= 0; k<128;) {
 \begin_inset space ~
 \end_inset
 
-len-1
+len - 1
 \end_layout
 
 \end_inset
@@ -8346,7 +8347,7 @@ sr
 \begin_inset space ~
 \end_inset
 
-for(a=0; a<len; a++) {
+for( a = 0; a < len; a++ ) {
 \end_layout
 
 \end_inset
@@ -8413,7 +8414,7 @@ for(a=0; a<len; a++) {
 \begin_inset space ~
 \end_inset
 
-quant_tables[i][j][k]=scale*v
+quant_tables[ i ][ j ][ k ] = scale * v
 \end_layout
 
 \end_inset
@@ -8652,7 +8653,7 @@ v++
 \begin_inset space ~
 \end_inset
 
-for (k=1; k<128; k++) {
+for( k = 1; k < 128; k++ ) {
 \end_layout
 
 \end_inset
@@ -8703,7 +8704,7 @@ for (k=1; k<128; k++) {
 \begin_inset space ~
 \end_inset
 
-quant_tables[i][j][256-k]=-quant_tables[i][j][k]
+quant_tables[ i ][ j ][ 256 - k ] = -quant_tables[ i ][ j ][ k ]
 \end_layout
 
 \end_inset
@@ -8773,7 +8774,7 @@ quant_tables[i][j][256-k]=-quant_tables[i][j][k]
 \begin_inset space ~
 \end_inset
 
-quant_tables[i][j][128]=-quant_tables[i][j][127]
+quant_tables[ i ][ j ][ 128 ] = -quant_tables[ i ][ j ][ 127 ]
 \end_layout
 
 \end_inset
@@ -8808,7 +8809,7 @@ quant_tables[i][j][128]=-quant_tables[i][j][127]
 \begin_inset space ~
 \end_inset
 
-len_count[i][j]=v
+len_count[ i ][ j ] = v
 \end_layout
 
 \end_inset
-- 
1.9.5.msysgit.1



More information about the ffmpeg-devel mailing list