Commit df486e1b authored by michaelni's avatar michaelni

mov/mp4 muxer cleanup (mostly cosmetics/simplifications & global header fix)


git-svn-id: file:///var/local/repositories/ffmpeg/trunk@2249 9553f0bf-9b14-0410-a0b8-cfaf0461ba5b
parent e9e720aa
...@@ -2191,6 +2191,9 @@ static void opt_output_file(const char *filename) ...@@ -2191,6 +2191,9 @@ static void opt_output_file(const char *filename)
avcodec_get_context_defaults(&st->codec); avcodec_get_context_defaults(&st->codec);
video_enc = &st->codec; video_enc = &st->codec;
if(!strcmp(file_oformat->name, "mp4") || !strcmp(file_oformat->name, "mov") || !strcmp(file_oformat->name, "3gp"))
video_enc->flags |= CODEC_FLAG_GLOBAL_HEADER;
if (video_stream_copy) { if (video_stream_copy) {
st->stream_copy = 1; st->stream_copy = 1;
video_enc->codec_type = CODEC_TYPE_VIDEO; video_enc->codec_type = CODEC_TYPE_VIDEO;
......
...@@ -20,6 +20,9 @@ ...@@ -20,6 +20,9 @@
#include "avio.h" #include "avio.h"
#include <time.h> #include <time.h>
#undef NDEBUG
#include <assert.h>
/* /*
* Limitations * Limitations
* - Currently supports h.263, MPEG4 video codecs, and AMR audio codec. * - Currently supports h.263, MPEG4 video codecs, and AMR audio codec.
...@@ -47,7 +50,7 @@ typedef struct MOVIndex { ...@@ -47,7 +50,7 @@ typedef struct MOVIndex {
AVCodecContext *enc; AVCodecContext *enc;
int vosLen; int vosLen;
char *vosData; uint8_t *vosData;
MOVIentry** cluster; MOVIentry** cluster;
} MOVTrack; } MOVTrack;
...@@ -59,15 +62,18 @@ typedef struct { ...@@ -59,15 +62,18 @@ typedef struct {
MOVTrack tracks[MAX_STREAMS]; MOVTrack tracks[MAX_STREAMS];
} MOVContext; } MOVContext;
void writeSize (ByteIOContext *pb, int pos, int size) //FIXME supprt 64bit varaint with wide placeholders
static int updateSize (ByteIOContext *pb, int pos)
{ {
long curpos = url_ftell(pb); long curpos = url_ftell(pb);
url_fseek(pb, pos, SEEK_SET); url_fseek(pb, pos, SEEK_SET);
put_be32(pb, size); /* rewrite size */ put_be32(pb, curpos - pos); /* rewrite size */
url_fseek(pb, curpos, SEEK_SET); url_fseek(pb, curpos, SEEK_SET);
return curpos - pos;
} }
int mov_write_stco_tag(ByteIOContext *pb, MOVTrack* track) static int mov_write_stco_tag(ByteIOContext *pb, MOVTrack* track)
{ {
int i; int i;
put_be32(pb, 16+track->entry*4); /* size */ put_be32(pb, 16+track->entry*4); /* size */
...@@ -82,7 +88,7 @@ int mov_write_stco_tag(ByteIOContext *pb, MOVTrack* track) ...@@ -82,7 +88,7 @@ int mov_write_stco_tag(ByteIOContext *pb, MOVTrack* track)
return 16+track->entry*4; return 16+track->entry*4;
} }
int mov_write_stsz_tag(ByteIOContext *pb, MOVTrack* track) static int mov_write_stsz_tag(ByteIOContext *pb, MOVTrack* track)
{ {
int i, size; int i, size;
...@@ -114,7 +120,7 @@ int mov_write_stsz_tag(ByteIOContext *pb, MOVTrack* track) ...@@ -114,7 +120,7 @@ int mov_write_stsz_tag(ByteIOContext *pb, MOVTrack* track)
return size; return size;
} }
int mov_write_stsc_tag(ByteIOContext *pb, MOVTrack* track) static int mov_write_stsc_tag(ByteIOContext *pb, MOVTrack* track)
{ {
int size; int size;
if(track->cluster[0][0].entries != 0) if(track->cluster[0][0].entries != 0)
...@@ -145,7 +151,8 @@ int mov_write_stsc_tag(ByteIOContext *pb, MOVTrack* track) ...@@ -145,7 +151,8 @@ int mov_write_stsc_tag(ByteIOContext *pb, MOVTrack* track)
return size; return size;
} }
int mov_write_stss_tag(ByteIOContext *pb) //TRA OK //FIXME keyframes?
static int mov_write_stss_tag(ByteIOContext *pb) //TRA OK
{ {
put_be32(pb, 0x14); /* size */ put_be32(pb, 0x14); /* size */
put_tag(pb, "stss"); put_tag(pb, "stss");
...@@ -155,7 +162,7 @@ int mov_write_stss_tag(ByteIOContext *pb) //TRA OK ...@@ -155,7 +162,7 @@ int mov_write_stss_tag(ByteIOContext *pb) //TRA OK
return 0x14; return 0x14;
} }
int mov_write_damr_tag(ByteIOContext *pb) static int mov_write_damr_tag(ByteIOContext *pb)
{ {
put_be32(pb, 0x11); /* size */ put_be32(pb, 0x11); /* size */
put_tag(pb, "damr"); put_tag(pb, "damr");
...@@ -166,11 +173,9 @@ int mov_write_damr_tag(ByteIOContext *pb) ...@@ -166,11 +173,9 @@ int mov_write_damr_tag(ByteIOContext *pb)
return 0x11; return 0x11;
} }
int mov_write_samr_tag(ByteIOContext *pb, MOVTrack* track) static int mov_write_samr_tag(ByteIOContext *pb, MOVTrack* track)
{ {
int size = 0x24; int pos = url_ftell(pb);
int pos;
pos = url_ftell(pb);
put_be32(pb, 0); /* size */ put_be32(pb, 0); /* size */
/* "samr" for AMR NB, "sawb" for AMR WB */ /* "samr" for AMR NB, "sawb" for AMR WB */
put_tag(pb, "samr"); put_tag(pb, "samr");
...@@ -186,12 +191,11 @@ int mov_write_samr_tag(ByteIOContext *pb, MOVTrack* track) ...@@ -186,12 +191,11 @@ int mov_write_samr_tag(ByteIOContext *pb, MOVTrack* track)
put_be16(pb, track->timescale); /* Time scale */ put_be16(pb, track->timescale); /* Time scale */
put_be16(pb, 0); /* Reserved */ put_be16(pb, 0); /* Reserved */
size += mov_write_damr_tag(pb); mov_write_damr_tag(pb);
writeSize (pb, pos, size); return updateSize (pb, pos);
return size;
} }
int mov_write_d263_tag(ByteIOContext *pb) static int mov_write_d263_tag(ByteIOContext *pb)
{ {
put_be32(pb, 0xf); /* size */ put_be32(pb, 0xf); /* size */
put_tag(pb, "d263"); put_tag(pb, "d263");
...@@ -201,11 +205,9 @@ int mov_write_d263_tag(ByteIOContext *pb) ...@@ -201,11 +205,9 @@ int mov_write_d263_tag(ByteIOContext *pb)
return 0xf; return 0xf;
} }
int mov_write_s263_tag(ByteIOContext *pb, MOVTrack* track) static int mov_write_s263_tag(ByteIOContext *pb, MOVTrack* track)
{ {
int size = 0x56; int pos = url_ftell(pb);
int pos;
pos = url_ftell(pb);
put_be32(pb, 0); /* size */ put_be32(pb, 0); /* size */
put_tag(pb, "s263"); put_tag(pb, "s263");
put_be32(pb, 0); /* Reserved */ put_be32(pb, 0); /* Reserved */
...@@ -231,9 +233,8 @@ int mov_write_s263_tag(ByteIOContext *pb, MOVTrack* track) ...@@ -231,9 +233,8 @@ int mov_write_s263_tag(ByteIOContext *pb, MOVTrack* track)
put_be32(pb, 0); /* Reserved */ put_be32(pb, 0); /* Reserved */
put_be16(pb, 0x18); /* Reserved */ put_be16(pb, 0x18); /* Reserved */
put_be16(pb, 0xffff); /* Reserved */ put_be16(pb, 0xffff); /* Reserved */
size += mov_write_d263_tag(pb); mov_write_d263_tag(pb);
writeSize (pb, pos, size); return updateSize (pb, pos);
return size;
} }
static unsigned int esdsLength(unsigned int len) static unsigned int esdsLength(unsigned int len)
...@@ -250,7 +251,7 @@ static unsigned int esdsLength(unsigned int len) ...@@ -250,7 +251,7 @@ static unsigned int esdsLength(unsigned int len)
return result; return result;
} }
int mov_write_esds_tag(ByteIOContext *pb, MOVTrack* track) // Basic static int mov_write_esds_tag(ByteIOContext *pb, MOVTrack* track) // Basic
{ {
put_be32(pb, track->vosLen+18+14+17); put_be32(pb, track->vosLen+18+14+17);
put_tag(pb, "esds"); put_tag(pb, "esds");
...@@ -284,9 +285,11 @@ int mov_write_esds_tag(ByteIOContext *pb, MOVTrack* track) // Basic ...@@ -284,9 +285,11 @@ int mov_write_esds_tag(ByteIOContext *pb, MOVTrack* track) // Basic
return track->vosLen+18+14+17; return track->vosLen+18+14+17;
} }
int mov_write_mp4v_tag(ByteIOContext *pb, MOVTrack* track) // Basic static int mov_write_mp4v_tag(ByteIOContext *pb, MOVTrack* track) // Basic
{ {
put_be32(pb, 194); int pos = url_ftell(pb);
put_be32(pb, 0);
put_tag(pb, "mp4v"); put_tag(pb, "mp4v");
put_be32(pb, 0); // Reserved put_be32(pb, 0); // Reserved
put_be16(pb, 0); // Reserved put_be16(pb, 0); // Reserved
...@@ -312,33 +315,30 @@ int mov_write_mp4v_tag(ByteIOContext *pb, MOVTrack* track) // Basic ...@@ -312,33 +315,30 @@ int mov_write_mp4v_tag(ByteIOContext *pb, MOVTrack* track) // Basic
put_be16(pb, 24); // Reserved put_be16(pb, 24); // Reserved
put_be16(pb, 0xFFFF); // Reserved put_be16(pb, 0xFFFF); // Reserved
mov_write_esds_tag(pb, track); mov_write_esds_tag(pb, track);
return 194; return updateSize(pb, pos);
} }
int mov_write_stsd_tag(ByteIOContext *pb, MOVTrack* track) static int mov_write_stsd_tag(ByteIOContext *pb, MOVTrack* track)
{ {
int size = 16; int pos = url_ftell(pb);
int pos;
pos = url_ftell(pb);
put_be32(pb, 0); /* size */ put_be32(pb, 0); /* size */
put_tag(pb, "stsd"); put_tag(pb, "stsd");
put_be32(pb, 0); /* version & flags */ put_be32(pb, 0); /* version & flags */
put_be32(pb, 1); /* entry count */ put_be32(pb, 1); /* entry count */
if (track->enc->codec_type == CODEC_TYPE_VIDEO) { if (track->enc->codec_type == CODEC_TYPE_VIDEO) {
if (track->enc->codec_id == CODEC_ID_H263) if (track->enc->codec_id == CODEC_ID_H263)
size += mov_write_s263_tag(pb, track); mov_write_s263_tag(pb, track);
else if (track->enc->codec_id == CODEC_ID_MPEG4) else if (track->enc->codec_id == CODEC_ID_MPEG4)
size += mov_write_mp4v_tag(pb, track); mov_write_mp4v_tag(pb, track);
} }
else if (track->enc->codec_type == CODEC_TYPE_AUDIO) { else if (track->enc->codec_type == CODEC_TYPE_AUDIO) {
if (track->enc->codec_id == CODEC_ID_AMR_NB) if (track->enc->codec_id == CODEC_ID_AMR_NB)
size += mov_write_samr_tag(pb, track); mov_write_samr_tag(pb, track);
} }
writeSize (pb, pos, size); return updateSize(pb, pos);
return size;
} }
int mov_write_stts_tag(ByteIOContext *pb, MOVTrack* track) static int mov_write_stts_tag(ByteIOContext *pb, MOVTrack* track)
{ {
put_be32(pb, 0x18); /* size */ put_be32(pb, 0x18); /* size */
put_tag(pb, "stts"); put_tag(pb, "stts");
...@@ -350,7 +350,7 @@ int mov_write_stts_tag(ByteIOContext *pb, MOVTrack* track) ...@@ -350,7 +350,7 @@ int mov_write_stts_tag(ByteIOContext *pb, MOVTrack* track)
return 0x18; return 0x18;
} }
int mov_write_dref_tag(ByteIOContext *pb) static int mov_write_dref_tag(ByteIOContext *pb)
{ {
put_be32(pb, 28); /* size */ put_be32(pb, 28); /* size */
put_tag(pb, "dref"); put_tag(pb, "dref");
...@@ -364,37 +364,31 @@ int mov_write_dref_tag(ByteIOContext *pb) ...@@ -364,37 +364,31 @@ int mov_write_dref_tag(ByteIOContext *pb)
return 28; return 28;
} }
int mov_write_stbl_tag(ByteIOContext *pb, MOVTrack* track) static int mov_write_stbl_tag(ByteIOContext *pb, MOVTrack* track)
{ {
int size = 8; int pos = url_ftell(pb);
int pos;
pos = url_ftell(pb);
put_be32(pb, 0); /* size */ put_be32(pb, 0); /* size */
put_tag(pb, "stbl"); put_tag(pb, "stbl");
size += mov_write_stsd_tag(pb, track); mov_write_stsd_tag(pb, track);
size += mov_write_stts_tag(pb, track); mov_write_stts_tag(pb, track);
if (track->enc->codec_type == CODEC_TYPE_VIDEO) if (track->enc->codec_type == CODEC_TYPE_VIDEO)
size += mov_write_stss_tag(pb); mov_write_stss_tag(pb);
size += mov_write_stsc_tag(pb, track); mov_write_stsc_tag(pb, track);
size += mov_write_stsz_tag(pb, track); mov_write_stsz_tag(pb, track);
size += mov_write_stco_tag(pb, track); mov_write_stco_tag(pb, track);
writeSize (pb, pos, size); return updateSize(pb, pos);
return size;
} }
int mov_write_dinf_tag(ByteIOContext *pb) static int mov_write_dinf_tag(ByteIOContext *pb)
{ {
int size = 8; int pos = url_ftell(pb);
int pos;
pos = url_ftell(pb);
put_be32(pb, 0); /* size */ put_be32(pb, 0); /* size */
put_tag(pb, "dinf"); put_tag(pb, "dinf");
size += mov_write_dref_tag(pb); mov_write_dref_tag(pb);
writeSize (pb, pos, size); return updateSize(pb, pos);
return size;
} }
int mov_write_smhd_tag(ByteIOContext *pb) static int mov_write_smhd_tag(ByteIOContext *pb)
{ {
put_be32(pb, 16); /* size */ put_be32(pb, 16); /* size */
put_tag(pb, "smhd"); put_tag(pb, "smhd");
...@@ -404,7 +398,7 @@ int mov_write_smhd_tag(ByteIOContext *pb) ...@@ -404,7 +398,7 @@ int mov_write_smhd_tag(ByteIOContext *pb)
return 16; return 16;
} }
int mov_write_vmhd_tag(ByteIOContext *pb) static int mov_write_vmhd_tag(ByteIOContext *pb)
{ {
put_be32(pb, 0x14); /* size (always 0x14) */ put_be32(pb, 0x14); /* size (always 0x14) */
put_tag(pb, "vmhd"); put_tag(pb, "vmhd");
...@@ -413,24 +407,21 @@ int mov_write_vmhd_tag(ByteIOContext *pb) ...@@ -413,24 +407,21 @@ int mov_write_vmhd_tag(ByteIOContext *pb)
return 0x14; return 0x14;
} }
int mov_write_minf_tag(ByteIOContext *pb, MOVTrack* track) static int mov_write_minf_tag(ByteIOContext *pb, MOVTrack* track)
{ {
int size = 8; int pos = url_ftell(pb);
int pos;
pos = url_ftell(pb);
put_be32(pb, 0); /* size */ put_be32(pb, 0); /* size */
put_tag(pb, "minf"); put_tag(pb, "minf");
if(track->enc->codec_type == CODEC_TYPE_VIDEO) if(track->enc->codec_type == CODEC_TYPE_VIDEO)
size += mov_write_vmhd_tag(pb); mov_write_vmhd_tag(pb);
else else
size += mov_write_smhd_tag(pb); mov_write_smhd_tag(pb);
size += mov_write_dinf_tag(pb); mov_write_dinf_tag(pb);
size += mov_write_stbl_tag(pb, track); mov_write_stbl_tag(pb, track);
writeSize (pb, pos, size); return updateSize(pb, pos);
return size;
} }
int mov_write_hdlr_tag(ByteIOContext *pb, MOVTrack* track) static int mov_write_hdlr_tag(ByteIOContext *pb, MOVTrack* track)
{ {
int size = 0; int size = 0;
size = 45; size = 45;
...@@ -461,7 +452,7 @@ int mov_write_hdlr_tag(ByteIOContext *pb, MOVTrack* track) ...@@ -461,7 +452,7 @@ int mov_write_hdlr_tag(ByteIOContext *pb, MOVTrack* track)
return size; return size;
} }
int mov_write_mdhd_tag(ByteIOContext *pb, MOVTrack* track) static int mov_write_mdhd_tag(ByteIOContext *pb, MOVTrack* track)
{ {
put_be32(pb, 32); /* size */ put_be32(pb, 32); /* size */
put_tag(pb, "mdhd"); put_tag(pb, "mdhd");
...@@ -476,21 +467,18 @@ int mov_write_mdhd_tag(ByteIOContext *pb, MOVTrack* track) ...@@ -476,21 +467,18 @@ int mov_write_mdhd_tag(ByteIOContext *pb, MOVTrack* track)
return 32; return 32;
} }
int mov_write_mdia_tag(ByteIOContext *pb, MOVTrack* track) static int mov_write_mdia_tag(ByteIOContext *pb, MOVTrack* track)
{ {
int size = 8; int pos = url_ftell(pb);
int pos;
pos = url_ftell(pb);
put_be32(pb, 0); /* size */ put_be32(pb, 0); /* size */
put_tag(pb, "mdia"); put_tag(pb, "mdia");
size += mov_write_mdhd_tag(pb, track); mov_write_mdhd_tag(pb, track);
size += mov_write_hdlr_tag(pb, track); mov_write_hdlr_tag(pb, track);
size += mov_write_minf_tag(pb, track); mov_write_minf_tag(pb, track);
writeSize (pb, pos, size); return updateSize(pb, pos);
return size;
} }
int mov_write_tkhd_tag(ByteIOContext *pb, MOVTrack* track) static int mov_write_tkhd_tag(ByteIOContext *pb, MOVTrack* track)
{ {
put_be32(pb, 0x5c); /* size (always 0x5c) */ put_be32(pb, 0x5c); /* size (always 0x5c) */
put_tag(pb, "tkhd"); put_tag(pb, "tkhd");
...@@ -534,21 +522,18 @@ int mov_write_tkhd_tag(ByteIOContext *pb, MOVTrack* track) ...@@ -534,21 +522,18 @@ int mov_write_tkhd_tag(ByteIOContext *pb, MOVTrack* track)
return 0x5c; return 0x5c;
} }
int mov_write_trak_tag(ByteIOContext *pb, MOVTrack* track) static int mov_write_trak_tag(ByteIOContext *pb, MOVTrack* track)
{ {
int size = 8; int pos = url_ftell(pb);
int pos;
pos = url_ftell(pb);
put_be32(pb, 0); /* size */ put_be32(pb, 0); /* size */
put_tag(pb, "trak"); put_tag(pb, "trak");
size += mov_write_tkhd_tag(pb, track); mov_write_tkhd_tag(pb, track);
size += mov_write_mdia_tag(pb, track); mov_write_mdia_tag(pb, track);
writeSize (pb, pos, size); return updateSize(pb, pos);
return size;
} }
/* TODO: Not sorted out, but not necessary either */ /* TODO: Not sorted out, but not necessary either */
int mov_write_iods_tag(ByteIOContext *pb, MOVContext *mov) static int mov_write_iods_tag(ByteIOContext *pb, MOVContext *mov)
{ {
put_be32(pb, 0x15); /* size */ put_be32(pb, 0x15); /* size */
put_tag(pb, "iods"); put_tag(pb, "iods");
...@@ -561,7 +546,7 @@ int mov_write_iods_tag(ByteIOContext *pb, MOVContext *mov) ...@@ -561,7 +546,7 @@ int mov_write_iods_tag(ByteIOContext *pb, MOVContext *mov)
return 0x15; return 0x15;
} }
int mov_write_mvhd_tag(ByteIOContext *pb, MOVContext *mov) static int mov_write_mvhd_tag(ByteIOContext *pb, MOVContext *mov)
{ {
int maxTrackID = 1, maxTrackLen = 0, i; int maxTrackID = 1, maxTrackLen = 0, i;
...@@ -608,9 +593,9 @@ int mov_write_mvhd_tag(ByteIOContext *pb, MOVContext *mov) ...@@ -608,9 +593,9 @@ int mov_write_mvhd_tag(ByteIOContext *pb, MOVContext *mov)
return 0x6c; return 0x6c;
} }
int mov_write_moov_tag(ByteIOContext *pb, MOVContext *mov) static int mov_write_moov_tag(ByteIOContext *pb, MOVContext *mov)
{ {
int pos, size = 8, i; int pos, i;
pos = url_ftell(pb); pos = url_ftell(pb);
put_be32(pb, 0); /* size placeholder*/ put_be32(pb, 0); /* size placeholder*/
put_tag(pb, "moov"); put_tag(pb, "moov");
...@@ -641,17 +626,15 @@ int mov_write_moov_tag(ByteIOContext *pb, MOVContext *mov) ...@@ -641,17 +626,15 @@ int mov_write_moov_tag(ByteIOContext *pb, MOVContext *mov)
} }
} }
size += mov_write_mvhd_tag(pb, mov); mov_write_mvhd_tag(pb, mov);
//size += mov_write_iods_tag(pb, mov); //mov_write_iods_tag(pb, mov);
for (i=0; i<MAX_STREAMS; i++) { for (i=0; i<MAX_STREAMS; i++) {
if(mov->tracks[i].entry > 0) { if(mov->tracks[i].entry > 0) {
size += mov_write_trak_tag(pb, &(mov->tracks[i])); mov_write_trak_tag(pb, &(mov->tracks[i]));
} }
} }
writeSize (pb, pos, size); return updateSize(pb, pos);
return size;
} }
int mov_write_mdat_tag(ByteIOContext *pb, MOVTrack* track) int mov_write_mdat_tag(ByteIOContext *pb, MOVTrack* track)
...@@ -705,8 +688,7 @@ static int mov_write_packet(AVFormatContext *s, int stream_index, ...@@ -705,8 +688,7 @@ static int mov_write_packet(AVFormatContext *s, int stream_index,
int sampleCount = 0; int sampleCount = 0;
/* We must find out how many AMR blocks there are in one packet */ /* We must find out how many AMR blocks there are in one packet */
if(enc->codec_type == CODEC_TYPE_AUDIO && if(enc->codec_id == CODEC_ID_AMR_NB) {
enc->codec_id == CODEC_ID_AMR_NB) {
static uint16_t packed_size[16] = {13, 14, 16, 18, 20, 21, 27, 32, 6, 0, 0, 0, 0, 0, 0, 0}; static uint16_t packed_size[16] = {13, 14, 16, 18, 20, 21, 27, 32, 6, 0, 0, 0, 0, 0, 0, 0};
int len = 0; int len = 0;
...@@ -715,30 +697,15 @@ static int mov_write_packet(AVFormatContext *s, int stream_index, ...@@ -715,30 +697,15 @@ static int mov_write_packet(AVFormatContext *s, int stream_index,
sampleCount++; sampleCount++;
} }
} }
/* TODO: Is there some other way to get VOS block from MPEG4 stream? */
if(enc->codec_type == CODEC_TYPE_VIDEO && if(enc->codec_id == CODEC_ID_MPEG4 &&
enc->codec_id == CODEC_ID_MPEG4 &&
trk->vosLen == 0) trk->vosLen == 0)
{ {
int index = 0; assert(enc->extradata_size);
int vosStart = 0;
while(index < size) { trk->vosLen = enc->extradata_size;
if(buf[index] == 0 && buf[index+1] == 0 && buf[index+2] == 1) { trk->vosData = av_malloc(trk->vosLen);
index+=3; memcpy(trk->vosData, enc->extradata, trk->vosLen);
if(buf[index] == 0xB6) {
if(vosStart != 0) {
trk->vosLen = index-3 - (vosStart-3);
trk->vosData = av_malloc(trk->vosLen+2);
memcpy(trk->vosData, (char *)&buf[vosStart-3], trk->vosLen);
break;
}
}
else if(buf[index] == 0xb0) {
vosStart = index;
}
}
index++;
}
} }
cl = trk->entry / MOV_INDEX_CLUSTER_SIZE; cl = trk->entry / MOV_INDEX_CLUSTER_SIZE;
...@@ -757,6 +724,7 @@ static int mov_write_packet(AVFormatContext *s, int stream_index, ...@@ -757,6 +724,7 @@ static int mov_write_packet(AVFormatContext *s, int stream_index,
mov_write_mdat_tag(pb, trk); mov_write_mdat_tag(pb, trk);
mov->time = Timestamp(); mov->time = Timestamp();
} }
trk->cluster[cl][id].pos = url_ftell(pb) - mov->movi_list; trk->cluster[cl][id].pos = url_ftell(pb) - mov->movi_list;
trk->cluster[cl][id].len = size; trk->cluster[cl][id].len = size;
trk->cluster[cl][id].entries = sampleCount; trk->cluster[cl][id].entries = sampleCount;
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment