mirror of
https://git.ffmpeg.org/ffmpeg.git
synced 2025-12-08 06:09:50 +00:00
avformat/vorbiscomment: Switch to AVIOContext from bytestream API
Up until now ff_vorbiscomment_write() used the bytestream API to write VorbisComments. Therefore the caller had to provide a sufficiently large buffer to write the output. Yet two of the three callers (namely the FLAC and the Matroska muxer) actually want the output to be written via an AVIOContext; therefore they allocated buffers of the right size just for this purpose (i.e. they get freed immediately afterwards). Only the Ogg muxer actually wants a buffer. But given that it is easy to wrap a buffer into an AVIOContext this commit changes ff_vorbiscomment_write() to use an AVIOContext for its output. Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@gmail.com>
This commit is contained in:
parent
704d7c9f46
commit
6397b4d6a2
5 changed files with 39 additions and 60 deletions
|
|
@ -29,7 +29,6 @@
|
|||
#include "id3v2.h"
|
||||
#include "internal.h"
|
||||
#include "vorbiscomment.h"
|
||||
#include "libavcodec/bytestream.h"
|
||||
|
||||
|
||||
typedef struct FlacMuxerContext {
|
||||
|
|
@ -62,25 +61,16 @@ static int flac_write_block_comment(AVIOContext *pb, AVDictionary **m,
|
|||
{
|
||||
const char *vendor = bitexact ? "ffmpeg" : LIBAVFORMAT_IDENT;
|
||||
int64_t len;
|
||||
uint8_t *p, *p0;
|
||||
|
||||
ff_metadata_conv(m, ff_vorbiscomment_metadata_conv, NULL);
|
||||
|
||||
len = ff_vorbiscomment_length(*m, vendor, NULL, 0);
|
||||
if (len >= ((1<<24) - 4))
|
||||
return AVERROR(EINVAL);
|
||||
p0 = av_malloc(len+4);
|
||||
if (!p0)
|
||||
return AVERROR(ENOMEM);
|
||||
p = p0;
|
||||
|
||||
bytestream_put_byte(&p, last_block ? 0x84 : 0x04);
|
||||
bytestream_put_be24(&p, len);
|
||||
ff_vorbiscomment_write(&p, *m, vendor, NULL, 0);
|
||||
|
||||
avio_write(pb, p0, len+4);
|
||||
av_freep(&p0);
|
||||
p = NULL;
|
||||
avio_w8(pb, last_block ? 0x84 : 0x04);
|
||||
avio_wb24(pb, len);
|
||||
ff_vorbiscomment_write(pb, *m, vendor, NULL, 0);
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue