summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--libavformat/asf.c17
-rw-r--r--libavformat/asf.h1
-rw-r--r--libavformat/asfenc.c6
-rw-r--r--libavformat/avio.h6
-rw-r--r--libavformat/aviobuf.c17
-rw-r--r--libavformat/mmst.c3
6 files changed, 27 insertions, 23 deletions
diff --git a/libavformat/asf.c b/libavformat/asf.c
index 58e17e9cef..e6659923d7 100644
--- a/libavformat/asf.c
+++ b/libavformat/asf.c
@@ -156,20 +156,3 @@ const AVMetadataConv ff_asf_metadata_conv[] = {
// { "Year" , "date" }, TODO: conversion year<->date
{ 0 }
};
-
-int ff_put_str16_nolen(ByteIOContext *s, const char *tag)
-{
- const uint8_t *q = tag;
- int ret = 0;
-
- while (*q) {
- uint32_t ch;
- uint16_t tmp;
-
- GET_UTF8(ch, *q++, break;)
- PUT_UTF16(ch, tmp, put_le16(s, tmp);ret += 2;)
- }
- put_le16(s, 0);
- ret += 2;
- return ret;
-}
diff --git a/libavformat/asf.h b/libavformat/asf.h
index f3705e946a..8cf517dd14 100644
--- a/libavformat/asf.h
+++ b/libavformat/asf.h
@@ -230,7 +230,6 @@ extern const AVMetadataConv ff_asf_metadata_conv[];
#define ASF_PL_FLAG_KEY_FRAME 0x80 //1000 0000
extern AVInputFormat asf_demuxer;
-int ff_put_str16_nolen(ByteIOContext *s, const char *tag);
int ff_guidcmp(const void *g1, const void *g2);
void ff_get_guid(ByteIOContext *s, ff_asf_guid *g);
diff --git a/libavformat/asfenc.c b/libavformat/asfenc.c
index b964953b2b..0c2a6ae94a 100644
--- a/libavformat/asfenc.c
+++ b/libavformat/asfenc.c
@@ -211,7 +211,7 @@ static void put_str16(ByteIOContext *s, const char *tag)
if (url_open_dyn_buf(&dyn_buf) < 0)
return;
- ff_put_str16_nolen(dyn_buf, tag);
+ avio_put_str16le(dyn_buf, tag);
len = url_close_dyn_buf(dyn_buf, &pb);
put_le16(s, len);
put_buffer(s, pb, len);
@@ -346,7 +346,7 @@ static int asf_write_header1(AVFormatContext *s, int64_t file_size, int64_t data
hpos = put_header(pb, &ff_asf_comment_header);
for (n = 0; n < FF_ARRAY_ELEMS(tags); n++) {
- len = tags[n] ? ff_put_str16_nolen(dyn_buf, tags[n]->value) : 0;
+ len = tags[n] ? avio_put_str16le(dyn_buf, tags[n]->value) : 0;
put_le16(pb, len);
}
len = url_close_dyn_buf(dyn_buf, &buf);
@@ -474,7 +474,7 @@ static int asf_write_header1(AVFormatContext *s, int64_t file_size, int64_t data
if ( url_open_dyn_buf(&dyn_buf) < 0)
return AVERROR(ENOMEM);
- ff_put_str16_nolen(dyn_buf, desc);
+ avio_put_str16le(dyn_buf, desc);
len = url_close_dyn_buf(dyn_buf, &buf);
put_le16(pb, len / 2); // "number of characters" = length in bytes / 2
diff --git a/libavformat/avio.h b/libavformat/avio.h
index 9f71c1921e..b35d4c716c 100644
--- a/libavformat/avio.h
+++ b/libavformat/avio.h
@@ -378,6 +378,12 @@ attribute_deprecated void put_strz(ByteIOContext *s, const char *buf);
int avio_put_str(ByteIOContext *s, const char *str);
/**
+ * Convert an UTF-8 string to UTF-16LE and write it.
+ * @return number of bytes written.
+ */
+int avio_put_str16le(ByteIOContext *s, const char *str);
+
+/**
* fseek() equivalent for ByteIOContext.
* @return new position or AVERROR.
*/
diff --git a/libavformat/aviobuf.c b/libavformat/aviobuf.c
index 4f0c16c308..5aeced1b9f 100644
--- a/libavformat/aviobuf.c
+++ b/libavformat/aviobuf.c
@@ -283,6 +283,23 @@ int avio_put_str(ByteIOContext *s, const char *str)
return len;
}
+int avio_put_str16le(ByteIOContext *s, const char *str)
+{
+ const uint8_t *q = str;
+ int ret = 0;
+
+ while (*q) {
+ uint32_t ch;
+ uint16_t tmp;
+
+ GET_UTF8(ch, *q++, break;)
+ PUT_UTF16(ch, tmp, put_le16(s, tmp);ret += 2;)
+ }
+ put_le16(s, 0);
+ ret += 2;
+ return ret;
+}
+
int ff_get_v_length(uint64_t val){
int i=1;
diff --git a/libavformat/mmst.c b/libavformat/mmst.c
index 57cca5d0d4..08e3b3e660 100644
--- a/libavformat/mmst.c
+++ b/libavformat/mmst.c
@@ -34,7 +34,6 @@
#include "libavutil/intreadwrite.h"
#include "libavcodec/bytestream.h"
#include "network.h"
-#include "asf.h"
#define LOCAL_ADDRESS 0xc0a80081 // FIXME get and use correct local ip address.
#define LOCAL_PORT 1037 // as above.
@@ -159,7 +158,7 @@ static void mms_put_utf16(MMSContext *mms, uint8_t *src)
init_put_byte(&bic, mms->write_out_ptr,
sizeof(mms->out_buffer) - size, 1, NULL, NULL, NULL, NULL);
- len = ff_put_str16_nolen(&bic, src);
+ len = avio_put_str16le(&bic, src);
mms->write_out_ptr += len;
}