]> git.sesse.net Git - ffmpeg/blobdiff - libavformat/avidec.c
AVPacket.pos
[ffmpeg] / libavformat / avidec.c
index 335a2ab4d3c56ebaa25644cc92fd104d2ec0315b..14fa2b5eff2c13d87a43daba7b74816d15e1bd7a 100644 (file)
@@ -125,7 +125,7 @@ static int avi_read_header(AVFormatContext *s, AVFormatParameters *ap)
             if (tag1 == MKTAG('m', 'o', 'v', 'i')) {
                 avi->movi_list = url_ftell(pb) - 4;
                 if(size) avi->movi_end = avi->movi_list + size;
-                else     avi->movi_end = url_filesize(url_fileno(pb));
+                else     avi->movi_end = url_fsize(pb);
 #ifdef DEBUG
                 printf("movi end=%Lx\n", avi->movi_end);
 #endif
@@ -221,7 +221,7 @@ static int avi_read_header(AVFormatContext *s, AVFormatParameters *ap)
             nb_frames = get_le32(pb);
 
             st->start_time = 0;
-            st->duration = av_rescale(nb_frames, ast->scale*(int64_t)AV_TIME_BASE, ast->rate);
+            st->duration = nb_frames;
             get_le32(pb); /* buffer size */
             get_le32(pb); /* quality */
             ast->sample_size = get_le32(pb); /* sample ssize */
@@ -232,8 +232,6 @@ static int avi_read_header(AVFormatContext *s, AVFormatParameters *ap)
                 codec_type = CODEC_TYPE_VIDEO;
 
                 ast->sample_size = 0;
-                st->codec.frame_rate = ast->rate;
-                st->codec.frame_rate_base = ast->scale;
                 break;
             case MKTAG('a', 'u', 'd', 's'):
                 codec_type = CODEC_TYPE_AUDIO;
@@ -425,8 +423,7 @@ resync:
 
         if(size > ast->remaining)
             size= ast->remaining;
-        av_new_packet(pkt, size);
-        get_buffer(pb, pkt->data, size);
+        av_get_packet(pb, pkt, size);
         
         if (avi->dv_demux) {
             dstr = pkt->destruct;
@@ -451,7 +448,7 @@ resync:
                     index= av_index_search_timestamp(st, pkt->dts, 0);
                     e= &st->index_entries[index];
                     
-                    if(e->timestamp == ast->frame_offset){
+                    if(index >= 0 && e->timestamp == ast->frame_offset){
                         if (e->flags & AVINDEX_KEYFRAME)
                             pkt->flags |= PKT_FLAG_KEY;
                     }
@@ -488,7 +485,7 @@ resync:
        if (i >= avi->movi_end) {
            if (avi->is_odml) {
                url_fskip(pb, avi->riff_end - i);
-               avi->riff_end = avi->movi_end = url_filesize(url_fileno(pb));
+               avi->riff_end = avi->movi_end = url_fsize(pb);
            } else
                break;
        }
@@ -532,7 +529,11 @@ resync:
           st = s->streams[n];
           ast = st->priv_data;
           
-          if(st->discard){
+          if(   (st->discard >= AVDISCARD_DEFAULT && size==0)
+             /*|| (st->discard >= AVDISCARD_NONKEY && !(pkt->flags & PKT_FLAG_KEY))*/ //FIXME needs a little reordering
+             || st->discard >= AVDISCARD_ALL){
+                if(ast->sample_size) ast->frame_offset += pkt->size;
+                else                 ast->frame_offset++;
                 url_fskip(pb, size);
                 goto resync;
           }
@@ -554,7 +555,6 @@ resync:
             ast->packet_size= size + 8;
             ast->remaining= size;
             goto resync;
-
           }
         }
         /* palette changed chunk */