encoder.js
function encodeArray_NUM_DELTA_INT( encoder, data, n_from, n_to ) {

	//
	// Delta Numeric Array (NUM_DELTA_INT)
	//
	// ...  ....       .   +   Data Length   +   Initial Value
	// 001 [DWS_TYPE] [LN]    [16bit/32bit]    [8bit/16bit/32bit]
	//

	// Get downscale type
	var n_delta_type = deltaEncTypeInt( n_from, n_to );
	if (n_delta_type === undefined) {
		throw new Errors.EncodeError('Non-viable integer delta value from '+_NUMTYPE[n_from]+' to '+_NUMTYPE[n_to]+'!');
	}

	encoder.counters.arr_delta_int+=1;
	encoder.log(LOG.ARR, "array.numeric.delta.int, len="+data.length+
		", from="+_NUMTYPE[n_from]+", to="+_NUMTYPE[n_to]+
		", type="+_NUMTYPE_DOWNSCALE_DELTA_INT[n_delta_type]+" ("+n_delta_type+")");


	if (data.length < UINT16_MAX) { // 16-bit length prefix
		encoder.stream8.write( pack1b( ARR_OP.NUM_DELTA_INT | NUMTYPE_LN.UINT16 | (n_delta_type << 1) ) );
		encoder.stream16.write( pack2b( data.length, false ) );
		encoder.counters.arr_hdr+=3;
	} else { // 32-bit length prefix
		encoder.stream8.write( pack1b( ARR_OP.NUM_DELTA_INT | NUMTYPE_LN.UINT32 | (n_delta_type << 1) ) );
		encoder.stream32.write( pack4b( data.length, false ) );
		encoder.counters.arr_hdr+=5;
	}

	// Write initial value
	pickStream( encoder, n_from )
		.write( packByNumType[n_from]( data[0] ) );

	// Delta-encode integers
	pickStream( encoder, n_to)
		.write( packTypedArray( deltaEncodeIntegers( data, n_to ) ) );

}
function encodeArray_NUM_DELTA_INT( encoder, data, n_from, n_to ) {

	//
	// Delta Numeric Array (NUM_DELTA_INT)
	//
	// ...  ....       .   +   Data Length   +   Initial Value
	// 001 [DWS_TYPE] [LN]    [16bit/32bit]    [8bit/16bit/32bit]
	//

	// Get downscale type
	var n_delta_type = deltaEncTypeInt( n_from, n_to );
	if (n_delta_type === undefined) {
		throw new Errors.EncodeError('Non-viable integer delta value from '+_NUMTYPE[n_from]+' to '+_NUMTYPE[n_to]+'!');
	}

	encoder.counters.arr_delta_int+=1;
	encoder.log(LOG.ARR, "array.numeric.delta.int, len="+data.length+
		", from="+_NUMTYPE[n_from]+", to="+_NUMTYPE[n_to]+
		", type="+_NUMTYPE_DOWNSCALE_DELTA_INT[n_delta_type]+" ("+n_delta_type+")");


	if (data.length < UINT16_MAX) { // 16-bit length prefix
		encoder.stream8.write( pack1b( ARR_OP.NUM_DELTA_INT | NUMTYPE_LN.UINT16 | (n_delta_type << 1) ) );
		encoder.stream16.write( pack2b( data.length, false ) );
		encoder.counters.arr_hdr+=3;
	} else { // 32-bit length prefix
		encoder.stream8.write( pack1b( ARR_OP.NUM_DELTA_INT | NUMTYPE_LN.UINT32 | (n_delta_type << 1) ) );
		encoder.stream32.write( pack4b( data.length, false ) );
		encoder.counters.arr_hdr+=5;
	}

	// Write initial value
	pickStream( encoder, n_from )
		.write( packByNumType[n_from]( data[0] ) );

	// Delta-encode integers
	pickStream( encoder, n_to)
		.write( packTypedArray( deltaEncodeIntegers( data, n_to ) ) );

}
function encodeArray_NUM_DELTA_INT ( encoder , data , n_from , n_to ) { // // Delta Numeric Array (NUM_DELTA_INT) // // ...  ....       .   +   Data Length   +   Initial Value // 001 [DWS_TYPE] [LN]    [16bit/32bit]    [8bit/16bit/32bit] // // Get downscale type var n_delta_type = deltaEncTypeInt ( n_from , n_to ) ; if ( n_delta_type === undefined ) { throw new Errors . EncodeError ( 'Non-viable integer delta value from ' + _NUMTYPE [ n_from ] + ' to ' + _NUMTYPE [ n_to ] + '!' ) ; } encoder . counters . arr_delta_int += 1 ; encoder . log ( LOG . ARR , "array.numeric.delta.int, len=" + data . length + ", from=" + _NUMTYPE [ n_from ] + ", to=" + _NUMTYPE [ n_to ] + ", type=" + _NUMTYPE_DOWNSCALE_DELTA_INT [ n_delta_type ] + " (" + n_delta_type + ")" ) ; if ( data . length < UINT16_MAX ) { // 16-bit length prefix encoder . stream8 . write ( pack1b ( ARR_OP . NUM_DELTA_INT | NUMTYPE_LN . UINT16 | ( n_delta_type << 1 ) ) ) ; encoder . stream16 . write ( pack2b ( data . length , false ) ) ; encoder . counters . arr_hdr += 3 ; } else { // 32-bit length prefix encoder . stream8 . write ( pack1b ( ARR_OP . NUM_DELTA_INT | NUMTYPE_LN . UINT32 | ( n_delta_type << 1 ) ) ) ; encoder . stream32 . write ( pack4b ( data . length , false ) ) ; encoder . counters . arr_hdr += 5 ; } // Write initial value pickStream ( encoder , n_from ) . write ( packByNumType [ n_from ] ( data [ 0 ] ) ) ; // Delta-encode integers pickStream ( encoder , n_to ) . write ( packTypedArray ( deltaEncodeIntegers ( data , n_to ) ) ) ; }
Encode array data as delta
Encode array data as delta