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

« back to all changes in this revision

Viewing changes to modules/audio_filter/converter/dtstospdif.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
 * dtstospdif.c : encapsulates DTS frames into S/PDIF packets
3
3
 *****************************************************************************
4
4
 * Copyright (C) 2003, 2006 the VideoLAN team
5
 
 * $Id: 86c5a8951caaffc67e392bfc22b94319333db54d $
 
5
 * $Id$
6
6
 *
7
7
 * Authors: Jon Lech Johansen <jon-vl@nanocrew.net>
8
8
 *
10
10
 * it under the terms of the GNU General Public License as published by
11
11
 * the Free Software Foundation; either version 2 of the License, or
12
12
 * (at your option) any later version.
13
 
 * 
 
13
 *
14
14
 * This program is distributed in the hope that it will be useful,
15
15
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
16
16
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
24
24
/*****************************************************************************
25
25
 * Preamble
26
26
 *****************************************************************************/
27
 
#include <stdlib.h>                                      /* malloc(), free() */
28
 
#include <string.h>
29
 
 
30
 
#include <vlc/vlc.h>
 
27
#ifdef HAVE_CONFIG_H
 
28
# include "config.h"
 
29
#endif
 
30
 
 
31
#include <vlc_common.h>
 
32
#include <vlc_plugin.h>
 
33
 
31
34
 
32
35
#ifdef HAVE_UNISTD_H
33
36
#   include <unistd.h>
34
37
#endif
35
38
 
36
 
#include "audio_output.h"
37
 
#include "aout_internal.h"
 
39
#include <vlc_aout.h>
38
40
 
39
41
/*****************************************************************************
40
42
 * Local structures
67
69
vlc_module_begin();
68
70
    set_category( CAT_AUDIO );
69
71
    set_subcategory( SUBCAT_AUDIO_MISC );
70
 
    set_description( _("Audio filter for DTS->S/PDIF encapsulation") );
 
72
    set_description( N_("Audio filter for DTS->S/PDIF encapsulation") );
71
73
    set_capability( "audio filter", 10 );
72
74
    set_callbacks( Create, Close );
73
75
vlc_module_end();
89
91
    /* Allocate the memory needed to store the module's structure */
90
92
    p_filter->p_sys = malloc( sizeof(struct aout_filter_sys_t) );
91
93
    if( p_filter->p_sys == NULL )
92
 
    {
93
 
        msg_Err( p_filter, "out of memory" );
94
94
        return VLC_ENOMEM;
95
 
    }
96
95
    memset( p_filter->p_sys, 0, sizeof(struct aout_filter_sys_t) );
97
96
    p_filter->p_sys->p_buf = 0;
98
97
 
127
126
    if( p_in_buf->i_nb_bytes != p_filter->p_sys->i_frame_size )
128
127
    {
129
128
        /* Frame size changed, reset everything */
 
129
        msg_Warn( p_aout, "Frame size changed from %u to %u, "
 
130
                          "resetting everything.",
 
131
                  p_filter->p_sys->i_frame_size,
 
132
                  (unsigned)p_in_buf->i_nb_bytes );
 
133
 
130
134
        p_filter->p_sys->i_frame_size = p_in_buf->i_nb_bytes;
131
135
        p_filter->p_sys->p_buf = realloc( p_filter->p_sys->p_buf,
132
136
                                          p_in_buf->i_nb_bytes * 3 );
134
138
    }
135
139
 
136
140
    /* Backup frame */
137
 
    p_filter->p_vlc->pf_memcpy( p_filter->p_sys->p_buf + p_in_buf->i_nb_bytes *
138
 
                                p_filter->p_sys->i_frames, p_in_buf->p_buffer,
139
 
                                p_in_buf->i_nb_bytes );
 
141
    vlc_memcpy( p_filter->p_sys->p_buf + p_in_buf->i_nb_bytes *
 
142
                  p_filter->p_sys->i_frames,
 
143
                p_in_buf->p_buffer, p_in_buf->i_nb_bytes );
140
144
 
141
145
    p_filter->p_sys->i_frames++;
142
146
 
143
147
    if( p_filter->p_sys->i_frames < 3 )
144
148
    {
145
 
        if( !p_filter->p_sys->i_frames )
 
149
        if( p_filter->p_sys->i_frames == 1 )
146
150
            /* We'll need the starting date */
147
151
            p_filter->p_sys->start_date = p_in_buf->start_date;
148
152
 
157
161
    for( i_frame = 0; i_frame < 3; i_frame++ )
158
162
    {
159
163
        uint16_t i_length_padded = i_length;
160
 
        byte_t * p_out = p_out_buf->p_buffer + (i_frame * i_fz);
161
 
        byte_t * p_in = p_filter->p_sys->p_buf + (i_frame * i_length);
 
164
        uint8_t * p_out = p_out_buf->p_buffer + (i_frame * i_fz);
 
165
        uint8_t * p_in = p_filter->p_sys->p_buf + (i_frame * i_length);
162
166
 
163
167
        switch( p_in_buf->i_nb_samples )
164
168
        {
170
174
        /* Copy the S/PDIF headers. */
171
175
        if( p_filter->output.i_format == VLC_FOURCC('s','p','d','b') )
172
176
        {
173
 
            p_filter->p_vlc->pf_memcpy( p_out, p_sync_be, 6 );
 
177
            vlc_memcpy( p_out, p_sync_be, 6 );
174
178
            p_out[5] = i_ac5_spdif_type;
175
179
            p_out[6] = (( i_length ) >> 5 ) & 0xFF;
176
180
            p_out[7] = ( i_length << 3 ) & 0xFF;
177
181
        }
178
182
        else
179
183
        {
180
 
            p_filter->p_vlc->pf_memcpy( p_out, p_sync_le, 6 );
 
184
            vlc_memcpy( p_out, p_sync_le, 6 );
181
185
            p_out[4] = i_ac5_spdif_type;
182
186
            p_out[6] = ( i_length << 3 ) & 0xFF;
183
187
            p_out[7] = (( i_length ) >> 5 ) & 0xFF;
193
197
            swab( p_in, p_out + 8, i_length );
194
198
#else
195
199
            uint16_t i;
196
 
            byte_t * p_tmp, tmp;
 
200
            uint8_t * p_tmp, tmp;
197
201
            p_tmp = p_out + 8;
198
202
            for( i = i_length / 2 ; i-- ; )
199
203
            {
213
217
        }
214
218
        else
215
219
        {
216
 
            p_filter->p_vlc->pf_memcpy( p_out + 8, p_in, i_length );
 
220
            vlc_memcpy( p_out + 8, p_in, i_length );
217
221
        }
218
222
 
219
223
        if( i_fz > i_length + 8 )
220
224
        {
221
 
            p_filter->p_vlc->pf_memset( p_out + 8 + i_length_padded, 0,
222
 
                                        i_fz - i_length_padded - 8 );
 
225
            vlc_memset( p_out + 8 + i_length_padded, 0,
 
226
                        i_fz - i_length_padded - 8 );
223
227
        }
224
228
    }
225
229