From db52f056c3d26c59feb9156a9deeaf8e0089b86e Mon Sep 17 00:00:00 2001 From: John Stebbins Date: Mon, 3 Mar 2014 20:20:15 +0000 Subject: [PATCH 1/3] movenc: allow override of "writing application" tag Signed-off-by: Tim Walker CC: libav-stable@libav.org (cherry picked from commit 565e0c6d866ce08d4b06427456d3d1f4fd856e9c) --- libavformat/movenc.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/libavformat/movenc.c b/libavformat/movenc.c index 85b5667076..0b774f54bf 100644 --- a/libavformat/movenc.c +++ b/libavformat/movenc.c @@ -1626,7 +1626,8 @@ static int mov_write_ilst_tag(AVIOContext *pb, MOVMuxContext *mov, mov_write_string_metadata(s, pb, "\251wrt", "composer" , 1); mov_write_string_metadata(s, pb, "\251alb", "album" , 1); mov_write_string_metadata(s, pb, "\251day", "date" , 1); - mov_write_string_tag(pb, "\251too", LIBAVFORMAT_IDENT, 0, 1); + if (!mov_write_string_metadata(s, pb, "\251too", "encoding_tool", 1)) + mov_write_string_tag(pb, "\251too", LIBAVFORMAT_IDENT, 0, 1); mov_write_string_metadata(s, pb, "\251cmt", "comment" , 1); mov_write_string_metadata(s, pb, "\251gen", "genre" , 1); mov_write_string_metadata(s, pb, "\251cpy", "copyright", 1); From b473fdcde329dfbe6d099247f65f51436a49e8c6 Mon Sep 17 00:00:00 2001 From: Paul B Mahol Date: Wed, 21 Mar 2012 00:10:18 +0000 Subject: [PATCH 2/3] bytestream: add functions for accessing size of buffer Signed-off-by: Paul B Mahol Signed-off-by: Michael Niedermayer Signed-off-by: Justin Ruggles CC:libav-stable@libav.org (cherry picked from commit de9d2705f61ef569487ec5f8974a9c7ce34ec783) --- libavcodec/bytestream.h | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/libavcodec/bytestream.h b/libavcodec/bytestream.h index 68146200ae..091cab8c8e 100644 --- a/libavcodec/bytestream.h +++ b/libavcodec/bytestream.h @@ -198,6 +198,16 @@ static av_always_inline int bytestream2_tell_p(PutByteContext *p) return (int)(p->buffer - p->buffer_start); } +static av_always_inline int bytestream2_size(GetByteContext *g) +{ + return (int)(g->buffer_end - g->buffer_start); +} + +static av_always_inline int bytestream2_size_p(PutByteContext *p) +{ + return (int)(p->buffer_end - p->buffer_start); +} + static av_always_inline int bytestream2_seek(GetByteContext *g, int offset, int whence) From fa60904ebd58da33abf10b05e9933d24619cf096 Mon Sep 17 00:00:00 2001 From: Justin Ruggles Date: Sun, 29 Sep 2013 19:45:57 -0400 Subject: [PATCH 3/3] bytestream: add bytestream2_copy_buffer() functions This is basically an overread/overwrite-safe memcpy between a GetByteContext and a PutByteContext. CC:libav-stable@libav.org (cherry picked from commit 5748faf291fec297ef25d81962b52b3438f54278) --- libavcodec/bytestream.h | 26 ++++++++++++++++++++++++++ 1 file changed, 26 insertions(+) diff --git a/libavcodec/bytestream.h b/libavcodec/bytestream.h index 091cab8c8e..617724139a 100644 --- a/libavcodec/bytestream.h +++ b/libavcodec/bytestream.h @@ -333,6 +333,32 @@ static av_always_inline unsigned int bytestream2_get_eof(PutByteContext *p) return p->eof; } +static av_always_inline unsigned int bytestream2_copy_bufferu(PutByteContext *p, + GetByteContext *g, + unsigned int size) +{ + memcpy(p->buffer, g->buffer, size); + p->buffer += size; + g->buffer += size; + return size; +} + +static av_always_inline unsigned int bytestream2_copy_buffer(PutByteContext *p, + GetByteContext *g, + unsigned int size) +{ + int size2; + + if (p->eof) + return 0; + size = FFMIN(g->buffer_end - g->buffer, size); + size2 = FFMIN(p->buffer_end - p->buffer, size); + if (size2 != size) + p->eof = 1; + + return bytestream2_copy_bufferu(p, g, size2); +} + static av_always_inline unsigned int bytestream_get_buffer(const uint8_t **b, uint8_t *dst, unsigned int size)