~ubuntu-branches/ubuntu/saucy/gst-libav1.0/saucy-proposed

« back to all changes in this revision

Viewing changes to gst-libs/ext/libav/libavformat/vocdec.c

  • Committer: Package Import Robot
  • Author(s): Sebastian Dröge
  • Date: 2013-07-30 09:00:15 UTC
  • mfrom: (1.1.16) (7.1.7 experimental)
  • Revision ID: package-import@ubuntu.com-20130730090015-sc1ou2yssu7q5w4e
Tags: 1.1.3-1
* New upstream development snapshot:
  + debian/control:
    - Build depend on GStreamer and gst-plugins-base >= 1.1.3.

Show diffs side-by-side

added added

removed removed

Lines of Context:
38
38
    return AVPROBE_SCORE_MAX;
39
39
}
40
40
 
41
 
static int voc_read_header(AVFormatContext *s, AVFormatParameters *ap)
 
41
static int voc_read_header(AVFormatContext *s)
42
42
{
43
43
    VocDecContext *voc = s->priv_data;
44
44
    AVIOContext *pb = s->pb;
62
62
}
63
63
 
64
64
int
65
 
voc_get_packet(AVFormatContext *s, AVPacket *pkt, AVStream *st, int max_size)
 
65
ff_voc_get_packet(AVFormatContext *s, AVPacket *pkt, AVStream *st, int max_size)
66
66
{
67
67
    VocDecContext *voc = s->priv_data;
68
68
    AVCodecContext *dec = st->codec;
86
86
 
87
87
        switch (type) {
88
88
        case VOC_TYPE_VOICE_DATA:
89
 
            dec->sample_rate = 1000000 / (256 - avio_r8(pb));
90
 
            if (sample_rate)
91
 
                dec->sample_rate = sample_rate;
 
89
            if (!dec->sample_rate) {
 
90
                dec->sample_rate = 1000000 / (256 - avio_r8(pb));
 
91
                if (sample_rate)
 
92
                    dec->sample_rate = sample_rate;
 
93
                avpriv_set_pts_info(st, 64, 1, dec->sample_rate);
 
94
            } else
 
95
                avio_skip(pb, 1);
92
96
            dec->channels = channels;
93
97
            tmp_codec = avio_r8(pb);
94
98
            dec->bits_per_coded_sample = av_get_bits_per_sample(dec->codec_id);
110
114
            break;
111
115
 
112
116
        case VOC_TYPE_NEW_VOICE_DATA:
113
 
            dec->sample_rate = avio_rl32(pb);
 
117
            if (!dec->sample_rate) {
 
118
                dec->sample_rate = avio_rl32(pb);
 
119
                avpriv_set_pts_info(st, 64, 1, dec->sample_rate);
 
120
            } else
 
121
                avio_skip(pb, 4);
114
122
            dec->bits_per_coded_sample = avio_r8(pb);
115
123
            dec->channels = avio_r8(pb);
116
124
            tmp_codec = avio_rl16(pb);
129
137
 
130
138
    if (tmp_codec >= 0) {
131
139
        tmp_codec = ff_codec_get_id(ff_voc_codec_tags, tmp_codec);
132
 
        if (dec->codec_id == CODEC_ID_NONE)
 
140
        if (dec->codec_id == AV_CODEC_ID_NONE)
133
141
            dec->codec_id = tmp_codec;
134
142
        else if (dec->codec_id != tmp_codec)
135
143
            av_log(s, AV_LOG_WARNING, "Ignoring mid-stream change in audio codec\n");
136
 
        if (dec->codec_id == CODEC_ID_NONE) {
137
 
            if (s->audio_codec_id == CODEC_ID_NONE) {
 
144
        if (dec->codec_id == AV_CODEC_ID_NONE) {
 
145
            if (s->audio_codec_id == AV_CODEC_ID_NONE) {
138
146
                av_log(s, AV_LOG_ERROR, "unknown codec tag\n");
139
147
                return AVERROR(EINVAL);
140
148
            }
153
161
 
154
162
static int voc_read_packet(AVFormatContext *s, AVPacket *pkt)
155
163
{
156
 
    return voc_get_packet(s, pkt, s->streams[0], 0);
 
164
    return ff_voc_get_packet(s, pkt, s->streams[0], 0);
157
165
}
158
166
 
159
167
AVInputFormat ff_voc_demuxer = {
160
168
    .name           = "voc",
161
 
    .long_name      = NULL_IF_CONFIG_SMALL("Creative Voice file format"),
 
169
    .long_name      = NULL_IF_CONFIG_SMALL("Creative Voice"),
162
170
    .priv_data_size = sizeof(VocDecContext),
163
171
    .read_probe     = voc_probe,
164
172
    .read_header    = voc_read_header,
165
173
    .read_packet    = voc_read_packet,
166
 
    .codec_tag=(const AVCodecTag* const []){ff_voc_codec_tags, 0},
 
174
    .codec_tag      = (const AVCodecTag* const []){ ff_voc_codec_tags, 0 },
167
175
};