Revision 0abdb293 libavformat/movenc.c
libavformat/movenc.c | ||
---|---|---|
23 | 23 |
|
24 | 24 |
#include "movenc.h" |
25 | 25 |
#include "avformat.h" |
26 |
#include "avio_internal.h" |
|
26 | 27 |
#include "riff.h" |
27 | 28 |
#include "avio.h" |
28 | 29 |
#include "isom.h" |
... | ... | |
55 | 56 |
avio_wb32(pb, 0); /* size */ |
56 | 57 |
if (pos > UINT32_MAX) { |
57 | 58 |
mode64 = 1; |
58 |
put_tag(pb, "co64");
|
|
59 |
ffio_wfourcc(pb, "co64");
|
|
59 | 60 |
} else |
60 |
put_tag(pb, "stco");
|
|
61 |
ffio_wfourcc(pb, "stco");
|
|
61 | 62 |
avio_wb32(pb, 0); /* version & flags */ |
62 | 63 |
avio_wb32(pb, track->entry); /* entry count */ |
63 | 64 |
for (i=0; i<track->entry; i++) { |
... | ... | |
77 | 78 |
|
78 | 79 |
int64_t pos = url_ftell(pb); |
79 | 80 |
avio_wb32(pb, 0); /* size */ |
80 |
put_tag(pb, "stsz");
|
|
81 |
ffio_wfourcc(pb, "stsz");
|
|
81 | 82 |
avio_wb32(pb, 0); /* version & flags */ |
82 | 83 |
|
83 | 84 |
for (i=0; i<track->entry; i++) { |
... | ... | |
114 | 115 |
|
115 | 116 |
int64_t pos = url_ftell(pb); |
116 | 117 |
avio_wb32(pb, 0); /* size */ |
117 |
put_tag(pb, "stsc");
|
|
118 |
ffio_wfourcc(pb, "stsc");
|
|
118 | 119 |
avio_wb32(pb, 0); // version & flags |
119 | 120 |
entryPos = url_ftell(pb); |
120 | 121 |
avio_wb32(pb, track->entry); // entry count |
... | ... | |
143 | 144 |
int i, index = 0; |
144 | 145 |
int64_t pos = url_ftell(pb); |
145 | 146 |
avio_wb32(pb, 0); // size |
146 |
put_tag(pb, flag == MOV_SYNC_SAMPLE ? "stss" : "stps");
|
|
147 |
ffio_wfourcc(pb, flag == MOV_SYNC_SAMPLE ? "stss" : "stps");
|
|
147 | 148 |
avio_wb32(pb, 0); // version & flags |
148 | 149 |
entryPos = url_ftell(pb); |
149 | 150 |
avio_wb32(pb, track->entry); // entry count |
... | ... | |
163 | 164 |
static int mov_write_amr_tag(AVIOContext *pb, MOVTrack *track) |
164 | 165 |
{ |
165 | 166 |
avio_wb32(pb, 0x11); /* size */ |
166 |
if (track->mode == MODE_MOV) put_tag(pb, "samr");
|
|
167 |
else put_tag(pb, "damr");
|
|
168 |
put_tag(pb, "FFMP");
|
|
167 |
if (track->mode == MODE_MOV) ffio_wfourcc(pb, "samr");
|
|
168 |
else ffio_wfourcc(pb, "damr");
|
|
169 |
ffio_wfourcc(pb, "FFMP");
|
|
169 | 170 |
avio_w8(pb, 0); /* decoder version */ |
170 | 171 |
|
171 | 172 |
avio_wb16(pb, 0x81FF); /* Mode set (all modes for AMR_NB) */ |
... | ... | |
185 | 186 |
return -1; |
186 | 187 |
|
187 | 188 |
avio_wb32(pb, 11); |
188 |
put_tag(pb, "dac3");
|
|
189 |
ffio_wfourcc(pb, "dac3");
|
|
189 | 190 |
|
190 | 191 |
init_get_bits(&gbc, track->vosData+4, track->vosLen-4); |
191 | 192 |
fscod = get_bits(&gbc, 2); |
... | ... | |
231 | 232 |
static int mov_write_enda_tag(AVIOContext *pb) |
232 | 233 |
{ |
233 | 234 |
avio_wb32(pb, 10); |
234 |
put_tag(pb, "enda");
|
|
235 |
ffio_wfourcc(pb, "enda");
|
|
235 | 236 |
avio_wb16(pb, 1); /* little endian */ |
236 | 237 |
return 10; |
237 | 238 |
} |
... | ... | |
258 | 259 |
int decoderSpecificInfoLen = track->vosLen ? descrLength(track->vosLen):0; |
259 | 260 |
|
260 | 261 |
avio_wb32(pb, 0); // size |
261 |
put_tag(pb, "esds");
|
|
262 |
ffio_wfourcc(pb, "esds");
|
|
262 | 263 |
avio_wb32(pb, 0); // Version |
263 | 264 |
|
264 | 265 |
// ES descriptor |
... | ... | |
329 | 330 |
int64_t pos = url_ftell(pb); |
330 | 331 |
|
331 | 332 |
avio_wb32(pb, 0); /* size */ |
332 |
put_tag(pb, "wave");
|
|
333 |
ffio_wfourcc(pb, "wave");
|
|
333 | 334 |
|
334 | 335 |
avio_wb32(pb, 12); /* size */ |
335 |
put_tag(pb, "frma");
|
|
336 |
ffio_wfourcc(pb, "frma");
|
|
336 | 337 |
avio_wl32(pb, track->tag); |
337 | 338 |
|
338 | 339 |
if (track->enc->codec_id == CODEC_ID_AAC) { |
339 | 340 |
/* useless atom needed by mplayer, ipod, not needed by quicktime */ |
340 | 341 |
avio_wb32(pb, 12); /* size */ |
341 |
put_tag(pb, "mp4a");
|
|
342 |
ffio_wfourcc(pb, "mp4a");
|
|
342 | 343 |
avio_wb32(pb, 0); |
343 | 344 |
mov_write_esds_tag(pb, track); |
344 | 345 |
} else if (mov_pcm_le_gt16(track->enc->codec_id)) { |
... | ... | |
363 | 364 |
static int mov_write_glbl_tag(AVIOContext *pb, MOVTrack *track) |
364 | 365 |
{ |
365 | 366 |
avio_wb32(pb, track->vosLen+8); |
366 |
put_tag(pb, "glbl");
|
|
367 |
ffio_wfourcc(pb, "glbl");
|
|
367 | 368 |
avio_write(pb, track->vosData, track->vosLen); |
368 | 369 |
return 8+track->vosLen; |
369 | 370 |
} |
... | ... | |
493 | 494 |
static int mov_write_d263_tag(AVIOContext *pb) |
494 | 495 |
{ |
495 | 496 |
avio_wb32(pb, 0xf); /* size */ |
496 |
put_tag(pb, "d263");
|
|
497 |
put_tag(pb, "FFMP");
|
|
497 |
ffio_wfourcc(pb, "d263");
|
|
498 |
ffio_wfourcc(pb, "FFMP");
|
|
498 | 499 |
avio_w8(pb, 0); /* decoder version */ |
499 | 500 |
/* FIXME use AVCodecContext level/profile, when encoder will set values */ |
500 | 501 |
avio_w8(pb, 0xa); /* level */ |
... | ... | |
506 | 507 |
static int mov_write_svq3_tag(AVIOContext *pb) |
507 | 508 |
{ |
508 | 509 |
avio_wb32(pb, 0x15); |
509 |
put_tag(pb, "SMI ");
|
|
510 |
put_tag(pb, "SEQH");
|
|
510 |
ffio_wfourcc(pb, "SMI ");
|
|
511 |
ffio_wfourcc(pb, "SEQH");
|
|
511 | 512 |
avio_wb32(pb, 0x5); |
512 | 513 |
avio_wb32(pb, 0xe2c0211d); |
513 | 514 |
avio_wb32(pb, 0xc0000000); |
... | ... | |
520 | 521 |
int64_t pos = url_ftell(pb); |
521 | 522 |
|
522 | 523 |
avio_wb32(pb, 0); |
523 |
put_tag(pb, "avcC");
|
|
524 |
ffio_wfourcc(pb, "avcC");
|
|
524 | 525 |
ff_isom_write_avcc(pb, track->vosData, track->vosLen); |
525 | 526 |
return updateSize(pb, pos); |
526 | 527 |
} |
... | ... | |
530 | 531 |
{ |
531 | 532 |
int i; |
532 | 533 |
avio_wb32(pb, 24); /* size */ |
533 |
put_tag(pb, "ACLR");
|
|
534 |
put_tag(pb, "ACLR");
|
|
535 |
put_tag(pb, "0001");
|
|
534 |
ffio_wfourcc(pb, "ACLR");
|
|
535 |
ffio_wfourcc(pb, "ACLR");
|
|
536 |
ffio_wfourcc(pb, "0001");
|
|
536 | 537 |
avio_wb32(pb, 1); /* yuv 1 / rgb 2 ? */ |
537 | 538 |
avio_wb32(pb, 0); /* unknown */ |
538 | 539 |
|
539 | 540 |
avio_wb32(pb, 24); /* size */ |
540 |
put_tag(pb, "APRG");
|
|
541 |
put_tag(pb, "APRG");
|
|
542 |
put_tag(pb, "0001");
|
|
541 |
ffio_wfourcc(pb, "APRG");
|
|
542 |
ffio_wfourcc(pb, "APRG");
|
|
543 |
ffio_wfourcc(pb, "0001");
|
|
543 | 544 |
avio_wb32(pb, 1); /* unknown */ |
544 | 545 |
avio_wb32(pb, 0); /* unknown */ |
545 | 546 |
|
546 | 547 |
avio_wb32(pb, 120); /* size */ |
547 |
put_tag(pb, "ARES");
|
|
548 |
put_tag(pb, "ARES");
|
|
549 |
put_tag(pb, "0001");
|
|
548 |
ffio_wfourcc(pb, "ARES");
|
|
549 |
ffio_wfourcc(pb, "ARES");
|
|
550 |
ffio_wfourcc(pb, "0001");
|
|
550 | 551 |
avio_wb32(pb, AV_RB32(track->vosData + 0x28)); /* dnxhd cid, some id ? */ |
551 | 552 |
avio_wb32(pb, track->enc->width); |
552 | 553 |
/* values below are based on samples created with quicktime and avid codecs */ |
... | ... | |
741 | 742 |
static int mov_write_uuid_tag_ipod(AVIOContext *pb) |
742 | 743 |
{ |
743 | 744 |
avio_wb32(pb, 28); |
744 |
put_tag(pb, "uuid");
|
|
745 |
ffio_wfourcc(pb, "uuid");
|
|
745 | 746 |
avio_wb32(pb, 0x6b6840f2); |
746 | 747 |
avio_wb32(pb, 0x5f244fc5); |
747 | 748 |
avio_wb32(pb, 0xba39a51b); |
... | ... | |
772 | 773 |
track->enc->sample_aspect_ratio.den, INT_MAX); |
773 | 774 |
|
774 | 775 |
avio_wb32(pb, 16); |
775 |
put_tag(pb, "pasp");
|
|
776 |
ffio_wfourcc(pb, "pasp");
|
|
776 | 777 |
avio_wb32(pb, sar.num); |
777 | 778 |
avio_wb32(pb, sar.den); |
778 | 779 |
return 16; |
... | ... | |
792 | 793 |
avio_wb16(pb, 0); /* Codec stream version */ |
793 | 794 |
avio_wb16(pb, 0); /* Codec stream revision (=0) */ |
794 | 795 |
if (track->mode == MODE_MOV) { |
795 |
put_tag(pb, "FFMP"); /* Vendor */
|
|
796 |
ffio_wfourcc(pb, "FFMP"); /* Vendor */
|
|
796 | 797 |
if(track->enc->codec_id == CODEC_ID_RAWVIDEO) { |
797 | 798 |
avio_wb32(pb, 0); /* Temporal Quality */ |
798 | 799 |
avio_wb32(pb, 0x400); /* Spatial Quality = lossless*/ |
... | ... | |
852 | 853 |
{ |
853 | 854 |
int64_t pos = url_ftell(pb); |
854 | 855 |
avio_wb32(pb, 0); /* size */ |
855 |
put_tag(pb, "rtp ");
|
|
856 |
ffio_wfourcc(pb, "rtp ");
|
|
856 | 857 |
avio_wb32(pb, 0); /* Reserved */ |
857 | 858 |
avio_wb16(pb, 0); /* Reserved */ |
858 | 859 |
avio_wb16(pb, 1); /* Data-reference index */ |
... | ... | |
862 | 863 |
avio_wb32(pb, track->max_packet_size); /* Max packet size */ |
863 | 864 |
|
864 | 865 |
avio_wb32(pb, 12); /* size */ |
865 |
put_tag(pb, "tims");
|
|
866 |
ffio_wfourcc(pb, "tims");
|
|
866 | 867 |
avio_wb32(pb, track->timescale); |
867 | 868 |
|
868 | 869 |
return updateSize(pb, pos); |
... | ... | |
872 | 873 |
{ |
873 | 874 |
int64_t pos = url_ftell(pb); |
874 | 875 |
avio_wb32(pb, 0); /* size */ |
875 |
put_tag(pb, "stsd");
|
|
876 |
ffio_wfourcc(pb, "stsd");
|
|
876 | 877 |
avio_wb32(pb, 0); /* version & flags */ |
877 | 878 |
avio_wb32(pb, 1); /* entry count */ |
878 | 879 |
if (track->enc->codec_type == AVMEDIA_TYPE_VIDEO) |
... | ... | |
908 | 909 |
entries++; /* last one */ |
909 | 910 |
atom_size = 16 + (entries * 8); |
910 | 911 |
avio_wb32(pb, atom_size); /* size */ |
911 |
put_tag(pb, "ctts");
|
|
912 |
ffio_wfourcc(pb, "ctts");
|
|
912 | 913 |
avio_wb32(pb, 0); /* version & flags */ |
913 | 914 |
avio_wb32(pb, entries); /* entry count */ |
914 | 915 |
for (i=0; i<entries; i++) { |
... | ... | |
950 | 951 |
} |
951 | 952 |
atom_size = 16 + (entries * 8); |
952 | 953 |
avio_wb32(pb, atom_size); /* size */ |
953 |
put_tag(pb, "stts");
|
|
954 |
ffio_wfourcc(pb, "stts");
|
|
954 | 955 |
avio_wb32(pb, 0); /* version & flags */ |
955 | 956 |
avio_wb32(pb, entries); /* entry count */ |
956 | 957 |
for (i=0; i<entries; i++) { |
... | ... | |
964 | 965 |
static int mov_write_dref_tag(AVIOContext *pb) |
965 | 966 |
{ |
966 | 967 |
avio_wb32(pb, 28); /* size */ |
967 |
put_tag(pb, "dref");
|
|
968 |
ffio_wfourcc(pb, "dref");
|
|
968 | 969 |
avio_wb32(pb, 0); /* version & flags */ |
969 | 970 |
avio_wb32(pb, 1); /* entry count */ |
970 | 971 |
|
971 | 972 |
avio_wb32(pb, 0xc); /* size */ |
972 |
put_tag(pb, "url ");
|
|
973 |
ffio_wfourcc(pb, "url ");
|
|
973 | 974 |
avio_wb32(pb, 1); /* version & flags */ |
974 | 975 |
|
975 | 976 |
return 28; |
... | ... | |
979 | 980 |
{ |
980 | 981 |
int64_t pos = url_ftell(pb); |
981 | 982 |
avio_wb32(pb, 0); /* size */ |
982 |
put_tag(pb, "stbl");
|
|
983 |
ffio_wfourcc(pb, "stbl");
|
|
983 | 984 |
mov_write_stsd_tag(pb, track); |
984 | 985 |
mov_write_stts_tag(pb, track); |
985 | 986 |
if ((track->enc->codec_type == AVMEDIA_TYPE_VIDEO || |
... | ... | |
1001 | 1002 |
{ |
1002 | 1003 |
int64_t pos = url_ftell(pb); |
1003 | 1004 |
avio_wb32(pb, 0); /* size */ |
1004 |
put_tag(pb, "dinf");
|
|
1005 |
ffio_wfourcc(pb, "dinf");
|
|
1005 | 1006 |
mov_write_dref_tag(pb); |
1006 | 1007 |
return updateSize(pb, pos); |
1007 | 1008 |
} |
... | ... | |
1009 | 1010 |
static int mov_write_nmhd_tag(AVIOContext *pb) |
1010 | 1011 |
{ |
1011 | 1012 |
avio_wb32(pb, 12); |
1012 |
put_tag(pb, "nmhd");
|
|
1013 |
ffio_wfourcc(pb, "nmhd");
|
|
1013 | 1014 |
avio_wb32(pb, 0); |
1014 | 1015 |
return 12; |
1015 | 1016 |
} |
... | ... | |
1017 | 1018 |
static int mov_write_gmhd_tag(AVIOContext *pb) |
1018 | 1019 |
{ |
1019 | 1020 |
avio_wb32(pb, 0x20); /* size */ |
1020 |
put_tag(pb, "gmhd");
|
|
1021 |
ffio_wfourcc(pb, "gmhd");
|
|
1021 | 1022 |
avio_wb32(pb, 0x18); /* gmin size */ |
1022 |
put_tag(pb, "gmin"); /* generic media info */
|
|
1023 |
ffio_wfourcc(pb, "gmin");/* generic media info */
|
|
1023 | 1024 |
avio_wb32(pb, 0); /* version & flags */ |
1024 | 1025 |
avio_wb16(pb, 0x40); /* graphics mode = */ |
1025 | 1026 |
avio_wb16(pb, 0x8000); /* opColor (r?) */ |
... | ... | |
1033 | 1034 |
static int mov_write_smhd_tag(AVIOContext *pb) |
1034 | 1035 |
{ |
1035 | 1036 |
avio_wb32(pb, 16); /* size */ |
1036 |
put_tag(pb, "smhd");
|
|
1037 |
ffio_wfourcc(pb, "smhd");
|
|
1037 | 1038 |
avio_wb32(pb, 0); /* version & flags */ |
1038 | 1039 |
avio_wb16(pb, 0); /* reserved (balance, normally = 0) */ |
1039 | 1040 |
avio_wb16(pb, 0); /* reserved */ |
... | ... | |
1043 | 1044 |
static int mov_write_vmhd_tag(AVIOContext *pb) |
1044 | 1045 |
{ |
1045 | 1046 |
avio_wb32(pb, 0x14); /* size (always 0x14) */ |
1046 |
put_tag(pb, "vmhd");
|
|
1047 |
ffio_wfourcc(pb, "vmhd");
|
|
1047 | 1048 |
avio_wb32(pb, 0x01); /* version & flags */ |
1048 | 1049 |
avio_wb64(pb, 0); /* reserved (graphics mode = copy) */ |
1049 | 1050 |
return 0x14; |
... | ... | |
1077 | 1078 |
} |
1078 | 1079 |
|
1079 | 1080 |
avio_wb32(pb, 0); /* size */ |
1080 |
put_tag(pb, "hdlr");
|
|
1081 |
ffio_wfourcc(pb, "hdlr");
|
|
1081 | 1082 |
avio_wb32(pb, 0); /* Version & flags */ |
1082 | 1083 |
avio_write(pb, hdlr, 4); /* handler */ |
1083 |
put_tag(pb, hdlr_type); /* handler type */
|
|
1084 |
ffio_wfourcc(pb, hdlr_type); /* handler type */
|
|
1084 | 1085 |
avio_wb32(pb ,0); /* reserved */ |
1085 | 1086 |
avio_wb32(pb ,0); /* reserved */ |
1086 | 1087 |
avio_wb32(pb ,0); /* reserved */ |
... | ... | |
1097 | 1098 |
/* This atom must be present, but leaving the values at zero |
1098 | 1099 |
* seems harmless. */ |
1099 | 1100 |
avio_wb32(pb, 28); /* size */ |
1100 |
put_tag(pb, "hmhd");
|
|
1101 |
ffio_wfourcc(pb, "hmhd");
|
|
1101 | 1102 |
avio_wb32(pb, 0); /* version, flags */ |
1102 | 1103 |
avio_wb16(pb, 0); /* maxPDUsize */ |
1103 | 1104 |
avio_wb16(pb, 0); /* avgPDUsize */ |
... | ... | |
1111 | 1112 |
{ |
1112 | 1113 |
int64_t pos = url_ftell(pb); |
1113 | 1114 |
avio_wb32(pb, 0); /* size */ |
1114 |
put_tag(pb, "minf");
|
|
1115 |
ffio_wfourcc(pb, "minf");
|
|
1115 | 1116 |
if(track->enc->codec_type == AVMEDIA_TYPE_VIDEO) |
1116 | 1117 |
mov_write_vmhd_tag(pb); |
1117 | 1118 |
else if (track->enc->codec_type == AVMEDIA_TYPE_AUDIO) |
... | ... | |
1134 | 1135 |
int version = track->trackDuration < INT32_MAX ? 0 : 1; |
1135 | 1136 |
|
1136 | 1137 |
(version == 1) ? avio_wb32(pb, 44) : avio_wb32(pb, 32); /* size */ |
1137 |
put_tag(pb, "mdhd");
|
|
1138 |
ffio_wfourcc(pb, "mdhd");
|
|
1138 | 1139 |
avio_w8(pb, version); |
1139 | 1140 |
avio_wb24(pb, 0); /* flags */ |
1140 | 1141 |
if (version == 1) { |
... | ... | |
1163 | 1164 |
{ |
1164 | 1165 |
int64_t pos = url_ftell(pb); |
1165 | 1166 |
avio_wb32(pb, 0); /* size */ |
1166 |
put_tag(pb, "mdia");
|
|
1167 |
ffio_wfourcc(pb, "mdia");
|
|
1167 | 1168 |
mov_write_mdhd_tag(pb, track); |
1168 | 1169 |
mov_write_hdlr_tag(pb, track); |
1169 | 1170 |
mov_write_minf_tag(pb, track); |
... | ... | |
1177 | 1178 |
int version = duration < INT32_MAX ? 0 : 1; |
1178 | 1179 |
|
1179 | 1180 |
(version == 1) ? avio_wb32(pb, 104) : avio_wb32(pb, 92); /* size */ |
1180 |
put_tag(pb, "tkhd");
|
|
1181 |
ffio_wfourcc(pb, "tkhd");
|
|
1181 | 1182 |
avio_w8(pb, version); |
1182 | 1183 |
avio_wb24(pb, 0xf); /* flags (track enabled) */ |
1183 | 1184 |
if (version == 1) { |
... | ... | |
1232 | 1233 |
static int mov_write_edts_tag(AVIOContext *pb, MOVTrack *track) |
1233 | 1234 |
{ |
1234 | 1235 |
avio_wb32(pb, 0x24); /* size */ |
1235 |
put_tag(pb, "edts");
|
|
1236 |
ffio_wfourcc(pb, "edts");
|
|
1236 | 1237 |
avio_wb32(pb, 0x1c); /* size */ |
1237 |
put_tag(pb, "elst");
|
|
1238 |
ffio_wfourcc(pb, "elst");
|
|
1238 | 1239 |
avio_wb32(pb, 0x0); |
1239 | 1240 |
avio_wb32(pb, 0x1); |
1240 | 1241 |
|
... | ... | |
1250 | 1251 |
static int mov_write_tref_tag(AVIOContext *pb, MOVTrack *track) |
1251 | 1252 |
{ |
1252 | 1253 |
avio_wb32(pb, 20); // size |
1253 |
put_tag(pb, "tref");
|
|
1254 |
ffio_wfourcc(pb, "tref");
|
|
1254 | 1255 |
avio_wb32(pb, 12); // size (subatom) |
1255 | 1256 |
avio_wl32(pb, track->tref_tag); |
1256 | 1257 |
avio_wb32(pb, track->tref_id); |
... | ... | |
1261 | 1262 |
static int mov_write_uuid_tag_psp(AVIOContext *pb, MOVTrack *mov) |
1262 | 1263 |
{ |
1263 | 1264 |
avio_wb32(pb, 0x34); /* size ... reports as 28 in mp4box! */ |
1264 |
put_tag(pb, "uuid");
|
|
1265 |
put_tag(pb, "USMT");
|
|
1265 |
ffio_wfourcc(pb, "uuid");
|
|
1266 |
ffio_wfourcc(pb, "USMT");
|
|
1266 | 1267 |
avio_wb32(pb, 0x21d24fce); |
1267 | 1268 |
avio_wb32(pb, 0xbb88695c); |
1268 | 1269 |
avio_wb32(pb, 0xfac9c740); |
1269 | 1270 |
avio_wb32(pb, 0x1c); // another size here! |
1270 |
put_tag(pb, "MTDT");
|
|
1271 |
ffio_wfourcc(pb, "MTDT");
|
|
1271 | 1272 |
avio_wb32(pb, 0x00010012); |
1272 | 1273 |
avio_wb32(pb, 0x0a); |
1273 | 1274 |
avio_wb32(pb, 0x55c40000); |
... | ... | |
1286 | 1287 |
len = strlen(buf); |
1287 | 1288 |
|
1288 | 1289 |
avio_wb32(pb, len + 24); |
1289 |
put_tag (pb, "udta");
|
|
1290 |
ffio_wfourcc(pb, "udta");
|
|
1290 | 1291 |
avio_wb32(pb, len + 16); |
1291 |
put_tag (pb, "hnti");
|
|
1292 |
ffio_wfourcc(pb, "hnti");
|
|
1292 | 1293 |
avio_wb32(pb, len + 8); |
1293 |
put_tag (pb, "sdp ");
|
|
1294 |
ffio_wfourcc(pb, "sdp ");
|
|
1294 | 1295 |
avio_write(pb, buf, len); |
1295 | 1296 |
return len + 24; |
1296 | 1297 |
} |
... | ... | |
1299 | 1300 |
{ |
1300 | 1301 |
int64_t pos = url_ftell(pb); |
1301 | 1302 |
avio_wb32(pb, 0); /* size */ |
1302 |
put_tag(pb, "trak");
|
|
1303 |
ffio_wfourcc(pb, "trak");
|
|
1303 | 1304 |
mov_write_tkhd_tag(pb, track, st); |
1304 | 1305 |
if (track->mode == MODE_PSP || track->flags & MOV_TRACK_CTTS) |
1305 | 1306 |
mov_write_edts_tag(pb, track); // PSP Movies require edts box |
... | ... | |
1318 | 1319 |
static int mov_write_iods_tag(AVIOContext *pb, MOVMuxContext *mov) |
1319 | 1320 |
{ |
1320 | 1321 |
avio_wb32(pb, 0x15); /* size */ |
1321 |
put_tag(pb, "iods");
|
|
1322 |
ffio_wfourcc(pb, "iods");
|
|
1322 | 1323 |
avio_wb32(pb, 0); /* version & flags */ |
1323 | 1324 |
avio_wb16(pb, 0x1007); |
1324 | 1325 |
avio_w8(pb, 0); |
... | ... | |
1350 | 1351 |
|
1351 | 1352 |
version = maxTrackLen < UINT32_MAX ? 0 : 1; |
1352 | 1353 |
(version == 1) ? avio_wb32(pb, 120) : avio_wb32(pb, 108); /* size */ |
1353 |
put_tag(pb, "mvhd");
|
|
1354 |
ffio_wfourcc(pb, "mvhd");
|
|
1354 | 1355 |
avio_w8(pb, version); |
1355 | 1356 |
avio_wb24(pb, 0); /* flags */ |
1356 | 1357 |
if (version == 1) { |
... | ... | |
1394 | 1395 |
AVFormatContext *s) |
1395 | 1396 |
{ |
1396 | 1397 |
avio_wb32(pb, 33); /* size */ |
1397 |
put_tag(pb, "hdlr");
|
|
1398 |
ffio_wfourcc(pb, "hdlr");
|
|
1398 | 1399 |
avio_wb32(pb, 0); |
1399 | 1400 |
avio_wb32(pb, 0); |
1400 |
put_tag(pb, "mdir");
|
|
1401 |
put_tag(pb, "appl");
|
|
1401 |
ffio_wfourcc(pb, "mdir");
|
|
1402 |
ffio_wfourcc(pb, "appl");
|
|
1402 | 1403 |
avio_wb32(pb, 0); |
1403 | 1404 |
avio_wb32(pb, 0); |
1404 | 1405 |
avio_w8(pb, 0); |
... | ... | |
1411 | 1412 |
if(long_style){ |
1412 | 1413 |
int size = 16 + strlen(data); |
1413 | 1414 |
avio_wb32(pb, size); /* size */ |
1414 |
put_tag(pb, "data");
|
|
1415 |
ffio_wfourcc(pb, "data");
|
|
1415 | 1416 |
avio_wb32(pb, 1); |
1416 | 1417 |
avio_wb32(pb, 0); |
1417 | 1418 |
avio_write(pb, data, strlen(data)); |
... | ... | |
1431 | 1432 |
if (value && value[0]) { |
1432 | 1433 |
int64_t pos = url_ftell(pb); |
1433 | 1434 |
avio_wb32(pb, 0); /* size */ |
1434 |
put_tag(pb, name);
|
|
1435 |
ffio_wfourcc(pb, name);
|
|
1435 | 1436 |
mov_write_string_data_tag(pb, value, lang, long_style); |
1436 | 1437 |
size= updateSize(pb, pos); |
1437 | 1438 |
} |
... | ... | |
1470 | 1471 |
int size = 0, track = t ? atoi(t->value) : 0; |
1471 | 1472 |
if (track) { |
1472 | 1473 |
avio_wb32(pb, 32); /* size */ |
1473 |
put_tag(pb, "trkn");
|
|
1474 |
ffio_wfourcc(pb, "trkn");
|
|
1474 | 1475 |
avio_wb32(pb, 24); /* size */ |
1475 |
put_tag(pb, "data");
|
|
1476 |
ffio_wfourcc(pb, "data");
|
|
1476 | 1477 |
avio_wb32(pb, 0); // 8 bytes empty |
1477 | 1478 |
avio_wb32(pb, 0); |
1478 | 1479 |
avio_wb16(pb, 0); // empty |
... | ... | |
1490 | 1491 |
{ |
1491 | 1492 |
int64_t pos = url_ftell(pb); |
1492 | 1493 |
avio_wb32(pb, 0); /* size */ |
1493 |
put_tag(pb, "ilst");
|
|
1494 |
ffio_wfourcc(pb, "ilst");
|
|
1494 | 1495 |
mov_write_string_metadata(s, pb, "\251nam", "title" , 1); |
1495 | 1496 |
mov_write_string_metadata(s, pb, "\251ART", "artist" , 1); |
1496 | 1497 |
mov_write_string_metadata(s, pb, "aART", "album_artist", 1); |
... | ... | |
1519 | 1520 |
int size = 0; |
1520 | 1521 |
int64_t pos = url_ftell(pb); |
1521 | 1522 |
avio_wb32(pb, 0); /* size */ |
1522 |
put_tag(pb, "meta");
|
|
1523 |
ffio_wfourcc(pb, "meta");
|
|
1523 | 1524 |
avio_wb32(pb, 0); |
1524 | 1525 |
mov_write_itunes_hdlr_tag(pb, mov, s); |
1525 | 1526 |
mov_write_ilst_tag(pb, mov, s); |
... | ... | |
1562 | 1563 |
if (!t || !utf8len(t->value)) |
1563 | 1564 |
return 0; |
1564 | 1565 |
avio_wb32(pb, 0); /* size */ |
1565 |
put_tag (pb, tag); /* type */
|
|
1566 |
ffio_wfourcc(pb, tag); /* type */
|
|
1566 | 1567 |
avio_wb32(pb, 0); /* version + flags */ |
1567 | 1568 |
if (!strcmp(tag, "yrrc")) |
1568 | 1569 |
avio_wb16(pb, atoi(t->value)); |
... | ... | |
1582 | 1583 |
int i, nb_chapters = FFMIN(s->nb_chapters, 255); |
1583 | 1584 |
|
1584 | 1585 |
avio_wb32(pb, 0); // size |
1585 |
put_tag (pb, "chpl");
|
|
1586 |
ffio_wfourcc(pb, "chpl");
|
|
1586 | 1587 |
avio_wb32(pb, 0x01000000); // version + flags |
1587 | 1588 |
avio_wb32(pb, 0); // unknown |
1588 | 1589 |
avio_w8(pb, nb_chapters); |
... | ... | |
1647 | 1648 |
|
1648 | 1649 |
if ((size = url_close_dyn_buf(pb_buf, &buf)) > 0) { |
1649 | 1650 |
avio_wb32(pb, size+8); |
1650 |
put_tag(pb, "udta");
|
|
1651 |
ffio_wfourcc(pb, "udta");
|
|
1651 | 1652 |
avio_write(pb, buf, size); |
1652 | 1653 |
} |
1653 | 1654 |
av_free(buf); |
... | ... | |
1676 | 1677 |
if (title) { |
1677 | 1678 |
pos = url_ftell(pb); |
1678 | 1679 |
avio_wb32(pb, 0); /* size placeholder*/ |
1679 |
put_tag(pb, "uuid");
|
|
1680 |
put_tag(pb, "USMT");
|
|
1680 |
ffio_wfourcc(pb, "uuid");
|
|
1681 |
ffio_wfourcc(pb, "USMT");
|
|
1681 | 1682 |
avio_wb32(pb, 0x21d24fce); /* 96 bit UUID */ |
1682 | 1683 |
avio_wb32(pb, 0xbb88695c); |
1683 | 1684 |
avio_wb32(pb, 0xfac9c740); |
1684 | 1685 |
|
1685 | 1686 |
pos2 = url_ftell(pb); |
1686 | 1687 |
avio_wb32(pb, 0); /* size placeholder*/ |
1687 |
put_tag(pb, "MTDT");
|
|
1688 |
ffio_wfourcc(pb, "MTDT");
|
|
1688 | 1689 |
avio_wb16(pb, 4); |
1689 | 1690 |
|
1690 | 1691 |
// ? |
... | ... | |
1712 | 1713 |
int i; |
1713 | 1714 |
int64_t pos = url_ftell(pb); |
1714 | 1715 |
avio_wb32(pb, 0); /* size placeholder*/ |
1715 |
put_tag(pb, "moov");
|
|
1716 |
ffio_wfourcc(pb, "moov");
|
|
1716 | 1717 |
|
1717 | 1718 |
for (i=0; i<mov->nb_streams; i++) { |
1718 | 1719 |
if(mov->tracks[i].entry <= 0) continue; |
... | ... | |
1753 | 1754 |
static int mov_write_mdat_tag(AVIOContext *pb, MOVMuxContext *mov) |
1754 | 1755 |
{ |
1755 | 1756 |
avio_wb32(pb, 8); // placeholder for extended size field (64 bit) |
1756 |
put_tag(pb, mov->mode == MODE_MOV ? "wide" : "free");
|
|
1757 |
ffio_wfourcc(pb, mov->mode == MODE_MOV ? "wide" : "free");
|
|
1757 | 1758 |
|
1758 | 1759 |
mov->mdat_pos = url_ftell(pb); |
1759 | 1760 |
avio_wb32(pb, 0); /* size placeholder*/ |
1760 |
put_tag(pb, "mdat");
|
|
1761 |
ffio_wfourcc(pb, "mdat");
|
|
1761 | 1762 |
return 0; |
1762 | 1763 |
} |
1763 | 1764 |
|
... | ... | |
1779 | 1780 |
} |
1780 | 1781 |
|
1781 | 1782 |
avio_wb32(pb, 0); /* size */ |
1782 |
put_tag(pb, "ftyp");
|
|
1783 |
ffio_wfourcc(pb, "ftyp");
|
|
1783 | 1784 |
|
1784 | 1785 |
if (mov->mode == MODE_3GP) { |
1785 |
put_tag(pb, has_h264 ? "3gp6" : "3gp4");
|
|
1786 |
ffio_wfourcc(pb, has_h264 ? "3gp6" : "3gp4");
|
|
1786 | 1787 |
minor = has_h264 ? 0x100 : 0x200; |
1787 | 1788 |
} else if (mov->mode & MODE_3G2) { |
1788 |
put_tag(pb, has_h264 ? "3g2b" : "3g2a");
|
|
1789 |
ffio_wfourcc(pb, has_h264 ? "3g2b" : "3g2a");
|
|
1789 | 1790 |
minor = has_h264 ? 0x20000 : 0x10000; |
1790 | 1791 |
}else if (mov->mode == MODE_PSP) |
1791 |
put_tag(pb, "MSNV");
|
|
1792 |
ffio_wfourcc(pb, "MSNV");
|
|
1792 | 1793 |
else if (mov->mode == MODE_MP4) |
1793 |
put_tag(pb, "isom");
|
|
1794 |
ffio_wfourcc(pb, "isom");
|
|
1794 | 1795 |
else if (mov->mode == MODE_IPOD) |
1795 |
put_tag(pb, has_video ? "M4V ":"M4A ");
|
|
1796 |
ffio_wfourcc(pb, has_video ? "M4V ":"M4A ");
|
|
1796 | 1797 |
else |
1797 |
put_tag(pb, "qt ");
|
|
1798 |
ffio_wfourcc(pb, "qt ");
|
|
1798 | 1799 |
|
1799 | 1800 |
avio_wb32(pb, minor); |
1800 | 1801 |
|
1801 | 1802 |
if(mov->mode == MODE_MOV) |
1802 |
put_tag(pb, "qt ");
|
|
1803 |
ffio_wfourcc(pb, "qt ");
|
|
1803 | 1804 |
else{ |
1804 |
put_tag(pb, "isom");
|
|
1805 |
put_tag(pb, "iso2");
|
|
1805 |
ffio_wfourcc(pb, "isom");
|
|
1806 |
ffio_wfourcc(pb, "iso2");
|
|
1806 | 1807 |
if(has_h264) |
1807 |
put_tag(pb, "avc1");
|
|
1808 |
ffio_wfourcc(pb, "avc1");
|
|
1808 | 1809 |
} |
1809 | 1810 |
|
1810 | 1811 |
if (mov->mode == MODE_3GP) |
1811 |
put_tag(pb, has_h264 ? "3gp6":"3gp4");
|
|
1812 |
ffio_wfourcc(pb, has_h264 ? "3gp6":"3gp4");
|
|
1812 | 1813 |
else if (mov->mode & MODE_3G2) |
1813 |
put_tag(pb, has_h264 ? "3g2b":"3g2a");
|
|
1814 |
ffio_wfourcc(pb, has_h264 ? "3g2b":"3g2a");
|
|
1814 | 1815 |
else if (mov->mode == MODE_PSP) |
1815 |
put_tag(pb, "MSNV");
|
|
1816 |
ffio_wfourcc(pb, "MSNV");
|
|
1816 | 1817 |
else if (mov->mode == MODE_MP4) |
1817 |
put_tag(pb, "mp41");
|
|
1818 |
ffio_wfourcc(pb, "mp41");
|
|
1818 | 1819 |
return updateSize(pb, pos); |
1819 | 1820 |
} |
1820 | 1821 |
|
... | ... | |
1828 | 1829 |
int video_kbitrate= FFMIN(VideoCodec->bit_rate / 1000, 800 - audio_kbitrate); |
1829 | 1830 |
|
1830 | 1831 |
avio_wb32(pb, 0x94); /* size */ |
1831 |
put_tag(pb, "uuid");
|
|
1832 |
put_tag(pb, "PROF");
|
|
1832 |
ffio_wfourcc(pb, "uuid");
|
|
1833 |
ffio_wfourcc(pb, "PROF");
|
|
1833 | 1834 |
|
1834 | 1835 |
avio_wb32(pb, 0x21d24fce); /* 96 bit UUID */ |
1835 | 1836 |
avio_wb32(pb, 0xbb88695c); |
... | ... | |
1839 | 1840 |
avio_wb32(pb, 0x3); /* 3 sections ? */ |
1840 | 1841 |
|
1841 | 1842 |
avio_wb32(pb, 0x14); /* size */ |
1842 |
put_tag(pb, "FPRF");
|
|
1843 |
ffio_wfourcc(pb, "FPRF");
|
|
1843 | 1844 |
avio_wb32(pb, 0x0); /* ? */ |
1844 | 1845 |
avio_wb32(pb, 0x0); /* ? */ |
1845 | 1846 |
avio_wb32(pb, 0x0); /* ? */ |
1846 | 1847 |
|
1847 | 1848 |
avio_wb32(pb, 0x2c); /* size */ |
1848 |
put_tag(pb, "APRF"); /* audio */
|
|
1849 |
ffio_wfourcc(pb, "APRF");/* audio */
|
|
1849 | 1850 |
avio_wb32(pb, 0x0); |
1850 | 1851 |
avio_wb32(pb, 0x2); /* TrackID */ |
1851 |
put_tag(pb, "mp4a");
|
|
1852 |
ffio_wfourcc(pb, "mp4a");
|
|
1852 | 1853 |
avio_wb32(pb, 0x20f); |
1853 | 1854 |
avio_wb32(pb, 0x0); |
1854 | 1855 |
avio_wb32(pb, audio_kbitrate); |
... | ... | |
1857 | 1858 |
avio_wb32(pb, AudioCodec->channels); |
1858 | 1859 |
|
1859 | 1860 |
avio_wb32(pb, 0x34); /* size */ |
1860 |
put_tag(pb, "VPRF"); /* video */
|
|
1861 |
ffio_wfourcc(pb, "VPRF"); /* video */
|
|
1861 | 1862 |
avio_wb32(pb, 0x0); |
1862 | 1863 |
avio_wb32(pb, 0x1); /* TrackID */ |
1863 | 1864 |
if (VideoCodec->codec_id == CODEC_ID_H264) { |
1864 |
put_tag(pb, "avc1");
|
|
1865 |
ffio_wfourcc(pb, "avc1");
|
|
1865 | 1866 |
avio_wb16(pb, 0x014D); |
1866 | 1867 |
avio_wb16(pb, 0x0015); |
1867 | 1868 |
} else { |
1868 |
put_tag(pb, "mp4v");
|
|
1869 |
ffio_wfourcc(pb, "mp4v");
|
|
1869 | 1870 |
avio_wb16(pb, 0x0000); |
1870 | 1871 |
avio_wb16(pb, 0x0103); |
1871 | 1872 |
} |
... | ... | |
2206 | 2207 |
/* overwrite 'wide' placeholder atom */ |
2207 | 2208 |
url_fseek(pb, mov->mdat_pos - 8, SEEK_SET); |
2208 | 2209 |
avio_wb32(pb, 1); /* special value: real atom size will be 64 bit value after tag field */ |
2209 |
put_tag(pb, "mdat");
|
|
2210 |
ffio_wfourcc(pb, "mdat");
|
|
2210 | 2211 |
avio_wb64(pb, mov->mdat_size+16); |
2211 | 2212 |
} |
2212 | 2213 |
url_fseek(pb, moov_pos, SEEK_SET); |
Also available in: Unified diff