~ubuntu-branches/ubuntu/maverick/vlc/maverick

« back to all changes in this revision

Viewing changes to modules/codec/a52.c

  • Committer: Bazaar Package Importer
  • Author(s): Reinhard Tartler
  • Date: 2008-09-17 21:56:14 UTC
  • mfrom: (1.1.17 upstream)
  • Revision ID: james.westby@ubuntu.com-20080917215614-tj0vx8xzd57e52t8
Tags: 0.9.2-1ubuntu1
* New Upstream Release, exception granted by
    - dktrkranz, norsetto, Hobbsee (via irc). LP: #270404

Changes done in ubuntu:

* add libxul-dev to build-depends
* make sure that vlc is build against libxul in configure. This doesn't
  change anything in the package, but makes it more robust if building
  in an 'unclean' chroot or when modifying the package.
* debian/control: make Vcs-* fields point to the motumedia branch
* add libx264-dev and libass-dev to build-depends
  LP: #210354, #199870
* actually enable libass support by passing --enable-libass to configure
* enable libdca: add libdca-dev to build depends and --enable-libdca
* install the x264 plugin.

Changes already in the pkg-multimedia branch in debian:

* don't install usr/share/vlc/mozilla in debian/mozilla-plugin-vlc.install  
* new upstream .desktop file now registers flash video mimetype LP: #261567
* add Xb-Npp-Applications to mozilla-plugin-vlc
* remove duplicate entries in debian/vlc-nox.install

Show diffs side-by-side

added added

removed removed

Lines of Context:
2
2
 * a52.c: parse A/52 audio sync info and packetize the stream
3
3
 *****************************************************************************
4
4
 * Copyright (C) 2001-2002 the VideoLAN team
5
 
 * $Id: e6c9503292ad76c87941ea0fd602efb6da7490e7 $
 
5
 * $Id$
6
6
 *
7
7
 * Authors: Stéphane Borel <stef@via.ecp.fr>
8
8
 *          Christophe Massiot <massiot@via.ecp.fr>
26
26
/*****************************************************************************
27
27
 * Preamble
28
28
 *****************************************************************************/
29
 
#include <vlc/vlc.h>
30
 
#include <vlc/decoder.h>
 
29
#ifdef HAVE_CONFIG_H
 
30
# include "config.h"
 
31
#endif
31
32
 
32
 
#include "vlc_block_helper.h"
 
33
#include <vlc_common.h>
 
34
#include <vlc_plugin.h>
 
35
#include <vlc_codec.h>
 
36
#include <vlc_aout.h>
 
37
#include <vlc_input.h>
 
38
#include <vlc_block_helper.h>
33
39
 
34
40
#define A52_HEADER_SIZE 7
35
41
 
39
45
struct decoder_sys_t
40
46
{
41
47
    /* Module mode */
42
 
    vlc_bool_t b_packetizer;
 
48
    bool b_packetizer;
43
49
 
44
50
    /*
45
51
     * Input properties
57
63
    int i_frame_size, i_bit_rate;
58
64
    unsigned int i_rate, i_channels, i_channels_conf;
59
65
 
 
66
    int i_input_rate;
60
67
};
61
68
 
62
69
enum {
77
84
static void CloseDecoder  ( vlc_object_t * );
78
85
static void *DecodeBlock  ( decoder_t *, block_t ** );
79
86
 
80
 
static int  SyncInfo      ( const byte_t *, unsigned int *, unsigned int *,
 
87
static int  SyncInfo      ( const uint8_t *, unsigned int *, unsigned int *,
81
88
                            unsigned int *, int * );
82
89
 
83
90
static uint8_t       *GetOutBuffer ( decoder_t *, void ** );
88
95
 * Module descriptor
89
96
 *****************************************************************************/
90
97
vlc_module_begin();
91
 
    set_description( _("A/52 parser") );
 
98
    set_description( N_("A/52 parser") );
92
99
    set_capability( "decoder", 100 );
93
100
    set_callbacks( OpenDecoder, CloseDecoder );
94
101
    set_category( CAT_INPUT );
95
102
    set_subcategory( SUBCAT_INPUT_ACODEC );
96
103
 
97
104
    add_submodule();
98
 
    set_description( _("A/52 audio packetizer") );
 
105
    set_description( N_("A/52 audio packetizer") );
99
106
    set_capability( "packetizer", 10 );
100
107
    set_callbacks( OpenPacketizer, CloseDecoder );
101
108
vlc_module_end();
117
124
    /* Allocate the memory needed to store the decoder's structure */
118
125
    if( ( p_dec->p_sys = p_sys =
119
126
          (decoder_sys_t *)malloc(sizeof(decoder_sys_t)) ) == NULL )
120
 
    {
121
 
        msg_Err( p_dec, "out of memory" );
122
 
        return VLC_EGENERIC;
123
 
    }
 
127
        return VLC_ENOMEM;
124
128
 
125
129
    /* Misc init */
126
 
    p_sys->b_packetizer = VLC_FALSE;
 
130
    p_sys->b_packetizer = false;
127
131
    p_sys->i_state = STATE_NOSYNC;
128
132
    aout_DateSet( &p_sys->end_date, 0 );
129
133
 
130
 
    p_sys->bytestream = block_BytestreamInit( p_dec );
 
134
    p_sys->bytestream = block_BytestreamInit();
 
135
    p_sys->i_input_rate = INPUT_RATE_DEFAULT;
131
136
 
132
137
    /* Set output properties */
133
138
    p_dec->fmt_out.i_cat = AUDIO_ES;
149
154
 
150
155
    int i_ret = OpenDecoder( p_this );
151
156
 
152
 
    if( i_ret == VLC_SUCCESS ) p_dec->p_sys->b_packetizer = VLC_TRUE;
 
157
    if( i_ret == VLC_SUCCESS ) p_dec->p_sys->b_packetizer = true;
153
158
 
154
159
    return i_ret;
155
160
}
168
173
 
169
174
    if( !pp_block || !*pp_block ) return NULL;
170
175
 
 
176
    if( (*pp_block)->i_flags&(BLOCK_FLAG_DISCONTINUITY|BLOCK_FLAG_CORRUPTED) )
 
177
    {
 
178
        if( (*pp_block)->i_flags&BLOCK_FLAG_CORRUPTED )
 
179
        {
 
180
            p_sys->i_state = STATE_NOSYNC;
 
181
            block_BytestreamFlush( &p_sys->bytestream );
 
182
        }
 
183
//        aout_DateSet( &p_sys->end_date, 0 );
 
184
        block_Release( *pp_block );
 
185
        return NULL;
 
186
    }
 
187
 
171
188
    if( !aout_DateGet( &p_sys->end_date ) && !(*pp_block)->i_pts )
172
189
    {
173
190
        /* We've just started the stream, wait for the first PTS. */
175
192
        return NULL;
176
193
    }
177
194
 
178
 
    if( (*pp_block)->i_flags&(BLOCK_FLAG_DISCONTINUITY|BLOCK_FLAG_CORRUPTED) )
179
 
    {
180
 
        p_sys->i_state = STATE_NOSYNC;
181
 
    }
 
195
    if( (*pp_block)->i_rate > 0 )
 
196
        p_sys->i_input_rate = (*pp_block)->i_rate;
182
197
 
183
198
    block_BytestreamPush( &p_sys->bytestream, *pp_block );
184
199
 
285
300
        case STATE_SEND_DATA:
286
301
            if( !(p_buf = GetOutBuffer( p_dec, &p_out_buffer )) )
287
302
            {
288
 
                //p_dec->b_error = VLC_TRUE;
 
303
                //p_dec->b_error = true;
289
304
                return NULL;
290
305
            }
291
306
 
378
393
    if( p_buf == NULL ) return NULL;
379
394
 
380
395
    p_buf->start_date = aout_DateGet( &p_sys->end_date );
381
 
    p_buf->end_date = aout_DateIncrement( &p_sys->end_date, A52_FRAME_NB );
 
396
    p_buf->end_date = aout_DateIncrement( &p_sys->end_date,
 
397
                                          A52_FRAME_NB * p_sys->i_input_rate / INPUT_RATE_DEFAULT );
382
398
 
383
399
    return p_buf;
384
400
}
396
412
 
397
413
    p_block->i_pts = p_block->i_dts = aout_DateGet( &p_sys->end_date );
398
414
 
399
 
    p_block->i_length = aout_DateIncrement( &p_sys->end_date, A52_FRAME_NB ) -
400
 
        p_block->i_pts;
 
415
    p_block->i_length =
 
416
        aout_DateIncrement( &p_sys->end_date,
 
417
                            A52_FRAME_NB * p_sys->i_input_rate / INPUT_RATE_DEFAULT ) -
 
418
            p_block->i_pts;
401
419
 
402
420
    return p_block;
403
421
}
409
427
 * since we don't want to oblige S/PDIF people to use liba52 just to get
410
428
 * their SyncInfo...
411
429
 *****************************************************************************/
412
 
static int SyncInfo( const byte_t * p_buf,
 
430
static int SyncInfo( const uint8_t * p_buf,
413
431
                     unsigned int * pi_channels,
414
432
                     unsigned int * pi_channels_conf,
415
433
                     unsigned int * pi_sample_rate, int * pi_bit_rate )