"Fossies" - the Fresh Open Source Software Archive  

Source code changes of the file "libavformat/apetag.c" between
libav-12.tar.gz and libav-12.1.tar.gz

About: libav provides cross-platform tools ("avconv") and libraries to convert, manipulate and stream a wide range of multimedia (audio and video) formats and protocols.

apetag.c  (libav-12):apetag.c  (libav-12.1)
skipping to change at line 34 skipping to change at line 34
#include "libavutil/intreadwrite.h" #include "libavutil/intreadwrite.h"
#include "libavutil/dict.h" #include "libavutil/dict.h"
#include "avformat.h" #include "avformat.h"
#include "avio_internal.h" #include "avio_internal.h"
#include "apetag.h" #include "apetag.h"
#include "internal.h" #include "internal.h"
#define APE_TAG_VERSION 2000 #define APE_TAG_VERSION 2000
#define APE_TAG_FOOTER_BYTES 32 #define APE_TAG_FOOTER_BYTES 32
#define APE_TAG_HEADER_BYTES 32
#define APE_TAG_FLAG_CONTAINS_HEADER (1 << 31) #define APE_TAG_FLAG_CONTAINS_HEADER (1 << 31)
#define APE_TAG_FLAG_CONTAINS_FOOTER (1 << 30) #define APE_TAG_FLAG_LACKS_FOOTER (1 << 30)
#define APE_TAG_FLAG_IS_HEADER (1 << 29) #define APE_TAG_FLAG_IS_HEADER (1 << 29)
#define APE_TAG_FLAG_IS_BINARY (1 << 1) #define APE_TAG_FLAG_IS_BINARY (1 << 1)
static int ape_tag_read_field(AVFormatContext *s) static int ape_tag_read_field(AVFormatContext *s)
{ {
AVIOContext *pb = s->pb; AVIOContext *pb = s->pb;
uint8_t key[1024], *value; uint8_t key[1024], *value;
int64_t size, flags; int64_t size, flags;
int i, c; int i, c;
skipping to change at line 157 skipping to change at line 158
tag_bytes = avio_rl32(pb); /* tag size */ tag_bytes = avio_rl32(pb); /* tag size */
if (tag_bytes - APE_TAG_FOOTER_BYTES > (1024 * 1024 * 16)) { if (tag_bytes - APE_TAG_FOOTER_BYTES > (1024 * 1024 * 16)) {
av_log(s, AV_LOG_ERROR, "Tag size is way too big\n"); av_log(s, AV_LOG_ERROR, "Tag size is way too big\n");
return 0; return 0;
} }
if (tag_bytes > file_size - APE_TAG_FOOTER_BYTES) { if (tag_bytes > file_size - APE_TAG_FOOTER_BYTES) {
av_log(s, AV_LOG_ERROR, "Invalid tag size %"PRIu32".\n", tag_bytes); av_log(s, AV_LOG_ERROR, "Invalid tag size %"PRIu32".\n", tag_bytes);
return 0; return 0;
} }
tag_start = file_size - tag_bytes - APE_TAG_FOOTER_BYTES;
fields = avio_rl32(pb); /* number of fields */ fields = avio_rl32(pb); /* number of fields */
if (fields > 65536) { if (fields > 65536) {
av_log(s, AV_LOG_ERROR, "Too many tag fields (%"PRIu32")\n", fields); av_log(s, AV_LOG_ERROR, "Too many tag fields (%"PRIu32")\n", fields);
return 0; return 0;
} }
val = avio_rl32(pb); /* flags */ val = avio_rl32(pb); /* flags */
if (val & APE_TAG_FLAG_IS_HEADER) { if (val & APE_TAG_FLAG_IS_HEADER) {
av_log(s, AV_LOG_ERROR, "APE Tag is a header\n"); av_log(s, AV_LOG_ERROR, "APE Tag is a header\n");
return 0; return 0;
} }
avio_seek(pb, file_size - tag_bytes, SEEK_SET); avio_seek(pb, file_size - tag_bytes, SEEK_SET);
if (val & APE_TAG_FLAG_CONTAINS_HEADER)
tag_bytes += APE_TAG_HEADER_BYTES;
tag_start = file_size - tag_bytes;
for (i=0; i<fields; i++) for (i=0; i<fields; i++)
if (ape_tag_read_field(s) < 0) break; if (ape_tag_read_field(s) < 0) break;
return tag_start; return tag_start;
} }
int ff_ape_write_tag(AVFormatContext *s) int ff_ape_write_tag(AVFormatContext *s)
{ {
AVDictionaryEntry *e = NULL; AVDictionaryEntry *e = NULL;
int64_t start, end; int64_t start, end;
skipping to change at line 197 skipping to change at line 202
start = avio_tell(s->pb); start = avio_tell(s->pb);
// header // header
avio_write(s->pb, "APETAGEX", 8); // id avio_write(s->pb, "APETAGEX", 8); // id
avio_wl32 (s->pb, APE_TAG_VERSION); // version avio_wl32 (s->pb, APE_TAG_VERSION); // version
avio_wl32(s->pb, 0); // reserve space for size avio_wl32(s->pb, 0); // reserve space for size
avio_wl32(s->pb, 0); // reserve space for tag count avio_wl32(s->pb, 0); // reserve space for tag count
// flags // flags
avio_wl32(s->pb, APE_TAG_FLAG_CONTAINS_HEADER | APE_TAG_FLAG_CONTAINS_FOOTER avio_wl32(s->pb, APE_TAG_FLAG_CONTAINS_HEADER | APE_TAG_FLAG_IS_HEADER);
|
APE_TAG_FLAG_IS_HEADER);
ffio_fill(s->pb, 0, 8); // reserved ffio_fill(s->pb, 0, 8); // reserved
while ((e = av_dict_get(s->metadata, "", e, AV_DICT_IGNORE_SUFFIX))) { while ((e = av_dict_get(s->metadata, "", e, AV_DICT_IGNORE_SUFFIX))) {
int val_len = strlen(e->value); int val_len = strlen(e->value);
avio_wl32(s->pb, val_len); // value length avio_wl32(s->pb, val_len); // value length
avio_wl32(s->pb, 0); // item flags avio_wl32(s->pb, 0); // item flags
avio_put_str(s->pb, e->key); // key avio_put_str(s->pb, e->key); // key
avio_write(s->pb, e->value, val_len); // value avio_write(s->pb, e->value, val_len); // value
count++; count++;
skipping to change at line 220 skipping to change at line 224
size = avio_tell(s->pb) - start; size = avio_tell(s->pb) - start;
// footer // footer
avio_write(s->pb, "APETAGEX", 8); // id avio_write(s->pb, "APETAGEX", 8); // id
avio_wl32 (s->pb, APE_TAG_VERSION); // version avio_wl32 (s->pb, APE_TAG_VERSION); // version
avio_wl32(s->pb, size); // size avio_wl32(s->pb, size); // size
avio_wl32(s->pb, count); // tag count avio_wl32(s->pb, count); // tag count
// flags // flags
avio_wl32(s->pb, APE_TAG_FLAG_CONTAINS_HEADER | APE_TAG_FLAG_CONTAINS_FOOTER ); avio_wl32(s->pb, APE_TAG_FLAG_CONTAINS_HEADER);
ffio_fill(s->pb, 0, 8); // reserved ffio_fill(s->pb, 0, 8); // reserved
// update values in the header // update values in the header
end = avio_tell(s->pb); end = avio_tell(s->pb);
avio_seek(s->pb, start + 12, SEEK_SET); avio_seek(s->pb, start + 12, SEEK_SET);
avio_wl32(s->pb, size); avio_wl32(s->pb, size);
avio_wl32(s->pb, count); avio_wl32(s->pb, count);
avio_seek(s->pb, end, SEEK_SET); avio_seek(s->pb, end, SEEK_SET);
return 0; return 0;
 End of changes. 6 change blocks. 
6 lines changed or deleted 9 lines changed or added

Home  |  About  |  All  |  Newest  |  Fossies Dox  |  Screenshots  |  Comments  |  Imprint  |  Privacy  |  HTTPS