Merge commit '21732063a346475eb22c332b27e8216b79f9ad4a'
* commit '21732063a346475eb22c332b27e8216b79f9ad4a': movenc: K&R formatting cosmetics Conflicts: libavformat/movenc.c Merged-by: Michael Niedermayer <michaelni@gmx.at>
This commit is contained in:
commit
4cd066b69c
@ -117,10 +117,10 @@ static int mov_write_stco_tag(AVIOContext *pb, MOVTrack *track)
|
||||
ffio_wfourcc(pb, "stco");
|
||||
avio_wb32(pb, 0); /* version & flags */
|
||||
avio_wb32(pb, track->chunkCount); /* entry count */
|
||||
for (i=0; i<track->entry; i++) {
|
||||
if(!track->cluster[i].chunkNum)
|
||||
for (i = 0; i < track->entry; i++) {
|
||||
if (!track->cluster[i].chunkNum)
|
||||
continue;
|
||||
if(mode64 == 1)
|
||||
if (mode64 == 1)
|
||||
avio_wb64(pb, track->cluster[i].pos + track->data_offset);
|
||||
else
|
||||
avio_wb32(pb, track->cluster[i].pos + track->data_offset);
|
||||
@ -139,27 +139,25 @@ static int mov_write_stsz_tag(AVIOContext *pb, MOVTrack *track)
|
||||
ffio_wfourcc(pb, "stsz");
|
||||
avio_wb32(pb, 0); /* version & flags */
|
||||
|
||||
for (i=0; i<track->entry; i++) {
|
||||
tst = track->cluster[i].size/track->cluster[i].entries;
|
||||
if(oldtst != -1 && tst != oldtst) {
|
||||
for (i = 0; i < track->entry; i++) {
|
||||
tst = track->cluster[i].size / track->cluster[i].entries;
|
||||
if (oldtst != -1 && tst != oldtst)
|
||||
equalChunks = 0;
|
||||
}
|
||||
oldtst = tst;
|
||||
entries += track->cluster[i].entries;
|
||||
}
|
||||
if (equalChunks && track->entry) {
|
||||
int sSize = track->entry ? track->cluster[0].size/track->cluster[0].entries : 0;
|
||||
int sSize = track->entry ? track->cluster[0].size / track->cluster[0].entries : 0;
|
||||
sSize = FFMAX(1, sSize); // adpcm mono case could make sSize == 0
|
||||
avio_wb32(pb, sSize); // sample size
|
||||
avio_wb32(pb, entries); // sample count
|
||||
}
|
||||
else {
|
||||
} else {
|
||||
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++) {
|
||||
for (i = 0; i < track->entry; i++) {
|
||||
for (j = 0; j < track->cluster[i].entries; j++) {
|
||||
avio_wb32(pb, track->cluster[i].size /
|
||||
track->cluster[i].entries);
|
||||
track->cluster[i].entries);
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -178,9 +176,8 @@ static int mov_write_stsc_tag(AVIOContext *pb, MOVTrack *track)
|
||||
avio_wb32(pb, 0); // version & flags
|
||||
entryPos = avio_tell(pb);
|
||||
avio_wb32(pb, track->chunkCount); // entry count
|
||||
for (i=0; i<track->entry; i++) {
|
||||
if (oldval != track->cluster[i].samples_in_chunk && track->cluster[i].chunkNum)
|
||||
{
|
||||
for (i = 0; i < track->entry; i++) {
|
||||
if (oldval != track->cluster[i].samples_in_chunk && track->cluster[i].chunkNum) {
|
||||
avio_wb32(pb, track->cluster[i].chunkNum); // first chunk
|
||||
avio_wb32(pb, track->cluster[i].samples_in_chunk); // samples per chunk
|
||||
avio_wb32(pb, 0x1); // sample description index
|
||||
@ -207,9 +204,9 @@ static int mov_write_stss_tag(AVIOContext *pb, MOVTrack *track, uint32_t flag)
|
||||
avio_wb32(pb, 0); // version & flags
|
||||
entryPos = avio_tell(pb);
|
||||
avio_wb32(pb, track->entry); // entry count
|
||||
for (i=0; i<track->entry; i++) {
|
||||
for (i = 0; i < track->entry; i++) {
|
||||
if (track->cluster[i].flags & flag) {
|
||||
avio_wb32(pb, i+1);
|
||||
avio_wb32(pb, i + 1);
|
||||
index++;
|
||||
}
|
||||
}
|
||||
@ -269,7 +266,7 @@ static int mov_write_ac3_tag(AVIOContext *pb, MOVTrack *track)
|
||||
put_bits(&pbc, 3, bsmod);
|
||||
put_bits(&pbc, 3, acmod);
|
||||
put_bits(&pbc, 1, lfeon);
|
||||
put_bits(&pbc, 5, frmsizecod>>1); // bit_rate_code
|
||||
put_bits(&pbc, 5, frmsizecod >> 1); // bit_rate_code
|
||||
put_bits(&pbc, 5, 0); // reserved
|
||||
|
||||
flush_put_bits(&pbc);
|
||||
@ -308,8 +305,8 @@ static void put_descr(AVIOContext *pb, int tag, unsigned int size)
|
||||
{
|
||||
int i = 3;
|
||||
avio_w8(pb, tag);
|
||||
for(; i>0; i--)
|
||||
avio_w8(pb, (size>>(7*i)) | 0x80);
|
||||
for (; i > 0; i--)
|
||||
avio_w8(pb, (size >> (7 * i)) | 0x80);
|
||||
avio_w8(pb, size & 0x7F);
|
||||
}
|
||||
|
||||
@ -352,7 +349,7 @@ static int mov_write_esds_tag(AVIOContext *pb, MOVTrack *track) // Basic
|
||||
|
||||
// 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)
|
||||
if (track->enc->codec_type == AVMEDIA_TYPE_AUDIO)
|
||||
avio_w8(pb, 0x15); // flags (= Audiostream)
|
||||
else
|
||||
avio_w8(pb, 0x11); // flags (= Visualstream)
|
||||
@ -708,7 +705,7 @@ static int mov_write_audio_tag(AVIOContext *pb, MOVTrack *track)
|
||||
avio_wb16(pb, 0); /* Reserved */
|
||||
}
|
||||
|
||||
if(version == 1) { /* SoundDescription V1 extended info */
|
||||
if (version == 1) { /* SoundDescription V1 extended info */
|
||||
if (mov_pcm_le_gt16(track->enc->codec_id) ||
|
||||
mov_pcm_be_gt16(track->enc->codec_id))
|
||||
avio_wb32(pb, 1); /* must be 1 for uncompressed formats */
|
||||
@ -719,24 +716,24 @@ static int mov_write_audio_tag(AVIOContext *pb, MOVTrack *track)
|
||||
avio_wb32(pb, 2); /* Bytes per sample */
|
||||
}
|
||||
|
||||
if(track->mode == MODE_MOV &&
|
||||
(track->enc->codec_id == AV_CODEC_ID_AAC ||
|
||||
track->enc->codec_id == AV_CODEC_ID_AC3 ||
|
||||
track->enc->codec_id == AV_CODEC_ID_AMR_NB ||
|
||||
track->enc->codec_id == AV_CODEC_ID_ALAC ||
|
||||
track->enc->codec_id == AV_CODEC_ID_ADPCM_MS ||
|
||||
track->enc->codec_id == AV_CODEC_ID_ADPCM_IMA_WAV ||
|
||||
track->enc->codec_id == AV_CODEC_ID_QDM2 ||
|
||||
(mov_pcm_le_gt16(track->enc->codec_id) && version==1) ||
|
||||
(mov_pcm_be_gt16(track->enc->codec_id) && version==1)))
|
||||
if (track->mode == MODE_MOV &&
|
||||
(track->enc->codec_id == AV_CODEC_ID_AAC ||
|
||||
track->enc->codec_id == AV_CODEC_ID_AC3 ||
|
||||
track->enc->codec_id == AV_CODEC_ID_AMR_NB ||
|
||||
track->enc->codec_id == AV_CODEC_ID_ALAC ||
|
||||
track->enc->codec_id == AV_CODEC_ID_ADPCM_MS ||
|
||||
track->enc->codec_id == AV_CODEC_ID_ADPCM_IMA_WAV ||
|
||||
track->enc->codec_id == AV_CODEC_ID_QDM2 ||
|
||||
(mov_pcm_le_gt16(track->enc->codec_id) && version==1) ||
|
||||
(mov_pcm_be_gt16(track->enc->codec_id) && version==1)))
|
||||
mov_write_wave_tag(pb, track);
|
||||
else if(track->tag == MKTAG('m','p','4','a'))
|
||||
else if (track->tag == MKTAG('m','p','4','a'))
|
||||
mov_write_esds_tag(pb, track);
|
||||
else if(track->enc->codec_id == AV_CODEC_ID_AMR_NB)
|
||||
else if (track->enc->codec_id == AV_CODEC_ID_AMR_NB)
|
||||
mov_write_amr_tag(pb, track);
|
||||
else if(track->enc->codec_id == AV_CODEC_ID_AC3)
|
||||
else if (track->enc->codec_id == AV_CODEC_ID_AC3)
|
||||
mov_write_ac3_tag(pb, track);
|
||||
else if(track->enc->codec_id == AV_CODEC_ID_ALAC)
|
||||
else if (track->enc->codec_id == AV_CODEC_ID_ALAC)
|
||||
mov_write_extradata_tag(pb, track);
|
||||
else if (track->enc->codec_id == AV_CODEC_ID_WMAPRO)
|
||||
mov_write_wfex_tag(pb, track);
|
||||
@ -797,7 +794,7 @@ static int mov_write_avid_tag(AVIOContext *pb, MOVTrack *track)
|
||||
avio_wb32(pb, track->enc->width);
|
||||
/* values below are based on samples created with quicktime and avid codecs */
|
||||
if (track->vos_data[5] & 2) { // interlaced
|
||||
avio_wb32(pb, track->enc->height/2);
|
||||
avio_wb32(pb, track->enc->height / 2);
|
||||
avio_wb32(pb, 2); /* unknown */
|
||||
avio_wb32(pb, 0); /* unknown */
|
||||
avio_wb32(pb, 4); /* unknown */
|
||||
@ -831,18 +828,18 @@ static int mp4_get_codec_tag(AVFormatContext *s, MOVTrack *track)
|
||||
else if (track->enc->codec_id == AV_CODEC_ID_DIRAC) tag = MKTAG('d','r','a','c');
|
||||
else if (track->enc->codec_id == AV_CODEC_ID_MOV_TEXT) tag = MKTAG('t','x','3','g');
|
||||
else if (track->enc->codec_id == AV_CODEC_ID_VC1) tag = MKTAG('v','c','-','1');
|
||||
else if (track->enc->codec_type == AVMEDIA_TYPE_VIDEO) tag = MKTAG('m','p','4','v');
|
||||
else if (track->enc->codec_type == AVMEDIA_TYPE_AUDIO) tag = MKTAG('m','p','4','a');
|
||||
else if (track->enc->codec_type == AVMEDIA_TYPE_VIDEO) tag = MKTAG('m','p','4','v');
|
||||
else if (track->enc->codec_type == AVMEDIA_TYPE_AUDIO) tag = MKTAG('m','p','4','a');
|
||||
|
||||
return tag;
|
||||
}
|
||||
|
||||
static const AVCodecTag codec_ipod_tags[] = {
|
||||
{ AV_CODEC_ID_H264, MKTAG('a','v','c','1') },
|
||||
{ AV_CODEC_ID_MPEG4, MKTAG('m','p','4','v') },
|
||||
{ AV_CODEC_ID_AAC, MKTAG('m','p','4','a') },
|
||||
{ AV_CODEC_ID_ALAC, MKTAG('a','l','a','c') },
|
||||
{ AV_CODEC_ID_AC3, MKTAG('a','c','-','3') },
|
||||
{ AV_CODEC_ID_H264, MKTAG('a','v','c','1') },
|
||||
{ AV_CODEC_ID_MPEG4, MKTAG('m','p','4','v') },
|
||||
{ AV_CODEC_ID_AAC, MKTAG('m','p','4','a') },
|
||||
{ AV_CODEC_ID_ALAC, MKTAG('a','l','a','c') },
|
||||
{ AV_CODEC_ID_AC3, MKTAG('a','c','-','3') },
|
||||
{ AV_CODEC_ID_MOV_TEXT, MKTAG('t','x','3','g') },
|
||||
{ AV_CODEC_ID_MOV_TEXT, MKTAG('t','e','x','t') },
|
||||
{ AV_CODEC_ID_NONE, 0 },
|
||||
@ -854,8 +851,8 @@ static int ipod_get_codec_tag(AVFormatContext *s, MOVTrack *track)
|
||||
|
||||
// keep original tag for subs, ipod supports both formats
|
||||
if (!(track->enc->codec_type == AVMEDIA_TYPE_SUBTITLE &&
|
||||
(tag == MKTAG('t','x','3','g') ||
|
||||
tag == MKTAG('t','e','x','t'))))
|
||||
(tag == MKTAG('t', 'x', '3', 'g') ||
|
||||
tag == MKTAG('t', 'e', 'x', 't'))))
|
||||
tag = ff_codec_get_tag(codec_ipod_tags, track->enc->codec_id);
|
||||
|
||||
if (!av_match_ext(s->filename, "m4a") && !av_match_ext(s->filename, "m4v"))
|
||||
@ -872,16 +869,16 @@ static int mov_get_dv_codec_tag(AVFormatContext *s, MOVTrack *track)
|
||||
if (track->enc->width == 720) { /* SD */
|
||||
if (track->enc->height == 480) { /* NTSC */
|
||||
if (track->enc->pix_fmt == AV_PIX_FMT_YUV422P) tag = MKTAG('d','v','5','n');
|
||||
else tag = MKTAG('d','v','c',' ');
|
||||
else tag = MKTAG('d','v','c',' ');
|
||||
}else if (track->enc->pix_fmt == AV_PIX_FMT_YUV422P) tag = MKTAG('d','v','5','p');
|
||||
else if (track->enc->pix_fmt == AV_PIX_FMT_YUV420P) tag = MKTAG('d','v','c','p');
|
||||
else tag = MKTAG('d','v','p','p');
|
||||
else tag = MKTAG('d','v','p','p');
|
||||
} else if (track->enc->height == 720) { /* HD 720 line */
|
||||
if (track->enc->time_base.den == 50) tag = MKTAG('d','v','h','q');
|
||||
else tag = MKTAG('d','v','h','p');
|
||||
if (track->enc->time_base.den == 50) tag = MKTAG('d','v','h','q');
|
||||
else tag = MKTAG('d','v','h','p');
|
||||
} else if (track->enc->height == 1080) { /* HD 1080 line */
|
||||
if (track->enc->time_base.den == 25) tag = MKTAG('d','v','h','5');
|
||||
else tag = MKTAG('d','v','h','6');
|
||||
if (track->enc->time_base.den == 25) tag = MKTAG('d','v','h','5');
|
||||
else tag = MKTAG('d','v','h','6');
|
||||
} else {
|
||||
av_log(s, AV_LOG_ERROR, "unsupported height for dv codec\n");
|
||||
return 0;
|
||||
@ -968,12 +965,12 @@ static int mov_get_codec_tag(AVFormatContext *s, MOVTrack *track)
|
||||
}
|
||||
|
||||
static const AVCodecTag codec_3gp_tags[] = {
|
||||
{ AV_CODEC_ID_H263, MKTAG('s','2','6','3') },
|
||||
{ AV_CODEC_ID_H264, MKTAG('a','v','c','1') },
|
||||
{ AV_CODEC_ID_MPEG4, MKTAG('m','p','4','v') },
|
||||
{ AV_CODEC_ID_AAC, MKTAG('m','p','4','a') },
|
||||
{ AV_CODEC_ID_AMR_NB, MKTAG('s','a','m','r') },
|
||||
{ AV_CODEC_ID_AMR_WB, MKTAG('s','a','w','b') },
|
||||
{ AV_CODEC_ID_H263, MKTAG('s','2','6','3') },
|
||||
{ AV_CODEC_ID_H264, MKTAG('a','v','c','1') },
|
||||
{ AV_CODEC_ID_MPEG4, MKTAG('m','p','4','v') },
|
||||
{ AV_CODEC_ID_AAC, MKTAG('m','p','4','a') },
|
||||
{ AV_CODEC_ID_AMR_NB, MKTAG('s','a','m','r') },
|
||||
{ AV_CODEC_ID_AMR_WB, MKTAG('s','a','w','b') },
|
||||
{ AV_CODEC_ID_MOV_TEXT, MKTAG('t','x','3','g') },
|
||||
{ AV_CODEC_ID_NONE, 0 },
|
||||
};
|
||||
@ -1084,7 +1081,7 @@ static int mov_write_video_tag(AVIOContext *pb, MOVTrack *track)
|
||||
avio_wb16(pb, 0); /* Codec stream revision (=0) */
|
||||
if (track->mode == MODE_MOV) {
|
||||
ffio_wfourcc(pb, "FFMP"); /* Vendor */
|
||||
if(track->enc->codec_id == AV_CODEC_ID_RAWVIDEO) {
|
||||
if (track->enc->codec_id == AV_CODEC_ID_RAWVIDEO) {
|
||||
avio_wb32(pb, 0); /* Temporal Quality */
|
||||
avio_wb32(pb, 0x400); /* Spatial Quality = lossless*/
|
||||
} else {
|
||||
@ -1105,7 +1102,7 @@ static int mov_write_video_tag(AVIOContext *pb, MOVTrack *track)
|
||||
|
||||
/* 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)
|
||||
av_strlcpy(compressor_name,track->enc->codec->name,32);
|
||||
av_strlcpy(compressor_name, track->enc->codec->name, 32);
|
||||
avio_w8(pb, strlen(compressor_name));
|
||||
avio_write(pb, compressor_name, 31);
|
||||
|
||||
@ -1114,19 +1111,19 @@ static int mov_write_video_tag(AVIOContext *pb, MOVTrack *track)
|
||||
else
|
||||
avio_wb16(pb, 0x18); /* Reserved */
|
||||
avio_wb16(pb, 0xffff); /* Reserved */
|
||||
if(track->tag == MKTAG('m','p','4','v'))
|
||||
if (track->tag == MKTAG('m','p','4','v'))
|
||||
mov_write_esds_tag(pb, track);
|
||||
else if(track->enc->codec_id == AV_CODEC_ID_H263)
|
||||
else if (track->enc->codec_id == AV_CODEC_ID_H263)
|
||||
mov_write_d263_tag(pb);
|
||||
else if(track->enc->codec_id == AV_CODEC_ID_AVUI ||
|
||||
else if (track->enc->codec_id == AV_CODEC_ID_AVUI ||
|
||||
track->enc->codec_id == AV_CODEC_ID_SVQ3) {
|
||||
mov_write_extradata_tag(pb, track);
|
||||
avio_wb32(pb, 0);
|
||||
} else if(track->enc->codec_id == AV_CODEC_ID_DNXHD)
|
||||
} else if (track->enc->codec_id == AV_CODEC_ID_DNXHD)
|
||||
mov_write_avid_tag(pb, track);
|
||||
else if(track->enc->codec_id == AV_CODEC_ID_H264) {
|
||||
else if (track->enc->codec_id == AV_CODEC_ID_H264) {
|
||||
mov_write_avcc_tag(pb, track);
|
||||
if(track->mode == MODE_IPOD)
|
||||
if (track->mode == MODE_IPOD)
|
||||
mov_write_uuid_tag_ipod(pb);
|
||||
} else if (track->enc->codec_id == AV_CODEC_ID_VC1 && track->vos_len > 0)
|
||||
mov_write_dvc1_tag(pb, track);
|
||||
@ -1222,7 +1219,7 @@ static int mov_write_ctts_tag(AVIOContext *pb, MOVTrack *track)
|
||||
ctts_entries = av_malloc((track->entry + 1) * sizeof(*ctts_entries)); /* worst case */
|
||||
ctts_entries[0].count = 1;
|
||||
ctts_entries[0].duration = track->cluster[0].cts;
|
||||
for (i=1; i<track->entry; i++) {
|
||||
for (i = 1; i < track->entry; i++) {
|
||||
if (track->cluster[i].cts == ctts_entries[entries].duration) {
|
||||
ctts_entries[entries].count++; /* compress */
|
||||
} else {
|
||||
@ -1237,7 +1234,7 @@ static int mov_write_ctts_tag(AVIOContext *pb, MOVTrack *track)
|
||||
ffio_wfourcc(pb, "ctts");
|
||||
avio_wb32(pb, 0); /* version & flags */
|
||||
avio_wb32(pb, entries); /* entry count */
|
||||
for (i=0; i<entries; i++) {
|
||||
for (i = 0; i < entries; i++) {
|
||||
avio_wb32(pb, ctts_entries[i].count);
|
||||
avio_wb32(pb, ctts_entries[i].duration);
|
||||
}
|
||||
@ -1262,7 +1259,7 @@ static int mov_write_stts_tag(AVIOContext *pb, MOVTrack *track)
|
||||
stts_entries = track->entry ?
|
||||
av_malloc(track->entry * sizeof(*stts_entries)) : /* worst case */
|
||||
NULL;
|
||||
for (i=0; i<track->entry; i++) {
|
||||
for (i = 0; i < track->entry; i++) {
|
||||
int duration = get_cluster_duration(track, i);
|
||||
if (i && duration == stts_entries[entries].duration) {
|
||||
stts_entries[entries].count++; /* compress */
|
||||
@ -1279,7 +1276,7 @@ static int mov_write_stts_tag(AVIOContext *pb, MOVTrack *track)
|
||||
ffio_wfourcc(pb, "stts");
|
||||
avio_wb32(pb, 0); /* version & flags */
|
||||
avio_wb32(pb, entries); /* entry count */
|
||||
for (i=0; i<entries; i++) {
|
||||
for (i = 0; i < entries; i++) {
|
||||
avio_wb32(pb, stts_entries[i].count);
|
||||
avio_wb32(pb, stts_entries[i].duration);
|
||||
}
|
||||
@ -1434,17 +1431,17 @@ static int mov_write_hdlr_tag(AVIOContext *pb, MOVTrack *track)
|
||||
int64_t pos = avio_tell(pb);
|
||||
|
||||
if (!track) { /* no media --> data handler */
|
||||
hdlr = "dhlr";
|
||||
hdlr = "dhlr";
|
||||
hdlr_type = "url ";
|
||||
descr = "DataHandler";
|
||||
descr = "DataHandler";
|
||||
} else {
|
||||
hdlr = (track->mode == MODE_MOV) ? "mhlr" : "\0\0\0\0";
|
||||
if (track->enc->codec_type == AVMEDIA_TYPE_VIDEO) {
|
||||
hdlr_type = "vide";
|
||||
descr = "VideoHandler";
|
||||
descr = "VideoHandler";
|
||||
} else if (track->enc->codec_type == AVMEDIA_TYPE_AUDIO) {
|
||||
hdlr_type = "soun";
|
||||
descr = "SoundHandler";
|
||||
descr = "SoundHandler";
|
||||
} else if (track->enc->codec_type == AVMEDIA_TYPE_SUBTITLE) {
|
||||
if (track->tag == MKTAG('c','6','0','8')) {
|
||||
hdlr_type = "clcp";
|
||||
@ -1459,11 +1456,11 @@ static int mov_write_hdlr_tag(AVIOContext *pb, MOVTrack *track)
|
||||
descr = "TimeCodeHandler";
|
||||
} else if (track->enc->codec_tag == MKTAG('r','t','p',' ')) {
|
||||
hdlr_type = "hint";
|
||||
descr = "HintHandler";
|
||||
descr = "HintHandler";
|
||||
} else {
|
||||
hdlr = "dhlr";
|
||||
hdlr = "dhlr";
|
||||
hdlr_type = "url ";
|
||||
descr = "DataHandler";
|
||||
descr = "DataHandler";
|
||||
}
|
||||
}
|
||||
|
||||
@ -1472,9 +1469,9 @@ static int mov_write_hdlr_tag(AVIOContext *pb, MOVTrack *track)
|
||||
avio_wb32(pb, 0); /* Version & flags */
|
||||
avio_write(pb, hdlr, 4); /* handler */
|
||||
ffio_wfourcc(pb, hdlr_type); /* handler type */
|
||||
avio_wb32(pb ,0); /* reserved */
|
||||
avio_wb32(pb ,0); /* reserved */
|
||||
avio_wb32(pb ,0); /* reserved */
|
||||
avio_wb32(pb, 0); /* reserved */
|
||||
avio_wb32(pb, 0); /* reserved */
|
||||
avio_wb32(pb, 0); /* reserved */
|
||||
if (!track || track->mode == MODE_MOV)
|
||||
avio_w8(pb, strlen(descr)); /* pascal string */
|
||||
avio_write(pb, descr, strlen(descr)); /* handler description */
|
||||
@ -1503,7 +1500,7 @@ static int mov_write_minf_tag(AVIOContext *pb, MOVTrack *track)
|
||||
int64_t pos = avio_tell(pb);
|
||||
avio_wb32(pb, 0); /* size */
|
||||
ffio_wfourcc(pb, "minf");
|
||||
if(track->enc->codec_type == AVMEDIA_TYPE_VIDEO)
|
||||
if (track->enc->codec_type == AVMEDIA_TYPE_VIDEO)
|
||||
mov_write_vmhd_tag(pb);
|
||||
else if (track->enc->codec_type == AVMEDIA_TYPE_AUDIO)
|
||||
mov_write_smhd_tag(pb);
|
||||
@ -1551,11 +1548,11 @@ static int mov_write_mdhd_tag(AVIOContext *pb, MOVTrack *track)
|
||||
avio_wb16(pb, track->language); /* language */
|
||||
avio_wb16(pb, 0); /* reserved (quality) */
|
||||
|
||||
if(version!=0 && track->mode == MODE_MOV){
|
||||
if (version != 0 && track->mode == MODE_MOV) {
|
||||
av_log(NULL, AV_LOG_ERROR,
|
||||
"FATAL error, file duration too long for timebase, this file will not be\n"
|
||||
"playable with quicktime. Choose a different timebase or a different\n"
|
||||
"container format\n");
|
||||
"FATAL error, file duration too long for timebase, this file will not be\n"
|
||||
"playable with quicktime. Choose a different timebase or a different\n"
|
||||
"container format\n");
|
||||
}
|
||||
|
||||
return 32;
|
||||
@ -1623,7 +1620,7 @@ static int mov_write_tkhd_tag(AVIOContext *pb, MOVTrack *track, AVStream *st)
|
||||
avio_wb16(pb, 0); /* layer */
|
||||
avio_wb16(pb, st ? st->codec->codec_type : 0); /* alternate group) */
|
||||
/* Volume, only for audio */
|
||||
if(track->enc->codec_type == AVMEDIA_TYPE_AUDIO)
|
||||
if (track->enc->codec_type == AVMEDIA_TYPE_AUDIO)
|
||||
avio_wb16(pb, 0x0100);
|
||||
else
|
||||
avio_wb16(pb, 0);
|
||||
@ -1644,20 +1641,19 @@ static int mov_write_tkhd_tag(AVIOContext *pb, MOVTrack *track, AVStream *st)
|
||||
write_matrix(pb, 1, 0, 0, 1, 0, 0);
|
||||
}
|
||||
/* Track width and height, for visual only */
|
||||
if(st && (track->enc->codec_type == AVMEDIA_TYPE_VIDEO ||
|
||||
track->enc->codec_type == AVMEDIA_TYPE_SUBTITLE)) {
|
||||
if(track->mode == MODE_MOV) {
|
||||
if (st && (track->enc->codec_type == AVMEDIA_TYPE_VIDEO ||
|
||||
track->enc->codec_type == AVMEDIA_TYPE_SUBTITLE)) {
|
||||
if (track->mode == MODE_MOV) {
|
||||
avio_wb32(pb, track->enc->width << 16);
|
||||
avio_wb32(pb, track->height << 16);
|
||||
} else {
|
||||
double sample_aspect_ratio = av_q2d(st->sample_aspect_ratio);
|
||||
if(!sample_aspect_ratio || track->height != track->enc->height)
|
||||
if (!sample_aspect_ratio || track->height != track->enc->height)
|
||||
sample_aspect_ratio = 1;
|
||||
avio_wb32(pb, sample_aspect_ratio * track->enc->width*0x10000);
|
||||
avio_wb32(pb, track->height*0x10000);
|
||||
avio_wb32(pb, sample_aspect_ratio * track->enc->width * 0x10000);
|
||||
avio_wb32(pb, track->height * 0x10000);
|
||||
}
|
||||
}
|
||||
else {
|
||||
} else {
|
||||
avio_wb32(pb, 0);
|
||||
avio_wb32(pb, 0);
|
||||
}
|
||||
@ -1778,7 +1774,6 @@ static int mov_write_uuid_tag_psp(AVIOContext *pb, MOVTrack *mov)
|
||||
|
||||
static int mov_write_udta_sdp(AVIOContext *pb, MOVTrack *track)
|
||||
{
|
||||
|
||||
AVFormatContext *ctx = track->rtp_ctx;
|
||||
char buf[1000] = "";
|
||||
int len;
|
||||
@ -1811,14 +1806,14 @@ static int mov_write_trak_tag(AVIOContext *pb, MOVMuxContext *mov,
|
||||
mov_write_tref_tag(pb, track);
|
||||
mov_write_mdia_tag(pb, track);
|
||||
if (track->mode == MODE_PSP)
|
||||
mov_write_uuid_tag_psp(pb,track); // PSP Movies require this uuid box
|
||||
mov_write_uuid_tag_psp(pb, track); // PSP Movies require this uuid box
|
||||
if (track->tag == MKTAG('r','t','p',' '))
|
||||
mov_write_udta_sdp(pb, track);
|
||||
if (track->enc->codec_type == AVMEDIA_TYPE_VIDEO && track->mode == MODE_MOV) {
|
||||
double sample_aspect_ratio = av_q2d(st->sample_aspect_ratio);
|
||||
if (st->sample_aspect_ratio.num && 1.0 != sample_aspect_ratio)
|
||||
mov_write_tapt_tag(pb, track);
|
||||
};
|
||||
}
|
||||
return update_size(pb, pos);
|
||||
}
|
||||
|
||||
@ -1829,7 +1824,7 @@ static int mov_write_iods_tag(AVIOContext *pb, MOVMuxContext *mov)
|
||||
int audio_profile = mov->iods_audio_profile;
|
||||
int video_profile = mov->iods_video_profile;
|
||||
for (i = 0; i < mov->nb_streams; i++) {
|
||||
if(mov->tracks[i].entry > 0) {
|
||||
if (mov->tracks[i].entry > 0) {
|
||||
has_audio |= mov->tracks[i].enc->codec_type == AVMEDIA_TYPE_AUDIO;
|
||||
has_video |= mov->tracks[i].enc->codec_type == AVMEDIA_TYPE_VIDEO;
|
||||
}
|
||||
@ -1881,8 +1876,8 @@ static int mov_write_mvhd_tag(AVIOContext *pb, MOVMuxContext *mov)
|
||||
int64_t max_track_len_temp, max_track_len = 0;
|
||||
int version;
|
||||
|
||||
for (i=0; i<mov->nb_streams; i++) {
|
||||
if(mov->tracks[i].entry > 0) {
|
||||
for (i = 0; i < mov->nb_streams; i++) {
|
||||
if (mov->tracks[i].entry > 0) {
|
||||
max_track_len_temp = av_rescale_rnd(mov->tracks[i].track_duration,
|
||||
MOV_TIMESCALE,
|
||||
mov->tracks[i].timescale,
|
||||
@ -1946,7 +1941,7 @@ static int mov_write_itunes_hdlr_tag(AVIOContext *pb, MOVMuxContext *mov,
|
||||
/* helper function to write a data tag with the specified string as data */
|
||||
static int mov_write_string_data_tag(AVIOContext *pb, const char *data, int lang, int long_style)
|
||||
{
|
||||
if(long_style){
|
||||
if (long_style) {
|
||||
int size = 16 + strlen(data);
|
||||
avio_wb32(pb, size); /* size */
|
||||
ffio_wfourcc(pb, "data");
|
||||
@ -1954,7 +1949,7 @@ static int mov_write_string_data_tag(AVIOContext *pb, const char *data, int lang
|
||||
avio_wb32(pb, 0);
|
||||
avio_write(pb, data, strlen(data));
|
||||
return size;
|
||||
}else{
|
||||
} else {
|
||||
if (!lang)
|
||||
lang = ff_mov_iso639_to_lang("und", 1);
|
||||
avio_wb16(pb, strlen(data)); /* string length */
|
||||
@ -1964,7 +1959,9 @@ static int mov_write_string_data_tag(AVIOContext *pb, const char *data, int lang
|
||||
}
|
||||
}
|
||||
|
||||
static int mov_write_string_tag(AVIOContext *pb, const char *name, const char *value, int lang, int long_style){
|
||||
static int mov_write_string_tag(AVIOContext *pb, const char *name,
|
||||
const char *value, int lang, int long_style)
|
||||
{
|
||||
int size = 0;
|
||||
if (value && value[0]) {
|
||||
int64_t pos = avio_tell(pb);
|
||||
@ -1991,8 +1988,8 @@ static int mov_write_string_metadata(AVFormatContext *s, AVIOContext *pb,
|
||||
snprintf(tag2, sizeof(tag2), "%s-", tag);
|
||||
while ((t2 = av_dict_get(s->metadata, tag2, t2, AV_DICT_IGNORE_SUFFIX))) {
|
||||
len2 = strlen(t2->key);
|
||||
if (len2 == len+4 && !strcmp(t->value, t2->value)
|
||||
&& (l=ff_mov_iso639_to_lang(&t2->key[len2-3], 1)) >= 0) {
|
||||
if (len2 == len + 4 && !strcmp(t->value, t2->value)
|
||||
&& (l = ff_mov_iso639_to_lang(&t2->key[len2 - 3], 1)) >= 0) {
|
||||
lang = l;
|
||||
break;
|
||||
}
|
||||
@ -2027,14 +2024,14 @@ static int mov_write_trkn_tag(AVIOContext *pb, MOVMuxContext *mov,
|
||||
if (track) {
|
||||
avio_wb32(pb, 32); /* size */
|
||||
ffio_wfourcc(pb, "trkn");
|
||||
avio_wb32(pb, 24); /* size */
|
||||
ffio_wfourcc(pb, "data");
|
||||
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
|
||||
avio_wb32(pb, 24); /* size */
|
||||
ffio_wfourcc(pb, "data");
|
||||
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;
|
||||
@ -2118,9 +2115,9 @@ static int mov_write_meta_tag(AVIOContext *pb, MOVMuxContext *mov,
|
||||
|
||||
static int utf8len(const uint8_t *b)
|
||||
{
|
||||
int len=0;
|
||||
int len = 0;
|
||||
int val;
|
||||
while(*b){
|
||||
while (*b) {
|
||||
GET_UTF8(val, *b++, return -1;)
|
||||
len++;
|
||||
}
|
||||
@ -2130,7 +2127,7 @@ static int utf8len(const uint8_t *b)
|
||||
static int ascii_to_wc(AVIOContext *pb, const uint8_t *b)
|
||||
{
|
||||
int val;
|
||||
while(*b){
|
||||
while (*b) {
|
||||
GET_UTF8(val, *b++, return -1;)
|
||||
avio_wb16(pb, val);
|
||||
}
|
||||
@ -2140,7 +2137,9 @@ static int ascii_to_wc(AVIOContext *pb, const uint8_t *b)
|
||||
|
||||
static uint16_t language_code(const char *str)
|
||||
{
|
||||
return (((str[0]-0x60) & 0x1F) << 10) + (((str[1]-0x60) & 0x1F) << 5) + ((str[2]-0x60) & 0x1F);
|
||||
return (((str[0] - 0x60) & 0x1F) << 10) +
|
||||
(((str[1] - 0x60) & 0x1F) << 5) +
|
||||
(( str[2] - 0x60) & 0x1F);
|
||||
}
|
||||
|
||||
static int mov_write_3gp_udta_tag(AVIOContext *pb, AVFormatContext *s,
|
||||
@ -2157,7 +2156,7 @@ static int mov_write_3gp_udta_tag(AVIOContext *pb, AVFormatContext *s,
|
||||
avio_wb16(pb, atoi(t->value));
|
||||
else {
|
||||
avio_wb16(pb, language_code("eng")); /* language */
|
||||
avio_write(pb, t->value, strlen(t->value)+1); /* UTF8 string value */
|
||||
avio_write(pb, t->value, strlen(t->value) + 1); /* UTF8 string value */
|
||||
if (!strcmp(tag, "albm") &&
|
||||
(t = av_dict_get(s->metadata, "track", NULL, 0)))
|
||||
avio_w8(pb, atoi(t->value));
|
||||
@ -2204,7 +2203,7 @@ static int mov_write_udta_tag(AVIOContext *pb, MOVMuxContext *mov,
|
||||
}
|
||||
|
||||
ret = avio_open_dyn_buf(&pb_buf);
|
||||
if(ret < 0)
|
||||
if (ret < 0)
|
||||
return ret;
|
||||
|
||||
if (mov->mode & MODE_3GP) {
|
||||
@ -2217,18 +2216,18 @@ static int mov_write_udta_tag(AVIOContext *pb, MOVMuxContext *mov,
|
||||
mov_write_3gp_udta_tag(pb_buf, s, "cprt", "copyright");
|
||||
mov_write_3gp_udta_tag(pb_buf, s, "yrrc", "date");
|
||||
} else if (mov->mode == MODE_MOV) { // the title field breaks gtkpod with mp4 and my suspicion is that stuff is not valid in mp4
|
||||
mov_write_string_metadata(s, pb_buf, "\251ART", "artist" , 0);
|
||||
mov_write_string_metadata(s, pb_buf, "\251nam", "title" , 0);
|
||||
mov_write_string_metadata(s, pb_buf, "\251aut", "author" , 0);
|
||||
mov_write_string_metadata(s, pb_buf, "\251alb", "album" , 0);
|
||||
mov_write_string_metadata(s, pb_buf, "\251day", "date" , 0);
|
||||
mov_write_string_metadata(s, pb_buf, "\251swr", "encoder" , 0);
|
||||
mov_write_string_metadata(s, pb_buf, "\251ART", "artist", 0);
|
||||
mov_write_string_metadata(s, pb_buf, "\251nam", "title", 0);
|
||||
mov_write_string_metadata(s, pb_buf, "\251aut", "author", 0);
|
||||
mov_write_string_metadata(s, pb_buf, "\251alb", "album", 0);
|
||||
mov_write_string_metadata(s, pb_buf, "\251day", "date", 0);
|
||||
mov_write_string_metadata(s, pb_buf, "\251swr", "encoder", 0);
|
||||
// currently ignored by mov.c
|
||||
mov_write_string_metadata(s, pb_buf, "\251des", "comment" , 0);
|
||||
mov_write_string_metadata(s, pb_buf, "\251des", "comment", 0);
|
||||
// add support for libquicktime, this atom is also actually read by mov.c
|
||||
mov_write_string_metadata(s, pb_buf, "\251cmt", "comment" , 0);
|
||||
mov_write_string_metadata(s, pb_buf, "\251gen", "genre" , 0);
|
||||
mov_write_string_metadata(s, pb_buf, "\251cpy", "copyright" , 0);
|
||||
mov_write_string_metadata(s, pb_buf, "\251cmt", "comment", 0);
|
||||
mov_write_string_metadata(s, pb_buf, "\251gen", "genre", 0);
|
||||
mov_write_string_metadata(s, pb_buf, "\251cpy", "copyright", 0);
|
||||
} else {
|
||||
/* iTunes meta data */
|
||||
mov_write_meta_tag(pb_buf, mov, s);
|
||||
@ -2238,7 +2237,7 @@ static int mov_write_udta_tag(AVIOContext *pb, MOVMuxContext *mov,
|
||||
mov_write_chpl_tag(pb_buf, s);
|
||||
|
||||
if ((size = avio_close_dyn_buf(pb_buf, &buf)) > 0) {
|
||||
avio_wb32(pb, size+8);
|
||||
avio_wb32(pb, size + 8);
|
||||
ffio_wfourcc(pb, "udta");
|
||||
avio_write(pb, buf, size);
|
||||
}
|
||||
@ -2248,12 +2247,12 @@ static int mov_write_udta_tag(AVIOContext *pb, MOVMuxContext *mov,
|
||||
}
|
||||
|
||||
static void mov_write_psp_udta_tag(AVIOContext *pb,
|
||||
const char *str, const char *lang, int type)
|
||||
const char *str, const char *lang, int type)
|
||||
{
|
||||
int len = utf8len(str)+1;
|
||||
if(len<=0)
|
||||
int len = utf8len(str) + 1;
|
||||
if (len <= 0)
|
||||
return;
|
||||
avio_wb16(pb, len*2+10); /* size */
|
||||
avio_wb16(pb, len * 2 + 10); /* size */
|
||||
avio_wb32(pb, type); /* type */
|
||||
avio_wb16(pb, language_code(lang)); /* language */
|
||||
avio_wb16(pb, 0x01); /* ? */
|
||||
@ -2300,18 +2299,18 @@ static int mov_write_uuidusmt_tag(AVIOContext *pb, AVFormatContext *s)
|
||||
static void build_chunks(MOVTrack *trk)
|
||||
{
|
||||
int i;
|
||||
MOVIentry *chunk= &trk->cluster[0];
|
||||
MOVIentry *chunk = &trk->cluster[0];
|
||||
uint64_t chunkSize = chunk->size;
|
||||
chunk->chunkNum= 1;
|
||||
chunk->chunkNum = 1;
|
||||
if (trk->chunkCount)
|
||||
return;
|
||||
trk->chunkCount= 1;
|
||||
for(i=1; i<trk->entry; i++){
|
||||
if(chunk->pos + chunkSize == trk->cluster[i].pos &&
|
||||
trk->chunkCount = 1;
|
||||
for (i = 1; i<trk->entry; i++){
|
||||
if (chunk->pos + chunkSize == trk->cluster[i].pos &&
|
||||
chunkSize + trk->cluster[i].size < (1<<20)){
|
||||
chunkSize += trk->cluster[i].size;
|
||||
chunk->samples_in_chunk += trk->cluster[i].entries;
|
||||
}else{
|
||||
} else {
|
||||
trk->cluster[i].chunkNum = chunk->chunkNum+1;
|
||||
chunk=&trk->cluster[i];
|
||||
chunkSize = chunk->size;
|
||||
@ -2329,21 +2328,21 @@ static int mov_write_moov_tag(AVIOContext *pb, MOVMuxContext *mov,
|
||||
avio_wb32(pb, 0); /* size placeholder*/
|
||||
ffio_wfourcc(pb, "moov");
|
||||
|
||||
for (i=0; i<mov->nb_streams; i++) {
|
||||
for (i = 0; i < mov->nb_streams; i++) {
|
||||
if (mov->tracks[i].entry <= 0 && !(mov->flags & FF_MOV_FLAG_FRAGMENT))
|
||||
continue;
|
||||
|
||||
mov->tracks[i].time = mov->time;
|
||||
mov->tracks[i].track_id = i+1;
|
||||
mov->tracks[i].time = mov->time;
|
||||
mov->tracks[i].track_id = i + 1;
|
||||
|
||||
if (mov->tracks[i].entry)
|
||||
build_chunks(&mov->tracks[i]);
|
||||
}
|
||||
|
||||
if (mov->chapter_track)
|
||||
for (i=0; i<s->nb_streams; i++) {
|
||||
for (i = 0; i < s->nb_streams; i++) {
|
||||
mov->tracks[i].tref_tag = MKTAG('c','h','a','p');
|
||||
mov->tracks[i].tref_id = mov->tracks[mov->chapter_track].track_id;
|
||||
mov->tracks[i].tref_id = mov->tracks[mov->chapter_track].track_id;
|
||||
}
|
||||
for (i = 0; i < mov->nb_streams; i++) {
|
||||
if (mov->tracks[i].tag == MKTAG('r','t','p',' ')) {
|
||||
@ -2364,11 +2363,11 @@ static int mov_write_moov_tag(AVIOContext *pb, MOVMuxContext *mov,
|
||||
mov_write_mvhd_tag(pb, mov);
|
||||
if (mov->mode != MODE_MOV && !mov->iods_skip)
|
||||
mov_write_iods_tag(pb, mov);
|
||||
for (i=0; i<mov->nb_streams; i++) {
|
||||
for (i = 0; i < mov->nb_streams; i++) {
|
||||
if (mov->tracks[i].entry > 0 || mov->flags & FF_MOV_FLAG_FRAGMENT) {
|
||||
if(i < s->nb_streams){
|
||||
if (i < s->nb_streams){
|
||||
int codec_type= s->streams[i]->codec->codec_type;
|
||||
if(codec_type==AVMEDIA_TYPE_AUDIO || codec_type==AVMEDIA_TYPE_SUBTITLE){
|
||||
if (codec_type==AVMEDIA_TYPE_AUDIO || codec_type==AVMEDIA_TYPE_SUBTITLE){
|
||||
mov->tracks[i].secondary= not_first[codec_type];
|
||||
not_first[codec_type]= 1;
|
||||
}
|
||||
@ -2400,9 +2399,9 @@ static void param_write_string(AVIOContext *pb, const char *name, const char *va
|
||||
static void param_write_hex(AVIOContext *pb, const char *name, const uint8_t *value, int len)
|
||||
{
|
||||
char buf[150];
|
||||
len = FFMIN(sizeof(buf)/2 - 1, len);
|
||||
len = FFMIN(sizeof(buf) / 2 - 1, len);
|
||||
ff_data_to_hex(buf, value, len, 0);
|
||||
buf[2*len] = '\0';
|
||||
buf[2 * len] = '\0';
|
||||
avio_printf(pb, "<param name=\"%s\" value=\"%s\" valuetype=\"data\"/>\n", name, buf);
|
||||
}
|
||||
|
||||
@ -2476,7 +2475,7 @@ static int mov_write_isml_manifest(AVIOContext *pb, MOVMuxContext *mov)
|
||||
param_write_hex(pb, "CodecPrivateData", track->enc->extradata,
|
||||
track->enc->extradata_size);
|
||||
param_write_int(pb, "AudioTag", ff_codec_get_tag(ff_codec_wav_tags,
|
||||
track->enc->codec_id));
|
||||
track->enc->codec_id));
|
||||
param_write_int(pb, "Channels", track->enc->channels);
|
||||
param_write_int(pb, "SamplingRate", track->enc->sample_rate);
|
||||
param_write_int(pb, "BitsPerSample", 16);
|
||||
@ -2646,7 +2645,7 @@ static int mov_write_tfrf_tag(AVIOContext *pb, MOVMuxContext *mov,
|
||||
avio_wb64(pb, track->frag_info[index].duration);
|
||||
}
|
||||
if (n < mov->ism_lookahead) {
|
||||
int free_size = 16*(mov->ism_lookahead - n);
|
||||
int free_size = 16 * (mov->ism_lookahead - n);
|
||||
avio_wb32(pb, free_size);
|
||||
ffio_wfourcc(pb, "free");
|
||||
ffio_fill(pb, 0, free_size - 8);
|
||||
@ -2682,7 +2681,7 @@ static int mov_write_traf_tag(AVIOContext *pb, MOVMuxContext *mov,
|
||||
mov_write_tfxd_tag(pb, track);
|
||||
|
||||
if (mov->ism_lookahead) {
|
||||
int i, size = 16 + 4 + 1 + 16*mov->ism_lookahead;
|
||||
int i, size = 16 + 4 + 1 + 16 * mov->ism_lookahead;
|
||||
|
||||
track->tfrf_offset = avio_tell(pb);
|
||||
avio_wb32(pb, 8 + size);
|
||||
@ -2816,7 +2815,7 @@ static int mov_write_ftyp_tag(AVIOContext *pb, AVFormatContext *s)
|
||||
} else if (mov->mode & MODE_3G2) {
|
||||
ffio_wfourcc(pb, has_h264 ? "3g2b" : "3g2a");
|
||||
minor = has_h264 ? 0x20000 : 0x10000;
|
||||
}else if (mov->mode == MODE_PSP)
|
||||
} else if (mov->mode == MODE_PSP)
|
||||
ffio_wfourcc(pb, "MSNV");
|
||||
else if (mov->mode == MODE_MP4)
|
||||
ffio_wfourcc(pb, "isom");
|
||||
@ -2831,7 +2830,7 @@ static int mov_write_ftyp_tag(AVIOContext *pb, AVFormatContext *s)
|
||||
|
||||
avio_wb32(pb, minor);
|
||||
|
||||
if(mov->mode == MODE_MOV)
|
||||
if (mov->mode == MODE_MOV)
|
||||
ffio_wfourcc(pb, "qt ");
|
||||
else if (mov->mode == MODE_ISM) {
|
||||
ffio_wfourcc(pb, "piff");
|
||||
@ -2839,7 +2838,7 @@ static int mov_write_ftyp_tag(AVIOContext *pb, AVFormatContext *s)
|
||||
} else {
|
||||
ffio_wfourcc(pb, "isom");
|
||||
ffio_wfourcc(pb, "iso2");
|
||||
if(has_h264)
|
||||
if (has_h264)
|
||||
ffio_wfourcc(pb, "avc1");
|
||||
}
|
||||
|
||||
@ -2859,7 +2858,7 @@ static void mov_write_uuidprof_tag(AVIOContext *pb, AVFormatContext *s)
|
||||
AVCodecContext *video_codec = s->streams[0]->codec;
|
||||
AVCodecContext *audio_codec = s->streams[1]->codec;
|
||||
int audio_rate = audio_codec->sample_rate;
|
||||
int frame_rate = ((video_codec->time_base.den) * (0x10000))/ (video_codec->time_base.num);
|
||||
int frame_rate = ((video_codec->time_base.den) * (0x10000)) / (video_codec->time_base.num);
|
||||
int audio_kbitrate = audio_codec->bit_rate / 1000;
|
||||
int video_kbitrate = FFMIN(video_codec->bit_rate / 1000, 800 - audio_kbitrate);
|
||||
|
||||
@ -2881,7 +2880,7 @@ static void mov_write_uuidprof_tag(AVIOContext *pb, AVFormatContext *s)
|
||||
avio_wb32(pb, 0x0); /* ? */
|
||||
|
||||
avio_wb32(pb, 0x2c); /* size */
|
||||
ffio_wfourcc(pb, "APRF");/* audio */
|
||||
ffio_wfourcc(pb, "APRF"); /* audio */
|
||||
avio_wb32(pb, 0x0);
|
||||
avio_wb32(pb, 0x2); /* TrackID */
|
||||
ffio_wfourcc(pb, "mp4a");
|
||||
@ -2921,11 +2920,11 @@ static int mov_parse_mpeg2_frame(AVPacket *pkt, uint32_t *flags)
|
||||
int i, closed_gop = 0;
|
||||
|
||||
for (i = 0; i < pkt->size - 4; i++) {
|
||||
c = (c<<8) + pkt->data[i];
|
||||
c = (c << 8) + pkt->data[i];
|
||||
if (c == 0x1b8) { // gop
|
||||
closed_gop = pkt->data[i+4]>>6 & 0x01;
|
||||
closed_gop = pkt->data[i + 4] >> 6 & 0x01;
|
||||
} else if (c == 0x100) { // pic
|
||||
int temp_ref = (pkt->data[i+1]<<2) | (pkt->data[i+2]>>6);
|
||||
int temp_ref = (pkt->data[i + 1] << 2) | (pkt->data[i + 2] >> 6);
|
||||
if (!temp_ref || closed_gop) // I picture is not reordered
|
||||
*flags = MOV_SYNC_SAMPLE;
|
||||
else
|
||||
@ -3140,7 +3139,7 @@ int ff_mov_write_packet(AVFormatContext *s, AVPacket *pkt)
|
||||
MOVTrack *trk = &mov->tracks[pkt->stream_index];
|
||||
AVCodecContext *enc = trk->enc;
|
||||
unsigned int samples_in_chunk = 0;
|
||||
int size= pkt->size;
|
||||
int size = pkt->size;
|
||||
uint8_t *reformatted_data = NULL;
|
||||
|
||||
if (mov->flags & FF_MOV_FLAG_FRAGMENT) {
|
||||
@ -3184,7 +3183,7 @@ int ff_mov_write_packet(AVFormatContext *s, AVPacket *pkt)
|
||||
|
||||
/* copy extradata if it exists */
|
||||
if (trk->vos_len == 0 && enc->extradata_size > 0) {
|
||||
trk->vos_len = enc->extradata_size;
|
||||
trk->vos_len = enc->extradata_size;
|
||||
trk->vos_data = av_malloc(trk->vos_len);
|
||||
memcpy(trk->vos_data, enc->extradata, trk->vos_len);
|
||||
}
|
||||
@ -3216,7 +3215,7 @@ int ff_mov_write_packet(AVFormatContext *s, AVPacket *pkt)
|
||||
if ((enc->codec_id == AV_CODEC_ID_DNXHD ||
|
||||
enc->codec_id == AV_CODEC_ID_AC3) && !trk->vos_len) {
|
||||
/* copy frame to create needed atoms */
|
||||
trk->vos_len = size;
|
||||
trk->vos_len = size;
|
||||
trk->vos_data = av_malloc(size);
|
||||
if (!trk->vos_data)
|
||||
return AVERROR(ENOMEM);
|
||||
@ -3224,19 +3223,19 @@ int ff_mov_write_packet(AVFormatContext *s, AVPacket *pkt)
|
||||
}
|
||||
|
||||
if (trk->entry >= trk->cluster_capacity) {
|
||||
unsigned new_capacity = 2*(trk->entry + MOV_INDEX_CLUSTER_SIZE);
|
||||
unsigned new_capacity = 2 * (trk->entry + MOV_INDEX_CLUSTER_SIZE);
|
||||
if (av_reallocp_array(&trk->cluster, new_capacity,
|
||||
sizeof(*trk->cluster)))
|
||||
return AVERROR(ENOMEM);
|
||||
trk->cluster_capacity = new_capacity;
|
||||
}
|
||||
|
||||
trk->cluster[trk->entry].pos = avio_tell(pb) - size;
|
||||
trk->cluster[trk->entry].pos = avio_tell(pb) - size;
|
||||
trk->cluster[trk->entry].samples_in_chunk = samples_in_chunk;
|
||||
trk->cluster[trk->entry].chunkNum = 0;
|
||||
trk->cluster[trk->entry].size = size;
|
||||
trk->cluster[trk->entry].entries = samples_in_chunk;
|
||||
trk->cluster[trk->entry].dts = pkt->dts;
|
||||
trk->cluster[trk->entry].chunkNum = 0;
|
||||
trk->cluster[trk->entry].size = size;
|
||||
trk->cluster[trk->entry].entries = samples_in_chunk;
|
||||
trk->cluster[trk->entry].dts = pkt->dts;
|
||||
if (!trk->entry && trk->start_dts != AV_NOPTS_VALUE) {
|
||||
/* First packet of a new fragment. We already wrote the duration
|
||||
* of the last packet of the previous fragment based on track_duration,
|
||||
@ -3258,7 +3257,7 @@ int ff_mov_write_packet(AVFormatContext *s, AVPacket *pkt)
|
||||
}
|
||||
if (pkt->dts != pkt->pts)
|
||||
trk->flags |= MOV_TRACK_CTTS;
|
||||
trk->cluster[trk->entry].cts = pkt->pts - pkt->dts;
|
||||
trk->cluster[trk->entry].cts = pkt->pts - pkt->dts;
|
||||
trk->cluster[trk->entry].flags = 0;
|
||||
if (enc->codec_id == AV_CODEC_ID_VC1) {
|
||||
mov_parse_vc1_frame(pkt, trk, mov->fragments);
|
||||
@ -3276,7 +3275,7 @@ int ff_mov_write_packet(AVFormatContext *s, AVPacket *pkt)
|
||||
}
|
||||
trk->entry++;
|
||||
trk->sample_count += samples_in_chunk;
|
||||
mov->mdat_size += size;
|
||||
mov->mdat_size += size;
|
||||
|
||||
avio_flush(pb);
|
||||
|
||||
@ -3295,7 +3294,8 @@ static int mov_write_single_packet(AVFormatContext *s, AVPacket *pkt)
|
||||
int64_t frag_duration = 0;
|
||||
int size = pkt->size;
|
||||
|
||||
if (!pkt->size) return 0; /* Discard 0 sized packets */
|
||||
if (!pkt->size)
|
||||
return 0; /* Discard 0 sized packets */
|
||||
|
||||
if (trk->entry && pkt->stream_index < s->nb_streams)
|
||||
frag_duration = av_rescale_q(pkt->dts - trk->cluster[0].dts,
|
||||
@ -3452,11 +3452,11 @@ static void mov_create_chapter_track(AVFormatContext *s, int tracknum)
|
||||
pkt.duration = end - pkt.dts;
|
||||
|
||||
if ((t = av_dict_get(c->metadata, "title", NULL, 0))) {
|
||||
len = strlen(t->value);
|
||||
pkt.size = len+2;
|
||||
len = strlen(t->value);
|
||||
pkt.size = len + 2;
|
||||
pkt.data = av_malloc(pkt.size);
|
||||
AV_WB16(pkt.data, len);
|
||||
memcpy(pkt.data+2, t->value, len);
|
||||
memcpy(pkt.data + 2, t->value, len);
|
||||
ff_mov_write_packet(s, &pkt);
|
||||
av_freep(&pkt.data);
|
||||
}
|
||||
@ -3562,7 +3562,7 @@ static int mov_write_header(AVFormatContext *s)
|
||||
av_log(s, AV_LOG_ERROR, "PSP mode need one video and one audio stream\n");
|
||||
return -1;
|
||||
}
|
||||
mov_write_uuidprof_tag(pb,s);
|
||||
mov_write_uuidprof_tag(pb, s);
|
||||
}
|
||||
}
|
||||
|
||||
@ -3608,11 +3608,11 @@ static int mov_write_header(AVFormatContext *s)
|
||||
mov->nb_streams += mov->nb_meta_tmcd;
|
||||
}
|
||||
|
||||
mov->tracks = av_mallocz(mov->nb_streams*sizeof(*mov->tracks));
|
||||
mov->tracks = av_mallocz(mov->nb_streams * sizeof(*mov->tracks));
|
||||
if (!mov->tracks)
|
||||
return AVERROR(ENOMEM);
|
||||
|
||||
for(i=0; i<s->nb_streams; i++){
|
||||
for (i = 0; i < s->nb_streams; i++) {
|
||||
AVStream *st= s->streams[i];
|
||||
MOVTrack *track= &mov->tracks[i];
|
||||
AVDictionaryEntry *lang = av_dict_get(st->metadata, "language", NULL,0);
|
||||
@ -3622,7 +3622,7 @@ static int mov_write_header(AVFormatContext *s)
|
||||
if (track->language < 0)
|
||||
track->language = 0;
|
||||
track->mode = mov->mode;
|
||||
track->tag = mov_find_codec_tag(s, track);
|
||||
track->tag = mov_find_codec_tag(s, track);
|
||||
if (!track->tag) {
|
||||
av_log(s, AV_LOG_ERROR, "track %d: could not find tag, "
|
||||
"codec not currently supported in container\n", i);
|
||||
@ -3631,8 +3631,8 @@ static int mov_write_header(AVFormatContext *s)
|
||||
/* If hinting of this track is enabled by a later hint track,
|
||||
* this is updated. */
|
||||
track->hint_track = -1;
|
||||
track->start_dts = AV_NOPTS_VALUE;
|
||||
if(st->codec->codec_type == AVMEDIA_TYPE_VIDEO){
|
||||
track->start_dts = AV_NOPTS_VALUE;
|
||||
if (st->codec->codec_type == AVMEDIA_TYPE_VIDEO) {
|
||||
if (track->tag == MKTAG('m','x','3','p') || track->tag == MKTAG('m','x','3','n') ||
|
||||
track->tag == MKTAG('m','x','4','p') || track->tag == MKTAG('m','x','4','n') ||
|
||||
track->tag == MKTAG('m','x','5','p') || track->tag == MKTAG('m','x','5','n')) {
|
||||
@ -3640,7 +3640,7 @@ static int mov_write_header(AVFormatContext *s)
|
||||
av_log(s, AV_LOG_ERROR, "D-10/IMX must use 720x608 or 720x512 video resolution\n");
|
||||
goto error;
|
||||
}
|
||||
track->height = track->tag>>24 == 'n' ? 486 : 576;
|
||||
track->height = track->tag >> 24 == 'n' ? 486 : 576;
|
||||
}
|
||||
if (mov->video_track_timescale) {
|
||||
track->timescale = mov->video_track_timescale;
|
||||
@ -3654,12 +3654,12 @@ static int mov_write_header(AVFormatContext *s)
|
||||
"WARNING codec timebase is very high. If duration is too long,\n"
|
||||
"file may not be playable by quicktime. Specify a shorter timebase\n"
|
||||
"or choose different container.\n");
|
||||
}else if(st->codec->codec_type == AVMEDIA_TYPE_AUDIO){
|
||||
} else if (st->codec->codec_type == AVMEDIA_TYPE_AUDIO) {
|
||||
track->timescale = st->codec->sample_rate;
|
||||
if(!st->codec->frame_size && !av_get_bits_per_sample(st->codec->codec_id)) {
|
||||
if (!st->codec->frame_size && !av_get_bits_per_sample(st->codec->codec_id)) {
|
||||
av_log(s, AV_LOG_WARNING, "track %d: codec frame size is not set\n", i);
|
||||
track->audio_vbr = 1;
|
||||
}else if(st->codec->codec_id == AV_CODEC_ID_ADPCM_MS ||
|
||||
}else if (st->codec->codec_id == AV_CODEC_ID_ADPCM_MS ||
|
||||
st->codec->codec_id == AV_CODEC_ID_ADPCM_IMA_WAV ||
|
||||
st->codec->codec_id == AV_CODEC_ID_ILBC){
|
||||
if (!st->codec->block_align) {
|
||||
@ -3667,7 +3667,7 @@ static int mov_write_header(AVFormatContext *s)
|
||||
goto error;
|
||||
}
|
||||
track->sample_size = st->codec->block_align;
|
||||
}else if(st->codec->frame_size > 1){ /* assume compressed audio */
|
||||
}else if (st->codec->frame_size > 1){ /* assume compressed audio */
|
||||
track->audio_vbr = 1;
|
||||
}else{
|
||||
track->sample_size = (av_get_bits_per_sample(st->codec->codec_id) >> 3) * st->codec->channels;
|
||||
@ -3678,7 +3678,7 @@ static int mov_write_header(AVFormatContext *s)
|
||||
i, track->enc->sample_rate);
|
||||
goto error;
|
||||
}
|
||||
}else if(st->codec->codec_type == AVMEDIA_TYPE_SUBTITLE){
|
||||
} else if (st->codec->codec_type == AVMEDIA_TYPE_SUBTITLE) {
|
||||
track->timescale = st->codec->time_base.den;
|
||||
}else{
|
||||
track->timescale = MOV_TIMESCALE;
|
||||
@ -3710,7 +3710,7 @@ static int mov_write_header(AVFormatContext *s)
|
||||
FF_MOV_FLAG_FRAGMENT;
|
||||
}
|
||||
|
||||
if(mov->reserved_moov_size){
|
||||
if (mov->reserved_moov_size){
|
||||
mov->reserved_moov_pos= avio_tell(pb);
|
||||
if (mov->reserved_moov_size > 0)
|
||||
avio_skip(pb, mov->reserved_moov_size);
|
||||
@ -3918,13 +3918,13 @@ static int mov_write_trailer(AVFormatContext *s)
|
||||
int64_t size;
|
||||
mov_write_moov_tag(pb, mov, s);
|
||||
size = mov->reserved_moov_size - (avio_tell(pb) - mov->reserved_moov_pos);
|
||||
if(size < 8){
|
||||
if (size < 8){
|
||||
av_log(s, AV_LOG_ERROR, "reserved_moov_size is too small, needed %"PRId64" additional\n", 8-size);
|
||||
return -1;
|
||||
}
|
||||
avio_wb32(pb, size);
|
||||
ffio_wfourcc(pb, "free");
|
||||
for(i=0; i<size; i++)
|
||||
for (i = 0; i < size; i++)
|
||||
avio_w8(pb, 0);
|
||||
avio_seek(pb, moov_pos, SEEK_SET);
|
||||
} else {
|
||||
@ -3938,7 +3938,7 @@ static int mov_write_trailer(AVFormatContext *s)
|
||||
if (mov->chapter_track)
|
||||
av_freep(&mov->tracks[mov->chapter_track].enc);
|
||||
|
||||
for (i=0; i<mov->nb_streams; i++) {
|
||||
for (i = 0; i < mov->nb_streams; i++) {
|
||||
if (mov->tracks[i].tag == MKTAG('r','t','p',' '))
|
||||
ff_mov_close_hinting(&mov->tracks[i]);
|
||||
else if (mov->tracks[i].tag == MKTAG('t','m','c','d') && mov->nb_meta_tmcd)
|
||||
@ -3958,7 +3958,6 @@ static int mov_write_trailer(AVFormatContext *s)
|
||||
|
||||
if (mov->tracks[i].vos_len)
|
||||
av_free(mov->tracks[i].vos_data);
|
||||
|
||||
}
|
||||
|
||||
av_freep(&mov->tracks);
|
||||
|
@ -87,7 +87,7 @@ static void sample_queue_free(HintSampleQueue *queue)
|
||||
if (queue->samples[i].own_data)
|
||||
av_free(queue->samples[i].data);
|
||||
av_freep(&queue->samples);
|
||||
queue->len = 0;
|
||||
queue->len = 0;
|
||||
queue->size = 0;
|
||||
}
|
||||
|
||||
@ -104,7 +104,7 @@ static void sample_queue_push(HintSampleQueue *queue, uint8_t *data, int size,
|
||||
if (size <= 14)
|
||||
return;
|
||||
if (!queue->samples || queue->len >= queue->size) {
|
||||
HintSample* samples;
|
||||
HintSample *samples;
|
||||
queue->size += 10;
|
||||
samples = av_realloc(queue->samples, sizeof(HintSample)*queue->size);
|
||||
if (!samples)
|
||||
@ -114,7 +114,7 @@ static void sample_queue_push(HintSampleQueue *queue, uint8_t *data, int size,
|
||||
queue->samples[queue->len].data = data;
|
||||
queue->samples[queue->len].size = size;
|
||||
queue->samples[queue->len].sample_number = sample;
|
||||
queue->samples[queue->len].offset = 0;
|
||||
queue->samples[queue->len].offset = 0;
|
||||
queue->samples[queue->len].own_data = 0;
|
||||
queue->len++;
|
||||
}
|
||||
@ -128,7 +128,7 @@ static void sample_queue_retain(HintSampleQueue *queue)
|
||||
for (i = 0; i < queue->len; ) {
|
||||
HintSample *sample = &queue->samples[i];
|
||||
if (!sample->own_data) {
|
||||
uint8_t* ptr = av_malloc(sample->size);
|
||||
uint8_t *ptr = av_malloc(sample->size);
|
||||
if (!ptr) {
|
||||
/* Unable to allocate memory for this one, remove it */
|
||||
memmove(queue->samples + i, queue->samples + i + 1,
|
||||
@ -344,7 +344,7 @@ static int write_hint_packets(AVIOContext *out, const uint8_t *data,
|
||||
trk->max_packet_size = packet_len;
|
||||
|
||||
seq = AV_RB16(&data[2]);
|
||||
ts = AV_RB32(&data[4]);
|
||||
ts = AV_RB32(&data[4]);
|
||||
|
||||
if (trk->prev_rtp_ts == 0)
|
||||
trk->prev_rtp_ts = ts;
|
||||
@ -417,7 +417,7 @@ int ff_mov_add_hinted_packet(AVFormatContext *s, AVPacket *pkt,
|
||||
* for next time. */
|
||||
size = avio_close_dyn_buf(rtp_ctx->pb, &buf);
|
||||
if ((ret = ffio_open_dyn_packet_buf(&rtp_ctx->pb,
|
||||
RTP_MAX_PACKET_SIZE)) < 0)
|
||||
RTP_MAX_PACKET_SIZE)) < 0)
|
||||
goto done;
|
||||
|
||||
if (size <= 0)
|
||||
@ -445,8 +445,9 @@ done:
|
||||
return ret;
|
||||
}
|
||||
|
||||
void ff_mov_close_hinting(MOVTrack *track) {
|
||||
AVFormatContext* rtp_ctx = track->rtp_ctx;
|
||||
void ff_mov_close_hinting(MOVTrack *track)
|
||||
{
|
||||
AVFormatContext *rtp_ctx = track->rtp_ctx;
|
||||
uint8_t *ptr;
|
||||
|
||||
av_freep(&track->enc);
|
||||
|
Loading…
x
Reference in New Issue
Block a user