~ubuntu-branches/ubuntu/oneiric/libav/oneiric

« back to all changes in this revision

Viewing changes to libavformat/vocenc.c

  • Committer: Bazaar Package Importer
  • Author(s): Reinhard Tartler
  • Date: 2011-04-30 14:27:42 UTC
  • mfrom: (1.1.2 experimental)
  • Revision ID: james.westby@ubuntu.com-20110430142742-quvblxk1tj6adlh5
Tags: 4:0.7~b1-1ubuntu1
* Merge from debian. Remaining changes:
  - don't build against libfaad, libdirac, librtmp and libopenjpeg
    (all in universe)
  - explicitly --enable-pic on powerpc, cf. LP #654666
  - different arm configure bits that should probably better be
    merged into debian
* Cherry-picked from git: 
  - install doc/APIChanges and refer to them in NEWS.Debian (Closes: #623682)
  - don't try to install non-existing documentation, fixes FTBFS on powerpc

Show diffs side-by-side

added added

removed removed

Lines of Context:
2
2
 * Creative Voice File muxer.
3
3
 * Copyright (c) 2006  Aurelien Jacobs <aurel@gnuage.org>
4
4
 *
5
 
 * This file is part of FFmpeg.
 
5
 * This file is part of Libav.
6
6
 *
7
 
 * FFmpeg is free software; you can redistribute it and/or
 
7
 * Libav is free software; you can redistribute it and/or
8
8
 * modify it under the terms of the GNU Lesser General Public
9
9
 * License as published by the Free Software Foundation; either
10
10
 * version 2.1 of the License, or (at your option) any later version.
11
11
 *
12
 
 * FFmpeg is distributed in the hope that it will be useful,
 
12
 * Libav is distributed in the hope that it will be useful,
13
13
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
14
14
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
15
15
 * Lesser General Public License for more details.
16
16
 *
17
17
 * You should have received a copy of the GNU Lesser General Public
18
 
 * License along with FFmpeg; if not, write to the Free Software
 
18
 * License along with Libav; if not, write to the Free Software
19
19
 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
20
20
 */
21
21
 
22
22
#include "voc.h"
 
23
#include "internal.h"
23
24
 
24
25
 
25
26
typedef struct voc_enc_context {
28
29
 
29
30
static int voc_write_header(AVFormatContext *s)
30
31
{
31
 
    ByteIOContext *pb = s->pb;
 
32
    AVIOContext *pb = s->pb;
32
33
    const int header_size = 26;
33
34
    const int version = 0x0114;
34
35
 
36
37
        || s->streams[0]->codec->codec_type != AVMEDIA_TYPE_AUDIO)
37
38
        return AVERROR_PATCHWELCOME;
38
39
 
39
 
    put_buffer(pb, ff_voc_magic, sizeof(ff_voc_magic) - 1);
40
 
    put_le16(pb, header_size);
41
 
    put_le16(pb, version);
42
 
    put_le16(pb, ~version + 0x1234);
 
40
    avio_write(pb, ff_voc_magic, sizeof(ff_voc_magic) - 1);
 
41
    avio_wl16(pb, header_size);
 
42
    avio_wl16(pb, version);
 
43
    avio_wl16(pb, ~version + 0x1234);
43
44
 
44
45
    return 0;
45
46
}
48
49
{
49
50
    VocEncContext *voc = s->priv_data;
50
51
    AVCodecContext *enc = s->streams[0]->codec;
51
 
    ByteIOContext *pb = s->pb;
 
52
    AVIOContext *pb = s->pb;
52
53
 
53
54
    if (!voc->param_written) {
54
55
        if (enc->codec_tag > 0xFF) {
55
 
            put_byte(pb, VOC_TYPE_NEW_VOICE_DATA);
56
 
            put_le24(pb, pkt->size + 12);
57
 
            put_le32(pb, enc->sample_rate);
58
 
            put_byte(pb, enc->bits_per_coded_sample);
59
 
            put_byte(pb, enc->channels);
60
 
            put_le16(pb, enc->codec_tag);
61
 
            put_le32(pb, 0);
 
56
            avio_w8(pb, VOC_TYPE_NEW_VOICE_DATA);
 
57
            avio_wl24(pb, pkt->size + 12);
 
58
            avio_wl32(pb, enc->sample_rate);
 
59
            avio_w8(pb, enc->bits_per_coded_sample);
 
60
            avio_w8(pb, enc->channels);
 
61
            avio_wl16(pb, enc->codec_tag);
 
62
            avio_wl32(pb, 0);
62
63
        } else {
63
64
            if (s->streams[0]->codec->channels > 1) {
64
 
                put_byte(pb, VOC_TYPE_EXTENDED);
65
 
                put_le24(pb, 4);
66
 
                put_le16(pb, 65536-256000000/(enc->sample_rate*enc->channels));
67
 
                put_byte(pb, enc->codec_tag);
68
 
                put_byte(pb, enc->channels - 1);
 
65
                avio_w8(pb, VOC_TYPE_EXTENDED);
 
66
                avio_wl24(pb, 4);
 
67
                avio_wl16(pb, 65536-256000000/(enc->sample_rate*enc->channels));
 
68
                avio_w8(pb, enc->codec_tag);
 
69
                avio_w8(pb, enc->channels - 1);
69
70
            }
70
 
            put_byte(pb, VOC_TYPE_VOICE_DATA);
71
 
            put_le24(pb, pkt->size + 2);
72
 
            put_byte(pb, 256 - 1000000 / enc->sample_rate);
73
 
            put_byte(pb, enc->codec_tag);
 
71
            avio_w8(pb, VOC_TYPE_VOICE_DATA);
 
72
            avio_wl24(pb, pkt->size + 2);
 
73
            avio_w8(pb, 256 - 1000000 / enc->sample_rate);
 
74
            avio_w8(pb, enc->codec_tag);
74
75
        }
75
76
        voc->param_written = 1;
76
77
    } else {
77
 
        put_byte(pb, VOC_TYPE_VOICE_DATA_CONT);
78
 
        put_le24(pb, pkt->size);
 
78
        avio_w8(pb, VOC_TYPE_VOICE_DATA_CONT);
 
79
        avio_wl24(pb, pkt->size);
79
80
    }
80
81
 
81
 
    put_buffer(pb, pkt->data, pkt->size);
 
82
    avio_write(pb, pkt->data, pkt->size);
82
83
    return 0;
83
84
}
84
85
 
85
86
static int voc_write_trailer(AVFormatContext *s)
86
87
{
87
 
    put_byte(s->pb, 0);
 
88
    avio_w8(s->pb, 0);
88
89
    return 0;
89
90
}
90
91
 
91
 
AVOutputFormat voc_muxer = {
 
92
AVOutputFormat ff_voc_muxer = {
92
93
    "voc",
93
94
    NULL_IF_CONFIG_SMALL("Creative Voice file format"),
94
95
    "audio/x-voc",