Mercurial > libavformat.hg
changeset 1256:2cddf00f92a6 libavformat
AVI tag reading and writing patch by David Conrad.
umovimus at gmail dot com
author | banan |
---|---|
date | Fri, 18 Aug 2006 16:48:35 +0000 |
parents | 12058d7c6d57 |
children | 6c654821b0ae |
files | avidec.c avienc.c |
diffstat | 2 files changed, 55 insertions(+), 0 deletions(-) [+] |
line wrap: on
line diff
--- a/avidec.c Fri Aug 18 07:55:08 2006 +0000 +++ b/avidec.c Fri Aug 18 16:48:35 2006 +0000 @@ -180,6 +180,15 @@ } } +static int avi_read_tag(ByteIOContext *pb, char *buf, int maxlen, unsigned int size) +{ + offset_t i = url_ftell(pb); + size += (size & 1); + get_strz(pb, buf, maxlen); + url_fseek(pb, i+size, SEEK_SET); + return 0; +} + static int avi_read_header(AVFormatContext *s, AVFormatParameters *ap) { AVIContext *avi = s->priv_data; @@ -438,6 +447,21 @@ } url_fseek(pb, i+size, SEEK_SET); break; + case MKTAG('I', 'N', 'A', 'M'): + avi_read_tag(pb, s->title, sizeof(s->title), size); + break; + case MKTAG('I', 'A', 'R', 'T'): + avi_read_tag(pb, s->author, sizeof(s->author), size); + break; + case MKTAG('I', 'C', 'O', 'P'): + avi_read_tag(pb, s->copyright, sizeof(s->copyright), size); + break; + case MKTAG('I', 'C', 'M', 'T'): + avi_read_tag(pb, s->comment, sizeof(s->comment), size); + break; + case MKTAG('I', 'G', 'N', 'R'): + avi_read_tag(pb, s->genre, sizeof(s->genre), size); + break; default: /* skip tag */ size += (size & 1);
--- a/avienc.c Fri Aug 18 07:55:08 2006 +0000 +++ b/avienc.c Fri Aug 18 16:48:35 2006 +0000 @@ -89,6 +89,19 @@ return tag; } +static void avi_write_info_tag(ByteIOContext *pb, const char *tag, const char *str) +{ + int len = strlen(str); + if (len > 0) { + len++; + put_tag(pb, tag); + put_le32(pb, len); + put_strz(pb, str); + if (len & 1) + put_byte(pb, 0); + } +} + static int avi_write_header(AVFormatContext *s) { AVIContext *avi = s->priv_data; @@ -258,6 +271,24 @@ end_tag(pb, list1); + list2 = start_tag(pb, "LIST"); + put_tag(pb, "INFO"); + avi_write_info_tag(pb, "INAM", s->title); + avi_write_info_tag(pb, "IART", s->author); + avi_write_info_tag(pb, "ICOP", s->copyright); + avi_write_info_tag(pb, "ICMT", s->comment); + avi_write_info_tag(pb, "IPRD", s->album); + avi_write_info_tag(pb, "IGNR", s->genre); + if(!(s->streams[0]->codec->flags & CODEC_FLAG_BITEXACT)) + avi_write_info_tag(pb, "ISFT", LIBAVFORMAT_IDENT); + end_tag(pb, list2); + + /* some padding for easier tag editing */ + list2 = start_tag(pb, "JUNK"); + for (i = 0; i < 1016; i += 4) + put_le32(pb, 0); + end_tag(pb, list2); + avi->movi_list = start_tag(pb, "LIST"); put_tag(pb, "movi");