vorbiscomment: change ff_vorbiscomment_write to take an AVMetadata**
patch by Anton Khirnov anton _at_ khirnov _dot_ net Originally committed as revision 25473 to svn://svn.ffmpeg.org/ffmpeg/trunk
This commit is contained in:
parent
da7548585e
commit
81e5ff7ae2
@ -39,14 +39,14 @@ static int flac_write_block_padding(ByteIOContext *pb, unsigned int n_padding_by
|
|||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
static int flac_write_block_comment(ByteIOContext *pb, AVMetadata *m,
|
static int flac_write_block_comment(ByteIOContext *pb, AVMetadata **m,
|
||||||
int last_block, int bitexact)
|
int last_block, int bitexact)
|
||||||
{
|
{
|
||||||
const char *vendor = bitexact ? "ffmpeg" : LIBAVFORMAT_IDENT;
|
const char *vendor = bitexact ? "ffmpeg" : LIBAVFORMAT_IDENT;
|
||||||
unsigned int len, count;
|
unsigned int len, count;
|
||||||
uint8_t *p, *p0;
|
uint8_t *p, *p0;
|
||||||
|
|
||||||
len = ff_vorbiscomment_length(m, vendor, &count);
|
len = ff_vorbiscomment_length(*m, vendor, &count);
|
||||||
p0 = av_malloc(len+4);
|
p0 = av_malloc(len+4);
|
||||||
if (!p0)
|
if (!p0)
|
||||||
return AVERROR(ENOMEM);
|
return AVERROR(ENOMEM);
|
||||||
@ -72,7 +72,7 @@ static int flac_write_header(struct AVFormatContext *s)
|
|||||||
if (ret)
|
if (ret)
|
||||||
return ret;
|
return ret;
|
||||||
|
|
||||||
ret = flac_write_block_comment(s->pb, s->metadata, 0,
|
ret = flac_write_block_comment(s->pb, &s->metadata, 0,
|
||||||
codec->flags & CODEC_FLAG_BITEXACT);
|
codec->flags & CODEC_FLAG_BITEXACT);
|
||||||
if (ret)
|
if (ret)
|
||||||
return ret;
|
return ret;
|
||||||
|
@ -206,14 +206,14 @@ static int ogg_buffer_data(AVFormatContext *s, AVStream *st,
|
|||||||
}
|
}
|
||||||
|
|
||||||
static uint8_t *ogg_write_vorbiscomment(int offset, int bitexact,
|
static uint8_t *ogg_write_vorbiscomment(int offset, int bitexact,
|
||||||
int *header_len, AVMetadata *m, int framing_bit)
|
int *header_len, AVMetadata **m, int framing_bit)
|
||||||
{
|
{
|
||||||
const char *vendor = bitexact ? "ffmpeg" : LIBAVFORMAT_IDENT;
|
const char *vendor = bitexact ? "ffmpeg" : LIBAVFORMAT_IDENT;
|
||||||
int size;
|
int size;
|
||||||
uint8_t *p, *p0;
|
uint8_t *p, *p0;
|
||||||
unsigned int count;
|
unsigned int count;
|
||||||
|
|
||||||
size = offset + ff_vorbiscomment_length(m, vendor, &count) + framing_bit;
|
size = offset + ff_vorbiscomment_length(*m, vendor, &count) + framing_bit;
|
||||||
p = av_mallocz(size);
|
p = av_mallocz(size);
|
||||||
if (!p)
|
if (!p)
|
||||||
return NULL;
|
return NULL;
|
||||||
@ -230,7 +230,7 @@ static uint8_t *ogg_write_vorbiscomment(int offset, int bitexact,
|
|||||||
|
|
||||||
static int ogg_build_flac_headers(AVCodecContext *avctx,
|
static int ogg_build_flac_headers(AVCodecContext *avctx,
|
||||||
OGGStreamContext *oggstream, int bitexact,
|
OGGStreamContext *oggstream, int bitexact,
|
||||||
AVMetadata *m)
|
AVMetadata **m)
|
||||||
{
|
{
|
||||||
enum FLACExtradataFormat format;
|
enum FLACExtradataFormat format;
|
||||||
uint8_t *streaminfo;
|
uint8_t *streaminfo;
|
||||||
@ -270,7 +270,7 @@ static int ogg_build_flac_headers(AVCodecContext *avctx,
|
|||||||
|
|
||||||
static int ogg_build_speex_headers(AVCodecContext *avctx,
|
static int ogg_build_speex_headers(AVCodecContext *avctx,
|
||||||
OGGStreamContext *oggstream, int bitexact,
|
OGGStreamContext *oggstream, int bitexact,
|
||||||
AVMetadata *m)
|
AVMetadata **m)
|
||||||
{
|
{
|
||||||
uint8_t *p;
|
uint8_t *p;
|
||||||
|
|
||||||
@ -338,7 +338,7 @@ static int ogg_write_header(AVFormatContext *s)
|
|||||||
if (st->codec->codec_id == CODEC_ID_FLAC) {
|
if (st->codec->codec_id == CODEC_ID_FLAC) {
|
||||||
int err = ogg_build_flac_headers(st->codec, oggstream,
|
int err = ogg_build_flac_headers(st->codec, oggstream,
|
||||||
st->codec->flags & CODEC_FLAG_BITEXACT,
|
st->codec->flags & CODEC_FLAG_BITEXACT,
|
||||||
s->metadata);
|
&s->metadata);
|
||||||
if (err) {
|
if (err) {
|
||||||
av_log(s, AV_LOG_ERROR, "Error writing FLAC headers\n");
|
av_log(s, AV_LOG_ERROR, "Error writing FLAC headers\n");
|
||||||
av_freep(&st->priv_data);
|
av_freep(&st->priv_data);
|
||||||
@ -347,7 +347,7 @@ static int ogg_write_header(AVFormatContext *s)
|
|||||||
} else if (st->codec->codec_id == CODEC_ID_SPEEX) {
|
} else if (st->codec->codec_id == CODEC_ID_SPEEX) {
|
||||||
int err = ogg_build_speex_headers(st->codec, oggstream,
|
int err = ogg_build_speex_headers(st->codec, oggstream,
|
||||||
st->codec->flags & CODEC_FLAG_BITEXACT,
|
st->codec->flags & CODEC_FLAG_BITEXACT,
|
||||||
s->metadata);
|
&s->metadata);
|
||||||
if (err) {
|
if (err) {
|
||||||
av_log(s, AV_LOG_ERROR, "Error writing Speex headers\n");
|
av_log(s, AV_LOG_ERROR, "Error writing Speex headers\n");
|
||||||
av_freep(&st->priv_data);
|
av_freep(&st->priv_data);
|
||||||
@ -368,7 +368,7 @@ static int ogg_write_header(AVFormatContext *s)
|
|||||||
}
|
}
|
||||||
|
|
||||||
p = ogg_write_vorbiscomment(7, st->codec->flags & CODEC_FLAG_BITEXACT,
|
p = ogg_write_vorbiscomment(7, st->codec->flags & CODEC_FLAG_BITEXACT,
|
||||||
&oggstream->header_len[1], s->metadata,
|
&oggstream->header_len[1], &s->metadata,
|
||||||
framing_bit);
|
framing_bit);
|
||||||
if (!p)
|
if (!p)
|
||||||
return AVERROR(ENOMEM);
|
return AVERROR(ENOMEM);
|
||||||
|
@ -52,15 +52,15 @@ int ff_vorbiscomment_length(AVMetadata *m, const char *vendor_string,
|
|||||||
return len;
|
return len;
|
||||||
}
|
}
|
||||||
|
|
||||||
int ff_vorbiscomment_write(uint8_t **p, AVMetadata *m,
|
int ff_vorbiscomment_write(uint8_t **p, AVMetadata **m,
|
||||||
const char *vendor_string, const unsigned count)
|
const char *vendor_string, const unsigned count)
|
||||||
{
|
{
|
||||||
bytestream_put_le32(p, strlen(vendor_string));
|
bytestream_put_le32(p, strlen(vendor_string));
|
||||||
bytestream_put_buffer(p, vendor_string, strlen(vendor_string));
|
bytestream_put_buffer(p, vendor_string, strlen(vendor_string));
|
||||||
if (m) {
|
if (*m) {
|
||||||
AVMetadataTag *tag = NULL;
|
AVMetadataTag *tag = NULL;
|
||||||
bytestream_put_le32(p, count);
|
bytestream_put_le32(p, count);
|
||||||
while ((tag = av_metadata_get(m, "", tag, AV_METADATA_IGNORE_SUFFIX))) {
|
while ((tag = av_metadata_get(*m, "", tag, AV_METADATA_IGNORE_SUFFIX))) {
|
||||||
unsigned int len1 = strlen(tag->key);
|
unsigned int len1 = strlen(tag->key);
|
||||||
unsigned int len2 = strlen(tag->value);
|
unsigned int len2 = strlen(tag->value);
|
||||||
bytestream_put_le32(p, len1+1+len2);
|
bytestream_put_le32(p, len1+1+len2);
|
||||||
|
@ -49,7 +49,7 @@ int ff_vorbiscomment_length(AVMetadata *m, const char *vendor_string,
|
|||||||
* @param vendor_string The vendor string to write.
|
* @param vendor_string The vendor string to write.
|
||||||
* @param count The number of tags in m because m->count is "not allowed"
|
* @param count The number of tags in m because m->count is "not allowed"
|
||||||
*/
|
*/
|
||||||
int ff_vorbiscomment_write(uint8_t **p, AVMetadata *m,
|
int ff_vorbiscomment_write(uint8_t **p, AVMetadata **m,
|
||||||
const char *vendor_string, const unsigned count);
|
const char *vendor_string, const unsigned count);
|
||||||
|
|
||||||
extern const AVMetadataConv ff_vorbiscomment_metadata_conv[];
|
extern const AVMetadataConv ff_vorbiscomment_metadata_conv[];
|
||||||
|
Loading…
x
Reference in New Issue
Block a user