]> git.sesse.net Git - ffmpeg/commitdiff
Merge commit 'ee37620b6ae4783cda637408422044b2d14a688c'
authorMichael Niedermayer <michaelni@gmx.at>
Wed, 26 Nov 2014 10:27:17 +0000 (11:27 +0100)
committerMichael Niedermayer <michaelni@gmx.at>
Wed, 26 Nov 2014 10:27:17 +0000 (11:27 +0100)
* commit 'ee37620b6ae4783cda637408422044b2d14a688c':
  movenc: Add a flag for indicating a discontinuous fragment

Conflicts:
libavformat/movenc.c

Merged-by: Michael Niedermayer <michaelni@gmx.at>
1  2 
libavformat/movenc.c
libavformat/movenc.h

index 04e11e248d5cf6ad6a7f35c3cad4500c20ac4605,80531d09f768b8d16388d3843b95685d1a249a91..159e2c3d9afad0942e52eebd43d7ddbe97b23947
@@@ -65,8 -60,9 +65,9 @@@ static const AVOption options[] = 
      { "disable_chpl", "Disable Nero chapter atom", 0, AV_OPT_TYPE_CONST, {.i64 = FF_MOV_FLAG_DISABLE_CHPL}, INT_MIN, INT_MAX, AV_OPT_FLAG_ENCODING_PARAM, "movflags" },
      { "default_base_moof", "Set the default-base-is-moof flag in tfhd atoms", 0, AV_OPT_TYPE_CONST, {.i64 = FF_MOV_FLAG_DEFAULT_BASE_MOOF}, INT_MIN, INT_MAX, AV_OPT_FLAG_ENCODING_PARAM, "movflags" },
      { "dash", "Write DASH compatible fragmented MP4", 0, AV_OPT_TYPE_CONST, {.i64 = FF_MOV_FLAG_DASH}, INT_MIN, INT_MAX, AV_OPT_FLAG_ENCODING_PARAM, "movflags" },
+     { "frag_discont", "Signal that the next fragment is discontinuous from earlier ones", 0, AV_OPT_TYPE_CONST, {.i64 = FF_MOV_FLAG_FRAG_DISCONT}, INT_MIN, INT_MAX, AV_OPT_FLAG_ENCODING_PARAM, "movflags" },
      FF_RTP_FLAG_OPTS(MOVMuxContext, rtp_flags),
 -    { "skip_iods", "Skip writing iods atom.", offsetof(MOVMuxContext, iods_skip), AV_OPT_TYPE_INT, {.i64 = 0}, 0, 1, AV_OPT_FLAG_ENCODING_PARAM},
 +    { "skip_iods", "Skip writing iods atom.", offsetof(MOVMuxContext, iods_skip), AV_OPT_TYPE_INT, {.i64 = 1}, 0, 1, AV_OPT_FLAG_ENCODING_PARAM},
      { "iods_audio_profile", "iods audio profile atom.", offsetof(MOVMuxContext, iods_audio_profile), AV_OPT_TYPE_INT, {.i64 = -1}, -1, 255, AV_OPT_FLAG_ENCODING_PARAM},
      { "iods_video_profile", "iods video profile atom.", offsetof(MOVMuxContext, iods_video_profile), AV_OPT_TYPE_INT, {.i64 = -1}, -1, 255, AV_OPT_FLAG_ENCODING_PARAM},
      { "frag_duration", "Maximum fragment duration", offsetof(MOVMuxContext, max_fragment_duration), AV_OPT_TYPE_INT, {.i64 = 0}, 0, INT_MAX, AV_OPT_FLAG_ENCODING_PARAM},
@@@ -4043,13 -3283,20 +4044,21 @@@ int ff_mov_write_packet(AVFormatContex
      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,
-          * which might not exactly match our dts. Therefore adjust the dts
-          * of this packet to be what the previous packets duration implies. */
-         trk->cluster[trk->entry].dts = trk->start_dts + trk->track_duration;
+         if (!trk->frag_discont) {
+             /* First packet of a new fragment. We already wrote the duration
+              * of the last packet of the previous fragment based on track_duration,
+              * which might not exactly match our dts. Therefore adjust the dts
+              * of this packet to be what the previous packets duration implies. */
+             trk->cluster[trk->entry].dts = trk->start_dts + trk->track_duration;
+         } else {
+             /* New fragment, but discontinuous from previous fragments.
+              * Pretend the duration sum of the earlier fragments is
+              * pkt->dts - trk->start_dts. */
+             trk->frag_start = pkt->dts - trk->start_dts;
+             trk->frag_discont = 0;
+         }
      }
 +
      if (!trk->entry && trk->start_dts == AV_NOPTS_VALUE && !mov->use_editlist &&
          s->avoid_negative_ts == AVFMT_AVOID_NEG_TS_MAKE_ZERO) {
          /* Not using edit lists and shifting the first track to start from zero.
@@@ -4118,7 -3372,14 +4133,14 @@@ static int mov_write_single_packet(AVFo
          if (!pkt->size)
              return 0;             /* Discard 0 sized packets */
  
 -        if (trk->entry)
+         if (mov->flags & FF_MOV_FLAG_FRAG_DISCONT) {
+             int i;
+             for (i = 0; i < s->nb_streams; i++)
+                 mov->tracks[i].frag_discont = 1;
+             mov->flags &= ~FF_MOV_FLAG_FRAG_DISCONT;
+         }
 +        if (trk->entry && pkt->stream_index < s->nb_streams)
              frag_duration = av_rescale_q(pkt->dts - trk->cluster[0].dts,
                                           s->streams[pkt->stream_index]->time_base,
                                           AV_TIME_BASE_Q);
Simple merge