mirror of https://git.ffmpeg.org/ffmpeg.git
use new metadata API in ape demuxer
Originally committed as revision 17388 to svn://svn.ffmpeg.org/ffmpeg/trunk
This commit is contained in:
parent
649c171aec
commit
3f9867b150
|
@ -48,24 +48,6 @@
|
||||||
#define APE_TAG_FLAG_CONTAINS_HEADER (1 << 31)
|
#define APE_TAG_FLAG_CONTAINS_HEADER (1 << 31)
|
||||||
#define APE_TAG_FLAG_IS_HEADER (1 << 29)
|
#define APE_TAG_FLAG_IS_HEADER (1 << 29)
|
||||||
|
|
||||||
#define TAG(name, field) {name, offsetof(AVFormatContext, field), sizeof(((AVFormatContext *)0)->field)}
|
|
||||||
|
|
||||||
static const struct {
|
|
||||||
const char *name;
|
|
||||||
int offset;
|
|
||||||
int size;
|
|
||||||
} tags[] = {
|
|
||||||
TAG("Title" , title ),
|
|
||||||
TAG("Artist" , author ),
|
|
||||||
TAG("Copyright", copyright),
|
|
||||||
TAG("Comment" , comment ),
|
|
||||||
TAG("Album" , album ),
|
|
||||||
TAG("Year" , year ),
|
|
||||||
TAG("Track" , track ),
|
|
||||||
TAG("Genre" , genre ),
|
|
||||||
{ NULL }
|
|
||||||
};
|
|
||||||
|
|
||||||
typedef struct {
|
typedef struct {
|
||||||
int64_t pos;
|
int64_t pos;
|
||||||
int nblocks;
|
int nblocks;
|
||||||
|
@ -112,34 +94,24 @@ typedef struct {
|
||||||
static void ape_tag_read_field(AVFormatContext *s)
|
static void ape_tag_read_field(AVFormatContext *s)
|
||||||
{
|
{
|
||||||
ByteIOContext *pb = s->pb;
|
ByteIOContext *pb = s->pb;
|
||||||
uint8_t buf[1024];
|
uint8_t key[1024], value[1024];
|
||||||
uint32_t size;
|
uint32_t size;
|
||||||
int i;
|
int i, l;
|
||||||
|
|
||||||
memset(buf, 0, 1024);
|
|
||||||
size = get_le32(pb); /* field size */
|
size = get_le32(pb); /* field size */
|
||||||
url_fskip(pb, 4); /* skip field flags */
|
url_fskip(pb, 4); /* skip field flags */
|
||||||
|
|
||||||
for (i=0; pb->buf_ptr[i]!='0' && pb->buf_ptr[i]>=0x20 && pb->buf_ptr[i]<=0x7E; i++);
|
for (i=0; pb->buf_ptr[i]!='0' && pb->buf_ptr[i]>=0x20 && pb->buf_ptr[i]<=0x7E; i++);
|
||||||
|
|
||||||
get_buffer(pb, buf, FFMIN(i, 1024));
|
l = FFMIN(i, sizeof(key) -1);
|
||||||
url_fskip(pb, 1);
|
get_buffer(pb, key, l);
|
||||||
|
key[l] = 0;
|
||||||
for (i=0; tags[i].name; i++)
|
url_fskip(pb, 1 + i-l);
|
||||||
if (!strcmp (buf, tags[i].name)) {
|
l = FFMIN(size, sizeof(value)-1);
|
||||||
if (tags[i].size == sizeof(int)) {
|
get_buffer(pb, value, l);
|
||||||
char tmp[16];
|
value[l] = 0;
|
||||||
get_buffer(pb, tmp, FFMIN(sizeof(tmp), size));
|
url_fskip(pb, size-l);
|
||||||
*(int *)(((char *)s)+tags[i].offset) = atoi(tmp);
|
av_metadata_set(&s->metadata, key, value);
|
||||||
} else {
|
|
||||||
get_buffer(pb, ((char *)s) + tags[i].offset,
|
|
||||||
FFMIN(tags[i].size, size));
|
|
||||||
}
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (!tags[i].name)
|
|
||||||
url_fskip(pb, size);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
static void ape_parse_tag(AVFormatContext *s)
|
static void ape_parse_tag(AVFormatContext *s)
|
||||||
|
|
Loading…
Reference in New Issue