~ubuntu-branches/ubuntu/feisty/avidemux/feisty

« back to all changes in this revision

Viewing changes to avidemux/ADM_mplex/stream_params.cpp

  • Committer: Bazaar Package Importer
  • Author(s): Christian Marillat
  • Date: 2005-05-25 13:02:29 UTC
  • mfrom: (1.1.2 upstream)
  • Revision ID: james.westby@ubuntu.com-20050525130229-jw94cav0yhmg7vjw
Tags: 1:2.0.40-0.0
New upstream release.

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
/*
 
2
 * params.hpp:  User specifiable parameters for various types of stream
 
3
 *
 
4
 *  The Check<stream>Params pseudo-constructors are constructed so that
 
5
 *  they will only construct legal combinations of parameters.
 
6
 *
 
7
 *  Copyright (C) 2002 Andrew Stevens <andrew.stevens@philips.com>
 
8
 *
 
9
 *  This program is free software; you can redistribute it and/or
 
10
 *  modify it under the terms of version 2 of the GNU General Public License
 
11
 *  as published by the Free Software Foundation.
 
12
 *
 
13
 *  This program is distributed in the hope that it will be useful,
 
14
 *  but WITHOUT ANY WARRANTY; without even the implied warranty of
 
15
 *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 
16
 *  GNU General Public License for more details.
 
17
 *
 
18
 *  You should have received a copy of the GNU General Public License
 
19
 *  along with this program; if not, write to the Free Software
 
20
 *  Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA  02111-1307, USA.
 
21
 */
 
22
 
 
23
 
 
24
#ifdef HAVE_CONFIG_H
 
25
#include "config.h"
 
26
#endif
 
27
 
 
28
#include "stream_params.hpp"
 
29
#include "format_codes.h"
 
30
 
 
31
LpcmParams *LpcmParams::Default(unsigned int mux_format)
 
32
{
 
33
        return new LpcmParams(48000,2,16);
 
34
}
 
35
 
 
36
LpcmParams::LpcmParams( unsigned int samples,  
 
37
                                                unsigned int chans, 
 
38
                                                unsigned int bits ) :
 
39
        samples_per_sec( samples ),
 
40
        channels(chans),
 
41
        bits_per_sample(bits)
 
42
{
 
43
}
 
44
 
 
45
LpcmParams *LpcmParams::Checked(unsigned int samples,  
 
46
                                                                unsigned int chans, 
 
47
                                                                unsigned int bits )
 
48
{
 
49
    if( samples != 48000 && samples != 96000 )
 
50
        return 0;
 
51
    if( chans < 1 || chans > 7 )
 
52
        return 0;
 
53
    if( bits != 16 && bits != 20 && bits != 24 )
 
54
        return 0;
 
55
 
 
56
    return new LpcmParams(samples,chans,bits);
 
57
}
 
58
 
 
59
bool VideoParams::Force( unsigned int mux_format )
 
60
{
 
61
        unsigned int bufsiz;
 
62
        //
 
63
        // Handle formats that force the buffer size parameter to a
 
64
        // standard-conforming value
 
65
        //
 
66
        switch( mux_format )
 
67
        {
 
68
        case MPEG_FORMAT_SVCD :
 
69
                bufsiz = 230;
 
70
                break;
 
71
        case MPEG_FORMAT_VCD :
 
72
                bufsiz = 46;
 
73
                break;
 
74
        case MPEG_FORMAT_DVD :
 
75
        case MPEG_FORMAT_DVD_NAV :
 
76
                bufsiz = 232;
 
77
                break;
 
78
        default :
 
79
                return false;
 
80
        }
 
81
        decode_buffer_size = bufsiz;
 
82
        return true;
 
83
}
 
84
 
 
85
VideoParams *VideoParams::Checked( unsigned int bufsiz)
 
86
{
 
87
        if( bufsiz < 20 && bufsiz >= 4096 )     // In KB here...
 
88
                return 0;
 
89
        return new VideoParams(bufsiz);
 
90
}
 
91
 
 
92
VideoParams::VideoParams( unsigned int bufsiz ) :
 
93
        decode_buffer_size(bufsiz)
 
94
{
 
95
}
 
96
 
 
97
VideoParams *VideoParams::Default(unsigned int mux_format)
 
98
{
 
99
        unsigned int bufsiz;
 
100
        switch( mux_format )
 
101
        {
 
102
        case MPEG_FORMAT_MPEG2 :
 
103
        case MPEG_FORMAT_SVCD :
 
104
        case MPEG_FORMAT_SVCD_NSR :     
 
105
        case MPEG_FORMAT_SVCD_STILL :
 
106
                bufsiz = 230;
 
107
                break;
 
108
        case MPEG_FORMAT_DVD :          
 
109
        case MPEG_FORMAT_DVD_NAV :              
 
110
                bufsiz = 232;
 
111
                break;
 
112
        default :
 
113
                bufsiz = 46;
 
114
        }
 
115
        return new VideoParams(bufsiz);
 
116
}
 
117
 
 
118
 
 
119
/* 
 
120
 * Local variables:
 
121
 *  c-file-style: "stroustrup"
 
122
 *  tab-width: 4
 
123
 *  indent-tabs-mode: nil
 
124
 * End:
 
125
 */