[Ffmpeg-cvslog] r6063 - trunk/libavformat/avienc.c

gpoirier subversion
Thu Aug 24 10:22:26 CEST 2006


Author: gpoirier
Date: Thu Aug 24 10:22:26 2006
New Revision: 6063

Modified:
   trunk/libavformat/avienc.c

Log:
fix ODML AVI Duration for files > 2GB
Patch by Brian Brice % bbrice A newtek P com %
Original thread:
Date: Aug 22, 2006 10:21 PM
Subject: [Ffmpeg-devel] [PATCH] ODML AVI Duration


Modified: trunk/libavformat/avienc.c
==============================================================================
--- trunk/libavformat/avienc.c	(original)
+++ trunk/libavformat/avienc.c	Thu Aug 24 10:22:26 2006
@@ -102,6 +102,38 @@
     }
 }
 
+static int avi_write_counters(AVFormatContext* s, int riff_id)
+{
+    ByteIOContext *pb = &s->pb;
+    AVIContext *avi = s->priv_data;
+    int n, au_byterate, au_ssize, au_scale, nb_frames = 0;
+    offset_t file_size;
+    AVCodecContext* stream;
+
+    file_size = url_ftell(pb);
+    for(n = 0; n < s->nb_streams; n++) {
+        assert(avi->frames_hdr_strm[n]);
+        stream = s->streams[n]->codec;
+        url_fseek(pb, avi->frames_hdr_strm[n], SEEK_SET);
+        ff_parse_specific_params(stream, &au_byterate, &au_ssize, &au_scale);
+        if(au_ssize == 0) {
+            put_le32(pb, avi->packet_count[n]);
+        } else {
+            put_le32(pb, avi->audio_strm_length[n] / au_ssize);
+        }
+        if(stream->codec_type == CODEC_TYPE_VIDEO)
+            nb_frames = FFMAX(nb_frames, avi->packet_count[n]);
+    }
+    if(riff_id == 1) {
+        assert(avi->frames_hdr_all);
+        url_fseek(pb, avi->frames_hdr_all, SEEK_SET);
+        put_le32(pb, nb_frames);
+    }
+    url_fseek(pb, file_size, SEEK_SET);
+
+    return 0;
+}
+
 static int avi_write_header(AVFormatContext *s)
 {
     AVIContext *avi = s->priv_data;
@@ -358,9 +390,8 @@
 {
     ByteIOContext *pb = &s->pb;
     AVIContext *avi = s->priv_data;
-    offset_t file_size, idx_chunk;
-    int i, n, nb_frames, au_byterate, au_ssize, au_scale;
-    AVCodecContext *stream;
+    offset_t idx_chunk;
+    int i;
     unsigned char tag[5];
 
     if (!url_is_streamed(pb)) {
@@ -395,26 +426,7 @@
         } while (!empty);
         end_tag(pb, idx_chunk);
 
-        /* Fill in frame/sample counters */
-        file_size = url_ftell(pb);
-        nb_frames = 0;
-        for(n=0;n<s->nb_streams;n++) {
-            assert(avi->frames_hdr_strm[n]);
-                stream = s->streams[n]->codec;
-                url_fseek(pb, avi->frames_hdr_strm[n], SEEK_SET);
-                ff_parse_specific_params(stream, &au_byterate, &au_ssize, &au_scale);
-                if (au_ssize == 0) {
-                    put_le32(pb, avi->packet_count[n]);
-                } else {
-                    put_le32(pb, avi->audio_strm_length[n] / au_ssize);
-                }
-            if(stream->codec_type == CODEC_TYPE_VIDEO)
-                nb_frames = FFMAX(nb_frames, avi->packet_count[n]);
-       }
-        assert(avi->frames_hdr_all);
-        url_fseek(pb, avi->frames_hdr_all, SEEK_SET);
-        put_le32(pb, nb_frames);
-       url_fseek(pb, file_size, SEEK_SET);
+        avi_write_counters(s, avi->riff_id);
     }
     return 0;
 }
@@ -530,6 +542,8 @@
         }
         put_le32(pb, nb_frames);
         url_fseek(pb, file_size, SEEK_SET);
+
+        avi_write_counters(s, avi->riff_id);
     }
     }
     put_flush_packet(pb);




More information about the ffmpeg-cvslog mailing list