X-Git-Url: https://git.sesse.net/?a=blobdiff_plain;f=modules%2Fpacketizer%2Fmlp.c;h=69b96b6e379487a004165897f004e7acff6055b2;hb=2d06d850c47ba3fe678b803cb3518a62ec976253;hp=09abbcb7575af0eacb6fa528afc72044cc9a6a4a;hpb=66bd92014e5d721d8fe74bfd69f601bfd228012a;p=vlc diff --git a/modules/packetizer/mlp.c b/modules/packetizer/mlp.c index 09abbcb757..69b96b6e37 100644 --- a/modules/packetizer/mlp.c +++ b/modules/packetizer/mlp.c @@ -6,19 +6,19 @@ * * Authors: Laurent Aimar < fenrir _AT videolan _DOT_ org > * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 2 of the License, or + * This program is free software; you can redistribute it and/or modify it + * under the terms of the GNU Lesser General Public License as published by + * the Free Software Foundation; either version 2.1 of the License, or * (at your option) any later version. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License for more details. * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston MA 02110-1301, USA. + * You should have received a copy of the GNU Lesser General Public License + * along with this program; if not, write to the Free Software Foundation, + * Inc., 51 Franklin Street, Fifth Floor, Boston MA 02110-1301, USA. *****************************************************************************/ /***************************************************************************** @@ -31,11 +31,12 @@ #include #include #include -#include #include #include #include +#include "packetizer_helper.h" + /***************************************************************************** * Module descriptor *****************************************************************************/ @@ -56,15 +57,15 @@ vlc_module_end () typedef struct { int i_type; - int i_rate; - int i_channels; + unsigned i_rate; + unsigned i_channels; int i_channels_conf; - int i_samples; + unsigned i_samples; bool b_vbr; - int i_bitrate; + unsigned i_bitrate; - int i_substreams; + unsigned i_substreams; } mlp_header_t; @@ -80,7 +81,7 @@ struct decoder_sys_t /* * Common properties */ - audio_date_t end_date; + date_t end_date; mtime_t i_pts; int i_frame_size; @@ -89,16 +90,6 @@ struct decoder_sys_t mlp_header_t mlp; }; -enum { - - STATE_NOSYNC, - STATE_SYNC, - STATE_HEADER, - STATE_NEXT_SYNC, - STATE_GET_DATA, - STATE_SEND_DATA -}; - #define MLP_MAX_SUBSTREAMS (16) #define MLP_HEADER_SYNC (28) #define MLP_HEADER_SIZE (4 + MLP_HEADER_SYNC + 4 * MLP_MAX_SUBSTREAMS) @@ -120,7 +111,8 @@ static int Open( vlc_object_t *p_this ) decoder_t *p_dec = (decoder_t*)p_this; decoder_sys_t *p_sys; - if( p_dec->fmt_in.i_codec != VLC_CODEC_MLP ) + if( p_dec->fmt_in.i_codec != VLC_CODEC_MLP && + p_dec->fmt_in.i_codec != VLC_CODEC_TRUEHD ) return VLC_EGENERIC; /* */ @@ -130,14 +122,14 @@ static int Open( vlc_object_t *p_this ) /* */ p_sys->i_state = STATE_NOSYNC; - aout_DateSet( &p_sys->end_date, 0 ); + date_Set( &p_sys->end_date, 0 ); - p_sys->bytestream = block_BytestreamInit(); + block_BytestreamInit( &p_sys->bytestream ); p_sys->b_mlp = false; /* Set output properties */ p_dec->fmt_out.i_cat = AUDIO_ES; - p_dec->fmt_out.i_codec = VLC_CODEC_MLP; + p_dec->fmt_out.i_codec = p_dec->fmt_in.i_codec; p_dec->fmt_out.audio.i_rate = 0; /* Set callback */ @@ -167,12 +159,12 @@ static block_t *Packetize( decoder_t *p_dec, block_t **pp_block ) p_sys->i_state = STATE_NOSYNC; block_BytestreamEmpty( &p_sys->bytestream ); } - aout_DateSet( &p_sys->end_date, 0 ); + date_Set( &p_sys->end_date, 0 ); block_Release( *pp_block ); return NULL; } - if( !aout_DateGet( &p_sys->end_date ) && !(*pp_block)->i_pts ) + if( !date_Get( &p_sys->end_date ) && !(*pp_block)->i_pts ) { /* We've just started the stream, wait for the first PTS. */ block_Release( *pp_block ); @@ -211,10 +203,10 @@ static block_t *Packetize( decoder_t *p_dec, block_t **pp_block ) case STATE_SYNC: /* New frame, set the Presentation Time Stamp */ p_sys->i_pts = p_sys->bytestream.p_block->i_pts; - if( p_sys->i_pts != 0 && - p_sys->i_pts != aout_DateGet( &p_sys->end_date ) ) + if( p_sys->i_pts > VLC_TS_INVALID && + p_sys->i_pts != date_Get( &p_sys->end_date ) ) { - aout_DateSet( &p_sys->end_date, p_sys->i_pts ); + date_Set( &p_sys->end_date, p_sys->i_pts ); } p_sys->i_state = STATE_HEADER; @@ -279,7 +271,7 @@ static block_t *Packetize( decoder_t *p_dec, block_t **pp_block ) case STATE_SEND_DATA: /* When we reach this point we already know we have enough * data available. */ - p_out_buffer = block_New( p_dec, p_sys->i_frame_size ); + p_out_buffer = block_Alloc( p_sys->i_frame_size ); if( !p_out_buffer ) return NULL; @@ -301,23 +293,24 @@ static block_t *Packetize( decoder_t *p_dec, block_t **pp_block ) msg_Info( p_dec, "MLP channels: %d samplerate: %d", p_sys->mlp.i_channels, p_sys->mlp.i_rate ); - aout_DateInit( &p_sys->end_date, p_sys->mlp.i_rate ); - aout_DateSet( &p_sys->end_date, p_sys->i_pts ); + const mtime_t i_end_date = date_Get( &p_sys->end_date ); + date_Init( &p_sys->end_date, p_sys->mlp.i_rate, 1 ); + date_Set( &p_sys->end_date, i_end_date ); } p_dec->fmt_out.audio.i_rate = p_sys->mlp.i_rate; p_dec->fmt_out.audio.i_channels = p_sys->mlp.i_channels; p_dec->fmt_out.audio.i_original_channels = p_sys->mlp.i_channels_conf; - p_dec->fmt_out.audio.i_physical_channels = p_sys->mlp.i_channels_conf & AOUT_CHAN_PHYSMASK; + p_dec->fmt_out.audio.i_physical_channels = p_sys->mlp.i_channels_conf; - p_out_buffer->i_pts = p_out_buffer->i_dts = aout_DateGet( &p_sys->end_date ); + p_out_buffer->i_pts = p_out_buffer->i_dts = date_Get( &p_sys->end_date ); p_out_buffer->i_length = - aout_DateIncrement( &p_sys->end_date, p_sys->mlp.i_samples ) - p_out_buffer->i_pts; + date_Increment( &p_sys->end_date, p_sys->mlp.i_samples ) - p_out_buffer->i_pts; /* Make sure we don't reuse the same pts twice */ if( p_sys->i_pts == p_sys->bytestream.p_block->i_pts ) - p_sys->i_pts = p_sys->bytestream.p_block->i_pts = 0; + p_sys->i_pts = p_sys->bytestream.p_block->i_pts = VLC_TS_INVALID; /* So p_block doesn't get re-added several times */ *pp_block = block_BytestreamPop( &p_sys->bytestream ); @@ -391,7 +384,10 @@ static int MlpParse( mlp_header_t *p_mlp, const uint8_t p_hdr[MLP_HEADER_SYNC] ) bs_skip( &s, 4 + 4 ); i_rate_idx1 = bs_read( &s, 4 ); - const int i_rate_idx2 = bs_read( &s, 4 ); + + // Just skip the 4 following, since we don't use it + // const int i_rate_idx2 = bs_read( &s, 4 ); + bs_skip( &s, 4 ); bs_skip( &s, 11 ); @@ -464,7 +460,7 @@ static int SyncInfo( const uint8_t *p_hdr, bool *pb_mlp, mlp_header_t *p_mlp ) int i_tmp = 0 ^ p_hdr[0] ^ p_hdr[1] ^ p_hdr[2] ^ p_hdr[3]; const uint8_t *p = &p_hdr[4 + ( b_has_sync ? 28 : 0 )]; - for( int i = 0; i < p_mlp->i_substreams; i++ ) + for( unsigned i = 0; i < p_mlp->i_substreams; i++ ) { i_tmp ^= *p++; i_tmp ^= *p++;