diff options
author | Anton Khirnov <anton@khirnov.net> | 2011-01-21 19:18:07 +0000 |
---|---|---|
committer | Mans Rullgard <mans@mansr.com> | 2011-01-21 20:21:03 +0000 |
commit | 4efd5cf34b7a04f87805aa0f09913d1d122d300c (patch) | |
tree | fee5313b3fd0435d44cab3e47a5dde79e1405576 /libavformat | |
parent | 1c189fc5334d4a687b15861d81d22c8ba2c9cd5e (diff) | |
download | ffmpeg-4efd5cf34b7a04f87805aa0f09913d1d122d300c.tar.gz |
avio: add av_put_str and deprecate put_strz in favor of it
Signed-off-by: Mans Rullgard <mans@mansr.com>
Diffstat (limited to 'libavformat')
-rw-r--r-- | libavformat/avienc.c | 2 | ||||
-rw-r--r-- | libavformat/avio.h | 10 | ||||
-rw-r--r-- | libavformat/aviobuf.c | 16 | ||||
-rw-r--r-- | libavformat/ffmenc.c | 2 | ||||
-rw-r--r-- | libavformat/version.h | 3 |
5 files changed, 27 insertions, 6 deletions
diff --git a/libavformat/avienc.c b/libavformat/avienc.c index c9476d5b9f..98b0ad713c 100644 --- a/libavformat/avienc.c +++ b/libavformat/avienc.c @@ -109,7 +109,7 @@ static void avi_write_info_tag(ByteIOContext *pb, const char *tag, const char *s len++; put_tag(pb, tag); put_le32(pb, len); - put_strz(pb, str); + avio_put_str(pb, str); if (len & 1) put_byte(pb, 0); } diff --git a/libavformat/avio.h b/libavformat/avio.h index 198507e4a8..9f71c1921e 100644 --- a/libavformat/avio.h +++ b/libavformat/avio.h @@ -367,7 +367,15 @@ void put_le16(ByteIOContext *s, unsigned int val); void put_be16(ByteIOContext *s, unsigned int val); void put_tag(ByteIOContext *s, const char *tag); -void put_strz(ByteIOContext *s, const char *buf); +#if FF_API_OLD_AVIO +attribute_deprecated void put_strz(ByteIOContext *s, const char *buf); +#endif + +/** + * Write a NULL-terminated string. + * @return number of bytes written. + */ +int avio_put_str(ByteIOContext *s, const char *str); /** * fseek() equivalent for ByteIOContext. diff --git a/libavformat/aviobuf.c b/libavformat/aviobuf.c index df76507866..4f0c16c308 100644 --- a/libavformat/aviobuf.c +++ b/libavformat/aviobuf.c @@ -265,12 +265,22 @@ void put_be32(ByteIOContext *s, unsigned int val) put_byte(s, val); } +#if FF_API_OLD_AVIO void put_strz(ByteIOContext *s, const char *str) { - if (str) - put_buffer(s, (const unsigned char *) str, strlen(str) + 1); - else + avio_put_str(s, str); +} +#endif + +int avio_put_str(ByteIOContext *s, const char *str) +{ + int len = 1; + if (str) { + len += strlen(str); + put_buffer(s, (const unsigned char *) str, len); + } else put_byte(s, 0); + return len; } int ff_get_v_length(uint64_t val){ diff --git a/libavformat/ffmenc.c b/libavformat/ffmenc.c index c5c59db711..10c0f118a7 100644 --- a/libavformat/ffmenc.c +++ b/libavformat/ffmenc.c @@ -132,7 +132,7 @@ static int ffm_write_header(AVFormatContext *s) put_be16(pb, (int) (codec->qcompress * 10000.0)); put_be16(pb, (int) (codec->qblur * 10000.0)); put_be32(pb, codec->bit_rate_tolerance); - put_strz(pb, codec->rc_eq ? codec->rc_eq : "tex^qComp"); + avio_put_str(pb, codec->rc_eq ? codec->rc_eq : "tex^qComp"); put_be32(pb, codec->rc_max_rate); put_be32(pb, codec->rc_min_rate); put_be32(pb, codec->rc_buffer_size); diff --git a/libavformat/version.h b/libavformat/version.h index 8cea555c61..9a902aa4b4 100644 --- a/libavformat/version.h +++ b/libavformat/version.h @@ -86,5 +86,8 @@ #ifndef FF_API_SYMVER #define FF_API_SYMVER (LIBAVFORMAT_VERSION_MAJOR < 53) #endif +#ifndef FF_API_OLD_AVIO +#define FF_API_OLD_AVIO (LIBAVFORMAT_VERSION_MAJOR < 53) +#endif #endif //AVFORMAT_VERSION_H |