comparison movenc.c @ 3024:19de43025f0f libavformat

cosmetics, remove whitespaces before and after parenthesis
author bcoudurier
date Wed, 06 Feb 2008 18:57:00 +0000
parents 0718b931314a
children 7f0f50bbfe23
comparison
equal deleted inserted replaced
3023:61ea9e6ee162 3024:19de43025f0f
139 } 139 }
140 else { 140 else {
141 put_be32(pb, 0); // sample size 141 put_be32(pb, 0); // sample size
142 put_be32(pb, entries); // sample count 142 put_be32(pb, entries); // sample count
143 for (i=0; i<track->entry; i++) { 143 for (i=0; i<track->entry; i++) {
144 for ( j=0; j<track->cluster[i].entries; j++) { 144 for (j=0; j<track->cluster[i].entries; j++) {
145 put_be32(pb, track->cluster[i].size / 145 put_be32(pb, track->cluster[i].size /
146 track->cluster[i].entries); 146 track->cluster[i].entries);
147 } 147 }
148 } 148 }
149 } 149 }
885 put_be32(pb, 0x40000000); /* reserved */ 885 put_be32(pb, 0x40000000); /* reserved */
886 886
887 /* Track width and height, for visual only */ 887 /* Track width and height, for visual only */
888 if(track->enc->codec_type == CODEC_TYPE_VIDEO) { 888 if(track->enc->codec_type == CODEC_TYPE_VIDEO) {
889 double sample_aspect_ratio = av_q2d(track->enc->sample_aspect_ratio); 889 double sample_aspect_ratio = av_q2d(track->enc->sample_aspect_ratio);
890 if( !sample_aspect_ratio ) sample_aspect_ratio = 1; 890 if(!sample_aspect_ratio) sample_aspect_ratio = 1;
891 put_be32(pb, sample_aspect_ratio * track->enc->width*0x10000); 891 put_be32(pb, sample_aspect_ratio * track->enc->width*0x10000);
892 put_be32(pb, track->enc->height*0x10000); 892 put_be32(pb, track->enc->height*0x10000);
893 } 893 }
894 else { 894 else {
895 put_be32(pb, 0); 895 put_be32(pb, 0);
1057 } 1057 }
1058 } 1058 }
1059 1059
1060 static int mov_write_string_tag(ByteIOContext *pb, const char *name, const char *value, int long_style){ 1060 static int mov_write_string_tag(ByteIOContext *pb, const char *name, const char *value, int long_style){
1061 int size = 0; 1061 int size = 0;
1062 if ( value && value[0] ) { 1062 if (value && value[0]) {
1063 offset_t pos = url_ftell(pb); 1063 offset_t pos = url_ftell(pb);
1064 put_be32(pb, 0); /* size */ 1064 put_be32(pb, 0); /* size */
1065 put_tag(pb, name); 1065 put_tag(pb, name);
1066 mov_write_string_data_tag(pb, value, long_style); 1066 mov_write_string_data_tag(pb, value, long_style);
1067 size= updateSize(pb, pos); 1067 size= updateSize(pb, pos);
1083 /* iTunes track number */ 1083 /* iTunes track number */
1084 static int mov_write_trkn_tag(ByteIOContext *pb, MOVContext* mov, 1084 static int mov_write_trkn_tag(ByteIOContext *pb, MOVContext* mov,
1085 AVFormatContext *s) 1085 AVFormatContext *s)
1086 { 1086 {
1087 int size = 0; 1087 int size = 0;
1088 if ( s->track ) { 1088 if (s->track) {
1089 offset_t pos = url_ftell(pb); 1089 offset_t pos = url_ftell(pb);
1090 put_be32(pb, 0); /* size */ 1090 put_be32(pb, 0); /* size */
1091 put_tag(pb, "trkn"); 1091 put_tag(pb, "trkn");
1092 { 1092 {
1093 offset_t pos = url_ftell(pb); 1093 offset_t pos = url_ftell(pb);
1131 AVFormatContext *s) 1131 AVFormatContext *s)
1132 { 1132 {
1133 int size = 0; 1133 int size = 0;
1134 1134
1135 // only save meta tag if required 1135 // only save meta tag if required
1136 if ( s->title[0] || s->author[0] || s->album[0] || s->year || 1136 if (s->title[0] || s->author[0] || s->album[0] || s->year ||
1137 s->comment[0] || s->genre[0] || s->track ) { 1137 s->comment[0] || s->genre[0] || s->track) {
1138 offset_t pos = url_ftell(pb); 1138 offset_t pos = url_ftell(pb);
1139 put_be32(pb, 0); /* size */ 1139 put_be32(pb, 0); /* size */
1140 put_tag(pb, "meta"); 1140 put_tag(pb, "meta");
1141 put_be32(pb, 0); 1141 put_be32(pb, 0);
1142 mov_write_itunes_hdlr_tag(pb, mov, s); 1142 mov_write_itunes_hdlr_tag(pb, mov, s);
1229 if (s->title[0]) { 1229 if (s->title[0]) {
1230 pos = url_ftell(pb); 1230 pos = url_ftell(pb);
1231 put_be32(pb, 0); /* size placeholder*/ 1231 put_be32(pb, 0); /* size placeholder*/
1232 put_tag(pb, "uuid"); 1232 put_tag(pb, "uuid");
1233 put_tag(pb, "USMT"); 1233 put_tag(pb, "USMT");
1234 put_be32(pb, 0x21d24fce ); /* 96 bit UUID */ 1234 put_be32(pb, 0x21d24fce); /* 96 bit UUID */
1235 put_be32(pb, 0xbb88695c ); 1235 put_be32(pb, 0xbb88695c);
1236 put_be32(pb, 0xfac9c740 ); 1236 put_be32(pb, 0xfac9c740);
1237 size += 24; 1237 size += 24;
1238 1238
1239 put_be32(pb, 0); /* size placeholder*/ 1239 put_be32(pb, 0); /* size placeholder*/
1240 put_tag(pb, "MTDT"); 1240 put_tag(pb, "MTDT");
1241 put_be16(pb, 4); 1241 put_be16(pb, 4);
1344 /* TODO: This needs to be more general */ 1344 /* TODO: This needs to be more general */
1345 static void mov_write_ftyp_tag (ByteIOContext *pb, AVFormatContext *s) 1345 static void mov_write_ftyp_tag (ByteIOContext *pb, AVFormatContext *s)
1346 { 1346 {
1347 MOVContext *mov = s->priv_data; 1347 MOVContext *mov = s->priv_data;
1348 1348
1349 put_be32(pb, 0x14 ); /* size */ 1349 put_be32(pb, 0x14); /* size */
1350 put_tag(pb, "ftyp"); 1350 put_tag(pb, "ftyp");
1351 1351
1352 if ( mov->mode == MODE_3GP ) 1352 if (mov->mode == MODE_3GP)
1353 put_tag(pb, "3gp4"); 1353 put_tag(pb, "3gp4");
1354 else if ( mov->mode == MODE_3G2 ) 1354 else if (mov->mode == MODE_3G2)
1355 put_tag(pb, "3g2a"); 1355 put_tag(pb, "3g2a");
1356 else if ( mov->mode == MODE_PSP ) 1356 else if (mov->mode == MODE_PSP)
1357 put_tag(pb, "MSNV"); 1357 put_tag(pb, "MSNV");
1358 else if ( mov->mode == MODE_MP4 ) 1358 else if (mov->mode == MODE_MP4)
1359 put_tag(pb, "isom"); 1359 put_tag(pb, "isom");
1360 else 1360 else
1361 put_tag(pb, "qt "); 1361 put_tag(pb, "qt ");
1362 1362
1363 put_be32(pb, 0x200 ); 1363 put_be32(pb, 0x200);
1364 1364
1365 if ( mov->mode == MODE_3GP ) 1365 if (mov->mode == MODE_3GP)
1366 put_tag(pb, "3gp4"); 1366 put_tag(pb, "3gp4");
1367 else if ( mov->mode == MODE_3G2 ) 1367 else if (mov->mode == MODE_3G2)
1368 put_tag(pb, "3g2a"); 1368 put_tag(pb, "3g2a");
1369 else if ( mov->mode == MODE_PSP ) 1369 else if (mov->mode == MODE_PSP)
1370 put_tag(pb, "MSNV"); 1370 put_tag(pb, "MSNV");
1371 else if ( mov->mode == MODE_MP4 ) 1371 else if (mov->mode == MODE_MP4)
1372 put_tag(pb, "mp41"); 1372 put_tag(pb, "mp41");
1373 else 1373 else
1374 put_tag(pb, "qt "); 1374 put_tag(pb, "qt ");
1375 } 1375 }
1376 1376
1381 int AudioRate = AudioCodec->sample_rate; 1381 int AudioRate = AudioCodec->sample_rate;
1382 int FrameRate = ((VideoCodec->time_base.den) * (0x10000))/ (VideoCodec->time_base.num); 1382 int FrameRate = ((VideoCodec->time_base.den) * (0x10000))/ (VideoCodec->time_base.num);
1383 int audio_kbitrate= AudioCodec->bit_rate / 1000; 1383 int audio_kbitrate= AudioCodec->bit_rate / 1000;
1384 int video_kbitrate= FFMIN(VideoCodec->bit_rate / 1000, 800 - audio_kbitrate); 1384 int video_kbitrate= FFMIN(VideoCodec->bit_rate / 1000, 800 - audio_kbitrate);
1385 1385
1386 put_be32(pb, 0x94 ); /* size */ 1386 put_be32(pb, 0x94); /* size */
1387 put_tag(pb, "uuid"); 1387 put_tag(pb, "uuid");
1388 put_tag(pb, "PROF"); 1388 put_tag(pb, "PROF");
1389 1389
1390 put_be32(pb, 0x21d24fce ); /* 96 bit UUID */ 1390 put_be32(pb, 0x21d24fce); /* 96 bit UUID */
1391 put_be32(pb, 0xbb88695c ); 1391 put_be32(pb, 0xbb88695c);
1392 put_be32(pb, 0xfac9c740 ); 1392 put_be32(pb, 0xfac9c740);
1393 1393
1394 put_be32(pb, 0x0 ); /* ? */ 1394 put_be32(pb, 0x0); /* ? */
1395 put_be32(pb, 0x3 ); /* 3 sections ? */ 1395 put_be32(pb, 0x3); /* 3 sections ? */
1396 1396
1397 put_be32(pb, 0x14 ); /* size */ 1397 put_be32(pb, 0x14); /* size */
1398 put_tag(pb, "FPRF"); 1398 put_tag(pb, "FPRF");
1399 put_be32(pb, 0x0 ); /* ? */ 1399 put_be32(pb, 0x0); /* ? */
1400 put_be32(pb, 0x0 ); /* ? */ 1400 put_be32(pb, 0x0); /* ? */
1401 put_be32(pb, 0x0 ); /* ? */ 1401 put_be32(pb, 0x0); /* ? */
1402 1402
1403 put_be32(pb, 0x2c ); /* size */ 1403 put_be32(pb, 0x2c); /* size */
1404 put_tag(pb, "APRF"); /* audio */ 1404 put_tag(pb, "APRF"); /* audio */
1405 put_be32(pb, 0x0 ); 1405 put_be32(pb, 0x0);
1406 put_be32(pb, 0x2 ); /* TrackID */ 1406 put_be32(pb, 0x2); /* TrackID */
1407 put_tag(pb, "mp4a"); 1407 put_tag(pb, "mp4a");
1408 put_be32(pb, 0x20f ); 1408 put_be32(pb, 0x20f);
1409 put_be32(pb, 0x0 ); 1409 put_be32(pb, 0x0);
1410 put_be32(pb, audio_kbitrate); 1410 put_be32(pb, audio_kbitrate);
1411 put_be32(pb, audio_kbitrate); 1411 put_be32(pb, audio_kbitrate);
1412 put_be32(pb, AudioRate ); 1412 put_be32(pb, AudioRate);
1413 put_be32(pb, AudioCodec->channels ); 1413 put_be32(pb, AudioCodec->channels);
1414 1414
1415 put_be32(pb, 0x34 ); /* size */ 1415 put_be32(pb, 0x34); /* size */
1416 put_tag(pb, "VPRF"); /* video */ 1416 put_tag(pb, "VPRF"); /* video */
1417 put_be32(pb, 0x0 ); 1417 put_be32(pb, 0x0);
1418 put_be32(pb, 0x1 ); /* TrackID */ 1418 put_be32(pb, 0x1); /* TrackID */
1419 if (VideoCodec->codec_id == CODEC_ID_H264) { 1419 if (VideoCodec->codec_id == CODEC_ID_H264) {
1420 put_tag(pb, "avc1"); 1420 put_tag(pb, "avc1");
1421 put_be16(pb, 0x014D ); 1421 put_be16(pb, 0x014D);
1422 put_be16(pb, 0x0015 ); 1422 put_be16(pb, 0x0015);
1423 } else { 1423 } else {
1424 put_tag(pb, "mp4v"); 1424 put_tag(pb, "mp4v");
1425 put_be16(pb, 0x0000 ); 1425 put_be16(pb, 0x0000);
1426 put_be16(pb, 0x0103 ); 1426 put_be16(pb, 0x0103);
1427 } 1427 }
1428 put_be32(pb, 0x0 ); 1428 put_be32(pb, 0x0);
1429 put_be32(pb, video_kbitrate); 1429 put_be32(pb, video_kbitrate);
1430 put_be32(pb, video_kbitrate); 1430 put_be32(pb, video_kbitrate);
1431 put_be32(pb, FrameRate); 1431 put_be32(pb, FrameRate);
1432 put_be32(pb, FrameRate); 1432 put_be32(pb, FrameRate);
1433 put_be16(pb, VideoCodec->width); 1433 put_be16(pb, VideoCodec->width);
1454 else if (!strcmp("3g2", s->oformat->name)) mov->mode = MODE_3G2; 1454 else if (!strcmp("3g2", s->oformat->name)) mov->mode = MODE_3G2;
1455 else if (!strcmp("mov", s->oformat->name)) mov->mode = MODE_MOV; 1455 else if (!strcmp("mov", s->oformat->name)) mov->mode = MODE_MOV;
1456 else if (!strcmp("psp", s->oformat->name)) mov->mode = MODE_PSP; 1456 else if (!strcmp("psp", s->oformat->name)) mov->mode = MODE_PSP;
1457 1457
1458 mov_write_ftyp_tag(pb,s); 1458 mov_write_ftyp_tag(pb,s);
1459 if ( mov->mode == MODE_PSP ) { 1459 if (mov->mode == MODE_PSP) {
1460 if ( s->nb_streams != 2 ) { 1460 if (s->nb_streams != 2) {
1461 av_log(s, AV_LOG_ERROR, "PSP mode need one video and one audio stream\n"); 1461 av_log(s, AV_LOG_ERROR, "PSP mode need one video and one audio stream\n");
1462 return -1; 1462 return -1;
1463 } 1463 }
1464 mov_write_uuidprof_tag(pb,s); 1464 mov_write_uuidprof_tag(pb,s);
1465 } 1465 }
1619 mov_write_moov_tag(pb, mov, s); 1619 mov_write_moov_tag(pb, mov, s);
1620 1620
1621 for (i=0; i<mov->nb_streams; i++) { 1621 for (i=0; i<mov->nb_streams; i++) {
1622 av_freep(&mov->tracks[i].cluster); 1622 av_freep(&mov->tracks[i].cluster);
1623 1623
1624 if( mov->tracks[i].vosLen ) av_free( mov->tracks[i].vosData ); 1624 if(mov->tracks[i].vosLen) av_free(mov->tracks[i].vosData);
1625 1625
1626 } 1626 }
1627 1627
1628 put_flush_packet(pb); 1628 put_flush_packet(pb);
1629 1629