| OLD | NEW |
| 1 /* | 1 /* |
| 2 * VorbisComment writer | 2 * VorbisComment writer |
| 3 * Copyright (c) 2009 James Darnley | 3 * Copyright (c) 2009 James Darnley |
| 4 * | 4 * |
| 5 * This file is part of FFmpeg. | 5 * This file is part of FFmpeg. |
| 6 * | 6 * |
| 7 * FFmpeg is free software; you can redistribute it and/or | 7 * FFmpeg is free software; you can redistribute it and/or |
| 8 * modify it under the terms of the GNU Lesser General Public | 8 * modify it under the terms of the GNU Lesser General Public |
| 9 * License as published by the Free Software Foundation; either | 9 * License as published by the Free Software Foundation; either |
| 10 * version 2.1 of the License, or (at your option) any later version. | 10 * version 2.1 of the License, or (at your option) any later version. |
| (...skipping 25 matching lines...) Expand all Loading... |
| 36 }; | 36 }; |
| 37 | 37 |
| 38 int ff_vorbiscomment_length(AVMetadata *m, const char *vendor_string, | 38 int ff_vorbiscomment_length(AVMetadata *m, const char *vendor_string, |
| 39 unsigned *count) | 39 unsigned *count) |
| 40 { | 40 { |
| 41 int len = 8; | 41 int len = 8; |
| 42 len += strlen(vendor_string); | 42 len += strlen(vendor_string); |
| 43 *count = 0; | 43 *count = 0; |
| 44 if (m) { | 44 if (m) { |
| 45 AVMetadataTag *tag = NULL; | 45 AVMetadataTag *tag = NULL; |
| 46 while ( (tag = av_metadata_get(m, "", tag, AV_METADATA_IGNORE_SUFFIX) )
) { | 46 while ((tag = av_metadata_get(m, "", tag, AV_METADATA_IGNORE_SUFFIX))) { |
| 47 len += 4 +strlen(tag->key) + 1 + strlen(tag->value); | 47 len += 4 +strlen(tag->key) + 1 + strlen(tag->value); |
| 48 (*count)++; | 48 (*count)++; |
| 49 } | 49 } |
| 50 } | 50 } |
| 51 return len; | 51 return len; |
| 52 } | 52 } |
| 53 | 53 |
| 54 int ff_vorbiscomment_write(uint8_t **p, AVMetadata *m, | 54 int ff_vorbiscomment_write(uint8_t **p, AVMetadata *m, |
| 55 const char *vendor_string, const unsigned count) | 55 const char *vendor_string, const unsigned count) |
| 56 { | 56 { |
| 57 bytestream_put_le32(p, strlen(vendor_string)); | 57 bytestream_put_le32(p, strlen(vendor_string)); |
| 58 bytestream_put_buffer(p, vendor_string, strlen(vendor_string)); | 58 bytestream_put_buffer(p, vendor_string, strlen(vendor_string)); |
| 59 if (m) { | 59 if (m) { |
| 60 AVMetadataTag *tag = NULL; | 60 AVMetadataTag *tag = NULL; |
| 61 bytestream_put_le32(p, count); | 61 bytestream_put_le32(p, count); |
| 62 while ( (tag = av_metadata_get(m, "", tag, AV_METADATA_IGNORE_SUFFIX) )
) { | 62 while ((tag = av_metadata_get(m, "", tag, AV_METADATA_IGNORE_SUFFIX))) { |
| 63 unsigned int len1 = strlen(tag->key); | 63 unsigned int len1 = strlen(tag->key); |
| 64 unsigned int len2 = strlen(tag->value); | 64 unsigned int len2 = strlen(tag->value); |
| 65 bytestream_put_le32(p, len1+1+len2); | 65 bytestream_put_le32(p, len1+1+len2); |
| 66 bytestream_put_buffer(p, tag->key, len1); | 66 bytestream_put_buffer(p, tag->key, len1); |
| 67 bytestream_put_byte(p, '='); | 67 bytestream_put_byte(p, '='); |
| 68 bytestream_put_buffer(p, tag->value, len2); | 68 bytestream_put_buffer(p, tag->value, len2); |
| 69 } | 69 } |
| 70 } else | 70 } else |
| 71 bytestream_put_le32(p, 0); | 71 bytestream_put_le32(p, 0); |
| 72 return 0; | 72 return 0; |
| 73 } | 73 } |
| OLD | NEW |