[FFmpeg-cvslog] avformat/avienc: factor out update_odml_entry()

Michael Niedermayer git at videolan.org
Thu Mar 19 17:20:54 CET 2015


ffmpeg | branch: master | Michael Niedermayer <michaelni at gmx.at> | Thu Mar 19 03:28:08 2015 +0100| [01775c8858c171787bc475471ba2cd6e6264b00c] | committer: Michael Niedermayer

avformat/avienc: factor out update_odml_entry()

Signed-off-by: Michael Niedermayer <michaelni at gmx.at>

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

 libavformat/avienc.c |   59 ++++++++++++++++++++++++++++++--------------------
 1 file changed, 35 insertions(+), 24 deletions(-)

diff --git a/libavformat/avienc.c b/libavformat/avienc.c
index 9dd13ff..5f1908d 100644
--- a/libavformat/avienc.c
+++ b/libavformat/avienc.c
@@ -469,6 +469,39 @@ static int avi_write_header(AVFormatContext *s)
     return 0;
 }
 
+static void update_odml_entry(AVFormatContext *s, int stream_index, int64_t ix)
+{
+    AVIOContext *pb = s->pb;
+    AVIContext *avi = s->priv_data;
+    AVIStream *avist = s->streams[stream_index]->priv_data;
+    int64_t pos;
+    int au_byterate, au_ssize, au_scale;
+
+    avio_flush(pb);
+    pos = avio_tell(pb);
+
+    /* Updating one entry in the AVI OpenDML master index */
+    avio_seek(pb, avist->indexes.indx_start - 8, SEEK_SET);
+    ffio_wfourcc(pb, "indx");             /* enabling this entry */
+    avio_skip(pb, 8);
+    avio_wl32(pb, avi->riff_id);          /* nEntriesInUse */
+    avio_skip(pb, 16 * avi->riff_id);
+    avio_wl64(pb, ix);                    /* qwOffset */
+    avio_wl32(pb, pos - ix);              /* dwSize */
+    ff_parse_specific_params(s->streams[stream_index], &au_byterate, &au_ssize, &au_scale);
+    if (s->streams[stream_index]->codec->codec_type == AVMEDIA_TYPE_AUDIO && au_ssize > 0) {
+        uint32_t audio_segm_size = (avist->audio_strm_length - avist->indexes.audio_strm_offset);
+        if ((audio_segm_size % au_ssize > 0) && !avist->sample_requested) {
+            avpriv_request_sample(s, "OpenDML index duration for audio packets with partial frames");
+            avist->sample_requested = 1;
+        }
+        avio_wl32(pb, audio_segm_size / au_ssize);  /* dwDuration (sample count) */
+    } else
+        avio_wl32(pb, avist->indexes.entry);  /* dwDuration (packet count) */
+
+    avio_seek(pb, pos, SEEK_SET);
+}
+
 static int avi_write_ix(AVFormatContext *s)
 {
     AVIOContext *pb = s->pb;
@@ -487,8 +520,7 @@ static int avi_write_ix(AVFormatContext *s)
 
     for (i = 0; i < s->nb_streams; i++) {
         AVIStream *avist = s->streams[i]->priv_data;
-        int64_t ix, pos;
-        int au_byterate, au_ssize, au_scale;
+        int64_t ix;
 
         avi_stream2fourcc(tag, i, s->streams[i]->codec->codec_type);
         ix_tag[3] = '0' + i;
@@ -513,29 +545,8 @@ static int avi_write_ix(AVFormatContext *s)
             avio_wl32(pb, ((uint32_t) ie->len & ~0x80000000) |
                           (ie->flags & 0x10 ? 0 : 0x80000000));
         }
-        avio_flush(pb);
-        pos = avio_tell(pb);
-
-        /* Updating one entry in the AVI OpenDML master index */
-        avio_seek(pb, avist->indexes.indx_start - 8, SEEK_SET);
-        ffio_wfourcc(pb, "indx");             /* enabling this entry */
-        avio_skip(pb, 8);
-        avio_wl32(pb, avi->riff_id);          /* nEntriesInUse */
-        avio_skip(pb, 16 * avi->riff_id);
-        avio_wl64(pb, ix);                    /* qwOffset */
-        avio_wl32(pb, pos - ix);              /* dwSize */
-        ff_parse_specific_params(s->streams[i], &au_byterate, &au_ssize, &au_scale);
-        if (s->streams[i]->codec->codec_type == AVMEDIA_TYPE_AUDIO && au_ssize > 0) {
-            uint32_t audio_segm_size = (avist->audio_strm_length - avist->indexes.audio_strm_offset);
-            if ((audio_segm_size % au_ssize > 0) && !avist->sample_requested) {
-                avpriv_request_sample(s, "OpenDML index duration for audio packets with partial frames");
-                avist->sample_requested = 1;
-            }
-            avio_wl32(pb, audio_segm_size / au_ssize);  /* dwDuration (sample count) */
-        } else
-            avio_wl32(pb, avist->indexes.entry);  /* dwDuration (packet count) */
 
-        avio_seek(pb, pos, SEEK_SET);
+        update_odml_entry(s, i, ix);
     }
     return 0;
 }



More information about the ffmpeg-cvslog mailing list