msg_Dbg( p_dec, "Opus audio with %d channels", p_header->channels);
if((p_header->channels>2 && p_header->channel_mapping==0) ||
- (p_header->channels>8 && p_header->channel_mapping==1) ||
+ p_header->channels>8 ||
p_header->channel_mapping>1)
{
msg_Err( p_dec, "Unsupported channel mapping" );
*pp_block = NULL; /* To avoid being fed the same packet again */
- {
- block_t *p_aout_buffer = DecodePacket( p_dec, p_oggpacket,
- p_block->i_nb_samples,
- (int)p_block->i_length );
+ if( !p_block )
+ return NULL;
- block_Release( p_block );
- return p_aout_buffer;
- }
+ block_t *p_aout_buffer = DecodePacket( p_dec, p_oggpacket,
+ p_block->i_nb_samples,
+ (int)p_block->i_length );
+
+ block_Release( p_block );
+ return p_aout_buffer;
}
/*****************************************************************************
if(spp>0)spp*=opus_packet_get_samples_per_frame(p_oggpacket->packet,48000);
if(spp<120||spp>120*48)return NULL;
+ /* Since the information isn't always available at the demux level
+ * use the packet's sample number */
+ if(!i_nb_samples)
+ i_nb_samples = spp;
+
block_t *p_aout_buffer=decoder_NewAudioBuffer( p_dec, spp );
if ( !p_aout_buffer )
{
msg_Err( p_dec, "Error: corrupted stream?" );
return NULL;
}
+
+ p_aout_buffer->i_buffer = (i_nb_samples - i_end_trim) *
+ p_sys->header.channels * sizeof(float);
+
if( spp > i_nb_samples )
{
- p_aout_buffer->i_buffer = (i_nb_samples - i_end_trim) *
- p_sys->header.channels * sizeof(float);
memmove(p_aout_buffer->p_buffer,
p_aout_buffer->p_buffer
+ (spp - i_nb_samples)*p_sys->header.channels*sizeof(float),
goto error;
}
- /* TODO: vbr, bitrate, fec */
+ /* TODO: vbr, fec */
+
+ if( enc->fmt_out.i_bitrate )
+ opus_multistream_encoder_ctl(sys->enc, OPUS_SET_BITRATE( enc->fmt_out.i_bitrate ));
/* Buffer for incoming audio, since opus only accepts frame sizes that are
multiples of 2.5ms */
/* Now that we have preskip, we can write the header to extradata */
if (opus_write_header((uint8_t **) &enc->fmt_out.p_extra,
- &enc->fmt_out.i_extra, &header))
+ &enc->fmt_out.i_extra, &header, opus_get_version_string()))
{
msg_Err(enc, "Failed to write header.");
status = VLC_ENOMEM;