mirror of
https://git.ffmpeg.org/ffmpeg.git
synced 2025-02-06 06:44:29 +00:00
lavf: move ff_put_str16_nolen from asf to avio and rename it
It will be useful in the mp3 muxer.
Signed-off-by: Mans Rullgard <mans@mansr.com>
(cherry picked from commit dccbd97d72
)
This commit is contained in:
parent
e910a77b0d
commit
6e89b61293
@ -156,20 +156,3 @@ const AVMetadataConv ff_asf_metadata_conv[] = {
|
|||||||
// { "Year" , "date" }, TODO: conversion year<->date
|
// { "Year" , "date" }, TODO: conversion year<->date
|
||||||
{ 0 }
|
{ 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;
|
|
||||||
}
|
|
||||||
|
@ -230,7 +230,6 @@ extern const AVMetadataConv ff_asf_metadata_conv[];
|
|||||||
#define ASF_PL_FLAG_KEY_FRAME 0x80 //1000 0000
|
#define ASF_PL_FLAG_KEY_FRAME 0x80 //1000 0000
|
||||||
|
|
||||||
extern AVInputFormat asf_demuxer;
|
extern AVInputFormat asf_demuxer;
|
||||||
int ff_put_str16_nolen(ByteIOContext *s, const char *tag);
|
|
||||||
int ff_guidcmp(const void *g1, const void *g2);
|
int ff_guidcmp(const void *g1, const void *g2);
|
||||||
void ff_get_guid(ByteIOContext *s, ff_asf_guid *g);
|
void ff_get_guid(ByteIOContext *s, ff_asf_guid *g);
|
||||||
|
|
||||||
|
@ -211,7 +211,7 @@ static void put_str16(ByteIOContext *s, const char *tag)
|
|||||||
if (url_open_dyn_buf(&dyn_buf) < 0)
|
if (url_open_dyn_buf(&dyn_buf) < 0)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
ff_put_str16_nolen(dyn_buf, tag);
|
avio_put_str16le(dyn_buf, tag);
|
||||||
len = url_close_dyn_buf(dyn_buf, &pb);
|
len = url_close_dyn_buf(dyn_buf, &pb);
|
||||||
put_le16(s, len);
|
put_le16(s, len);
|
||||||
put_buffer(s, pb, 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);
|
hpos = put_header(pb, &ff_asf_comment_header);
|
||||||
|
|
||||||
for (n = 0; n < FF_ARRAY_ELEMS(tags); n++) {
|
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);
|
put_le16(pb, len);
|
||||||
}
|
}
|
||||||
len = url_close_dyn_buf(dyn_buf, &buf);
|
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)
|
if ( url_open_dyn_buf(&dyn_buf) < 0)
|
||||||
return AVERROR(ENOMEM);
|
return AVERROR(ENOMEM);
|
||||||
|
|
||||||
ff_put_str16_nolen(dyn_buf, desc);
|
avio_put_str16le(dyn_buf, desc);
|
||||||
len = url_close_dyn_buf(dyn_buf, &buf);
|
len = url_close_dyn_buf(dyn_buf, &buf);
|
||||||
put_le16(pb, len / 2); // "number of characters" = length in bytes / 2
|
put_le16(pb, len / 2); // "number of characters" = length in bytes / 2
|
||||||
|
|
||||||
|
@ -377,6 +377,12 @@ attribute_deprecated void put_strz(ByteIOContext *s, const char *buf);
|
|||||||
*/
|
*/
|
||||||
int avio_put_str(ByteIOContext *s, const char *str);
|
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.
|
* fseek() equivalent for ByteIOContext.
|
||||||
* @return new position or AVERROR.
|
* @return new position or AVERROR.
|
||||||
|
@ -283,6 +283,23 @@ int avio_put_str(ByteIOContext *s, const char *str)
|
|||||||
return len;
|
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 ff_get_v_length(uint64_t val){
|
||||||
int i=1;
|
int i=1;
|
||||||
|
|
||||||
|
@ -34,7 +34,6 @@
|
|||||||
#include "libavutil/intreadwrite.h"
|
#include "libavutil/intreadwrite.h"
|
||||||
#include "libavcodec/bytestream.h"
|
#include "libavcodec/bytestream.h"
|
||||||
#include "network.h"
|
#include "network.h"
|
||||||
#include "asf.h"
|
|
||||||
|
|
||||||
#define LOCAL_ADDRESS 0xc0a80081 // FIXME get and use correct local ip address.
|
#define LOCAL_ADDRESS 0xc0a80081 // FIXME get and use correct local ip address.
|
||||||
#define LOCAL_PORT 1037 // as above.
|
#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,
|
init_put_byte(&bic, mms->write_out_ptr,
|
||||||
sizeof(mms->out_buffer) - size, 1, NULL, NULL, NULL, NULL);
|
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;
|
mms->write_out_ptr += len;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user