[FFmpeg-devel] [PATCH 3/4] lavf: replace remaining uses of put_tag with avio_write
Anton Khirnov
anton
Thu Feb 24 07:36:04 CET 2011
---
libavformat/amr.c | 4 ++--
libavformat/ffmetaenc.c | 6 +++---
libavformat/flvenc.c | 2 +-
libavformat/gif.c | 6 +++---
libavformat/gxfenc.c | 11 +++++++----
libavformat/mmf.c | 2 +-
libavformat/rmenc.c | 2 +-
libavformat/swfenc.c | 4 ++--
8 files changed, 20 insertions(+), 17 deletions(-)
diff --git a/libavformat/amr.c b/libavformat/amr.c
index 3b78ba3..fd43283 100644
--- a/libavformat/amr.c
+++ b/libavformat/amr.c
@@ -40,11 +40,11 @@ static int amr_write_header(AVFormatContext *s)
if (enc->codec_id == CODEC_ID_AMR_NB)
{
- put_tag(pb, AMR_header); /* magic number */
+ avio_write(pb, AMR_header, sizeof(AMR_header) - 1); /* magic number */
}
else if(enc->codec_id == CODEC_ID_AMR_WB)
{
- put_tag(pb, AMRWB_header); /* magic number */
+ avio_write(pb, AMRWB_header, sizeof(AMRWB_header) - 1); /* magic number */
}
else
{
diff --git a/libavformat/ffmetaenc.c b/libavformat/ffmetaenc.c
index 322ec0f..77db0b9 100644
--- a/libavformat/ffmetaenc.c
+++ b/libavformat/ffmetaenc.c
@@ -50,7 +50,7 @@ static void write_tags(AVIOContext *s, AVMetadata *m)
static int write_header(AVFormatContext *s)
{
- put_tag(s->pb, ID_STRING);
+ avio_write(s->pb, ID_STRING, sizeof(ID_STRING) - 1);
avio_w8(s->pb, '1'); // version
avio_w8(s->pb, '\n');
put_flush_packet(s->pb);
@@ -64,14 +64,14 @@ static int write_trailer(AVFormatContext *s)
write_tags(s->pb, s->metadata);
for (i = 0; i < s->nb_streams; i++) {
- put_tag(s->pb, ID_STREAM);
+ avio_write(s->pb, ID_STREAM, sizeof(ID_STREAM) - 1);
avio_w8(s->pb, '\n');
write_tags(s->pb, s->streams[i]->metadata);
}
for (i = 0; i < s->nb_chapters; i++) {
AVChapter *ch = s->chapters[i];
- put_tag(s->pb, ID_CHAPTER);
+ avio_write(s->pb, ID_CHAPTER, sizeof(ID_CHAPTER) - 1);
avio_w8(s->pb, '\n');
url_fprintf(s->pb, "TIMEBASE=%d/%d\n", ch->time_base.num, ch->time_base.den);
url_fprintf(s->pb, "START=%"PRId64"\n", ch->start);
diff --git a/libavformat/flvenc.c b/libavformat/flvenc.c
index 71a3784..4d49a96 100644
--- a/libavformat/flvenc.c
+++ b/libavformat/flvenc.c
@@ -199,7 +199,7 @@ static int flv_write_header(AVFormatContext *s)
}
av_set_pts_info(s->streams[i], 32, 1, 1000); /* 32 bit pts in ms */
}
- put_tag(pb,"FLV");
+ avio_write(pb, "FLV", 3);
avio_w8(pb,1);
avio_w8(pb, FLV_HEADER_FLAG_HASAUDIO * !!audio_enc
+ FLV_HEADER_FLAG_HASVIDEO * !!video_enc);
diff --git a/libavformat/gif.c b/libavformat/gif.c
index f3f64d1..17effaa 100644
--- a/libavformat/gif.c
+++ b/libavformat/gif.c
@@ -114,8 +114,8 @@ static int gif_image_write_header(AVIOContext *pb,
int i;
unsigned int v;
- put_tag(pb, "GIF");
- put_tag(pb, "89a");
+ avio_write(pb, "GIF", 3);
+ avio_write(pb, "89a", 3);
avio_wl16(pb, width);
avio_wl16(pb, height);
@@ -162,7 +162,7 @@ static int gif_image_write_header(AVIOContext *pb,
avio_w8(pb, 0x21);
avio_w8(pb, 0xff);
avio_w8(pb, 0x0b);
- put_tag(pb, "NETSCAPE2.0"); // bytes 4 to 14
+ avio_write(pb, "NETSCAPE2.0", sizeof("NETSCAPE2.0") - 1); // bytes 4 to 14
avio_w8(pb, 0x03); // byte 15
avio_w8(pb, 0x01); // byte 16
avio_wl16(pb, (uint16_t)loop_count);
diff --git a/libavformat/gxfenc.c b/libavformat/gxfenc.c
index fb6f441..1b12f41 100644
--- a/libavformat/gxfenc.c
+++ b/libavformat/gxfenc.c
@@ -224,7 +224,7 @@ static int gxf_write_track_description(AVFormatContext *s, GXFStreamContext *sc,
/* media file name */
avio_w8(pb, TRACK_NAME);
avio_w8(pb, strlen(ES_NAME_PATTERN) + 3);
- put_tag(pb, ES_NAME_PATTERN);
+ avio_write(pb, ES_NAME_PATTERN, sizeof(ES_NAME_PATTERN) - 1);
avio_wb16(pb, sc->media_info);
avio_w8(pb, 0);
@@ -269,6 +269,7 @@ static int gxf_write_material_data_section(AVFormatContext *s)
GXFContext *gxf = s->priv_data;
AVIOContext *pb = s->pb;
int64_t pos;
+ int len;
const char *filename = strrchr(s->filename, '/');
pos = url_ftell(pb);
@@ -279,10 +280,12 @@ static int gxf_write_material_data_section(AVFormatContext *s)
filename++;
else
filename = s->filename;
+ len = strlen(filename);
+
avio_w8(pb, MAT_NAME);
- avio_w8(pb, strlen(SERVER_PATH) + strlen(filename) + 1);
- put_tag(pb, SERVER_PATH);
- put_tag(pb, filename);
+ avio_w8(pb, strlen(SERVER_PATH) + len + 1);
+ avio_write(pb, SERVER_PATH, sizeof(SERVER_PATH) - 1);
+ avio_write(pb, filename, len);
avio_w8(pb, 0);
/* first field */
diff --git a/libavformat/mmf.c b/libavformat/mmf.c
index 76b27dd..bcb862c 100644
--- a/libavformat/mmf.c
+++ b/libavformat/mmf.c
@@ -79,7 +79,7 @@ static int mmf_write_header(AVFormatContext *s)
avio_w8(pb, 0); /* code type */
avio_w8(pb, 0); /* status */
avio_w8(pb, 0); /* counts */
- put_tag(pb, "VN:libavcodec,"); /* metadata ("ST:songtitle,VN:version,...") */
+ avio_write(pb, "VN:libavcodec,", sizeof("VN:libavcodec,") -1); /* metadata ("ST:songtitle,VN:version,...") */
end_tag_be(pb, pos);
avio_write(pb, "ATR\x00", 4);
diff --git a/libavformat/rmenc.c b/libavformat/rmenc.c
index 5d311d3..29a6a35 100644
--- a/libavformat/rmenc.c
+++ b/libavformat/rmenc.c
@@ -184,7 +184,7 @@ static int rv10_write_header(AVFormatContext *ctx,
coded_frame_size = (stream->enc->bit_rate *
stream->enc->frame_size) / (8 * sample_rate);
/* audio codec info */
- put_tag(s, ".ra");
+ avio_write(s, ".ra", 3);
avio_w8(s, 0xfd);
avio_wb32(s, 0x00040000); /* version */
ffio_wfourcc(s, ".ra4");
diff --git a/libavformat/swfenc.c b/libavformat/swfenc.c
index c698600..296b9c2 100644
--- a/libavformat/swfenc.c
+++ b/libavformat/swfenc.c
@@ -229,7 +229,7 @@ static int swf_write_header(AVFormatContext *s)
else
swf->samples_per_frame = (swf->audio_enc->sample_rate * rate_base) / rate;
- put_tag(pb, "FWS");
+ avio_write(pb, "FWS", 3);
if (!strcmp("avm2", s->oformat->name))
version = 9;
@@ -361,7 +361,7 @@ static int swf_write_video(AVFormatContext *s,
avio_wl16(pb, VIDEO_ID);
put_swf_matrix(pb, 1 << FRAC_BITS, 0, 0, 1 << FRAC_BITS, 0, 0);
avio_wl16(pb, swf->video_frame_number);
- put_tag(pb, "video");
+ avio_write(pb, "video", 5);
avio_w8(pb, 0x00);
put_swf_end_tag(s);
} else {
--
1.7.2.3
More information about the ffmpeg-devel
mailing list