diff options
author | Andreas Rheinhardt <andreas.rheinhardt@gmail.com> | 2019-04-20 01:41:06 +0200 |
---|---|---|
committer | James Almer <jamrial@gmail.com> | 2019-05-08 13:02:30 -0300 |
commit | add68dcca958f0f6b42cabea6f546ceae5c7f16d (patch) | |
tree | 3d352d5f7540ad5f8d5fe487704243ff3bdfc44d /libavformat | |
parent | e04a24e70148e330bcdcfd7c049acbe1a821398f (diff) | |
download | ffmpeg-add68dcca958f0f6b42cabea6f546ceae5c7f16d.tar.gz |
avformat/matroskaenc: Write CRC-32 in non-seekable mode
Given that in both the seekable as well as the non-seekable mode dynamic
buffers are used to write level 1 elements and that now no seeks are
used in the seekable case any more, the two modes can be combined; as a
consequence, the non-seekable mode automatically inherits the ability to
write CRC-32 elements.
There are no differences in case the output is seekable; when it is not
and writing CRC-32 elements is disabled, there can still be minor
differences because before this commit, the EBML ID and length field
were counted towards the cluster size limit; now they no longer are.
Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@gmail.com>
Signed-off-by: James Almer <jamrial@gmail.com>
Diffstat (limited to 'libavformat')
-rw-r--r-- | libavformat/matroskaenc.c | 14 |
1 files changed, 2 insertions, 12 deletions
diff --git a/libavformat/matroskaenc.c b/libavformat/matroskaenc.c index 2875552469..d9a7ca9ad1 100644 --- a/libavformat/matroskaenc.c +++ b/libavformat/matroskaenc.c @@ -336,20 +336,15 @@ static void end_ebml_master(AVIOContext *pb, ebml_master master) static int start_ebml_master_crc32(AVIOContext *pb, AVIOContext **dyn_cp, MatroskaMuxContext *mkv, ebml_master *master, uint32_t elementid, uint64_t expectedsize) { - int ret; + int ret, bytes = expectedsize ? ebml_num_size(expectedsize) : 8; if ((ret = avio_open_dyn_buf(dyn_cp)) < 0) return ret; - if (pb->seekable & AVIO_SEEKABLE_NORMAL) { - int bytes = expectedsize ? ebml_num_size(expectedsize) : 8; - put_ebml_id(pb, elementid); *master = (ebml_master) { avio_tell(pb), bytes }; 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); return 0; } @@ -360,7 +355,6 @@ static void end_ebml_master_crc32(AVIOContext *pb, AVIOContext **dyn_cp, Matrosk uint8_t *buf, crc[4]; int size, skip = 0; - if (pb->seekable & AVIO_SEEKABLE_NORMAL) { size = avio_close_dyn_buf(*dyn_cp, &buf); put_ebml_num(pb, size, master.sizebytes); if (mkv->write_crc) { @@ -369,11 +363,7 @@ static void end_ebml_master_crc32(AVIOContext *pb, AVIOContext **dyn_cp, Matrosk put_ebml_binary(pb, EBML_ID_CRC32, crc, sizeof(crc)); } avio_write(pb, buf + skip, size - skip); - } else { - end_ebml_master(*dyn_cp, master); - size = avio_close_dyn_buf(*dyn_cp, &buf); - avio_write(pb, buf, size); - } + av_free(buf); *dyn_cp = NULL; } |