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

« back to all changes in this revision

Viewing changes to modules/audio_filter/converter/mpgatofixed32.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:
3
3
 * using MAD (MPEG Audio Decoder)
4
4
 *****************************************************************************
5
5
 * Copyright (C) 2001-2005 the VideoLAN team
6
 
 * $Id: f5815ec17356739281811d1241566e02ae345d99 $
 
6
 * $Id$
7
7
 *
8
8
 * Authors: Christophe Massiot <massiot@via.ecp.fr>
9
9
 *          Jean-Paul Saman <jpsaman _at_ videolan _dot_ org>
10
 
 *      
 
10
 *
11
11
 * This program is free software; you can redistribute it and/or modify
12
12
 * it under the terms of the GNU General Public License as published by
13
13
 * the Free Software Foundation; either version 2 of the License, or
14
14
 * (at your option) any later version.
15
 
 * 
 
15
 *
16
16
 * This program is distributed in the hope that it will be useful,
17
17
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
18
18
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
26
26
/*****************************************************************************
27
27
 * Preamble
28
28
 *****************************************************************************/
29
 
#include <stdlib.h>                                      /* malloc(), free() */
30
 
#include <string.h>                                              /* strdup() */
31
29
 
32
30
#include <mad.h>
33
31
 
34
 
#include <vlc/vlc.h>
35
 
#include <vlc/decoder.h>
36
 
#include "aout_internal.h"
 
32
#ifdef HAVE_CONFIG_H
 
33
# include "config.h"
 
34
#endif
 
35
 
 
36
#include <vlc_common.h>
 
37
#include <vlc_plugin.h>
 
38
#include <vlc_aout.h>
 
39
#include <vlc_block.h>
37
40
#include "vlc_filter.h"
38
41
 
39
42
/*****************************************************************************
41
44
 *****************************************************************************/
42
45
static int  Create    ( vlc_object_t * );
43
46
static void Destroy   ( vlc_object_t * );
44
 
static void DoWork    ( aout_instance_t *, aout_filter_t *, aout_buffer_t *,  
 
47
static void DoWork    ( aout_instance_t *, aout_filter_t *, aout_buffer_t *,
45
48
                        aout_buffer_t * );
46
49
 
47
50
static int  OpenFilter ( vlc_object_t * );
54
57
struct filter_sys_t
55
58
{
56
59
    struct mad_stream mad_stream;
57
 
    struct mad_frame mad_frame;
58
 
    struct mad_synth mad_synth;
 
60
    struct mad_frame  mad_frame;
 
61
    struct mad_synth  mad_synth;
 
62
 
 
63
    int               i_reject_count;
59
64
};
60
65
 
61
66
/*****************************************************************************
64
69
vlc_module_begin();
65
70
    set_category( CAT_INPUT );
66
71
    set_subcategory( SUBCAT_INPUT_ACODEC );
67
 
    set_description( _("MPEG audio decoder") );
 
72
    set_description( N_("MPEG audio decoder") );
68
73
    set_capability( "audio filter", 100 );
69
74
    set_callbacks( Create, Destroy );
70
75
 
71
76
    add_submodule();
72
 
    set_description( _("MPEG audio decoder") );
 
77
    set_description( N_("MPEG audio decoder") );
73
78
    set_capability( "audio filter2", 100 );
74
79
    set_callbacks( OpenFilter, CloseFilter );
75
80
vlc_module_end();
76
81
 
77
82
/*****************************************************************************
78
 
 * Create: 
 
83
 * Create:
79
84
 *****************************************************************************/
80
85
static int Create( vlc_object_t *p_this )
81
86
{
99
104
    p_sys = malloc( sizeof(filter_sys_t) );
100
105
    p_filter->p_sys = (struct aout_filter_sys_t *)p_sys;
101
106
    if( p_sys == NULL )
102
 
    {
103
 
        msg_Err( p_filter, "out of memory" );
104
107
        return -1;
105
 
    }
106
108
 
107
109
    /* Initialize libmad */
108
110
    mad_stream_init( &p_sys->mad_stream );
109
111
    mad_frame_init( &p_sys->mad_frame );
110
112
    mad_synth_init( &p_sys->mad_synth );
111
113
    mad_stream_options( &p_sys->mad_stream, MAD_OPTION_IGNORECRC );
 
114
    p_sys->i_reject_count = 0;
112
115
 
113
116
    p_filter->pf_do_work = DoWork;
114
117
    p_filter->b_in_place = 0;
125
128
    filter_sys_t *p_sys = (filter_sys_t *)p_filter->p_sys;
126
129
 
127
130
    p_out_buf->i_nb_samples = p_in_buf->i_nb_samples;
128
 
    p_out_buf->i_nb_bytes = p_in_buf->i_nb_samples * sizeof(vlc_fixed_t) * 
 
131
    p_out_buf->i_nb_bytes = p_in_buf->i_nb_samples * sizeof(vlc_fixed_t) *
129
132
                               aout_FormatNbChannels( &p_filter->output );
130
133
 
131
134
    /* Do the actual decoding now. */
135
138
    {
136
139
        msg_Dbg( p_aout, "libmad error: %s",
137
140
                  mad_stream_errorstr( &p_sys->mad_stream ) );
 
141
        p_sys->i_reject_count = 3;
 
142
    }
 
143
    else if( p_in_buf->b_discontinuity )
 
144
    {
 
145
        p_sys->i_reject_count = 3;
 
146
    }
 
147
 
 
148
    if( p_sys->i_reject_count > 0 )
 
149
    {
138
150
        if( p_filter->output.i_format == VLC_FOURCC('f','l','3','2') )
139
151
        {
140
152
            int i;
141
153
            int i_size = p_out_buf->i_nb_bytes / sizeof(float);
142
 
            
 
154
 
143
155
            float * a = (float *)p_out_buf->p_buffer;
144
156
            for ( i = 0 ; i < i_size ; i++ )
145
157
                *a++ = 0.0;
148
160
        {
149
161
            memset( p_out_buf->p_buffer, 0, p_out_buf->i_nb_bytes );
150
162
        }
 
163
        p_sys->i_reject_count--;
151
164
        return;
152
165
    }
153
166
 
 
167
 
154
168
    mad_synth_frame( &p_sys->mad_synth, &p_sys->mad_frame );
155
169
 
156
170
    if ( p_filter->output.i_format == VLC_FOURCC('f','i','3','2') )
199
213
            break;
200
214
 
201
215
        case 1:
202
 
            p_filter->p_vlc->pf_memcpy( p_samples, p_left,
203
 
                                        i_samples * sizeof(mad_fixed_t) );
 
216
            vlc_memcpy( p_samples, p_left, i_samples * sizeof(mad_fixed_t) );
204
217
            break;
205
218
 
206
219
        default:
284
297
}
285
298
 
286
299
/*****************************************************************************
287
 
 * OpenFilter: 
 
300
 * OpenFilter:
288
301
 *****************************************************************************/
289
302
static int OpenFilter( vlc_object_t *p_this )
290
303
{
300
313
    /* Allocate the memory needed to store the module's structure */
301
314
    p_sys = p_filter->p_sys = malloc( sizeof(filter_sys_t) );
302
315
    if( p_sys == NULL )
303
 
    {
304
 
        msg_Err( p_filter, "out of memory" );
305
316
        return -1;
306
 
    }
 
317
    p_sys->i_reject_count = 0;
307
318
 
308
319
    p_filter->pf_audio_filter = Convert;
309
320
 
313
324
    mad_synth_init( &p_sys->mad_synth );
314
325
    mad_stream_options( &p_sys->mad_stream, MAD_OPTION_IGNORECRC );
315
326
 
316
 
    if( p_this->p_libvlc->i_cpu & CPU_CAPABILITY_FPU )
 
327
    if( vlc_CPU() & CPU_CAPABILITY_FPU )
317
328
        p_filter->fmt_out.i_codec = VLC_FOURCC('f','l','3','2');
318
329
    else
319
330
        p_filter->fmt_out.i_codec = VLC_FOURCC('f','i','3','2');
320
331
    p_filter->fmt_out.audio.i_format = p_filter->fmt_out.i_codec;
 
332
    p_filter->fmt_out.audio.i_bitspersample =
 
333
        aout_BitsPerSample( p_filter->fmt_out.i_codec );
321
334
 
322
335
    p_filter->fmt_out.audio.i_rate = p_filter->fmt_in.audio.i_rate;
323
336
 
352
365
 
353
366
    if( !p_block || !p_block->i_samples )
354
367
    {
355
 
        if( p_block ) p_block->pf_release( p_block );
 
368
        if( p_block )
 
369
            block_Release( p_block );
356
370
        return NULL;
357
371
    }
358
372
 
364
378
    if( !p_out )
365
379
    {
366
380
        msg_Warn( p_filter, "can't get output buffer" );
367
 
        p_block->pf_release( p_block );
 
381
        block_Release( p_block );
368
382
        return NULL;
369
383
    }
370
384
 
380
394
    aout_filter.output.i_format = p_filter->fmt_out.i_codec;
381
395
 
382
396
    in_buf.p_buffer = p_block->p_buffer;
 
397
    in_buf.b_discontinuity = false;
383
398
    in_buf.i_nb_bytes = p_block->i_buffer;
384
399
    in_buf.i_nb_samples = p_block->i_samples;
385
400
    out_buf.p_buffer = p_out->p_buffer;
388
403
 
389
404
    DoWork( (aout_instance_t *)p_filter, &aout_filter, &in_buf, &out_buf );
390
405
 
391
 
    p_block->pf_release( p_block );
 
406
    block_Release( p_block );
392
407
 
393
408
    p_out->i_buffer = out_buf.i_nb_bytes;
394
409
    p_out->i_samples = out_buf.i_nb_samples;