Commit b8460e98 authored by Laurent Aimar's avatar Laurent Aimar

* mpegaudio.c : cosmetics.

parent 80a2e686
...@@ -2,7 +2,7 @@ ...@@ -2,7 +2,7 @@
* mpegaudio.c * mpegaudio.c
***************************************************************************** *****************************************************************************
* Copyright (C) 2001, 2002 VideoLAN * Copyright (C) 2001, 2002 VideoLAN
* $Id: mpegaudio.c,v 1.9 2003/09/10 21:56:44 fenrir Exp $ * $Id: mpegaudio.c,v 1.10 2003/09/10 22:59:55 fenrir Exp $
* *
* Authors: Laurent Aimar <fenrir@via.ecp.fr> * Authors: Laurent Aimar <fenrir@via.ecp.fr>
* Eric Petit <titer@videolan.org> * Eric Petit <titer@videolan.org>
...@@ -25,15 +25,24 @@ ...@@ -25,15 +25,24 @@
/***************************************************************************** /*****************************************************************************
* Preamble * Preamble
*****************************************************************************/ *****************************************************************************/
#include <stdlib.h> /* malloc(), free() */
#include <vlc/vlc.h> #include <vlc/vlc.h>
#include <vlc/aout.h>
#include <vlc/decoder.h> #include <vlc/decoder.h>
#include <vlc/input.h> #include <vlc/input.h>
#include <vlc/sout.h> #include <vlc/sout.h>
#include <stdlib.h> /* malloc(), free() */ /*****************************************************************************
#include <string.h> /* strdup() */ * Module descriptor
#include "codecs.h" /* WAVEFORMATEX BITMAPINFOHEADER */ *****************************************************************************/
static int Open ( vlc_object_t * );
static int Run ( decoder_fifo_t * );
vlc_module_begin();
set_description( _("MPEG-I/II audio packetizer") );
set_capability( "packetizer", 50 );
set_callbacks( Open, NULL );
vlc_module_end();
/***************************************************************************** /*****************************************************************************
* Local prototypes * Local prototypes
*****************************************************************************/ *****************************************************************************/
...@@ -47,30 +56,13 @@ typedef struct packetizer_s ...@@ -47,30 +56,13 @@ typedef struct packetizer_s
sout_packetizer_input_t *p_sout_input; sout_packetizer_input_t *p_sout_input;
sout_format_t output_format; sout_format_t output_format;
uint64_t i_samplescount;
uint32_t i_samplespersecond;
mtime_t i_last_pts; mtime_t i_last_pts;
} packetizer_t; } packetizer_t;
static int Open ( vlc_object_t * );
static int Run ( decoder_fifo_t * );
static int InitThread ( packetizer_t * ); static int InitThread ( packetizer_t * );
static void PacketizeThread ( packetizer_t * ); static void PacketizeThread( packetizer_t * );
static void EndThread ( packetizer_t * ); static void EndThread ( packetizer_t * );
#define FREE( p ) if( p ) free( p ); p = NULL
/*****************************************************************************
* Module descriptor
*****************************************************************************/
vlc_module_begin();
set_description( _("MPEG-I/II audio packetizer") );
set_capability( "packetizer", 50 );
set_callbacks( Open, NULL );
vlc_module_end();
static int mpegaudio_bitrate[2][3][16] = static int mpegaudio_bitrate[2][3][16] =
...@@ -83,7 +75,6 @@ static int mpegaudio_bitrate[2][3][16] = ...@@ -83,7 +75,6 @@ static int mpegaudio_bitrate[2][3][16] =
/* v1 l3 */ /* v1 l3 */
{ 0, 32, 40, 48, 56, 64, 80, 96, 112, 128, 160, 192, 224, 256, 320, 0} { 0, 32, 40, 48, 56, 64, 80, 96, 112, 128, 160, 192, 224, 256, 320, 0}
}, },
{ {
/* v2 l1 */ /* v2 l1 */
{ 0, 32, 48, 56, 64, 80, 96, 112, 128, 144, 160, 176, 192, 224, 256, 0}, { 0, 32, 48, 56, 64, 80, 96, 112, 128, 144, 160, 176, 192, 224, 256, 0},
...@@ -92,7 +83,6 @@ static int mpegaudio_bitrate[2][3][16] = ...@@ -92,7 +83,6 @@ static int mpegaudio_bitrate[2][3][16] =
/* v2 l3 */ /* v2 l3 */
{ 0, 8, 16, 24, 32, 40, 48, 56, 64, 80, 96, 112, 128, 144, 160, 0} { 0, 8, 16, 24, 32, 40, 48, 56, 64, 80, 96, 112, 128, 144, 160, 0}
} }
}; };
static int mpegaudio_samplerate[2][4] = /* version 1 then 2 */ static int mpegaudio_samplerate[2][4] = /* version 1 then 2 */
...@@ -130,12 +120,8 @@ static int Run( decoder_fifo_t *p_fifo ) ...@@ -130,12 +120,8 @@ static int Run( decoder_fifo_t *p_fifo )
int b_error; int b_error;
msg_Info( p_fifo, "Running mpegaudio packetizer" ); msg_Info( p_fifo, "Running mpegaudio packetizer" );
if( !( p_pack = malloc( sizeof( packetizer_t ) ) ) )
{ p_pack = malloc( sizeof( packetizer_t ) );
msg_Err( p_fifo, "out of memory" );
DecoderError( p_fifo );
return( -1 );
}
memset( p_pack, 0, sizeof( packetizer_t ) ); memset( p_pack, 0, sizeof( packetizer_t ) );
p_pack->p_fifo = p_fifo; p_pack->p_fifo = p_fifo;
...@@ -143,7 +129,7 @@ static int Run( decoder_fifo_t *p_fifo ) ...@@ -143,7 +129,7 @@ static int Run( decoder_fifo_t *p_fifo )
if( InitThread( p_pack ) != 0 ) if( InitThread( p_pack ) != 0 )
{ {
DecoderError( p_fifo ); DecoderError( p_fifo );
return( -1 ); return VLC_EGENERIC;
} }
while( ( !p_pack->p_fifo->b_die )&&( !p_pack->p_fifo->b_error ) ) while( ( !p_pack->p_fifo->b_die )&&( !p_pack->p_fifo->b_error ) )
...@@ -159,14 +145,14 @@ static int Run( decoder_fifo_t *p_fifo ) ...@@ -159,14 +145,14 @@ static int Run( decoder_fifo_t *p_fifo )
EndThread( p_pack ); EndThread( p_pack );
FREE( p_pack ); free( p_pack );
if( b_error ) if( b_error )
{ {
return( -1 ); return VLC_EGENERIC;
} }
return( 0 ); return VLC_SUCCESS;
} }
...@@ -190,18 +176,16 @@ static int InitThread( packetizer_t *p_pack ) ...@@ -190,18 +176,16 @@ static int InitThread( packetizer_t *p_pack )
p_pack->p_sout_input = NULL; p_pack->p_sout_input = NULL;
p_pack->i_samplescount = 0;
p_pack->i_samplespersecond = 0;
p_pack->i_last_pts = 0; p_pack->i_last_pts = 0;
if( InitBitstream( &p_pack->bit_stream, p_pack->p_fifo, if( InitBitstream( &p_pack->bit_stream, p_pack->p_fifo,
NULL, NULL ) != VLC_SUCCESS ) NULL, NULL ) != VLC_SUCCESS )
{ {
msg_Err( p_pack->p_fifo, "cannot initialize bitstream" ); msg_Err( p_pack->p_fifo, "cannot initialize bitstream" );
return -1; return VLC_EGENERIC;
} }
return( 0 ); return VLC_SUCCESS;
} }
/***************************************************************************** /*****************************************************************************
...@@ -372,8 +356,6 @@ static void PacketizeThread( packetizer_t *p_pack ) ...@@ -372,8 +356,6 @@ static void PacketizeThread( packetizer_t *p_pack )
(uint64_t)i_samplesperframe / (uint64_t)i_samplesperframe /
(uint64_t)i_samplerate; (uint64_t)i_samplerate;
p_pack->i_samplescount += i_samplesperframe;
/* we are already aligned */ /* we are already aligned */
GetChunk( &p_pack->bit_stream, GetChunk( &p_pack->bit_stream,
p_sout_buffer->p_buffer + 4, p_sout_buffer->p_buffer + 4,
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment