comparison movenc.c @ 5393:a3853508bb5c libavformat

remove useless mov timescale field
author bcoudurier
date Sun, 29 Nov 2009 02:46:49 +0000
parents 93d1192a9301
children 896dbdababcb
comparison
equal deleted inserted replaced
5392:93d1192a9301 5393:a3853508bb5c
31 31
32 #undef NDEBUG 32 #undef NDEBUG
33 #include <assert.h> 33 #include <assert.h>
34 34
35 #define MOV_INDEX_CLUSTER_SIZE 16384 35 #define MOV_INDEX_CLUSTER_SIZE 16384
36 #define globalTimescale 1000 36 #define MOV_TIMESCALE 1000
37 37
38 #define MODE_MP4 0x01 38 #define MODE_MP4 0x01
39 #define MODE_MOV 0x02 39 #define MODE_MOV 0x02
40 #define MODE_3GP 0x04 40 #define MODE_3GP 0x04
41 #define MODE_PSP 0x08 // example working PSP command line: 41 #define MODE_PSP 0x08 // example working PSP command line:
83 int mode; 83 int mode;
84 int64_t time; 84 int64_t time;
85 int nb_streams; 85 int nb_streams;
86 int64_t mdat_pos; 86 int64_t mdat_pos;
87 uint64_t mdat_size; 87 uint64_t mdat_size;
88 long timescale;
89 MOVTrack *tracks; 88 MOVTrack *tracks;
90 } MOVMuxContext; 89 } MOVMuxContext;
91 90
92 //FIXME support 64 bit variant with wide placeholders 91 //FIXME support 64 bit variant with wide placeholders
93 static int64_t updateSize(ByteIOContext *pb, int64_t pos) 92 static int64_t updateSize(ByteIOContext *pb, int64_t pos)
1141 return updateSize(pb, pos); 1140 return updateSize(pb, pos);
1142 } 1141 }
1143 1142
1144 static int mov_write_tkhd_tag(ByteIOContext *pb, MOVTrack *track, AVStream *st) 1143 static int mov_write_tkhd_tag(ByteIOContext *pb, MOVTrack *track, AVStream *st)
1145 { 1144 {
1146 int64_t duration = av_rescale_rnd(track->trackDuration, globalTimescale, track->timescale, AV_ROUND_UP); 1145 int64_t duration = av_rescale_rnd(track->trackDuration, MOV_TIMESCALE,
1146 track->timescale, AV_ROUND_UP);
1147 int version = duration < INT32_MAX ? 0 : 1; 1147 int version = duration < INT32_MAX ? 0 : 1;
1148 1148
1149 (version == 1) ? put_be32(pb, 104) : put_be32(pb, 92); /* size */ 1149 (version == 1) ? put_be32(pb, 104) : put_be32(pb, 92); /* size */
1150 put_tag(pb, "tkhd"); 1150 put_tag(pb, "tkhd");
1151 put_byte(pb, version); 1151 put_byte(pb, version);
1206 put_be32(pb, 0x1c); /* size */ 1206 put_be32(pb, 0x1c); /* size */
1207 put_tag(pb, "elst"); 1207 put_tag(pb, "elst");
1208 put_be32(pb, 0x0); 1208 put_be32(pb, 0x0);
1209 put_be32(pb, 0x1); 1209 put_be32(pb, 0x1);
1210 1210
1211 put_be32(pb, av_rescale_rnd(track->trackDuration, globalTimescale, track->timescale, AV_ROUND_UP)); /* duration ... doesn't seem to effect psp */ 1211 /* duration ... doesn't seem to effect psp */
1212 put_be32(pb, av_rescale_rnd(track->trackDuration, MOV_TIMESCALE,
1213 track->timescale, AV_ROUND_UP));
1212 1214
1213 put_be32(pb, track->cluster[0].cts); /* first pts is cts since dts is 0 */ 1215 put_be32(pb, track->cluster[0].cts); /* first pts is cts since dts is 0 */
1214 put_be32(pb, 0x00010000); 1216 put_be32(pb, 0x00010000);
1215 return 0x24; 1217 return 0x24;
1216 } 1218 }
1270 int64_t maxTrackLenTemp, maxTrackLen = 0; 1272 int64_t maxTrackLenTemp, maxTrackLen = 0;
1271 int version; 1273 int version;
1272 1274
1273 for (i=0; i<mov->nb_streams; i++) { 1275 for (i=0; i<mov->nb_streams; i++) {
1274 if(mov->tracks[i].entry > 0) { 1276 if(mov->tracks[i].entry > 0) {
1275 maxTrackLenTemp = av_rescale_rnd(mov->tracks[i].trackDuration, globalTimescale, mov->tracks[i].timescale, AV_ROUND_UP); 1277 maxTrackLenTemp = av_rescale_rnd(mov->tracks[i].trackDuration,
1278 MOV_TIMESCALE,
1279 mov->tracks[i].timescale,
1280 AV_ROUND_UP);
1276 if(maxTrackLen < maxTrackLenTemp) 1281 if(maxTrackLen < maxTrackLenTemp)
1277 maxTrackLen = maxTrackLenTemp; 1282 maxTrackLen = maxTrackLenTemp;
1278 if(maxTrackID < mov->tracks[i].trackID) 1283 if(maxTrackID < mov->tracks[i].trackID)
1279 maxTrackID = mov->tracks[i].trackID; 1284 maxTrackID = mov->tracks[i].trackID;
1280 } 1285 }
1290 put_be64(pb, mov->time); 1295 put_be64(pb, mov->time);
1291 } else { 1296 } else {
1292 put_be32(pb, mov->time); /* creation time */ 1297 put_be32(pb, mov->time); /* creation time */
1293 put_be32(pb, mov->time); /* modification time */ 1298 put_be32(pb, mov->time); /* modification time */
1294 } 1299 }
1295 put_be32(pb, mov->timescale); /* timescale */ 1300 put_be32(pb, MOV_TIMESCALE);
1296 (version == 1) ? put_be64(pb, maxTrackLen) : put_be32(pb, maxTrackLen); /* duration of longest track */ 1301 (version == 1) ? put_be64(pb, maxTrackLen) : put_be32(pb, maxTrackLen); /* duration of longest track */
1297 1302
1298 put_be32(pb, 0x00010000); /* reserved (preferred rate) 1.0 = normal */ 1303 put_be32(pb, 0x00010000); /* reserved (preferred rate) 1.0 = normal */
1299 put_be16(pb, 0x0100); /* reserved (preferred volume) 1.0 = normal */ 1304 put_be16(pb, 0x0100); /* reserved (preferred volume) 1.0 = normal */
1300 put_be16(pb, 0); /* reserved */ 1305 put_be16(pb, 0); /* reserved */
1613 { 1618 {
1614 int i; 1619 int i;
1615 int64_t pos = url_ftell(pb); 1620 int64_t pos = url_ftell(pb);
1616 put_be32(pb, 0); /* size placeholder*/ 1621 put_be32(pb, 0); /* size placeholder*/
1617 put_tag(pb, "moov"); 1622 put_tag(pb, "moov");
1618 mov->timescale = globalTimescale;
1619 1623
1620 for (i=0; i<mov->nb_streams; i++) { 1624 for (i=0; i<mov->nb_streams; i++) {
1621 if(mov->tracks[i].entry <= 0) continue; 1625 if(mov->tracks[i].entry <= 0) continue;
1622 1626
1623 mov->tracks[i].time = mov->time; 1627 mov->tracks[i].time = mov->time;