for( unsigned j = 0; j < i_samples; j++ )
for( unsigned i = 0; i < i_nb_channels; i++ )
- p_out[j * i_nb_channels + i] = pp_in[pi_index[i]][j] << shift;
+ {
+ union { int32_t i; uint32_t u; } spl;
+
+ spl.u = ((uint32_t)pp_in[pi_index[i]][j]) << shift;
+ p_out[j * i_nb_channels + i] = spl.i;
+ }
}
/*****************************************************************************
msg_Dbg( p_enc, "Writing STREAMINFO: %zu", bytes );
/* Backup the STREAMINFO metadata block */
- p_enc->fmt_out.i_extra = STREAMINFO_SIZE;
- p_enc->fmt_out.p_extra = xmalloc( STREAMINFO_SIZE );
- memcpy(p_enc->fmt_out.p_extra, buffer + 4, STREAMINFO_SIZE );
+ p_enc->fmt_out.i_extra = STREAMINFO_SIZE + 8;
+ p_enc->fmt_out.p_extra = xmalloc( STREAMINFO_SIZE + 8);
+ memcpy(p_enc->fmt_out.p_extra, "fLaC", 4);
+ memcpy((uint8_t*)p_enc->fmt_out.p_extra + 4, buffer, STREAMINFO_SIZE );
+ /* Fake this as the last metadata block */
+ ((uint8_t*)p_enc->fmt_out.p_extra)[4] |= 0x80;
}
p_sys->i_headers++;
- return FLAC__STREAM_DECODER_WRITE_STATUS_CONTINUE;
+ return FLAC__STREAM_ENCODER_WRITE_STATUS_OK;
}
p_block = block_Alloc( bytes );
block_ChainAppend( &p_sys->p_chain, p_block );
- return FLAC__STREAM_DECODER_WRITE_STATUS_CONTINUE;
+ return FLAC__STREAM_ENCODER_WRITE_STATUS_OK;
}
/*****************************************************************************
* EncoderMetadataCallback: called by libflac to output metadata