Patch by Zhentan Feng <spyfeng gmail com>.
Originally committed as revision 22656 to svn://svn.ffmpeg.org/ffmpeg/trunk
| ... | ... |
@@ -152,3 +152,20 @@ const AVMetadataConv ff_asf_metadata_conv[] = {
|
| 152 | 152 |
// { "Year" , "date" }, TODO: conversion year<->date
|
| 153 | 153 |
{ 0 }
|
| 154 | 154 |
}; |
| 155 |
+ |
|
| 156 |
+int ff_put_str16_nolen(ByteIOContext *s, const char *tag) |
|
| 157 |
+{
|
|
| 158 |
+ const uint8_t *q = tag; |
|
| 159 |
+ int ret = 0; |
|
| 160 |
+ |
|
| 161 |
+ while (*q) {
|
|
| 162 |
+ uint32_t ch; |
|
| 163 |
+ uint16_t tmp; |
|
| 164 |
+ |
|
| 165 |
+ GET_UTF8(ch, *q++, break;) |
|
| 166 |
+ PUT_UTF16(ch, tmp, put_le16(s, tmp);ret += 2;) |
|
| 167 |
+ } |
|
| 168 |
+ put_le16(s, 0); |
|
| 169 |
+ ret += 2; |
|
| 170 |
+ return ret; |
|
| 171 |
+} |
| ... | ... |
@@ -203,23 +203,6 @@ static void put_guid(ByteIOContext *s, const ff_asf_guid *g) |
| 203 | 203 |
put_buffer(s, *g, sizeof(*g)); |
| 204 | 204 |
} |
| 205 | 205 |
|
| 206 |
-static int put_str16_nolen(ByteIOContext *s, const char *tag) |
|
| 207 |
-{
|
|
| 208 |
- const uint8_t *q = tag; |
|
| 209 |
- int ret = 0; |
|
| 210 |
- |
|
| 211 |
- while (*q) {
|
|
| 212 |
- uint32_t ch; |
|
| 213 |
- uint16_t tmp; |
|
| 214 |
- |
|
| 215 |
- GET_UTF8(ch, *q++, break;) |
|
| 216 |
- PUT_UTF16(ch, tmp, put_le16(s, tmp);ret += 2;) |
|
| 217 |
- } |
|
| 218 |
- put_le16(s, 0); |
|
| 219 |
- ret += 2; |
|
| 220 |
- return ret; |
|
| 221 |
-} |
|
| 222 |
- |
|
| 223 | 206 |
static void put_str16(ByteIOContext *s, const char *tag) |
| 224 | 207 |
{
|
| 225 | 208 |
int len; |
| ... | ... |
@@ -228,7 +211,7 @@ static void put_str16(ByteIOContext *s, const char *tag) |
| 228 | 228 |
if (url_open_dyn_buf(&dyn_buf) < 0) |
| 229 | 229 |
return; |
| 230 | 230 |
|
| 231 |
- put_str16_nolen(dyn_buf, tag); |
|
| 231 |
+ ff_put_str16_nolen(dyn_buf, tag); |
|
| 232 | 232 |
len = url_close_dyn_buf(dyn_buf, &pb); |
| 233 | 233 |
put_le16(s, len); |
| 234 | 234 |
put_buffer(s, pb, len); |
| ... | ... |
@@ -361,7 +344,7 @@ static int asf_write_header1(AVFormatContext *s, int64_t file_size, int64_t data |
| 361 | 361 |
hpos = put_header(pb, &ff_asf_comment_header); |
| 362 | 362 |
|
| 363 | 363 |
for (n = 0; n < FF_ARRAY_ELEMS(tags); n++) {
|
| 364 |
- len = tags[n] ? put_str16_nolen(dyn_buf, tags[n]->value) : 0; |
|
| 364 |
+ len = tags[n] ? ff_put_str16_nolen(dyn_buf, tags[n]->value) : 0; |
|
| 365 | 365 |
put_le16(pb, len); |
| 366 | 366 |
} |
| 367 | 367 |
len = url_close_dyn_buf(dyn_buf, &buf); |
| ... | ... |
@@ -489,7 +472,7 @@ static int asf_write_header1(AVFormatContext *s, int64_t file_size, int64_t data |
| 489 | 489 |
if ( url_open_dyn_buf(&dyn_buf) < 0) |
| 490 | 490 |
return AVERROR(ENOMEM); |
| 491 | 491 |
|
| 492 |
- put_str16_nolen(dyn_buf, desc); |
|
| 492 |
+ ff_put_str16_nolen(dyn_buf, desc); |
|
| 493 | 493 |
len = url_close_dyn_buf(dyn_buf, &buf); |
| 494 | 494 |
put_le16(pb, len / 2); // "number of characters" = length in bytes / 2 |
| 495 | 495 |
|