[FFmpeg-cvslog] avformat/matroskaenc: write a CRC32 element on Cues

James Almer git at videolan.org
Thu Oct 6 23:32:31 EEST 2016


ffmpeg | branch: master | James Almer <jamrial at gmail.com> | Mon Oct  3 19:15:24 2016 -0300| [79248795d4af6ef4782c528e872dfcc9bbd46d68] | committer: James Almer

avformat/matroskaenc: write a CRC32 element on Cues

Implements part of ticket #4347

Tested-by: Dave Rice <dave at dericed.com>
Tested-by: Jerome Martinez <jerome at mediaarea.net>
Reviewed-by: Michael Niedermayer <michael at niedermayer.cc>
Signed-off-by: James Almer <jamrial at gmail.com>

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

 libavformat/matroskaenc.c | 29 ++++++++++++++++-------------
 tests/ref/fate/rgb24-mkv  |  4 ++--
 tests/ref/lavf/mkv        |  8 ++++----
 3 files changed, 22 insertions(+), 19 deletions(-)

diff --git a/libavformat/matroskaenc.c b/libavformat/matroskaenc.c
index 4766531..5009ebc 100644
--- a/libavformat/matroskaenc.c
+++ b/libavformat/matroskaenc.c
@@ -514,13 +514,16 @@ static int mkv_add_cuepoint(mkv_cues *cues, int stream, int tracknum, int64_t ts
 
 static int64_t mkv_write_cues(AVFormatContext *s, mkv_cues *cues, mkv_track *tracks, int num_tracks)
 {
-    AVIOContext *pb = s->pb;
+    MatroskaMuxContext *mkv = s->priv_data;
+    AVIOContext *dyn_cp, *pb = s->pb;
     ebml_master cues_element;
     int64_t currentpos;
-    int i, j;
+    int i, j, ret;
 
     currentpos = avio_tell(pb);
-    cues_element = start_ebml_master(pb, MATROSKA_ID_CUES, 0);
+    ret = start_ebml_master_crc32(pb, &dyn_cp, &cues_element, MATROSKA_ID_CUES, 0);
+    if (ret < 0)
+        return ret;
 
     for (i = 0; i < cues->num_entries; i++) {
         ebml_master cuepoint, track_positions;
@@ -540,8 +543,8 @@ static int64_t mkv_write_cues(AVFormatContext *s, mkv_cues *cues, mkv_track *tra
             ctp_nb ++;
         }
 
-        cuepoint = start_ebml_master(pb, MATROSKA_ID_POINTENTRY, MAX_CUEPOINT_SIZE(ctp_nb));
-        put_ebml_uint(pb, MATROSKA_ID_CUETIME, pts);
+        cuepoint = start_ebml_master(dyn_cp, MATROSKA_ID_POINTENTRY, MAX_CUEPOINT_SIZE(ctp_nb));
+        put_ebml_uint(dyn_cp, MATROSKA_ID_CUETIME, pts);
 
         // put all the entries from different tracks that have the exact same
         // timestamp into the same CuePoint
@@ -553,18 +556,18 @@ static int64_t mkv_write_cues(AVFormatContext *s, mkv_cues *cues, mkv_track *tra
             if (tracks[tracknum].has_cue && s->streams[tracknum]->codecpar->codec_type != AVMEDIA_TYPE_SUBTITLE)
                 continue;
             tracks[tracknum].has_cue = 1;
-            track_positions = start_ebml_master(pb, MATROSKA_ID_CUETRACKPOSITION, MAX_CUETRACKPOS_SIZE);
-            put_ebml_uint(pb, MATROSKA_ID_CUETRACK           , entry[j].tracknum   );
-            put_ebml_uint(pb, MATROSKA_ID_CUECLUSTERPOSITION , entry[j].cluster_pos);
-            put_ebml_uint(pb, MATROSKA_ID_CUERELATIVEPOSITION, entry[j].relative_pos);
+            track_positions = start_ebml_master(dyn_cp, MATROSKA_ID_CUETRACKPOSITION, MAX_CUETRACKPOS_SIZE);
+            put_ebml_uint(dyn_cp, MATROSKA_ID_CUETRACK           , entry[j].tracknum   );
+            put_ebml_uint(dyn_cp, MATROSKA_ID_CUECLUSTERPOSITION , entry[j].cluster_pos);
+            put_ebml_uint(dyn_cp, MATROSKA_ID_CUERELATIVEPOSITION, entry[j].relative_pos);
             if (entry[j].duration != -1)
-                put_ebml_uint(pb, MATROSKA_ID_CUEDURATION    , entry[j].duration);
-            end_ebml_master(pb, track_positions);
+                put_ebml_uint(dyn_cp, MATROSKA_ID_CUEDURATION    , entry[j].duration);
+            end_ebml_master(dyn_cp, track_positions);
         }
         i += j - 1;
-        end_ebml_master(pb, cuepoint);
+        end_ebml_master(dyn_cp, cuepoint);
     }
-    end_ebml_master(pb, cues_element);
+    end_ebml_master_crc32(pb, &dyn_cp, mkv, cues_element);
 
     return currentpos;
 }
diff --git a/tests/ref/fate/rgb24-mkv b/tests/ref/fate/rgb24-mkv
index ab11a33..193deda 100644
--- a/tests/ref/fate/rgb24-mkv
+++ b/tests/ref/fate/rgb24-mkv
@@ -1,5 +1,5 @@
-0c30c5b33b33c7cf49c4b76e799317e0 *tests/data/fate/rgb24-mkv.matroska
-58333 tests/data/fate/rgb24-mkv.matroska
+cb5ac9272f6df8a9e4a442ff38ef2793 *tests/data/fate/rgb24-mkv.matroska
+58339 tests/data/fate/rgb24-mkv.matroska
 #tb 0: 1/10
 #media_type 0: video
 #codec_id 0: rawvideo
diff --git a/tests/ref/lavf/mkv b/tests/ref/lavf/mkv
index 2ae2134..4488737 100644
--- a/tests/ref/lavf/mkv
+++ b/tests/ref/lavf/mkv
@@ -1,6 +1,6 @@
-b637cf946d049b62ffad79b4d4699ea5 *./tests/data/lavf/lavf.mkv
-472899 ./tests/data/lavf/lavf.mkv
+645d74deeb73d692c0dfb840b56d6a74 *./tests/data/lavf/lavf.mkv
+472905 ./tests/data/lavf/lavf.mkv
 ./tests/data/lavf/lavf.mkv CRC=0xec6c3c68
-76894898a210a0c060f6b988e6c34bc8 *./tests/data/lavf/lavf.mkv
-320575 ./tests/data/lavf/lavf.mkv
+657a2ffa837a99691e36f668a06f2ff3 *./tests/data/lavf/lavf.mkv
+320581 ./tests/data/lavf/lavf.mkv
 ./tests/data/lavf/lavf.mkv CRC=0xec6c3c68



More information about the ffmpeg-cvslog mailing list