[FFmpeg-cvslog] Merge commit '1263b2039eb5aaf1522e9de9f07c787ab30a5f50'

Clément Bœsch git at videolan.org
Fri Mar 24 14:37:12 EET 2017


ffmpeg | branch: master | Clément Bœsch <u at pkh.me> | Fri Mar 24 13:29:45 2017 +0100| [46f4f8ad865d4e4d867d14edb44a656318951ec1] | committer: Clément Bœsch

Merge commit '1263b2039eb5aaf1522e9de9f07c787ab30a5f50'

* commit '1263b2039eb5aaf1522e9de9f07c787ab30a5f50':
  Adjust printf conversion specifiers to match variable signedness

Merged-by: Clément Bœsch <u at pkh.me>

> http://git.videolan.org/gitweb.cgi/ffmpeg.git/?a=commit;h=46f4f8ad865d4e4d867d14edb44a656318951ec1
---

 libavcodec/dnxhddec.c      |  4 ++--
 libavcodec/dvdec.c         |  2 +-
 libavcodec/dxv.c           |  2 +-
 libavcodec/fraps.c         |  2 +-
 libavcodec/txd.c           |  4 ++--
 libavformat/mov.c          | 38 +++++++++++++++++++-------------------
 libavformat/rtpdec_jpeg.c  |  2 +-
 libavformat/rtpdec_xiph.c  |  4 ++--
 libavformat/rtpenc.c       |  2 +-
 libswscale/tests/swscale.c |  2 +-
 10 files changed, 31 insertions(+), 31 deletions(-)

diff --git a/libavcodec/dnxhddec.c b/libavcodec/dnxhddec.c
index defbf10..305fd52 100644
--- a/libavcodec/dnxhddec.c
+++ b/libavcodec/dnxhddec.c
@@ -278,7 +278,7 @@ static int dnxhd_decode_header(DNXHDContext *ctx, AVFrame *frame,
     }
 
     if (buf_size < ctx->cid_table->coding_unit_size) {
-        av_log(ctx->avctx, AV_LOG_ERROR, "incorrect frame size (%d < %d).\n",
+        av_log(ctx->avctx, AV_LOG_ERROR, "incorrect frame size (%d < %u).\n",
                buf_size, ctx->cid_table->coding_unit_size);
         return AVERROR_INVALIDDATA;
     }
@@ -608,7 +608,7 @@ decode_coding_unit:
 
     if ((avctx->width || avctx->height) &&
         (ctx->width != avctx->width || ctx->height != avctx->height)) {
-        av_log(avctx, AV_LOG_WARNING, "frame size changed: %dx%d -> %dx%d\n",
+        av_log(avctx, AV_LOG_WARNING, "frame size changed: %dx%d -> %ux%u\n",
                avctx->width, avctx->height, ctx->width, ctx->height);
         first_field = 1;
     }
diff --git a/libavcodec/dvdec.c b/libavcodec/dvdec.c
index d71a660..a8d7a07 100644
--- a/libavcodec/dvdec.c
+++ b/libavcodec/dvdec.c
@@ -222,7 +222,7 @@ static void dv_decode_ac(GetBitContext *gb, BlockInfo *mb, int16_t *block)
 
     /* get the AC coefficients until last_index is reached */
     for (;;) {
-        ff_dlog(NULL, "%2d: bits=%04x index=%d\n", pos, SHOW_UBITS(re, gb, 16),
+        ff_dlog(NULL, "%2d: bits=%04x index=%u\n", pos, SHOW_UBITS(re, gb, 16),
                 re_index);
         /* our own optimized GET_RL_VLC */
         index   = NEG_USR32(re_cache, TEX_VLC_BITS);
diff --git a/libavcodec/dxv.c b/libavcodec/dxv.c
index c931577..b1f826a 100644
--- a/libavcodec/dxv.c
+++ b/libavcodec/dxv.c
@@ -429,7 +429,7 @@ static int dxv_decode(AVCodecContext *avctx, void *data,
 
     if (size != bytestream2_get_bytes_left(gbc)) {
         av_log(avctx, AV_LOG_ERROR,
-               "Incomplete or invalid file (header %d, left %d).\n",
+               "Incomplete or invalid file (header %d, left %u).\n",
                size, bytestream2_get_bytes_left(gbc));
         return AVERROR_INVALIDDATA;
     }
diff --git a/libavcodec/fraps.c b/libavcodec/fraps.c
index ed8cb18..d5fb919 100644
--- a/libavcodec/fraps.c
+++ b/libavcodec/fraps.c
@@ -161,7 +161,7 @@ static int decode_frame(AVCodecContext *avctx,
 
     if (version > 5) {
         av_log(avctx, AV_LOG_ERROR,
-               "This file is encoded with Fraps version %d. " \
+               "This file is encoded with Fraps version %u. "
                "This codec can only decode versions <= 5.\n", version);
         return AVERROR_PATCHWELCOME;
     }
diff --git a/libavcodec/txd.c b/libavcodec/txd.c
index d7fdde0..9b412a7 100644
--- a/libavcodec/txd.c
+++ b/libavcodec/txd.c
@@ -56,7 +56,7 @@ static int txd_decode_frame(AVCodecContext *avctx, void *data, int *got_frame,
     flags           = bytestream2_get_byte(&gb);
 
     if (version < 8 || version > 9) {
-        av_log(avctx, AV_LOG_ERROR, "texture data version %i is unsupported\n",
+        av_log(avctx, AV_LOG_ERROR, "texture data version %u is unsupported\n",
                                                                     version);
         return AVERROR_PATCHWELCOME;
     }
@@ -66,7 +66,7 @@ static int txd_decode_frame(AVCodecContext *avctx, void *data, int *got_frame,
     } else if (depth == 16 || depth == 32) {
         avctx->pix_fmt = AV_PIX_FMT_RGBA;
     } else {
-        av_log(avctx, AV_LOG_ERROR, "depth of %i is unsupported\n", depth);
+        av_log(avctx, AV_LOG_ERROR, "depth of %u is unsupported\n", depth);
         return AVERROR_PATCHWELCOME;
     }
 
diff --git a/libavformat/mov.c b/libavformat/mov.c
index dbe94e2..41bf21d 100644
--- a/libavformat/mov.c
+++ b/libavformat/mov.c
@@ -2407,7 +2407,7 @@ static int mov_read_stsc(MOVContext *c, AVIOContext *pb, MOVAtom atom)
 
     entries = avio_rb32(pb);
 
-    av_log(c->fc, AV_LOG_TRACE, "track[%i].stsc.entries = %i\n", c->fc->nb_streams-1, entries);
+    av_log(c->fc, AV_LOG_TRACE, "track[%u].stsc.entries = %u\n", c->fc->nb_streams - 1, entries);
 
     if (!entries)
         return 0;
@@ -2498,7 +2498,7 @@ static int mov_read_stss(MOVContext *c, AVIOContext *pb, MOVAtom atom)
 
     entries = avio_rb32(pb);
 
-    av_log(c->fc, AV_LOG_TRACE, "keyframe_count = %d\n", entries);
+    av_log(c->fc, AV_LOG_TRACE, "keyframe_count = %u\n", entries);
 
     if (!entries)
     {
@@ -2559,14 +2559,14 @@ static int mov_read_stsz(MOVContext *c, AVIOContext *pb, MOVAtom atom)
     }
     entries = avio_rb32(pb);
 
-    av_log(c->fc, AV_LOG_TRACE, "sample_size = %d sample_count = %d\n", sc->sample_size, entries);
+    av_log(c->fc, AV_LOG_TRACE, "sample_size = %u sample_count = %u\n", sc->sample_size, entries);
 
     sc->sample_count = entries;
     if (sample_size)
         return 0;
 
     if (field_size != 4 && field_size != 8 && field_size != 16 && field_size != 32) {
-        av_log(c->fc, AV_LOG_ERROR, "Invalid sample field size %d\n", field_size);
+        av_log(c->fc, AV_LOG_ERROR, "Invalid sample field size %u\n", field_size);
         return AVERROR_INVALIDDATA;
     }
 
@@ -2631,7 +2631,7 @@ static int mov_read_stts(MOVContext *c, AVIOContext *pb, MOVAtom atom)
     avio_rb24(pb); /* flags */
     entries = avio_rb32(pb);
 
-    av_log(c->fc, AV_LOG_TRACE, "track[%i].stts.entries = %i\n",
+    av_log(c->fc, AV_LOG_TRACE, "track[%u].stts.entries = %u\n",
             c->fc->nb_streams-1, entries);
 
     if (sc->stts_data)
@@ -2710,7 +2710,7 @@ static int mov_read_ctts(MOVContext *c, AVIOContext *pb, MOVAtom atom)
     avio_rb24(pb); /* flags */
     entries = avio_rb32(pb);
 
-    av_log(c->fc, AV_LOG_TRACE, "track[%i].ctts.entries = %i\n", c->fc->nb_streams-1, entries);
+    av_log(c->fc, AV_LOG_TRACE, "track[%u].ctts.entries = %u\n", c->fc->nb_streams - 1, entries);
 
     if (!entries)
         return 0;
@@ -3425,8 +3425,8 @@ static void mov_build_index(MOVContext *mov, AVStream *st)
                     e->size = sample_size;
                     e->min_distance = distance;
                     e->flags = keyframe ? AVINDEX_KEYFRAME : 0;
-                    av_log(mov->fc, AV_LOG_TRACE, "AVIndex stream %d, sample %d, offset %"PRIx64", dts %"PRId64", "
-                            "size %d, distance %d, keyframe %d\n", st->index, current_sample,
+                    av_log(mov->fc, AV_LOG_TRACE, "AVIndex stream %d, sample %u, offset %"PRIx64", dts %"PRId64", "
+                            "size %u, distance %u, keyframe %d\n", st->index, current_sample,
                             current_offset, current_dts, sample_size, distance, keyframe);
                     if (st->codecpar->codec_type == AVMEDIA_TYPE_VIDEO && st->nb_index_entries < 100)
                         ff_rfps_add_frame(mov->fc, st, current_dts);
@@ -3496,7 +3496,7 @@ static void mov_build_index(MOVContext *mov, AVStream *st)
             total += chunk_count * count;
         }
 
-        av_log(mov->fc, AV_LOG_TRACE, "chunk count %d\n", total);
+        av_log(mov->fc, AV_LOG_TRACE, "chunk count %u\n", total);
         if (total >= UINT_MAX / sizeof(*st->index_entries) - st->nb_index_entries)
             return;
         if (av_reallocp_array(&st->index_entries,
@@ -3541,7 +3541,7 @@ static void mov_build_index(MOVContext *mov, AVStream *st)
                 }
 
                 if (st->nb_index_entries >= total) {
-                    av_log(mov->fc, AV_LOG_ERROR, "wrong chunk count %d\n", total);
+                    av_log(mov->fc, AV_LOG_ERROR, "wrong chunk count %u\n", total);
                     return;
                 }
                 if (size > 0x3FFFFFFF) {
@@ -3554,9 +3554,9 @@ static void mov_build_index(MOVContext *mov, AVStream *st)
                 e->size = size;
                 e->min_distance = 0;
                 e->flags = AVINDEX_KEYFRAME;
-                av_log(mov->fc, AV_LOG_TRACE, "AVIndex stream %d, chunk %d, offset %"PRIx64", dts %"PRId64", "
-                        "size %d, duration %d\n", st->index, i, current_offset, current_dts,
-                        size, samples);
+                av_log(mov->fc, AV_LOG_TRACE, "AVIndex stream %d, chunk %u, offset %"PRIx64", dts %"PRId64", "
+                       "size %u, duration %u\n", st->index, i, current_offset, current_dts,
+                       size, samples);
 
                 current_offset += size;
                 current_dts += samples;
@@ -4183,7 +4183,7 @@ static int mov_read_tfdt(MOVContext *c, AVIOContext *pb, MOVAtom atom)
         }
     }
     if (!st) {
-        av_log(c->fc, AV_LOG_ERROR, "could not find corresponding track id %d\n", frag->track_id);
+        av_log(c->fc, AV_LOG_ERROR, "could not find corresponding track id %u\n", frag->track_id);
         return AVERROR_INVALIDDATA;
     }
     sc = st->priv_data;
@@ -4218,7 +4218,7 @@ static int mov_read_trun(MOVContext *c, AVIOContext *pb, MOVAtom atom)
         }
     }
     if (!st) {
-        av_log(c->fc, AV_LOG_ERROR, "could not find corresponding track id %d\n", frag->track_id);
+        av_log(c->fc, AV_LOG_ERROR, "could not find corresponding track id %u\n", frag->track_id);
         return AVERROR_INVALIDDATA;
     }
     sc = st->priv_data;
@@ -4227,7 +4227,7 @@ static int mov_read_trun(MOVContext *c, AVIOContext *pb, MOVAtom atom)
     avio_r8(pb); /* version */
     flags = avio_rb24(pb);
     entries = avio_rb32(pb);
-    av_log(c->fc, AV_LOG_TRACE, "flags 0x%x entries %d\n", flags, entries);
+    av_log(c->fc, AV_LOG_TRACE, "flags 0x%x entries %u\n", flags, entries);
 
     /* Always assume the presence of composition time offsets.
      * Without this assumption, for instance, we cannot deal with a track in fragmented movies that meet the following.
@@ -4307,8 +4307,8 @@ static int mov_read_trun(MOVContext *c, AVIOContext *pb, MOVAtom atom)
         if (err < 0) {
             av_log(c->fc, AV_LOG_ERROR, "Failed to add index entry\n");
         }
-        av_log(c->fc, AV_LOG_TRACE, "AVIndex stream %d, sample %d, offset %"PRIx64", dts %"PRId64", "
-                "size %d, distance %d, keyframe %d\n", st->index, sc->sample_count+i,
+        av_log(c->fc, AV_LOG_TRACE, "AVIndex stream %d, sample %u, offset %"PRIx64", dts %"PRId64", "
+                "size %u, distance %d, keyframe %d\n", st->index, sc->sample_count+i,
                 offset, dts, sample_size, distance, keyframe);
         distance++;
         dts += sample_duration;
@@ -4547,7 +4547,7 @@ static int mov_read_elst(MOVContext *c, AVIOContext *pb, MOVAtom atom)
     if (!sc->elst_data)
         return AVERROR(ENOMEM);
 
-    av_log(c->fc, AV_LOG_TRACE, "track[%i].edit_count = %i\n", c->fc->nb_streams-1, edit_count);
+    av_log(c->fc, AV_LOG_TRACE, "track[%u].edit_count = %i\n", c->fc->nb_streams - 1, edit_count);
     for (i = 0; i < edit_count && !pb->eof_reached; i++) {
         MOVElst *e = &sc->elst_data[i];
 
diff --git a/libavformat/rtpdec_jpeg.c b/libavformat/rtpdec_jpeg.c
index 397b5cf..05dd172 100644
--- a/libavformat/rtpdec_jpeg.c
+++ b/libavformat/rtpdec_jpeg.c
@@ -247,7 +247,7 @@ static int jpeg_parse_packet(AVFormatContext *ctx, PayloadContext *jpeg,
         type &= ~0x40;
     }
     if (type > 1) {
-        av_log(ctx, AV_LOG_ERROR, "Unimplemented RTP/JPEG type %d\n", type);
+        av_log(ctx, AV_LOG_ERROR, "Unimplemented RTP/JPEG type %"PRIu8"\n", type);
         return AVERROR_PATCHWELCOME;
     }
 
diff --git a/libavformat/rtpdec_xiph.c b/libavformat/rtpdec_xiph.c
index 26aef54..e1b7990 100644
--- a/libavformat/rtpdec_xiph.c
+++ b/libavformat/rtpdec_xiph.c
@@ -247,7 +247,7 @@ parse_packed_headers(AVFormatContext *s,
 
     if (num_packed != 1 || num_headers > 3) {
         av_log(s, AV_LOG_ERROR,
-               "Unimplemented number of headers: %d packed headers, %d headers\n",
+               "Unimplemented number of headers: %u packed headers, %u headers\n",
                num_packed, num_headers);
         return AVERROR_PATCHWELCOME;
     }
@@ -255,7 +255,7 @@ parse_packed_headers(AVFormatContext *s,
     if (packed_headers_end - packed_headers != length ||
         length1 > length || length2 > length - length1) {
         av_log(s, AV_LOG_ERROR,
-               "Bad packed header lengths (%d,%d,%"PTRDIFF_SPECIFIER",%d)\n", length1,
+               "Bad packed header lengths (%d,%d,%"PTRDIFF_SPECIFIER",%u)\n", length1,
                length2, packed_headers_end - packed_headers, length);
         return AVERROR_INVALIDDATA;
     }
diff --git a/libavformat/rtpenc.c b/libavformat/rtpenc.c
index efa63a5..eee17d0 100644
--- a/libavformat/rtpenc.c
+++ b/libavformat/rtpenc.c
@@ -145,7 +145,7 @@ static int rtp_write_header(AVFormatContext *s1)
     } else
         s1->packet_size = s1->pb->max_packet_size;
     if (s1->packet_size <= 12) {
-        av_log(s1, AV_LOG_ERROR, "Max packet size %d too low\n", s1->packet_size);
+        av_log(s1, AV_LOG_ERROR, "Max packet size %u too low\n", s1->packet_size);
         return AVERROR(EIO);
     }
     s->buf = av_malloc(s1->packet_size);
diff --git a/libswscale/tests/swscale.c b/libswscale/tests/swscale.c
index da6a41b..bd8d098 100644
--- a/libswscale/tests/swscale.c
+++ b/libswscale/tests/swscale.c
@@ -318,7 +318,7 @@ static int fileTest(uint8_t *ref[4], int refStride[4], int w, int h, FILE *fp,
 
         ret = sscanf(buf,
                      " %12s %dx%d -> %12s %dx%d flags=%d CRC=%x"
-                     " SSD=%"SCNd64 ", %"SCNd64 ", %"SCNd64 ", %"SCNd64 "\n",
+                     " SSD=%"SCNu64 ", %"SCNu64 ", %"SCNu64 ", %"SCNu64 "\n",
                      srcStr, &srcW, &srcH, dstStr, &dstW, &dstH,
                      &flags, &r.crc, &r.ssdY, &r.ssdU, &r.ssdV, &r.ssdA);
         if (ret != 12) {


======================================================================

diff --cc libavformat/mov.c
index dbe94e2,0d7ce3d..41bf21d
--- a/libavformat/mov.c
+++ b/libavformat/mov.c
@@@ -2631,14 -2155,16 +2631,14 @@@ static int mov_read_stts(MOVContext *c
      avio_rb24(pb); /* flags */
      entries = avio_rb32(pb);
  
-     av_log(c->fc, AV_LOG_TRACE, "track[%i].stts.entries = %i\n",
+     av_log(c->fc, AV_LOG_TRACE, "track[%u].stts.entries = %u\n",
              c->fc->nb_streams-1, entries);
  
 -    if (!entries)
 -        return 0;
 -    if (entries >= UINT_MAX / sizeof(*sc->stts_data))
 -        return AVERROR(EINVAL);
 -
 +    if (sc->stts_data)
 +        av_log(c->fc, AV_LOG_WARNING, "Duplicated STTS atom\n");
      av_free(sc->stts_data);
 -    sc->stts_data = av_malloc(entries * sizeof(*sc->stts_data));
 +    sc->stts_count = 0;
 +    sc->stts_data = av_malloc_array(entries, sizeof(*sc->stts_data));
      if (!sc->stts_data)
          return AVERROR(ENOMEM);
  
@@@ -2710,8 -2215,10 +2710,8 @@@ static int mov_read_ctts(MOVContext *c
      avio_rb24(pb); /* flags */
      entries = avio_rb32(pb);
  
-     av_log(c->fc, AV_LOG_TRACE, "track[%i].ctts.entries = %i\n", c->fc->nb_streams-1, entries);
+     av_log(c->fc, AV_LOG_TRACE, "track[%u].ctts.entries = %u\n", c->fc->nb_streams - 1, entries);
  
 -    av_freep(&sc->ctts_data);
 -
      if (!entries)
          return 0;
      if (entries >= UINT_MAX / sizeof(*sc->ctts_data))
@@@ -3425,11 -2372,9 +3425,11 @@@ static void mov_build_index(MOVContext 
                      e->size = sample_size;
                      e->min_distance = distance;
                      e->flags = keyframe ? AVINDEX_KEYFRAME : 0;
-                     av_log(mov->fc, AV_LOG_TRACE, "AVIndex stream %d, sample %d, offset %"PRIx64", dts %"PRId64", "
-                             "size %d, distance %d, keyframe %d\n", st->index, current_sample,
+                     av_log(mov->fc, AV_LOG_TRACE, "AVIndex stream %d, sample %u, offset %"PRIx64", dts %"PRId64", "
 -                           "size %u, distance %u, keyframe %d\n", st->index, current_sample,
 -                           current_offset, current_dts, sample_size, distance, keyframe);
++                            "size %u, distance %u, keyframe %d\n", st->index, current_sample,
 +                            current_offset, current_dts, sample_size, distance, keyframe);
 +                    if (st->codecpar->codec_type == AVMEDIA_TYPE_VIDEO && st->nb_index_entries < 100)
 +                        ff_rfps_add_frame(mov->fc, st, current_dts);
                  }
  
                  current_offset += sample_size;
@@@ -3541,13 -2466,9 +3541,13 @@@
                  }
  
                  if (st->nb_index_entries >= total) {
-                     av_log(mov->fc, AV_LOG_ERROR, "wrong chunk count %d\n", total);
+                     av_log(mov->fc, AV_LOG_ERROR, "wrong chunk count %u\n", total);
                      return;
                  }
 +                if (size > 0x3FFFFFFF) {
 +                    av_log(mov->fc, AV_LOG_ERROR, "Sample size %u is too large\n", size);
 +                    return;
 +                }
                  e = &st->index_entries[st->nb_index_entries++];
                  e->pos = current_offset;
                  e->timestamp = current_dts;
@@@ -4302,14 -3016,11 +4302,14 @@@ static int mov_read_trun(MOVContext *c
                                    MOV_FRAG_SAMPLE_FLAG_DEPENDS_YES));
          if (keyframe)
              distance = 0;
 -        av_add_index_entry(st, offset, dts, sample_size, distance,
 -                           keyframe ? AVINDEX_KEYFRAME : 0);
 +        err = av_add_index_entry(st, offset, dts, sample_size, distance,
 +                                 keyframe ? AVINDEX_KEYFRAME : 0);
 +        if (err < 0) {
 +            av_log(c->fc, AV_LOG_ERROR, "Failed to add index entry\n");
 +        }
-         av_log(c->fc, AV_LOG_TRACE, "AVIndex stream %d, sample %d, offset %"PRIx64", dts %"PRId64", "
-                 "size %d, distance %d, keyframe %d\n", st->index, sc->sample_count+i,
+         av_log(c->fc, AV_LOG_TRACE, "AVIndex stream %d, sample %u, offset %"PRIx64", dts %"PRId64", "
 -               "size %u, distance %d, keyframe %d\n", st->index, sc->sample_count+i,
 -               offset, dts, sample_size, distance, keyframe);
++                "size %u, distance %d, keyframe %d\n", st->index, sc->sample_count+i,
 +                offset, dts, sample_size, distance, keyframe);
          distance++;
          dts += sample_duration;
          offset += sample_size;
@@@ -4537,707 -3123,30 +4537,707 @@@ static int mov_read_elst(MOVContext *c
      avio_rb24(pb); /* flags */
      edit_count = avio_rb32(pb); /* entries */
  
 -    if ((uint64_t)edit_count*12+8 > atom.size)
 -        return AVERROR_INVALIDDATA;
 +    if (!edit_count)
 +        return 0;
 +    if (sc->elst_data)
 +        av_log(c->fc, AV_LOG_WARNING, "Duplicated ELST atom\n");
 +    av_free(sc->elst_data);
 +    sc->elst_count = 0;
 +    sc->elst_data = av_malloc_array(edit_count, sizeof(*sc->elst_data));
 +    if (!sc->elst_data)
 +        return AVERROR(ENOMEM);
 +
-     av_log(c->fc, AV_LOG_TRACE, "track[%i].edit_count = %i\n", c->fc->nb_streams-1, edit_count);
++    av_log(c->fc, AV_LOG_TRACE, "track[%u].edit_count = %i\n", c->fc->nb_streams - 1, edit_count);
 +    for (i = 0; i < edit_count && !pb->eof_reached; i++) {
 +        MOVElst *e = &sc->elst_data[i];
  
 -    for (i=0; i<edit_count; i++){
 -        int64_t time;
 -        int64_t duration;
          if (version == 1) {
 -            duration = avio_rb64(pb);
 -            time     = avio_rb64(pb);
 +            e->duration = avio_rb64(pb);
 +            e->time     = avio_rb64(pb);
          } else {
 -            duration = avio_rb32(pb); /* segment duration */
 -            time     = (int32_t)avio_rb32(pb); /* media time */
 +            e->duration = avio_rb32(pb); /* segment duration */
 +            e->time     = (int32_t)avio_rb32(pb); /* media time */
          }
 -        avio_rb32(pb); /* Media rate */
 -        if (i == 0 && time >= -1) {
 -            sc->time_offset = time != -1 ? time : -duration;
 +        e->rate = avio_rb32(pb) / 65536.0;
 +        av_log(c->fc, AV_LOG_TRACE, "duration=%"PRId64" time=%"PRId64" rate=%f\n",
 +               e->duration, e->time, e->rate);
 +
 +        if (e->time < 0 && e->time != -1 &&
 +            c->fc->strict_std_compliance >= FF_COMPLIANCE_STRICT) {
 +            av_log(c->fc, AV_LOG_ERROR, "Track %d, edit %d: Invalid edit list media time=%"PRId64"\n",
 +                   c->fc->nb_streams-1, i, e->time);
 +            return AVERROR_INVALIDDATA;
          }
      }
 +    sc->elst_count = i;
  
 -    if (edit_count > 1)
 -        av_log(c->fc, AV_LOG_WARNING, "multiple edit list entries, "
 -               "a/v desync might occur, patch welcome\n");
 +    return 0;
 +}
 +
 +static int mov_read_tmcd(MOVContext *c, AVIOContext *pb, MOVAtom atom)
 +{
 +    MOVStreamContext *sc;
 +
 +    if (c->fc->nb_streams < 1)
 +        return AVERROR_INVALIDDATA;
 +    sc = c->fc->streams[c->fc->nb_streams - 1]->priv_data;
 +    sc->timecode_track = avio_rb32(pb);
 +    return 0;
 +}
 +
 +static int mov_read_st3d(MOVContext *c, AVIOContext *pb, MOVAtom atom)
 +{
 +    AVStream *st;
 +    MOVStreamContext *sc;
 +    enum AVStereo3DType type;
 +    int mode;
 +
 +    if (c->fc->nb_streams < 1)
 +        return 0;
 +
 +    st = c->fc->streams[c->fc->nb_streams - 1];
 +    sc = st->priv_data;
 +
 +    if (atom.size < 5) {
 +        av_log(c->fc, AV_LOG_ERROR, "Empty stereoscopic video box\n");
 +        return AVERROR_INVALIDDATA;
 +    }
 +    avio_skip(pb, 4); /* version + flags */
 +
 +    mode = avio_r8(pb);
 +    switch (mode) {
 +    case 0:
 +        type = AV_STEREO3D_2D;
 +        break;
 +    case 1:
 +        type = AV_STEREO3D_TOPBOTTOM;
 +        break;
 +    case 2:
 +        type = AV_STEREO3D_SIDEBYSIDE;
 +        break;
 +    default:
 +        av_log(c->fc, AV_LOG_WARNING, "Unknown st3d mode value %d\n", mode);
 +        return 0;
 +    }
 +
 +    sc->stereo3d = av_stereo3d_alloc();
 +    if (!sc->stereo3d)
 +        return AVERROR(ENOMEM);
 +
 +    sc->stereo3d->type = type;
 +    return 0;
 +}
 +
 +static int mov_read_sv3d(MOVContext *c, AVIOContext *pb, MOVAtom atom)
 +{
 +    AVStream *st;
 +    MOVStreamContext *sc;
 +    int size, layout;
 +    int32_t yaw, pitch, roll;
 +    uint32_t l = 0, t = 0, r = 0, b = 0;
 +    uint32_t tag, padding = 0;
 +    enum AVSphericalProjection projection;
 +
 +    if (c->fc->nb_streams < 1)
 +        return 0;
 +
 +    st = c->fc->streams[c->fc->nb_streams - 1];
 +    sc = st->priv_data;
 +
 +    if (atom.size < 8) {
 +        av_log(c->fc, AV_LOG_ERROR, "Empty spherical video box\n");
 +        return AVERROR_INVALIDDATA;
 +    }
 +
 +    size = avio_rb32(pb);
 +    if (size <= 12 || size > atom.size)
 +        return AVERROR_INVALIDDATA;
 +
 +    tag = avio_rl32(pb);
 +    if (tag != MKTAG('s','v','h','d')) {
 +        av_log(c->fc, AV_LOG_ERROR, "Missing spherical video header\n");
 +        return 0;
 +    }
 +    avio_skip(pb, 4); /*  version + flags */
 +    avio_skip(pb, size - 12); /* metadata_source */
 +
 +    size = avio_rb32(pb);
 +    if (size > atom.size)
 +        return AVERROR_INVALIDDATA;
 +
 +    tag = avio_rl32(pb);
 +    if (tag != MKTAG('p','r','o','j')) {
 +        av_log(c->fc, AV_LOG_ERROR, "Missing projection box\n");
 +        return 0;
 +    }
 +
 +    size = avio_rb32(pb);
 +    if (size > atom.size)
 +        return AVERROR_INVALIDDATA;
 +
 +    tag = avio_rl32(pb);
 +    if (tag != MKTAG('p','r','h','d')) {
 +        av_log(c->fc, AV_LOG_ERROR, "Missing projection header box\n");
 +        return 0;
 +    }
 +    avio_skip(pb, 4); /*  version + flags */
 +
 +    /* 16.16 fixed point */
 +    yaw   = avio_rb32(pb);
 +    pitch = avio_rb32(pb);
 +    roll  = avio_rb32(pb);
 +
 +    size = avio_rb32(pb);
 +    if (size > atom.size)
 +        return AVERROR_INVALIDDATA;
 +
 +    tag = avio_rl32(pb);
 +    avio_skip(pb, 4); /*  version + flags */
 +    switch (tag) {
 +    case MKTAG('c','b','m','p'):
 +        layout = avio_rb32(pb);
 +        if (layout) {
 +            av_log(c->fc, AV_LOG_WARNING,
 +                   "Unsupported cubemap layout %d\n", layout);
 +            return 0;
 +        }
 +        projection = AV_SPHERICAL_CUBEMAP;
 +        padding = avio_rb32(pb);
 +        break;
 +    case MKTAG('e','q','u','i'):
 +        t = avio_rb32(pb);
 +        b = avio_rb32(pb);
 +        l = avio_rb32(pb);
 +        r = avio_rb32(pb);
 +
 +        if (b >= UINT_MAX - t || r >= UINT_MAX - l) {
 +            av_log(c->fc, AV_LOG_ERROR,
 +                   "Invalid bounding rectangle coordinates "
 +                   "%"PRIu32",%"PRIu32",%"PRIu32",%"PRIu32"\n", l, t, r, b);
 +            return AVERROR_INVALIDDATA;
 +        }
 +
 +        if (l || t || r || b)
 +            projection = AV_SPHERICAL_EQUIRECTANGULAR_TILE;
 +        else
 +            projection = AV_SPHERICAL_EQUIRECTANGULAR;
 +        break;
 +    default:
 +        av_log(c->fc, AV_LOG_ERROR, "Unknown projection type\n");
 +        return 0;
 +    }
 +
 +    sc->spherical = av_spherical_alloc(&sc->spherical_size);
 +    if (!sc->spherical)
 +        return AVERROR(ENOMEM);
 +
 +    sc->spherical->projection = projection;
 +
 +    sc->spherical->yaw   = yaw;
 +    sc->spherical->pitch = pitch;
 +    sc->spherical->roll  = roll;
 +
 +    sc->spherical->padding = padding;
 +
 +    sc->spherical->bound_left   = l;
 +    sc->spherical->bound_top    = t;
 +    sc->spherical->bound_right  = r;
 +    sc->spherical->bound_bottom = b;
  
 -    av_log(c->fc, AV_LOG_TRACE, "track[%u].edit_count = %i\n", c->fc->nb_streams - 1, edit_count);
 +    return 0;
 +}
 +
 +static int mov_parse_uuid_spherical(MOVStreamContext *sc, AVIOContext *pb, size_t len)
 +{
 +    int ret = 0;
 +    uint8_t *buffer = av_malloc(len + 1);
 +    const char *val;
 +
 +    if (!buffer)
 +        return AVERROR(ENOMEM);
 +    buffer[len] = '\0';
 +
 +    ret = ffio_read_size(pb, buffer, len);
 +    if (ret < 0)
 +        goto out;
 +
 +    /* Check for mandatory keys and values, try to support XML as best-effort */
 +    if (av_stristr(buffer, "<GSpherical:StitchingSoftware>") &&
 +        (val = av_stristr(buffer, "<GSpherical:Spherical>")) &&
 +        av_stristr(val, "true") &&
 +        (val = av_stristr(buffer, "<GSpherical:Stitched>")) &&
 +        av_stristr(val, "true") &&
 +        (val = av_stristr(buffer, "<GSpherical:ProjectionType>")) &&
 +        av_stristr(val, "equirectangular")) {
 +        sc->spherical = av_spherical_alloc(&sc->spherical_size);
 +        if (!sc->spherical)
 +            goto out;
 +
 +        sc->spherical->projection = AV_SPHERICAL_EQUIRECTANGULAR;
 +
 +        if (av_stristr(buffer, "<GSpherical:StereoMode>")) {
 +            enum AVStereo3DType mode;
 +
 +            if (av_stristr(buffer, "left-right"))
 +                mode = AV_STEREO3D_SIDEBYSIDE;
 +            else if (av_stristr(buffer, "top-bottom"))
 +                mode = AV_STEREO3D_TOPBOTTOM;
 +            else
 +                mode = AV_STEREO3D_2D;
 +
 +            sc->stereo3d = av_stereo3d_alloc();
 +            if (!sc->stereo3d)
 +                goto out;
 +
 +            sc->stereo3d->type = mode;
 +        }
 +
 +        /* orientation */
 +        val = av_stristr(buffer, "<GSpherical:InitialViewHeadingDegrees>");
 +        if (val)
 +            sc->spherical->yaw = strtol(val, NULL, 10) * (1 << 16);
 +        val = av_stristr(buffer, "<GSpherical:InitialViewPitchDegrees>");
 +        if (val)
 +            sc->spherical->pitch = strtol(val, NULL, 10) * (1 << 16);
 +        val = av_stristr(buffer, "<GSpherical:InitialViewRollDegrees>");
 +        if (val)
 +            sc->spherical->roll = strtol(val, NULL, 10) * (1 << 16);
 +    }
 +
 +out:
 +    av_free(buffer);
 +    return ret;
 +}
 +
 +static int mov_read_uuid(MOVContext *c, AVIOContext *pb, MOVAtom atom)
 +{
 +    AVStream *st;
 +    MOVStreamContext *sc;
 +    int64_t ret;
 +    uint8_t uuid[16];
 +    static const uint8_t uuid_isml_manifest[] = {
 +        0xa5, 0xd4, 0x0b, 0x30, 0xe8, 0x14, 0x11, 0xdd,
 +        0xba, 0x2f, 0x08, 0x00, 0x20, 0x0c, 0x9a, 0x66
 +    };
 +    static const uint8_t uuid_xmp[] = {
 +        0xbe, 0x7a, 0xcf, 0xcb, 0x97, 0xa9, 0x42, 0xe8,
 +        0x9c, 0x71, 0x99, 0x94, 0x91, 0xe3, 0xaf, 0xac
 +    };
 +    static const uint8_t uuid_spherical[] = {
 +        0xff, 0xcc, 0x82, 0x63, 0xf8, 0x55, 0x4a, 0x93,
 +        0x88, 0x14, 0x58, 0x7a, 0x02, 0x52, 0x1f, 0xdd,
 +    };
 +
 +    if (atom.size < sizeof(uuid) || atom.size >= FFMIN(INT_MAX, SIZE_MAX))
 +        return AVERROR_INVALIDDATA;
 +
 +    if (c->fc->nb_streams < 1)
 +        return 0;
 +    st = c->fc->streams[c->fc->nb_streams - 1];
 +    sc = st->priv_data;
 +
 +    ret = avio_read(pb, uuid, sizeof(uuid));
 +    if (ret < 0) {
 +        return ret;
 +    } else if (ret != sizeof(uuid)) {
 +        return AVERROR_INVALIDDATA;
 +    }
 +    if (!memcmp(uuid, uuid_isml_manifest, sizeof(uuid))) {
 +        uint8_t *buffer, *ptr;
 +        char *endptr;
 +        size_t len = atom.size - sizeof(uuid);
 +
 +        if (len < 4) {
 +            return AVERROR_INVALIDDATA;
 +        }
 +        ret = avio_skip(pb, 4); // zeroes
 +        len -= 4;
 +
 +        buffer = av_mallocz(len + 1);
 +        if (!buffer) {
 +            return AVERROR(ENOMEM);
 +        }
 +        ret = avio_read(pb, buffer, len);
 +        if (ret < 0) {
 +            av_free(buffer);
 +            return ret;
 +        } else if (ret != len) {
 +            av_free(buffer);
 +            return AVERROR_INVALIDDATA;
 +        }
 +
 +        ptr = buffer;
 +        while ((ptr = av_stristr(ptr, "systemBitrate=\""))) {
 +            ptr += sizeof("systemBitrate=\"") - 1;
 +            c->bitrates_count++;
 +            c->bitrates = av_realloc_f(c->bitrates, c->bitrates_count, sizeof(*c->bitrates));
 +            if (!c->bitrates) {
 +                c->bitrates_count = 0;
 +                av_free(buffer);
 +                return AVERROR(ENOMEM);
 +            }
 +            errno = 0;
 +            ret = strtol(ptr, &endptr, 10);
 +            if (ret < 0 || errno || *endptr != '"') {
 +                c->bitrates[c->bitrates_count - 1] = 0;
 +            } else {
 +                c->bitrates[c->bitrates_count - 1] = ret;
 +            }
 +        }
 +
 +        av_free(buffer);
 +    } else if (!memcmp(uuid, uuid_xmp, sizeof(uuid))) {
 +        uint8_t *buffer;
 +        size_t len = atom.size - sizeof(uuid);
 +        if (c->export_xmp) {
 +            buffer = av_mallocz(len + 1);
 +            if (!buffer) {
 +                return AVERROR(ENOMEM);
 +            }
 +            ret = avio_read(pb, buffer, len);
 +            if (ret < 0) {
 +                av_free(buffer);
 +                return ret;
 +            } else if (ret != len) {
 +                av_free(buffer);
 +                return AVERROR_INVALIDDATA;
 +            }
 +            buffer[len] = '\0';
 +            av_dict_set(&c->fc->metadata, "xmp", buffer, 0);
 +            av_free(buffer);
 +        } else {
 +            // skip all uuid atom, which makes it fast for long uuid-xmp file
 +            ret = avio_skip(pb, len);
 +            if (ret < 0)
 +                return ret;
 +        }
 +    } else if (!memcmp(uuid, uuid_spherical, sizeof(uuid))) {
 +        size_t len = atom.size - sizeof(uuid);
 +        ret = mov_parse_uuid_spherical(sc, pb, len);
 +        if (ret < 0)
 +            return ret;
 +        if (!sc->spherical)
 +            av_log(c->fc, AV_LOG_WARNING, "Invalid spherical metadata found\n");    }
 +
 +    return 0;
 +}
 +
 +static int mov_read_free(MOVContext *c, AVIOContext *pb, MOVAtom atom)
 +{
 +    int ret;
 +    uint8_t content[16];
 +
 +    if (atom.size < 8)
 +        return 0;
 +
 +    ret = avio_read(pb, content, FFMIN(sizeof(content), atom.size));
 +    if (ret < 0)
 +        return ret;
 +
 +    if (   !c->found_moov
 +        && !c->found_mdat
 +        && !memcmp(content, "Anevia\x1A\x1A", 8)
 +        && c->use_mfra_for == FF_MOV_FLAG_MFRA_AUTO) {
 +        c->use_mfra_for = FF_MOV_FLAG_MFRA_PTS;
 +    }
 +
 +    return 0;
 +}
 +
 +static int mov_read_frma(MOVContext *c, AVIOContext *pb, MOVAtom atom)
 +{
 +    uint32_t format = avio_rl32(pb);
 +    MOVStreamContext *sc;
 +    enum AVCodecID id;
 +    AVStream *st;
 +
 +    if (c->fc->nb_streams < 1)
 +        return 0;
 +    st = c->fc->streams[c->fc->nb_streams - 1];
 +    sc = st->priv_data;
 +
 +    switch (sc->format)
 +    {
 +    case MKTAG('e','n','c','v'):        // encrypted video
 +    case MKTAG('e','n','c','a'):        // encrypted audio
 +        id = mov_codec_id(st, format);
 +        if (st->codecpar->codec_id != AV_CODEC_ID_NONE &&
 +            st->codecpar->codec_id != id) {
 +            av_log(c->fc, AV_LOG_WARNING,
 +                   "ignoring 'frma' atom of '%.4s', stream has codec id %d\n",
 +                   (char*)&format, st->codecpar->codec_id);
 +            break;
 +        }
 +
 +        st->codecpar->codec_id = id;
 +        sc->format = format;
 +        break;
 +
 +    default:
 +        if (format != sc->format) {
 +            av_log(c->fc, AV_LOG_WARNING,
 +                   "ignoring 'frma' atom of '%.4s', stream format is '%.4s'\n",
 +                   (char*)&format, (char*)&sc->format);
 +        }
 +        break;
 +    }
 +
 +    return 0;
 +}
 +
 +static int mov_read_senc(MOVContext *c, AVIOContext *pb, MOVAtom atom)
 +{
 +    AVStream *st;
 +    MOVStreamContext *sc;
 +    size_t auxiliary_info_size;
 +
 +    if (c->decryption_key_len == 0 || c->fc->nb_streams < 1)
 +        return 0;
 +
 +    st = c->fc->streams[c->fc->nb_streams - 1];
 +    sc = st->priv_data;
 +
 +    if (sc->cenc.aes_ctr) {
 +        av_log(c->fc, AV_LOG_ERROR, "duplicate senc atom\n");
 +        return AVERROR_INVALIDDATA;
 +    }
 +
 +    avio_r8(pb); /* version */
 +    sc->cenc.use_subsamples = avio_rb24(pb) & 0x02; /* flags */
 +
 +    avio_rb32(pb);        /* entries */
 +
 +    if (atom.size < 8 || atom.size > FFMIN(INT_MAX, SIZE_MAX)) {
 +        av_log(c->fc, AV_LOG_ERROR, "senc atom size %"PRId64" invalid\n", atom.size);
 +        return AVERROR_INVALIDDATA;
 +    }
 +
 +    /* save the auxiliary info as is */
 +    auxiliary_info_size = atom.size - 8;
 +
 +    sc->cenc.auxiliary_info = av_malloc(auxiliary_info_size);
 +    if (!sc->cenc.auxiliary_info) {
 +        return AVERROR(ENOMEM);
 +    }
 +
 +    sc->cenc.auxiliary_info_end = sc->cenc.auxiliary_info + auxiliary_info_size;
 +    sc->cenc.auxiliary_info_pos = sc->cenc.auxiliary_info;
 +    sc->cenc.auxiliary_info_index = 0;
 +
 +    if (avio_read(pb, sc->cenc.auxiliary_info, auxiliary_info_size) != auxiliary_info_size) {
 +        av_log(c->fc, AV_LOG_ERROR, "failed to read the auxiliary info");
 +        return AVERROR_INVALIDDATA;
 +    }
 +
 +    /* initialize the cipher */
 +    sc->cenc.aes_ctr = av_aes_ctr_alloc();
 +    if (!sc->cenc.aes_ctr) {
 +        return AVERROR(ENOMEM);
 +    }
 +
 +    return av_aes_ctr_init(sc->cenc.aes_ctr, c->decryption_key);
 +}
 +
 +static int mov_read_saiz(MOVContext *c, AVIOContext *pb, MOVAtom atom)
 +{
 +    AVStream *st;
 +    MOVStreamContext *sc;
 +    size_t data_size;
 +    int atom_header_size;
 +    int flags;
 +
 +    if (c->decryption_key_len == 0 || c->fc->nb_streams < 1)
 +        return 0;
 +
 +    st = c->fc->streams[c->fc->nb_streams - 1];
 +    sc = st->priv_data;
 +
 +    if (sc->cenc.auxiliary_info_sizes || sc->cenc.auxiliary_info_default_size) {
 +        av_log(c->fc, AV_LOG_ERROR, "duplicate saiz atom\n");
 +        return AVERROR_INVALIDDATA;
 +    }
 +
 +    atom_header_size = 9;
 +
 +    avio_r8(pb); /* version */
 +    flags = avio_rb24(pb);
 +
 +    if ((flags & 0x01) != 0) {
 +        atom_header_size += 8;
 +
 +        avio_rb32(pb);    /* info type */
 +        avio_rb32(pb);    /* info type param */
 +    }
 +
 +    sc->cenc.auxiliary_info_default_size = avio_r8(pb);
 +    avio_rb32(pb);    /* entries */
 +
 +    if (atom.size <= atom_header_size) {
 +        return 0;
 +    }
 +
 +    if (atom.size > FFMIN(INT_MAX, SIZE_MAX)) {
 +        av_log(c->fc, AV_LOG_ERROR, "saiz atom auxiliary_info_sizes size %"PRId64" invalid\n", atom.size);
 +        return AVERROR_INVALIDDATA;
 +    }
 +
 +    /* save the auxiliary info sizes as is */
 +    data_size = atom.size - atom_header_size;
 +
 +    sc->cenc.auxiliary_info_sizes = av_malloc(data_size);
 +    if (!sc->cenc.auxiliary_info_sizes) {
 +        return AVERROR(ENOMEM);
 +    }
 +
 +    sc->cenc.auxiliary_info_sizes_count = data_size;
 +
 +    if (avio_read(pb, sc->cenc.auxiliary_info_sizes, data_size) != data_size) {
 +        av_log(c->fc, AV_LOG_ERROR, "failed to read the auxiliary info sizes");
 +        return AVERROR_INVALIDDATA;
 +    }
 +
 +    return 0;
 +}
 +
 +static int mov_read_dfla(MOVContext *c, AVIOContext *pb, MOVAtom atom)
 +{
 +    AVStream *st;
 +    int last, type, size, ret;
 +    uint8_t buf[4];
 +
 +    if (c->fc->nb_streams < 1)
 +        return 0;
 +    st = c->fc->streams[c->fc->nb_streams-1];
 +
 +    if ((uint64_t)atom.size > (1<<30) || atom.size < 42)
 +        return AVERROR_INVALIDDATA;
 +
 +    /* Check FlacSpecificBox version. */
 +    if (avio_r8(pb) != 0)
 +        return AVERROR_INVALIDDATA;
 +
 +    avio_rb24(pb); /* Flags */
 +
 +    avio_read(pb, buf, sizeof(buf));
 +    flac_parse_block_header(buf, &last, &type, &size);
 +
 +    if (type != FLAC_METADATA_TYPE_STREAMINFO || size != FLAC_STREAMINFO_SIZE) {
 +        av_log(c->fc, AV_LOG_ERROR, "STREAMINFO must be first FLACMetadataBlock\n");
 +        return AVERROR_INVALIDDATA;
 +    }
 +
 +    ret = ff_get_extradata(c->fc, st->codecpar, pb, size);
 +    if (ret < 0)
 +        return ret;
 +
 +    if (!last)
 +        av_log(c->fc, AV_LOG_WARNING, "non-STREAMINFO FLACMetadataBlock(s) ignored\n");
 +
 +    return 0;
 +}
 +
 +static int mov_seek_auxiliary_info(MOVContext *c, MOVStreamContext *sc, int64_t index)
 +{
 +    size_t auxiliary_info_seek_offset = 0;
 +    int i;
 +
 +    if (sc->cenc.auxiliary_info_default_size) {
 +        auxiliary_info_seek_offset = (size_t)sc->cenc.auxiliary_info_default_size * index;
 +    } else if (sc->cenc.auxiliary_info_sizes) {
 +        if (index > sc->cenc.auxiliary_info_sizes_count) {
 +            av_log(c, AV_LOG_ERROR, "current sample %"PRId64" greater than the number of auxiliary info sample sizes %"SIZE_SPECIFIER"\n",
 +                index, sc->cenc.auxiliary_info_sizes_count);
 +            return AVERROR_INVALIDDATA;
 +        }
 +
 +        for (i = 0; i < index; i++) {
 +            auxiliary_info_seek_offset += sc->cenc.auxiliary_info_sizes[i];
 +        }
 +    }
 +
 +    if (auxiliary_info_seek_offset > sc->cenc.auxiliary_info_end - sc->cenc.auxiliary_info) {
 +        av_log(c, AV_LOG_ERROR, "auxiliary info offset %"SIZE_SPECIFIER" greater than auxiliary info size %"SIZE_SPECIFIER"\n",
 +            auxiliary_info_seek_offset, (size_t)(sc->cenc.auxiliary_info_end - sc->cenc.auxiliary_info));
 +        return AVERROR_INVALIDDATA;
 +    }
 +
 +    sc->cenc.auxiliary_info_pos = sc->cenc.auxiliary_info + auxiliary_info_seek_offset;
 +    sc->cenc.auxiliary_info_index = index;
 +    return 0;
 +}
 +
 +static int cenc_filter(MOVContext *c, MOVStreamContext *sc, int64_t index, uint8_t *input, int size)
 +{
 +    uint32_t encrypted_bytes;
 +    uint16_t subsample_count;
 +    uint16_t clear_bytes;
 +    uint8_t* input_end = input + size;
 +    int ret;
 +
 +    if (index != sc->cenc.auxiliary_info_index) {
 +        ret = mov_seek_auxiliary_info(c, sc, index);
 +        if (ret < 0) {
 +            return ret;
 +        }
 +    }
 +
 +    /* read the iv */
 +    if (AES_CTR_IV_SIZE > sc->cenc.auxiliary_info_end - sc->cenc.auxiliary_info_pos) {
 +        av_log(c->fc, AV_LOG_ERROR, "failed to read iv from the auxiliary info\n");
 +        return AVERROR_INVALIDDATA;
 +    }
 +
 +    av_aes_ctr_set_iv(sc->cenc.aes_ctr, sc->cenc.auxiliary_info_pos);
 +    sc->cenc.auxiliary_info_pos += AES_CTR_IV_SIZE;
 +
 +    if (!sc->cenc.use_subsamples)
 +    {
 +        /* decrypt the whole packet */
 +        av_aes_ctr_crypt(sc->cenc.aes_ctr, input, input, size);
 +        return 0;
 +    }
 +
 +    /* read the subsample count */
 +    if (sizeof(uint16_t) > sc->cenc.auxiliary_info_end - sc->cenc.auxiliary_info_pos) {
 +        av_log(c->fc, AV_LOG_ERROR, "failed to read subsample count from the auxiliary info\n");
 +        return AVERROR_INVALIDDATA;
 +    }
 +
 +    subsample_count = AV_RB16(sc->cenc.auxiliary_info_pos);
 +    sc->cenc.auxiliary_info_pos += sizeof(uint16_t);
 +
 +    for (; subsample_count > 0; subsample_count--)
 +    {
 +        if (6 > sc->cenc.auxiliary_info_end - sc->cenc.auxiliary_info_pos) {
 +            av_log(c->fc, AV_LOG_ERROR, "failed to read subsample from the auxiliary info\n");
 +            return AVERROR_INVALIDDATA;
 +        }
 +
 +        /* read the number of clear / encrypted bytes */
 +        clear_bytes = AV_RB16(sc->cenc.auxiliary_info_pos);
 +        sc->cenc.auxiliary_info_pos += sizeof(uint16_t);
 +        encrypted_bytes = AV_RB32(sc->cenc.auxiliary_info_pos);
 +        sc->cenc.auxiliary_info_pos += sizeof(uint32_t);
 +
 +        if ((uint64_t)clear_bytes + encrypted_bytes > input_end - input) {
 +            av_log(c->fc, AV_LOG_ERROR, "subsample size exceeds the packet size left\n");
 +            return AVERROR_INVALIDDATA;
 +        }
 +
 +        /* skip the clear bytes */
 +        input += clear_bytes;
 +
 +        /* decrypt the encrypted bytes */
 +        av_aes_ctr_crypt(sc->cenc.aes_ctr, input, input, encrypted_bytes);
 +        input += encrypted_bytes;
 +    }
 +
 +    if (input < input_end) {
 +        av_log(c->fc, AV_LOG_ERROR, "leftover packet bytes after subsample processing\n");
 +        return AVERROR_INVALIDDATA;
 +    }
 +
 +    sc->cenc.auxiliary_info_index++;
      return 0;
  }
  
diff --cc libavformat/rtpdec_jpeg.c
index 397b5cf,2cf4113..05dd172
--- a/libavformat/rtpdec_jpeg.c
+++ b/libavformat/rtpdec_jpeg.c
@@@ -236,18 -229,8 +236,18 @@@ static int jpeg_parse_packet(AVFormatCo
      buf += 8;
      len -= 8;
  
 +    if (type & 0x40) {
 +        if (len < 4) {
 +            av_log(ctx, AV_LOG_ERROR, "Too short RTP/JPEG packet.\n");
 +            return AVERROR_INVALIDDATA;
 +        }
 +        dri = AV_RB16(buf);
 +        buf += 4;
 +        len -= 4;
 +        type &= ~0x40;
 +    }
      if (type > 1) {
-         av_log(ctx, AV_LOG_ERROR, "Unimplemented RTP/JPEG type %d\n", type);
+         av_log(ctx, AV_LOG_ERROR, "Unimplemented RTP/JPEG type %"PRIu8"\n", type);
          return AVERROR_PATCHWELCOME;
      }
  
diff --cc libavformat/rtpdec_xiph.c
index 26aef54,7821686..e1b7990
--- a/libavformat/rtpdec_xiph.c
+++ b/libavformat/rtpdec_xiph.c
@@@ -255,7 -255,7 +255,7 @@@ parse_packed_headers(AVFormatContext *s
      if (packed_headers_end - packed_headers != length ||
          length1 > length || length2 > length - length1) {
          av_log(s, AV_LOG_ERROR,
-                "Bad packed header lengths (%d,%d,%"PTRDIFF_SPECIFIER",%d)\n", length1,
 -               "Bad packed header lengths (%u,%u,%td,%u)\n", length1,
++               "Bad packed header lengths (%d,%d,%"PTRDIFF_SPECIFIER",%u)\n", length1,
                 length2, packed_headers_end - packed_headers, length);
          return AVERROR_INVALIDDATA;
      }
diff --cc libswscale/tests/swscale.c
index da6a41b,853a8a7..bd8d098
--- a/libswscale/tests/swscale.c
+++ b/libswscale/tests/swscale.c
@@@ -318,7 -305,7 +318,7 @@@ static int fileTest(uint8_t *ref[4], in
  
          ret = sscanf(buf,
                       " %12s %dx%d -> %12s %dx%d flags=%d CRC=%x"
-                      " SSD=%"SCNd64 ", %"SCNd64 ", %"SCNd64 ", %"SCNd64 "\n",
 -                     " SSD=%"PRIu64 ", %"PRIu64 ", %"PRIu64 ", %"PRIu64 "\n",
++                     " SSD=%"SCNu64 ", %"SCNu64 ", %"SCNu64 ", %"SCNu64 "\n",
                       srcStr, &srcW, &srcH, dstStr, &dstW, &dstH,
                       &flags, &r.crc, &r.ssdY, &r.ssdU, &r.ssdV, &r.ssdA);
          if (ret != 12) {




More information about the ffmpeg-cvslog mailing list