提交 0abdb293 编写于 作者: A Anton Khirnov 提交者: Ronald S. Bultje

lavf: use a new ffio_wfourcc macro instead of put_tag() where possible

Signed-off-by: NRonald S. Bultje <rsbultje@gmail.com>
上级 7e06e0ed
......@@ -21,6 +21,7 @@
#include "avformat.h"
#include "aiff.h"
#include "avio_internal.h"
typedef struct {
int64_t form;
......@@ -43,10 +44,10 @@ static int aiff_write_header(AVFormatContext *s)
aifc = 1;
/* FORM AIFF header */
put_tag(pb, "FORM");
ffio_wfourcc(pb, "FORM");
aiff->form = url_ftell(pb);
avio_wb32(pb, 0); /* file length */
put_tag(pb, aifc ? "AIFC" : "AIFF");
ffio_wfourcc(pb, aifc ? "AIFC" : "AIFF");
if (aifc) { // compressed audio
enc->bits_per_coded_sample = 16;
......@@ -55,13 +56,13 @@ static int aiff_write_header(AVFormatContext *s)
return -1;
}
/* Version chunk */
put_tag(pb, "FVER");
ffio_wfourcc(pb, "FVER");
avio_wb32(pb, 4);
avio_wb32(pb, 0xA2805140);
}
/* Common chunk */
put_tag(pb, "COMM");
ffio_wfourcc(pb, "COMM");
avio_wb32(pb, aifc ? 24 : 18); /* size */
avio_wb16(pb, enc->channels); /* Number of channels */
......@@ -88,7 +89,7 @@ static int aiff_write_header(AVFormatContext *s)
}
/* Sound data chunk */
put_tag(pb, "SSND");
ffio_wfourcc(pb, "SSND");
aiff->ssnd = url_ftell(pb); /* Sound chunk size */
avio_wb32(pb, 0); /* Sound samples data size */
avio_wb32(pb, 0); /* Data offset */
......
......@@ -28,6 +28,7 @@
*/
#include "avformat.h"
#include "avio_internal.h"
#include "pcm.h"
#include "riff.h"
......@@ -53,7 +54,7 @@ static int put_au_header(AVIOContext *pb, AVCodecContext *enc)
{
if(!enc->codec_tag)
return -1;
put_tag(pb, ".snd"); /* magic number */
ffio_wfourcc(pb, ".snd"); /* magic number */
avio_wb32(pb, 24); /* header size */
avio_wb32(pb, AU_UNKNOWN_SIZE); /* data size */
avio_wb32(pb, (uint32_t)enc->codec_tag); /* codec ID */
......
......@@ -20,6 +20,7 @@
*/
#include "avformat.h"
#include "avi.h"
#include "avio_internal.h"
#include "riff.h"
#include "libavutil/intreadwrite.h"
......@@ -77,9 +78,9 @@ static int64_t avi_start_new_riff(AVFormatContext *s, AVIOContext *pb,
}
avi->riff_start = ff_start_tag(pb, "RIFF");
put_tag(pb, riff_tag);
ffio_wfourcc(pb, riff_tag);
loff = ff_start_tag(pb, "LIST");
put_tag(pb, list_tag);
ffio_wfourcc(pb, list_tag);
return loff;
}
......@@ -107,7 +108,7 @@ static void avi_write_info_tag(AVIOContext *pb, const char *tag, const char *str
int len = strlen(str);
if (len > 0) {
len++;
put_tag(pb, tag);
ffio_wfourcc(pb, tag);
avio_wl32(pb, len);
avio_put_str(pb, str);
if (len & 1)
......@@ -175,7 +176,7 @@ static int avi_write_header(AVFormatContext *s)
list1 = avi_start_new_riff(s, pb, "AVI ", "hdrl");
/* avi header */
put_tag(pb, "avih");
ffio_wfourcc(pb, "avih");
avio_wl32(pb, 14 * 4);
bitrate = 0;
......@@ -221,7 +222,7 @@ static int avi_write_header(AVFormatContext *s)
for(i=0;i<n;i++) {
AVIStream *avist= s->streams[i]->priv_data;
list2 = ff_start_tag(pb, "LIST");
put_tag(pb, "strl");
ffio_wfourcc(pb, "strl");
stream = s->streams[i]->codec;
......@@ -235,10 +236,10 @@ static int avi_write_header(AVFormatContext *s)
av_log(s, AV_LOG_ERROR, "Subtitle streams other than DivX XSUB are not supported by the AVI muxer.\n");
return AVERROR_PATCHWELCOME;
}
case AVMEDIA_TYPE_VIDEO: put_tag(pb, "vids"); break;
case AVMEDIA_TYPE_AUDIO: put_tag(pb, "auds"); break;
// case AVMEDIA_TYPE_TEXT : put_tag(pb, "txts"); break;
case AVMEDIA_TYPE_DATA : put_tag(pb, "dats"); break;
case AVMEDIA_TYPE_VIDEO: ffio_wfourcc(pb, "vids"); break;
case AVMEDIA_TYPE_AUDIO: ffio_wfourcc(pb, "auds"); break;
// case AVMEDIA_TYPE_TEXT : ffio_wfourcc(pb, "txts"); break;
case AVMEDIA_TYPE_DATA : ffio_wfourcc(pb, "dats"); break;
}
if(stream->codec_type == AVMEDIA_TYPE_VIDEO ||
stream->codec_id == CODEC_ID_XSUB)
......@@ -317,7 +318,7 @@ static int avi_write_header(AVFormatContext *s)
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));
ffio_wfourcc(pb, avi_stream2fourcc(&tag[0], i, stream->codec_type));
/* dwChunkId */
avio_wl64(pb, 0); /* dwReserved[3]
avio_wl32(pb, 0); Must be 0. */
......@@ -364,8 +365,8 @@ static int avi_write_header(AVFormatContext *s)
if (!url_is_streamed(pb)) {
/* AVI could become an OpenDML one, if it grows beyond 2Gb range */
avi->odml_list = ff_start_tag(pb, "JUNK");
put_tag(pb, "odml");
put_tag(pb, "dmlh");
ffio_wfourcc(pb, "odml");
ffio_wfourcc(pb, "dmlh");
avio_wl32(pb, 248);
for (i = 0; i < 248; i+= 4)
avio_wl32(pb, 0);
......@@ -375,7 +376,7 @@ static int avi_write_header(AVFormatContext *s)
ff_end_tag(pb, list1);
list2 = ff_start_tag(pb, "LIST");
put_tag(pb, "INFO");
ffio_wfourcc(pb, "INFO");
ff_metadata_conv(&s->metadata, ff_avi_metadata_conv, NULL);
for (i = 0; *ff_avi_tags[i]; i++) {
if ((t = av_metadata_get(s->metadata, ff_avi_tags[i], NULL, AV_METADATA_MATCH_CASE)))
......@@ -390,7 +391,7 @@ static int avi_write_header(AVFormatContext *s)
ff_end_tag(pb, list2);
avi->movi_list = ff_start_tag(pb, "LIST");
put_tag(pb, "movi");
ffio_wfourcc(pb, "movi");
put_flush_packet(pb);
......@@ -419,7 +420,7 @@ static int avi_write_ix(AVFormatContext *s)
/* Writing AVI OpenDML leaf index chunk */
ix = url_ftell(pb);
put_tag(pb, &ix_tag[0]); /* ix?? */
ffio_wfourcc(pb, &ix_tag[0]); /* ix?? */
avio_wl32(pb, avist->indexes.entry * 8 + 24);
/* chunk size */
avio_wl16(pb, 2); /* wLongsPerEntry */
......@@ -427,7 +428,7 @@ static int avi_write_ix(AVFormatContext *s)
avio_w8(pb, 1); /* bIndexType (1 == AVI_INDEX_OF_CHUNKS) */
avio_wl32(pb, avist->indexes.entry);
/* nEntriesInUse */
put_tag(pb, &tag[0]); /* dwChunkId */
ffio_wfourcc(pb, &tag[0]); /* dwChunkId */
avio_wl64(pb, avi->movi_list);/* qwBaseOffset */
avio_wl32(pb, 0); /* dwReserved_3 (must be 0) */
......@@ -442,7 +443,7 @@ static int avi_write_ix(AVFormatContext *s)
/* Updating one entry in the AVI OpenDML master index */
url_fseek(pb, avist->indexes.indx_start - 8, SEEK_SET);
put_tag(pb, "indx"); /* enabling this entry */
ffio_wfourcc(pb, "indx"); /* enabling this entry */
url_fskip(pb, 8);
avio_wl32(pb, avi->riff_id); /* nEntriesInUse */
url_fskip(pb, 16*avi->riff_id);
......@@ -492,7 +493,7 @@ static int avi_write_idx1(AVFormatContext *s)
avist= s->streams[stream_id]->priv_data;
avi_stream2fourcc(&tag[0], stream_id,
s->streams[stream_id]->codec->codec_type);
put_tag(pb, &tag[0]);
ffio_wfourcc(pb, &tag[0]);
avio_wl32(pb, ie->flags);
avio_wl32(pb, ie->pos);
avio_wl32(pb, ie->len);
......@@ -601,7 +602,7 @@ static int avi_write_trailer(AVFormatContext *s)
file_size = url_ftell(pb);
url_fseek(pb, avi->odml_list - 8, SEEK_SET);
put_tag(pb, "LIST"); /* Making this AVI OpenDML one */
ffio_wfourcc(pb, "LIST"); /* Making this AVI OpenDML one */
url_fskip(pb, 16);
for (n=nb_frames=0;n<s->nb_streams;n++) {
......
......@@ -42,4 +42,6 @@ int ffio_read_partial(AVIOContext *s, unsigned char *buf, int size);
void ffio_fill(AVIOContext *s, int b, int count);
#define ffio_wfourcc(pb, str) avio_wl32(pb, MKTAG((str)[0], (str)[1], (str)[2], (str)[3]))
#endif // AVFORMAT_AVIO_INTERNAL_H
......@@ -23,6 +23,7 @@
#include "libavutil/intreadwrite.h"
#include "libavutil/avstring.h"
#include "avformat.h"
#include "avio_internal.h"
#include <strings.h>
typedef struct {
......@@ -383,13 +384,13 @@ static int write_packet(AVFormatContext *s, AVPacket *pkt)
if(pkt->size < 8 || AV_RL32(pkt->data+4) != MKTAG('j','p','2','c'))
goto error;
avio_wb32(pb[0], 12);
put_tag (pb[0], "jP ");
ffio_wfourcc(pb[0], "jP ");
avio_wb32(pb[0], 0x0D0A870A); // signature
avio_wb32(pb[0], 20);
put_tag (pb[0], "ftyp");
put_tag (pb[0], "jp2 ");
ffio_wfourcc(pb[0], "ftyp");
ffio_wfourcc(pb[0], "jp2 ");
avio_wb32(pb[0], 0);
put_tag (pb[0], "jp2 ");
ffio_wfourcc(pb[0], "jp2 ");
avio_write(pb[0], st->codec->extradata, st->codec->extradata_size);
}else if(pkt->size < 8 ||
(!st->codec->extradata_size &&
......
......@@ -19,6 +19,7 @@
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
*/
#include "avformat.h"
#include "avio_internal.h"
#include "pcm.h"
#include "riff.h"
......@@ -70,7 +71,7 @@ static int mmf_write_header(AVFormatContext *s)
return -1;
}
put_tag(pb, "MMMD");
ffio_wfourcc(pb, "MMMD");
avio_wb32(pb, 0);
pos = ff_start_tag(pb, "CNTI");
avio_w8(pb, 0); /* class */
......@@ -91,7 +92,7 @@ static int mmf_write_header(AVFormatContext *s)
avio_w8(pb, 2); /* time base d */
avio_w8(pb, 2); /* time base g */
put_tag(pb, "Atsq");
ffio_wfourcc(pb, "Atsq");
avio_wb32(pb, 16);
mmf->atsqpos = url_ftell(pb);
/* Will be filled on close */
......
此差异已折叠。
......@@ -25,6 +25,7 @@
#include "libavcodec/bytestream.h"
#include "libavcodec/flac.h"
#include "avformat.h"
#include "avio_internal.h"
#include "internal.h"
#include "vorbiscomment.h"
......@@ -85,7 +86,7 @@ static int ogg_write_page(AVFormatContext *s, OGGPage *page, int extra_flags)
if (ret < 0)
return ret;
init_checksum(pb, ff_crc04C11DB7_update, 0);
put_tag(pb, "OggS");
ffio_wfourcc(pb, "OggS");
avio_w8(pb, 0);
avio_w8(pb, page->flags | extra_flags);
avio_wl64(pb, page->granule);
......
......@@ -21,6 +21,7 @@
#include "libavcodec/avcodec.h"
#include "avformat.h"
#include "avio_internal.h"
#include "riff.h"
#include "libavcodec/bytestream.h"
......@@ -321,7 +322,7 @@ const AVCodecTag ff_codec_wav_tags[] = {
#if CONFIG_MUXERS
int64_t ff_start_tag(AVIOContext *pb, const char *tag)
{
put_tag(pb, tag);
ffio_wfourcc(pb, tag);
avio_wl32(pb, 0);
return url_ftell(pb);
}
......
......@@ -19,6 +19,7 @@
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
*/
#include "avformat.h"
#include "avio_internal.h"
#include "rm.h"
typedef struct {
......@@ -74,13 +75,13 @@ static int rv10_write_header(AVFormatContext *ctx,
start_ptr = s->buf_ptr;
put_tag(s, ".RMF");
ffio_wfourcc(s, ".RMF");
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");
ffio_wfourcc(s,"PROP");
avio_wb32(s, 50);
avio_wb16(s, 0);
packet_max_size = 0;
......@@ -123,7 +124,7 @@ static int rv10_write_header(AVFormatContext *ctx,
/* comments */
put_tag(s,"CONT");
ffio_wfourcc(s,"CONT");
size = 4 * 2 + 10;
for(i=0; i<FF_ARRAY_ELEMS(ff_rm_metadata); i++) {
tag = av_metadata_get(ctx->metadata, ff_rm_metadata[i], NULL, 0);
......@@ -151,7 +152,7 @@ static int rv10_write_header(AVFormatContext *ctx,
codec_data_size = 34;
}
put_tag(s,"MDPR");
ffio_wfourcc(s,"MDPR");
size = 10 + 9 * 4 + strlen(desc) + strlen(mimetype) + codec_data_size;
avio_wb32(s, size);
avio_wb16(s, 0);
......@@ -186,7 +187,7 @@ static int rv10_write_header(AVFormatContext *ctx,
put_tag(s, ".ra");
avio_w8(s, 0xfd);
avio_wb32(s, 0x00040000); /* version */
put_tag(s, ".ra4");
ffio_wfourcc(s, ".ra4");
avio_wb32(s, 0x01b53530); /* stream length */
avio_wb16(s, 4); /* unknown */
avio_wb32(s, 0x39); /* header size */
......@@ -239,10 +240,11 @@ static int rv10_write_header(AVFormatContext *ctx,
} else {
/* video codec info */
avio_wb32(s,34); /* size */
ffio_wfourcc(s, "VIDO");
if(stream->enc->codec_id == CODEC_ID_RV10)
put_tag(s,"VIDORV10");
ffio_wfourcc(s,"RV10");
else
put_tag(s,"VIDORV20");
ffio_wfourcc(s,"RV20");
avio_wb16(s, stream->enc->width);
avio_wb16(s, stream->enc->height);
avio_wb16(s, (int) stream->frame_rate); /* frames per seconds ? */
......@@ -270,7 +272,7 @@ static int rv10_write_header(AVFormatContext *ctx,
data_offset_ptr[3] = data_pos;
/* data stream */
put_tag(s,"DATA");
ffio_wfourcc(s, "DATA");
avio_wb32(s,data_size + 10 + 8);
avio_wb16(s,0);
......
......@@ -31,6 +31,7 @@
#include "libavutil/intreadwrite.h"
#include "avformat.h"
#include "avio_internal.h"
#include "sox.h"
typedef struct {
......@@ -53,14 +54,14 @@ static int sox_write_header(AVFormatContext *s)
sox->header_size = SOX_FIXED_HDR + comment_size;
if (enc->codec_id == CODEC_ID_PCM_S32LE) {
put_tag(pb, ".SoX");
ffio_wfourcc(pb, ".SoX");
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.");
ffio_wfourcc(pb, "XoS.");
avio_wb32(pb, sox->header_size);
avio_wb64(pb, 0); /* number of samples */
avio_wb64(pb, av_dbl2int(enc->sample_rate));
......
......@@ -23,6 +23,7 @@
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
*/
#include "avformat.h"
#include "avio_internal.h"
#include "pcm.h"
#include "riff.h"
......@@ -42,9 +43,9 @@ static int wav_write_header(AVFormatContext *s)
AVIOContext *pb = s->pb;
int64_t fmt, fact;
put_tag(pb, "RIFF");
ffio_wfourcc(pb, "RIFF");
avio_wl32(pb, 0); /* file length */
put_tag(pb, "WAVE");
ffio_wfourcc(pb, "WAVE");
/* format header */
fmt = ff_start_tag(pb, "fmt ");
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册