Revision 6e89b612

View differences:

libavformat/asf.c
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
}
libavformat/asf.h
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

  
libavformat/asfenc.c
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 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 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

  
libavformat/avio.h
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
 */
libavformat/aviobuf.c
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

  
libavformat/mmst.c
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 158
    init_put_byte(&bic, mms->write_out_ptr,
160 159
            sizeof(mms->out_buffer) - size, 1, NULL, NULL, NULL, NULL);
161 160

  
162
    len = ff_put_str16_nolen(&bic, src);
161
    len = avio_put_str16le(&bic, src);
163 162
    mms->write_out_ptr += len;
164 163
}
165 164

  

Also available in: Unified diff