summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--ffserver.c6
-rw-r--r--libavformat/a64.c12
-rw-r--r--libavformat/adtsenc.c6
-rw-r--r--libavformat/aiffenc.c36
-rw-r--r--libavformat/amr.c2
-rw-r--r--libavformat/asfenc.c180
-rw-r--r--libavformat/assenc.c6
-rw-r--r--libavformat/au.c14
-rw-r--r--libavformat/avc.c30
-rw-r--r--libavformat/avienc.c188
-rw-r--r--libavformat/avio.h31
-rw-r--r--libavformat/aviobuf.c102
-rw-r--r--libavformat/crcenc.c2
-rw-r--r--libavformat/daud.c6
-rw-r--r--libavformat/dvenc.c2
-rw-r--r--libavformat/ffmenc.c140
-rw-r--r--libavformat/ffmetaenc.c16
-rw-r--r--libavformat/filmstripenc.c20
-rw-r--r--libavformat/flacenc.c12
-rw-r--r--libavformat/flacenc_header.c4
-rw-r--r--libavformat/flvenc.c124
-rw-r--r--libavformat/framecrcenc.c2
-rw-r--r--libavformat/gif.c70
-rw-r--r--libavformat/gxfenc.c322
-rw-r--r--libavformat/idroqenc.c2
-rw-r--r--libavformat/img2.c18
-rw-r--r--libavformat/ivfenc.c24
-rw-r--r--libavformat/libnut.c2
-rw-r--r--libavformat/matroskadec.c12
-rw-r--r--libavformat/matroskaenc.c46
-rw-r--r--libavformat/md5enc.c2
-rw-r--r--libavformat/mmf.c50
-rw-r--r--libavformat/movenc.c880
-rw-r--r--libavformat/movenchint.c40
-rw-r--r--libavformat/mp3enc.c30
-rw-r--r--libavformat/mpegenc.c82
-rw-r--r--libavformat/mpegtsenc.c8
-rw-r--r--libavformat/mpjpeg.c8
-rw-r--r--libavformat/mxfenc.c332
-rw-r--r--libavformat/nutenc.c32
-rw-r--r--libavformat/oggenc.c22
-rw-r--r--libavformat/rawenc.c2
-rw-r--r--libavformat/riff.c64
-rw-r--r--libavformat/rmenc.c192
-rw-r--r--libavformat/rsoenc.c12
-rw-r--r--libavformat/rtpdec.c58
-rw-r--r--libavformat/rtpdec_asf.c2
-rw-r--r--libavformat/rtpdec_latm.c2
-rw-r--r--libavformat/rtpdec_svq3.c2
-rw-r--r--libavformat/rtpdec_vp8.c2
-rw-r--r--libavformat/rtpdec_xiph.c4
-rw-r--r--libavformat/rtpenc.c30
-rw-r--r--libavformat/soxenc.c30
-rw-r--r--libavformat/spdifenc.c8
-rw-r--r--libavformat/swfenc.c108
-rw-r--r--libavformat/vc1testenc.c32
-rw-r--r--libavformat/vocenc.c48
-rw-r--r--libavformat/wav.c10
-rw-r--r--libavformat/yuv4mpeg.c10
59 files changed, 1787 insertions, 1752 deletions
diff --git a/ffserver.c b/ffserver.c
index ecc3f74d67..7bda96889a 100644
--- a/ffserver.c
+++ b/ffserver.c
@@ -2514,10 +2514,10 @@ static int http_send_data(HTTPContext *c)
header[1] = interleaved_index;
header[2] = len >> 8;
header[3] = len;
- put_buffer(pb, header, 4);
+ avio_write(pb, header, 4);
/* write RTP packet data */
c->buffer_ptr += 4;
- put_buffer(pb, c->buffer_ptr, len);
+ avio_write(pb, c->buffer_ptr, len);
size = url_close_dyn_buf(pb, &c->packet_buffer);
/* prepare asynchronous TCP sending */
rtsp_c->packet_buffer_ptr = c->packet_buffer;
@@ -3018,7 +3018,7 @@ static void rtsp_cmd_describe(HTTPContext *c, const char *url)
url_fprintf(c->pb, "Content-Type: application/sdp\r\n");
url_fprintf(c->pb, "Content-Length: %d\r\n", content_length);
url_fprintf(c->pb, "\r\n");
- put_buffer(c->pb, content, content_length);
+ avio_write(c->pb, content, content_length);
av_free(content);
}
diff --git a/libavformat/a64.c b/libavformat/a64.c
index 46441b23d8..17dcd96b5b 100644
--- a/libavformat/a64.c
+++ b/libavformat/a64.c
@@ -57,7 +57,7 @@ static int a64_write_header(struct AVFormatContext *s)
return AVERROR(EINVAL);
break;
}
- put_buffer(s->pb, header, 2);
+ avio_write(s->pb, header, 2);
c->prev_pkt.size = 0;
c->prev_frame_count = 0;
return 0;
@@ -110,18 +110,18 @@ static int a64_write_packet(struct AVFormatContext *s, AVPacket *pkt)
for(i = 0; i < num_frames; i++) {
if(pkt->data) {
/* if available, put newest charset chunk into buffer */
- put_buffer(s->pb, pkt->data + ch_chunksize * i, ch_chunksize);
+ avio_write(s->pb, pkt->data + ch_chunksize * i, ch_chunksize);
} else {
/* a bit ugly, but is there an alternative to put many zeros? */
- for(j = 0; j < ch_chunksize; j++) put_byte(s->pb, 0);
+ for(j = 0; j < ch_chunksize; j++) avio_w8(s->pb, 0);
}
if(c->prev_pkt.data) {
/* put frame (screen + colram) from last packet into buffer */
- put_buffer(s->pb, c->prev_pkt.data + charset_size + frame_size * i, frame_size);
+ avio_write(s->pb, c->prev_pkt.data + charset_size + frame_size * i, frame_size);
} else {
/* a bit ugly, but is there an alternative to put many zeros? */
- for(j = 0; j < frame_size; j++) put_byte(s->pb, 0);
+ for(j = 0; j < frame_size; j++) avio_w8(s->pb, 0);
}
}
@@ -145,7 +145,7 @@ static int a64_write_packet(struct AVFormatContext *s, AVPacket *pkt)
default:
/* Write things as is. Nice for self-contained frames from non-multicolor modes or if played
* directly from ram and not from a streaming device (rrnet/mmc) */
- if(pkt) put_buffer(s->pb, pkt->data, pkt->size);
+ if(pkt) avio_write(s->pb, pkt->data, pkt->size);
break;
}
diff --git a/libavformat/adtsenc.c b/libavformat/adtsenc.c
index c2cb16112c..1f5453dbaf 100644
--- a/libavformat/adtsenc.c
+++ b/libavformat/adtsenc.c
@@ -125,13 +125,13 @@ static int adts_write_packet(AVFormatContext *s, AVPacket *pkt)
return 0;
if (adts->write_adts) {
ff_adts_write_frame_header(adts, buf, pkt->size, adts->pce_size);
- put_buffer(pb, buf, ADTS_HEADER_SIZE);
+ avio_write(pb, buf, ADTS_HEADER_SIZE);
if (adts->pce_size) {
- put_buffer(pb, adts->pce_data, adts->pce_size);
+ avio_write(pb, adts->pce_data, adts->pce_size);
adts->pce_size = 0;
}
}
- put_buffer(pb, pkt->data, pkt->size);
+ avio_write(pb, pkt->data, pkt->size);
put_flush_packet(pb);
return 0;
diff --git a/libavformat/aiffenc.c b/libavformat/aiffenc.c
index 178bbec42a..49aff8bd78 100644
--- a/libavformat/aiffenc.c
+++ b/libavformat/aiffenc.c
@@ -45,7 +45,7 @@ static int aiff_write_header(AVFormatContext *s)
/* FORM AIFF header */
put_tag(pb, "FORM");
aiff->form = url_ftell(pb);
- put_be32(pb, 0); /* file length */
+ avio_wb32(pb, 0); /* file length */
put_tag(pb, aifc ? "AIFC" : "AIFF");
if (aifc) { // compressed audio
@@ -56,17 +56,17 @@ static int aiff_write_header(AVFormatContext *s)
}
/* Version chunk */
put_tag(pb, "FVER");
- put_be32(pb, 4);
- put_be32(pb, 0xA2805140);
+ avio_wb32(pb, 4);
+ avio_wb32(pb, 0xA2805140);
}
/* Common chunk */
put_tag(pb, "COMM");
- put_be32(pb, aifc ? 24 : 18); /* size */
- put_be16(pb, enc->channels); /* Number of channels */
+ avio_wb32(pb, aifc ? 24 : 18); /* size */
+ avio_wb16(pb, enc->channels); /* Number of channels */
aiff->frames = url_ftell(pb);
- put_be32(pb, 0); /* Number of frames */
+ avio_wb32(pb, 0); /* Number of frames */
if (!enc->bits_per_coded_sample)
enc->bits_per_coded_sample = av_get_bits_per_sample(enc->codec_id);
@@ -77,22 +77,22 @@ static int aiff_write_header(AVFormatContext *s)
if (!enc->block_align)
enc->block_align = (enc->bits_per_coded_sample * enc->channels) >> 3;
- put_be16(pb, enc->bits_per_coded_sample); /* Sample size */
+ avio_wb16(pb, enc->bits_per_coded_sample); /* Sample size */
sample_rate = av_dbl2ext((double)enc->sample_rate);
- put_buffer(pb, (uint8_t*)&sample_rate, sizeof(sample_rate));
+ avio_write(pb, (uint8_t*)&sample_rate, sizeof(sample_rate));
if (aifc) {
- put_le32(pb, enc->codec_tag);
- put_be16(pb, 0);
+ avio_wl32(pb, enc->codec_tag);
+ avio_wb16(pb, 0);
}
/* Sound data chunk */
put_tag(pb, "SSND");
aiff->ssnd = url_ftell(pb); /* Sound chunk size */
- put_be32(pb, 0); /* Sound samples data size */
- put_be32(pb, 0); /* Data offset */
- put_be32(pb, 0); /* Block-size (block align) */
+ avio_wb32(pb, 0); /* Sound samples data size */
+ avio_wb32(pb, 0); /* Data offset */
+ avio_wb32(pb, 0); /* Block-size (block align) */
av_set_pts_info(s->streams[0], 64, 1, s->streams[0]->codec->sample_rate);
@@ -105,7 +105,7 @@ static int aiff_write_header(AVFormatContext *s)
static int aiff_write_packet(AVFormatContext *s, AVPacket *pkt)
{
AVIOContext *pb = s->pb;
- put_buffer(pb, pkt->data, pkt->size);
+ avio_write(pb, pkt->data, pkt->size);
return 0;
}
@@ -119,22 +119,22 @@ static int aiff_write_trailer(AVFormatContext *s)
int64_t file_size, end_size;
end_size = file_size = url_ftell(pb);
if (file_size & 1) {
- put_byte(pb, 0);
+ avio_w8(pb, 0);
end_size++;
}
if (!url_is_streamed(s->pb)) {
/* File length */
url_fseek(pb, aiff->form, SEEK_SET);
- put_be32(pb, file_size - aiff->form - 4);
+ avio_wb32(pb, file_size - aiff->form - 4);
/* Number of sample frames */
url_fseek(pb, aiff->frames, SEEK_SET);
- put_be32(pb, (file_size-aiff->ssnd-12)/enc->block_align);
+ avio_wb32(pb, (file_size-aiff->ssnd-12)/enc->block_align);
/* Sound Data chunk size */
url_fseek(pb, aiff->ssnd, SEEK_SET);
- put_be32(pb, file_size - aiff->ssnd - 4);
+ avio_wb32(pb, file_size - aiff->ssnd - 4);
/* return to the end */
url_fseek(pb, end_size, SEEK_SET);
diff --git a/libavformat/amr.c b/libavformat/amr.c
index 9c64d35716..3b78ba3659 100644
--- a/libavformat/amr.c
+++ b/libavformat/amr.c
@@ -56,7 +56,7 @@ static int amr_write_header(AVFormatContext *s)
static int amr_write_packet(AVFormatContext *s, AVPacket *pkt)
{
- put_buffer(s->pb, pkt->data, pkt->size);
+ avio_write(s->pb, pkt->data, pkt->size);
put_flush_packet(s->pb);
return 0;
}
diff --git a/libavformat/asfenc.c b/libavformat/asfenc.c
index a529c1bbdf..b181f2321e 100644
--- a/libavformat/asfenc.c
+++ b/libavformat/asfenc.c
@@ -226,7 +226,7 @@ static const AVCodecTag codec_asf_bmp_tags[] = {
static void put_guid(AVIOContext *s, const ff_asf_guid *g)
{
assert(sizeof(*g) == 16);
- put_buffer(s, *g, sizeof(*g));
+ avio_write(s, *g, sizeof(*g));
}
static void put_str16(AVIOContext *s, const char *tag)
@@ -239,8 +239,8 @@ static void put_str16(AVIOContext *s, const char *tag)
avio_put_str16le(dyn_buf, tag);
len = url_close_dyn_buf(dyn_buf, &pb);
- put_le16(s, len);
- put_buffer(s, pb, len);
+ avio_wl16(s, len);
+ avio_write(s, pb, len);
av_freep(&pb);
}
@@ -250,7 +250,7 @@ static int64_t put_header(AVIOContext *pb, const ff_asf_guid *g)
pos = url_ftell(pb);
put_guid(pb, g);
- put_le64(pb, 24);
+ avio_wl64(pb, 24);
return pos;
}
@@ -261,7 +261,7 @@ static void end_header(AVIOContext *pb, int64_t pos)
pos1 = url_ftell(pb);
url_fseek(pb, pos + 16, SEEK_SET);
- put_le64(pb, pos1 - pos);
+ avio_wl64(pb, pos1 - pos);
url_fseek(pb, pos1, SEEK_SET);
}
@@ -273,11 +273,11 @@ static void put_chunk(AVFormatContext *s, int type, int payload_length, int flag
int length;
length = payload_length + 8;
- put_le16(pb, type);
- put_le16(pb, length); //size
- put_le32(pb, asf->seqno);//sequence number
- put_le16(pb, flags); /* unknown bytes */
- put_le16(pb, length); //size_confirm
+ avio_wl16(pb, type);
+ avio_wl16(pb, length); //size
+ avio_wl32(pb, asf->seqno);//sequence number
+ avio_wl16(pb, flags); /* unknown bytes */
+ avio_wl16(pb, length); //size_confirm
asf->seqno++;
}
@@ -331,33 +331,33 @@ static int asf_write_header1(AVFormatContext *s, int64_t file_size, int64_t data
}
put_guid(pb, &ff_asf_header);
- put_le64(pb, -1); /* header length, will be patched after */
- put_le32(pb, 3 + has_title + !!metadata_count + s->nb_streams); /* number of chunks in header */
- put_byte(pb, 1); /* ??? */
- put_byte(pb, 2); /* ??? */
+ avio_wl64(pb, -1); /* header length, will be patched after */
+ avio_wl32(pb, 3 + has_title + !!metadata_count + s->nb_streams); /* number of chunks in header */
+ avio_w8(pb, 1); /* ??? */
+ avio_w8(pb, 2); /* ??? */
/* file header */
header_offset = url_ftell(pb);
hpos = put_header(pb, &ff_asf_file_header);
put_guid(pb, &ff_asf_my_guid);
- put_le64(pb, file_size);
+ avio_wl64(pb, file_size);
file_time = 0;
- put_le64(pb, unix_to_file_time(file_time));
- put_le64(pb, asf->nb_packets); /* number of packets */
- put_le64(pb, duration); /* end time stamp (in 100ns units) */
- put_le64(pb, asf->duration); /* duration (in 100ns units) */
- put_le64(pb, PREROLL_TIME); /* start time stamp */
- put_le32(pb, (asf->is_streamed || url_is_streamed(pb)) ? 3 : 2); /* ??? */
- put_le32(pb, s->packet_size); /* packet size */
- put_le32(pb, s->packet_size); /* packet size */
- put_le32(pb, bit_rate); /* Nominal data rate in bps */
+ avio_wl64(pb, unix_to_file_time(file_time));
+ avio_wl64(pb, asf->nb_packets); /* number of packets */
+ avio_wl64(pb, duration); /* end time stamp (in 100ns units) */
+ avio_wl64(pb, asf->duration); /* duration (in 100ns units) */
+ avio_wl64(pb, PREROLL_TIME); /* start time stamp */
+ avio_wl32(pb, (asf->is_streamed || url_is_streamed(pb)) ? 3 : 2); /* ??? */
+ avio_wl32(pb, s->packet_size); /* packet size */
+ avio_wl32(pb, s->packet_size); /* packet size */
+ avio_wl32(pb, bit_rate); /* Nominal data rate in bps */
end_header(pb, hpos);
/* unknown headers */
hpos = put_header(pb, &ff_asf_head1_guid);
put_guid(pb, &ff_asf_head2_guid);
- put_le32(pb, 6);
- put_le16(pb, 0);
+ avio_wl32(pb, 6);
+ avio_wl16(pb, 0);
end_header(pb, hpos);
/* title and other infos */
@@ -373,20 +373,20 @@ static int asf_write_header1(AVFormatContext *s, int64_t file_size, int64_t data
for (n = 0; n < FF_ARRAY_ELEMS(tags); n++) {
len = tags[n] ? avio_put_str16le(dyn_buf, tags[n]->value) : 0;
- put_le16(pb, len);
+ avio_wl16(pb, len);
}
len = url_close_dyn_buf(dyn_buf, &buf);
- put_buffer(pb, buf, len);
+ avio_write(pb, buf, len);
av_freep(&buf);
end_header(pb, hpos);
}
if (metadata_count) {
AVMetadataTag *tag = NULL;
hpos = put_header(pb, &ff_asf_extended_content_header);
- put_le16(pb, metadata_count);
+ avio_wl16(pb, metadata_count);
while ((tag = av_metadata_get(s->metadata, "", tag, AV_METADATA_IGNORE_SUFFIX))) {
put_str16(pb, tag->key);
- put_le16(pb, 0);
+ avio_wl16(pb, 0);
put_str16(pb, tag->value);
}
end_header(pb, hpos);
@@ -424,19 +424,19 @@ static int asf_write_header1(AVFormatContext *s, int64_t file_size, int64_t data
put_guid(pb, &ff_asf_video_stream);
put_guid(pb, &ff_asf_video_conceal_none);
}
- put_le64(pb, 0); /* ??? */
+ avio_wl64(pb, 0); /* ??? */
es_pos = url_ftell(pb);
- put_le32(pb, extra_size); /* wav header len */
- put_le32(pb, extra_size2); /* additional data len */
- put_le16(pb, n + 1); /* stream number */
- put_le32(pb, 0); /* ??? */
+ avio_wl32(pb, extra_size); /* wav header len */
+ avio_wl32(pb, extra_size2); /* additional data len */
+ avio_wl16(pb, n + 1); /* stream number */
+ avio_wl32(pb, 0); /* ??? */
if (enc->codec_type == AVMEDIA_TYPE_AUDIO) {
/* WAVEFORMATEX header */
int wavsize = ff_put_wav_header(pb, enc);
if ((enc->codec_id != CODEC_ID_MP3) && (enc->codec_id != CODEC_ID_MP2) && (enc->codec_id != CODEC_ID_ADPCM_IMA_WAV) && (enc->extradata_size==0)) {
wavsize += 2;
- put_le16(pb, 0);
+ avio_wl16(pb, 0);
}
if (wavsize < 0)
@@ -444,25 +444,25 @@ static int asf_write_header1(AVFormatContext *s, int64_t file_size, int64_t data
if (wavsize != extra_size) {
cur_pos = url_ftell(pb);
url_fseek(pb, es_pos, SEEK_SET);
- put_le32(pb, wavsize); /* wav header len */
+ avio_wl32(pb, wavsize); /* wav header len */
url_fseek(pb, cur_pos, SEEK_SET);
}
/* ERROR Correction */
- put_byte(pb, 0x01);
+ avio_w8(pb, 0x01);
if(enc->codec_id == CODEC_ID_ADPCM_G726 || !enc->block_align){
- put_le16(pb, 0x0190);
- put_le16(pb, 0x0190);
+ avio_wl16(pb, 0x0190);
+ avio_wl16(pb, 0x0190);
}else{
- put_le16(pb, enc->block_align);
- put_le16(pb, enc->block_align);
+ avio_wl16(pb, enc->block_align);
+ avio_wl16(pb, enc->block_align);
}
- put_le16(pb, 0x01);
- put_byte(pb, 0x00);
+ avio_wl16(pb, 0x01);
+ avio_w8(pb, 0x00);
} else {
- put_le32(pb, enc->width);
- put_le32(pb, enc->height);
- put_byte(pb, 2); /* ??? */
- put_le16(pb, 40 + enc->extradata_size); /* size */
+ avio_wl32(pb, enc->width);
+ avio_wl32(pb, enc->height);
+ avio_w8(pb, 2); /* ??? */
+ avio_wl16(pb, 40 + enc->extradata_size); /* size */
/* BITMAPINFOHEADER header */
ff_put_bmp_header(pb, enc, ff_codec_bmp_tags, 1);
@@ -474,7 +474,7 @@ static int asf_write_header1(AVFormatContext *s, int64_t file_size, int64_t data
hpos = put_header(pb, &ff_asf_codec_comment_header);
put_guid(pb, &ff_asf_codec_comment1_header);
- put_le32(pb, s->nb_streams);
+ avio_wl32(pb, s->nb_streams);
for(n=0;n<s->nb_streams;n++) {
AVCodec *p;
const char *desc;
@@ -486,11 +486,11 @@ static int asf_write_header1(AVFormatContext *s, int64_t file_size, int64_t data
p = avcodec_find_encoder(enc->codec_id);
if(enc->codec_type == AVMEDIA_TYPE_AUDIO)
- put_le16(pb, 2);
+ avio_wl16(pb, 2);
else if(enc->codec_type == AVMEDIA_TYPE_VIDEO)
- put_le16(pb, 1);
+ avio_wl16(pb, 1);
else
- put_le16(pb, -1);
+ avio_wl16(pb, -1);
if(enc->codec_id == CODEC_ID_WMAV2)
desc = "Windows Media Audio V8";
@@ -502,21 +502,21 @@ static int asf_write_header1(AVFormatContext *s, int64_t file_size, int64_t data
avio_put_str16le(dyn_buf, desc);
len = url_close_dyn_buf(dyn_buf, &buf);
- put_le16(pb, len / 2); // "number of characters" = length in bytes / 2
+ avio_wl16(pb, len / 2); // "number of characters" = length in bytes / 2
- put_buffer(pb, buf, len);
+ avio_write(pb, buf, len);
av_freep(&buf);
- put_le16(pb, 0); /* no parameters */
+ avio_wl16(pb, 0); /* no parameters */
/* id */
if (enc->codec_type == AVMEDIA_TYPE_AUDIO) {
- put_le16(pb, 2);
- put_le16(pb, enc->codec_tag);
+ avio_wl16(pb, 2);
+ avio_wl16(pb, enc->codec_tag);
} else {
- put_le16(pb, 4);
- put_le32(pb, enc->codec_tag);
+ avio_wl16(pb, 4);
+ avio_wl32(pb, enc->codec_tag);
}
if(!enc->codec_tag)
return -1;
@@ -531,25 +531,25 @@ static int asf_write_header1(AVFormatContext *s, int64_t file_size, int64_t data
header_size += 8 + 30 + 50;
url_fseek(pb, header_offset - 10 - 30, SEEK_SET);
- put_le16(pb, header_size);
+ avio_wl16(pb, header_size);
url_fseek(pb, header_offset - 2 - 30, SEEK_SET);
- put_le16(pb, header_size);
+ avio_wl16(pb, header_size);
header_size -= 8 + 30 + 50;
}
header_size += 24 + 6;
url_fseek(pb, header_offset - 14, SEEK_SET);
- put_le64(pb, header_size);
+ avio_wl64(pb, header_size);
url_fseek(pb, cur_pos, SEEK_SET);
/* movie chunk, followed by packets of packet_size */
asf->data_offset = cur_pos;
put_guid(pb, &ff_asf_data_header);
- put_le64(pb, data_chunk_size);
+ avio_wl64(pb, data_chunk_size);
put_guid(pb, &ff_asf_my_guid);
- put_le64(pb, asf->nb_packets); /* nb packets */
- put_byte(pb, 1); /* ??? */
- put_byte(pb, 1); /* ??? */
+ avio_wl64(pb, asf->nb_packets); /* nb packets */
+ avio_w8(pb, 1); /* ??? */
+ avio_w8(pb, 1); /* ??? */
return 0;
}
@@ -614,9 +614,9 @@ static int put_payload_parsing_info(
padsize--;
assert(padsize>=0);
- put_byte(pb, ASF_PACKET_ERROR_CORRECTION_FLAGS);
+ avio_w8(pb, ASF_PACKET_ERROR_CORRECTION_FLAGS);
for (i = 0; i < ASF_PACKET_ERROR_CORRECTION_DATA_SIZE; i++){
- put_byte(pb, 0x0);
+ avio_w8(pb, 0x0);
}
if (asf->multi_payloads_present)
@@ -628,19 +628,19 @@ static int put_payload_parsing_info(
else
iLengthTypeFlags |= ASF_PPI_FLAG_PADDING_LENGTH_FIELD_IS_WORD;
}
- put_byte(pb, iLengthTypeFlags);
+ avio_w8(pb, iLengthTypeFlags);
- put_byte(pb, ASF_PPI_PROPERTY_FLAGS);
+ avio_w8(pb, ASF_PPI_PROPERTY_FLAGS);
if (iLengthTypeFlags & ASF_PPI_FLAG_PADDING_LENGTH_FIELD_IS_WORD)
- put_le16(pb, padsize - 2);
+ avio_wl16(pb, padsize - 2);
if (iLengthTypeFlags & ASF_PPI_FLAG_PADDING_LENGTH_FIELD_IS_BYTE)
- put_byte(pb, padsize - 1);
+ avio_w8(pb, padsize - 1);
- put_le32(pb, sendtime);
- put_le16(pb, duration);
+ avio_wl32(pb, sendtime);
+ avio_wl16(pb, duration);
if (asf->multi_payloads_present)
- put_byte(pb, nb_payloads | ASF_PAYLOAD_FLAGS);
+ avio_w8(pb, nb_payloads | ASF_PAYLOAD_FLAGS);
ppi_size = url_ftell(pb) - start;
@@ -670,7 +670,7 @@ static void flush_packet(AVFormatContext *s)
assert(packet_hdr_size <= asf->packet_size_left);
memset(asf->packet_buf + packet_filled_size, 0, asf->packet_size_left);
- put_buffer(s->pb, asf->packet_buf, s->packet_size - packet_hdr_size);
+ avio_write(s->pb, asf->packet_buf, s->packet_size - packet_hdr_size);
put_flush_packet(s->pb);
asf->nb_packets++;
@@ -698,23 +698,23 @@ static void put_payload_header(
val = stream->num;
if (flags & AV_PKT_FLAG_KEY)
val |= ASF_PL_FLAG_KEY_FRAME;
- put_byte(pb, val);
+ avio_w8(pb, val);
- put_byte(pb, stream->seq); //Media object number
- put_le32(pb, m_obj_offset); //Offset Into Media Object
+ avio_w8(pb, stream->seq); //Media object number
+ avio_wl32(pb, m_obj_offset); //Offset Into Media Object
// Replicated Data shall be at least 8 bytes long.
// The first 4 bytes of data shall contain the
// Size of the Media Object that the payload belongs to.
// The next 4 bytes of data shall contain the
// Presentation Time for the media object that the payload belongs to.
- put_byte(pb, ASF_PAYLOAD_REPLICATED_DATA_LENGTH);
+ avio_w8(pb, ASF_PAYLOAD_REPLICATED_DATA_LENGTH);
- put_le32(pb, m_obj_size); //Replicated Data - Media Object Size
- put_le32(pb, presentation_time);//Replicated Data - Presentation Time
+ avio_wl32(pb, m_obj_size); //Replicated Data - Media Object Size
+ avio_wl32(pb, presentation_time);//Replicated Data - Presentation Time
if (asf->multi_payloads_present){
- put_le16(pb, payload_len); //payload length
+ avio_wl16(pb, payload_len); //payload length
}
}
@@ -762,7 +762,7 @@ static void put_frame(
payload_len = frag_len1 - 2; //additional byte need to put padding length
put_payload_header(s, stream, timestamp+PREROLL_TIME, m_obj_size, m_obj_offset, payload_len, flags);
- put_buffer(&asf->pb, buf, payload_len);
+ avio_write(&asf->pb, buf, payload_len);
if (asf->multi_payloads_present)
asf->packet_size_left -= (payload_len + PAYLOAD_HEADER_SIZE_MULTIPLE_PAYLOADS);
@@ -837,14 +837,14 @@ static int asf_write_index(AVFormatContext *s, ASFIndex *index, uint16_t max, ui
int i;
put_guid(pb, &ff_asf_simple_index_header);
- put_le64(pb, 24 + 16 + 8 + 4 + 4 + (4 + 2)*count);
+ avio_wl64(pb, 24 + 16 + 8 + 4 + 4 + (4 + 2)*count);
put_guid(pb, &ff_asf_my_guid);
- put_le64(pb, ASF_INDEXED_INTERVAL);
- put_le32(pb, max);
- put_le32(pb, count);
+ avio_wl64(pb, ASF_INDEXED_INTERVAL);
+ avio_wl32(pb, max);
+ avio_wl32(pb, count);
for(i=0; i<count; i++) {
- put_le32(pb, index[i].packet_number);
- put_le16(pb, index[i].packet_count);
+ avio_wl32(pb, index[i].packet_number);
+ avio_wl16(pb, index[i].packet_count);
}
return 0;
diff --git a/libavformat/assenc.c b/libavformat/assenc.c
index fdd5306028..9abe302744 100644
--- a/libavformat/assenc.c
+++ b/libavformat/assenc.c
@@ -42,7 +42,7 @@ static int write_header(AVFormatContext *s)
if(!end) end= avctx->extradata + avctx->extradata_size;
else end++;
- put_buffer(s->pb, p, end-p);
+ avio_write(s->pb, p, end-p);
ass->extra_index += end-p;
if(last && !memcmp(last, "[Events]", 8))
@@ -57,7 +57,7 @@ static int write_header(AVFormatContext *s)
static int write_packet(AVFormatContext *s, AVPacket *pkt)
{
- put_buffer(s->pb, pkt->data, pkt->size);
+ avio_write(s->pb, pkt->data, pkt->size);
put_flush_packet(s->pb);
@@ -69,7 +69,7 @@ static int write_trailer(AVFormatContext *s)
ASSContext *ass = s->priv_data;
AVCodecContext *avctx= s->streams[0]->codec;
- put_buffer(s->pb, avctx->extradata + ass->extra_index,
+ avio_write(s->pb, avctx->extradata + ass->extra_index,
avctx->extradata_size - ass->extra_index);
put_flush_packet(s->pb);
diff --git a/libavformat/au.c b/libavformat/au.c
index 16d53fec9d..486c514087 100644
--- a/libavformat/au.c
+++ b/libavformat/au.c
@@ -54,11 +54,11 @@ static int put_au_header(AVIOContext *pb, AVCodecContext *enc)
if(!enc->codec_tag)
return -1;
put_tag(pb, ".snd"); /* magic number */
- put_be32(pb, 24); /* header size */
- put_be32(pb, AU_UNKNOWN_SIZE); /* data size */
- put_be32(pb, (uint32_t)enc->codec_tag); /* codec ID */
- put_be32(pb, enc->sample_rate);
- put_be32(pb, (uint32_t)enc->channels);
+ avio_wb32(pb, 24); /* header size */
+ avio_wb32(pb, AU_UNKNOWN_SIZE); /* data size */
+ avio_wb32(pb, (uint32_t)enc->codec_tag); /* codec ID */
+ avio_wb32(pb, enc->sample_rate);
+ avio_wb32(pb, (uint32_t)enc->channels);
return 0;
}
@@ -81,7 +81,7 @@ static int au_write_header(AVFormatContext *s)
static int au_write_packet(AVFormatContext *s, AVPacket *pkt)
{
AVIOContext *pb = s->pb;
- put_buffer(pb, pkt->data, pkt->size);
+ avio_write(pb, pkt->data, pkt->size);
return 0;
}
@@ -95,7 +95,7 @@ static int au_write_trailer(AVFormatContext *s)
/* update file size */
file_size = url_ftell(pb);
url_fseek(pb, 8, SEEK_SET);
- put_be32(pb, (uint32_t)(file_size - 24));
+ avio_wb32(pb, (uint32_t)(file_size - 24));
url_fseek(pb, file_size, SEEK_SET);
put_flush_packet(pb);
diff --git a/libavformat/avc.c b/libavformat/avc.c
index 79fdf1a1c2..a39343b1ca 100644
--- a/libavformat/avc.c
+++ b/libavformat/avc.c
@@ -78,8 +78,8 @@ int ff_avc_parse_nal_units(AVIOContext *pb, const uint8_t *buf_in, int size)
while (nal_start < end) {
while(!*(nal_start++));
nal_end = ff_avc_find_startcode(nal_start, end);
- put_be32(pb, nal_end - nal_start);
- put_buffer(pb, nal_start, nal_end - nal_start);
+ avio_wb32(pb, nal_end - nal_start);
+ avio_write(pb, nal_start, nal_end - nal_start);
size += 4 + nal_end - nal_start;
nal_start = nal_end;
}
@@ -134,21 +134,21 @@ int ff_isom_write_avcc(AVIOContext *pb, const uint8_t *data, int len)
assert(sps);
assert(pps);
- put_byte(pb, 1); /* version */
- put_byte(pb, sps[1]); /* profile */
- put_byte(pb, sps[2]); /* profile compat */
- put_byte(pb, sps[3]); /* level */
- put_byte(pb, 0xff); /* 6 bits reserved (111111) + 2 bits nal size length - 1 (11) */
- put_byte(pb, 0xe1); /* 3 bits reserved (111) + 5 bits number of sps (00001) */
-
- put_be16(pb, sps_size);
- put_buffer(pb, sps, sps_size);
- put_byte(pb, 1); /* number of pps */
- put_be16(pb, pps_size);
- put_buffer(pb, pps, pps_size);
+ avio_w8(pb, 1); /* version */
+ avio_w8(pb, sps[1]); /* profile */
+ avio_w8(pb, sps[2]); /* profile compat */
+ avio_w8(pb, sps[3]); /* level */
+ avio_w8(pb, 0xff); /* 6 bits reserved (111111) + 2 bits nal size length - 1 (11) */
+ avio_w8(pb, 0xe1); /* 3 bits reserved (111) + 5 bits number of sps (00001) */
+
+ avio_wb16(pb, sps_size);
+ avio_write(pb, sps, sps_size);
+ avio_w8(pb, 1); /* number of pps */
+ avio_wb16(pb, pps_size);
+ avio_write(pb, pps, pps_size);
av_free(start);
} else {
- put_buffer(pb, data, len);
+ avio_write(pb, data, len);
}
}
return 0;
diff --git a/libavformat/avienc.c b/libavformat/avienc.c
index cf3b9fbce8..61af511350 100644
--- a/libavformat/avienc.c
+++ b/libavformat/avienc.c
@@ -108,10 +108,10 @@ static void avi_write_info_tag(AVIOContext *pb, const char *tag, const char *str
if (len > 0) {
len++;
put_tag(pb, tag);
- put_le32(pb, len);
+ avio_wl32(pb, len);
avio_put_str(pb, str);
if (len & 1)
- put_byte(pb, 0);
+ avio_w8(pb, 0);
}
}
@@ -132,9 +132,9 @@ static int avi_write_counters(AVFormatContext* s, int riff_id)
url_fseek(pb, avist->frames_hdr_strm, SEEK_SET);
ff_parse_specific_params(stream, &au_byterate, &au_ssize, &au_scale);
if(au_ssize == 0) {
- put_le32(pb, avist->packet_count);
+ avio_wl32(pb, avist->packet_count);
} else {
- put_le32(pb, avist->audio_strm_length / au_ssize);
+ avio_wl32(pb, avist->audio_strm_length / au_ssize);
}
if(stream->codec_type == AVMEDIA_TYPE_VIDEO)
nb_frames = FFMAX(nb_frames, avist->packet_count);
@@ -142,7 +142,7 @@ static int avi_write_counters(AVFormatContext* s, int riff_id)
if(riff_id == 1) {
assert(avi->frames_hdr_all);
url_fseek(pb, avi->frames_hdr_all, SEEK_SET);
- put_le32(pb, nb_frames);
+ avio_wl32(pb, nb_frames);
}
url_fseek(pb, file_size, SEEK_SET);
@@ -170,7 +170,7 @@ static int avi_write_header(AVFormatContext *s)
/* avi header */
put_tag(pb, "avih");
- put_le32(pb, 14 * 4);
+ avio_wl32(pb, 14 * 4);
bitrate = 0;
video_enc = NULL;
@@ -184,32 +184,32 @@ static int avi_write_header(AVFormatContext *s)
nb_frames = 0;
if(video_enc){
- put_le32(pb, (uint32_t)(INT64_C(1000000) * video_enc->time_base.num / video_enc->time_base.den));
+ avio_wl32(pb, (uint32_t)(INT64_C(1000000) * video_enc->time_base.num / video_enc->time_base.den));
} else {
- put_le32(pb, 0);
+ avio_wl32(pb, 0);
}
- put_le32(pb, bitrate / 8); /* XXX: not quite exact */
- put_le32(pb, 0); /* padding */
+ avio_wl32(pb, bitrate / 8); /* XXX: not quite exact */
+ avio_wl32(pb, 0); /* padding */
if (url_is_streamed(pb))
- put_le32(pb, AVIF_TRUSTCKTYPE | AVIF_ISINTERLEAVED); /* flags */
+ avio_wl32(pb, AVIF_TRUSTCKTYPE | AVIF_ISINTERLEAVED); /* flags */
else
- put_le32(pb, AVIF_TRUSTCKTYPE | AVIF_HASINDEX | AVIF_ISINTERLEAVED); /* flags */
+ avio_wl32(pb, AVIF_TRUSTCKTYPE | AVIF_HASINDEX | AVIF_ISINTERLEAVED); /* flags */
avi->frames_hdr_all = url_ftell(pb); /* remember this offset to fill later */
- put_le32(pb, nb_frames); /* nb frames, filled later */
- put_le32(pb, 0); /* initial frame */
- put_le32(pb, s->nb_streams); /* nb streams */
- put_le32(pb, 1024 * 1024); /* suggested buffer size */
+ avio_wl32(pb, nb_frames); /* nb frames, filled later */
+ avio_wl32(pb, 0); /* initial frame */
+ avio_wl32(pb, s->nb_streams); /* nb streams */
+ avio_wl32(pb, 1024 * 1024); /* suggested buffer size */
if(video_enc){
- put_le32(pb, video_enc->width);
- put_le32(pb, video_enc->height);
+ avio_wl32(pb, video_enc->width);
+ avio_wl32(pb, video_enc->height);
} else {
- put_le32(pb, 0);
- put_le32(pb, 0);
+ avio_wl32(pb, 0);
+ avio_wl32(pb, 0);
}
- put_le32(pb, 0); /* reserved */
- put_le32(pb, 0); /* reserved */
- put_le32(pb, 0); /* reserved */
- put_le32(pb, 0); /* reserved */
+ avio_wl32(pb, 0); /* reserved */
+ avio_wl32(pb, 0); /* reserved */
+ avio_wl32(pb, 0); /* reserved */
+ avio_wl32(pb, 0); /* reserved */
/* stream list */
for(i=0;i<n;i++) {
@@ -236,39 +236,39 @@ static int avi_write_header(AVFormatContext *s)
}
if(stream->codec_type == AVMEDIA_TYPE_VIDEO ||
stream->codec_id == CODEC_ID_XSUB)
- put_le32(pb, stream->codec_tag);
+ avio_wl32(pb, stream->codec_tag);
else
- put_le32(pb, 1);
- put_le32(pb, 0); /* flags */
- put_le16(pb, 0); /* priority */
- put_le16(pb, 0); /* language */
- put_le32(pb, 0); /* initial frame */
+ avio_wl32(pb, 1);
+ avio_wl32(pb, 0); /* flags */
+ avio_wl16(pb, 0); /* priority */
+ avio_wl16(pb, 0); /* language */
+ avio_wl32(pb, 0); /* initial frame */
ff_parse_specific_params(stream, &au_byterate, &au_ssize, &au_scale);
- put_le32(pb, au_scale); /* scale */
- put_le32(pb, au_byterate); /* rate */
+ avio_wl32(pb, au_scale); /* scale */
+ avio_wl32(pb, au_byterate); /* rate */
av_set_pts_info(s->streams[i], 64, au_scale, au_byterate);
- put_le32(pb, 0); /* start */
+ avio_wl32(pb, 0); /* start */
avist->frames_hdr_strm = url_ftell(pb); /* remember this offset to fill later */
if (url_is_streamed(pb))
- put_le32(pb, AVI_MAX_RIFF_SIZE); /* FIXME: this may be broken, but who cares */
+ avio_wl32(pb, AVI_MAX_RIFF_SIZE); /* FIXME: this may be broken, but who cares */
else
- put_le32(pb, 0); /* length, XXX: filled later */
+ avio_wl32(pb, 0); /* length, XXX: filled later */
/* suggested buffer size */ //FIXME set at the end to largest chunk
if(stream->codec_type == AVMEDIA_TYPE_VIDEO)
- put_le32(pb, 1024 * 1024);
+ avio_wl32(pb, 1024 * 1024);
else if(stream->codec_type == AVMEDIA_TYPE_AUDIO)
- put_le32(pb, 12 * 1024);
+ avio_wl32(pb, 12 * 1024);
else
- put_le32(pb, 0);
- put_le32(pb, -1); /* quality */
- put_le32(pb, au_ssize); /* sample size */
- put_le32(pb, 0);
- put_le16(pb, stream->width);
- put_le16(pb, stream->height);
+ avio_wl32(pb, 0);
+ avio_wl32(pb, -1); /* quality */
+ avio_wl32(pb, au_ssize); /* sample size */
+ avio_wl32(pb, 0);
+ avio_wl16(pb, stream->width);
+ avio_wl16(pb, stream->height);
ff_end_tag(pb, strh);
if(stream->codec_type != AVMEDIA_TYPE_DATA){
@@ -307,16 +307,16 @@ static int avi_write_header(AVFormatContext *s)
*/
avist->indexes.entry = avist->indexes.ents_allocated = 0;
avist->indexes.indx_start = ff_start_tag(pb, "JUNK");
- put_le16(pb, 4); /* wLongsPerEntry */
- put_byte(pb, 0); /* bIndexSubType (0 == frame index) */
- put_byte(pb, 0); /* bIndexType (0 == AVI_INDEX_OF_INDEXES) */
- put_le32(pb, 0); /* nEntriesInUse (will fill out later on) */
+ avio_wl16(pb, 4); /* wLongsPerEntry */
+ avio_w8(pb, 0); /* bIndexSubType (0 == frame index) */
+ avio_w8(pb, 0); /* bIndexType (0 == AVI_INDEX_OF_INDEXES) */
+ avio_wl32(pb, 0); /* nEntriesInUse (will fill out later on) */
put_tag(pb, avi_stream2fourcc(&tag[0], i, stream->codec_type));
/* dwChunkId */
- put_le64(pb, 0); /* dwReserved[3]
- put_le32(pb, 0); Must be 0. */
+ avio_wl64(pb, 0); /* dwReserved[3]
+ avio_wl32(pb, 0); Must be 0. */
for (j=0; j < AVI_MASTER_INDEX_SIZE * 2; j++)
- put_le64(pb, 0);
+ avio_wl64(pb, 0);
ff_end_tag(pb, avist->indexes.indx_start);
}
@@ -329,26 +329,26 @@ static int avi_write_header(AVFormatContext *s)
int num, den;
av_reduce(&num, &den, dar.num, dar.den, 0xFFFF);
- put_le32(pb, 0); //video format = unknown
- put_le32(pb, 0); //video standard= unknown
- put_le32(pb, lrintf(1.0/av_q2d(stream->time_base)));
- put_le32(pb, stream->width );
- put_le32(pb, stream->height);
- put_le16(pb, den);
- put_le16(pb, num);
- put_le32(pb, stream->width );
- put_le32(pb, stream->height);
- put_le32(pb, 1); //progressive FIXME
-
- put_le32(pb, stream->height);
- put_le32(pb, stream->width );
- put_le32(pb, stream->height);
- put_le32(pb, stream->width );
- put_le32(pb, 0);
- put_le32(pb, 0);
-
- put_le32(pb, 0);
- put_le32(pb, 0);
+ avio_wl32(pb, 0); //video format = unknown
+ avio_wl32(pb, 0); //video standard= unknown
+ avio_wl32(pb, lrintf(1.0/av_q2d(stream->time_base)));
+ avio_wl32(pb, stream->width );
+ avio_wl32(pb, stream->height);
+ avio_wl16(pb, den);
+ avio_wl16(pb, num);
+ avio_wl32(pb, stream->width );
+ avio_wl32(pb, stream->height);
+ avio_wl32(pb, 1); //progressive FIXME
+
+ avio_wl32(pb, stream->height);
+ avio_wl32(pb, stream->width );
+ avio_wl32(pb, stream->height);
+ avio_wl32(pb, stream->width );
+ avio_wl32(pb, 0);
+ avio_wl32(pb, 0);
+
+ avio_wl32(pb, 0);
+ avio_wl32(pb, 0);
ff_end_tag(pb, vprp);
}
@@ -360,9 +360,9 @@ static int avi_write_header(AVFormatContext *s)
avi->odml_list = ff_start_tag(pb, "JUNK");
put_tag(pb, "odml");
put_tag(pb, "dmlh");
- put_le32(pb, 248);
+ avio_wl32(pb, 248);
for (i = 0; i < 248; i+= 4)
- put_le32(pb, 0);
+ avio_wl32(pb, 0);
ff_end_tag(pb, avi->odml_list);
}
@@ -380,7 +380,7 @@ static int avi_write_header(AVFormatContext *s)
/* some padding for easier tag editing */
list2 = ff_start_tag(pb, "JUNK");
for (i = 0; i < 1016; i += 4)
- put_le32(pb, 0);
+ avio_wl32(pb, 0);
ff_end_tag(pb, list2);
avi->movi_list = ff_start_tag(pb, "LIST");
@@ -414,21 +414,21 @@ static int avi_write_ix(AVFormatContext *s)
/* Writing AVI OpenDML leaf index chunk */
ix = url_ftell(pb);
put_tag(pb, &ix_tag[0]); /* ix?? */
- put_le32(pb, avist->indexes.entry * 8 + 24);
+ avio_wl32(pb, avist->indexes.entry * 8 + 24);
/* chunk size */
- put_le16(pb, 2); /* wLongsPerEntry */
- put_byte(pb, 0); /* bIndexSubType (0 == frame index) */
- put_byte(pb, 1); /* bIndexType (1 == AVI_INDEX_OF_CHUNKS) */
- put_le32(pb, avist->indexes.entry);
+ avio_wl16(pb, 2); /* wLongsPerEntry */
+ avio_w8(pb, 0); /* bIndexSubType (0 == frame index) */
+ avio_w8(pb, 1); /* bIndexType (1 == AVI_INDEX_OF_CHUNKS) */
+ avio_wl32(pb, avist->indexes.entry);
/* nEntriesInUse */
put_tag(pb, &tag[0]); /* dwChunkId */
- put_le64(pb, avi->movi_list);/* qwBaseOffset */
- put_le32(pb, 0); /* dwReserved_3 (must be 0) */
+ avio_wl64(pb, avi->movi_list);/* qwBaseOffset */
+ avio_wl32(pb, 0); /* dwReserved_3 (must be 0) */
for (j=0; j<avist->indexes.entry; j++) {
AVIIentry* ie = avi_get_ientry(&avist->indexes, j);
- put_le32(pb, ie->pos + 8);
- put_le32(pb, ((uint32_t)ie->len & ~0x80000000) |
+ avio_wl32(pb, ie->pos + 8);
+ avio_wl32(pb, ((uint32_t)ie->len & ~0x80000000) |
(ie->flags & 0x10 ? 0 : 0x80000000));
}
put_flush_packet(pb);
@@ -438,11 +438,11 @@ static int avi_write_ix(AVFormatContext *s)
url_fseek(pb, avist->indexes.indx_start - 8, SEEK_SET);
put_tag(pb, "indx"); /* enabling this entry */
url_fskip(pb, 8);
- put_le32(pb, avi->riff_id); /* nEntriesInUse */
+ avio_wl32(pb, avi->riff_id); /* nEntriesInUse */
url_fskip(pb, 16*avi->riff_id);
- put_le64(pb, ix); /* qwOffset */
- put_le32(pb, pos - ix); /* dwSize */
- put_le32(pb, avist->indexes.entry); /* dwDuration */
+ avio_wl64(pb, ix); /* qwOffset */
+ avio_wl32(pb, pos - ix); /* dwSize */
+ avio_wl32(pb, avist->indexes.entry); /* dwDuration */
url_fseek(pb, pos, SEEK_SET);
}
@@ -487,9 +487,9 @@ static int avi_write_idx1(AVFormatContext *s)
avi_stream2fourcc(&tag[0], stream_id,
s->streams[stream_id]->codec->codec_type);
put_tag(pb, &tag[0]);
- put_le32(pb, ie->flags);
- put_le32(pb, ie->pos);
- put_le32(pb, ie->len);
+ avio_wl32(pb, ie->flags);
+ avio_wl32(pb, ie->pos);
+ avio_wl32(pb, ie->len);
avist->entry++;
}
} while (!empty);
@@ -565,11 +565,11 @@ static int avi_write_packet(AVFormatContext *s, AVPacket *pkt)
idx->entry++;
}
- put_buffer(pb, tag, 4);
- put_le32(pb, size);
- put_buffer(pb, pkt->data, size);
+ avio_write(pb, tag, 4);
+ avio_wl32(pb, size);
+ avio_write(pb, pkt->data, size);
if (size & 1)
- put_byte(pb, 0);
+ avio_w8(pb, 0);
put_flush_packet(pb);
return 0;
@@ -611,7 +611,7 @@ static int avi_write_trailer(AVFormatContext *s)
}
}
}
- put_le32(pb, nb_frames);
+ avio_wl32(pb, nb_frames);
url_fseek(pb, file_size, SEEK_SET);
avi_write_counters(s, avi->riff_id);
diff --git a/libavformat/avio.h b/libavformat/avio.h
index 43d94db790..f12b9f8127 100644
--- a/libavformat/avio.h
+++ b/libavformat/avio.h
@@ -395,6 +395,17 @@ attribute_deprecated unsigned int get_be16(AVIOContext *s);
attribute_deprecated unsigned int get_be24(AVIOContext *s);
attribute_deprecated unsigned int get_be32(AVIOContext *s);
attribute_deprecated uint64_t get_be64(AVIOContext *s);
+
+attribute_deprecated void put_byte(AVIOContext *s, int b);
+attribute_deprecated void put_buffer(AVIOContext *s, const unsigned char *buf, int size);
+attribute_deprecated void put_le64(AVIOContext *s, uint64_t val);
+attribute_deprecated void put_be64(AVIOContext *s, uint64_t val);
+attribute_deprecated void put_le32(AVIOContext *s, unsigned int val);
+attribute_deprecated void put_be32(AVIOContext *s, unsigned int val);
+attribute_deprecated void put_le24(AVIOContext *s, unsigned int val);
+attribute_deprecated void put_be24(AVIOContext *s, unsigned int val);
+attribute_deprecated void put_le16(AVIOContext *s, unsigned int val);
+attribute_deprecated void put_be16(AVIOContext *s, unsigned int val);
/**
* @}
*/
@@ -409,17 +420,17 @@ AVIOContext *avio_alloc_context(
int (*write_packet)(void *opaque, uint8_t *buf, int buf_size),
int64_t (*seek)(void *opaque, int64_t offset, int whence));
-void put_byte(AVIOContext *s, int b);
+void avio_w8(AVIOContext *s, int b);
void put_nbyte(AVIOContext *s, int b, int count);
-void put_buffer(AVIOContext *s, const unsigned char *buf, int size);
-void put_le64(AVIOContext *s, uint64_t val);
-void put_be64(AVIOContext *s, uint64_t val);
-void put_le32(AVIOContext *s, unsigned int val);
-void put_be32(AVIOContext *s, unsigned int val);
-void put_le24(AVIOContext *s, unsigned int val);
-void put_be24(AVIOContext *s, unsigned int val);
-void put_le16(AVIOContext *s, unsigned int val);
-void put_be16(AVIOContext *s, unsigned int val);
+void avio_write(AVIOContext *s, const unsigned char *buf, int size);
+void avio_wl64(AVIOContext *s, uint64_t val);
+void avio_wb64(AVIOContext *s, uint64_t val);
+void avio_wl32(AVIOContext *s, unsigned int val);
+void avio_wb32(AVIOContext *s, unsigned int val);
+void avio_wl24(AVIOContext *s, unsigned int val);
+void avio_wb24(AVIOContext *s, unsigned int val);
+void avio_wl16(AVIOContext *s, unsigned int val);
+void avio_wb16(AVIOContext *s, unsigned int val);
void put_tag(AVIOContext *s, const char *tag);
#if FF_API_OLD_AVIO
diff --git a/libavformat/aviobuf.c b/libavformat/aviobuf.c
index fd1419893c..275794deb9 100644
--- a/libavformat/aviobuf.c
+++ b/libavformat/aviobuf.c
@@ -134,7 +134,7 @@ static void flush_buffer(AVIOContext *s)
s->buf_ptr = s->buffer;
}
-void put_byte(AVIOContext *s, int b)
+void avio_w8(AVIOContext *s, int b)
{
*(s->buf_ptr)++ = b;
if (s->buf_ptr >= s->buf_end)
@@ -155,7 +155,7 @@ void put_nbyte(AVIOContext *s, int b, int count)
}
}
-void put_buffer(AVIOContext *s, const unsigned char *buf, int size)
+void avio_write(AVIOContext *s, const unsigned char *buf, int size)
{
while (size > 0) {
int len = FFMIN(s->buf_end - s->buf_ptr, size);
@@ -277,20 +277,20 @@ int url_ferror(AVIOContext *s)
return s->error;
}
-void put_le32(AVIOContext *s, unsigned int val)
+void avio_wl32(AVIOContext *s, unsigned int val)
{
- put_byte(s, val);
- put_byte(s, val >> 8);
- put_byte(s, val >> 16);
- put_byte(s, val >> 24);
+ avio_w8(s, val);
+ avio_w8(s, val >> 8);
+ avio_w8(s, val >> 16);
+ avio_w8(s, val >> 24);
}
-void put_be32(AVIOContext *s, unsigned int val)
+void avio_wb32(AVIOContext *s, unsigned int val)
{
- put_byte(s, val >> 24);
- put_byte(s, val >> 16);
- put_byte(s, val >> 8);
- put_byte(s, val);
+ avio_w8(s, val >> 24);
+ avio_w8(s, val >> 16);
+ avio_w8(s, val >> 8);
+ avio_w8(s, val);
}
#if FF_API_OLD_AVIO
@@ -316,6 +316,22 @@ GET(64, uint64_t)
#undef GET
+#define PUT(name, type ) \
+ void put_le ##name(AVIOContext *s, type val)\
+{\
+ avio_wl ##name(s, val);\
+}\
+ void put_be ##name(AVIOContext *s, type val)\
+{\
+ avio_wb ##name(s, val);\
+}
+
+PUT(16, unsigned int)
+PUT(24, unsigned int)
+PUT(32, unsigned int)
+PUT(64, uint64_t)
+#undef PUT
+
int get_byte(AVIOContext *s)
{
return avio_r8(s);
@@ -328,6 +344,14 @@ int get_partial_buffer(AVIOContext *s, unsigned char *buf, int size)
{
return ffio_read_partial(s, buf, size);
}
+void put_byte(AVIOContext *s, int val)
+{
+ avio_w8(s, val);
+}
+void put_buffer(AVIOContext *s, const unsigned char *buf, int size)
+{
+ avio_write(s, buf, size);
+}
#endif
int avio_put_str(AVIOContext *s, const char *str)
@@ -335,9 +359,9 @@ int avio_put_str(AVIOContext *s, const char *str)
int len = 1;
if (str) {
len += strlen(str);
- put_buffer(s, (const unsigned char *) str, len);
+ avio_write(s, (const unsigned char *) str, len);
} else
- put_byte(s, 0);
+ avio_w8(s, 0);
return len;
}
@@ -351,9 +375,9 @@ int avio_put_str16le(AVIOContext *s, const char *str)
uint16_t tmp;
GET_UTF8(ch, *q++, break;)
- PUT_UTF16(ch, tmp, put_le16(s, tmp);ret += 2;)
+ PUT_UTF16(ch, tmp, avio_wl16(s, tmp);ret += 2;)
}
- put_le16(s, 0);
+ avio_wl16(s, 0);
ret += 2;
return ret;
}
@@ -371,51 +395,51 @@ void ff_put_v(AVIOContext *bc, uint64_t val){
int i= ff_get_v_length(val);
while(--i>0)
- put_byte(bc, 128 | (val>>(7*i)));
+ avio_w8(bc, 128 | (val>>(7*i)));
- put_byte(bc, val&127);
+ avio_w8(bc, val&127);
}
-void put_le64(AVIOContext *s, uint64_t val)
+void avio_wl64(AVIOContext *s, uint64_t val)
{
- put_le32(s, (uint32_t)(val & 0xffffffff));
- put_le32(s, (uint32_t)(val >> 32));
+ avio_wl32(s, (uint32_t)(val & 0xffffffff));
+ avio_wl32(s, (uint32_t)(val >> 32));
}
-void put_be64(AVIOContext *s, uint64_t val)
+void avio_wb64(AVIOContext *s, uint64_t val)
{
- put_be32(s, (uint32_t)(val >> 32));
- put_be32(s, (uint32_t)(val & 0xffffffff));
+ avio_wb32(s, (uint32_t)(val >> 32));
+ avio_wb32(s, (uint32_t)(val & 0xffffffff));
}
-void put_le16(AVIOContext *s, unsigned int val)
+void avio_wl16(AVIOContext *s, unsigned int val)
{
- put_byte(s, val);
- put_byte(s, val >> 8);
+ avio_w8(s, val);
+ avio_w8(s, val >> 8);
}
-void put_be16(AVIOContext *s, unsigned int val)
+void avio_wb16(AVIOContext *s, unsigned int val)
{
- put_byte(s, val >> 8);
- put_byte(s, val);
+ avio_w8(s, val >> 8);
+ avio_w8(s, val);
}
-void put_le24(AVIOContext *s, unsigned int val)
+void avio_wl24(AVIOContext *s, unsigned int val)
{
- put_le16(s, val & 0xffff);
- put_byte(s, val >> 16);
+ avio_wl16(s, val & 0xffff);
+ avio_w8(s, val >> 16);
}
-void put_be24(AVIOContext *s, unsigned int val)
+void avio_wb24(AVIOContext *s, unsigned int val)
{
- put_be16(s, val >> 8);
- put_byte(s, val);
+ avio_wb16(s, val >> 8);
+ avio_w8(s, val);
}
void put_tag(AVIOContext *s, const char *tag)
{
while (*tag) {
- put_byte(s, *tag++);
+ avio_w8(s, *tag++);
}
}
@@ -855,7 +879,7 @@ int url_fprintf(AVIOContext *s, const char *fmt, ...)
va_start(ap, fmt);
ret = vsnprintf(buf, sizeof(buf), fmt, ap);
va_end(ap);
- put_buffer(s, buf, strlen(buf));
+ avio_write(s, buf, strlen(buf));
return ret;
}
#endif //CONFIG_MUXERS
@@ -1056,7 +1080,7 @@ int url_close_dyn_buf(AVIOContext *s, uint8_t **pbuffer)
/* don't attempt to pad fixed-size packet buffers */
if (!s->max_packet_size) {
- put_buffer(s, padbuf, sizeof(padbuf));
+ avio_write(s, padbuf, sizeof(padbuf));
padding = FF_INPUT_BUFFER_PADDING_SIZE;
}
diff --git a/libavformat/crcenc.c b/libavformat/crcenc.c
index 2f9a099a21..ec106b0b38 100644
--- a/libavformat/crcenc.c
+++ b/libavformat/crcenc.c
@@ -49,7 +49,7 @@ static int crc_write_trailer(struct AVFormatContext *s)
char buf[64];
snprintf(buf, sizeof(buf), "CRC=0x%08x\n", crc->crcval);
- put_buffer(s->pb, buf, strlen(buf));
+ avio_write(s->pb, buf, strlen(buf));
put_flush_packet(s->pb);
return 0;
}
diff --git a/libavformat/daud.c b/libavformat/daud.c
index c4931961ec..39a994b605 100644
--- a/libavformat/daud.c
+++ b/libavformat/daud.c
@@ -57,9 +57,9 @@ static int daud_write_header(struct AVFormatContext *s)
static int daud_write_packet(struct AVFormatContext *s, AVPacket *pkt)
{
- put_be16(s->pb, pkt->size);
- put_be16(s->pb, 0x8010); // unknown
- put_buffer(s->pb, pkt->data, pkt->size);
+ avio_wb16(s->pb, pkt->size);
+ avio_wb16(s->pb, 0x8010); // unknown
+ avio_write(s->pb, pkt->data, pkt->size);
put_flush_packet(s->pb);
return 0;
}
diff --git a/libavformat/dvenc.c b/libavformat/dvenc.c
index faaa529813..6d90024eef 100644
--- a/libavformat/dvenc.c
+++ b/libavformat/dvenc.c
@@ -381,7 +381,7 @@ static int dv_write_packet(struct AVFormatContext *s, AVPacket *pkt)
fsize = dv_assemble_frame(s->priv_data, s->streams[pkt->stream_index],
pkt->data, pkt->size, &frame);
if (fsize > 0) {
- put_buffer(s->pb, frame, fsize);
+ avio_write(s->pb, frame, fsize);
put_flush_packet(s->pb);
}
return 0;
diff --git a/libavformat/ffmenc.c b/libavformat/ffmenc.c
index 858bd2ffc5..eeaaa22945 100644
--- a/libavformat/ffmenc.c
+++ b/libavformat/ffmenc.c
@@ -36,14 +36,14 @@ static void flush_packet(AVFormatContext *s)
av_abort();
/* put header */
- put_be16(pb, PACKET_ID);
- put_be16(pb, fill_size);
- put_be64(pb, ffm->dts);
+ avio_wb16(pb, PACKET_ID);
+ avio_wb16(pb, fill_size);
+ avio_wb64(pb, ffm->dts);
h = ffm->frame_offset;
if (ffm->first_packet)
h |= 0x8000;
- put_be16(pb, h);
- put_buffer(pb, ffm->packet, ffm->packet_end - ffm->packet);
+ avio_wb16(pb, h);
+ avio_write(pb, ffm->packet, ffm->packet_end - ffm->packet);
put_flush_packet(pb);
/* prepare next packet */
@@ -91,17 +91,17 @@ static int ffm_write_header(AVFormatContext *s)
ffm->packet_size = FFM_PACKET_SIZE;
/* header */
- put_le32(pb, MKTAG('F', 'F', 'M', '1'));
- put_be32(pb, ffm->packet_size);
- put_be64(pb, 0); /* current write position */
+ avio_wl32(pb, MKTAG('F', 'F', 'M', '1'));
+ avio_wb32(pb, ffm->packet_size);
+ avio_wb64(pb, 0); /* current write position */
- put_be32(pb, s->nb_streams);
+ avio_wb32(pb, s->nb_streams);
bit_rate = 0;
for(i=0;i<s->nb_streams;i++) {
st = s->streams[i];
bit_rate += st->codec->bit_rate;
}
- put_be32(pb, bit_rate);
+ avio_wb32(pb, bit_rate);
/* list of streams */
for(i=0;i<s->nb_streams;i++) {
@@ -110,82 +110,82 @@ static int ffm_write_header(AVFormatContext *s)
codec = st->codec;
/* generic info */
- put_be32(pb, codec->codec_id);
- put_byte(pb, codec->codec_type);
- put_be32(pb, codec->bit_rate);
- put_be32(pb, st->quality);
- put_be32(pb, codec->flags);
- put_be32(pb, codec->flags2);
- put_be32(pb, codec->debug);
+ avio_wb32(pb, codec->codec_id);
+ avio_w8(pb, codec->codec_type);
+ avio_wb32(pb, codec->bit_rate);
+ avio_wb32(pb, st->quality);
+ avio_wb32(pb, codec->flags);
+ avio_wb32(pb, codec->flags2);
+ avio_wb32(pb, codec->debug);
/* specific info */
switch(codec->codec_type) {
case AVMEDIA_TYPE_VIDEO:
- put_be32(pb, codec->time_base.num);
- put_be32(pb, codec->time_base.den);
- put_be16(pb, codec->width);
- put_be16(pb, codec->height);
- put_be16(pb, codec->gop_size);
- put_be32(pb, codec->pix_fmt);
- put_byte(pb, codec->qmin);
- put_byte(pb, codec->qmax);
- put_byte(pb, codec->max_qdiff);
- put_be16(pb, (int) (codec->qcompress * 10000.0));
- put_be16(pb, (int) (codec->qblur * 10000.0));
- put_be32(pb, codec->bit_rate_tolerance);
+ avio_wb32(pb, codec->time_base.num);
+ avio_wb32(pb, codec->time_base.den);
+ avio_wb16(pb, codec->width);
+ avio_wb16(pb, codec->height);
+ avio_wb16(pb, codec->gop_size);
+ avio_wb32(pb, codec->pix_fmt);
+ avio_w8(pb, codec->qmin);
+ avio_w8(pb, codec->qmax);
+ avio_w8(pb, codec->max_qdiff);
+ avio_wb16(pb, (int) (codec->qcompress * 10000.0));
+ avio_wb16(pb, (int) (codec->qblur * 10000.0));
+ avio_wb32(pb, codec->bit_rate_tolerance);
avio_put_str(pb, codec->rc_eq ? codec->rc_eq : "tex^qComp");
- put_be32(pb, codec->rc_max_rate);
- put_be32(pb, codec->rc_min_rate);
- put_be32(pb, codec->rc_buffer_size);
- put_be64(pb, av_dbl2int(codec->i_quant_factor));
- put_be64(pb, av_dbl2int(codec->b_quant_factor));
- put_be64(pb, av_dbl2int(codec->i_quant_offset));
- put_be64(pb, av_dbl2int(codec->b_quant_offset));
- put_be32(pb, codec->dct_algo);
- put_be32(pb, codec->strict_std_compliance);
- put_be32(pb, codec->max_b_frames);
- put_be32(pb, codec->luma_elim_threshold);
- put_be32(pb, codec->chroma_elim_threshold);
- put_be32(pb, codec->mpeg_quant);
- put_be32(pb, codec->intra_dc_precision);
- put_be32(pb, codec->me_method);
- put_be32(pb, codec->mb_decision);
- put_be32(pb, codec->nsse_weight);
- put_be32(pb, codec->frame_skip_cmp);
- put_be64(pb, av_dbl2int(codec->rc_buffer_aggressivity));
- put_be32(pb, codec->codec_tag);
- put_byte(pb, codec->thread_count);
- put_be32(pb, codec->coder_type);
- put_be32(pb, codec->me_cmp);
- put_be32(pb, codec->partitions);
- put_be32(pb, codec->me_subpel_quality);
- put_be32(pb, codec->me_range);
- put_be32(pb, codec->keyint_min);
- put_be32(pb, codec->scenechange_threshold);
- put_be32(pb, codec->b_frame_strategy);
- put_be64(pb, av_dbl2int(codec->qcompress));
- put_be64(pb, av_dbl2int(codec->qblur));
- put_be32(pb, codec->max_qdiff);
- put_be32(pb, codec->refs);
- put_be32(pb, codec->directpred);
+ avio_wb32(pb, codec->rc_max_rate);
+ avio_wb32(pb, codec->rc_min_rate);
+ avio_wb32(pb, codec->rc_buffer_size);
+ avio_wb64(pb, av_dbl2int(codec->i_quant_factor));
+ avio_wb64(pb, av_dbl2int(codec->b_quant_factor));
+ avio_wb64(pb, av_dbl2int(codec->i_quant_offset));
+ avio_wb64(pb, av_dbl2int(codec->b_quant_offset));
+ avio_wb32(pb, codec->dct_algo);
+ avio_wb32(pb, codec->strict_std_compliance);
+ avio_wb32(pb, codec->max_b_frames);
+ avio_wb32(pb, codec->luma_elim_threshold);
+ avio_wb32(pb, codec->chroma_elim_threshold);
+ avio_wb32(pb, codec->mpeg_quant);
+ avio_wb32(pb, codec->intra_dc_precision);
+ avio_wb32(pb, codec->me_method);
+ avio_wb32(pb, codec->mb_decision);
+ avio_wb32(pb, codec->nsse_weight);
+ avio_wb32(pb, codec->frame_skip_cmp);
+ avio_wb64(pb, av_dbl2int(codec->rc_buffer_aggressivity));
+ avio_wb32(pb, codec->codec_tag);
+ avio_w8(pb, codec->thread_count);
+ avio_wb32(pb, codec->coder_type);
+ avio_wb32(pb, codec->me_cmp);
+ avio_wb32(pb, codec->partitions);
+ avio_wb32(pb, codec->me_subpel_quality);
+ avio_wb32(pb, codec->me_range);
+ avio_wb32(pb, codec->keyint_min);
+ avio_wb32(pb, codec->scenechange_threshold);
+ avio_wb32(pb, codec->b_frame_strategy);
+ avio_wb64(pb, av_dbl2int(codec->qcompress));
+ avio_wb64(pb, av_dbl2int(codec->qblur));
+ avio_wb32(pb, codec->max_qdiff);
+ avio_wb32(pb, codec->refs);
+ avio_wb32(pb, codec->directpred);
break;
case AVMEDIA_TYPE_AUDIO:
- put_be32(pb, codec->sample_rate);
- put_le16(pb, codec->channels);
- put_le16(pb, codec->frame_size);
- put_le16(pb, codec->sample_fmt);
+ avio_wb32(pb, codec->sample_rate);
+ avio_wl16(pb, codec->channels);
+ avio_wl16(pb, codec->frame_size);
+ avio_wl16(pb, codec->sample_fmt);
break;
default:
return -1;
}
if (codec->flags & CODEC_FLAG_GLOBAL_HEADER) {
- put_be32(pb, codec->extradata_size);
- put_buffer(pb, codec->extradata, codec->extradata_size);
+ avio_wb32(pb, codec->extradata_size);
+ avio_write(pb, codec->extradata, codec->extradata_size);
}
}
/* flush until end of block reached */
while ((url_ftell(pb) % ffm->packet_size) != 0)
- put_byte(pb, 0);
+ avio_w8(pb, 0);
put_flush_packet(pb);
diff --git a/libavformat/ffmetaenc.c b/libavformat/ffmetaenc.c
index 68b22e9551..322ec0f576 100644
--- a/libavformat/ffmetaenc.c
+++ b/libavformat/ffmetaenc.c
@@ -31,8 +31,8 @@ static void write_escape_str(AVIOContext *s, const uint8_t *str)
while (*p) {
if (*p == '#' || *p == ';' || *p == '=' || *p == '\\' || *p == '\n')
- put_byte(s, '\\');
- put_byte(s, *p);
+ avio_w8(s, '\\');
+ avio_w8(s, *p);
p++;
}
}
@@ -42,17 +42,17 @@ static void write_tags(AVIOContext *s, AVMetadata *m)
AVMetadataTag *t = NULL;
while ((t = av_metadata_get(m, "", t, AV_METADATA_IGNORE_SUFFIX))) {
write_escape_str(s, t->key);
- put_byte(s, '=');
+ avio_w8(s, '=');
write_escape_str(s, t->value);
- put_byte(s, '\n');
+ avio_w8(s, '\n');
}
}
static int write_header(AVFormatContext *s)
{
put_tag(s->pb, ID_STRING);
- put_byte(s->pb, '1'); // version
- put_byte(s->pb, '\n');
+ avio_w8(s->pb, '1'); // version
+ avio_w8(s->pb, '\n');
put_flush_packet(s->pb);
return 0;
}
@@ -65,14 +65,14 @@ static int write_trailer(AVFormatContext *s)
for (i = 0; i < s->nb_streams; i++) {
put_tag(s->pb, ID_STREAM);
- put_byte(s->pb, '\n');
+ 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);
- put_byte(s->pb, '\n');
+ 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);
url_fprintf(s->pb, "END=%"PRId64"\n", ch->end);
diff --git a/libavformat/filmstripenc.c b/libavformat/filmstripenc.c
index 3fdfa4a36a..d20b4ecd4c 100644
--- a/libavformat/filmstripenc.c
+++ b/libavformat/filmstripenc.c
@@ -45,7 +45,7 @@ static int write_header(AVFormatContext *s)
static int write_packet(AVFormatContext *s, AVPacket *pkt)
{
FilmstripMuxContext *film = s->priv_data;
- put_buffer(s->pb, pkt->data, pkt->size);
+ avio_write(s->pb, pkt->data, pkt->size);
film->nb_frames++;
return 0;
}
@@ -57,16 +57,16 @@ static int write_trailer(AVFormatContext *s)
AVStream *st = s->streams[0];
int i;
- put_be32(pb, RAND_TAG);
- put_be32(pb, film->nb_frames);
- put_be16(pb, 0); // packing method
- put_be16(pb, 0); // reserved
- put_be16(pb, st->codec->width);
- put_be16(pb, st->codec->height);
- put_be16(pb, 0); // leading
- put_be16(pb, 1/av_q2d(st->codec->time_base));
+ avio_wb32(pb, RAND_TAG);
+ avio_wb32(pb, film->nb_frames);
+ avio_wb16(pb, 0); // packing method
+ avio_wb16(pb, 0); // reserved
+ avio_wb16(pb, st->codec->width);
+ avio_wb16(pb, st->codec->height);
+ avio_wb16(pb, 0); // leading
+ avio_wb16(pb, 1/av_q2d(st->codec->time_base));
for (i = 0; i < 16; i++)
- put_byte(pb, 0x00); // reserved
+ avio_w8(pb, 0x00); // reserved
put_flush_packet(pb);
return 0;
}
diff --git a/libavformat/flacenc.c b/libavformat/flacenc.c
index 8f5f6c2128..d11d75d27d 100644
--- a/libavformat/flacenc.c
+++ b/libavformat/flacenc.c
@@ -30,10 +30,10 @@
static int flac_write_block_padding(AVIOContext *pb, unsigned int n_padding_bytes,
int last_block)
{
- put_byte(pb, last_block ? 0x81 : 0x01);
- put_be24(pb, n_padding_bytes);
+ avio_w8(pb, last_block ? 0x81 : 0x01);
+ avio_wb24(pb, n_padding_bytes);
while (n_padding_bytes > 0) {
- put_byte(pb, 0);
+ avio_w8(pb, 0);
n_padding_bytes--;
}
return 0;
@@ -58,7 +58,7 @@ static int flac_write_block_comment(AVIOContext *pb, AVMetadata **m,
bytestream_put_be24(&p, len);
ff_vorbiscomment_write(&p, m, vendor, count);
- put_buffer(pb, p0, len+4);
+ avio_write(pb, p0, len+4);
av_freep(&p0);
p = NULL;
@@ -102,7 +102,7 @@ static int flac_write_trailer(struct AVFormatContext *s)
/* rewrite the STREAMINFO header block data */
file_size = url_ftell(pb);
url_fseek(pb, 8, SEEK_SET);
- put_buffer(pb, streaminfo, FLAC_STREAMINFO_SIZE);
+ avio_write(pb, streaminfo, FLAC_STREAMINFO_SIZE);
url_fseek(pb, file_size, SEEK_SET);
put_flush_packet(pb);
} else {
@@ -113,7 +113,7 @@ static int flac_write_trailer(struct AVFormatContext *s)
static int flac_write_packet(struct AVFormatContext *s, AVPacket *pkt)
{
- put_buffer(s->pb, pkt->data, pkt->size);
+ avio_write(s->pb, pkt->data, pkt->size);
put_flush_packet(s->pb);
return 0;
}
diff --git a/libavformat/flacenc_header.c b/libavformat/flacenc_header.c
index fa7ed48241..389efbd01a 100644
--- a/libavformat/flacenc_header.c
+++ b/libavformat/flacenc_header.c
@@ -39,11 +39,11 @@ int ff_flac_write_header(AVIOContext *pb, AVCodecContext *codec,
/* write "fLaC" stream marker and first metadata block header if needed */
if (format == FLAC_EXTRADATA_FORMAT_STREAMINFO) {
- put_buffer(pb, header, 8);
+ avio_write(pb, header, 8);
}
/* write STREAMINFO or full header */
- put_buffer(pb, codec->extradata, codec->extradata_size);
+ avio_write(pb, codec->extradata, codec->extradata_size);
return 0;
}
diff --git a/libavformat/flvenc.c b/libavformat/flvenc.c
index a092c30c1e..71a3784396 100644
--- a/libavformat/flvenc.c
+++ b/libavformat/flvenc.c
@@ -142,31 +142,31 @@ static int get_audio_flags(AVCodecContext *enc){
static void put_amf_string(AVIOContext *pb, const char *str)
{
size_t len = strlen(str);
- put_be16(pb, len);
- put_buffer(pb, str, len);
+ avio_wb16(pb, len);
+ avio_write(pb, str, len);
}
static void put_avc_eos_tag(AVIOContext *pb, unsigned ts) {
- put_byte(pb, FLV_TAG_TYPE_VIDEO);
- put_be24(pb, 5); /* Tag Data Size */
- put_be24(pb, ts); /* lower 24 bits of timestamp in ms*/
- put_byte(pb, (ts >> 24) & 0x7F); /* MSB of ts in ms*/
- put_be24(pb, 0); /* StreamId = 0 */
- put_byte(pb, 23); /* ub[4] FrameType = 1, ub[4] CodecId = 7 */
- put_byte(pb, 2); /* AVC end of sequence */
- put_be24(pb, 0); /* Always 0 for AVC EOS. */
- put_be32(pb, 16); /* Size of FLV tag */
+ avio_w8(pb, FLV_TAG_TYPE_VIDEO);
+ avio_wb24(pb, 5); /* Tag Data Size */
+ avio_wb24(pb, ts); /* lower 24 bits of timestamp in ms*/
+ avio_w8(pb, (ts >> 24) & 0x7F); /* MSB of ts in ms*/
+ avio_wb24(pb, 0); /* StreamId = 0 */
+ avio_w8(pb, 23); /* ub[4] FrameType = 1, ub[4] CodecId = 7 */
+ avio_w8(pb, 2); /* AVC end of sequence */
+ avio_wb24(pb, 0); /* Always 0 for AVC EOS. */
+ avio_wb32(pb, 16); /* Size of FLV tag */
}
static void put_amf_double(AVIOContext *pb, double d)
{
- put_byte(pb, AMF_DATA_TYPE_NUMBER);
- put_be64(pb, av_dbl2int(d));
+ avio_w8(pb, AMF_DATA_TYPE_NUMBER);
+ avio_wb64(pb, av_dbl2int(d));
}
static void put_amf_bool(AVIOContext *pb, int b) {
- put_byte(pb, AMF_DATA_TYPE_BOOL);
- put_byte(pb, !!b);
+ avio_w8(pb, AMF_DATA_TYPE_BOOL);
+ avio_w8(pb, !!b);
}
static int flv_write_header(AVFormatContext *s)
@@ -200,19 +200,19 @@ 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");
- put_byte(pb,1);
- put_byte(pb, FLV_HEADER_FLAG_HASAUDIO * !!audio_enc
+ avio_w8(pb,1);
+ avio_w8(pb, FLV_HEADER_FLAG_HASAUDIO * !!audio_enc
+ FLV_HEADER_FLAG_HASVIDEO * !!video_enc);
- put_be32(pb,9);
- put_be32(pb,0);
+ avio_wb32(pb,9);
+ avio_wb32(pb,0);
for(i=0; i<s->nb_streams; i++){
if(s->streams[i]->codec->codec_tag == 5){
- put_byte(pb,8); // message type
- put_be24(pb,0); // include flags
- put_be24(pb,0); // time stamp
- put_be32(pb,0); // reserved
- put_be32(pb,11); // size
+ avio_w8(pb,8); // message type
+ avio_wb24(pb,0); // include flags
+ avio_wb24(pb,0); // time stamp
+ avio_wb32(pb,0); // reserved
+ avio_wb32(pb,11); // size
flv->reserved=5;
}
}
@@ -220,21 +220,21 @@ static int flv_write_header(AVFormatContext *s)
flv->last_video_ts = -1;
/* write meta_tag */
- put_byte(pb, 18); // tag type META
+ avio_w8(pb, 18); // tag type META
metadata_size_pos= url_ftell(pb);
- put_be24(pb, 0); // size of data part (sum of all parts below)
- put_be24(pb, 0); // time stamp
- put_be32(pb, 0); // reserved
+ avio_wb24(pb, 0); // size of data part (sum of all parts below)
+ avio_wb24(pb, 0); // time stamp
+ avio_wb32(pb, 0); // reserved
/* now data of data_size size */
/* first event name as a string */
- put_byte(pb, AMF_DATA_TYPE_STRING);
+ avio_w8(pb, AMF_DATA_TYPE_STRING);
put_amf_string(pb, "onMetaData"); // 12 bytes
/* mixed array (hash) with size and string/type/data tuples */
- put_byte(pb, AMF_DATA_TYPE_MIXEDARRAY);
- put_be32(pb, 5*!!video_enc + 5*!!audio_enc + 2); // +2 for duration and file size
+ avio_w8(pb, AMF_DATA_TYPE_MIXEDARRAY);
+ avio_wb32(pb, 5*!!video_enc + 5*!!audio_enc + 2); // +2 for duration and file size
put_amf_string(pb, "duration");
flv->duration_offset= url_ftell(pb);
@@ -276,7 +276,7 @@ static int flv_write_header(AVFormatContext *s)
while ((tag = av_metadata_get(s->metadata, "", tag, AV_METADATA_IGNORE_SUFFIX))) {
put_amf_string(pb, tag->key);
- put_byte(pb, AMF_DATA_TYPE_STRING);
+ avio_w8(pb, AMF_DATA_TYPE_STRING);
put_amf_string(pb, tag->value);
}
@@ -285,41 +285,41 @@ static int flv_write_header(AVFormatContext *s)
put_amf_double(pb, 0); // delayed write
put_amf_string(pb, "");
- put_byte(pb, AMF_END_OF_OBJECT);
+ avio_w8(pb, AMF_END_OF_OBJECT);
/* write total size of tag */
data_size= url_ftell(pb) - metadata_size_pos - 10;
url_fseek(pb, metadata_size_pos, SEEK_SET);
- put_be24(pb, data_size);
+ avio_wb24(pb, data_size);
url_fseek(pb, data_size + 10 - 3, SEEK_CUR);
- put_be32(pb, data_size + 11);
+ avio_wb32(pb, data_size + 11);
for (i = 0; i < s->nb_streams; i++) {
AVCodecContext *enc = s->streams[i]->codec;
if (enc->codec_id == CODEC_ID_AAC || enc->codec_id == CODEC_ID_H264) {
int64_t pos;
- put_byte(pb, enc->codec_type == AVMEDIA_TYPE_VIDEO ?
+ avio_w8(pb, enc->codec_type == AVMEDIA_TYPE_VIDEO ?
FLV_TAG_TYPE_VIDEO : FLV_TAG_TYPE_AUDIO);
- put_be24(pb, 0); // size patched later
- put_be24(pb, 0); // ts
- put_byte(pb, 0); // ts ext
- put_be24(pb, 0); // streamid
+ avio_wb24(pb, 0); // size patched later
+ avio_wb24(pb, 0); // ts
+ avio_w8(pb, 0); // ts ext
+ avio_wb24(pb, 0); // streamid
pos = url_ftell(pb);
if (enc->codec_id == CODEC_ID_AAC) {
- put_byte(pb, get_audio_flags(enc));
- put_byte(pb, 0); // AAC sequence header
- put_buffer(pb, enc->extradata, enc->extradata_size);
+ avio_w8(pb, get_audio_flags(enc));
+ avio_w8(pb, 0); // AAC sequence header
+ avio_write(pb, enc->extradata, enc->extradata_size);
} else {
- put_byte(pb, enc->codec_tag | FLV_FRAME_KEY); // flags
- put_byte(pb, 0); // AVC sequence header
- put_be24(pb, 0); // composition time
+ avio_w8(pb, enc->codec_tag | FLV_FRAME_KEY); // flags
+ avio_w8(pb, 0); // AVC sequence header
+ avio_wb24(pb, 0); // composition time
ff_isom_write_avcc(pb, enc->extradata, enc->extradata_size);
}
data_size = url_ftell(pb) - pos;
url_fseek(pb, -data_size - 10, SEEK_CUR);
- put_be24(pb, data_size);
+ avio_wb24(pb, data_size);
url_fseek(pb, data_size + 10 - 3, SEEK_CUR);
- put_be32(pb, data_size + 11); // previous tag size
+ avio_wb32(pb, data_size + 11); // previous tag size
}
}
@@ -376,7 +376,7 @@ static int flv_write_packet(AVFormatContext *s, AVPacket *pkt)
flags_size= 1;
if (enc->codec_type == AVMEDIA_TYPE_VIDEO) {
- put_byte(pb, FLV_TAG_TYPE_VIDEO);
+ avio_w8(pb, FLV_TAG_TYPE_VIDEO);
flags = enc->codec_tag;
if(flags == 0) {
@@ -391,7 +391,7 @@ static int flv_write_packet(AVFormatContext *s, AVPacket *pkt)
assert(size);
- put_byte(pb, FLV_TAG_TYPE_AUDIO);
+ avio_w8(pb, FLV_TAG_TYPE_AUDIO);
}
if (enc->codec_id == CODEC_ID_H264) {
@@ -409,25 +409,25 @@ static int flv_write_packet(AVFormatContext *s, AVPacket *pkt)
if (flv->last_video_ts < ts)
flv->last_video_ts = ts;
}
- put_be24(pb,size + flags_size);
- put_be24(pb,ts);
- put_byte(pb,(ts >> 24) & 0x7F); // timestamps are 32bits _signed_
- put_be24(pb,flv->reserved);
- put_byte(pb,flags);
+ avio_wb24(pb,size + flags_size);
+ avio_wb24(pb,ts);
+ avio_w8(pb,(ts >> 24) & 0x7F); // timestamps are 32bits _signed_
+ avio_wb24(pb,flv->reserved);
+ avio_w8(pb,flags);
if (enc->codec_id == CODEC_ID_VP6)
- put_byte(pb,0);
+ avio_w8(pb,0);
if (enc->codec_id == CODEC_ID_VP6F)
- put_byte(pb, enc->extradata_size ? enc->extradata[0] : 0);
+ avio_w8(pb, enc->extradata_size ? enc->extradata[0] : 0);
else if (enc->codec_id == CODEC_ID_AAC)
- put_byte(pb,1); // AAC raw
+ avio_w8(pb,1); // AAC raw
else if (enc->codec_id == CODEC_ID_H264) {
- put_byte(pb,1); // AVC NALU
- put_be24(pb,pkt->pts - pkt->dts);
+ avio_w8(pb,1); // AVC NALU
+ avio_wb24(pb,pkt->pts - pkt->dts);
}
- put_buffer(pb, data ? data : pkt->data, size);
+ avio_write(pb, data ? data : pkt->data, size);
- put_be32(pb,size+flags_size+11); // previous tag size
+ avio_wb32(pb,size+flags_size+11); // previous tag size
flv->duration = FFMAX(flv->duration, pkt->pts + flv->delay + pkt->duration);
put_flush_packet(pb);
diff --git a/libavformat/framecrcenc.c b/libavformat/framecrcenc.c
index f456ec6816..26ede95495 100644
--- a/libavformat/framecrcenc.c
+++ b/libavformat/framecrcenc.c
@@ -28,7 +28,7 @@ static int framecrc_write_packet(struct AVFormatContext *s, AVPacket *pkt)
char buf[256];
snprintf(buf, sizeof(buf), "%d, %"PRId64", %d, 0x%08x\n", pkt->stream_index, pkt->dts, pkt->size, crc);
- put_buffer(s->pb, buf, strlen(buf));
+ avio_write(s->pb, buf, strlen(buf));
put_flush_packet(s->pb);
return 0;
}
diff --git a/libavformat/gif.c b/libavformat/gif.c
index 2fdd5cdae0..f3f64d1fcc 100644
--- a/libavformat/gif.c
+++ b/libavformat/gif.c
@@ -116,24 +116,24 @@ static int gif_image_write_header(AVIOContext *pb,
put_tag(pb, "GIF");
put_tag(pb, "89a");
- put_le16(pb, width);
- put_le16(pb, height);
+ avio_wl16(pb, width);
+ avio_wl16(pb, height);
- put_byte(pb, 0xf7); /* flags: global clut, 256 entries */
- put_byte(pb, 0x1f); /* background color index */
- put_byte(pb, 0); /* aspect ratio */
+ avio_w8(pb, 0xf7); /* flags: global clut, 256 entries */
+ avio_w8(pb, 0x1f); /* background color index */
+ avio_w8(pb, 0); /* aspect ratio */
/* the global palette */
if (!palette) {
- put_buffer(pb, (const unsigned char *)gif_clut, 216*3);
+ avio_write(pb, (const unsigned char *)gif_clut, 216*3);
for(i=0;i<((256-216)*3);i++)
- put_byte(pb, 0);
+ avio_w8(pb, 0);
} else {
for(i=0;i<256;i++) {
v = palette[i];
- put_byte(pb, (v >> 16) & 0xff);
- put_byte(pb, (v >> 8) & 0xff);
- put_byte(pb, (v) & 0xff);
+ avio_w8(pb, (v >> 16) & 0xff);
+ avio_w8(pb, (v >> 8) & 0xff);
+ avio_w8(pb, (v) & 0xff);
}
}
@@ -159,14 +159,14 @@ static int gif_image_write_header(AVIOContext *pb,
/* application extension header */
#ifdef GIF_ADD_APP_HEADER
if (loop_count >= 0 && loop_count <= 65535) {
- put_byte(pb, 0x21);
- put_byte(pb, 0xff);
- put_byte(pb, 0x0b);
+ avio_w8(pb, 0x21);
+ avio_w8(pb, 0xff);
+ avio_w8(pb, 0x0b);
put_tag(pb, "NETSCAPE2.0"); // bytes 4 to 14
- put_byte(pb, 0x03); // byte 15
- put_byte(pb, 0x01); // byte 16
- put_le16(pb, (uint16_t)loop_count);
- put_byte(pb, 0x00); // byte 19
+ avio_w8(pb, 0x03); // byte 15
+ avio_w8(pb, 0x01); // byte 16
+ avio_wl16(pb, (uint16_t)loop_count);
+ avio_w8(pb, 0x00); // byte 19
}
#endif
return 0;
@@ -189,15 +189,15 @@ static int gif_image_write_image(AVIOContext *pb,
const uint8_t *ptr;
/* image block */
- put_byte(pb, 0x2c);
- put_le16(pb, x1);
- put_le16(pb, y1);
- put_le16(pb, width);
- put_le16(pb, height);
- put_byte(pb, 0x00); /* flags */
+ avio_w8(pb, 0x2c);
+ avio_wl16(pb, x1);
+ avio_wl16(pb, y1);
+ avio_wl16(pb, width);
+ avio_wl16(pb, height);
+ avio_w8(pb, 0x00); /* flags */
/* no local clut */
- put_byte(pb, 0x08);
+ avio_w8(pb, 0x08);
left= width * height;
@@ -233,13 +233,13 @@ static int gif_image_write_image(AVIOContext *pb,
flush_put_bits(&p);
}
if(put_bits_ptr(&p) - p.buf > 0) {
- put_byte(pb, put_bits_ptr(&p) - p.buf); /* byte count of the packet */
- put_buffer(pb, p.buf, put_bits_ptr(&p) - p.buf); /* the actual buffer */
+ avio_w8(pb, put_bits_ptr(&p) - p.buf); /* byte count of the packet */
+ avio_write(pb, p.buf, put_bits_ptr(&p) - p.buf); /* the actual buffer */
p.buf_ptr = p.buf; /* dequeue the bytes off the bitstream */
}
left-=GIF_CHUNKS;
}
- put_byte(pb, 0x00); /* end of image block */
+ avio_w8(pb, 0x00); /* end of image block */
return 0;
}
@@ -300,10 +300,10 @@ static int gif_write_video(AVFormatContext *s,
int64_t delay;
/* graphic control extension block */
- put_byte(pb, 0x21);
- put_byte(pb, 0xf9);
- put_byte(pb, 0x04); /* block size */
- put_byte(pb, 0x04); /* flags */
+ avio_w8(pb, 0x21);
+ avio_w8(pb, 0xf9);
+ avio_w8(pb, 0x04); /* block size */
+ avio_w8(pb, 0x04); /* flags */
/* 1 jiffy is 1/70 s */
/* the delay_time field indicates the number of jiffies - 1 */
@@ -314,10 +314,10 @@ static int gif_write_video(AVFormatContext *s,
/* XXX: don't even remember if I really use it for now */
jiffies = (70*enc->time_base.num/enc->time_base.den) - 1;
- put_le16(pb, jiffies);
+ avio_wl16(pb, jiffies);
- put_byte(pb, 0x1f); /* transparent color index */
- put_byte(pb, 0x00);
+ avio_w8(pb, 0x1f); /* transparent color index */
+ avio_w8(pb, 0x00);
gif_image_write_image(pb, 0, 0, enc->width, enc->height,
buf, enc->width * 3, PIX_FMT_RGB24);
@@ -339,7 +339,7 @@ static int gif_write_trailer(AVFormatContext *s)
{
AVIOContext *pb = s->pb;
- put_byte(pb, 0x3b);
+ avio_w8(pb, 0x3b);
put_flush_packet(s->pb);
return 0;
}
diff --git a/libavformat/gxfenc.c b/libavformat/gxfenc.c
index 60db45d3e5..fb6f441f3e 100644
--- a/libavformat/gxfenc.c
+++ b/libavformat/gxfenc.c
@@ -116,7 +116,7 @@ static int gxf_find_lines_index(AVStream *st)
static void gxf_write_padding(AVIOContext *pb, int64_t to_pad)
{
for (; to_pad > 0; to_pad--) {
- put_byte(pb, 0);
+ avio_w8(pb, 0);
}
}
@@ -132,7 +132,7 @@ static int64_t updatePacketSize(AVIOContext *pb, int64_t pos)
}
curpos = url_ftell(pb);
url_fseek(pb, pos + 6, SEEK_SET);
- put_be32(pb, size);
+ avio_wb32(pb, size);
url_fseek(pb, curpos, SEEK_SET);
return curpos - pos;
}
@@ -143,20 +143,20 @@ static int64_t updateSize(AVIOContext *pb, int64_t pos)
curpos = url_ftell(pb);
url_fseek(pb, pos, SEEK_SET);
- put_be16(pb, curpos - pos - 2);
+ avio_wb16(pb, curpos - pos - 2);
url_fseek(pb, curpos, SEEK_SET);
return curpos - pos;
}
static void gxf_write_packet_header(AVIOContext *pb, GXFPktType type)
{
- put_be32(pb, 0); /* packet leader for synchro */
- put_byte(pb, 1);
- put_byte(pb, type); /* map packet */
- put_be32(pb, 0); /* size */
- put_be32(pb, 0); /* reserved */
- put_byte(pb, 0xE1); /* trailer 1 */
- put_byte(pb, 0xE2); /* trailer 2 */
+ avio_wb32(pb, 0); /* packet leader for synchro */
+ avio_w8(pb, 1);
+ avio_w8(pb, type); /* map packet */
+ avio_wb32(pb, 0); /* size */
+ avio_wb32(pb, 0); /* reserved */
+ avio_w8(pb, 0xE1); /* trailer 1 */
+ avio_w8(pb, 0xE2); /* trailer 2 */
}
static int gxf_write_mpeg_auxiliary(AVIOContext *pb, AVStream *st)
@@ -191,20 +191,20 @@ static int gxf_write_mpeg_auxiliary(AVIOContext *pb, AVStream *st)
(float)st->codec->bit_rate, sc->p_per_gop, sc->b_per_i_or_p,
st->codec->pix_fmt == PIX_FMT_YUV422P ? 2 : 1, sc->first_gop_closed == 1,
starting_line, (st->codec->height + 15) / 16);
- put_byte(pb, TRACK_MPG_AUX);
- put_byte(pb, size + 1);
- put_buffer(pb, (uint8_t *)buffer, size + 1);
+ avio_w8(pb, TRACK_MPG_AUX);
+ avio_w8(pb, size + 1);
+ avio_write(pb, (uint8_t *)buffer, size + 1);
return size + 3;
}
static int gxf_write_timecode_auxiliary(AVIOContext *pb, GXFStreamContext *sc)
{
- put_byte(pb, 0); /* fields */
- put_byte(pb, 0); /* seconds */
- put_byte(pb, 0); /* minutes */
- put_byte(pb, 0); /* flags + hours */
+ avio_w8(pb, 0); /* fields */
+ avio_w8(pb, 0); /* seconds */
+ avio_w8(pb, 0); /* minutes */
+ avio_w8(pb, 0); /* flags + hours */
/* reserved */
- put_be32(pb, 0);
+ avio_wb32(pb, 0);
return 8;
}
@@ -215,51 +215,51 @@ static int gxf_write_track_description(AVFormatContext *s, GXFStreamContext *sc,
int mpeg = sc->track_type == 4 || sc->track_type == 9;
/* track description section */
- put_byte(pb, sc->media_type + 0x80);
- put_byte(pb, index + 0xC0);
+ avio_w8(pb, sc->media_type + 0x80);
+ avio_w8(pb, index + 0xC0);
pos = url_ftell(pb);
- put_be16(pb, 0); /* size */
+ avio_wb16(pb, 0); /* size */
/* media file name */
- put_byte(pb, TRACK_NAME);
- put_byte(pb, strlen(ES_NAME_PATTERN) + 3);
+ avio_w8(pb, TRACK_NAME);
+ avio_w8(pb, strlen(ES_NAME_PATTERN) + 3);
put_tag(pb, ES_NAME_PATTERN);
- put_be16(pb, sc->media_info);
- put_byte(pb, 0);
+ avio_wb16(pb, sc->media_info);
+ avio_w8(pb, 0);
if (!mpeg) {
/* auxiliary information */
- put_byte(pb, TRACK_AUX);
- put_byte(pb, 8);
+ avio_w8(pb, TRACK_AUX);
+ avio_w8(pb, 8);
if (sc->track_type == 3)
gxf_write_timecode_auxiliary(pb, sc);
else
- put_le64(pb, 0);
+ avio_wl64(pb, 0);
}
/* file system version */
- put_byte(pb, TRACK_VER);
- put_byte(pb, 4);
- put_be32(pb, 0);
+ avio_w8(pb, TRACK_VER);
+ avio_w8(pb, 4);
+ avio_wb32(pb, 0);
if (mpeg)
gxf_write_mpeg_auxiliary(pb, s->streams[index]);
/* frame rate */
- put_byte(pb, TRACK_FPS);
- put_byte(pb, 4);
- put_be32(pb, sc->frame_rate_index);
+ avio_w8(pb, TRACK_FPS);
+ avio_w8(pb, 4);
+ avio_wb32(pb, sc->frame_rate_index);
/* lines per frame */
- put_byte(pb, TRACK_LINES);
- put_byte(pb, 4);
- put_be32(pb, sc->lines_index);
+ avio_w8(pb, TRACK_LINES);
+ avio_w8(pb, 4);
+ avio_wb32(pb, sc->lines_index);
/* fields per frame */
- put_byte(pb, TRACK_FPF);
- put_byte(pb, 4);
- put_be32(pb, sc->fields);
+ avio_w8(pb, TRACK_FPF);
+ avio_w8(pb, 4);
+ avio_wb32(pb, sc->fields);
return updateSize(pb, pos);
}
@@ -272,42 +272,42 @@ static int gxf_write_material_data_section(AVFormatContext *s)
const char *filename = strrchr(s->filename, '/');
pos = url_ftell(pb);
- put_be16(pb, 0); /* size */
+ avio_wb16(pb, 0); /* size */
/* name */
if (filename)
filename++;
else
filename = s->filename;
- put_byte(pb, MAT_NAME);
- put_byte(pb, strlen(SERVER_PATH) + strlen(filename) + 1);
+ avio_w8(pb, MAT_NAME);
+ avio_w8(pb, strlen(SERVER_PATH) + strlen(filename) + 1);
put_tag(pb, SERVER_PATH);
put_tag(pb, filename);
- put_byte(pb, 0);
+ avio_w8(pb, 0);
/* first field */
- put_byte(pb, MAT_FIRST_FIELD);
- put_byte(pb, 4);
- put_be32(pb, 0);
+ avio_w8(pb, MAT_FIRST_FIELD);
+ avio_w8(pb, 4);
+ avio_wb32(pb, 0);
/* last field */
- put_byte(pb, MAT_LAST_FIELD);
- put_byte(pb, 4);
- put_be32(pb, gxf->nb_fields);
+ avio_w8(pb, MAT_LAST_FIELD);
+ avio_w8(pb, 4);
+ avio_wb32(pb, gxf->nb_fields);
/* reserved */
- put_byte(pb, MAT_MARK_IN);
- put_byte(pb, 4);
- put_be32(pb, 0);
+ avio_w8(pb, MAT_MARK_IN);
+ avio_w8(pb, 4);
+ avio_wb32(pb, 0);
- put_byte(pb, MAT_MARK_OUT);
- put_byte(pb, 4);
- put_be32(pb, gxf->nb_fields);
+ avio_w8(pb, MAT_MARK_OUT);
+ avio_w8(pb, 4);
+ avio_wb32(pb, gxf->nb_fields);
/* estimated size */
- put_byte(pb, MAT_SIZE);
- put_byte(pb, 4);
- put_be32(pb, url_fsize(pb) / 1024);
+ avio_w8(pb, MAT_SIZE);
+ avio_w8(pb, 4);
+ avio_wb32(pb, url_fsize(pb) / 1024);
return updateSize(pb, pos);
}
@@ -320,7 +320,7 @@ static int gxf_write_track_description_section(AVFormatContext *s)
int i;
pos = url_ftell(pb);
- put_be16(pb, 0); /* size */
+ avio_wb16(pb, 0); /* size */
for (i = 0; i < s->nb_streams; ++i)
gxf_write_track_description(s, s->streams[i]->priv_data, i);
@@ -350,8 +350,8 @@ static int gxf_write_map_packet(AVFormatContext *s, int rewrite)
gxf_write_packet_header(pb, PKT_MAP);
/* preamble */
- put_byte(pb, 0xE0); /* version */
- put_byte(pb, 0xFF); /* reserved */
+ avio_w8(pb, 0xE0); /* version */
+ avio_w8(pb, 0xFF); /* reserved */
gxf_write_material_data_section(s);
gxf_write_track_description_section(s);
@@ -370,16 +370,16 @@ static int gxf_write_flt_packet(AVFormatContext *s)
gxf_write_packet_header(pb, PKT_FLT);
- put_le32(pb, fields_per_flt); /* number of fields */
- put_le32(pb, flt_entries); /* number of active flt entries */
+ avio_wl32(pb, fields_per_flt); /* number of fields */
+ avio_wl32(pb, flt_entries); /* number of active flt entries */
if (gxf->flt_entries) {
for (i = 0; i < flt_entries; i++)
- put_le32(pb, gxf->flt_entries[(i*fields_per_flt)>>1]);
+ avio_wl32(pb, gxf->flt_entries[(i*fields_per_flt)>>1]);
}
for (; i < 1000; i++)
- put_le32(pb, 0);
+ avio_wl32(pb, 0);
return updatePacketSize(pb, pos);
}
@@ -397,21 +397,21 @@ static int gxf_write_umf_material_description(AVFormatContext *s)
gxf->nb_fields / timecode_base % 60 << 8 | // seconds
gxf->nb_fields % timecode_base; // fields
- put_le32(pb, gxf->flags);
- put_le32(pb, gxf->nb_fields); /* length of the longest track */
- put_le32(pb, gxf->nb_fields); /* length of the shortest track */
- put_le32(pb, 0); /* mark in */
- put_le32(pb, gxf->nb_fields); /* mark out */
- put_le32(pb, 0); /* timecode mark in */
- put_le32(pb, timecode); /* timecode mark out */
- put_le64(pb, s->timestamp); /* modification time */
- put_le64(pb, s->timestamp); /* creation time */
- put_le16(pb, 0); /* reserved */
- put_le16(pb, 0); /* reserved */
- put_le16(pb, gxf->audio_tracks);
- put_le16(pb, 1); /* timecode track count */
- put_le16(pb, 0); /* reserved */
- put_le16(pb, gxf->mpeg_tracks);
+ avio_wl32(pb, gxf->flags);
+ avio_wl32(pb, gxf->nb_fields); /* length of the longest track */
+ avio_wl32(pb, gxf->nb_fields); /* length of the shortest track */
+ avio_wl32(pb, 0); /* mark in */
+ avio_wl32(pb, gxf->nb_fields); /* mark out */
+ avio_wl32(pb, 0); /* timecode mark in */
+ avio_wl32(pb, timecode); /* timecode mark out */
+ avio_wl64(pb, s->timestamp); /* modification time */
+ avio_wl64(pb, s->timestamp); /* creation time */
+ avio_wl16(pb, 0); /* reserved */
+ avio_wl16(pb, 0); /* reserved */
+ avio_wl16(pb, gxf->audio_tracks);
+ avio_wl16(pb, 1); /* timecode track count */
+ avio_wl16(pb, 0); /* reserved */
+ avio_wl16(pb, gxf->mpeg_tracks);
return 48;
}
@@ -420,18 +420,18 @@ static int gxf_write_umf_payload(AVFormatContext *s)
GXFContext *gxf = s->priv_data;
AVIOContext *pb = s->pb;
- put_le32(pb, gxf->umf_length); /* total length of the umf data */
- put_le32(pb, 3); /* version */
- put_le32(pb, s->nb_streams+1);
- put_le32(pb, gxf->umf_track_offset); /* umf track section offset */
- put_le32(pb, gxf->umf_track_size);
- put_le32(pb, s->nb_streams+1);
- put_le32(pb, gxf->umf_media_offset);
- put_le32(pb, gxf->umf_media_size);
- put_le32(pb, gxf->umf_length); /* user data offset */
- put_le32(pb, 0); /* user data size */
- put_le32(pb, 0); /* reserved */
- put_le32(pb, 0); /* reserved */
+ avio_wl32(pb, gxf->umf_length); /* total length of the umf data */
+ avio_wl32(pb, 3); /* version */
+ avio_wl32(pb, s->nb_streams+1);
+ avio_wl32(pb, gxf->umf_track_offset); /* umf track section offset */
+ avio_wl32(pb, gxf->umf_track_size);
+ avio_wl32(pb, s->nb_streams+1);
+ avio_wl32(pb, gxf->umf_media_offset);
+ avio_wl32(pb, gxf->umf_media_size);
+ avio_wl32(pb, gxf->umf_length); /* user data offset */
+ avio_wl32(pb, 0); /* user data size */
+ avio_wl32(pb, 0); /* reserved */
+ avio_wl32(pb, 0); /* reserved */
return 48;
}
@@ -445,12 +445,12 @@ static int gxf_write_umf_track_description(AVFormatContext *s)
gxf->umf_track_offset = pos - gxf->umf_start_offset;
for (i = 0; i < s->nb_streams; ++i) {
GXFStreamContext *sc = s->streams[i]->priv_data;
- put_le16(pb, sc->media_info);
- put_le16(pb, 1);
+ avio_wl16(pb, sc->media_info);
+ avio_wl16(pb, 1);
}
- put_le16(pb, gxf->timecode_track.media_info);
- put_le16(pb, 1);
+ avio_wl16(pb, gxf->timecode_track.media_info);
+ avio_wl16(pb, 1);
return url_ftell(pb) - pos;
}
@@ -460,34 +460,34 @@ static int gxf_write_umf_media_mpeg(AVIOContext *pb, AVStream *st)
GXFStreamContext *sc = st->priv_data;
if (st->codec->pix_fmt == PIX_FMT_YUV422P)
- put_le32(pb, 2);
+ avio_wl32(pb, 2);
else
- put_le32(pb, 1); /* default to 420 */
- put_le32(pb, sc->first_gop_closed == 1); /* closed = 1, open = 0, unknown = 255 */
- put_le32(pb, 3); /* top = 1, bottom = 2, frame = 3, unknown = 0 */
- put_le32(pb, 1); /* I picture per GOP */
- put_le32(pb, sc->p_per_gop);
- put_le32(pb, sc->b_per_i_or_p);
+ avio_wl32(pb, 1); /* default to 420 */
+ avio_wl32(pb, sc->first_gop_closed == 1); /* closed = 1, open = 0, unknown = 255 */
+ avio_wl32(pb, 3); /* top = 1, bottom = 2, frame = 3, unknown = 0 */
+ avio_wl32(pb, 1); /* I picture per GOP */
+ avio_wl32(pb, sc->p_per_gop);
+ avio_wl32(pb, sc->b_per_i_or_p);
if (st->codec->codec_id == CODEC_ID_MPEG2VIDEO)
- put_le32(pb, 2);
+ avio_wl32(pb, 2);
else if (st->codec->codec_id == CODEC_ID_MPEG1VIDEO)
- put_le32(pb, 1);
+ avio_wl32(pb, 1);
else
- put_le32(pb, 0);
- put_le32(pb, 0); /* reserved */
+ avio_wl32(pb, 0);
+ avio_wl32(pb, 0); /* reserved */
return 32;
}
static int gxf_write_umf_media_timecode(AVIOContext *pb, GXFStreamContext *sc)
{
- put_le32(pb, 1); /* non drop frame */
- put_le32(pb, 0); /* reserved */
- put_le32(pb, 0); /* reserved */
- put_le32(pb, 0); /* reserved */
- put_le32(pb, 0); /* reserved */
- put_le32(pb, 0); /* reserved */
- put_le32(pb, 0); /* reserved */
- put_le32(pb, 0); /* reserved */
+ avio_wl32(pb, 1); /* non drop frame */
+ avio_wl32(pb, 0); /* reserved */
+ avio_wl32(pb, 0); /* reserved */
+ avio_wl32(pb, 0); /* reserved */
+ avio_wl32(pb, 0); /* reserved */
+ avio_wl32(pb, 0); /* reserved */
+ avio_wl32(pb, 0); /* reserved */
+ avio_wl32(pb, 0); /* reserved */
return 32;
}
@@ -496,29 +496,29 @@ static int gxf_write_umf_media_dv(AVIOContext *pb, GXFStreamContext *sc)
int i;
for (i = 0; i < 8; i++) {
- put_be32(pb, 0);
+ avio_wb32(pb, 0);
}
return 32;
}
static int gxf_write_umf_media_audio(AVIOContext *pb, GXFStreamContext *sc)
{
- put_le64(pb, av_dbl2int(1)); /* sound level to begin to */
- put_le64(pb, av_dbl2int(1)); /* sound level to begin to */
- put_le32(pb, 0); /* number of fields over which to ramp up sound level */
- put_le32(pb, 0); /* number of fields over which to ramp down sound level */
- put_le32(pb, 0); /* reserved */
- put_le32(pb, 0); /* reserved */
+ avio_wl64(pb, av_dbl2int(1)); /* sound level to begin to */
+ avio_wl64(pb, av_dbl2int(1)); /* sound level to begin to */
+ avio_wl32(pb, 0); /* number of fields over which to ramp up sound level */
+ avio_wl32(pb, 0); /* number of fields over which to ramp down sound level */
+ avio_wl32(pb, 0); /* reserved */
+ avio_wl32(pb, 0); /* reserved */
return 32;
}
#if 0
static int gxf_write_umf_media_mjpeg(AVIOContext *pb, GXFStreamContext *sc)
{
- put_be64(pb, 0); /* FIXME FLOAT max chroma quant level */
- put_be64(pb, 0); /* FIXME FLOAT max luma quant level */
- put_be64(pb, 0); /* FIXME FLOAT min chroma quant level */
- put_be64(pb, 0); /* FIXME FLOAT min luma quant level */
+ avio_wb64(pb, 0); /* FIXME FLOAT max chroma quant level */
+ avio_wb64(pb, 0); /* FIXME FLOAT max luma quant level */
+ avio_wb64(pb, 0); /* FIXME FLOAT min chroma quant level */
+ avio_wb64(pb, 0); /* FIXME FLOAT min luma quant level */
return 32;
}
#endif
@@ -542,22 +542,22 @@ static int gxf_write_umf_media_description(AVFormatContext *s)
sc = s->streams[i]->priv_data;
startpos = url_ftell(pb);
- put_le16(pb, 0); /* length */
- put_le16(pb, sc->media_info);
- put_le16(pb, 0); /* reserved */
- put_le16(pb, 0); /* reserved */
- put_le32(pb, gxf->nb_fields);
- put_le32(pb, 0); /* attributes rw, ro */
- put_le32(pb, 0); /* mark in */
- put_le32(pb, gxf->nb_fields); /* mark out */
- put_buffer(pb, ES_NAME_PATTERN, strlen(ES_NAME_PATTERN));
- put_be16(pb, sc->media_info);
+ avio_wl16(pb, 0); /* length */
+ avio_wl16(pb, sc->media_info);
+ avio_wl16(pb, 0); /* reserved */
+ avio_wl16(pb, 0); /* reserved */
+ avio_wl32(pb, gxf->nb_fields);
+ avio_wl32(pb, 0); /* attributes rw, ro */
+ avio_wl32(pb, 0); /* mark in */
+ avio_wl32(pb, gxf->nb_fields); /* mark out */
+ avio_write(pb, ES_NAME_PATTERN, strlen(ES_NAME_PATTERN));
+ avio_wb16(pb, sc->media_info);
for (j = strlen(ES_NAME_PATTERN)+2; j < 88; j++)
- put_byte(pb, 0);
- put_le32(pb, sc->track_type);
- put_le32(pb, sc->sample_rate);
- put_le32(pb, sc->sample_size);
- put_le32(pb, 0); /* reserved */
+ avio_w8(pb, 0);
+ avio_wl32(pb, sc->track_type);
+ avio_wl32(pb, sc->sample_rate);
+ avio_wl32(pb, sc->sample_size);
+ avio_wl32(pb, 0); /* reserved */
if (sc == &gxf->timecode_track)
gxf_write_umf_media_timecode(pb, sc); /* 8 0bytes */
@@ -579,7 +579,7 @@ static int gxf_write_umf_media_description(AVFormatContext *s)
curpos = url_ftell(pb);
url_fseek(pb, startpos, SEEK_SET);
- put_le16(pb, curpos - startpos);
+ avio_wl16(pb, curpos - startpos);
url_fseek(pb, curpos, SEEK_SET);
}
return url_ftell(pb) - pos;
@@ -594,8 +594,8 @@ static int gxf_write_umf_packet(AVFormatContext *s)
gxf_write_packet_header(pb, PKT_UMF);
/* preamble */
- put_byte(pb, 3); /* first and last (only) packet */
- put_be32(pb, gxf->umf_length); /* data length */
+ avio_w8(pb, 3); /* first and last (only) packet */
+ avio_wb32(pb, gxf->umf_length); /* data length */
gxf->umf_start_offset = url_ftell(pb);
gxf_write_umf_payload(s);
@@ -823,33 +823,33 @@ static int gxf_write_media_preamble(AVFormatContext *s, AVPacket *pkt, int size)
(int64_t)48000*gxf->time_base.num, AV_ROUND_UP);
}
- put_byte(pb, sc->media_type);
- put_byte(pb, st->index);
- put_be32(pb, field_nb);
+ avio_w8(pb, sc->media_type);
+ avio_w8(pb, st->index);
+ avio_wb32(pb, field_nb);
if (st->codec->codec_type == AVMEDIA_TYPE_AUDIO) {
- put_be16(pb, 0);
- put_be16(pb, size / 2);
+ avio_wb16(pb, 0);
+ avio_wb16(pb, size / 2);
} else if (st->codec->codec_id == CODEC_ID_MPEG2VIDEO) {
int frame_type = gxf_parse_mpeg_frame(sc, pkt->data, pkt->size);
if (frame_type == FF_I_TYPE) {
- put_byte(pb, 0x0d);
+ avio_w8(pb, 0x0d);
sc->iframes++;
} else if (frame_type == FF_B_TYPE) {
- put_byte(pb, 0x0f);
+ avio_w8(pb, 0x0f);
sc->bframes++;
} else {
- put_byte(pb, 0x0e);
+ avio_w8(pb, 0x0e);
sc->pframes++;
}
- put_be24(pb, size);
+ avio_wb24(pb, size);
} else if (st->codec->codec_id == CODEC_ID_DVVIDEO) {
- put_byte(pb, size / 4096);
- put_be24(pb, 0);
+ avio_w8(pb, size / 4096);
+ avio_wb24(pb, 0);
} else
- put_be32(pb, size);
- put_be32(pb, field_nb);
- put_byte(pb, 1); /* flags */
- put_byte(pb, 0); /* reserved */
+ avio_wb32(pb, size);
+ avio_wb32(pb, field_nb);
+ avio_w8(pb, 1); /* flags */
+ avio_w8(pb, 0); /* reserved */
return 16;
}
@@ -868,7 +868,7 @@ static int gxf_write_packet(AVFormatContext *s, AVPacket *pkt)
else if (st->codec->codec_type == AVMEDIA_TYPE_AUDIO)
padding = GXF_AUDIO_PACKET_SIZE - pkt->size;
gxf_write_media_preamble(s, pkt, pkt->size + padding);
- put_buffer(pb, pkt->data, pkt->size);
+ avio_write(pb, pkt->data, pkt->size);
gxf_write_padding(pb, padding);
if (st->codec->codec_type == AVMEDIA_TYPE_VIDEO) {
diff --git a/libavformat/idroqenc.c b/libavformat/idroqenc.c
index 8859c98a93..9935b61e1b 100644
--- a/libavformat/idroqenc.c
+++ b/libavformat/idroqenc.c
@@ -29,7 +29,7 @@ static int roq_write_header(struct AVFormatContext *s)
0x84, 0x10, 0xFF, 0xFF, 0xFF, 0xFF, 0x1E, 0x00
};
- put_buffer(s->pb, header, 8);
+ avio_write(s->pb, header, 8);
put_flush_packet(s->pb);
return 0;
diff --git a/libavformat/img2.c b/libavformat/img2.c
index f2d40d16de..56c4850efe 100644
--- a/libavformat/img2.c
+++ b/libavformat/img2.c
@@ -368,9 +368,9 @@ static int write_packet(AVFormatContext *s, AVPacket *pkt)
if(codec->codec_id == CODEC_ID_RAWVIDEO){
int ysize = codec->width * codec->height;
- put_buffer(pb[0], pkt->data , ysize);
- put_buffer(pb[1], pkt->data + ysize, (pkt->size - ysize)/2);
- put_buffer(pb[2], pkt->data + ysize +(pkt->size - ysize)/2, (pkt->size - ysize)/2);
+ avio_write(pb[0], pkt->data , ysize);
+ avio_write(pb[1], pkt->data + ysize, (pkt->size - ysize)/2);
+ avio_write(pb[2], pkt->data + ysize +(pkt->size - ysize)/2, (pkt->size - ysize)/2);
put_flush_packet(pb[1]);
put_flush_packet(pb[2]);
url_fclose(pb[1]);
@@ -382,15 +382,15 @@ static int write_packet(AVFormatContext *s, AVPacket *pkt)
AV_RL32(st->codec->extradata+4) == MKTAG('j','p','2','h')){
if(pkt->size < 8 || AV_RL32(pkt->data+4) != MKTAG('j','p','2','c'))
goto error;
- put_be32(pb[0], 12);
+ avio_wb32(pb[0], 12);
put_tag (pb[0], "jP ");
- put_be32(pb[0], 0x0D0A870A); // signature
- put_be32(pb[0], 20);
+ avio_wb32(pb[0], 0x0D0A870A); // signature
+ avio_wb32(pb[0], 20);
put_tag (pb[0], "ftyp");
put_tag (pb[0], "jp2 ");
- put_be32(pb[0], 0);
+ avio_wb32(pb[0], 0);
put_tag (pb[0], "jp2 ");
- put_buffer(pb[0], st->codec->extradata, st->codec->extradata_size);
+ avio_write(pb[0], st->codec->extradata, st->codec->extradata_size);
}else if(pkt->size < 8 ||
(!st->codec->extradata_size &&
AV_RL32(pkt->data+4) != MKTAG('j','P',' ',' '))){ // signature
@@ -399,7 +399,7 @@ static int write_packet(AVFormatContext *s, AVPacket *pkt)
return -1;
}
}
- put_buffer(pb[0], pkt->data, pkt->size);
+ avio_write(pb[0], pkt->data, pkt->size);
}
put_flush_packet(pb[0]);
if (!img->is_pipe) {
diff --git a/libavformat/ivfenc.c b/libavformat/ivfenc.c
index d7eed73e79..3913988144 100644
--- a/libavformat/ivfenc.c
+++ b/libavformat/ivfenc.c
@@ -34,15 +34,15 @@ static int ivf_write_header(AVFormatContext *s)
av_log(s, AV_LOG_ERROR, "Currently only VP8 is supported!\n");
return AVERROR(EINVAL);
}
- put_buffer(pb, "DKIF", 4);
- put_le16(pb, 0); // version
- put_le16(pb, 32); // header length
- put_le32(pb, ctx->codec_tag ? ctx->codec_tag : AV_RL32("VP80"));
- put_le16(pb, ctx->width);
- put_le16(pb, ctx->height);
- put_le32(pb, s->streams[0]->time_base.den);
- put_le32(pb, s->streams[0]->time_base.num);
- put_le64(pb, s->streams[0]->duration); // TODO: duration or number of frames?!?
+ avio_write(pb, "DKIF", 4);
+ avio_wl16(pb, 0); // version
+ avio_wl16(pb, 32); // header length
+ avio_wl32(pb, ctx->codec_tag ? ctx->codec_tag : AV_RL32("VP80"));
+ avio_wl16(pb, ctx->width);
+ avio_wl16(pb, ctx->height);
+ avio_wl32(pb, s->streams[0]->time_base.den);
+ avio_wl32(pb, s->streams[0]->time_base.num);
+ avio_wl64(pb, s->streams[0]->duration); // TODO: duration or number of frames?!?
return 0;
}
@@ -50,9 +50,9 @@ static int ivf_write_header(AVFormatContext *s)
static int ivf_write_packet(AVFormatContext *s, AVPacket *pkt)
{
AVIOContext *pb = s->pb;
- put_le32(pb, pkt->size);
- put_le64(pb, pkt->pts);
- put_buffer(pb, pkt->data, pkt->size);
+ avio_wl32(pb, pkt->size);
+ avio_wl64(pb, pkt->pts);
+ avio_write(pb, pkt->data, pkt->size);
put_flush_packet(pb);
return 0;
diff --git a/libavformat/libnut.c b/libavformat/libnut.c
index 30ada1bf2f..af94d8c30e 100644
--- a/libavformat/libnut.c
+++ b/libavformat/libnut.c
@@ -47,7 +47,7 @@ static const AVCodecTag nut_tags[] = {
#if CONFIG_LIBNUT_MUXER
static int av_write(void * h, size_t len, const uint8_t * buf) {
AVIOContext * bc = h;
- put_buffer(bc, buf, len);
+ avio_write(bc, buf, len);
//put_flush_packet(bc);
return len;
}
diff --git a/libavformat/matroskadec.c b/libavformat/matroskadec.c
index 545c93895f..4488dd6c50 100644
--- a/libavformat/matroskadec.c
+++ b/libavformat/matroskadec.c
@@ -1376,12 +1376,12 @@ static int matroska_read_header(AVFormatContext *s, AVFormatParameters *ap)
return AVERROR(ENOMEM);
ffio_init_context(&b, extradata, extradata_size, 1,
NULL, NULL, NULL, NULL);
- put_buffer(&b, "TTA1", 4);
- put_le16(&b, 1);
- put_le16(&b, track->audio.channels);
- put_le16(&b, track->audio.bitdepth);
- put_le32(&b, track->audio.out_samplerate);
- put_le32(&b, matroska->ctx->duration * track->audio.out_samplerate);
+ avio_write(&b, "TTA1", 4);
+ avio_wl16(&b, 1);
+ avio_wl16(&b, track->audio.channels);
+ avio_wl16(&b, track->audio.bitdepth);
+ avio_wl32(&b, track->audio.out_samplerate);
+ avio_wl32(&b, matroska->ctx->duration * track->audio.out_samplerate);
} else if (codec_id == CODEC_ID_RV10 || codec_id == CODEC_ID_RV20 ||
codec_id == CODEC_ID_RV30 || codec_id == CODEC_ID_RV40) {
extradata_offset = 26;
diff --git a/libavformat/matroskaenc.c b/libavformat/matroskaenc.c
index fbaa8db4da..2f075942ec 100644
--- a/libavformat/matroskaenc.c
+++ b/libavformat/matroskaenc.c
@@ -112,7 +112,7 @@ static void put_ebml_id(AVIOContext *pb, unsigned int id)
{
int i = ebml_id_size(id);
while (i--)
- put_byte(pb, id >> (i*8));
+ avio_w8(pb, id >> (i*8));
}
/**
@@ -123,9 +123,9 @@ static void put_ebml_id(AVIOContext *pb, unsigned int id)
static void put_ebml_size_unknown(AVIOContext *pb, int bytes)
{
assert(bytes <= 8);
- put_byte(pb, 0x1ff >> bytes);
+ avio_w8(pb, 0x1ff >> bytes);
while (--bytes)
- put_byte(pb, 0xff);
+ avio_w8(pb, 0xff);
}
/**
@@ -160,7 +160,7 @@ static void put_ebml_num(AVIOContext *pb, uint64_t num, int bytes)
num |= 1ULL << bytes*7;
for (i = bytes - 1; i >= 0; i--)
- put_byte(pb, num >> i*8);
+ avio_w8(pb, num >> i*8);
}
static void put_ebml_uint(AVIOContext *pb, unsigned int elementid, uint64_t val)
@@ -172,14 +172,14 @@ static void put_ebml_uint(AVIOContext *pb, unsigned int elementid, uint64_t val)
put_ebml_id(pb, elementid);
put_ebml_num(pb, bytes, 0);
for (i = bytes - 1; i >= 0; i--)
- put_byte(pb, val >> i*8);
+ avio_w8(pb, val >> i*8);
}
static void put_ebml_float(AVIOContext *pb, unsigned int elementid, double val)
{
put_ebml_id(pb, elementid);
put_ebml_num(pb, 8, 0);
- put_be64(pb, av_dbl2int(val));
+ avio_wb64(pb, av_dbl2int(val));
}
static void put_ebml_binary(AVIOContext *pb, unsigned int elementid,
@@ -187,7 +187,7 @@ static void put_ebml_binary(AVIOContext *pb, unsigned int elementid,
{
put_ebml_id(pb, elementid);
put_ebml_num(pb, size, 0);
- put_buffer(pb, buf, size);
+ avio_write(pb, buf, size);
}
static void put_ebml_string(AVIOContext *pb, unsigned int elementid, const char *str)
@@ -216,7 +216,7 @@ static void put_ebml_void(AVIOContext *pb, uint64_t size)
else
put_ebml_num(pb, size-9, 8);
while(url_ftell(pb) < currentpos + size)
- put_byte(pb, 0);
+ avio_w8(pb, 0);
}
static ebml_master start_ebml_master(AVIOContext *pb, unsigned int elementid, uint64_t expectedsize)
@@ -241,8 +241,8 @@ static void put_xiph_size(AVIOContext *pb, int size)
{
int i;
for (i = 0; i < size / 255; i++)
- put_byte(pb, 255);
- put_byte(pb, size % 255);
+ avio_w8(pb, 255);
+ avio_w8(pb, size % 255);
}
/**
@@ -426,12 +426,12 @@ static int put_xiph_codecpriv(AVFormatContext *s, AVIOContext *pb, AVCodecContex
return -1;
}
- put_byte(pb, 2); // number packets - 1
+ avio_w8(pb, 2); // number packets - 1
for (j = 0; j < 2; j++) {
put_xiph_size(pb, header_len[j]);
}
for (j = 0; j < 3; j++)
- put_buffer(pb, header_start[j], header_len[j]);
+ avio_write(pb, header_start[j], header_len[j]);
return 0;
}
@@ -481,13 +481,13 @@ static int mkv_write_codecprivate(AVFormatContext *s, AVIOContext *pb, AVCodecCo
else if (codec->codec_id == CODEC_ID_H264)
ret = ff_isom_write_avcc(dyn_cp, codec->extradata, codec->extradata_size);
else if (codec->extradata_size)
- put_buffer(dyn_cp, codec->extradata, codec->extradata_size);
+ avio_write(dyn_cp, codec->extradata, codec->extradata_size);
} else if (codec->codec_type == AVMEDIA_TYPE_VIDEO) {
if (qt_id) {
if (!codec->codec_tag)
codec->codec_tag = ff_codec_get_tag(codec_movvideo_tags, codec->codec_id);
if (codec->extradata_size)
- put_buffer(dyn_cp, codec->extradata, codec->extradata_size);
+ avio_write(dyn_cp, codec->extradata, codec->extradata_size);
} else {
if (!codec->codec_tag)
codec->codec_tag = ff_codec_get_tag(ff_codec_bmp_tags, codec->codec_id);
@@ -932,10 +932,10 @@ static int mkv_write_ass_blocks(AVFormatContext *s, AVIOContext *pb, AVPacket *p
blockgroup = start_ebml_master(pb, MATROSKA_ID_BLOCKGROUP, mkv_blockgroup_size(size));
put_ebml_id(pb, MATROSKA_ID_BLOCK);
put_ebml_num(pb, size+4, 0);
- put_byte(pb, 0x80 | (pkt->stream_index + 1)); // this assumes stream_index is less than 126
- put_be16(pb, pkt->pts - mkv->cluster_pts);
- put_byte(pb, 0);
- put_buffer(pb, buffer, size);
+ avio_w8(pb, 0x80 | (pkt->stream_index + 1)); // this assumes stream_index is less than 126
+ avio_wb16(pb, pkt->pts - mkv->cluster_pts);
+ avio_w8(pb, 0);
+ avio_write(pb, buffer, size);
put_ebml_uint(pb, MATROSKA_ID_BLOCKDURATION, duration);
end_ebml_master(pb, blockgroup);
@@ -965,10 +965,10 @@ static void mkv_write_block(AVFormatContext *s, AVIOContext *pb,
data = pkt->data;
put_ebml_id(pb, blockid);
put_ebml_num(pb, size+4, 0);
- put_byte(pb, 0x80 | (pkt->stream_index + 1)); // this assumes stream_index is less than 126
- put_be16(pb, ts - mkv->cluster_pts);
- put_byte(pb, flags);
- put_buffer(pb, data, size);
+ avio_w8(pb, 0x80 | (pkt->stream_index + 1)); // this assumes stream_index is less than 126
+ avio_wb16(pb, ts - mkv->cluster_pts);
+ avio_w8(pb, flags);
+ avio_write(pb, data, size);
if (data != pkt->data)
av_free(data);
}
@@ -1018,7 +1018,7 @@ static void mkv_flush_dynbuf(AVFormatContext *s)
return;
bufsize = url_close_dyn_buf(mkv->dyn_bc, &dyn_buf);
- put_buffer(s->pb, dyn_buf, bufsize);
+ avio_write(s->pb, dyn_buf, bufsize);
av_free(dyn_buf);
mkv->dyn_bc = NULL;
}
diff --git a/libavformat/md5enc.c b/libavformat/md5enc.c
index dd2f7c03ae..065f7e8dc9 100644
--- a/libavformat/md5enc.c
+++ b/libavformat/md5enc.c
@@ -36,7 +36,7 @@ static void md5_finish(struct AVFormatContext *s, char *buf)
buf[offset] = '\n';
buf[offset+1] = 0;
- put_buffer(s->pb, buf, strlen(buf));
+ avio_write(s->pb, buf, strlen(buf));
put_flush_packet(s->pb);
}
diff --git a/libavformat/mmf.c b/libavformat/mmf.c
index 1a00908eba..eb48b782d2 100644
--- a/libavformat/mmf.c
+++ b/libavformat/mmf.c
@@ -53,7 +53,7 @@ static void end_tag_be(AVIOContext *pb, int64_t start)
pos = url_ftell(pb);
url_fseek(pb, start - 4, SEEK_SET);
- put_be32(pb, (uint32_t)(pos - start));
+ avio_wb32(pb, (uint32_t)(pos - start));
url_fseek(pb, pos, SEEK_SET);
}
@@ -71,31 +71,31 @@ static int mmf_write_header(AVFormatContext *s)
}
put_tag(pb, "MMMD");
- put_be32(pb, 0);
+ avio_wb32(pb, 0);
pos = ff_start_tag(pb, "CNTI");
- put_byte(pb, 0); /* class */
- put_byte(pb, 0); /* type */
- put_byte(pb, 0); /* code type */
- put_byte(pb, 0); /* status */
- put_byte(pb, 0); /* counts */
+ avio_w8(pb, 0); /* class */
+ avio_w8(pb, 0); /* type */
+ 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,...") */
end_tag_be(pb, pos);
- put_buffer(pb, "ATR\x00", 4);
- put_be32(pb, 0);
+ avio_write(pb, "ATR\x00", 4);
+ avio_wb32(pb, 0);
mmf->atrpos = url_ftell(pb);
- put_byte(pb, 0); /* format type */
- put_byte(pb, 0); /* sequence type */
- put_byte(pb, (0 << 7) | (1 << 4) | rate); /* (channel << 7) | (format << 4) | rate */
- put_byte(pb, 0); /* wave base bit */
- put_byte(pb, 2); /* time base d */
- put_byte(pb, 2); /* time base g */
+ avio_w8(pb, 0); /* format type */
+ avio_w8(pb, 0); /* sequence type */
+ avio_w8(pb, (0 << 7) | (1 << 4) | rate); /* (channel << 7) | (format << 4) | rate */
+ avio_w8(pb, 0); /* wave base bit */
+ avio_w8(pb, 2); /* time base d */
+ avio_w8(pb, 2); /* time base g */
put_tag(pb, "Atsq");
- put_be32(pb, 16);
+ avio_wb32(pb, 16);
mmf->atsqpos = url_ftell(pb);
/* Will be filled on close */
- put_buffer(pb, "\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00", 16);
+ avio_write(pb, "\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00", 16);
mmf->awapos = ff_start_tag(pb, "Awa\x01");
@@ -109,7 +109,7 @@ static int mmf_write_header(AVFormatContext *s)
static int mmf_write_packet(AVFormatContext *s, AVPacket *pkt)
{
AVIOContext *pb = s->pb;
- put_buffer(pb, pkt->data, pkt->size);
+ avio_write(pb, pkt->data, pkt->size);
return 0;
}
@@ -117,11 +117,11 @@ static int mmf_write_packet(AVFormatContext *s, AVPacket *pkt)
static void put_varlength(AVIOContext *pb, int val)
{
if(val < 128)
- put_byte(pb, val);
+ avio_w8(pb, val);
else {
val -= 128;
- put_byte(pb, 0x80 | val >> 7);
- put_byte(pb, 0x7f & val);
+ avio_w8(pb, 0x80 | val >> 7);
+ avio_w8(pb, 0x7f & val);
}
}
@@ -145,17 +145,17 @@ static int mmf_write_trailer(AVFormatContext *s)
url_fseek(pb, mmf->atsqpos, SEEK_SET);
/* "play wav" */
- put_byte(pb, 0); /* start time */
- put_byte(pb, 1); /* (channel << 6) | wavenum */
+ avio_w8(pb, 0); /* start time */
+ avio_w8(pb, 1); /* (channel << 6) | wavenum */
gatetime = size * 500 / s->streams[0]->codec->sample_rate;
put_varlength(pb, gatetime); /* duration */
/* "nop" */
put_varlength(pb, gatetime); /* start time */
- put_buffer(pb, "\xff\x00", 2); /* nop */
+ avio_write(pb, "\xff\x00", 2); /* nop */
/* "end of sequence" */
- put_buffer(pb, "\x00\x00\x00\x00", 4);
+ avio_write(pb, "\x00\x00\x00\x00", 4);
url_fseek(pb, pos, SEEK_SET);
diff --git a/libavformat/movenc.c b/libavformat/movenc.c
index 097f4641f2..9c45352e0f 100644
--- a/libavformat/movenc.c
+++ b/libavformat/movenc.c
@@ -40,7 +40,7 @@ static int64_t updateSize(AVIOContext *pb, int64_t pos)
{
int64_t curpos = url_ftell(pb);
url_fseek(pb, pos, SEEK_SET);
- put_be32(pb, curpos - pos); /* rewrite size */
+ avio_wb32(pb, curpos - pos); /* rewrite size */
url_fseek(pb, curpos, SEEK_SET);
return curpos - pos;
@@ -52,19 +52,19 @@ static int mov_write_stco_tag(AVIOContext *pb, MOVTrack *track)
int i;
int mode64 = 0; // use 32 bit size variant if possible
int64_t pos = url_ftell(pb);
- put_be32(pb, 0); /* size */
+ avio_wb32(pb, 0); /* size */
if (pos > UINT32_MAX) {
mode64 = 1;
put_tag(pb, "co64");
} else
put_tag(pb, "stco");
- put_be32(pb, 0); /* version & flags */
- put_be32(pb, track->entry); /* entry count */
+ avio_wb32(pb, 0); /* version & flags */
+ avio_wb32(pb, track->entry); /* entry count */
for (i=0; i<track->entry; i++) {
if(mode64 == 1)
- put_be64(pb, track->cluster[i].pos);
+ avio_wb64(pb, track->cluster[i].pos);
else
- put_be32(pb, track->cluster[i].pos);
+ avio_wb32(pb, track->cluster[i].pos);
}
return updateSize(pb, pos);
}
@@ -76,9 +76,9 @@ static int mov_write_stsz_tag(AVIOContext *pb, MOVTrack *track)
int i, j, entries = 0, tst = -1, oldtst = -1;
int64_t pos = url_ftell(pb);
- put_be32(pb, 0); /* size */
+ avio_wb32(pb, 0); /* size */
put_tag(pb, "stsz");
- put_be32(pb, 0); /* version & flags */
+ avio_wb32(pb, 0); /* version & flags */
for (i=0; i<track->entry; i++) {
tst = track->cluster[i].size/track->cluster[i].entries;
@@ -90,15 +90,15 @@ static int mov_write_stsz_tag(AVIOContext *pb, MOVTrack *track)
}
if (equalChunks) {
int sSize = track->cluster[0].size/track->cluster[0].entries;
- put_be32(pb, sSize); // sample size
- put_be32(pb, entries); // sample count
+ avio_wb32(pb, sSize); // sample size
+ avio_wb32(pb, entries); // sample count
}
else {
- put_be32(pb, 0); // sample size
- put_be32(pb, entries); // sample count
+ avio_wb32(pb, 0); // sample size
+ avio_wb32(pb, entries); // sample count
for (i=0; i<track->entry; i++) {
for (j=0; j<track->cluster[i].entries; j++) {
- put_be32(pb, track->cluster[i].size /
+ avio_wb32(pb, track->cluster[i].size /
track->cluster[i].entries);
}
}
@@ -113,24 +113,24 @@ static int mov_write_stsc_tag(AVIOContext *pb, MOVTrack *track)
int64_t entryPos, curpos;
int64_t pos = url_ftell(pb);
- put_be32(pb, 0); /* size */
+ avio_wb32(pb, 0); /* size */
put_tag(pb, "stsc");
- put_be32(pb, 0); // version & flags
+ avio_wb32(pb, 0); // version & flags
entryPos = url_ftell(pb);
- put_be32(pb, track->entry); // entry count
+ avio_wb32(pb, track->entry); // entry count
for (i=0; i<track->entry; i++) {
if(oldval != track->cluster[i].samplesInChunk)
{
- put_be32(pb, i+1); // first chunk
- put_be32(pb, track->cluster[i].samplesInChunk); // samples per chunk
- put_be32(pb, 0x1); // sample description index
+ avio_wb32(pb, i+1); // first chunk
+ avio_wb32(pb, track->cluster[i].samplesInChunk); // samples per chunk
+ avio_wb32(pb, 0x1); // sample description index
oldval = track->cluster[i].samplesInChunk;
index++;
}
}
curpos = url_ftell(pb);
url_fseek(pb, entryPos, SEEK_SET);
- put_be32(pb, index); // rewrite size
+ avio_wb32(pb, index); // rewrite size
url_fseek(pb, curpos, SEEK_SET);
return updateSize(pb, pos);
@@ -142,35 +142,35 @@ static int mov_write_stss_tag(AVIOContext *pb, MOVTrack *track, uint32_t flag)
int64_t curpos, entryPos;
int i, index = 0;
int64_t pos = url_ftell(pb);
- put_be32(pb, 0); // size
+ avio_wb32(pb, 0); // size
put_tag(pb, flag == MOV_SYNC_SAMPLE ? "stss" : "stps");
- put_be32(pb, 0); // version & flags
+ avio_wb32(pb, 0); // version & flags
entryPos = url_ftell(pb);
- put_be32(pb, track->entry); // entry count
+ avio_wb32(pb, track->entry); // entry count
for (i=0; i<track->entry; i++) {
if (track->cluster[i].flags & flag) {
- put_be32(pb, i+1);
+ avio_wb32(pb, i+1);
index++;
}
}
curpos = url_ftell(pb);
url_fseek(pb, entryPos, SEEK_SET);
- put_be32(pb, index); // rewrite size
+ avio_wb32(pb, index); // rewrite size
url_fseek(pb, curpos, SEEK_SET);
return updateSize(pb, pos);
}
static int mov_write_amr_tag(AVIOContext *pb, MOVTrack *track)
{
- put_be32(pb, 0x11); /* size */
+ avio_wb32(pb, 0x11); /* size */
if (track->mode == MODE_MOV) put_tag(pb, "samr");
else put_tag(pb, "damr");
put_tag(pb, "FFMP");
- put_byte(pb, 0); /* decoder version */
+ avio_w8(pb, 0); /* decoder version */
- put_be16(pb, 0x81FF); /* Mode set (all modes for AMR_NB) */
- put_byte(pb, 0x00); /* Mode change period (no restriction) */
- put_byte(pb, 0x01); /* Frames per sample */
+ avio_wb16(pb, 0x81FF); /* Mode set (all modes for AMR_NB) */
+ avio_w8(pb, 0x00); /* Mode change period (no restriction) */
+ avio_w8(pb, 0x01); /* Frames per sample */
return 0x11;
}
@@ -184,7 +184,7 @@ static int mov_write_ac3_tag(AVIOContext *pb, MOVTrack *track)
if (track->vosLen < 7)
return -1;
- put_be32(pb, 11);
+ avio_wb32(pb, 11);
put_tag(pb, "dac3");
init_get_bits(&gbc, track->vosData+4, track->vosLen-4);
@@ -213,7 +213,7 @@ static int mov_write_ac3_tag(AVIOContext *pb, MOVTrack *track)
put_bits(&pbc, 5, 0); // reserved
flush_put_bits(&pbc);
- put_buffer(pb, buf, sizeof(buf));
+ avio_write(pb, buf, sizeof(buf));
return 11;
}
@@ -224,15 +224,15 @@ static int mov_write_ac3_tag(AVIOContext *pb, MOVTrack *track)
*/
static int mov_write_extradata_tag(AVIOContext *pb, MOVTrack *track)
{
- put_buffer(pb, track->enc->extradata, track->enc->extradata_size);
+ avio_write(pb, track->enc->extradata, track->enc->extradata_size);
return track->enc->extradata_size;
}
static int mov_write_enda_tag(AVIOContext *pb)
{
- put_be32(pb, 10);
+ avio_wb32(pb, 10);
put_tag(pb, "enda");
- put_be16(pb, 1); /* little endian */
+ avio_wb16(pb, 1); /* little endian */
return 10;
}
@@ -246,10 +246,10 @@ static unsigned int descrLength(unsigned int len)
static void putDescr(AVIOContext *pb, int tag, unsigned int size)
{
int i= descrLength(size) - size - 2;
- put_byte(pb, tag);
+ avio_w8(pb, tag);
for(; i>0; i--)
- put_byte(pb, (size>>(7*i)) | 0x80);
- put_byte(pb, size & 0x7F);
+ avio_w8(pb, (size>>(7*i)) | 0x80);
+ avio_w8(pb, size & 0x7F);
}
static int mov_write_esds_tag(AVIOContext *pb, MOVTrack *track) // Basic
@@ -257,15 +257,15 @@ static int mov_write_esds_tag(AVIOContext *pb, MOVTrack *track) // Basic
int64_t pos = url_ftell(pb);
int decoderSpecificInfoLen = track->vosLen ? descrLength(track->vosLen):0;
- put_be32(pb, 0); // size
+ avio_wb32(pb, 0); // size
put_tag(pb, "esds");
- put_be32(pb, 0); // Version
+ avio_wb32(pb, 0); // Version
// ES descriptor
putDescr(pb, 0x03, 3 + descrLength(13 + decoderSpecificInfoLen) +
descrLength(1));
- put_be16(pb, track->trackID);
- put_byte(pb, 0x00); // flags (= no flags)
+ avio_wb16(pb, track->trackID);
+ avio_w8(pb, 0x00); // flags (= no flags)
// DecoderConfig descriptor
putDescr(pb, 0x04, 13 + decoderSpecificInfoLen);
@@ -274,35 +274,35 @@ static int mov_write_esds_tag(AVIOContext *pb, MOVTrack *track) // Basic
if ((track->enc->codec_id == CODEC_ID_MP2 ||
track->enc->codec_id == CODEC_ID_MP3) &&
track->enc->sample_rate > 24000)
- put_byte(pb, 0x6B); // 11172-3
+ avio_w8(pb, 0x6B); // 11172-3
else
- put_byte(pb, ff_codec_get_tag(ff_mp4_obj_type, track->enc->codec_id));
+ avio_w8(pb, ff_codec_get_tag(ff_mp4_obj_type, track->enc->codec_id));
// the following fields is made of 6 bits to identify the streamtype (4 for video, 5 for audio)
// plus 1 bit to indicate upstream and 1 bit set to 1 (reserved)
if(track->enc->codec_type == AVMEDIA_TYPE_AUDIO)
- put_byte(pb, 0x15); // flags (= Audiostream)
+ avio_w8(pb, 0x15); // flags (= Audiostream)
else
- put_byte(pb, 0x11); // flags (= Visualstream)
+ avio_w8(pb, 0x11); // flags (= Visualstream)
- put_byte(pb, track->enc->rc_buffer_size>>(3+16)); // Buffersize DB (24 bits)
- put_be16(pb, (track->enc->rc_buffer_size>>3)&0xFFFF); // Buffersize DB
+ avio_w8(pb, track->enc->rc_buffer_size>>(3+16)); // Buffersize DB (24 bits)
+ avio_wb16(pb, (track->enc->rc_buffer_size>>3)&0xFFFF); // Buffersize DB
- put_be32(pb, FFMAX(track->enc->bit_rate, track->enc->rc_max_rate)); // maxbitrate (FIXME should be max rate in any 1 sec window)
+ avio_wb32(pb, FFMAX(track->enc->bit_rate, track->enc->rc_max_rate)); // maxbitrate (FIXME should be max rate in any 1 sec window)
if(track->enc->rc_max_rate != track->enc->rc_min_rate || track->enc->rc_min_rate==0)
- put_be32(pb, 0); // vbr
+ avio_wb32(pb, 0); // vbr
else
- put_be32(pb, track->enc->rc_max_rate); // avg bitrate
+ avio_wb32(pb, track->enc->rc_max_rate); // avg bitrate
if (track->vosLen) {
// DecoderSpecific info descriptor
putDescr(pb, 0x05, track->vosLen);
- put_buffer(pb, track->vosData, track->vosLen);
+ avio_write(pb, track->vosData, track->vosLen);
}
// SL descriptor
putDescr(pb, 0x06, 1);
- put_byte(pb, 0x02);
+ avio_w8(pb, 0x02);
return updateSize(pb, pos);
}
@@ -317,8 +317,8 @@ static int mov_pcm_le_gt16(enum CodecID codec_id)
static int mov_write_ms_tag(AVIOContext *pb, MOVTrack *track)
{
int64_t pos = url_ftell(pb);
- put_be32(pb, 0);
- put_le32(pb, track->tag); // store it byteswapped
+ avio_wb32(pb, 0);
+ avio_wl32(pb, track->tag); // store it byteswapped
track->enc->codec_tag = av_bswap16(track->tag >> 16);
ff_put_wav_header(pb, track->enc);
return updateSize(pb, pos);
@@ -328,18 +328,18 @@ static int mov_write_wave_tag(AVIOContext *pb, MOVTrack *track)
{
int64_t pos = url_ftell(pb);
- put_be32(pb, 0); /* size */
+ avio_wb32(pb, 0); /* size */
put_tag(pb, "wave");
- put_be32(pb, 12); /* size */
+ avio_wb32(pb, 12); /* size */
put_tag(pb, "frma");
- put_le32(pb, track->tag);
+ avio_wl32(pb, track->tag);
if (track->enc->codec_id == CODEC_ID_AAC) {
/* useless atom needed by mplayer, ipod, not needed by quicktime */
- put_be32(pb, 12); /* size */
+ avio_wb32(pb, 12); /* size */
put_tag(pb, "mp4a");
- put_be32(pb, 0);
+ avio_wb32(pb, 0);
mov_write_esds_tag(pb, track);
} else if (mov_pcm_le_gt16(track->enc->codec_id)) {
mov_write_enda_tag(pb);
@@ -354,17 +354,17 @@ static int mov_write_wave_tag(AVIOContext *pb, MOVTrack *track)
mov_write_ms_tag(pb, track);
}
- put_be32(pb, 8); /* size */
- put_be32(pb, 0); /* null tag */
+ avio_wb32(pb, 8); /* size */
+ avio_wb32(pb, 0); /* null tag */
return updateSize(pb, pos);
}
static int mov_write_glbl_tag(AVIOContext *pb, MOVTrack *track)
{
- put_be32(pb, track->vosLen+8);
+ avio_wb32(pb, track->vosLen+8);
put_tag(pb, "glbl");
- put_buffer(pb, track->vosData, track->vosLen);
+ avio_write(pb, track->vosData, track->vosLen);
return 8+track->vosLen;
}
@@ -415,56 +415,56 @@ static int mov_write_audio_tag(AVIOContext *pb, MOVTrack *track)
}
}
- put_be32(pb, 0); /* size */
- put_le32(pb, tag); // store it byteswapped
- put_be32(pb, 0); /* Reserved */
- put_be16(pb, 0); /* Reserved */
- put_be16(pb, 1); /* Data-reference index, XXX == 1 */
+ avio_wb32(pb, 0); /* size */
+ avio_wl32(pb, tag); // store it byteswapped
+ avio_wb32(pb, 0); /* Reserved */
+ avio_wb16(pb, 0); /* Reserved */
+ avio_wb16(pb, 1); /* Data-reference index, XXX == 1 */
/* SoundDescription */
- put_be16(pb, version); /* Version */
- put_be16(pb, 0); /* Revision level */
- put_be32(pb, 0); /* Reserved */
+ avio_wb16(pb, version); /* Version */
+ avio_wb16(pb, 0); /* Revision level */
+ avio_wb32(pb, 0); /* Reserved */
if (version == 2) {
- put_be16(pb, 3);
- put_be16(pb, 16);
- put_be16(pb, 0xfffe);
- put_be16(pb, 0);
- put_be32(pb, 0x00010000);
- put_be32(pb, 72);
- put_be64(pb, av_dbl2int(track->timescale));
- put_be32(pb, track->enc->channels);
- put_be32(pb, 0x7F000000);
- put_be32(pb, av_get_bits_per_sample(track->enc->codec_id));
- put_be32(pb, mov_get_lpcm_flags(track->enc->codec_id));
- put_be32(pb, track->sampleSize);
- put_be32(pb, track->enc->frame_size);
+ avio_wb16(pb, 3);
+ avio_wb16(pb, 16);
+ avio_wb16(pb, 0xfffe);
+ avio_wb16(pb, 0);
+ avio_wb32(pb, 0x00010000);
+ avio_wb32(pb, 72);
+ avio_wb64(pb, av_dbl2int(track->timescale));
+ avio_wb32(pb, track->enc->channels);
+ avio_wb32(pb, 0x7F000000);
+ avio_wb32(pb, av_get_bits_per_sample(track->enc->codec_id));
+ avio_wb32(pb, mov_get_lpcm_flags(track->enc->codec_id));
+ avio_wb32(pb, track->sampleSize);
+ avio_wb32(pb, track->enc->frame_size);
} else {
if (track->mode == MODE_MOV) {
- put_be16(pb, track->enc->channels);
+ avio_wb16(pb, track->enc->channels);
if (track->enc->codec_id == CODEC_ID_PCM_U8 ||
track->enc->codec_id == CODEC_ID_PCM_S8)
- put_be16(pb, 8); /* bits per sample */
+ avio_wb16(pb, 8); /* bits per sample */
else
- put_be16(pb, 16);
- put_be16(pb, track->audio_vbr ? -2 : 0); /* compression ID */
+ avio_wb16(pb, 16);
+ avio_wb16(pb, track->audio_vbr ? -2 : 0); /* compression ID */
} else { /* reserved for mp4/3gp */
- put_be16(pb, 2);
- put_be16(pb, 16);
- put_be16(pb, 0);
+ avio_wb16(pb, 2);
+ avio_wb16(pb, 16);
+ avio_wb16(pb, 0);
}
- put_be16(pb, 0); /* packet size (= 0) */
- put_be16(pb, track->timescale); /* Time scale */
- put_be16(pb, 0); /* Reserved */
+ avio_wb16(pb, 0); /* packet size (= 0) */
+ avio_wb16(pb, track->timescale); /* Time scale */
+ avio_wb16(pb, 0); /* Reserved */
}
if(version == 1) { /* SoundDescription V1 extended info */
- put_be32(pb, track->enc->frame_size); /* Samples per packet */
- put_be32(pb, track->sampleSize / track->enc->channels); /* Bytes per packet */
- put_be32(pb, track->sampleSize); /* Bytes per frame */
- put_be32(pb, 2); /* Bytes per sample */
+ avio_wb32(pb, track->enc->frame_size); /* Samples per packet */
+ avio_wb32(pb, track->sampleSize / track->enc->channels); /* Bytes per packet */
+ avio_wb32(pb, track->sampleSize); /* Bytes per frame */
+ avio_wb32(pb, 2); /* Bytes per sample */
}
if(track->mode == MODE_MOV &&
@@ -492,26 +492,26 @@ static int mov_write_audio_tag(AVIOContext *pb, MOVTrack *track)
static int mov_write_d263_tag(AVIOContext *pb)
{
- put_be32(pb, 0xf); /* size */
+ avio_wb32(pb, 0xf); /* size */
put_tag(pb, "d263");
put_tag(pb, "FFMP");
- put_byte(pb, 0); /* decoder version */
+ avio_w8(pb, 0); /* decoder version */
/* FIXME use AVCodecContext level/profile, when encoder will set values */
- put_byte(pb, 0xa); /* level */
- put_byte(pb, 0); /* profile */
+ avio_w8(pb, 0xa); /* level */
+ avio_w8(pb, 0); /* profile */
return 0xf;
}
/* TODO: No idea about these values */
static int mov_write_svq3_tag(AVIOContext *pb)
{
- put_be32(pb, 0x15);
+ avio_wb32(pb, 0x15);
put_tag(pb, "SMI ");
put_tag(pb, "SEQH");
- put_be32(pb, 0x5);
- put_be32(pb, 0xe2c0211d);
- put_be32(pb, 0xc0000000);
- put_byte(pb, 0);
+ avio_wb32(pb, 0x5);
+ avio_wb32(pb, 0xe2c0211d);
+ avio_wb32(pb, 0xc0000000);
+ avio_w8(pb, 0);
return 0x15;
}
@@ -519,7 +519,7 @@ static int mov_write_avcc_tag(AVIOContext *pb, MOVTrack *track)
{
int64_t pos = url_ftell(pb);
- put_be32(pb, 0);
+ avio_wb32(pb, 0);
put_tag(pb, "avcC");
ff_isom_write_avcc(pb, track->vosData, track->vosLen);
return updateSize(pb, pos);
@@ -529,47 +529,47 @@ static int mov_write_avcc_tag(AVIOContext *pb, MOVTrack *track)
static int mov_write_avid_tag(AVIOContext *pb, MOVTrack *track)
{
int i;
- put_be32(pb, 24); /* size */
+ avio_wb32(pb, 24); /* size */
put_tag(pb, "ACLR");
put_tag(pb, "ACLR");
put_tag(pb, "0001");
- put_be32(pb, 1); /* yuv 1 / rgb 2 ? */
- put_be32(pb, 0); /* unknown */
+ avio_wb32(pb, 1); /* yuv 1 / rgb 2 ? */
+ avio_wb32(pb, 0); /* unknown */
- put_be32(pb, 24); /* size */
+ avio_wb32(pb, 24); /* size */
put_tag(pb, "APRG");
put_tag(pb, "APRG");
put_tag(pb, "0001");
- put_be32(pb, 1); /* unknown */
- put_be32(pb, 0); /* unknown */
+ avio_wb32(pb, 1); /* unknown */
+ avio_wb32(pb, 0); /* unknown */
- put_be32(pb, 120); /* size */
+ avio_wb32(pb, 120); /* size */
put_tag(pb, "ARES");
put_tag(pb, "ARES");
put_tag(pb, "0001");
- put_be32(pb, AV_RB32(track->vosData + 0x28)); /* dnxhd cid, some id ? */
- put_be32(pb, track->enc->width);
+ avio_wb32(pb, AV_RB32(track->vosData + 0x28)); /* dnxhd cid, some id ? */
+ avio_wb32(pb, track->enc->width);
/* values below are based on samples created with quicktime and avid codecs */
if (track->vosData[5] & 2) { // interlaced
- put_be32(pb, track->enc->height/2);
- put_be32(pb, 2); /* unknown */
- put_be32(pb, 0); /* unknown */
- put_be32(pb, 4); /* unknown */
+ avio_wb32(pb, track->enc->height/2);
+ avio_wb32(pb, 2); /* unknown */
+ avio_wb32(pb, 0); /* unknown */
+ avio_wb32(pb, 4); /* unknown */
} else {
- put_be32(pb, track->enc->height);
- put_be32(pb, 1); /* unknown */
- put_be32(pb, 0); /* unknown */
+ avio_wb32(pb, track->enc->height);
+ avio_wb32(pb, 1); /* unknown */
+ avio_wb32(pb, 0); /* unknown */
if (track->enc->height == 1080)
- put_be32(pb, 5); /* unknown */
+ avio_wb32(pb, 5); /* unknown */
else
- put_be32(pb, 6); /* unknown */
+ avio_wb32(pb, 6); /* unknown */
}
/* padding */
for (i = 0; i < 10; i++)
- put_be64(pb, 0);
+ avio_wb64(pb, 0);
/* extra padding for stsd needed */
- put_be32(pb, 0);
+ avio_wb32(pb, 0);
return 0;
}
@@ -740,27 +740,27 @@ static int mov_find_codec_tag(AVFormatContext *s, MOVTrack *track)
*/
static int mov_write_uuid_tag_ipod(AVIOContext *pb)
{
- put_be32(pb, 28);
+ avio_wb32(pb, 28);
put_tag(pb, "uuid");
- put_be32(pb, 0x6b6840f2);
- put_be32(pb, 0x5f244fc5);
- put_be32(pb, 0xba39a51b);
- put_be32(pb, 0xcf0323f3);
- put_be32(pb, 0x0);
+ avio_wb32(pb, 0x6b6840f2);
+ avio_wb32(pb, 0x5f244fc5);
+ avio_wb32(pb, 0xba39a51b);
+ avio_wb32(pb, 0xcf0323f3);
+ avio_wb32(pb, 0x0);
return 28;
}
static int mov_write_subtitle_tag(AVIOContext *pb, MOVTrack *track)
{
int64_t pos = url_ftell(pb);
- put_be32(pb, 0); /* size */
- put_le32(pb, track->tag); // store it byteswapped
- put_be32(pb, 0); /* Reserved */
- put_be16(pb, 0); /* Reserved */
- put_be16(pb, 1); /* Data-reference index */
+ avio_wb32(pb, 0); /* size */
+ avio_wl32(pb, track->tag); // store it byteswapped
+ avio_wb32(pb, 0); /* Reserved */
+ avio_wb16(pb, 0); /* Reserved */
+ avio_wb16(pb, 1); /* Data-reference index */
if (track->enc->extradata_size)
- put_buffer(pb, track->enc->extradata, track->enc->extradata_size);
+ avio_write(pb, track->enc->extradata, track->enc->extradata_size);
return updateSize(pb, pos);
}
@@ -771,10 +771,10 @@ static int mov_write_pasp_tag(AVIOContext *pb, MOVTrack *track)
av_reduce(&sar.num, &sar.den, track->enc->sample_aspect_ratio.num,
track->enc->sample_aspect_ratio.den, INT_MAX);
- put_be32(pb, 16);
+ avio_wb32(pb, 16);
put_tag(pb, "pasp");
- put_be32(pb, sar.num);
- put_be32(pb, sar.den);
+ avio_wb32(pb, sar.num);
+ avio_wb32(pb, sar.den);
return 16;
}
@@ -783,47 +783,47 @@ static int mov_write_video_tag(AVIOContext *pb, MOVTrack *track)
int64_t pos = url_ftell(pb);
char compressor_name[32];
- put_be32(pb, 0); /* size */
- put_le32(pb, track->tag); // store it byteswapped
- put_be32(pb, 0); /* Reserved */
- put_be16(pb, 0); /* Reserved */
- put_be16(pb, 1); /* Data-reference index */
+ avio_wb32(pb, 0); /* size */
+ avio_wl32(pb, track->tag); // store it byteswapped
+ avio_wb32(pb, 0); /* Reserved */
+ avio_wb16(pb, 0); /* Reserved */
+ avio_wb16(pb, 1); /* Data-reference index */
- put_be16(pb, 0); /* Codec stream version */
- put_be16(pb, 0); /* Codec stream revision (=0) */
+ avio_wb16(pb, 0); /* Codec stream version */
+ avio_wb16(pb, 0); /* Codec stream revision (=0) */
if (track->mode == MODE_MOV) {
put_tag(pb, "FFMP"); /* Vendor */
if(track->enc->codec_id == CODEC_ID_RAWVIDEO) {
- put_be32(pb, 0); /* Temporal Quality */
- put_be32(pb, 0x400); /* Spatial Quality = lossless*/
+ avio_wb32(pb, 0); /* Temporal Quality */
+ avio_wb32(pb, 0x400); /* Spatial Quality = lossless*/
} else {
- put_be32(pb, 0x200); /* Temporal Quality = normal */
- put_be32(pb, 0x200); /* Spatial Quality = normal */
+ avio_wb32(pb, 0x200); /* Temporal Quality = normal */
+ avio_wb32(pb, 0x200); /* Spatial Quality = normal */
}
} else {
- put_be32(pb, 0); /* Reserved */
- put_be32(pb, 0); /* Reserved */
- put_be32(pb, 0); /* Reserved */
+ avio_wb32(pb, 0); /* Reserved */
+ avio_wb32(pb, 0); /* Reserved */
+ avio_wb32(pb, 0); /* Reserved */
}
- put_be16(pb, track->enc->width); /* Video width */
- put_be16(pb, track->height); /* Video height */
- put_be32(pb, 0x00480000); /* Horizontal resolution 72dpi */
- put_be32(pb, 0x00480000); /* Vertical resolution 72dpi */
- put_be32(pb, 0); /* Data size (= 0) */
- put_be16(pb, 1); /* Frame count (= 1) */
+ avio_wb16(pb, track->enc->width); /* Video width */
+ avio_wb16(pb, track->height); /* Video height */
+ avio_wb32(pb, 0x00480000); /* Horizontal resolution 72dpi */
+ avio_wb32(pb, 0x00480000); /* Vertical resolution 72dpi */
+ avio_wb32(pb, 0); /* Data size (= 0) */
+ avio_wb16(pb, 1); /* Frame count (= 1) */
memset(compressor_name,0,32);
/* FIXME not sure, ISO 14496-1 draft where it shall be set to 0 */
if (track->mode == MODE_MOV && track->enc->codec && track->enc->codec->name)
strncpy(compressor_name,track->enc->codec->name,31);
- put_byte(pb, strlen(compressor_name));
- put_buffer(pb, compressor_name, 31);
+ avio_w8(pb, strlen(compressor_name));
+ avio_write(pb, compressor_name, 31);
if (track->mode == MODE_MOV && track->enc->bits_per_coded_sample)
- put_be16(pb, track->enc->bits_per_coded_sample);
+ avio_wb16(pb, track->enc->bits_per_coded_sample);
else
- put_be16(pb, 0x18); /* Reserved */
- put_be16(pb, 0xffff); /* Reserved */
+ avio_wb16(pb, 0x18); /* Reserved */
+ avio_wb16(pb, 0xffff); /* Reserved */
if(track->tag == MKTAG('m','p','4','v'))
mov_write_esds_tag(pb, track);
else if(track->enc->codec_id == CODEC_ID_H263)
@@ -851,19 +851,19 @@ static int mov_write_video_tag(AVIOContext *pb, MOVTrack *track)
static int mov_write_rtp_tag(AVIOContext *pb, MOVTrack *track)
{
int64_t pos = url_ftell(pb);
- put_be32(pb, 0); /* size */
+ avio_wb32(pb, 0); /* size */
put_tag(pb, "rtp ");
- put_be32(pb, 0); /* Reserved */
- put_be16(pb, 0); /* Reserved */
- put_be16(pb, 1); /* Data-reference index */
+ avio_wb32(pb, 0); /* Reserved */
+ avio_wb16(pb, 0); /* Reserved */
+ avio_wb16(pb, 1); /* Data-reference index */
- put_be16(pb, 1); /* Hint track version */
- put_be16(pb, 1); /* Highest compatible version */
- put_be32(pb, track->max_packet_size); /* Max packet size */
+ avio_wb16(pb, 1); /* Hint track version */
+ avio_wb16(pb, 1); /* Highest compatible version */
+ avio_wb32(pb, track->max_packet_size); /* Max packet size */
- put_be32(pb, 12); /* size */
+ avio_wb32(pb, 12); /* size */
put_tag(pb, "tims");
- put_be32(pb, track->timescale);
+ avio_wb32(pb, track->timescale);
return updateSize(pb, pos);
}
@@ -871,10 +871,10 @@ static int mov_write_rtp_tag(AVIOContext *pb, MOVTrack *track)
static int mov_write_stsd_tag(AVIOContext *pb, MOVTrack *track)
{
int64_t pos = url_ftell(pb);
- put_be32(pb, 0); /* size */
+ avio_wb32(pb, 0); /* size */
put_tag(pb, "stsd");
- put_be32(pb, 0); /* version & flags */
- put_be32(pb, 1); /* entry count */
+ avio_wb32(pb, 0); /* version & flags */
+ avio_wb32(pb, 1); /* entry count */
if (track->enc->codec_type == AVMEDIA_TYPE_VIDEO)
mov_write_video_tag(pb, track);
else if (track->enc->codec_type == AVMEDIA_TYPE_AUDIO)
@@ -907,13 +907,13 @@ static int mov_write_ctts_tag(AVIOContext *pb, MOVTrack *track)
}
entries++; /* last one */
atom_size = 16 + (entries * 8);
- put_be32(pb, atom_size); /* size */
+ avio_wb32(pb, atom_size); /* size */
put_tag(pb, "ctts");
- put_be32(pb, 0); /* version & flags */
- put_be32(pb, entries); /* entry count */
+ avio_wb32(pb, 0); /* version & flags */
+ avio_wb32(pb, entries); /* entry count */
for (i=0; i<entries; i++) {
- put_be32(pb, ctts_entries[i].count);
- put_be32(pb, ctts_entries[i].duration);
+ avio_wb32(pb, ctts_entries[i].count);
+ avio_wb32(pb, ctts_entries[i].duration);
}
av_free(ctts_entries);
return atom_size;
@@ -949,13 +949,13 @@ static int mov_write_stts_tag(AVIOContext *pb, MOVTrack *track)
entries++; /* last one */
}
atom_size = 16 + (entries * 8);
- put_be32(pb, atom_size); /* size */
+ avio_wb32(pb, atom_size); /* size */
put_tag(pb, "stts");
- put_be32(pb, 0); /* version & flags */
- put_be32(pb, entries); /* entry count */
+ avio_wb32(pb, 0); /* version & flags */
+ avio_wb32(pb, entries); /* entry count */
for (i=0; i<entries; i++) {
- put_be32(pb, stts_entries[i].count);
- put_be32(pb, stts_entries[i].duration);
+ avio_wb32(pb, stts_entries[i].count);
+ avio_wb32(pb, stts_entries[i].duration);
}
av_free(stts_entries);
return atom_size;
@@ -963,14 +963,14 @@ static int mov_write_stts_tag(AVIOContext *pb, MOVTrack *track)
static int mov_write_dref_tag(AVIOContext *pb)
{
- put_be32(pb, 28); /* size */
+ avio_wb32(pb, 28); /* size */
put_tag(pb, "dref");
- put_be32(pb, 0); /* version & flags */
- put_be32(pb, 1); /* entry count */
+ avio_wb32(pb, 0); /* version & flags */
+ avio_wb32(pb, 1); /* entry count */
- put_be32(pb, 0xc); /* size */
+ avio_wb32(pb, 0xc); /* size */
put_tag(pb, "url ");
- put_be32(pb, 1); /* version & flags */
+ avio_wb32(pb, 1); /* version & flags */
return 28;
}
@@ -978,7 +978,7 @@ static int mov_write_dref_tag(AVIOContext *pb)
static int mov_write_stbl_tag(AVIOContext *pb, MOVTrack *track)
{
int64_t pos = url_ftell(pb);
- put_be32(pb, 0); /* size */
+ avio_wb32(pb, 0); /* size */
put_tag(pb, "stbl");
mov_write_stsd_tag(pb, track);
mov_write_stts_tag(pb, track);
@@ -1000,7 +1000,7 @@ static int mov_write_stbl_tag(AVIOContext *pb, MOVTrack *track)
static int mov_write_dinf_tag(AVIOContext *pb)
{
int64_t pos = url_ftell(pb);
- put_be32(pb, 0); /* size */
+ avio_wb32(pb, 0); /* size */
put_tag(pb, "dinf");
mov_write_dref_tag(pb);
return updateSize(pb, pos);
@@ -1008,44 +1008,44 @@ static int mov_write_dinf_tag(AVIOContext *pb)
static int mov_write_nmhd_tag(AVIOContext *pb)
{
- put_be32(pb, 12);
+ avio_wb32(pb, 12);
put_tag(pb, "nmhd");
- put_be32(pb, 0);
+ avio_wb32(pb, 0);
return 12;
}
static int mov_write_gmhd_tag(AVIOContext *pb)
{
- put_be32(pb, 0x20); /* size */
+ avio_wb32(pb, 0x20); /* size */
put_tag(pb, "gmhd");
- put_be32(pb, 0x18); /* gmin size */
+ avio_wb32(pb, 0x18); /* gmin size */
put_tag(pb, "gmin"); /* generic media info */
- put_be32(pb, 0); /* version & flags */
- put_be16(pb, 0x40); /* graphics mode = */
- put_be16(pb, 0x8000); /* opColor (r?) */
- put_be16(pb, 0x8000); /* opColor (g?) */
- put_be16(pb, 0x8000); /* opColor (b?) */
- put_be16(pb, 0); /* balance */
- put_be16(pb, 0); /* reserved */
+ avio_wb32(pb, 0); /* version & flags */
+ avio_wb16(pb, 0x40); /* graphics mode = */
+ avio_wb16(pb, 0x8000); /* opColor (r?) */
+ avio_wb16(pb, 0x8000); /* opColor (g?) */
+ avio_wb16(pb, 0x8000); /* opColor (b?) */
+ avio_wb16(pb, 0); /* balance */
+ avio_wb16(pb, 0); /* reserved */
return 0x20;
}
static int mov_write_smhd_tag(AVIOContext *pb)
{
- put_be32(pb, 16); /* size */
+ avio_wb32(pb, 16); /* size */
put_tag(pb, "smhd");
- put_be32(pb, 0); /* version & flags */
- put_be16(pb, 0); /* reserved (balance, normally = 0) */
- put_be16(pb, 0); /* reserved */
+ avio_wb32(pb, 0); /* version & flags */
+ avio_wb16(pb, 0); /* reserved (balance, normally = 0) */
+ avio_wb16(pb, 0); /* reserved */
return 16;
}
static int mov_write_vmhd_tag(AVIOContext *pb)
{
- put_be32(pb, 0x14); /* size (always 0x14) */
+ avio_wb32(pb, 0x14); /* size (always 0x14) */
put_tag(pb, "vmhd");
- put_be32(pb, 0x01); /* version & flags */
- put_be64(pb, 0); /* reserved (graphics mode = copy) */
+ avio_wb32(pb, 0x01); /* version & flags */
+ avio_wb64(pb, 0); /* reserved (graphics mode = copy) */
return 0x14;
}
@@ -1076,19 +1076,19 @@ static int mov_write_hdlr_tag(AVIOContext *pb, MOVTrack *track)
}
}
- put_be32(pb, 0); /* size */
+ avio_wb32(pb, 0); /* size */
put_tag(pb, "hdlr");
- put_be32(pb, 0); /* Version & flags */
- put_buffer(pb, hdlr, 4); /* handler */
+ avio_wb32(pb, 0); /* Version & flags */
+ avio_write(pb, hdlr, 4); /* handler */
put_tag(pb, hdlr_type); /* handler type */
- put_be32(pb ,0); /* reserved */
- put_be32(pb ,0); /* reserved */
- put_be32(pb ,0); /* reserved */
+ avio_wb32(pb ,0); /* reserved */
+ avio_wb32(pb ,0); /* reserved */
+ avio_wb32(pb ,0); /* reserved */
if (!track || track->mode == MODE_MOV)
- put_byte(pb, strlen(descr)); /* pascal string */
- put_buffer(pb, descr, strlen(descr)); /* handler description */
+ avio_w8(pb, strlen(descr)); /* pascal string */
+ avio_write(pb, descr, strlen(descr)); /* handler description */
if (track && track->mode != MODE_MOV)
- put_byte(pb, 0); /* c string */
+ avio_w8(pb, 0); /* c string */
return updateSize(pb, pos);
}
@@ -1096,21 +1096,21 @@ static int mov_write_hmhd_tag(AVIOContext *pb)
{
/* This atom must be present, but leaving the values at zero
* seems harmless. */
- put_be32(pb, 28); /* size */
+ avio_wb32(pb, 28); /* size */
put_tag(pb, "hmhd");
- put_be32(pb, 0); /* version, flags */
- put_be16(pb, 0); /* maxPDUsize */
- put_be16(pb, 0); /* avgPDUsize */
- put_be32(pb, 0); /* maxbitrate */
- put_be32(pb, 0); /* avgbitrate */
- put_be32(pb, 0); /* reserved */
+ avio_wb32(pb, 0); /* version, flags */
+ avio_wb16(pb, 0); /* maxPDUsize */
+ avio_wb16(pb, 0); /* avgPDUsize */
+ avio_wb32(pb, 0); /* maxbitrate */
+ avio_wb32(pb, 0); /* avgbitrate */
+ avio_wb32(pb, 0); /* reserved */
return 28;
}
static int mov_write_minf_tag(AVIOContext *pb, MOVTrack *track)
{
int64_t pos = url_ftell(pb);
- put_be32(pb, 0); /* size */
+ avio_wb32(pb, 0); /* size */
put_tag(pb, "minf");
if(track->enc->codec_type == AVMEDIA_TYPE_VIDEO)
mov_write_vmhd_tag(pb);
@@ -1133,21 +1133,21 @@ static int mov_write_mdhd_tag(AVIOContext *pb, MOVTrack *track)
{
int version = track->trackDuration < INT32_MAX ? 0 : 1;
- (version == 1) ? put_be32(pb, 44) : put_be32(pb, 32); /* size */
+ (version == 1) ? avio_wb32(pb, 44) : avio_wb32(pb, 32); /* size */
put_tag(pb, "mdhd");
- put_byte(pb, version);
- put_be24(pb, 0); /* flags */
+ avio_w8(pb, version);
+ avio_wb24(pb, 0); /* flags */
if (version == 1) {
- put_be64(pb, track->time);
- put_be64(pb, track->time);
+ avio_wb64(pb, track->time);
+ avio_wb64(pb, track->time);
} else {
- put_be32(pb, track->time); /* creation time */
- put_be32(pb, track->time); /* modification time */
+ avio_wb32(pb, track->time); /* creation time */
+ avio_wb32(pb, track->time); /* modification time */
}
- put_be32(pb, track->timescale); /* time scale (sample rate for audio) */
- (version == 1) ? put_be64(pb, track->trackDuration) : put_be32(pb, track->trackDuration); /* duration */
- put_be16(pb, track->language); /* language */
- put_be16(pb, 0); /* reserved (quality) */
+ avio_wb32(pb, track->timescale); /* time scale (sample rate for audio) */
+ (version == 1) ? avio_wb64(pb, track->trackDuration) : avio_wb32(pb, track->trackDuration); /* duration */
+ avio_wb16(pb, track->language); /* language */
+ avio_wb16(pb, 0); /* reserved (quality) */
if(version!=0 && track->mode == MODE_MOV){
av_log(NULL, AV_LOG_ERROR,
@@ -1162,7 +1162,7 @@ static int mov_write_mdhd_tag(AVIOContext *pb, MOVTrack *track)
static int mov_write_mdia_tag(AVIOContext *pb, MOVTrack *track)
{
int64_t pos = url_ftell(pb);
- put_be32(pb, 0); /* size */
+ avio_wb32(pb, 0); /* size */
put_tag(pb, "mdia");
mov_write_mdhd_tag(pb, track);
mov_write_hdlr_tag(pb, track);
@@ -1176,41 +1176,41 @@ static int mov_write_tkhd_tag(AVIOContext *pb, MOVTrack *track, AVStream *st)
track->timescale, AV_ROUND_UP);
int version = duration < INT32_MAX ? 0 : 1;
- (version == 1) ? put_be32(pb, 104) : put_be32(pb, 92); /* size */
+ (version == 1) ? avio_wb32(pb, 104) : avio_wb32(pb, 92); /* size */
put_tag(pb, "tkhd");
- put_byte(pb, version);
- put_be24(pb, 0xf); /* flags (track enabled) */
+ avio_w8(pb, version);
+ avio_wb24(pb, 0xf); /* flags (track enabled) */
if (version == 1) {
- put_be64(pb, track->time);
- put_be64(pb, track->time);
+ avio_wb64(pb, track->time);
+ avio_wb64(pb, track->time);
} else {
- put_be32(pb, track->time); /* creation time */
- put_be32(pb, track->time); /* modification time */
+ avio_wb32(pb, track->time); /* creation time */
+ avio_wb32(pb, track->time); /* modification time */
}
- put_be32(pb, track->trackID); /* track-id */
- put_be32(pb, 0); /* reserved */
- (version == 1) ? put_be64(pb, duration) : put_be32(pb, duration);
+ avio_wb32(pb, track->trackID); /* track-id */
+ avio_wb32(pb, 0); /* reserved */
+ (version == 1) ? avio_wb64(pb, duration) : avio_wb32(pb, duration);
- put_be32(pb, 0); /* reserved */
- put_be32(pb, 0); /* reserved */
- put_be32(pb, 0x0); /* reserved (Layer & Alternate group) */
+ avio_wb32(pb, 0); /* reserved */
+ avio_wb32(pb, 0); /* reserved */
+ avio_wb32(pb, 0x0); /* reserved (Layer & Alternate group) */
/* Volume, only for audio */
if(track->enc->codec_type == AVMEDIA_TYPE_AUDIO)
- put_be16(pb, 0x0100);
+ avio_wb16(pb, 0x0100);
else
- put_be16(pb, 0);
- put_be16(pb, 0); /* reserved */
+ avio_wb16(pb, 0);
+ avio_wb16(pb, 0); /* reserved */
/* Matrix structure */
- put_be32(pb, 0x00010000); /* reserved */
- put_be32(pb, 0x0); /* reserved */
- put_be32(pb, 0x0); /* reserved */
- put_be32(pb, 0x0); /* reserved */
- put_be32(pb, 0x00010000); /* reserved */
- put_be32(pb, 0x0); /* reserved */
- put_be32(pb, 0x0); /* reserved */
- put_be32(pb, 0x0); /* reserved */
- put_be32(pb, 0x40000000); /* reserved */
+ avio_wb32(pb, 0x00010000); /* reserved */
+ avio_wb32(pb, 0x0); /* reserved */
+ avio_wb32(pb, 0x0); /* reserved */
+ avio_wb32(pb, 0x0); /* reserved */
+ avio_wb32(pb, 0x00010000); /* reserved */
+ avio_wb32(pb, 0x0); /* reserved */
+ avio_wb32(pb, 0x0); /* reserved */
+ avio_wb32(pb, 0x0); /* reserved */
+ avio_wb32(pb, 0x40000000); /* reserved */
/* Track width and height, for visual only */
if(st && (track->enc->codec_type == AVMEDIA_TYPE_VIDEO ||
@@ -1218,12 +1218,12 @@ static int mov_write_tkhd_tag(AVIOContext *pb, MOVTrack *track, AVStream *st)
double sample_aspect_ratio = av_q2d(st->sample_aspect_ratio);
if(!sample_aspect_ratio || track->height != track->enc->height)
sample_aspect_ratio = 1;
- put_be32(pb, sample_aspect_ratio * track->enc->width*0x10000);
- put_be32(pb, track->height*0x10000);
+ avio_wb32(pb, sample_aspect_ratio * track->enc->width*0x10000);
+ avio_wb32(pb, track->height*0x10000);
}
else {
- put_be32(pb, 0);
- put_be32(pb, 0);
+ avio_wb32(pb, 0);
+ avio_wb32(pb, 0);
}
return 0x5c;
}
@@ -1231,48 +1231,48 @@ static int mov_write_tkhd_tag(AVIOContext *pb, MOVTrack *track, AVStream *st)
// This box seems important for the psp playback ... without it the movie seems to hang
static int mov_write_edts_tag(AVIOContext *pb, MOVTrack *track)
{
- put_be32(pb, 0x24); /* size */
+ avio_wb32(pb, 0x24); /* size */
put_tag(pb, "edts");
- put_be32(pb, 0x1c); /* size */
+ avio_wb32(pb, 0x1c); /* size */
put_tag(pb, "elst");
- put_be32(pb, 0x0);
- put_be32(pb, 0x1);
+ avio_wb32(pb, 0x0);
+ avio_wb32(pb, 0x1);
/* duration ... doesn't seem to effect psp */
- put_be32(pb, av_rescale_rnd(track->trackDuration, MOV_TIMESCALE,
+ avio_wb32(pb, av_rescale_rnd(track->trackDuration, MOV_TIMESCALE,
track->timescale, AV_ROUND_UP));
- put_be32(pb, track->cluster[0].cts); /* first pts is cts since dts is 0 */
- put_be32(pb, 0x00010000);
+ avio_wb32(pb, track->cluster[0].cts); /* first pts is cts since dts is 0 */
+ avio_wb32(pb, 0x00010000);
return 0x24;
}
static int mov_write_tref_tag(AVIOContext *pb, MOVTrack *track)
{
- put_be32(pb, 20); // size
+ avio_wb32(pb, 20); // size
put_tag(pb, "tref");
- put_be32(pb, 12); // size (subatom)
- put_le32(pb, track->tref_tag);
- put_be32(pb, track->tref_id);
+ avio_wb32(pb, 12); // size (subatom)
+ avio_wl32(pb, track->tref_tag);
+ avio_wb32(pb, track->tref_id);
return 20;
}
// goes at the end of each track! ... Critical for PSP playback ("Incompatible data" without it)
static int mov_write_uuid_tag_psp(AVIOContext *pb, MOVTrack *mov)
{
- put_be32(pb, 0x34); /* size ... reports as 28 in mp4box! */
+ avio_wb32(pb, 0x34); /* size ... reports as 28 in mp4box! */
put_tag(pb, "uuid");
put_tag(pb, "USMT");
- put_be32(pb, 0x21d24fce);
- put_be32(pb, 0xbb88695c);
- put_be32(pb, 0xfac9c740);
- put_be32(pb, 0x1c); // another size here!
+ avio_wb32(pb, 0x21d24fce);
+ avio_wb32(pb, 0xbb88695c);
+ avio_wb32(pb, 0xfac9c740);
+ avio_wb32(pb, 0x1c); // another size here!
put_tag(pb, "MTDT");
- put_be32(pb, 0x00010012);
- put_be32(pb, 0x0a);
- put_be32(pb, 0x55c40000);
- put_be32(pb, 0x1);
- put_be32(pb, 0x0);
+ avio_wb32(pb, 0x00010012);
+ avio_wb32(pb, 0x0a);
+ avio_wb32(pb, 0x55c40000);
+ avio_wb32(pb, 0x1);
+ avio_wb32(pb, 0x0);
return 0x34;
}
@@ -1285,20 +1285,20 @@ static int mov_write_udta_sdp(AVIOContext *pb, AVCodecContext *ctx, int index)
av_strlcatf(buf, sizeof(buf), "a=control:streamid=%d\r\n", index);
len = strlen(buf);
- put_be32(pb, len + 24);
+ avio_wb32(pb, len + 24);
put_tag (pb, "udta");
- put_be32(pb, len + 16);
+ avio_wb32(pb, len + 16);
put_tag (pb, "hnti");
- put_be32(pb, len + 8);
+ avio_wb32(pb, len + 8);
put_tag (pb, "sdp ");
- put_buffer(pb, buf, len);
+ avio_write(pb, buf, len);
return len + 24;
}
static int mov_write_trak_tag(AVIOContext *pb, MOVTrack *track, AVStream *st)
{
int64_t pos = url_ftell(pb);
- put_be32(pb, 0); /* size */
+ avio_wb32(pb, 0); /* size */
put_tag(pb, "trak");
mov_write_tkhd_tag(pb, track, st);
if (track->mode == MODE_PSP || track->flags & MOV_TRACK_CTTS)
@@ -1317,14 +1317,14 @@ static int mov_write_trak_tag(AVIOContext *pb, MOVTrack *track, AVStream *st)
/* TODO: Not sorted out, but not necessary either */
static int mov_write_iods_tag(AVIOContext *pb, MOVMuxContext *mov)
{
- put_be32(pb, 0x15); /* size */
+ avio_wb32(pb, 0x15); /* size */
put_tag(pb, "iods");
- put_be32(pb, 0); /* version & flags */
- put_be16(pb, 0x1007);
- put_byte(pb, 0);
- put_be16(pb, 0x4fff);
- put_be16(pb, 0xfffe);
- put_be16(pb, 0x01ff);
+ avio_wb32(pb, 0); /* version & flags */
+ avio_wb16(pb, 0x1007);
+ avio_w8(pb, 0);
+ avio_wb16(pb, 0x4fff);
+ avio_wb16(pb, 0xfffe);
+ avio_wb16(pb, 0x01ff);
return 0x15;
}
#endif
@@ -1349,59 +1349,59 @@ static int mov_write_mvhd_tag(AVIOContext *pb, MOVMuxContext *mov)
}
version = maxTrackLen < UINT32_MAX ? 0 : 1;
- (version == 1) ? put_be32(pb, 120) : put_be32(pb, 108); /* size */
+ (version == 1) ? avio_wb32(pb, 120) : avio_wb32(pb, 108); /* size */
put_tag(pb, "mvhd");
- put_byte(pb, version);
- put_be24(pb, 0); /* flags */
+ avio_w8(pb, version);
+ avio_wb24(pb, 0); /* flags */
if (version == 1) {
- put_be64(pb, mov->time);
- put_be64(pb, mov->time);
+ avio_wb64(pb, mov->time);
+ avio_wb64(pb, mov->time);
} else {
- put_be32(pb, mov->time); /* creation time */
- put_be32(pb, mov->time); /* modification time */
+ avio_wb32(pb, mov->time); /* creation time */
+ avio_wb32(pb, mov->time); /* modification time */
}
- put_be32(pb, MOV_TIMESCALE);
- (version == 1) ? put_be64(pb, maxTrackLen) : put_be32(pb, maxTrackLen); /* duration of longest track */
+ avio_wb32(pb, MOV_TIMESCALE);
+ (version == 1) ? avio_wb64(pb, maxTrackLen) : avio_wb32(pb, maxTrackLen); /* duration of longest track */
- put_be32(pb, 0x00010000); /* reserved (preferred rate) 1.0 = normal */
- put_be16(pb, 0x0100); /* reserved (preferred volume) 1.0 = normal */
- put_be16(pb, 0); /* reserved */
- put_be32(pb, 0); /* reserved */
- put_be32(pb, 0); /* reserved */
+ avio_wb32(pb, 0x00010000); /* reserved (preferred rate) 1.0 = normal */
+ avio_wb16(pb, 0x0100); /* reserved (preferred volume) 1.0 = normal */
+ avio_wb16(pb, 0); /* reserved */
+ avio_wb32(pb, 0); /* reserved */
+ avio_wb32(pb, 0); /* reserved */
/* Matrix structure */
- put_be32(pb, 0x00010000); /* reserved */
- put_be32(pb, 0x0); /* reserved */
- put_be32(pb, 0x0); /* reserved */
- put_be32(pb, 0x0); /* reserved */
- put_be32(pb, 0x00010000); /* reserved */
- put_be32(pb, 0x0); /* reserved */
- put_be32(pb, 0x0); /* reserved */
- put_be32(pb, 0x0); /* reserved */
- put_be32(pb, 0x40000000); /* reserved */
-
- put_be32(pb, 0); /* reserved (preview time) */
- put_be32(pb, 0); /* reserved (preview duration) */
- put_be32(pb, 0); /* reserved (poster time) */
- put_be32(pb, 0); /* reserved (selection time) */
- put_be32(pb, 0); /* reserved (selection duration) */
- put_be32(pb, 0); /* reserved (current time) */
- put_be32(pb, maxTrackID+1); /* Next track id */
+ avio_wb32(pb, 0x00010000); /* reserved */
+ avio_wb32(pb, 0x0); /* reserved */
+ avio_wb32(pb, 0x0); /* reserved */
+ avio_wb32(pb, 0x0); /* reserved */
+ avio_wb32(pb, 0x00010000); /* reserved */
+ avio_wb32(pb, 0x0); /* reserved */
+ avio_wb32(pb, 0x0); /* reserved */
+ avio_wb32(pb, 0x0); /* reserved */
+ avio_wb32(pb, 0x40000000); /* reserved */
+
+ avio_wb32(pb, 0); /* reserved (preview time) */
+ avio_wb32(pb, 0); /* reserved (preview duration) */
+ avio_wb32(pb, 0); /* reserved (poster time) */
+ avio_wb32(pb, 0); /* reserved (selection time) */
+ avio_wb32(pb, 0); /* reserved (selection duration) */
+ avio_wb32(pb, 0); /* reserved (current time) */
+ avio_wb32(pb, maxTrackID+1); /* Next track id */
return 0x6c;
}
static int mov_write_itunes_hdlr_tag(AVIOContext *pb, MOVMuxContext *mov,
AVFormatContext *s)
{
- put_be32(pb, 33); /* size */
+ avio_wb32(pb, 33); /* size */
put_tag(pb, "hdlr");
- put_be32(pb, 0);
- put_be32(pb, 0);
+ avio_wb32(pb, 0);
+ avio_wb32(pb, 0);
put_tag(pb, "mdir");
put_tag(pb, "appl");
- put_be32(pb, 0);
- put_be32(pb, 0);
- put_byte(pb, 0);
+ avio_wb32(pb, 0);
+ avio_wb32(pb, 0);
+ avio_w8(pb, 0);
return 33;
}
@@ -1410,18 +1410,18 @@ static int mov_write_string_data_tag(AVIOContext *pb, const char *data, int lang
{
if(long_style){
int size = 16 + strlen(data);
- put_be32(pb, size); /* size */
+ avio_wb32(pb, size); /* size */
put_tag(pb, "data");
- put_be32(pb, 1);
- put_be32(pb, 0);
- put_buffer(pb, data, strlen(data));
+ avio_wb32(pb, 1);
+ avio_wb32(pb, 0);
+ avio_write(pb, data, strlen(data));
return size;
}else{
if (!lang)
lang = ff_mov_iso639_to_lang("und", 1);
- put_be16(pb, strlen(data)); /* string length */
- put_be16(pb, lang);
- put_buffer(pb, data, strlen(data));
+ avio_wb16(pb, strlen(data)); /* string length */
+ avio_wb16(pb, lang);
+ avio_write(pb, data, strlen(data));
return strlen(data) + 4;
}
}
@@ -1430,7 +1430,7 @@ static int mov_write_string_tag(AVIOContext *pb, const char *name, const char *v
int size = 0;
if (value && value[0]) {
int64_t pos = url_ftell(pb);
- put_be32(pb, 0); /* size */
+ avio_wb32(pb, 0); /* size */
put_tag(pb, name);
mov_write_string_data_tag(pb, value, lang, long_style);
size= updateSize(pb, pos);
@@ -1469,16 +1469,16 @@ static int mov_write_trkn_tag(AVIOContext *pb, MOVMuxContext *mov,
AVMetadataTag *t = av_metadata_get(s->metadata, "track", NULL, 0);
int size = 0, track = t ? atoi(t->value) : 0;
if (track) {
- put_be32(pb, 32); /* size */
+ avio_wb32(pb, 32); /* size */
put_tag(pb, "trkn");
- put_be32(pb, 24); /* size */
+ avio_wb32(pb, 24); /* size */
put_tag(pb, "data");
- put_be32(pb, 0); // 8 bytes empty
- put_be32(pb, 0);
- put_be16(pb, 0); // empty
- put_be16(pb, track); // track number
- put_be16(pb, 0); // total track number
- put_be16(pb, 0); // empty
+ avio_wb32(pb, 0); // 8 bytes empty
+ avio_wb32(pb, 0);
+ avio_wb16(pb, 0); // empty
+ avio_wb16(pb, track); // track number
+ avio_wb16(pb, 0); // total track number
+ avio_wb16(pb, 0); // empty
size = 32;
}
return size;
@@ -1489,7 +1489,7 @@ static int mov_write_ilst_tag(AVIOContext *pb, MOVMuxContext *mov,
AVFormatContext *s)
{
int64_t pos = url_ftell(pb);
- put_be32(pb, 0); /* size */
+ avio_wb32(pb, 0); /* size */
put_tag(pb, "ilst");
mov_write_string_metadata(s, pb, "\251nam", "title" , 1);
mov_write_string_metadata(s, pb, "\251ART", "artist" , 1);
@@ -1518,9 +1518,9 @@ static int mov_write_meta_tag(AVIOContext *pb, MOVMuxContext *mov,
{
int size = 0;
int64_t pos = url_ftell(pb);
- put_be32(pb, 0); /* size */
+ avio_wb32(pb, 0); /* size */
put_tag(pb, "meta");
- put_be32(pb, 0);
+ avio_wb32(pb, 0);
mov_write_itunes_hdlr_tag(pb, mov, s);
mov_write_ilst_tag(pb, mov, s);
size = updateSize(pb, pos);
@@ -1543,9 +1543,9 @@ static int ascii_to_wc(AVIOContext *pb, const uint8_t *b)
int val;
while(*b){
GET_UTF8(val, *b++, return -1;)
- put_be16(pb, val);
+ avio_wb16(pb, val);
}
- put_be16(pb, 0x00);
+ avio_wb16(pb, 0x00);
return 0;
}
@@ -1561,17 +1561,17 @@ static int mov_write_3gp_udta_tag(AVIOContext *pb, AVFormatContext *s,
AVMetadataTag *t = av_metadata_get(s->metadata, str, NULL, 0);
if (!t || !utf8len(t->value))
return 0;
- put_be32(pb, 0); /* size */
+ avio_wb32(pb, 0); /* size */
put_tag (pb, tag); /* type */
- put_be32(pb, 0); /* version + flags */
+ avio_wb32(pb, 0); /* version + flags */
if (!strcmp(tag, "yrrc"))
- put_be16(pb, atoi(t->value));
+ avio_wb16(pb, atoi(t->value));
else {
- put_be16(pb, language_code("eng")); /* language */
- put_buffer(pb, t->value, strlen(t->value)+1); /* UTF8 string value */
+ avio_wb16(pb, language_code("eng")); /* language */
+ avio_write(pb, t->value, strlen(t->value)+1); /* UTF8 string value */
if (!strcmp(tag, "albm") &&
(t = av_metadata_get(s->metadata, "track", NULL, 0)))
- put_byte(pb, atoi(t->value));
+ avio_w8(pb, atoi(t->value));
}
return updateSize(pb, pos);
}
@@ -1581,23 +1581,23 @@ static int mov_write_chpl_tag(AVIOContext *pb, AVFormatContext *s)
int64_t pos = url_ftell(pb);
int i, nb_chapters = FFMIN(s->nb_chapters, 255);
- put_be32(pb, 0); // size
+ avio_wb32(pb, 0); // size
put_tag (pb, "chpl");
- put_be32(pb, 0x01000000); // version + flags
- put_be32(pb, 0); // unknown
- put_byte(pb, nb_chapters);
+ avio_wb32(pb, 0x01000000); // version + flags
+ avio_wb32(pb, 0); // unknown
+ avio_w8(pb, nb_chapters);
for (i = 0; i < nb_chapters; i++) {
AVChapter *c = s->chapters[i];
AVMetadataTag *t;
- put_be64(pb, av_rescale_q(c->start, c->time_base, (AVRational){1,10000000}));
+ avio_wb64(pb, av_rescale_q(c->start, c->time_base, (AVRational){1,10000000}));
if ((t = av_metadata_get(c->metadata, "title", NULL, 0))) {
int len = FFMIN(strlen(t->value), 255);
- put_byte(pb, len);
- put_buffer(pb, t->value, len);
+ avio_w8(pb, len);
+ avio_write(pb, t->value, len);
} else
- put_byte(pb, 0);
+ avio_w8(pb, 0);
}
return updateSize(pb, pos);
}
@@ -1646,9 +1646,9 @@ static int mov_write_udta_tag(AVIOContext *pb, MOVMuxContext *mov,
mov_write_chpl_tag(pb_buf, s);
if ((size = url_close_dyn_buf(pb_buf, &buf)) > 0) {
- put_be32(pb, size+8);
+ avio_wb32(pb, size+8);
put_tag(pb, "udta");
- put_buffer(pb, buf, size);
+ avio_write(pb, buf, size);
}
av_free(buf);
@@ -1661,10 +1661,10 @@ static void mov_write_psp_udta_tag(AVIOContext *pb,
int len = utf8len(str)+1;
if(len<=0)
return;
- put_be16(pb, len*2+10); /* size */
- put_be32(pb, type); /* type */
- put_be16(pb, language_code(lang)); /* language */
- put_be16(pb, 0x01); /* ? */
+ avio_wb16(pb, len*2+10); /* size */
+ avio_wb32(pb, type); /* type */
+ avio_wb16(pb, language_code(lang)); /* language */
+ avio_wb16(pb, 0x01); /* ? */
ascii_to_wc(pb, str);
}
@@ -1675,24 +1675,24 @@ static int mov_write_uuidusmt_tag(AVIOContext *pb, AVFormatContext *s)
if (title) {
pos = url_ftell(pb);
- put_be32(pb, 0); /* size placeholder*/
+ avio_wb32(pb, 0); /* size placeholder*/
put_tag(pb, "uuid");
put_tag(pb, "USMT");
- put_be32(pb, 0x21d24fce); /* 96 bit UUID */
- put_be32(pb, 0xbb88695c);
- put_be32(pb, 0xfac9c740);
+ avio_wb32(pb, 0x21d24fce); /* 96 bit UUID */
+ avio_wb32(pb, 0xbb88695c);
+ avio_wb32(pb, 0xfac9c740);
pos2 = url_ftell(pb);
- put_be32(pb, 0); /* size placeholder*/
+ avio_wb32(pb, 0); /* size placeholder*/
put_tag(pb, "MTDT");
- put_be16(pb, 4);
+ avio_wb16(pb, 4);
// ?
- put_be16(pb, 0x0C); /* size */
- put_be32(pb, 0x0B); /* type */
- put_be16(pb, language_code("und")); /* language */
- put_be16(pb, 0x0); /* ? */
- put_be16(pb, 0x021C); /* data */
+ avio_wb16(pb, 0x0C); /* size */
+ avio_wb32(pb, 0x0B); /* type */
+ avio_wb16(pb, language_code("und")); /* language */
+ avio_wb16(pb, 0x0); /* ? */
+ avio_wb16(pb, 0x021C); /* data */
mov_write_psp_udta_tag(pb, LIBAVCODEC_IDENT, "eng", 0x04);
mov_write_psp_udta_tag(pb, title->value, "eng", 0x01);
@@ -1711,7 +1711,7 @@ static int mov_write_moov_tag(AVIOContext *pb, MOVMuxContext *mov,
{
int i;
int64_t pos = url_ftell(pb);
- put_be32(pb, 0); /* size placeholder*/
+ avio_wb32(pb, 0); /* size placeholder*/
put_tag(pb, "moov");
for (i=0; i<mov->nb_streams; i++) {
@@ -1752,11 +1752,11 @@ static int mov_write_moov_tag(AVIOContext *pb, MOVMuxContext *mov,
static int mov_write_mdat_tag(AVIOContext *pb, MOVMuxContext *mov)
{
- put_be32(pb, 8); // placeholder for extended size field (64 bit)
+ avio_wb32(pb, 8); // placeholder for extended size field (64 bit)
put_tag(pb, mov->mode == MODE_MOV ? "wide" : "free");
mov->mdat_pos = url_ftell(pb);
- put_be32(pb, 0); /* size placeholder*/
+ avio_wb32(pb, 0); /* size placeholder*/
put_tag(pb, "mdat");
return 0;
}
@@ -1778,7 +1778,7 @@ static int mov_write_ftyp_tag(AVIOContext *pb, AVFormatContext *s)
has_h264 = 1;
}
- put_be32(pb, 0); /* size */
+ avio_wb32(pb, 0); /* size */
put_tag(pb, "ftyp");
if (mov->mode == MODE_3GP) {
@@ -1796,7 +1796,7 @@ static int mov_write_ftyp_tag(AVIOContext *pb, AVFormatContext *s)
else
put_tag(pb, "qt ");
- put_be32(pb, minor);
+ avio_wb32(pb, minor);
if(mov->mode == MODE_MOV)
put_tag(pb, "qt ");
@@ -1827,56 +1827,56 @@ static void mov_write_uuidprof_tag(AVIOContext *pb, AVFormatContext *s)
int audio_kbitrate= AudioCodec->bit_rate / 1000;
int video_kbitrate= FFMIN(VideoCodec->bit_rate / 1000, 800 - audio_kbitrate);
- put_be32(pb, 0x94); /* size */
+ avio_wb32(pb, 0x94); /* size */
put_tag(pb, "uuid");
put_tag(pb, "PROF");
- put_be32(pb, 0x21d24fce); /* 96 bit UUID */
- put_be32(pb, 0xbb88695c);
- put_be32(pb, 0xfac9c740);
+ avio_wb32(pb, 0x21d24fce); /* 96 bit UUID */
+ avio_wb32(pb, 0xbb88695c);
+ avio_wb32(pb, 0xfac9c740);
- put_be32(pb, 0x0); /* ? */
- put_be32(pb, 0x3); /* 3 sections ? */
+ avio_wb32(pb, 0x0); /* ? */
+ avio_wb32(pb, 0x3); /* 3 sections ? */
- put_be32(pb, 0x14); /* size */
+ avio_wb32(pb, 0x14); /* size */
put_tag(pb, "FPRF");
- put_be32(pb, 0x0); /* ? */
- put_be32(pb, 0x0); /* ? */
- put_be32(pb, 0x0); /* ? */
+ avio_wb32(pb, 0x0); /* ? */
+ avio_wb32(pb, 0x0); /* ? */
+ avio_wb32(pb, 0x0); /* ? */
- put_be32(pb, 0x2c); /* size */
+ avio_wb32(pb, 0x2c); /* size */
put_tag(pb, "APRF"); /* audio */
- put_be32(pb, 0x0);
- put_be32(pb, 0x2); /* TrackID */
+ avio_wb32(pb, 0x0);
+ avio_wb32(pb, 0x2); /* TrackID */
put_tag(pb, "mp4a");
- put_be32(pb, 0x20f);
- put_be32(pb, 0x0);
- put_be32(pb, audio_kbitrate);
- put_be32(pb, audio_kbitrate);
- put_be32(pb, AudioRate);
- put_be32(pb, AudioCodec->channels);
-
- put_be32(pb, 0x34); /* size */
+ avio_wb32(pb, 0x20f);
+ avio_wb32(pb, 0x0);
+ avio_wb32(pb, audio_kbitrate);
+ avio_wb32(pb, audio_kbitrate);
+ avio_wb32(pb, AudioRate);
+ avio_wb32(pb, AudioCodec->channels);
+
+ avio_wb32(pb, 0x34); /* size */
put_tag(pb, "VPRF"); /* video */
- put_be32(pb, 0x0);
- put_be32(pb, 0x1); /* TrackID */
+ avio_wb32(pb, 0x0);
+ avio_wb32(pb, 0x1); /* TrackID */
if (VideoCodec->codec_id == CODEC_ID_H264) {
put_tag(pb, "avc1");
- put_be16(pb, 0x014D);
- put_be16(pb, 0x0015);
+ avio_wb16(pb, 0x014D);
+ avio_wb16(pb, 0x0015);
} else {
put_tag(pb, "mp4v");
- put_be16(pb, 0x0000);
- put_be16(pb, 0x0103);
+ avio_wb16(pb, 0x0000);
+ avio_wb16(pb, 0x0103);
}
- put_be32(pb, 0x0);
- put_be32(pb, video_kbitrate);
- put_be32(pb, video_kbitrate);
- put_be32(pb, FrameRate);
- put_be32(pb, FrameRate);
- put_be16(pb, VideoCodec->width);
- put_be16(pb, VideoCodec->height);
- put_be32(pb, 0x010001); /* ? */
+ avio_wb32(pb, 0x0);
+ avio_wb32(pb, video_kbitrate);
+ avio_wb32(pb, video_kbitrate);
+ avio_wb32(pb, FrameRate);
+ avio_wb32(pb, FrameRate);
+ avio_wb16(pb, VideoCodec->width);
+ avio_wb16(pb, VideoCodec->height);
+ avio_wb32(pb, 0x010001); /* ? */
}
static int mov_parse_mpeg2_frame(AVPacket *pkt, uint32_t *flags)
@@ -1946,7 +1946,7 @@ int ff_mov_write_packet(AVFormatContext *s, AVPacket *pkt)
/* nal reformating needed */
size = ff_avc_parse_nal_units(pb, pkt->data, pkt->size);
} else {
- put_buffer(pb, pkt->data, size);
+ avio_write(pb, pkt->data, size);
}
if ((enc->codec_id == CODEC_ID_DNXHD ||
@@ -2201,13 +2201,13 @@ static int mov_write_trailer(AVFormatContext *s)
/* Write size of mdat tag */
if (mov->mdat_size+8 <= UINT32_MAX) {
url_fseek(pb, mov->mdat_pos, SEEK_SET);
- put_be32(pb, mov->mdat_size+8);
+ avio_wb32(pb, mov->mdat_size+8);
} else {
/* overwrite 'wide' placeholder atom */
url_fseek(pb, mov->mdat_pos - 8, SEEK_SET);
- put_be32(pb, 1); /* special value: real atom size will be 64 bit value after tag field */
+ avio_wb32(pb, 1); /* special value: real atom size will be 64 bit value after tag field */
put_tag(pb, "mdat");
- put_be64(pb, mov->mdat_size+16);
+ avio_wb64(pb, mov->mdat_size+16);
}
url_fseek(pb, moov_pos, SEEK_SET);
diff --git a/libavformat/movenchint.c b/libavformat/movenchint.c
index d9c1e44f05..fbc7faace6 100644
--- a/libavformat/movenchint.c
+++ b/libavformat/movenchint.c
@@ -251,14 +251,14 @@ static void output_immediate(const uint8_t *data, int size,
int len = size;
if (len > 14)
len = 14;
- put_byte(out, 1); /* immediate constructor */
- put_byte(out, len); /* amount of valid data */
- put_buffer(out, data, len);
+ avio_w8(out, 1); /* immediate constructor */
+ avio_w8(out, len); /* amount of valid data */
+ avio_write(out, data, len);
data += len;
size -= len;
for (; len < 14; len++)
- put_byte(out, 0);
+ avio_w8(out, 0);
(*entries)++;
}
@@ -267,13 +267,13 @@ static void output_immediate(const uint8_t *data, int size,
static void output_match(AVIOContext *out, int match_sample,
int match_offset, int match_len, int *entries)
{
- put_byte(out, 2); /* sample constructor */
- put_byte(out, 0); /* track reference */
- put_be16(out, match_len);
- put_be32(out, match_sample);
- put_be32(out, match_offset);
- put_be16(out, 1); /* bytes per block */
- put_be16(out, 1); /* samples per block */
+ avio_w8(out, 2); /* sample constructor */
+ avio_w8(out, 0); /* track reference */
+ avio_wb16(out, match_len);
+ avio_wb32(out, match_sample);
+ avio_wb32(out, match_offset);
+ avio_wb16(out, 1); /* bytes per block */
+ avio_wb16(out, 1); /* samples per block */
(*entries)++;
}
@@ -318,8 +318,8 @@ static int write_hint_packets(AVIOContext *out, const uint8_t *data,
count_pos = url_ftell(out);
/* RTPsample header */
- put_be16(out, 0); /* packet count */
- put_be16(out, 0); /* reserved */
+ avio_wb16(out, 0); /* packet count */
+ avio_wb16(out, 0); /* reserved */
while (size > 4) {
uint32_t packet_len = AV_RB32(data);
@@ -354,12 +354,12 @@ static int write_hint_packets(AVIOContext *out, const uint8_t *data,
count++;
/* RTPpacket header */
- put_be32(out, 0); /* relative_time */
- put_buffer(out, data, 2); /* RTP header */
- put_be16(out, seq); /* RTPsequenceseed */
- put_be16(out, 0); /* reserved + flags */
+ avio_wb32(out, 0); /* relative_time */
+ avio_write(out, data, 2); /* RTP header */
+ avio_wb16(out, seq); /* RTPsequenceseed */
+ avio_wb16(out, 0); /* reserved + flags */
entries_pos = url_ftell(out);
- put_be16(out, 0); /* entry count */
+ avio_wb16(out, 0); /* entry count */
data += 12;
size -= 12;
@@ -373,13 +373,13 @@ static int write_hint_packets(AVIOContext *out, const uint8_t *data,
curpos = url_ftell(out);
url_fseek(out, entries_pos, SEEK_SET);
- put_be16(out, entries);
+ avio_wb16(out, entries);
url_fseek(out, curpos, SEEK_SET);
}
curpos = url_ftell(out);
url_fseek(out, count_pos, SEEK_SET);
- put_be16(out, count);
+ avio_wb16(out, count);
url_fseek(out, curpos, SEEK_SET);
return count;
}
diff --git a/libavformat/mp3enc.c b/libavformat/mp3enc.c
index cdecda67c3..0635228f61 100644
--- a/libavformat/mp3enc.c
+++ b/libavformat/mp3enc.c
@@ -71,10 +71,10 @@ static int id3v1_create_tag(AVFormatContext *s, uint8_t *buf)
static void id3v2_put_size(AVFormatContext *s, int size)
{
- put_byte(s->pb, size >> 21 & 0x7f);
- put_byte(s->pb, size >> 14 & 0x7f);
- put_byte(s->pb, size >> 7 & 0x7f);
- put_byte(s->pb, size & 0x7f);
+ avio_w8(s->pb, size >> 21 & 0x7f);
+ avio_w8(s->pb, size >> 14 & 0x7f);
+ avio_w8(s->pb, size >> 7 & 0x7f);
+ avio_w8(s->pb, size & 0x7f);
}
static int string_is_ascii(const uint8_t *str)
@@ -104,9 +104,9 @@ static int id3v2_put_ttag(AVFormatContext *s, const char *str1, const char *str2
(!str2 || string_is_ascii(str2)))
enc = ID3v2_ENCODING_ISO8859;
- put_byte(dyn_buf, enc);
+ avio_w8(dyn_buf, enc);
if (enc == ID3v2_ENCODING_UTF16BOM) {
- put_le16(dyn_buf, 0xFEFF); /* BOM */
+ avio_wl16(dyn_buf, 0xFEFF); /* BOM */
put = avio_put_str16le;
} else
put = avio_put_str;
@@ -116,10 +116,10 @@ static int id3v2_put_ttag(AVFormatContext *s, const char *str1, const char *str2
put(dyn_buf, str2);
len = url_close_dyn_buf(dyn_buf, &pb);
- put_be32(s->pb, tag);
+ avio_wb32(s->pb, tag);
id3v2_put_size(s, len);
- put_be16(s->pb, 0);
- put_buffer(s->pb, pb, len);
+ avio_wb16(s->pb, 0);
+ avio_write(s->pb, pb, len);
av_freep(&pb);
return len + ID3v2_HEADER_SIZE;
@@ -128,7 +128,7 @@ static int id3v2_put_ttag(AVFormatContext *s, const char *str1, const char *str2
static int mp3_write_packet(struct AVFormatContext *s, AVPacket *pkt)
{
- put_buffer(s->pb, pkt->data, pkt->size);
+ avio_write(s->pb, pkt->data, pkt->size);
put_flush_packet(s->pb);
return 0;
}
@@ -139,7 +139,7 @@ static int mp3_write_trailer(struct AVFormatContext *s)
/* write the id3v1 tag */
if (id3v1_create_tag(s, buf) > 0) {
- put_buffer(s->pb, buf, ID3v1_TAG_SIZE);
+ avio_write(s->pb, buf, ID3v1_TAG_SIZE);
put_flush_packet(s->pb);
}
return 0;
@@ -206,13 +206,13 @@ static int mp3_write_header(struct AVFormatContext *s)
ID3v2_ENCODING_UTF8;
int64_t size_pos, cur_pos;
- put_be32(s->pb, MKBETAG('I', 'D', '3', mp3->id3v2_version));
- put_byte(s->pb, 0);
- put_byte(s->pb, 0); /* flags */
+ avio_wb32(s->pb, MKBETAG('I', 'D', '3', mp3->id3v2_version));
+ avio_w8(s->pb, 0);
+ avio_w8(s->pb, 0); /* flags */
/* reserve space for size */
size_pos = url_ftell(s->pb);
- put_be32(s->pb, 0);
+ avio_wb32(s->pb, 0);
ff_metadata_conv(&s->metadata, ff_id3v2_34_metadata_conv, NULL);
if (mp3->id3v2_version == 4)
diff --git a/libavformat/mpegenc.c b/libavformat/mpegenc.c
index e5ee32d276..8c5c644f42 100644
--- a/libavformat/mpegenc.c
+++ b/libavformat/mpegenc.c
@@ -493,12 +493,12 @@ static int mpeg_mux_init(AVFormatContext *ctx)
static inline void put_timestamp(AVIOContext *pb, int id, int64_t timestamp)
{
- put_byte(pb,
+ avio_w8(pb,
(id << 4) |
(((timestamp >> 30) & 0x07) << 1) |
1);
- put_be16(pb, (uint16_t)((((timestamp >> 15) & 0x7fff) << 1) | 1));
- put_be16(pb, (uint16_t)((((timestamp ) & 0x7fff) << 1) | 1));
+ avio_wb16(pb, (uint16_t)((((timestamp >> 15) & 0x7fff) << 1) | 1));
+ avio_wb16(pb, (uint16_t)((((timestamp ) & 0x7fff) << 1) | 1));
}
@@ -618,16 +618,16 @@ static void put_padding_packet(AVFormatContext *ctx, AVIOContext *pb,int packet_
MpegMuxContext *s = ctx->priv_data;
int i;
- put_be32(pb, PADDING_STREAM);
- put_be16(pb, packet_bytes - 6);
+ avio_wb32(pb, PADDING_STREAM);
+ avio_wb16(pb, packet_bytes - 6);
if (!s->is_mpeg2) {
- put_byte(pb, 0x0f);
+ avio_w8(pb, 0x0f);
packet_bytes -= 7;
} else
packet_bytes -= 6;
for(i=0;i<packet_bytes;i++)
- put_byte(pb, 0xff);
+ avio_w8(pb, 0xff);
}
static int get_nb_frames(AVFormatContext *ctx, StreamInfo *stream, int len){
@@ -699,19 +699,19 @@ static int flush_packet(AVFormatContext *ctx, int stream_index,
size = put_system_header(ctx, buf_ptr, 0);
buf_ptr += size;
size = buf_ptr - buffer;
- put_buffer(ctx->pb, buffer, size);
+ avio_write(ctx->pb, buffer, size);
- put_be32(ctx->pb, PRIVATE_STREAM_2);
- put_be16(ctx->pb, 0x03d4); // length
- put_byte(ctx->pb, 0x00); // substream ID, 00=PCI
+ avio_wb32(ctx->pb, PRIVATE_STREAM_2);
+ avio_wb16(ctx->pb, 0x03d4); // length
+ avio_w8(ctx->pb, 0x00); // substream ID, 00=PCI
for (i = 0; i < 979; i++)
- put_byte(ctx->pb, 0x00);
+ avio_w8(ctx->pb, 0x00);
- put_be32(ctx->pb, PRIVATE_STREAM_2);
- put_be16(ctx->pb, 0x03fa); // length
- put_byte(ctx->pb, 0x01); // substream ID, 01=DSI
+ avio_wb32(ctx->pb, PRIVATE_STREAM_2);
+ avio_wb16(ctx->pb, 0x03fa); // length
+ avio_w8(ctx->pb, 0x01); // substream ID, 01=DSI
for (i = 0; i < 1017; i++)
- put_byte(ctx->pb, 0x00);
+ avio_w8(ctx->pb, 0x00);
memset(buffer, 0, 128);
buf_ptr = buffer;
@@ -734,7 +734,7 @@ static int flush_packet(AVFormatContext *ctx, int stream_index,
}
}
size = buf_ptr - buffer;
- put_buffer(ctx->pb, buffer, size);
+ avio_write(ctx->pb, buffer, size);
packet_size = s->packet_size - size;
@@ -839,16 +839,16 @@ static int flush_packet(AVFormatContext *ctx, int stream_index,
nb_frames= get_nb_frames(ctx, stream, payload_size - stuffing_size);
- put_be32(ctx->pb, startcode);
+ avio_wb32(ctx->pb, startcode);
- put_be16(ctx->pb, packet_size);
+ avio_wb16(ctx->pb, packet_size);
if (!s->is_mpeg2)
for(i=0;i<stuffing_size;i++)
- put_byte(ctx->pb, 0xff);
+ avio_w8(ctx->pb, 0xff);
if (s->is_mpeg2) {
- put_byte(ctx->pb, 0x80); /* mpeg2 id */
+ avio_w8(ctx->pb, 0x80); /* mpeg2 id */
pes_flags=0;
@@ -865,8 +865,8 @@ static int flush_packet(AVFormatContext *ctx, int stream_index,
if (stream->packet_number == 0)
pes_flags |= 0x01;
- put_byte(ctx->pb, pes_flags); /* flags */
- put_byte(ctx->pb, header_len - 3 + stuffing_size);
+ avio_w8(ctx->pb, pes_flags); /* flags */
+ avio_w8(ctx->pb, header_len - 3 + stuffing_size);
if (pes_flags & 0x80) /*write pts*/
put_timestamp(ctx->pb, (pes_flags & 0x40) ? 0x03 : 0x02, pts);
@@ -874,13 +874,13 @@ static int flush_packet(AVFormatContext *ctx, int stream_index,
put_timestamp(ctx->pb, 0x01, dts);
if (pes_flags & 0x01) { /*write pes extension*/
- put_byte(ctx->pb, 0x10); /* flags */
+ avio_w8(ctx->pb, 0x10); /* flags */
/* P-STD buffer info */
if ((id & 0xe0) == AUDIO_ID)
- put_be16(ctx->pb, 0x4000 | stream->max_buffer_size/ 128);
+ avio_wb16(ctx->pb, 0x4000 | stream->max_buffer_size/ 128);
else
- put_be16(ctx->pb, 0x6000 | stream->max_buffer_size/1024);
+ avio_wb16(ctx->pb, 0x6000 | stream->max_buffer_size/1024);
}
} else {
@@ -892,38 +892,38 @@ static int flush_packet(AVFormatContext *ctx, int stream_index,
put_timestamp(ctx->pb, 0x02, pts);
}
} else {
- put_byte(ctx->pb, 0x0f);
+ avio_w8(ctx->pb, 0x0f);
}
}
if (s->is_mpeg2) {
/* special stuffing byte that is always written
to prevent accidental generation of start codes. */
- put_byte(ctx->pb, 0xff);
+ avio_w8(ctx->pb, 0xff);
for(i=0;i<stuffing_size;i++)
- put_byte(ctx->pb, 0xff);
+ avio_w8(ctx->pb, 0xff);
}
if (startcode == PRIVATE_STREAM_1) {
- put_byte(ctx->pb, id);
+ avio_w8(ctx->pb, id);
if (id >= 0xa0) {
/* LPCM (XXX: check nb_frames) */
- put_byte(ctx->pb, 7);
- put_be16(ctx->pb, 4); /* skip 3 header bytes */
- put_byte(ctx->pb, stream->lpcm_header[0]);
- put_byte(ctx->pb, stream->lpcm_header[1]);
- put_byte(ctx->pb, stream->lpcm_header[2]);
+ avio_w8(ctx->pb, 7);
+ avio_wb16(ctx->pb, 4); /* skip 3 header bytes */
+ avio_w8(ctx->pb, stream->lpcm_header[0]);
+ avio_w8(ctx->pb, stream->lpcm_header[1]);
+ avio_w8(ctx->pb, stream->lpcm_header[2]);
} else if (id >= 0x40) {
/* AC-3 */
- put_byte(ctx->pb, nb_frames);
- put_be16(ctx->pb, trailer_size+1);
+ avio_w8(ctx->pb, nb_frames);
+ avio_wb16(ctx->pb, trailer_size+1);
}
}
/* output data */
assert(payload_size - stuffing_size <= av_fifo_size(stream->fifo));
- av_fifo_generic_read(stream->fifo, ctx->pb, payload_size - stuffing_size, &put_buffer);
+ av_fifo_generic_read(stream->fifo, ctx->pb, payload_size - stuffing_size, &avio_write);
stream->bytes_to_iframe -= payload_size - stuffing_size;
}else{
payload_size=
@@ -934,7 +934,7 @@ static int flush_packet(AVFormatContext *ctx, int stream_index,
put_padding_packet(ctx,ctx->pb, pad_packet_bytes);
for(i=0;i<zero_trail_bytes;i++)
- put_byte(ctx->pb, 0x00);
+ avio_w8(ctx->pb, 0x00);
put_flush_packet(ctx->pb);
@@ -961,7 +961,7 @@ static void put_vcd_padding_sector(AVFormatContext *ctx)
int i;
for(i=0;i<s->packet_size;i++)
- put_byte(ctx->pb, 0);
+ avio_w8(ctx->pb, 0);
s->vcd_padding_bytes_written += s->packet_size;
@@ -1220,7 +1220,7 @@ static int mpeg_mux_end(AVFormatContext *ctx)
/* End header according to MPEG1 systems standard. We do not write
it as it is usually not needed by decoders and because it
complicates MPEG stream concatenation. */
- //put_be32(ctx->pb, ISO_11172_END_CODE);
+ //avio_wb32(ctx->pb, ISO_11172_END_CODE);
//put_flush_packet(ctx->pb);
for(i=0;i<ctx->nb_streams;i++) {
diff --git a/libavformat/mpegtsenc.c b/libavformat/mpegtsenc.c
index 891d469ab3..99becbcb31 100644
--- a/libavformat/mpegtsenc.c
+++ b/libavformat/mpegtsenc.c
@@ -415,7 +415,7 @@ static MpegTSService *mpegts_add_service(MpegTSWrite *ts,
static void section_write_packet(MpegTSSection *s, const uint8_t *packet)
{
AVFormatContext *ctx = s->opaque;
- put_buffer(ctx->pb, packet, TS_PACKET_SIZE);
+ avio_write(ctx->pb, packet, TS_PACKET_SIZE);
}
static int mpegts_write_header(AVFormatContext *s)
@@ -625,7 +625,7 @@ static void mpegts_insert_null_packet(AVFormatContext *s)
*q++ = 0xff;
*q++ = 0x10;
memset(q, 0x0FF, TS_PACKET_SIZE - (q - buf));
- put_buffer(s->pb, buf, TS_PACKET_SIZE);
+ avio_write(s->pb, buf, TS_PACKET_SIZE);
}
/* Write a single transport stream packet with a PCR and no payload */
@@ -650,7 +650,7 @@ static void mpegts_insert_pcr_only(AVFormatContext *s, AVStream *st)
/* stuffing bytes */
memset(q, 0xFF, TS_PACKET_SIZE - (q - buf));
- put_buffer(s->pb, buf, TS_PACKET_SIZE);
+ avio_write(s->pb, buf, TS_PACKET_SIZE);
}
static void write_pts(uint8_t *q, int fourbits, int64_t pts)
@@ -844,7 +844,7 @@ static void mpegts_write_pes(AVFormatContext *s, AVStream *st,
memcpy(buf + TS_PACKET_SIZE - len, payload, len);
payload += len;
payload_size -= len;
- put_buffer(s->pb, buf, TS_PACKET_SIZE);
+ avio_write(s->pb, buf, TS_PACKET_SIZE);
}
put_flush_packet(s->pb);
}
diff --git a/libavformat/mpjpeg.c b/libavformat/mpjpeg.c
index 76f598598b..e98fb363e7 100644
--- a/libavformat/mpjpeg.c
+++ b/libavformat/mpjpeg.c
@@ -29,7 +29,7 @@ static int mpjpeg_write_header(AVFormatContext *s)
uint8_t buf1[256];
snprintf(buf1, sizeof(buf1), "--%s\n", BOUNDARY_TAG);
- put_buffer(s->pb, buf1, strlen(buf1));
+ avio_write(s->pb, buf1, strlen(buf1));
put_flush_packet(s->pb);
return 0;
}
@@ -39,11 +39,11 @@ static int mpjpeg_write_packet(AVFormatContext *s, AVPacket *pkt)
uint8_t buf1[256];
snprintf(buf1, sizeof(buf1), "Content-type: image/jpeg\n\n");
- put_buffer(s->pb, buf1, strlen(buf1));
- put_buffer(s->pb, pkt->data, pkt->size);
+ avio_write(s->pb, buf1, strlen(buf1));
+ avio_write(s->pb, pkt->data, pkt->size);
snprintf(buf1, sizeof(buf1), "\n--%s\n", BOUNDARY_TAG);
- put_buffer(s->pb, buf1, strlen(buf1));
+ avio_write(s->pb, buf1, strlen(buf1));
put_flush_packet(s->pb);
return 0;
}
diff --git a/libavformat/mxfenc.c b/libavformat/mxfenc.c
index 9f2e4fe08d..9e63531388 100644
--- a/libavformat/mxfenc.c
+++ b/libavformat/mxfenc.c
@@ -307,24 +307,24 @@ static const MXFLocalTagPair mxf_local_tag_batch[] = {
static void mxf_write_uuid(AVIOContext *pb, enum MXFMetadataSetType type, int value)
{
- put_buffer(pb, uuid_base, 12);
- put_be16(pb, type);
- put_be16(pb, value);
+ avio_write(pb, uuid_base, 12);
+ avio_wb16(pb, type);
+ avio_wb16(pb, value);
}
static void mxf_write_umid(AVFormatContext *s, int type)
{
MXFContext *mxf = s->priv_data;
- put_buffer(s->pb, umid_ul, 13);
- put_be24(s->pb, mxf->instance_number);
- put_buffer(s->pb, mxf->umid, 15);
- put_byte(s->pb, type);
+ avio_write(s->pb, umid_ul, 13);
+ avio_wb24(s->pb, mxf->instance_number);
+ avio_write(s->pb, mxf->umid, 15);
+ avio_w8(s->pb, type);
}
static void mxf_write_refs_count(AVIOContext *pb, int ref_count)
{
- put_be32(pb, ref_count);
- put_be32(pb, 16);
+ avio_wb32(pb, ref_count);
+ avio_wb32(pb, 16);
}
static int klv_ber_length(uint64_t len)
@@ -341,25 +341,25 @@ static int klv_encode_ber_length(AVIOContext *pb, uint64_t len)
int size;
if (len < 128) {
//short form
- put_byte(pb, len);
+ avio_w8(pb, len);
return 1;
}
size = (av_log2(len) >> 3) + 1;
// long form
- put_byte(pb, 0x80 + size);
+ avio_w8(pb, 0x80 + size);
while(size) {
size--;
- put_byte(pb, len >> 8 * size & 0xff);
+ avio_w8(pb, len >> 8 * size & 0xff);
}
return 0;
}
static void klv_encode_ber4_length(AVIOContext *pb, int len)
{
- put_byte(pb, 0x80 + 3);
- put_be24(pb, len);
+ avio_w8(pb, 0x80 + 3);
+ avio_wb24(pb, len);
}
/*
@@ -381,28 +381,28 @@ static void mxf_write_primer_pack(AVFormatContext *s)
local_tag_number = FF_ARRAY_ELEMS(mxf_local_tag_batch);
- put_buffer(pb, primer_pack_key, 16);
+ avio_write(pb, primer_pack_key, 16);
klv_encode_ber_length(pb, local_tag_number * 18 + 8);
- put_be32(pb, local_tag_number); // local_tag num
- put_be32(pb, 18); // item size, always 18 according to the specs
+ avio_wb32(pb, local_tag_number); // local_tag num
+ avio_wb32(pb, 18); // item size, always 18 according to the specs
for (i = 0; i < local_tag_number; i++) {
- put_be16(pb, mxf_local_tag_batch[i].local_tag);
- put_buffer(pb, mxf_local_tag_batch[i].uid, 16);
+ avio_wb16(pb, mxf_local_tag_batch[i].local_tag);
+ avio_write(pb, mxf_local_tag_batch[i].uid, 16);
}
}
static void mxf_write_local_tag(AVIOContext *pb, int size, int tag)
{
- put_be16(pb, tag);
- put_be16(pb, size);
+ avio_wb16(pb, tag);
+ avio_wb16(pb, size);
}
static void mxf_write_metadata_key(AVIOContext *pb, unsigned int value)
{
- put_buffer(pb, header_metadata_key, 13);
- put_be24(pb, value);
+ avio_write(pb, header_metadata_key, 13);
+ avio_wb24(pb, value);
}
static void mxf_free(AVFormatContext *s)
@@ -436,7 +436,7 @@ static void mxf_write_essence_container_refs(AVFormatContext *s)
av_log(s,AV_LOG_DEBUG, "essence container count:%d\n", c->essence_container_count);
for (i = 0; i < c->essence_container_count; i++) {
MXFStreamContext *sc = s->streams[i]->priv_data;
- put_buffer(pb, mxf_essence_container_uls[sc->index].container_ul, 16);
+ avio_write(pb, mxf_essence_container_uls[sc->index].container_ul, 16);
}
}
@@ -456,11 +456,11 @@ static void mxf_write_preface(AVFormatContext *s)
// last modified date
mxf_write_local_tag(pb, 8, 0x3B02);
- put_be64(pb, mxf->timestamp);
+ avio_wb64(pb, mxf->timestamp);
// write version
mxf_write_local_tag(pb, 2, 0x3B05);
- put_be16(pb, 258); // v1.2
+ avio_wb16(pb, 258); // v1.2
// write identification_refs
mxf_write_local_tag(pb, 16 + 8, 0x3B06);
@@ -473,7 +473,7 @@ static void mxf_write_preface(AVFormatContext *s)
// operational pattern
mxf_write_local_tag(pb, 16, 0x3B09);
- put_buffer(pb, op1a_ul, 16);
+ avio_write(pb, op1a_ul, 16);
// write essence_container_refs
mxf_write_local_tag(pb, 8 + 16 * mxf->essence_container_count, 0x3B0A);
@@ -481,7 +481,7 @@ static void mxf_write_preface(AVFormatContext *s)
// write dm_scheme_refs
mxf_write_local_tag(pb, 8, 0x3B0B);
- put_be64(pb, 0);
+ avio_wb64(pb, 0);
}
/*
@@ -492,7 +492,7 @@ static void mxf_write_local_tag_utf16(AVIOContext *pb, int tag, const char *valu
int i, size = strlen(value);
mxf_write_local_tag(pb, size*2, tag);
for (i = 0; i < size; i++)
- put_be16(pb, value[i]);
+ avio_wb16(pb, value[i]);
}
static void mxf_write_identification(AVFormatContext *s)
@@ -531,7 +531,7 @@ static void mxf_write_identification(AVFormatContext *s)
// modification date
mxf_write_local_tag(pb, 8, 0x3C06);
- put_be64(pb, mxf->timestamp);
+ avio_wb64(pb, mxf->timestamp);
}
static void mxf_write_content_storage(AVFormatContext *s)
@@ -576,22 +576,22 @@ static void mxf_write_track(AVFormatContext *s, AVStream *st, enum MXFMetadataSe
// write track id
mxf_write_local_tag(pb, 4, 0x4801);
- put_be32(pb, st->index+2);
+ avio_wb32(pb, st->index+2);
// write track number
mxf_write_local_tag(pb, 4, 0x4804);
if (type == MaterialPackage)
- put_be32(pb, 0); // track number of material package is 0
+ avio_wb32(pb, 0); // track number of material package is 0
else
- put_buffer(pb, sc->track_essence_element_key + 12, 4);
+ avio_write(pb, sc->track_essence_element_key + 12, 4);
mxf_write_local_tag(pb, 8, 0x4B01);
- put_be32(pb, mxf->time_base.den);
- put_be32(pb, mxf->time_base.num);
+ avio_wb32(pb, mxf->time_base.den);
+ avio_wb32(pb, mxf->time_base.num);
// write origin
mxf_write_local_tag(pb, 8, 0x4B02);
- put_be64(pb, 0);
+ avio_wb64(pb, 0);
// write sequence refs
mxf_write_local_tag(pb, 16, 0x4803);
@@ -608,15 +608,15 @@ static void mxf_write_common_fields(AVFormatContext *s, AVStream *st)
// find data define uls
mxf_write_local_tag(pb, 16, 0x0201);
if (st == mxf->timecode_track)
- put_buffer(pb, smpte_12m_timecode_track_data_ul, 16);
+ avio_write(pb, smpte_12m_timecode_track_data_ul, 16);
else {
const MXFCodecUL *data_def_ul = mxf_get_data_definition_ul(st->codec->codec_type);
- put_buffer(pb, data_def_ul->uid, 16);
+ avio_write(pb, data_def_ul->uid, 16);
}
// write duration
mxf_write_local_tag(pb, 8, 0x0202);
- put_be64(pb, mxf->duration);
+ avio_wb64(pb, mxf->duration);
}
static void mxf_write_sequence(AVFormatContext *s, AVStream *st, enum MXFMetadataSetType type)
@@ -664,15 +664,15 @@ static void mxf_write_timecode_component(AVFormatContext *s, AVStream *st, enum
// Start Time Code
mxf_write_local_tag(pb, 8, 0x1501);
- put_be64(pb, mxf->timecode_start);
+ avio_wb64(pb, mxf->timecode_start);
// Rounded Time Code Base
mxf_write_local_tag(pb, 2, 0x1502);
- put_be16(pb, mxf->timecode_base);
+ avio_wb16(pb, mxf->timecode_base);
// Drop Frame
mxf_write_local_tag(pb, 1, 0x1503);
- put_byte(pb, mxf->timecode_drop_frame);
+ avio_w8(pb, mxf->timecode_drop_frame);
}
static void mxf_write_structural_component(AVFormatContext *s, AVStream *st, enum MXFMetadataSetType type)
@@ -693,22 +693,22 @@ static void mxf_write_structural_component(AVFormatContext *s, AVStream *st, enu
// write start_position
mxf_write_local_tag(pb, 8, 0x1201);
- put_be64(pb, 0);
+ avio_wb64(pb, 0);
// write source package uid, end of the reference
mxf_write_local_tag(pb, 32, 0x1101);
if (type == SourcePackage) {
for (i = 0; i < 4; i++)
- put_be64(pb, 0);
+ avio_wb64(pb, 0);
} else
mxf_write_umid(s, 1);
// write source track id
mxf_write_local_tag(pb, 4, 0x1102);
if (type == SourcePackage)
- put_be32(pb, 0);
+ avio_wb32(pb, 0);
else
- put_be32(pb, st->index+2);
+ avio_wb32(pb, st->index+2);
}
static void mxf_write_multi_descriptor(AVFormatContext *s)
@@ -728,8 +728,8 @@ static void mxf_write_multi_descriptor(AVFormatContext *s)
// write sample rate
mxf_write_local_tag(pb, 8, 0x3001);
- put_be32(pb, mxf->time_base.den);
- put_be32(pb, mxf->time_base.num);
+ avio_wb32(pb, mxf->time_base.den);
+ avio_wb32(pb, mxf->time_base.num);
// write essence container ul
mxf_write_local_tag(pb, 16, 0x3004);
@@ -739,7 +739,7 @@ static void mxf_write_multi_descriptor(AVFormatContext *s)
MXFStreamContext *sc = s->streams[0]->priv_data;
ul = mxf_essence_container_uls[sc->index].container_ul;
}
- put_buffer(pb, ul, 16);
+ avio_write(pb, ul, 16);
// write sub descriptor refs
mxf_write_local_tag(pb, s->nb_streams * 16 + 8, 0x3F01);
@@ -754,21 +754,21 @@ static void mxf_write_generic_desc(AVFormatContext *s, AVStream *st, const UID k
MXFStreamContext *sc = st->priv_data;
AVIOContext *pb = s->pb;
- put_buffer(pb, key, 16);
+ avio_write(pb, key, 16);
klv_encode_ber4_length(pb, size+20+8+12+20);
mxf_write_local_tag(pb, 16, 0x3C0A);
mxf_write_uuid(pb, SubDescriptor, st->index);
mxf_write_local_tag(pb, 4, 0x3006);
- put_be32(pb, st->index+2);
+ avio_wb32(pb, st->index+2);
mxf_write_local_tag(pb, 8, 0x3001);
- put_be32(pb, mxf->time_base.den);
- put_be32(pb, mxf->time_base.num);
+ avio_wb32(pb, mxf->time_base.den);
+ avio_wb32(pb, mxf->time_base.num);
mxf_write_local_tag(pb, 16, 0x3004);
- put_buffer(pb, mxf_essence_container_uls[sc->index].container_ul, 16);
+ avio_write(pb, mxf_essence_container_uls[sc->index].container_ul, 16);
}
static const UID mxf_mpegvideo_descriptor_key = { 0x06,0x0E,0x2B,0x34,0x02,0x53,0x01,0x01,0x0d,0x01,0x01,0x01,0x01,0x01,0x51,0x00 };
@@ -788,13 +788,13 @@ static void mxf_write_cdci_common(AVFormatContext *s, AVStream *st, const UID ke
mxf_write_generic_desc(s, st, key, size+8+8+8+8+8+8+5+16+sc->interlaced*4+12+20);
mxf_write_local_tag(pb, 4, 0x3203);
- put_be32(pb, st->codec->width);
+ avio_wb32(pb, st->codec->width);
mxf_write_local_tag(pb, 4, 0x3202);
- put_be32(pb, stored_height>>sc->interlaced);
+ avio_wb32(pb, stored_height>>sc->interlaced);
mxf_write_local_tag(pb, 4, 0x3209);
- put_be32(pb, st->codec->width);
+ avio_wb32(pb, st->codec->width);
if (st->codec->height == 608) // PAL + VBI
display_height = 576;
@@ -804,19 +804,19 @@ static void mxf_write_cdci_common(AVFormatContext *s, AVStream *st, const UID ke
display_height = st->codec->height;
mxf_write_local_tag(pb, 4, 0x3208);
- put_be32(pb, display_height>>sc->interlaced);
+ avio_wb32(pb, display_height>>sc->interlaced);
// component depth
mxf_write_local_tag(pb, 4, 0x3301);
- put_be32(pb, 8);
+ avio_wb32(pb, 8);
// horizontal subsampling
mxf_write_local_tag(pb, 4, 0x3302);
- put_be32(pb, 2);
+ avio_wb32(pb, 2);
// frame layout
mxf_write_local_tag(pb, 1, 0x320C);
- put_byte(pb, sc->interlaced);
+ avio_w8(pb, sc->interlaced);
// video line map
switch (st->codec->height) {
@@ -835,18 +835,18 @@ static void mxf_write_cdci_common(AVFormatContext *s, AVStream *st, const UID ke
}
mxf_write_local_tag(pb, 12+sc->interlaced*4, 0x320D);
- put_be32(pb, sc->interlaced ? 2 : 1);
- put_be32(pb, 4);
- put_be32(pb, f1);
+ avio_wb32(pb, sc->interlaced ? 2 : 1);
+ avio_wb32(pb, 4);
+ avio_wb32(pb, f1);
if (sc->interlaced)
- put_be32(pb, f2);
+ avio_wb32(pb, f2);
mxf_write_local_tag(pb, 8, 0x320E);
- put_be32(pb, sc->aspect_ratio.num);
- put_be32(pb, sc->aspect_ratio.den);
+ avio_wb32(pb, sc->aspect_ratio.num);
+ avio_wb32(pb, sc->aspect_ratio.den);
mxf_write_local_tag(pb, 16, 0x3201);
- put_buffer(pb, *sc->codec_ul, 16);
+ avio_write(pb, *sc->codec_ul, 16);
}
static void mxf_write_cdci_desc(AVFormatContext *s, AVStream *st)
@@ -863,13 +863,13 @@ static void mxf_write_mpegvideo_desc(AVFormatContext *s, AVStream *st)
// bit rate
mxf_write_local_tag(pb, 4, 0x8000);
- put_be32(pb, st->codec->bit_rate);
+ avio_wb32(pb, st->codec->bit_rate);
// profile and level
mxf_write_local_tag(pb, 1, 0x8007);
if (!st->codec->profile)
profile_and_level |= 0x80; // escape bit
- put_byte(pb, profile_and_level);
+ avio_w8(pb, profile_and_level);
}
static void mxf_write_generic_sound_common(AVFormatContext *s, AVStream *st, const UID key, unsigned size)
@@ -880,18 +880,18 @@ static void mxf_write_generic_sound_common(AVFormatContext *s, AVStream *st, con
// audio locked
mxf_write_local_tag(pb, 1, 0x3D02);
- put_byte(pb, 1);
+ avio_w8(pb, 1);
// write audio sampling rate
mxf_write_local_tag(pb, 8, 0x3D03);
- put_be32(pb, st->codec->sample_rate);
- put_be32(pb, 1);
+ avio_wb32(pb, st->codec->sample_rate);
+ avio_wb32(pb, 1);
mxf_write_local_tag(pb, 4, 0x3D07);
- put_be32(pb, st->codec->channels);
+ avio_wb32(pb, st->codec->channels);
mxf_write_local_tag(pb, 4, 0x3D01);
- put_be32(pb, av_get_bits_per_sample(st->codec->codec_id));
+ avio_wb32(pb, av_get_bits_per_sample(st->codec->codec_id));
}
static void mxf_write_wav_common(AVFormatContext *s, AVStream *st, const UID key, unsigned size)
@@ -901,11 +901,11 @@ static void mxf_write_wav_common(AVFormatContext *s, AVStream *st, const UID key
mxf_write_generic_sound_common(s, st, key, size+6+8);
mxf_write_local_tag(pb, 2, 0x3D0A);
- put_be16(pb, st->codec->block_align);
+ avio_wb16(pb, st->codec->block_align);
// avg bytes per sec
mxf_write_local_tag(pb, 4, 0x3D09);
- put_be32(pb, st->codec->block_align*st->codec->sample_rate);
+ avio_wb32(pb, st->codec->block_align*st->codec->sample_rate);
}
static void mxf_write_wav_desc(AVFormatContext *s, AVStream *st)
@@ -952,11 +952,11 @@ static void mxf_write_package(AVFormatContext *s, enum MXFMetadataSetType type)
// package creation date
mxf_write_local_tag(pb, 8, 0x4405);
- put_be64(pb, mxf->timestamp);
+ avio_wb64(pb, mxf->timestamp);
// package modified date
mxf_write_local_tag(pb, 8, 0x4404);
- put_be64(pb, mxf->timestamp);
+ avio_wb64(pb, mxf->timestamp);
// write track refs
mxf_write_local_tag(pb, track_count*16 + 8, 0x4403);
@@ -1008,10 +1008,10 @@ static int mxf_write_essence_container_data(AVFormatContext *s)
mxf_write_umid(s, 1);
mxf_write_local_tag(pb, 4, 0x3F07); // BodySID
- put_be32(pb, 1);
+ avio_wb32(pb, 1);
mxf_write_local_tag(pb, 4, 0x3F06); // IndexSID
- put_be32(pb, 2);
+ avio_wb32(pb, 2);
return 0;
}
@@ -1048,7 +1048,7 @@ static void mxf_write_index_table_segment(AVFormatContext *s)
if (!mxf->edit_units_count && !mxf->edit_unit_byte_count)
return;
- put_buffer(pb, index_table_segment_key, 16);
+ avio_write(pb, index_table_segment_key, 16);
if (mxf->edit_unit_byte_count) {
klv_encode_ber_length(pb, 80);
@@ -1063,65 +1063,65 @@ static void mxf_write_index_table_segment(AVFormatContext *s)
// index edit rate
mxf_write_local_tag(pb, 8, 0x3F0B);
- put_be32(pb, mxf->time_base.den);
- put_be32(pb, mxf->time_base.num);
+ avio_wb32(pb, mxf->time_base.den);
+ avio_wb32(pb, mxf->time_base.num);
// index start position
mxf_write_local_tag(pb, 8, 0x3F0C);
- put_be64(pb, mxf->last_indexed_edit_unit);
+ avio_wb64(pb, mxf->last_indexed_edit_unit);
// index duration
mxf_write_local_tag(pb, 8, 0x3F0D);
if (mxf->edit_unit_byte_count)
- put_be64(pb, 0); // index table covers whole container
+ avio_wb64(pb, 0); // index table covers whole container
else
- put_be64(pb, mxf->edit_units_count);
+ avio_wb64(pb, mxf->edit_units_count);
// edit unit byte count
mxf_write_local_tag(pb, 4, 0x3F05);
- put_be32(pb, mxf->edit_unit_byte_count);
+ avio_wb32(pb, mxf->edit_unit_byte_count);
// index sid
mxf_write_local_tag(pb, 4, 0x3F06);
- put_be32(pb, 2);
+ avio_wb32(pb, 2);
// body sid
mxf_write_local_tag(pb, 4, 0x3F07);
- put_be32(pb, 1);
+ avio_wb32(pb, 1);
if (!mxf->edit_unit_byte_count) {
// real slice count - 1
mxf_write_local_tag(pb, 1, 0x3F08);
- put_byte(pb, mxf->slice_count);
+ avio_w8(pb, mxf->slice_count);
// delta entry array
mxf_write_local_tag(pb, 8 + (s->nb_streams+1)*6, 0x3F09);
- put_be32(pb, s->nb_streams+1); // num of entries
- put_be32(pb, 6); // size of one entry
+ avio_wb32(pb, s->nb_streams+1); // num of entries
+ avio_wb32(pb, 6); // size of one entry
// write system item delta entry
- put_byte(pb, 0);
- put_byte(pb, 0); // slice entry
- put_be32(pb, 0); // element delta
+ avio_w8(pb, 0);
+ avio_w8(pb, 0); // slice entry
+ avio_wb32(pb, 0); // element delta
for (i = 0; i < s->nb_streams; i++) {
AVStream *st = s->streams[i];
MXFStreamContext *sc = st->priv_data;
- put_byte(pb, sc->temporal_reordering);
+ avio_w8(pb, sc->temporal_reordering);
if (sc->temporal_reordering)
temporal_reordering = 1;
if (i == 0) { // video track
- put_byte(pb, 0); // slice number
- put_be32(pb, KAG_SIZE); // system item size including klv fill
+ avio_w8(pb, 0); // slice number
+ avio_wb32(pb, KAG_SIZE); // system item size including klv fill
} else { // audio track
unsigned audio_frame_size = sc->aic.samples[0]*sc->aic.sample_size;
audio_frame_size += klv_fill_size(audio_frame_size);
- put_byte(pb, 1);
- put_be32(pb, (i-1)*audio_frame_size); // element delta
+ avio_w8(pb, 1);
+ avio_wb32(pb, (i-1)*audio_frame_size); // element delta
}
}
mxf_write_local_tag(pb, 8 + mxf->edit_units_count*(11+mxf->slice_count*4), 0x3F0A);
- put_be32(pb, mxf->edit_units_count); // num of entries
- put_be32(pb, 11+mxf->slice_count*4); // size of one entry
+ avio_wb32(pb, mxf->edit_units_count); // num of entries
+ avio_wb32(pb, 11+mxf->slice_count*4); // size of one entry
for (i = 0; i < mxf->edit_units_count; i++) {
int temporal_offset = 0;
@@ -1143,12 +1143,12 @@ static void mxf_write_index_table_segment(AVFormatContext *s)
temporal_offset = j - key_index - pic_num_in_gop;
}
}
- put_byte(pb, temporal_offset);
+ avio_w8(pb, temporal_offset);
if ((mxf->index_entries[i].flags & 0x30) == 0x30) { // back and forward prediction
- put_byte(pb, mxf->last_key_index - i);
+ avio_w8(pb, mxf->last_key_index - i);
} else {
- put_byte(pb, key_index - i); // key frame offset
+ avio_w8(pb, key_index - i); // key frame offset
if ((mxf->index_entries[i].flags & 0x20) == 0x20) // only forward
mxf->last_key_index = key_index;
}
@@ -1156,11 +1156,11 @@ static void mxf_write_index_table_segment(AVFormatContext *s)
if (!(mxf->index_entries[i].flags & 0x33) && // I frame
mxf->index_entries[i].flags & 0x40 && !temporal_offset)
mxf->index_entries[i].flags |= 0x80; // random access
- put_byte(pb, mxf->index_entries[i].flags);
+ avio_w8(pb, mxf->index_entries[i].flags);
// stream offset
- put_be64(pb, mxf->index_entries[i].offset);
+ avio_wb64(pb, mxf->index_entries[i].offset);
if (s->nb_streams > 1)
- put_be32(pb, mxf->index_entries[i].slice_offset);
+ avio_wb32(pb, mxf->index_entries[i].slice_offset);
}
mxf->last_key_index = key_index - mxf->edit_units_count;
@@ -1173,11 +1173,11 @@ static void mxf_write_klv_fill(AVFormatContext *s)
{
unsigned pad = klv_fill_size(url_ftell(s->pb));
if (pad) {
- put_buffer(s->pb, klv_fill_key, 16);
+ avio_write(s->pb, klv_fill_key, 16);
pad -= 16 + 4;
klv_encode_ber4_length(s->pb, pad);
for (; pad; pad--)
- put_byte(s->pb, 0);
+ avio_w8(s->pb, 0);
assert(!(url_ftell(s->pb) & (KAG_SIZE-1)));
}
}
@@ -1213,43 +1213,43 @@ static void mxf_write_partition(AVFormatContext *s, int bodysid,
}
// write klv
- put_buffer(pb, key, 16);
+ avio_write(pb, key, 16);
klv_encode_ber_length(pb, 88 + 16 * mxf->essence_container_count);
// write partition value
- put_be16(pb, 1); // majorVersion
- put_be16(pb, 2); // minorVersion
- put_be32(pb, KAG_SIZE); // KAGSize
+ avio_wb16(pb, 1); // majorVersion
+ avio_wb16(pb, 2); // minorVersion
+ avio_wb32(pb, KAG_SIZE); // KAGSize
- put_be64(pb, partition_offset); // ThisPartition
+ avio_wb64(pb, partition_offset); // ThisPartition
if (!memcmp(key, body_partition_key, 16) && mxf->body_partitions_count > 1)
- put_be64(pb, mxf->body_partition_offset[mxf->body_partitions_count-2]); // PreviousPartition
+ avio_wb64(pb, mxf->body_partition_offset[mxf->body_partitions_count-2]); // PreviousPartition
else if (!memcmp(key, footer_partition_key, 16) && mxf->body_partitions_count)
- put_be64(pb, mxf->body_partition_offset[mxf->body_partitions_count-1]); // PreviousPartition
+ avio_wb64(pb, mxf->body_partition_offset[mxf->body_partitions_count-1]); // PreviousPartition
else
- put_be64(pb, 0);
+ avio_wb64(pb, 0);
- put_be64(pb, mxf->footer_partition_offset); // footerPartition
+ avio_wb64(pb, mxf->footer_partition_offset); // footerPartition
// set offset
header_byte_count_offset = url_ftell(pb);
- put_be64(pb, 0); // headerByteCount, update later
+ avio_wb64(pb, 0); // headerByteCount, update later
// indexTable
- put_be64(pb, index_byte_count); // indexByteCount
- put_be32(pb, index_byte_count ? indexsid : 0); // indexSID
+ avio_wb64(pb, index_byte_count); // indexByteCount
+ avio_wb32(pb, index_byte_count ? indexsid : 0); // indexSID
// BodyOffset
if (bodysid && mxf->edit_units_count && mxf->body_partitions_count) {
- put_be64(pb, mxf->body_offset);
+ avio_wb64(pb, mxf->body_offset);
} else
- put_be64(pb, 0);
+ avio_wb64(pb, 0);
- put_be32(pb, bodysid); // bodySID
+ avio_wb32(pb, bodysid); // bodySID
// operational pattern
- put_buffer(pb, op1a_ul, 16);
+ avio_write(pb, op1a_ul, 16);
// essence container
mxf_write_essence_container_refs(s);
@@ -1268,7 +1268,7 @@ static void mxf_write_partition(AVFormatContext *s, int bodysid,
// update header_byte_count
url_fseek(pb, header_byte_count_offset, SEEK_SET);
- put_be64(pb, header_byte_count);
+ avio_wb64(pb, header_byte_count);
url_fseek(pb, pos, SEEK_SET);
}
@@ -1564,34 +1564,34 @@ static void mxf_write_system_item(AVFormatContext *s)
frame = mxf->timecode_start + mxf->last_indexed_edit_unit + mxf->edit_units_count;
// write system metadata pack
- put_buffer(pb, system_metadata_pack_key, 16);
+ avio_write(pb, system_metadata_pack_key, 16);
klv_encode_ber4_length(pb, 57);
- put_byte(pb, 0x5c); // UL, user date/time stamp, picture and sound item present
- put_byte(pb, 0x04); // content package rate
- put_byte(pb, 0x00); // content package type
- put_be16(pb, 0x00); // channel handle
- put_be16(pb, frame); // continuity count
+ avio_w8(pb, 0x5c); // UL, user date/time stamp, picture and sound item present
+ avio_w8(pb, 0x04); // content package rate
+ avio_w8(pb, 0x00); // content package type
+ avio_wb16(pb, 0x00); // channel handle
+ avio_wb16(pb, frame); // continuity count
if (mxf->essence_container_count > 1)
- put_buffer(pb, multiple_desc_ul, 16);
+ avio_write(pb, multiple_desc_ul, 16);
else {
MXFStreamContext *sc = s->streams[0]->priv_data;
- put_buffer(pb, mxf_essence_container_uls[sc->index].container_ul, 16);
+ avio_write(pb, mxf_essence_container_uls[sc->index].container_ul, 16);
}
- put_byte(pb, 0);
- put_be64(pb, 0);
- put_be64(pb, 0); // creation date/time stamp
+ avio_w8(pb, 0);
+ avio_wb64(pb, 0);
+ avio_wb64(pb, 0); // creation date/time stamp
- put_byte(pb, 0x81); // SMPTE 12M time code
+ avio_w8(pb, 0x81); // SMPTE 12M time code
time_code = ff_framenum_to_12m_time_code(frame, mxf->timecode_drop_frame, mxf->timecode_base);
- put_be32(pb, time_code);
- put_be32(pb, 0); // binary group data
- put_be64(pb, 0);
+ avio_wb32(pb, time_code);
+ avio_wb32(pb, 0); // binary group data
+ avio_wb64(pb, 0);
// write system metadata package set
- put_buffer(pb, system_metadata_package_set_key, 16);
+ avio_write(pb, system_metadata_package_set_key, 16);
klv_encode_ber4_length(pb, 35);
- put_byte(pb, 0x83); // UMID
- put_be16(pb, 0x20);
+ avio_w8(pb, 0x83); // UMID
+ avio_wb16(pb, 0x20);
mxf_write_umid(s, 1);
}
@@ -1607,21 +1607,21 @@ static void mxf_write_d10_video_packet(AVFormatContext *s, AVStream *st, AVPacke
packet_size += klv_fill_size(packet_size);
klv_encode_ber4_length(pb, pkt->size);
- put_buffer(pb, pkt->data, pkt->size);
+ avio_write(pb, pkt->data, pkt->size);
// ensure CBR muxing by padding to correct video frame size
pad = packet_size - pkt->size - 16 - 4;
if (pad > 20) {
- put_buffer(s->pb, klv_fill_key, 16);
+ avio_write(s->pb, klv_fill_key, 16);
pad -= 16 + 4;
klv_encode_ber4_length(s->pb, pad);
for (; pad; pad--)
- put_byte(s->pb, 0);
+ avio_w8(s->pb, 0);
assert(!(url_ftell(s->pb) & (KAG_SIZE-1)));
} else {
av_log(s, AV_LOG_WARNING, "cannot fill d-10 video packet\n");
for (; pad > 0; pad--)
- put_byte(s->pb, 0);
+ avio_w8(s->pb, 0);
}
}
@@ -1636,9 +1636,9 @@ static void mxf_write_d10_audio_packet(AVFormatContext *s, AVStream *st, AVPacke
klv_encode_ber4_length(pb, 4 + frame_size*4*8);
- put_byte(pb, (frame_size == 1920 ? 0 : (mxf->edit_units_count-1) % 5 + 1));
- put_le16(pb, frame_size);
- put_byte(pb, (1<<st->codec->channels)-1);
+ avio_w8(pb, (frame_size == 1920 ? 0 : (mxf->edit_units_count-1) % 5 + 1));
+ avio_wl16(pb, frame_size);
+ avio_w8(pb, (1<<st->codec->channels)-1);
while (samples < end) {
for (i = 0; i < st->codec->channels; i++) {
@@ -1650,10 +1650,10 @@ static void mxf_write_d10_audio_packet(AVFormatContext *s, AVStream *st, AVPacke
sample = AV_RL16(samples)<<12;
samples += 2;
}
- put_le32(pb, sample | i);
+ avio_wl32(pb, sample | i);
}
for (; i < 8; i++)
- put_le32(pb, i);
+ avio_wl32(pb, i);
}
}
@@ -1719,7 +1719,7 @@ static int mxf_write_packet(AVFormatContext *s, AVPacket *pkt)
}
mxf_write_klv_fill(s);
- put_buffer(pb, sc->track_essence_element_key, 16); // write key
+ avio_write(pb, sc->track_essence_element_key, 16); // write key
if (s->oformat == &ff_mxf_d10_muxer) {
if (st->codec->codec_type == AVMEDIA_TYPE_VIDEO)
mxf_write_d10_video_packet(s, st, pkt);
@@ -1727,7 +1727,7 @@ static int mxf_write_packet(AVFormatContext *s, AVPacket *pkt)
mxf_write_d10_audio_packet(s, st, pkt);
} else {
klv_encode_ber4_length(pb, pkt->size); // write length
- put_buffer(pb, pkt->data, pkt->size);
+ avio_write(pb, pkt->data, pkt->size);
mxf->body_offset += 16+4+pkt->size + klv_fill_size(16+4+pkt->size);
}
@@ -1743,24 +1743,24 @@ static void mxf_write_random_index_pack(AVFormatContext *s)
uint64_t pos = url_ftell(pb);
int i;
- put_buffer(pb, random_index_pack_key, 16);
+ avio_write(pb, random_index_pack_key, 16);
klv_encode_ber_length(pb, 28 + 12*mxf->body_partitions_count);
if (mxf->edit_unit_byte_count)
- put_be32(pb, 1); // BodySID of header partition
+ avio_wb32(pb, 1); // BodySID of header partition
else
- put_be32(pb, 0);
- put_be64(pb, 0); // offset of header partition
+ avio_wb32(pb, 0);
+ avio_wb64(pb, 0); // offset of header partition
for (i = 0; i < mxf->body_partitions_count; i++) {
- put_be32(pb, 1); // BodySID
- put_be64(pb, mxf->body_partition_offset[i]);
+ avio_wb32(pb, 1); // BodySID
+ avio_wb64(pb, mxf->body_partition_offset[i]);
}
- put_be32(pb, 0); // BodySID of footer partition
- put_be64(pb, mxf->footer_partition_offset);
+ avio_wb32(pb, 0); // BodySID of footer partition
+ avio_wb64(pb, mxf->footer_partition_offset);
- put_be32(pb, url_ftell(pb) - pos + 4);
+ avio_wb32(pb, url_ftell(pb) - pos + 4);
}
static int mxf_write_footer(AVFormatContext *s)
diff --git a/libavformat/nutenc.c b/libavformat/nutenc.c
index ce7d6522a9..078ffac0ba 100644
--- a/libavformat/nutenc.c
+++ b/libavformat/nutenc.c
@@ -254,7 +254,7 @@ static void put_str(AVIOContext *bc, const char *string){
int len= strlen(string);
ff_put_v(bc, len);
- put_buffer(bc, string, len);
+ avio_write(bc, string, len);
}
static void put_s(AVIOContext *bc, int64_t val){
@@ -285,16 +285,16 @@ static void put_packet(NUTContext *nut, AVIOContext *bc, AVIOContext *dyn_bc, in
if(forw_ptr > 4096)
init_checksum(bc, ff_crc04C11DB7_update, 0);
- put_be64(bc, startcode);
+ avio_wb64(bc, startcode);
ff_put_v(bc, forw_ptr);
if(forw_ptr > 4096)
- put_le32(bc, get_checksum(bc));
+ avio_wl32(bc, get_checksum(bc));
if(calculate_checksum)
init_checksum(bc, ff_crc04C11DB7_update, 0);
- put_buffer(bc, dyn_buf, dyn_size);
+ avio_write(bc, dyn_buf, dyn_size);
if(calculate_checksum)
- put_le32(bc, get_checksum(bc));
+ avio_wl32(bc, get_checksum(bc));
av_free(dyn_buf);
}
@@ -366,7 +366,7 @@ static void write_mainheader(NUTContext *nut, AVIOContext *bc){
ff_put_v(bc, nut->header_count-1);
for(i=1; i<nut->header_count; i++){
ff_put_v(bc, nut->header_len[i]);
- put_buffer(bc, nut->header[i], nut->header_len[i]);
+ avio_write(bc, nut->header[i], nut->header_len[i]);
}
}
@@ -382,7 +382,7 @@ static int write_streamheader(AVFormatContext *avctx, AVIOContext *bc, AVStream
}
ff_put_v(bc, 4);
if (codec->codec_tag){
- put_le32(bc, codec->codec_tag);
+ avio_wl32(bc, codec->codec_tag);
} else {
av_log(avctx, AV_LOG_ERROR, "No codec tag defined for stream %d\n", i);
return AVERROR(EINVAL);
@@ -392,10 +392,10 @@ static int write_streamheader(AVFormatContext *avctx, AVIOContext *bc, AVStream
ff_put_v(bc, nut->stream[i].msb_pts_shift);
ff_put_v(bc, nut->stream[i].max_pts_distance);
ff_put_v(bc, codec->has_b_frames);
- put_byte(bc, 0); /* flags: 0x1 - fixed_fps, 0x2 - index_present */
+ avio_w8(bc, 0); /* flags: 0x1 - fixed_fps, 0x2 - index_present */
ff_put_v(bc, codec->extradata_size);
- put_buffer(bc, codec->extradata, codec->extradata_size);
+ avio_write(bc, codec->extradata, codec->extradata_size);
switch(codec->codec_type){
case AVMEDIA_TYPE_AUDIO:
@@ -450,7 +450,7 @@ static int write_globalinfo(NUTContext *nut, AVIOContext *bc){
ff_put_v(bc, count);
dyn_size= url_close_dyn_buf(dyn_bc, &dyn_buf);
- put_buffer(bc, dyn_buf, dyn_size);
+ avio_write(bc, dyn_buf, dyn_size);
av_free(dyn_buf);
return 0;
}
@@ -479,7 +479,7 @@ static int write_streaminfo(NUTContext *nut, AVIOContext *bc, int stream_id){
ff_put_v(bc, count);
- put_buffer(bc, dyn_buf, dyn_size);
+ avio_write(bc, dyn_buf, dyn_size);
}
av_free(dyn_buf);
@@ -575,8 +575,8 @@ static int write_header(AVFormatContext *s){
build_frame_code(s);
assert(nut->frame_code['N'].flags == FLAG_INVALID);
- put_buffer(bc, ID_STRING, strlen(ID_STRING));
- put_byte(bc, 0);
+ avio_write(bc, ID_STRING, strlen(ID_STRING));
+ avio_w8(bc, 0);
if ((ret = write_headers(s, bc)) < 0)
return ret;
@@ -749,7 +749,7 @@ static int write_packet(AVFormatContext *s, AVPacket *pkt){
header_idx= fc->header_idx;
init_checksum(bc, ff_crc04C11DB7_update, 0);
- put_byte(bc, frame_code);
+ avio_w8(bc, frame_code);
if(flags & FLAG_CODED){
ff_put_v(bc, (flags^needed_flags) & ~(FLAG_CODED));
flags = needed_flags;
@@ -759,10 +759,10 @@ static int write_packet(AVFormatContext *s, AVPacket *pkt){
if(flags & FLAG_SIZE_MSB) ff_put_v(bc, pkt->size / fc->size_mul);
if(flags & FLAG_HEADER_IDX) ff_put_v(bc, header_idx= best_header_idx);
- if(flags & FLAG_CHECKSUM) put_le32(bc, get_checksum(bc));
+ if(flags & FLAG_CHECKSUM) avio_wl32(bc, get_checksum(bc));
else get_checksum(bc);
- put_buffer(bc, pkt->data + nut->header_len[header_idx], pkt->size - nut->header_len[header_idx]);
+ avio_write(bc, pkt->data + nut->header_len[header_idx], pkt->size - nut->header_len[header_idx]);
nus->last_flags= flags;
nus->last_pts= pkt->pts;
diff --git a/libavformat/oggenc.c b/libavformat/oggenc.c
index 79e4a8aa90..533f89e7b8 100644
--- a/libavformat/oggenc.c
+++ b/libavformat/oggenc.c
@@ -69,7 +69,7 @@ static void ogg_update_checksum(AVFormatContext *s, AVIOContext *pb, int64_t crc
int64_t pos = url_ftell(pb);
uint32_t checksum = get_checksum(pb);
url_fseek(pb, crc_offset, SEEK_SET);
- put_be32(pb, checksum);
+ avio_wb32(pb, checksum);
url_fseek(pb, pos, SEEK_SET);
}
@@ -86,16 +86,16 @@ static int ogg_write_page(AVFormatContext *s, OGGPage *page, int extra_flags)
return ret;
init_checksum(pb, ff_crc04C11DB7_update, 0);
put_tag(pb, "OggS");
- put_byte(pb, 0);
- put_byte(pb, page->flags | extra_flags);
- put_le64(pb, page->granule);
- put_le32(pb, oggstream->serial_num);
- put_le32(pb, oggstream->page_counter++);
+ avio_w8(pb, 0);
+ avio_w8(pb, page->flags | extra_flags);
+ avio_wl64(pb, page->granule);
+ avio_wl32(pb, oggstream->serial_num);
+ avio_wl32(pb, oggstream->page_counter++);
crc_offset = url_ftell(pb);
- put_le32(pb, 0); // crc
- put_byte(pb, page->segments_count);
- put_buffer(pb, page->segments, page->segments_count);
- put_buffer(pb, page->data, page->size);
+ avio_wl32(pb, 0); // crc
+ avio_w8(pb, page->segments_count);
+ avio_write(pb, page->segments, page->segments_count);
+ avio_write(pb, page->data, page->size);
ogg_update_checksum(s, pb, crc_offset);
put_flush_packet(pb);
@@ -104,7 +104,7 @@ static int ogg_write_page(AVFormatContext *s, OGGPage *page, int extra_flags)
if (size < 0)
return size;
- put_buffer(s->pb, buf, size);
+ avio_write(s->pb, buf, size);
put_flush_packet(s->pb);
av_free(buf);
oggstream->page_count--;
diff --git a/libavformat/rawenc.c b/libavformat/rawenc.c
index 6f9fdce4a1..20ddfd5609 100644
--- a/libavformat/rawenc.c
+++ b/libavformat/rawenc.c
@@ -25,7 +25,7 @@
int ff_raw_write_packet(AVFormatContext *s, AVPacket *pkt)
{
- put_buffer(s->pb, pkt->data, pkt->size);
+ avio_write(s->pb, pkt->data, pkt->size);
put_flush_packet(s->pb);
return 0;
}
diff --git a/libavformat/riff.c b/libavformat/riff.c
index 7111487f8c..4cbc2b7f0a 100644
--- a/libavformat/riff.c
+++ b/libavformat/riff.c
@@ -322,7 +322,7 @@ const AVCodecTag ff_codec_wav_tags[] = {
int64_t ff_start_tag(AVIOContext *pb, const char *tag)
{
put_tag(pb, tag);
- put_le32(pb, 0);
+ avio_wl32(pb, 0);
return url_ftell(pb);
}
@@ -332,7 +332,7 @@ void ff_end_tag(AVIOContext *pb, int64_t start)
pos = url_ftell(pb);
url_fseek(pb, start - 4, SEEK_SET);
- put_le32(pb, (uint32_t)(pos - start));
+ avio_wl32(pb, (uint32_t)(pos - start));
url_fseek(pb, pos, SEEK_SET);
}
@@ -354,12 +354,12 @@ int ff_put_wav_header(AVIOContext *pb, AVCodecContext *enc)
|| av_get_bits_per_sample(enc->codec_id) > 16;
if (waveformatextensible) {
- put_le16(pb, 0xfffe);
+ avio_wl16(pb, 0xfffe);
} else {
- put_le16(pb, enc->codec_tag);
+ avio_wl16(pb, enc->codec_tag);
}
- put_le16(pb, enc->channels);
- put_le32(pb, enc->sample_rate);
+ avio_wl16(pb, enc->channels);
+ avio_wl32(pb, enc->sample_rate);
if (enc->codec_id == CODEC_ID_MP2 || enc->codec_id == CODEC_ID_MP3 || enc->codec_id == CODEC_ID_GSM_MS) {
bps = 0;
} else if (enc->codec_id == CODEC_ID_ADPCM_G726) {
@@ -393,9 +393,9 @@ int ff_put_wav_header(AVIOContext *pb, AVCodecContext *enc)
} else {
bytespersec = enc->bit_rate / 8;
}
- put_le32(pb, bytespersec); /* bytes per second */
- put_le16(pb, blkalign); /* block align */
- put_le16(pb, bps); /* bits per sample */
+ avio_wl32(pb, bytespersec); /* bytes per second */
+ avio_wl16(pb, blkalign); /* block align */
+ avio_wl16(pb, bps); /* bits per sample */
if (enc->codec_id == CODEC_ID_MP3) {
hdrsize += 12;
bytestream_put_le16(&riff_extradata, 1); /* wID */
@@ -425,20 +425,20 @@ int ff_put_wav_header(AVIOContext *pb, AVCodecContext *enc)
}
if(waveformatextensible) { /* write WAVEFORMATEXTENSIBLE extensions */
hdrsize += 22;
- put_le16(pb, riff_extradata - riff_extradata_start + 22); /* 22 is WAVEFORMATEXTENSIBLE size */
- put_le16(pb, enc->bits_per_coded_sample); /* ValidBitsPerSample || SamplesPerBlock || Reserved */
- put_le32(pb, enc->channel_layout); /* dwChannelMask */
- put_le32(pb, enc->codec_tag); /* GUID + next 3 */
- put_le32(pb, 0x00100000);
- put_le32(pb, 0xAA000080);
- put_le32(pb, 0x719B3800);
+ avio_wl16(pb, riff_extradata - riff_extradata_start + 22); /* 22 is WAVEFORMATEXTENSIBLE size */
+ avio_wl16(pb, enc->bits_per_coded_sample); /* ValidBitsPerSample || SamplesPerBlock || Reserved */
+ avio_wl32(pb, enc->channel_layout); /* dwChannelMask */
+ avio_wl32(pb, enc->codec_tag); /* GUID + next 3 */
+ avio_wl32(pb, 0x00100000);
+ avio_wl32(pb, 0xAA000080);
+ avio_wl32(pb, 0x719B3800);
} else if(riff_extradata - riff_extradata_start) {
- put_le16(pb, riff_extradata - riff_extradata_start);
+ avio_wl16(pb, riff_extradata - riff_extradata_start);
}
- put_buffer(pb, riff_extradata_start, riff_extradata - riff_extradata_start);
+ avio_write(pb, riff_extradata_start, riff_extradata - riff_extradata_start);
if(hdrsize&1){
hdrsize++;
- put_byte(pb, 0);
+ avio_w8(pb, 0);
}
return hdrsize;
@@ -447,25 +447,25 @@ int ff_put_wav_header(AVIOContext *pb, AVCodecContext *enc)
/* BITMAPINFOHEADER header */
void ff_put_bmp_header(AVIOContext *pb, AVCodecContext *enc, const AVCodecTag *tags, int for_asf)
{
- put_le32(pb, 40 + enc->extradata_size); /* size */
- put_le32(pb, enc->width);
+ avio_wl32(pb, 40 + enc->extradata_size); /* size */
+ avio_wl32(pb, enc->width);
//We always store RGB TopDown
- put_le32(pb, enc->codec_tag ? enc->height : -enc->height);
- put_le16(pb, 1); /* planes */
+ avio_wl32(pb, enc->codec_tag ? enc->height : -enc->height);
+ avio_wl16(pb, 1); /* planes */
- put_le16(pb, enc->bits_per_coded_sample ? enc->bits_per_coded_sample : 24); /* depth */
+ avio_wl16(pb, enc->bits_per_coded_sample ? enc->bits_per_coded_sample : 24); /* depth */
/* compression type */
- put_le32(pb, enc->codec_tag);
- put_le32(pb, enc->width * enc->height * 3);
- put_le32(pb, 0);
- put_le32(pb, 0);
- put_le32(pb, 0);
- put_le32(pb, 0);
+ avio_wl32(pb, enc->codec_tag);
+ avio_wl32(pb, enc->width * enc->height * 3);
+ avio_wl32(pb, 0);
+ avio_wl32(pb, 0);
+ avio_wl32(pb, 0);
+ avio_wl32(pb, 0);
- put_buffer(pb, enc->extradata, enc->extradata_size);
+ avio_write(pb, enc->extradata, enc->extradata_size);
if (!for_asf && enc->extradata_size & 1)
- put_byte(pb, 0);
+ avio_w8(pb, 0);
}
#endif //CONFIG_MUXERS
diff --git a/libavformat/rmenc.c b/libavformat/rmenc.c
index b60b8a20eb..6ba152e45c 100644
--- a/libavformat/rmenc.c
+++ b/libavformat/rmenc.c
@@ -46,17 +46,17 @@ typedef struct {
static void put_str(AVIOContext *s, const char *tag)
{
- put_be16(s,strlen(tag));
+ avio_wb16(s,strlen(tag));
while (*tag) {
- put_byte(s, *tag++);
+ avio_w8(s, *tag++);
}
}
static void put_str8(AVIOContext *s, const char *tag)
{
- put_byte(s, strlen(tag));
+ avio_w8(s, strlen(tag));
while (*tag) {
- put_byte(s, *tag++);
+ avio_w8(s, *tag++);
}
}
@@ -75,14 +75,14 @@ static int rv10_write_header(AVFormatContext *ctx,
start_ptr = s->buf_ptr;
put_tag(s, ".RMF");
- put_be32(s,18); /* header size */
- put_be16(s,0);
- put_be32(s,0);
- put_be32(s,4 + ctx->nb_streams); /* num headers */
+ avio_wb32(s,18); /* header size */
+ avio_wb16(s,0);
+ avio_wb32(s,0);
+ avio_wb32(s,4 + ctx->nb_streams); /* num headers */
put_tag(s,"PROP");
- put_be32(s, 50);
- put_be16(s, 0);
+ avio_wb32(s, 50);
+ avio_wb16(s, 0);
packet_max_size = 0;
packet_total_size = 0;
nb_packets = 0;
@@ -100,26 +100,26 @@ static int rv10_write_header(AVFormatContext *ctx,
if (v > duration)
duration = v;
}
- put_be32(s, bit_rate); /* max bit rate */
- put_be32(s, bit_rate); /* avg bit rate */
- put_be32(s, packet_max_size); /* max packet size */
+ avio_wb32(s, bit_rate); /* max bit rate */
+ avio_wb32(s, bit_rate); /* avg bit rate */
+ avio_wb32(s, packet_max_size); /* max packet size */
if (nb_packets > 0)
packet_avg_size = packet_total_size / nb_packets;
else
packet_avg_size = 0;
- put_be32(s, packet_avg_size); /* avg packet size */
- put_be32(s, nb_packets); /* num packets */
- put_be32(s, duration); /* duration */
- put_be32(s, BUFFER_DURATION); /* preroll */
- put_be32(s, index_pos); /* index offset */
+ avio_wb32(s, packet_avg_size); /* avg packet size */
+ avio_wb32(s, nb_packets); /* num packets */
+ avio_wb32(s, duration); /* duration */
+ avio_wb32(s, BUFFER_DURATION); /* preroll */
+ avio_wb32(s, index_pos); /* index offset */
/* computation of data the data offset */
data_offset_ptr = s->buf_ptr;
- put_be32(s, 0); /* data offset : will be patched after */
- put_be16(s, ctx->nb_streams); /* num streams */
+ avio_wb32(s, 0); /* data offset : will be patched after */
+ avio_wb16(s, ctx->nb_streams); /* num streams */
flags = 1 | 2; /* save allowed & perfect play */
if (url_is_streamed(s))
flags |= 4; /* live broadcast */
- put_be16(s, flags);
+ avio_wb16(s, flags);
/* comments */
@@ -129,8 +129,8 @@ static int rv10_write_header(AVFormatContext *ctx,
tag = av_metadata_get(ctx->metadata, ff_rm_metadata[i], NULL, 0);
if(tag) size += strlen(tag->value);
}
- put_be32(s,size);
- put_be16(s,0);
+ avio_wb32(s,size);
+ avio_wb16(s,0);
for(i=0; i<FF_ARRAY_ELEMS(ff_rm_metadata); i++) {
tag = av_metadata_get(ctx->metadata, ff_rm_metadata[i], NULL, 0);
put_str(s, tag ? tag->value : "");
@@ -153,29 +153,29 @@ static int rv10_write_header(AVFormatContext *ctx,
put_tag(s,"MDPR");
size = 10 + 9 * 4 + strlen(desc) + strlen(mimetype) + codec_data_size;
- put_be32(s, size);
- put_be16(s, 0);
+ avio_wb32(s, size);
+ avio_wb16(s, 0);
- put_be16(s, i); /* stream number */
- put_be32(s, stream->bit_rate); /* max bit rate */
- put_be32(s, stream->bit_rate); /* avg bit rate */
- put_be32(s, stream->packet_max_size); /* max packet size */
+ avio_wb16(s, i); /* stream number */
+ avio_wb32(s, stream->bit_rate); /* max bit rate */
+ avio_wb32(s, stream->bit_rate); /* avg bit rate */
+ avio_wb32(s, stream->packet_max_size); /* max packet size */
if (stream->nb_packets > 0)
packet_avg_size = stream->packet_total_size /
stream->nb_packets;
else
packet_avg_size = 0;
- put_be32(s, packet_avg_size); /* avg packet size */
- put_be32(s, 0); /* start time */
- put_be32(s, BUFFER_DURATION); /* preroll */
+ avio_wb32(s, packet_avg_size); /* avg packet size */
+ avio_wb32(s, 0); /* start time */
+ avio_wb32(s, BUFFER_DURATION); /* preroll */
/* duration */
if (url_is_streamed(s) || !stream->total_frames)
- put_be32(s, (int)(3600 * 1000));
+ avio_wb32(s, (int)(3600 * 1000));
else
- put_be32(s, (int)(stream->total_frames * 1000 / stream->frame_rate));
+ avio_wb32(s, (int)(stream->total_frames * 1000 / stream->frame_rate));
put_str8(s, desc);
put_str8(s, mimetype);
- put_be32(s, codec_data_size);
+ avio_wb32(s, codec_data_size);
if (stream->enc->codec_type == AVMEDIA_TYPE_AUDIO) {
int coded_frame_size, fscode, sample_rate;
@@ -184,12 +184,12 @@ static int rv10_write_header(AVFormatContext *ctx,
stream->enc->frame_size) / (8 * sample_rate);
/* audio codec info */
put_tag(s, ".ra");
- put_byte(s, 0xfd);
- put_be32(s, 0x00040000); /* version */
+ avio_w8(s, 0xfd);
+ avio_wb32(s, 0x00040000); /* version */
put_tag(s, ".ra4");
- put_be32(s, 0x01b53530); /* stream length */
- put_be16(s, 4); /* unknown */
- put_be32(s, 0x39); /* header size */
+ avio_wb32(s, 0x01b53530); /* stream length */
+ avio_wb16(s, 4); /* unknown */
+ avio_wb32(s, 0x39); /* header size */
switch(sample_rate) {
case 48000:
@@ -208,56 +208,56 @@ static int rv10_write_header(AVFormatContext *ctx,
case 8000:
fscode = 3;
}
- put_be16(s, fscode); /* codec additional info, for AC-3, seems
+ avio_wb16(s, fscode); /* codec additional info, for AC-3, seems
to be a frequency code */
/* special hack to compensate rounding errors... */
if (coded_frame_size == 557)
coded_frame_size--;
- put_be32(s, coded_frame_size); /* frame length */
- put_be32(s, 0x51540); /* unknown */
- put_be32(s, 0x249f0); /* unknown */
- put_be32(s, 0x249f0); /* unknown */
- put_be16(s, 0x01);
+ avio_wb32(s, coded_frame_size); /* frame length */
+ avio_wb32(s, 0x51540); /* unknown */
+ avio_wb32(s, 0x249f0); /* unknown */
+ avio_wb32(s, 0x249f0); /* unknown */
+ avio_wb16(s, 0x01);
/* frame length : seems to be very important */
- put_be16(s, coded_frame_size);
- put_be32(s, 0); /* unknown */
- put_be16(s, stream->enc->sample_rate); /* sample rate */
- put_be32(s, 0x10); /* unknown */
- put_be16(s, stream->enc->channels);
+ avio_wb16(s, coded_frame_size);
+ avio_wb32(s, 0); /* unknown */
+ avio_wb16(s, stream->enc->sample_rate); /* sample rate */
+ avio_wb32(s, 0x10); /* unknown */
+ avio_wb16(s, stream->enc->channels);
put_str8(s, "Int0"); /* codec name */
if (stream->enc->codec_tag) {
- put_byte(s, 4); /* tag length */
- put_le32(s, stream->enc->codec_tag);
+ avio_w8(s, 4); /* tag length */
+ avio_wl32(s, stream->enc->codec_tag);
} else {
av_log(ctx, AV_LOG_ERROR, "Invalid codec tag\n");
return -1;
}
- put_be16(s, 0); /* title length */
- put_be16(s, 0); /* author length */
- put_be16(s, 0); /* copyright length */
- put_byte(s, 0); /* end of header */
+ avio_wb16(s, 0); /* title length */
+ avio_wb16(s, 0); /* author length */
+ avio_wb16(s, 0); /* copyright length */
+ avio_w8(s, 0); /* end of header */
} else {
/* video codec info */
- put_be32(s,34); /* size */
+ avio_wb32(s,34); /* size */
if(stream->enc->codec_id == CODEC_ID_RV10)
put_tag(s,"VIDORV10");
else
put_tag(s,"VIDORV20");
- put_be16(s, stream->enc->width);
- put_be16(s, stream->enc->height);
- put_be16(s, (int) stream->frame_rate); /* frames per seconds ? */
- put_be32(s,0); /* unknown meaning */
- put_be16(s, (int) stream->frame_rate); /* unknown meaning */
- put_be32(s,0); /* unknown meaning */
- put_be16(s, 8); /* unknown meaning */
+ avio_wb16(s, stream->enc->width);
+ avio_wb16(s, stream->enc->height);
+ avio_wb16(s, (int) stream->frame_rate); /* frames per seconds ? */
+ avio_wb32(s,0); /* unknown meaning */
+ avio_wb16(s, (int) stream->frame_rate); /* unknown meaning */
+ avio_wb32(s,0); /* unknown meaning */
+ avio_wb16(s, 8); /* unknown meaning */
/* Seems to be the codec version: only use basic H263. The next
versions seems to add a diffential DC coding as in
MPEG... nothing new under the sun */
if(stream->enc->codec_id == CODEC_ID_RV10)
- put_be32(s,0x10000000);
+ avio_wb32(s,0x10000000);
else
- put_be32(s,0x20103001);
- //put_be32(s,0x10003000);
+ avio_wb32(s,0x20103001);
+ //avio_wb32(s,0x10003000);
}
}
@@ -271,11 +271,11 @@ static int rv10_write_header(AVFormatContext *ctx,
/* data stream */
put_tag(s,"DATA");
- put_be32(s,data_size + 10 + 8);
- put_be16(s,0);
+ avio_wb32(s,data_size + 10 + 8);
+ avio_wb16(s,0);
- put_be32(s, nb_packets); /* number of packets */
- put_be32(s,0); /* next data header */
+ avio_wb32(s, nb_packets); /* number of packets */
+ avio_wb32(s,0); /* next data header */
return 0;
}
@@ -290,13 +290,13 @@ static void write_packet_header(AVFormatContext *ctx, StreamInfo *stream,
if (length > stream->packet_max_size)
stream->packet_max_size = length;
- put_be16(s,0); /* version */
- put_be16(s,length + 12);
- put_be16(s, stream->num); /* stream number */
+ avio_wb16(s,0); /* version */
+ avio_wb16(s,length + 12);
+ avio_wb16(s, stream->num); /* stream number */
timestamp = (1000 * (float)stream->nb_frames) / stream->frame_rate;
- put_be32(s, timestamp); /* timestamp */
- put_byte(s, 0); /* reserved */
- put_byte(s, key_frame ? 2 : 0); /* flags */
+ avio_wb32(s, timestamp); /* timestamp */
+ avio_w8(s, 0); /* reserved */
+ avio_w8(s, key_frame ? 2 : 0); /* flags */
}
static int rm_write_header(AVFormatContext *s)
@@ -362,9 +362,9 @@ static int rm_write_audio(AVFormatContext *s, const uint8_t *buf, int size, int
buf1[i] = buf[i+1];
buf1[i+1] = buf[i];
}
- put_buffer(pb, buf1, size);
+ avio_write(pb, buf1, size);
} else {
- put_buffer(pb, buf, size);
+ avio_write(pb, buf, size);
}
put_flush_packet(pb);
stream->nb_frames++;
@@ -386,31 +386,31 @@ static int rm_write_video(AVFormatContext *s, const uint8_t *buf, int size, int
#if 1
write_packet_header(s, stream, size + 7 + (size >= 0x4000)*4, key_frame);
/* bit 7: '1' if final packet of a frame converted in several packets */
- put_byte(pb, 0x81);
+ avio_w8(pb, 0x81);
/* bit 7: '1' if I frame. bits 6..0 : sequence number in current
frame starting from 1 */
if (key_frame) {
- put_byte(pb, 0x81);
+ avio_w8(pb, 0x81);
} else {
- put_byte(pb, 0x01);
+ avio_w8(pb, 0x01);
}
if(size >= 0x4000){
- put_be32(pb, size); /* total frame size */
- put_be32(pb, size); /* offset from the start or the end */
+ avio_wb32(pb, size); /* total frame size */
+ avio_wb32(pb, size); /* offset from the start or the end */
}else{
- put_be16(pb, 0x4000 | size); /* total frame size */
- put_be16(pb, 0x4000 | size); /* offset from the start or the end */
+ avio_wb16(pb, 0x4000 | size); /* total frame size */
+ avio_wb16(pb, 0x4000 | size); /* offset from the start or the end */
}
#else
/* full frame */
write_packet_header(s, size + 6);
- put_byte(pb, 0xc0);
- put_be16(pb, 0x4000 + size); /* total frame size */
- put_be16(pb, 0x4000 + packet_number * 126); /* position in stream */
+ avio_w8(pb, 0xc0);
+ avio_wb16(pb, 0x4000 + size); /* total frame size */
+ avio_wb16(pb, 0x4000 + packet_number * 126); /* position in stream */
#endif
- put_byte(pb, stream->nb_frames & 0xff);
+ avio_w8(pb, stream->nb_frames & 0xff);
- put_buffer(pb, buf, size);
+ avio_write(pb, buf, size);
put_flush_packet(pb);
stream->nb_frames++;
@@ -440,8 +440,8 @@ static int rm_write_trailer(AVFormatContext *s)
/* FIXME: write index */
/* undocumented end header */
- put_be32(pb, 0);
- put_be32(pb, 0);
+ avio_wb32(pb, 0);
+ avio_wb32(pb, 0);
url_fseek(pb, 0, SEEK_SET);
for(i=0;i<s->nb_streams;i++)
@@ -449,8 +449,8 @@ static int rm_write_trailer(AVFormatContext *s)
rv10_write_header(s, data_size, 0);
} else {
/* undocumented end header */
- put_be32(pb, 0);
- put_be32(pb, 0);
+ avio_wb32(pb, 0);
+ avio_wb32(pb, 0);
}
put_flush_packet(pb);
return 0;
diff --git a/libavformat/rsoenc.c b/libavformat/rsoenc.c
index 0093265772..9c5ee9bd62 100644
--- a/libavformat/rsoenc.c
+++ b/libavformat/rsoenc.c
@@ -55,10 +55,10 @@ static int rso_write_header(AVFormatContext *s)
}
/* format header */
- put_be16(pb, enc->codec_tag); /* codec ID */
- put_be16(pb, 0); /* data size, will be written at EOF */
- put_be16(pb, enc->sample_rate);
- put_be16(pb, 0x0000); /* play mode ? (0x0000 = don't loop) */
+ avio_wb16(pb, enc->codec_tag); /* codec ID */
+ avio_wb16(pb, 0); /* data size, will be written at EOF */
+ avio_wb16(pb, enc->sample_rate);
+ avio_wb16(pb, 0x0000); /* play mode ? (0x0000 = don't loop) */
put_flush_packet(pb);
@@ -67,7 +67,7 @@ static int rso_write_header(AVFormatContext *s)
static int rso_write_packet(AVFormatContext *s, AVPacket *pkt)
{
- put_buffer(s->pb, pkt->data, pkt->size);
+ avio_write(s->pb, pkt->data, pkt->size);
return 0;
}
@@ -92,7 +92,7 @@ static int rso_write_trailer(AVFormatContext *s)
/* update file size */
url_fseek(pb, 2, SEEK_SET);
- put_be16(pb, coded_file_size);
+ avio_wb16(pb, coded_file_size);
url_fseek(pb, file_size, SEEK_SET);
put_flush_packet(pb);
diff --git a/libavformat/rtpdec.c b/libavformat/rtpdec.c
index 3d40729d1c..b4b8ffcd72 100644
--- a/libavformat/rtpdec.c
+++ b/libavformat/rtpdec.c
@@ -268,12 +268,12 @@ int rtp_check_and_send_back_rr(RTPDemuxContext *s, int count)
return -1;
// Receiver Report
- put_byte(pb, (RTP_VERSION << 6) + 1); /* 1 report block */
- put_byte(pb, RTCP_RR);
- put_be16(pb, 7); /* length in words - 1 */
+ avio_w8(pb, (RTP_VERSION << 6) + 1); /* 1 report block */
+ avio_w8(pb, RTCP_RR);
+ avio_wb16(pb, 7); /* length in words - 1 */
// our own SSRC: we use the server's SSRC + 1 to avoid conflicts
- put_be32(pb, s->ssrc + 1);
- put_be32(pb, s->ssrc); // server SSRC
+ avio_wb32(pb, s->ssrc + 1);
+ avio_wb32(pb, s->ssrc); // server SSRC
// some placeholders we should really fill...
// RFC 1889/p64
extended_max= stats->cycles + stats->max_seq;
@@ -290,34 +290,34 @@ int rtp_check_and_send_back_rr(RTPDemuxContext *s, int count)
fraction= (fraction<<24) | lost;
- put_be32(pb, fraction); /* 8 bits of fraction, 24 bits of total packets lost */
- put_be32(pb, extended_max); /* max sequence received */
- put_be32(pb, stats->jitter>>4); /* jitter */
+ avio_wb32(pb, fraction); /* 8 bits of fraction, 24 bits of total packets lost */
+ avio_wb32(pb, extended_max); /* max sequence received */
+ avio_wb32(pb, stats->jitter>>4); /* jitter */
if(s->last_rtcp_ntp_time==AV_NOPTS_VALUE)
{
- put_be32(pb, 0); /* last SR timestamp */
- put_be32(pb, 0); /* delay since last SR */
+ avio_wb32(pb, 0); /* last SR timestamp */
+ avio_wb32(pb, 0); /* delay since last SR */
} else {
uint32_t middle_32_bits= s->last_rtcp_ntp_time>>16; // this is valid, right? do we need to handle 64 bit values special?
uint32_t delay_since_last= ntp_time - s->last_rtcp_ntp_time;
- put_be32(pb, middle_32_bits); /* last SR timestamp */
- put_be32(pb, delay_since_last); /* delay since last SR */
+ avio_wb32(pb, middle_32_bits); /* last SR timestamp */
+ avio_wb32(pb, delay_since_last); /* delay since last SR */
}
// CNAME
- put_byte(pb, (RTP_VERSION << 6) + 1); /* 1 report block */
- put_byte(pb, RTCP_SDES);
+ avio_w8(pb, (RTP_VERSION << 6) + 1); /* 1 report block */
+ avio_w8(pb, RTCP_SDES);
len = strlen(s->hostname);
- put_be16(pb, (6 + len + 3) / 4); /* length in words - 1 */
- put_be32(pb, s->ssrc);
- put_byte(pb, 0x01);
- put_byte(pb, len);
- put_buffer(pb, s->hostname, len);
+ avio_wb16(pb, (6 + len + 3) / 4); /* length in words - 1 */
+ avio_wb32(pb, s->ssrc);
+ avio_w8(pb, 0x01);
+ avio_w8(pb, len);
+ avio_write(pb, s->hostname, len);
// padding
for (len = (6 + len) % 4; len % 4; len++) {
- put_byte(pb, 0);
+ avio_w8(pb, 0);
}
put_flush_packet(pb);
@@ -342,11 +342,11 @@ void rtp_send_punch_packets(URLContext* rtp_handle)
if (url_open_dyn_buf(&pb) < 0)
return;
- put_byte(pb, (RTP_VERSION << 6));
- put_byte(pb, 0); /* Payload type */
- put_be16(pb, 0); /* Seq */
- put_be32(pb, 0); /* Timestamp */
- put_be32(pb, 0); /* SSRC */
+ avio_w8(pb, (RTP_VERSION << 6));
+ avio_w8(pb, 0); /* Payload type */
+ avio_wb16(pb, 0); /* Seq */
+ avio_wb32(pb, 0); /* Timestamp */
+ avio_wb32(pb, 0); /* SSRC */
put_flush_packet(pb);
len = url_close_dyn_buf(pb, &buf);
@@ -358,10 +358,10 @@ void rtp_send_punch_packets(URLContext* rtp_handle)
if (url_open_dyn_buf(&pb) < 0)
return;
- put_byte(pb, (RTP_VERSION << 6));
- put_byte(pb, RTCP_RR); /* receiver report */
- put_be16(pb, 1); /* length in words - 1 */
- put_be32(pb, 0); /* our own SSRC */
+ avio_w8(pb, (RTP_VERSION << 6));
+ avio_w8(pb, RTCP_RR); /* receiver report */
+ avio_wb16(pb, 1); /* length in words - 1 */
+ avio_wb32(pb, 0); /* our own SSRC */
put_flush_packet(pb);
len = url_close_dyn_buf(pb, &buf);
diff --git a/libavformat/rtpdec_asf.c b/libavformat/rtpdec_asf.c
index 0f2393f5de..f949725a0f 100644
--- a/libavformat/rtpdec_asf.c
+++ b/libavformat/rtpdec_asf.c
@@ -213,7 +213,7 @@ static int asfrtp_parse_packet(AVFormatContext *s, PayloadContext *asf,
if (!asf->pktbuf)
return AVERROR(EIO);
- put_buffer(asf->pktbuf, buf + off, len - off);
+ avio_write(asf->pktbuf, buf + off, len - off);
url_fskip(pb, len - off);
if (!(flags & RTP_FLAG_MARKER))
return -1;
diff --git a/libavformat/rtpdec_latm.c b/libavformat/rtpdec_latm.c
index 255398df02..c6d865a650 100644
--- a/libavformat/rtpdec_latm.c
+++ b/libavformat/rtpdec_latm.c
@@ -68,7 +68,7 @@ static int latm_parse_packet(AVFormatContext *ctx, PayloadContext *data,
if ((ret = url_open_dyn_buf(&data->dyn_buf)) < 0)
return ret;
}
- put_buffer(data->dyn_buf, buf, len);
+ avio_write(data->dyn_buf, buf, len);
if (!(flags & RTP_FLAG_MARKER))
return AVERROR(EAGAIN);
diff --git a/libavformat/rtpdec_svq3.c b/libavformat/rtpdec_svq3.c
index 36271a3c15..a4fad1cc13 100644
--- a/libavformat/rtpdec_svq3.c
+++ b/libavformat/rtpdec_svq3.c
@@ -94,7 +94,7 @@ static int svq3_parse_packet (AVFormatContext *s, PayloadContext *sv,
if (!sv->pktbuf)
return AVERROR_INVALIDDATA;
- put_buffer(sv->pktbuf, buf, len);
+ avio_write(sv->pktbuf, buf, len);
if (end_packet) {
av_init_packet(pkt);
diff --git a/libavformat/rtpdec_vp8.c b/libavformat/rtpdec_vp8.c
index 2431e6b32b..3b1ee137aa 100644
--- a/libavformat/rtpdec_vp8.c
+++ b/libavformat/rtpdec_vp8.c
@@ -111,7 +111,7 @@ static int vp8_handle_packet(AVFormatContext *ctx,
}
}
- put_buffer(vp8->data, buf, au_len);
+ avio_write(vp8->data, buf, au_len);
buf += au_len;
len -= au_len;
}
diff --git a/libavformat/rtpdec_xiph.c b/libavformat/rtpdec_xiph.c
index 17d81e7222..37e57f504f 100644
--- a/libavformat/rtpdec_xiph.c
+++ b/libavformat/rtpdec_xiph.c
@@ -179,7 +179,7 @@ static int xiph_handle_packet(AVFormatContext * ctx,
if((res = url_open_dyn_buf(&data->fragment)) < 0)
return res;
- put_buffer(data->fragment, buf, pkt_len);
+ avio_write(data->fragment, buf, pkt_len);
data->timestamp = *timestamp;
} else {
@@ -198,7 +198,7 @@ static int xiph_handle_packet(AVFormatContext * ctx,
}
// copy data to fragment buffer
- put_buffer(data->fragment, buf, pkt_len);
+ avio_write(data->fragment, buf, pkt_len);
if (fragmented == 3) {
// end of xiph data packet
diff --git a/libavformat/rtpenc.c b/libavformat/rtpenc.c
index 22e68bac97..b32a9a4041 100644
--- a/libavformat/rtpenc.c
+++ b/libavformat/rtpenc.c
@@ -197,15 +197,15 @@ static void rtcp_send_sr(AVFormatContext *s1, int64_t ntp_time)
s->last_rtcp_ntp_time = ntp_time;
rtp_ts = av_rescale_q(ntp_time - s->first_rtcp_ntp_time, (AVRational){1, 1000000},
s1->streams[0]->time_base) + s->base_timestamp;
- put_byte(s1->pb, (RTP_VERSION << 6));
- put_byte(s1->pb, RTCP_SR);
- put_be16(s1->pb, 6); /* length in words - 1 */
- put_be32(s1->pb, s->ssrc);
- put_be32(s1->pb, ntp_time / 1000000);
- put_be32(s1->pb, ((ntp_time % 1000000) << 32) / 1000000);
- put_be32(s1->pb, rtp_ts);
- put_be32(s1->pb, s->packet_count);
- put_be32(s1->pb, s->octet_count);
+ avio_w8(s1->pb, (RTP_VERSION << 6));
+ avio_w8(s1->pb, RTCP_SR);
+ avio_wb16(s1->pb, 6); /* length in words - 1 */
+ avio_wb32(s1->pb, s->ssrc);
+ avio_wb32(s1->pb, ntp_time / 1000000);
+ avio_wb32(s1->pb, ((ntp_time % 1000000) << 32) / 1000000);
+ avio_wb32(s1->pb, rtp_ts);
+ avio_wb32(s1->pb, s->packet_count);
+ avio_wb32(s1->pb, s->octet_count);
put_flush_packet(s1->pb);
}
@@ -218,13 +218,13 @@ void ff_rtp_send_data(AVFormatContext *s1, const uint8_t *buf1, int len, int m)
av_dlog(s1, "rtp_send_data size=%d\n", len);
/* build the RTP header */
- put_byte(s1->pb, (RTP_VERSION << 6));
- put_byte(s1->pb, (s->payload_type & 0x7f) | ((m & 0x01) << 7));
- put_be16(s1->pb, s->seq);
- put_be32(s1->pb, s->timestamp);
- put_be32(s1->pb, s->ssrc);
+ avio_w8(s1->pb, (RTP_VERSION << 6));
+ avio_w8(s1->pb, (s->payload_type & 0x7f) | ((m & 0x01) << 7));
+ avio_wb16(s1->pb, s->seq);
+ avio_wb32(s1->pb, s->timestamp);
+ avio_wb32(s1->pb, s->ssrc);
- put_buffer(s1->pb, buf1, len);
+ avio_write(s1->pb, buf1, len);
put_flush_packet(s1->pb);
s->seq++;
diff --git a/libavformat/soxenc.c b/libavformat/soxenc.c
index 6315efd7ef..75141de789 100644
--- a/libavformat/soxenc.c
+++ b/libavformat/soxenc.c
@@ -54,28 +54,28 @@ static int sox_write_header(AVFormatContext *s)
if (enc->codec_id == CODEC_ID_PCM_S32LE) {
put_tag(pb, ".SoX");
- put_le32(pb, sox->header_size);
- put_le64(pb, 0); /* number of samples */
- put_le64(pb, av_dbl2int(enc->sample_rate));
- put_le32(pb, enc->channels);
- put_le32(pb, comment_size);
+ avio_wl32(pb, sox->header_size);
+ avio_wl64(pb, 0); /* number of samples */
+ avio_wl64(pb, av_dbl2int(enc->sample_rate));
+ avio_wl32(pb, enc->channels);
+ avio_wl32(pb, comment_size);
} else if (enc->codec_id == CODEC_ID_PCM_S32BE) {
put_tag(pb, "XoS.");
- put_be32(pb, sox->header_size);
- put_be64(pb, 0); /* number of samples */
- put_be64(pb, av_dbl2int(enc->sample_rate));
- put_be32(pb, enc->channels);
- put_be32(pb, comment_size);
+ avio_wb32(pb, sox->header_size);
+ avio_wb64(pb, 0); /* number of samples */
+ avio_wb64(pb, av_dbl2int(enc->sample_rate));
+ avio_wb32(pb, enc->channels);
+ avio_wb32(pb, comment_size);
} else {
av_log(s, AV_LOG_ERROR, "invalid codec; use pcm_s32le or pcm_s32be\n");
return -1;
}
if (comment_len)
- put_buffer(pb, comment->value, comment_len);
+ avio_write(pb, comment->value, comment_len);
for ( ; comment_size > comment_len; comment_len++)
- put_byte(pb, 0);
+ avio_w8(pb, 0);
put_flush_packet(pb);
@@ -85,7 +85,7 @@ static int sox_write_header(AVFormatContext *s)
static int sox_write_packet(AVFormatContext *s, AVPacket *pkt)
{
AVIOContext *pb = s->pb;
- put_buffer(pb, pkt->data, pkt->size);
+ avio_write(pb, pkt->data, pkt->size);
return 0;
}
@@ -101,9 +101,9 @@ static int sox_write_trailer(AVFormatContext *s)
int64_t num_samples = (file_size - sox->header_size - 4LL) >> 2LL;
url_fseek(pb, 8, SEEK_SET);
if (enc->codec_id == CODEC_ID_PCM_S32LE) {
- put_le64(pb, num_samples);
+ avio_wl64(pb, num_samples);
} else
- put_be64(pb, num_samples);
+ avio_wb64(pb, num_samples);
url_fseek(pb, file_size, SEEK_SET);
put_flush_packet(pb);
diff --git a/libavformat/spdifenc.c b/libavformat/spdifenc.c
index f959c96156..8c0ee70e2c 100644
--- a/libavformat/spdifenc.c
+++ b/libavformat/spdifenc.c
@@ -476,9 +476,9 @@ static av_always_inline void spdif_put_16(IEC61937Context *ctx,
AVIOContext *pb, unsigned int val)
{
if (ctx->spdif_flags & SPDIF_FLAG_BIGENDIAN)
- put_be16(pb, val);
+ avio_wb16(pb, val);
else
- put_le16(pb, val);
+ avio_wl16(pb, val);
}
static int spdif_write_packet(struct AVFormatContext *s, AVPacket *pkt)
@@ -512,13 +512,13 @@ static int spdif_write_packet(struct AVFormatContext *s, AVPacket *pkt)
}
if (ctx->extra_bswap ^ (ctx->spdif_flags & SPDIF_FLAG_BIGENDIAN)) {
- put_buffer(s->pb, ctx->out_buf, ctx->out_bytes & ~1);
+ avio_write(s->pb, ctx->out_buf, ctx->out_bytes & ~1);
} else {
av_fast_malloc(&ctx->buffer, &ctx->buffer_size, ctx->out_bytes + FF_INPUT_BUFFER_PADDING_SIZE);
if (!ctx->buffer)
return AVERROR(ENOMEM);
ff_spdif_bswap_buf16((uint16_t *)ctx->buffer, (uint16_t *)ctx->out_buf, ctx->out_bytes >> 1);
- put_buffer(s->pb, ctx->buffer, ctx->out_bytes & ~1);
+ avio_write(s->pb, ctx->buffer, ctx->out_bytes & ~1);
}
/* a final lone byte has to be MSB aligned */
diff --git a/libavformat/swfenc.c b/libavformat/swfenc.c
index 956e595965..c698600bdd 100644
--- a/libavformat/swfenc.c
+++ b/libavformat/swfenc.c
@@ -33,10 +33,10 @@ static void put_swf_tag(AVFormatContext *s, int tag)
swf->tag = tag;
/* reserve some room for the tag */
if (tag & TAG_LONG) {
- put_le16(pb, 0);
- put_le32(pb, 0);
+ avio_wl16(pb, 0);
+ avio_wl32(pb, 0);
} else {
- put_le16(pb, 0);
+ avio_wl16(pb, 0);
}
}
@@ -53,11 +53,11 @@ static void put_swf_end_tag(AVFormatContext *s)
url_fseek(pb, swf->tag_pos, SEEK_SET);
if (tag & TAG_LONG) {
tag &= ~TAG_LONG;
- put_le16(pb, (tag << 6) | 0x3f);
- put_le32(pb, tag_len - 4);
+ avio_wl16(pb, (tag << 6) | 0x3f);
+ avio_wl32(pb, tag_len - 4);
} else {
assert(tag_len < 0x3f);
- put_le16(pb, (tag << 6) | tag_len);
+ avio_wl16(pb, (tag << 6) | tag_len);
}
url_fseek(pb, pos, SEEK_SET);
}
@@ -102,7 +102,7 @@ static void put_swf_rect(AVIOContext *pb,
put_bits(&p, nbits, ymax & mask);
flush_put_bits(&p);
- put_buffer(pb, buf, put_bits_ptr(&p) - p.buf);
+ avio_write(pb, buf, put_bits_ptr(&p) - p.buf);
}
static void put_swf_line_edge(PutBitContext *pb, int dx, int dy)
@@ -167,7 +167,7 @@ static void put_swf_matrix(AVIOContext *pb,
put_bits(&p, nbits, ty);
flush_put_bits(&p);
- put_buffer(pb, buf, put_bits_ptr(&p) - p.buf);
+ avio_write(pb, buf, put_bits_ptr(&p) - p.buf);
}
static int swf_write_header(AVFormatContext *s)
@@ -239,20 +239,20 @@ static int swf_write_header(AVFormatContext *s)
version = 6; /* version 6 and above support FLV1 codec */
else
version = 4; /* version 4 for mpeg audio support */
- put_byte(pb, version);
+ avio_w8(pb, version);
- put_le32(pb, DUMMY_FILE_SIZE); /* dummy size
+ avio_wl32(pb, DUMMY_FILE_SIZE); /* dummy size
(will be patched if not streamed) */
put_swf_rect(pb, 0, width * 20, 0, height * 20);
- put_le16(pb, (rate * 256) / rate_base); /* frame rate */
+ avio_wl16(pb, (rate * 256) / rate_base); /* frame rate */
swf->duration_pos = url_ftell(pb);
- put_le16(pb, (uint16_t)(DUMMY_DURATION * (int64_t)rate / rate_base)); /* frame count */
+ avio_wl16(pb, (uint16_t)(DUMMY_DURATION * (int64_t)rate / rate_base)); /* frame count */
/* avm2/swf v9 (also v8?) files require a file attribute tag */
if (version == 9) {
put_swf_tag(s, TAG_FILEATTRIBUTES);
- put_le32(pb, 1<<3); /* set ActionScript v3/AVM2 flag */
+ avio_wl32(pb, 1<<3); /* set ActionScript v3/AVM2 flag */
put_swf_end_tag(s);
}
@@ -260,17 +260,17 @@ static int swf_write_header(AVFormatContext *s)
if (swf->video_enc && swf->video_enc->codec_id == CODEC_ID_MJPEG) {
put_swf_tag(s, TAG_DEFINESHAPE);
- put_le16(pb, SHAPE_ID); /* ID of shape */
+ avio_wl16(pb, SHAPE_ID); /* ID of shape */
/* bounding rectangle */
put_swf_rect(pb, 0, width, 0, height);
/* style info */
- put_byte(pb, 1); /* one fill style */
- put_byte(pb, 0x41); /* clipped bitmap fill */
- put_le16(pb, BITMAP_ID); /* bitmap ID */
+ avio_w8(pb, 1); /* one fill style */
+ avio_w8(pb, 0x41); /* clipped bitmap fill */
+ avio_wl16(pb, BITMAP_ID); /* bitmap ID */
/* position of the bitmap */
put_swf_matrix(pb, (int)(1.0 * (1 << FRAC_BITS)), 0,
0, (int)(1.0 * (1 << FRAC_BITS)), 0, 0);
- put_byte(pb, 0); /* no line style */
+ avio_w8(pb, 0); /* no line style */
/* shape drawing */
init_put_bits(&p, buf1, sizeof(buf1));
@@ -295,7 +295,7 @@ static int swf_write_header(AVFormatContext *s)
put_bits(&p, 5, 0);
flush_put_bits(&p);
- put_buffer(pb, buf1, put_bits_ptr(&p) - p.buf);
+ avio_write(pb, buf1, put_bits_ptr(&p) - p.buf);
put_swf_end_tag(s);
}
@@ -317,11 +317,11 @@ static int swf_write_header(AVFormatContext *s)
v |= 0x02; /* 16 bit playback */
if (swf->audio_enc->channels == 2)
v |= 0x01; /* stereo playback */
- put_byte(s->pb, v);
+ avio_w8(s->pb, v);
v |= 0x20; /* mp3 compressed */
- put_byte(s->pb, v);
- put_le16(s->pb, swf->samples_per_frame); /* avg samples per frame */
- put_le16(s->pb, 0);
+ avio_w8(s->pb, v);
+ avio_wl16(s->pb, swf->samples_per_frame); /* avg samples per frame */
+ avio_wl16(s->pb, 0);
put_swf_end_tag(s);
}
@@ -345,70 +345,70 @@ static int swf_write_video(AVFormatContext *s,
if (swf->video_frame_number == 0) {
/* create a new video object */
put_swf_tag(s, TAG_VIDEOSTREAM);
- put_le16(pb, VIDEO_ID);
+ avio_wl16(pb, VIDEO_ID);
swf->vframes_pos = url_ftell(pb);
- put_le16(pb, 15000); /* hard flash player limit */
- put_le16(pb, enc->width);
- put_le16(pb, enc->height);
- put_byte(pb, 0);
- put_byte(pb,ff_codec_get_tag(swf_codec_tags,enc->codec_id));
+ avio_wl16(pb, 15000); /* hard flash player limit */
+ avio_wl16(pb, enc->width);
+ avio_wl16(pb, enc->height);
+ avio_w8(pb, 0);
+ avio_w8(pb,ff_codec_get_tag(swf_codec_tags,enc->codec_id));
put_swf_end_tag(s);
/* place the video object for the first time */
put_swf_tag(s, TAG_PLACEOBJECT2);
- put_byte(pb, 0x36);
- put_le16(pb, 1);
- put_le16(pb, VIDEO_ID);
+ avio_w8(pb, 0x36);
+ avio_wl16(pb, 1);
+ avio_wl16(pb, VIDEO_ID);
put_swf_matrix(pb, 1 << FRAC_BITS, 0, 0, 1 << FRAC_BITS, 0, 0);
- put_le16(pb, swf->video_frame_number);
+ avio_wl16(pb, swf->video_frame_number);
put_tag(pb, "video");
- put_byte(pb, 0x00);
+ avio_w8(pb, 0x00);
put_swf_end_tag(s);
} else {
/* mark the character for update */
put_swf_tag(s, TAG_PLACEOBJECT2);
- put_byte(pb, 0x11);
- put_le16(pb, 1);
- put_le16(pb, swf->video_frame_number);
+ avio_w8(pb, 0x11);
+ avio_wl16(pb, 1);
+ avio_wl16(pb, swf->video_frame_number);
put_swf_end_tag(s);
}
/* set video frame data */
put_swf_tag(s, TAG_VIDEOFRAME | TAG_LONG);
- put_le16(pb, VIDEO_ID);
- put_le16(pb, swf->video_frame_number++);
- put_buffer(pb, buf, size);
+ avio_wl16(pb, VIDEO_ID);
+ avio_wl16(pb, swf->video_frame_number++);
+ avio_write(pb, buf, size);
put_swf_end_tag(s);
} else if (enc->codec_id == CODEC_ID_MJPEG) {
if (swf->swf_frame_number > 0) {
/* remove the shape */
put_swf_tag(s, TAG_REMOVEOBJECT);
- put_le16(pb, SHAPE_ID); /* shape ID */
- put_le16(pb, 1); /* depth */
+ avio_wl16(pb, SHAPE_ID); /* shape ID */
+ avio_wl16(pb, 1); /* depth */
put_swf_end_tag(s);
/* free the bitmap */
put_swf_tag(s, TAG_FREECHARACTER);
- put_le16(pb, BITMAP_ID);
+ avio_wl16(pb, BITMAP_ID);
put_swf_end_tag(s);
}
put_swf_tag(s, TAG_JPEG2 | TAG_LONG);
- put_le16(pb, BITMAP_ID); /* ID of the image */
+ avio_wl16(pb, BITMAP_ID); /* ID of the image */
/* a dummy jpeg header seems to be required */
- put_be32(pb, 0xffd8ffd9);
+ avio_wb32(pb, 0xffd8ffd9);
/* write the jpeg image */
- put_buffer(pb, buf, size);
+ avio_write(pb, buf, size);
put_swf_end_tag(s);
/* draw the shape */
put_swf_tag(s, TAG_PLACEOBJECT);
- put_le16(pb, SHAPE_ID); /* shape ID */
- put_le16(pb, 1); /* depth */
+ avio_wl16(pb, SHAPE_ID); /* shape ID */
+ avio_wl16(pb, 1); /* depth */
put_swf_matrix(pb, 20 << FRAC_BITS, 0, 0, 20 << FRAC_BITS, 0, 0);
put_swf_end_tag(s);
}
@@ -419,9 +419,9 @@ static int swf_write_video(AVFormatContext *s,
if (swf->audio_enc && av_fifo_size(swf->audio_fifo)) {
int frame_size = av_fifo_size(swf->audio_fifo);
put_swf_tag(s, TAG_STREAMBLOCK | TAG_LONG);
- put_le16(pb, swf->sound_samples);
- put_le16(pb, 0); // seek samples
- av_fifo_generic_read(swf->audio_fifo, pb, frame_size, &put_buffer);
+ avio_wl16(pb, swf->sound_samples);
+ avio_wl16(pb, 0); // seek samples
+ av_fifo_generic_read(swf->audio_fifo, pb, frame_size, &avio_write);
put_swf_end_tag(s);
/* update FIFO */
@@ -495,11 +495,11 @@ static int swf_write_trailer(AVFormatContext *s)
if (!url_is_streamed(s->pb) && video_enc) {
file_size = url_ftell(pb);
url_fseek(pb, 4, SEEK_SET);
- put_le32(pb, file_size);
+ avio_wl32(pb, file_size);
url_fseek(pb, swf->duration_pos, SEEK_SET);
- put_le16(pb, swf->video_frame_number);
+ avio_wl16(pb, swf->video_frame_number);
url_fseek(pb, swf->vframes_pos, SEEK_SET);
- put_le16(pb, swf->video_frame_number);
+ avio_wl16(pb, swf->video_frame_number);
url_fseek(pb, file_size, SEEK_SET);
}
return 0;
diff --git a/libavformat/vc1testenc.c b/libavformat/vc1testenc.c
index 865a157dac..65889fc55c 100644
--- a/libavformat/vc1testenc.c
+++ b/libavformat/vc1testenc.c
@@ -33,20 +33,20 @@ static int vc1test_write_header(AVFormatContext *s)
av_log(s, AV_LOG_ERROR, "Only WMV3 is accepted!\n");
return -1;
}
- put_le24(pb, 0); //frames count will be here
- put_byte(pb, 0xC5);
- put_le32(pb, 4);
- put_buffer(pb, avc->extradata, 4);
- put_le32(pb, avc->height);
- put_le32(pb, avc->width);
- put_le32(pb, 0xC);
- put_le24(pb, 0); // hrd_buffer
- put_byte(pb, 0x80); // level|cbr|res1
- put_le32(pb, 0); // hrd_rate
+ avio_wl24(pb, 0); //frames count will be here
+ avio_w8(pb, 0xC5);
+ avio_wl32(pb, 4);
+ avio_write(pb, avc->extradata, 4);
+ avio_wl32(pb, avc->height);
+ avio_wl32(pb, avc->width);
+ avio_wl32(pb, 0xC);
+ avio_wl24(pb, 0); // hrd_buffer
+ avio_w8(pb, 0x80); // level|cbr|res1
+ avio_wl32(pb, 0); // hrd_rate
if (s->streams[0]->r_frame_rate.den && s->streams[0]->r_frame_rate.num == 1)
- put_le32(pb, s->streams[0]->r_frame_rate.den);
+ avio_wl32(pb, s->streams[0]->r_frame_rate.den);
else
- put_le32(pb, 0xFFFFFFFF); //variable framerate
+ avio_wl32(pb, 0xFFFFFFFF); //variable framerate
av_set_pts_info(s->streams[0], 32, 1, 1000);
return 0;
@@ -59,9 +59,9 @@ static int vc1test_write_packet(AVFormatContext *s, AVPacket *pkt)
if (!pkt->size)
return 0;
- put_le32(pb, pkt->size | ((pkt->flags & AV_PKT_FLAG_KEY) ? 0x80000000 : 0));
- put_le32(pb, pkt->pts);
- put_buffer(pb, pkt->data, pkt->size);
+ avio_wl32(pb, pkt->size | ((pkt->flags & AV_PKT_FLAG_KEY) ? 0x80000000 : 0));
+ avio_wl32(pb, pkt->pts);
+ avio_write(pb, pkt->data, pkt->size);
put_flush_packet(pb);
ctx->frames++;
@@ -75,7 +75,7 @@ static int vc1test_write_trailer(AVFormatContext *s)
if (!url_is_streamed(s->pb)) {
url_fseek(pb, 0, SEEK_SET);
- put_le24(pb, ctx->frames);
+ avio_wl24(pb, ctx->frames);
put_flush_packet(pb);
}
return 0;
diff --git a/libavformat/vocenc.c b/libavformat/vocenc.c
index 3a17eb4e64..74cd4790e4 100644
--- a/libavformat/vocenc.c
+++ b/libavformat/vocenc.c
@@ -37,10 +37,10 @@ static int voc_write_header(AVFormatContext *s)
|| s->streams[0]->codec->codec_type != AVMEDIA_TYPE_AUDIO)
return AVERROR_PATCHWELCOME;
- put_buffer(pb, ff_voc_magic, sizeof(ff_voc_magic) - 1);
- put_le16(pb, header_size);
- put_le16(pb, version);
- put_le16(pb, ~version + 0x1234);
+ avio_write(pb, ff_voc_magic, sizeof(ff_voc_magic) - 1);
+ avio_wl16(pb, header_size);
+ avio_wl16(pb, version);
+ avio_wl16(pb, ~version + 0x1234);
return 0;
}
@@ -53,39 +53,39 @@ static int voc_write_packet(AVFormatContext *s, AVPacket *pkt)
if (!voc->param_written) {
if (enc->codec_tag > 0xFF) {
- put_byte(pb, VOC_TYPE_NEW_VOICE_DATA);
- put_le24(pb, pkt->size + 12);
- put_le32(pb, enc->sample_rate);
- put_byte(pb, enc->bits_per_coded_sample);
- put_byte(pb, enc->channels);
- put_le16(pb, enc->codec_tag);
- put_le32(pb, 0);
+ avio_w8(pb, VOC_TYPE_NEW_VOICE_DATA);
+ avio_wl24(pb, pkt->size + 12);
+ avio_wl32(pb, enc->sample_rate);
+ avio_w8(pb, enc->bits_per_coded_sample);
+ avio_w8(pb, enc->channels);
+ avio_wl16(pb, enc->codec_tag);
+ avio_wl32(pb, 0);
} else {
if (s->streams[0]->codec->channels > 1) {
- put_byte(pb, VOC_TYPE_EXTENDED);
- put_le24(pb, 4);
- put_le16(pb, 65536-256000000/(enc->sample_rate*enc->channels));
- put_byte(pb, enc->codec_tag);
- put_byte(pb, enc->channels - 1);
+ avio_w8(pb, VOC_TYPE_EXTENDED);
+ avio_wl24(pb, 4);
+ avio_wl16(pb, 65536-256000000/(enc->sample_rate*enc->channels));
+ avio_w8(pb, enc->codec_tag);
+ avio_w8(pb, enc->channels - 1);
}
- put_byte(pb, VOC_TYPE_VOICE_DATA);
- put_le24(pb, pkt->size + 2);
- put_byte(pb, 256 - 1000000 / enc->sample_rate);
- put_byte(pb, enc->codec_tag);
+ avio_w8(pb, VOC_TYPE_VOICE_DATA);
+ avio_wl24(pb, pkt->size + 2);
+ avio_w8(pb, 256 - 1000000 / enc->sample_rate);
+ avio_w8(pb, enc->codec_tag);
}
voc->param_written = 1;
} else {
- put_byte(pb, VOC_TYPE_VOICE_DATA_CONT);
- put_le24(pb, pkt->size);
+ avio_w8(pb, VOC_TYPE_VOICE_DATA_CONT);
+ avio_wl24(pb, pkt->size);
}
- put_buffer(pb, pkt->data, pkt->size);
+ avio_write(pb, pkt->data, pkt->size);
return 0;
}
static int voc_write_trailer(AVFormatContext *s)
{
- put_byte(s->pb, 0);
+ avio_w8(s->pb, 0);
return 0;
}
diff --git a/libavformat/wav.c b/libavformat/wav.c
index 9a6e7619b6..dea70fa4dc 100644
--- a/libavformat/wav.c
+++ b/libavformat/wav.c
@@ -43,7 +43,7 @@ static int wav_write_header(AVFormatContext *s)
int64_t fmt, fact;
put_tag(pb, "RIFF");
- put_le32(pb, 0); /* file length */
+ avio_wl32(pb, 0); /* file length */
put_tag(pb, "WAVE");
/* format header */
@@ -59,7 +59,7 @@ static int wav_write_header(AVFormatContext *s)
if (s->streams[0]->codec->codec_tag != 0x01 /* hence for all other than PCM */
&& !url_is_streamed(s->pb)) {
fact = ff_start_tag(pb, "fact");
- put_le32(pb, 0);
+ avio_wl32(pb, 0);
ff_end_tag(pb, fact);
}
@@ -79,7 +79,7 @@ static int wav_write_packet(AVFormatContext *s, AVPacket *pkt)
{
AVIOContext *pb = s->pb;
WAVContext *wav = s->priv_data;
- put_buffer(pb, pkt->data, pkt->size);
+ avio_write(pb, pkt->data, pkt->size);
if(pkt->pts != AV_NOPTS_VALUE) {
wav->minpts = FFMIN(wav->minpts, pkt->pts);
wav->maxpts = FFMAX(wav->maxpts, pkt->pts);
@@ -103,7 +103,7 @@ static int wav_write_trailer(AVFormatContext *s)
/* update file size */
file_size = url_ftell(pb);
url_fseek(pb, 4, SEEK_SET);
- put_le32(pb, (uint32_t)(file_size - 8));
+ avio_wl32(pb, (uint32_t)(file_size - 8));
url_fseek(pb, file_size, SEEK_SET);
put_flush_packet(pb);
@@ -115,7 +115,7 @@ static int wav_write_trailer(AVFormatContext *s)
s->streams[0]->codec->sample_rate * (int64_t)s->streams[0]->time_base.num,
s->streams[0]->time_base.den);
url_fseek(pb, wav->data-12, SEEK_SET);
- put_le32(pb, number_of_samples);
+ avio_wl32(pb, number_of_samples);
url_fseek(pb, file_size, SEEK_SET);
put_flush_packet(pb);
}
diff --git a/libavformat/yuv4mpeg.c b/libavformat/yuv4mpeg.c
index 54b77370af..01366b08b6 100644
--- a/libavformat/yuv4mpeg.c
+++ b/libavformat/yuv4mpeg.c
@@ -108,21 +108,21 @@ static int yuv4_write_packet(AVFormatContext *s, AVPacket *pkt)
av_log(s, AV_LOG_ERROR, "Error. YUV4MPEG stream header write failed.\n");
return AVERROR(EIO);
} else {
- put_buffer(pb, buf2, strlen(buf2));
+ avio_write(pb, buf2, strlen(buf2));
}
}
/* construct frame header */
m = snprintf(buf1, sizeof(buf1), "%s\n", Y4M_FRAME_MAGIC);
- put_buffer(pb, buf1, strlen(buf1));
+ avio_write(pb, buf1, strlen(buf1));
width = st->codec->width;
height = st->codec->height;
ptr = picture->data[0];
for(i=0;i<height;i++) {
- put_buffer(pb, ptr, width);
+ avio_write(pb, ptr, width);
ptr += picture->linesize[0];
}
@@ -135,11 +135,11 @@ static int yuv4_write_packet(AVFormatContext *s, AVPacket *pkt)
ptr1 = picture->data[1];
ptr2 = picture->data[2];
for(i=0;i<height;i++) { /* Cb */
- put_buffer(pb, ptr1, width);
+ avio_write(pb, ptr1, width);
ptr1 += picture->linesize[1];
}
for(i=0;i<height;i++) { /* Cr */
- put_buffer(pb, ptr2, width);
+ avio_write(pb, ptr2, width);
ptr2 += picture->linesize[2];
}
}