summaryrefslogtreecommitdiffstats
path: root/libavformat/matroskaenc.c
diff options
context:
space:
mode:
authorAndreas Rheinhardt <andreas.rheinhardt@gmail.com>2019-04-20 01:41:01 +0200
committerJames Almer <jamrial@gmail.com>2019-05-08 13:02:29 -0300
commit30d07c74dbd9384e50535cfedde5237114a81bee (patch)
treee7ee9b0694257ceb909477006ffea13ab4a049ba /libavformat/matroskaenc.c
parent01506e6b663948c9e3666c6d35f7830f397ab78a (diff)
downloadffmpeg-streaming-30d07c74dbd9384e50535cfedde5237114a81bee.zip
ffmpeg-streaming-30d07c74dbd9384e50535cfedde5237114a81bee.tar.gz
avformat/matroskaenc: Simplify check for writing CRCs
Up until now, the check for whether to write CRC32 elements was always mkv->write_crc && mkv->mode != MODE_WEBM. This is equivalent to simply set write_crc to zero in WebM-mode. And this is what this commit does. Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@gmail.com> Signed-off-by: James Almer <jamrial@gmail.com>
Diffstat (limited to 'libavformat/matroskaenc.c')
-rw-r--r--libavformat/matroskaenc.c11
1 files changed, 6 insertions, 5 deletions
diff --git a/libavformat/matroskaenc.c b/libavformat/matroskaenc.c
index 7586365..e623469 100644
--- a/libavformat/matroskaenc.c
+++ b/libavformat/matroskaenc.c
@@ -341,7 +341,7 @@ static int start_ebml_master_crc32(AVIOContext *pb, AVIOContext **dyn_cp, Matros
if (pb->seekable & AVIO_SEEKABLE_NORMAL) {
*master = start_ebml_master(pb, elementid, expectedsize);
- if (mkv->write_crc && mkv->mode != MODE_WEBM)
+ if (mkv->write_crc)
put_ebml_void(*dyn_cp, 6); /* Reserve space for CRC32 so position/size calculations using avio_tell() take it into account */
} else
*master = start_ebml_master(*dyn_cp, elementid, expectedsize);
@@ -357,7 +357,7 @@ static void end_ebml_master_crc32(AVIOContext *pb, AVIOContext **dyn_cp, Matrosk
if (pb->seekable & AVIO_SEEKABLE_NORMAL) {
size = avio_close_dyn_buf(*dyn_cp, &buf);
- if (mkv->write_crc && mkv->mode != MODE_WEBM) {
+ if (mkv->write_crc) {
skip = 6; /* Skip reserved 6-byte long void element from the dynamic buffer. */
AV_WL32(crc, av_crc(av_crc_get_table(AV_CRC_32_IEEE_LE), UINT32_MAX, buf + skip, size - skip) ^ UINT32_MAX);
put_ebml_binary(pb, EBML_ID_CRC32, crc, sizeof(crc));
@@ -1867,9 +1867,10 @@ static int mkv_write_header(AVFormatContext *s)
int ret, i, version = 2;
int64_t creation_time;
- if (!strcmp(s->oformat->name, "webm"))
- mkv->mode = MODE_WEBM;
- else
+ if (!strcmp(s->oformat->name, "webm")) {
+ mkv->mode = MODE_WEBM;
+ mkv->write_crc = 0;
+ } else
mkv->mode = MODE_MATROSKAv2;
if (mkv->mode != MODE_WEBM ||
OpenPOWER on IntegriCloud