]> git.sesse.net Git - ffmpeg/blobdiff - libavformat/mov.c
Dirac decoding/encoding support via libdirac.
[ffmpeg] / libavformat / mov.c
index 64bb8900765d78465d24ae881caf3d3465906293..611d547734f00e11915c38e4d9656939af224d88 100644 (file)
@@ -669,12 +669,7 @@ static int mov_read_stsd(MOVContext *c, ByteIOContext *pb, MOV_atom_t atom)
 {
     AVStream *st = c->fc->streams[c->fc->nb_streams-1];
     MOVStreamContext *sc = st->priv_data;
-    int entries, frames_per_sample;
-    uint32_t format;
-    uint8_t codec_name[32];
-    unsigned int color_depth;
-    int color_greyscale;
-    int j, pseudo_stream_id;
+    int j, entries, pseudo_stream_id;
 
     get_byte(pb); /* version */
     get_be24(pb); /* flags */
@@ -688,7 +683,7 @@ static int mov_read_stsd(MOVContext *c, ByteIOContext *pb, MOV_atom_t atom)
         MOV_atom_t a = { 0, 0, 0 };
         offset_t start_pos = url_ftell(pb);
         int size = get_be32(pb); /* size */
-        format = get_le32(pb); /* data format */
+        uint32_t format = get_le32(pb); /* data format */
 
         get_be32(pb); /* reserved */
         get_be16(pb); /* reserved */
@@ -733,6 +728,10 @@ static int mov_read_stsd(MOVContext *c, ByteIOContext *pb, MOV_atom_t atom)
                 (format >> 24) & 0xff, st->codec->codec_type);
 
         if(st->codec->codec_type==CODEC_TYPE_VIDEO) {
+            uint8_t codec_name[32];
+            unsigned int color_depth;
+            int color_greyscale;
+
             st->codec->codec_id = id;
             get_be16(pb); /* version */
             get_be16(pb); /* revision level */
@@ -746,11 +745,9 @@ static int mov_read_stsd(MOVContext *c, ByteIOContext *pb, MOV_atom_t atom)
             get_be32(pb); /* horiz resolution */
             get_be32(pb); /* vert resolution */
             get_be32(pb); /* data size, always 0 */
-            frames_per_sample = get_be16(pb); /* frames per samples */
-
-            dprintf(c->fc, "frames/samples = %d\n", frames_per_sample);
+            get_be16(pb); /* frames per samples */
 
-            get_buffer(pb, codec_name, 32); /* codec name, pascal string (FIXME: true for mp4?) */
+            get_buffer(pb, codec_name, 32); /* codec name, pascal string */
             if (codec_name[0] <= 31) {
                 memcpy(st->codec->codec_name, &codec_name[1],codec_name[0]);
                 st->codec->codec_name[codec_name[0]] = 0;
@@ -1815,6 +1812,10 @@ static int mov_read_packet(AVFormatContext *s, AVPacket *pkt)
             sc->sample_to_ctime_sample = 0;
         }
     } else {
+        AVStream *st = s->streams[sc->ffindex];
+        int64_t next_dts = (sc->current_sample < sc->sample_count) ?
+            st->index_entries[sc->current_sample].timestamp : st->duration;
+        pkt->duration = next_dts - pkt->dts;
         pkt->pts = pkt->dts;
     }
     pkt->flags |= sample->flags & AVINDEX_KEYFRAME ? PKT_FLAG_KEY : 0;