It will be useful in the mp3 muxer.
Signed-off-by: Mans Rullgard <mans@mansr.com>
(cherry picked from commit dccbd97d72991f4df63542e1ee03db2f8d7a0238)
... | ... |
@@ -156,20 +156,3 @@ const AVMetadataConv ff_asf_metadata_conv[] = { |
156 | 156 |
// { "Year" , "date" }, TODO: conversion year<->date |
157 | 157 |
{ 0 } |
158 | 158 |
}; |
159 |
- |
|
160 |
-int ff_put_str16_nolen(ByteIOContext *s, const char *tag) |
|
161 |
-{ |
|
162 |
- const uint8_t *q = tag; |
|
163 |
- int ret = 0; |
|
164 |
- |
|
165 |
- while (*q) { |
|
166 |
- uint32_t ch; |
|
167 |
- uint16_t tmp; |
|
168 |
- |
|
169 |
- GET_UTF8(ch, *q++, break;) |
|
170 |
- PUT_UTF16(ch, tmp, put_le16(s, tmp);ret += 2;) |
|
171 |
- } |
|
172 |
- put_le16(s, 0); |
|
173 |
- ret += 2; |
|
174 |
- return ret; |
|
175 |
-} |
... | ... |
@@ -230,7 +230,6 @@ extern const AVMetadataConv ff_asf_metadata_conv[]; |
230 | 230 |
#define ASF_PL_FLAG_KEY_FRAME 0x80 //1000 0000 |
231 | 231 |
|
232 | 232 |
extern AVInputFormat asf_demuxer; |
233 |
-int ff_put_str16_nolen(ByteIOContext *s, const char *tag); |
|
234 | 233 |
int ff_guidcmp(const void *g1, const void *g2); |
235 | 234 |
void ff_get_guid(ByteIOContext *s, ff_asf_guid *g); |
236 | 235 |
|
... | ... |
@@ -211,7 +211,7 @@ static void put_str16(ByteIOContext *s, const char *tag) |
211 | 211 |
if (url_open_dyn_buf(&dyn_buf) < 0) |
212 | 212 |
return; |
213 | 213 |
|
214 |
- ff_put_str16_nolen(dyn_buf, tag); |
|
214 |
+ avio_put_str16le(dyn_buf, tag); |
|
215 | 215 |
len = url_close_dyn_buf(dyn_buf, &pb); |
216 | 216 |
put_le16(s, len); |
217 | 217 |
put_buffer(s, pb, len); |
... | ... |
@@ -346,7 +346,7 @@ static int asf_write_header1(AVFormatContext *s, int64_t file_size, int64_t data |
346 | 346 |
hpos = put_header(pb, &ff_asf_comment_header); |
347 | 347 |
|
348 | 348 |
for (n = 0; n < FF_ARRAY_ELEMS(tags); n++) { |
349 |
- len = tags[n] ? ff_put_str16_nolen(dyn_buf, tags[n]->value) : 0; |
|
349 |
+ len = tags[n] ? avio_put_str16le(dyn_buf, tags[n]->value) : 0; |
|
350 | 350 |
put_le16(pb, len); |
351 | 351 |
} |
352 | 352 |
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 |
474 | 474 |
if ( url_open_dyn_buf(&dyn_buf) < 0) |
475 | 475 |
return AVERROR(ENOMEM); |
476 | 476 |
|
477 |
- ff_put_str16_nolen(dyn_buf, desc); |
|
477 |
+ avio_put_str16le(dyn_buf, desc); |
|
478 | 478 |
len = url_close_dyn_buf(dyn_buf, &buf); |
479 | 479 |
put_le16(pb, len / 2); // "number of characters" = length in bytes / 2 |
480 | 480 |
|
... | ... |
@@ -378,6 +378,12 @@ attribute_deprecated void put_strz(ByteIOContext *s, const char *buf); |
378 | 378 |
int avio_put_str(ByteIOContext *s, const char *str); |
379 | 379 |
|
380 | 380 |
/** |
381 |
+ * Convert an UTF-8 string to UTF-16LE and write it. |
|
382 |
+ * @return number of bytes written. |
|
383 |
+ */ |
|
384 |
+int avio_put_str16le(ByteIOContext *s, const char *str); |
|
385 |
+ |
|
386 |
+/** |
|
381 | 387 |
* fseek() equivalent for ByteIOContext. |
382 | 388 |
* @return new position or AVERROR. |
383 | 389 |
*/ |
... | ... |
@@ -283,6 +283,23 @@ int avio_put_str(ByteIOContext *s, const char *str) |
283 | 283 |
return len; |
284 | 284 |
} |
285 | 285 |
|
286 |
+int avio_put_str16le(ByteIOContext *s, const char *str) |
|
287 |
+{ |
|
288 |
+ const uint8_t *q = str; |
|
289 |
+ int ret = 0; |
|
290 |
+ |
|
291 |
+ while (*q) { |
|
292 |
+ uint32_t ch; |
|
293 |
+ uint16_t tmp; |
|
294 |
+ |
|
295 |
+ GET_UTF8(ch, *q++, break;) |
|
296 |
+ PUT_UTF16(ch, tmp, put_le16(s, tmp);ret += 2;) |
|
297 |
+ } |
|
298 |
+ put_le16(s, 0); |
|
299 |
+ ret += 2; |
|
300 |
+ return ret; |
|
301 |
+} |
|
302 |
+ |
|
286 | 303 |
int ff_get_v_length(uint64_t val){ |
287 | 304 |
int i=1; |
288 | 305 |
|
... | ... |
@@ -34,7 +34,6 @@ |
34 | 34 |
#include "libavutil/intreadwrite.h" |
35 | 35 |
#include "libavcodec/bytestream.h" |
36 | 36 |
#include "network.h" |
37 |
-#include "asf.h" |
|
38 | 37 |
|
39 | 38 |
#define LOCAL_ADDRESS 0xc0a80081 // FIXME get and use correct local ip address. |
40 | 39 |
#define LOCAL_PORT 1037 // as above. |
... | ... |
@@ -159,7 +158,7 @@ static void mms_put_utf16(MMSContext *mms, uint8_t *src) |
159 | 159 |
init_put_byte(&bic, mms->write_out_ptr, |
160 | 160 |
sizeof(mms->out_buffer) - size, 1, NULL, NULL, NULL, NULL); |
161 | 161 |
|
162 |
- len = ff_put_str16_nolen(&bic, src); |
|
162 |
+ len = avio_put_str16le(&bic, src); |
|
163 | 163 |
mms->write_out_ptr += len; |
164 | 164 |
} |
165 | 165 |
|