annotate vorbiscomment.c @ 6201:f5cb0b79f58c libavformat

Make "invalid dts/pts combination" a debug instead of a warning message. Patch by XBMC
author cehoyos
date Wed, 30 Jun 2010 23:01:44 +0000
parents 121d6994c20e
children a8abcc0f32cf
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
5857
121d6994c20e Add VorbisComment writing to FLAC files.
jbr
parents:
diff changeset
1 /*
121d6994c20e Add VorbisComment writing to FLAC files.
jbr
parents:
diff changeset
2 * VorbisComment writer
121d6994c20e Add VorbisComment writing to FLAC files.
jbr
parents:
diff changeset
3 * Copyright (c) 2009 James Darnley
121d6994c20e Add VorbisComment writing to FLAC files.
jbr
parents:
diff changeset
4 *
121d6994c20e Add VorbisComment writing to FLAC files.
jbr
parents:
diff changeset
5 * This file is part of FFmpeg.
121d6994c20e Add VorbisComment writing to FLAC files.
jbr
parents:
diff changeset
6 *
121d6994c20e Add VorbisComment writing to FLAC files.
jbr
parents:
diff changeset
7 * FFmpeg is free software; you can redistribute it and/or
121d6994c20e Add VorbisComment writing to FLAC files.
jbr
parents:
diff changeset
8 * modify it under the terms of the GNU Lesser General Public
121d6994c20e Add VorbisComment writing to FLAC files.
jbr
parents:
diff changeset
9 * License as published by the Free Software Foundation; either
121d6994c20e Add VorbisComment writing to FLAC files.
jbr
parents:
diff changeset
10 * version 2.1 of the License, or (at your option) any later version.
121d6994c20e Add VorbisComment writing to FLAC files.
jbr
parents:
diff changeset
11 *
121d6994c20e Add VorbisComment writing to FLAC files.
jbr
parents:
diff changeset
12 * FFmpeg is distributed in the hope that it will be useful,
121d6994c20e Add VorbisComment writing to FLAC files.
jbr
parents:
diff changeset
13 * but WITHOUT ANY WARRANTY; without even the implied warranty of
121d6994c20e Add VorbisComment writing to FLAC files.
jbr
parents:
diff changeset
14 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
121d6994c20e Add VorbisComment writing to FLAC files.
jbr
parents:
diff changeset
15 * Lesser General Public License for more details.
121d6994c20e Add VorbisComment writing to FLAC files.
jbr
parents:
diff changeset
16 *
121d6994c20e Add VorbisComment writing to FLAC files.
jbr
parents:
diff changeset
17 * You should have received a copy of the GNU Lesser General Public
121d6994c20e Add VorbisComment writing to FLAC files.
jbr
parents:
diff changeset
18 * License along with FFmpeg; if not, write to the Free Software
121d6994c20e Add VorbisComment writing to FLAC files.
jbr
parents:
diff changeset
19 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
121d6994c20e Add VorbisComment writing to FLAC files.
jbr
parents:
diff changeset
20 */
121d6994c20e Add VorbisComment writing to FLAC files.
jbr
parents:
diff changeset
21
121d6994c20e Add VorbisComment writing to FLAC files.
jbr
parents:
diff changeset
22 #include "avformat.h"
121d6994c20e Add VorbisComment writing to FLAC files.
jbr
parents:
diff changeset
23 #include "metadata.h"
121d6994c20e Add VorbisComment writing to FLAC files.
jbr
parents:
diff changeset
24 #include "vorbiscomment.h"
121d6994c20e Add VorbisComment writing to FLAC files.
jbr
parents:
diff changeset
25 #include "libavcodec/bytestream.h"
121d6994c20e Add VorbisComment writing to FLAC files.
jbr
parents:
diff changeset
26
121d6994c20e Add VorbisComment writing to FLAC files.
jbr
parents:
diff changeset
27 /**
121d6994c20e Add VorbisComment writing to FLAC files.
jbr
parents:
diff changeset
28 * VorbisComment metadata conversion mapping.
121d6994c20e Add VorbisComment writing to FLAC files.
jbr
parents:
diff changeset
29 * from Ogg Vorbis I format specification: comment field and header specification
121d6994c20e Add VorbisComment writing to FLAC files.
jbr
parents:
diff changeset
30 * http://xiph.org/vorbis/doc/v-comment.html
121d6994c20e Add VorbisComment writing to FLAC files.
jbr
parents:
diff changeset
31 */
121d6994c20e Add VorbisComment writing to FLAC files.
jbr
parents:
diff changeset
32 const AVMetadataConv ff_vorbiscomment_metadata_conv[] = {
121d6994c20e Add VorbisComment writing to FLAC files.
jbr
parents:
diff changeset
33 { "ALBUMARTIST", "album_artist"},
121d6994c20e Add VorbisComment writing to FLAC files.
jbr
parents:
diff changeset
34 { "TRACKNUMBER", "track" },
121d6994c20e Add VorbisComment writing to FLAC files.
jbr
parents:
diff changeset
35 { 0 }
121d6994c20e Add VorbisComment writing to FLAC files.
jbr
parents:
diff changeset
36 };
121d6994c20e Add VorbisComment writing to FLAC files.
jbr
parents:
diff changeset
37
121d6994c20e Add VorbisComment writing to FLAC files.
jbr
parents:
diff changeset
38 int ff_vorbiscomment_length(AVMetadata *m, const char *vendor_string,
121d6994c20e Add VorbisComment writing to FLAC files.
jbr
parents:
diff changeset
39 unsigned *count)
121d6994c20e Add VorbisComment writing to FLAC files.
jbr
parents:
diff changeset
40 {
121d6994c20e Add VorbisComment writing to FLAC files.
jbr
parents:
diff changeset
41 int len = 8;
121d6994c20e Add VorbisComment writing to FLAC files.
jbr
parents:
diff changeset
42 len += strlen(vendor_string);
121d6994c20e Add VorbisComment writing to FLAC files.
jbr
parents:
diff changeset
43 *count = 0;
121d6994c20e Add VorbisComment writing to FLAC files.
jbr
parents:
diff changeset
44 if (m) {
121d6994c20e Add VorbisComment writing to FLAC files.
jbr
parents:
diff changeset
45 AVMetadataTag *tag = NULL;
121d6994c20e Add VorbisComment writing to FLAC files.
jbr
parents:
diff changeset
46 while ( (tag = av_metadata_get(m, "", tag, AV_METADATA_IGNORE_SUFFIX) ) ) {
121d6994c20e Add VorbisComment writing to FLAC files.
jbr
parents:
diff changeset
47 len += 4 +strlen(tag->key) + 1 + strlen(tag->value);
121d6994c20e Add VorbisComment writing to FLAC files.
jbr
parents:
diff changeset
48 (*count)++;
121d6994c20e Add VorbisComment writing to FLAC files.
jbr
parents:
diff changeset
49 }
121d6994c20e Add VorbisComment writing to FLAC files.
jbr
parents:
diff changeset
50 }
121d6994c20e Add VorbisComment writing to FLAC files.
jbr
parents:
diff changeset
51 return len;
121d6994c20e Add VorbisComment writing to FLAC files.
jbr
parents:
diff changeset
52 }
121d6994c20e Add VorbisComment writing to FLAC files.
jbr
parents:
diff changeset
53
121d6994c20e Add VorbisComment writing to FLAC files.
jbr
parents:
diff changeset
54 int ff_vorbiscomment_write(uint8_t **p, AVMetadata *m,
121d6994c20e Add VorbisComment writing to FLAC files.
jbr
parents:
diff changeset
55 const char *vendor_string, const unsigned count)
121d6994c20e Add VorbisComment writing to FLAC files.
jbr
parents:
diff changeset
56 {
121d6994c20e Add VorbisComment writing to FLAC files.
jbr
parents:
diff changeset
57 bytestream_put_le32(p, strlen(vendor_string));
121d6994c20e Add VorbisComment writing to FLAC files.
jbr
parents:
diff changeset
58 bytestream_put_buffer(p, vendor_string, strlen(vendor_string));
121d6994c20e Add VorbisComment writing to FLAC files.
jbr
parents:
diff changeset
59 if (m) {
121d6994c20e Add VorbisComment writing to FLAC files.
jbr
parents:
diff changeset
60 AVMetadataTag *tag = NULL;
121d6994c20e Add VorbisComment writing to FLAC files.
jbr
parents:
diff changeset
61 bytestream_put_le32(p, count);
121d6994c20e Add VorbisComment writing to FLAC files.
jbr
parents:
diff changeset
62 while ( (tag = av_metadata_get(m, "", tag, AV_METADATA_IGNORE_SUFFIX) ) ) {
121d6994c20e Add VorbisComment writing to FLAC files.
jbr
parents:
diff changeset
63 unsigned int len1 = strlen(tag->key);
121d6994c20e Add VorbisComment writing to FLAC files.
jbr
parents:
diff changeset
64 unsigned int len2 = strlen(tag->value);
121d6994c20e Add VorbisComment writing to FLAC files.
jbr
parents:
diff changeset
65 bytestream_put_le32(p, len1+1+len2);
121d6994c20e Add VorbisComment writing to FLAC files.
jbr
parents:
diff changeset
66 bytestream_put_buffer(p, tag->key, len1);
121d6994c20e Add VorbisComment writing to FLAC files.
jbr
parents:
diff changeset
67 bytestream_put_byte(p, '=');
121d6994c20e Add VorbisComment writing to FLAC files.
jbr
parents:
diff changeset
68 bytestream_put_buffer(p, tag->value, len2);
121d6994c20e Add VorbisComment writing to FLAC files.
jbr
parents:
diff changeset
69 }
121d6994c20e Add VorbisComment writing to FLAC files.
jbr
parents:
diff changeset
70 } else
121d6994c20e Add VorbisComment writing to FLAC files.
jbr
parents:
diff changeset
71 bytestream_put_le32(p, 0);
121d6994c20e Add VorbisComment writing to FLAC files.
jbr
parents:
diff changeset
72 return 0;
121d6994c20e Add VorbisComment writing to FLAC files.
jbr
parents:
diff changeset
73 }