~phatforge/libav/fixup

« back to all changes in this revision

Viewing changes to libavformat/apetag.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:
3
3
 * Copyright (c) 2007 Benjamin Zores <ben@geexbox.org>
4
4
 *  based upon libdemac from Dave Chapman.
5
5
 *
6
 
 * This file is part of FFmpeg.
 
6
 * This file is part of Libav.
7
7
 *
8
 
 * FFmpeg is free software; you can redistribute it and/or
 
8
 * Libav is free software; you can redistribute it and/or
9
9
 * modify it under the terms of the GNU Lesser General Public
10
10
 * License as published by the Free Software Foundation; either
11
11
 * version 2.1 of the License, or (at your option) any later version.
12
12
 *
13
 
 * FFmpeg is distributed in the hope that it will be useful,
 
13
 * Libav is distributed in the hope that it will be useful,
14
14
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
15
15
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
16
16
 * Lesser General Public License for more details.
17
17
 *
18
18
 * You should have received a copy of the GNU Lesser General Public
19
 
 * License along with FFmpeg; if not, write to the Free Software
 
19
 * License along with Libav; if not, write to the Free Software
20
20
 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
21
21
 */
22
22
 
33
33
 
34
34
static int ape_tag_read_field(AVFormatContext *s)
35
35
{
36
 
    ByteIOContext *pb = s->pb;
 
36
    AVIOContext *pb = s->pb;
37
37
    uint8_t key[1024], *value;
38
38
    uint32_t size, flags;
39
39
    int i, c;
40
40
 
41
 
    size = get_le32(pb);  /* field size */
42
 
    flags = get_le32(pb); /* field flags */
 
41
    size = avio_rl32(pb);  /* field size */
 
42
    flags = avio_rl32(pb); /* field flags */
43
43
    for (i = 0; i < sizeof(key) - 1; i++) {
44
 
        c = get_byte(pb);
 
44
        c = avio_r8(pb);
45
45
        if (c < 0x20 || c > 0x7E)
46
46
            break;
47
47
        else
57
57
    value = av_malloc(size+1);
58
58
    if (!value)
59
59
        return AVERROR(ENOMEM);
60
 
    get_buffer(pb, value, size);
 
60
    avio_read(pb, value, size);
61
61
    value[size] = 0;
62
62
    av_metadata_set2(&s->metadata, key, value, AV_METADATA_DONT_STRDUP_VAL);
63
63
    return 0;
65
65
 
66
66
void ff_ape_parse_tag(AVFormatContext *s)
67
67
{
68
 
    ByteIOContext *pb = s->pb;
69
 
    int file_size = url_fsize(pb);
 
68
    AVIOContext *pb = s->pb;
 
69
    int file_size = avio_size(pb);
70
70
    uint32_t val, fields, tag_bytes;
71
71
    uint8_t buf[8];
72
72
    int i;
74
74
    if (file_size < APE_TAG_FOOTER_BYTES)
75
75
        return;
76
76
 
77
 
    url_fseek(pb, file_size - APE_TAG_FOOTER_BYTES, SEEK_SET);
 
77
    avio_seek(pb, file_size - APE_TAG_FOOTER_BYTES, SEEK_SET);
78
78
 
79
 
    get_buffer(pb, buf, 8);    /* APETAGEX */
 
79
    avio_read(pb, buf, 8);     /* APETAGEX */
80
80
    if (strncmp(buf, "APETAGEX", 8)) {
81
81
        return;
82
82
    }
83
83
 
84
 
    val = get_le32(pb);        /* APE tag version */
 
84
    val = avio_rl32(pb);       /* APE tag version */
85
85
    if (val > APE_TAG_VERSION) {
86
86
        av_log(s, AV_LOG_ERROR, "Unsupported tag version. (>=%d)\n", APE_TAG_VERSION);
87
87
        return;
88
88
    }
89
89
 
90
 
    tag_bytes = get_le32(pb);  /* tag size */
 
90
    tag_bytes = avio_rl32(pb); /* tag size */
91
91
    if (tag_bytes - APE_TAG_FOOTER_BYTES > (1024 * 1024 * 16)) {
92
92
        av_log(s, AV_LOG_ERROR, "Tag size is way too big\n");
93
93
        return;
94
94
    }
95
95
 
96
 
    fields = get_le32(pb);     /* number of fields */
 
96
    fields = avio_rl32(pb);    /* number of fields */
97
97
    if (fields > 65536) {
98
98
        av_log(s, AV_LOG_ERROR, "Too many tag fields (%d)\n", fields);
99
99
        return;
100
100
    }
101
101
 
102
 
    val = get_le32(pb);        /* flags */
 
102
    val = avio_rl32(pb);       /* flags */
103
103
    if (val & APE_TAG_FLAG_IS_HEADER) {
104
104
        av_log(s, AV_LOG_ERROR, "APE Tag is a header\n");
105
105
        return;
106
106
    }
107
107
 
108
 
    url_fseek(pb, file_size - tag_bytes, SEEK_SET);
 
108
    avio_seek(pb, file_size - tag_bytes, SEEK_SET);
109
109
 
110
110
    for (i=0; i<fields; i++)
111
111
        if (ape_tag_read_field(s) < 0) break;