diff options
author | Martin Storsjö <martin@martin.st> | 2013-07-07 14:59:47 +0300 |
---|---|---|
committer | Martin Storsjö <martin@martin.st> | 2013-07-07 21:34:31 +0300 |
commit | 21732063a346475eb22c332b27e8216b79f9ad4a (patch) | |
tree | 86ce9aef1fe8f6339d83429d01d24723de782302 | |
parent | 38e9585de993c32899588ab037180f2c930ce74c (diff) | |
download | ffmpeg-21732063a346475eb22c332b27e8216b79f9ad4a.tar.gz |
movenc: K&R formatting cosmetics
Signed-off-by: Martin Storsjö <martin@martin.st>
-rw-r--r-- | libavformat/movenc.c | 378 | ||||
-rw-r--r-- | libavformat/movenchint.c | 17 |
2 files changed, 198 insertions, 197 deletions
diff --git a/libavformat/movenc.c b/libavformat/movenc.c index 1dde214e3f..ef038577af 100644 --- a/libavformat/movenc.c +++ b/libavformat/movenc.c @@ -95,8 +95,8 @@ static int mov_write_stco_tag(AVIOContext *pb, MOVTrack *track) ffio_wfourcc(pb, "stco"); avio_wb32(pb, 0); /* version & flags */ avio_wb32(pb, track->entry); /* entry count */ - for (i=0; i<track->entry; i++) { - if(mode64 == 1) + for (i = 0; i < track->entry; i++) { + if (mode64 == 1) avio_wb64(pb, track->cluster[i].pos + track->data_offset); else avio_wb32(pb, track->cluster[i].pos + track->data_offset); @@ -115,27 +115,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); } } } @@ -154,10 +152,9 @@ static int mov_write_stsc_tag(AVIOContext *pb, MOVTrack *track) avio_wb32(pb, 0); // version & flags entryPos = avio_tell(pb); avio_wb32(pb, track->entry); // entry count - for (i=0; i<track->entry; i++) { - if (oldval != track->cluster[i].samples_in_chunk) - { - avio_wb32(pb, i+1); // first chunk + for (i = 0; i < track->entry; i++) { + if (oldval != track->cluster[i].samples_in_chunk) { + avio_wb32(pb, i + 1); // first chunk avio_wb32(pb, track->cluster[i].samples_in_chunk); // samples per chunk avio_wb32(pb, 0x1); // sample description index oldval = track->cluster[i].samples_in_chunk; @@ -183,9 +180,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++; } } @@ -245,7 +242,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); @@ -268,8 +265,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); } @@ -300,7 +297,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) @@ -308,7 +305,8 @@ static int mov_write_esds_tag(AVIOContext *pb, MOVTrack *track) // Basic avio_wb24(pb, track->enc->rc_buffer_size >> 3); // Buffersize DB avio_wb32(pb, FFMAX(track->enc->bit_rate, track->enc->rc_max_rate)); // maxbitrate (FIXME should be max rate in any 1 sec window) - if(track->enc->rc_max_rate != track->enc->rc_min_rate || track->enc->rc_min_rate==0) + if (track->enc->rc_max_rate != track->enc->rc_min_rate || + track->enc->rc_min_rate == 0) avio_wb32(pb, 0); // vbr else avio_wb32(pb, track->enc->rc_max_rate); // avg bitrate @@ -615,21 +613,21 @@ static int mov_write_audio_tag(AVIOContext *pb, MOVTrack *track) avio_wb16(pb, 0); /* Reserved */ } - 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)) + 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)) 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); @@ -703,7 +701,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 */ @@ -737,18 +735,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 }, @@ -760,8 +758,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")) @@ -778,16 +776,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; @@ -872,12 +870,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 }, }; @@ -978,7 +976,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 { @@ -999,7 +997,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); @@ -1008,17 +1006,17 @@ 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_SVQ3) + else if (track->enc->codec_id == AV_CODEC_ID_SVQ3) mov_write_svq3_tag(pb); - 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->field_order != AV_FIELD_UNKNOWN) mov_write_fiel_tag(pb, track); @@ -1083,7 +1081,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 { @@ -1098,7 +1096,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); } @@ -1123,7 +1121,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 */ @@ -1140,7 +1138,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); } @@ -1242,24 +1240,24 @@ 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('t','x','3','g')) hdlr_type = "sbtl"; else hdlr_type = "text"; descr = "SubtitleHandler"; } else if (track->enc->codec_tag == MKTAG('r','t','p',' ')) { hdlr_type = "hint"; - descr = "HintHandler"; + descr = "HintHandler"; } } @@ -1268,9 +1266,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 */ @@ -1299,7 +1297,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); @@ -1342,11 +1340,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; @@ -1395,7 +1393,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); @@ -1413,20 +1411,19 @@ static int mov_write_tkhd_tag(AVIOContext *pb, MOVTrack *track, AVStream *st) avio_wb32(pb, 0x40000000); /* reserved */ /* 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); } @@ -1537,7 +1534,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; @@ -1573,14 +1569,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 (0.0 != sample_aspect_ratio && 1.0 != sample_aspect_ratio) mov_write_tapt_tag(pb, track); - }; + } return update_size(pb, pos); } @@ -1591,7 +1587,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; } @@ -1643,8 +1639,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, @@ -1716,7 +1712,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"); @@ -1724,7 +1720,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 */ @@ -1734,7 +1730,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); @@ -1761,8 +1759,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; } @@ -1779,14 +1777,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; @@ -1837,9 +1835,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++; } @@ -1849,7 +1847,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); } @@ -1859,7 +1857,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, @@ -1876,7 +1876,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)); @@ -1923,38 +1923,38 @@ 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) { - mov_write_3gp_udta_tag(pb_buf, s, "perf", "artist"); - mov_write_3gp_udta_tag(pb_buf, s, "titl", "title"); - mov_write_3gp_udta_tag(pb_buf, s, "auth", "author"); - mov_write_3gp_udta_tag(pb_buf, s, "gnre", "genre"); - mov_write_3gp_udta_tag(pb_buf, s, "dscp", "comment"); - mov_write_3gp_udta_tag(pb_buf, s, "albm", "album"); - 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, "\251des", "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); - } + if (mov->mode & MODE_3GP) { + mov_write_3gp_udta_tag(pb_buf, s, "perf", "artist"); + mov_write_3gp_udta_tag(pb_buf, s, "titl", "title"); + mov_write_3gp_udta_tag(pb_buf, s, "auth", "author"); + mov_write_3gp_udta_tag(pb_buf, s, "gnre", "genre"); + mov_write_3gp_udta_tag(pb_buf, s, "dscp", "comment"); + mov_write_3gp_udta_tag(pb_buf, s, "albm", "album"); + 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, "\251des", "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); + } - if (s->nb_chapters) - mov_write_chpl_tag(pb_buf, s); + if (s->nb_chapters) + 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); } @@ -1964,12 +1964,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); /* ? */ @@ -2021,18 +2021,18 @@ 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->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',' ')) { @@ -2045,7 +2045,7 @@ 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) { mov_write_trak_tag(pb, mov, &(mov->tracks[i]), i < s->nb_streams ? s->streams[i] : NULL); } @@ -2074,9 +2074,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); } @@ -2150,7 +2150,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); @@ -2320,7 +2320,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"); for (i = 0; i < free_size - 8; i++) @@ -2357,7 +2357,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); @@ -2491,7 +2491,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"); @@ -2504,7 +2504,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"); @@ -2512,7 +2512,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"); } @@ -2532,7 +2532,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); @@ -2554,7 +2554,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"); @@ -2594,11 +2594,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 @@ -2804,7 +2804,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) { @@ -2845,7 +2845,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); } @@ -2867,7 +2867,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); @@ -2875,18 +2875,18 @@ 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].size = size; - trk->cluster[trk->entry].entries = samples_in_chunk; - trk->cluster[trk->entry].dts = pkt->dts; + 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, @@ -2904,7 +2904,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); @@ -2922,7 +2922,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); @@ -2945,7 +2945,8 @@ static int mov_write_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) frag_duration = av_rescale_q(pkt->dts - trk->cluster[0].dts, @@ -2989,11 +2990,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); } @@ -3042,7 +3043,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); } } @@ -3062,11 +3063,11 @@ static int mov_write_header(AVFormatContext *s) } } - 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); @@ -3076,7 +3077,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); @@ -3085,8 +3086,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')) { @@ -3094,7 +3095,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; } track->timescale = st->codec->time_base.den; if (track->mode == MODE_MOV && track->timescale > 100000) @@ -3102,7 +3103,7 @@ 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; /* set sample_size for PCM and ADPCM */ if (av_get_bits_per_sample(st->codec->codec_id) || @@ -3123,7 +3124,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; } if (!track->height) @@ -3226,7 +3227,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]); if (mov->flags & FF_MOV_FLAG_FRAGMENT && @@ -3244,7 +3245,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); diff --git a/libavformat/movenchint.c b/libavformat/movenchint.c index 02391b5106..b4e4654552 100644 --- a/libavformat/movenchint.c +++ b/libavformat/movenchint.c @@ -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); |