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

	//
	// Downscaled Numeric Array (NUM_DWS)
	//
	// ...  ....       .   +   Data Length
	// 000 [DWS_TYPE] [LN]    [16bit/32bit]
	//

	// Get downscale type
	var n_dws_type = downscaleType( n_from, n_to );
	// console.log(">>>",data.constructor,":",_NUMTYPE[n_from],"->",_NUMTYPE[n_to],":",n_dws_type);

	encoder.counters.arr_dws+=1;
	encoder.log(LOG.ARR, "array.numeric.downscaled, len="+data.length+
		", from="+_NUMTYPE[n_from]+", to="+_NUMTYPE[n_to]+
		", type="+_NUMTYPE_DOWNSCALE_DWS[n_dws_type]+" ("+n_dws_type+")");

	if (data.length < UINT16_MAX) { // 16-bit length prefix
		encoder.stream8.write( pack1b( ARR_OP.NUM_DWS | NUMTYPE_LN.UINT16 | (n_dws_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_DWS | NUMTYPE_LN.UINT32 | (n_dws_type << 1) ) );
		encoder.stream32.write( pack4b( data.length, false ) );
		encoder.counters.arr_hdr+=5;
	}

	// Encode value
	pickStream( encoder, n_to )
		.write( packTypedArray( convertArray( data, n_to ) ) );

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

	//
	// Downscaled Numeric Array (NUM_DWS)
	//
	// ...  ....       .   +   Data Length
	// 000 [DWS_TYPE] [LN]    [16bit/32bit]
	//

	// Get downscale type
	var n_dws_type = downscaleType( n_from, n_to );
	// console.log(">>>",data.constructor,":",_NUMTYPE[n_from],"->",_NUMTYPE[n_to],":",n_dws_type);

	encoder.counters.arr_dws+=1;
	encoder.log(LOG.ARR, "array.numeric.downscaled, len="+data.length+
		", from="+_NUMTYPE[n_from]+", to="+_NUMTYPE[n_to]+
		", type="+_NUMTYPE_DOWNSCALE_DWS[n_dws_type]+" ("+n_dws_type+")");

	if (data.length < UINT16_MAX) { // 16-bit length prefix
		encoder.stream8.write( pack1b( ARR_OP.NUM_DWS | NUMTYPE_LN.UINT16 | (n_dws_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_DWS | NUMTYPE_LN.UINT32 | (n_dws_type << 1) ) );
		encoder.stream32.write( pack4b( data.length, false ) );
		encoder.counters.arr_hdr+=5;
	}

	// Encode value
	pickStream( encoder, n_to )
		.write( packTypedArray( convertArray( data, n_to ) ) );

}
function encodeArray_NUM_DWS ( encoder , data , n_from , n_to ) { // // Downscaled Numeric Array (NUM_DWS) // // ...  ....       .   +   Data Length // 000 [DWS_TYPE] [LN]    [16bit/32bit] // // Get downscale type var n_dws_type = downscaleType ( n_from , n_to ) ; // console.log(">>>",data.constructor,":",_NUMTYPE[n_from],"->",_NUMTYPE[n_to],":",n_dws_type); encoder . counters . arr_dws += 1 ; encoder . log ( LOG . ARR , "array.numeric.downscaled, len=" + data . length + ", from=" + _NUMTYPE [ n_from ] + ", to=" + _NUMTYPE [ n_to ] + ", type=" + _NUMTYPE_DOWNSCALE_DWS [ n_dws_type ] + " (" + n_dws_type + ")" ) ; if ( data . length < UINT16_MAX ) { // 16-bit length prefix encoder . stream8 . write ( pack1b ( ARR_OP . NUM_DWS | NUMTYPE_LN . UINT16 | ( n_dws_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_DWS | NUMTYPE_LN . UINT32 | ( n_dws_type << 1 ) ) ) ; encoder . stream32 . write ( pack4b ( data . length , false ) ) ; encoder . counters . arr_hdr += 5 ; } // Encode value pickStream ( encoder , n_to ) . write ( packTypedArray ( convertArray ( data , n_to ) ) ) ; }
Encode array data as downscaled
Encode array data as downscaled