aboutsummaryrefslogtreecommitdiffstats
path: root/libavformat/rawenc.c
diff options
context:
space:
mode:
authorMichael Niedermayer <michaelni@gmx.at>2015-06-21 00:32:09 +0200
committerMichael Niedermayer <michaelni@gmx.at>2015-06-21 12:16:24 +0200
commit6c8a05268cfe2235e37a28a5cc5b20f6c16b90ad (patch)
treec0dc44e4f59e87c61ef91225d083a4f4f5ae8fd2 /libavformat/rawenc.c
parent95ee0fbacfad9e79ed0f67e1e1980a53a4d2807e (diff)
downloadffmpeg-6c8a05268cfe2235e37a28a5cc5b20f6c16b90ad.tar.gz
avformat/rawenc: Store sample number for ADX
Fixes Ticket4540 Reviewed-by: Paul B Mahol <onemda@gmail.com> Signed-off-by: Michael Niedermayer <michaelni@gmx.at>
Diffstat (limited to 'libavformat/rawenc.c')
-rw-r--r--libavformat/rawenc.c20
1 files changed, 20 insertions, 0 deletions
diff --git a/libavformat/rawenc.c b/libavformat/rawenc.c
index e59f1ae95e..d65c7c7909 100644
--- a/libavformat/rawenc.c
+++ b/libavformat/rawenc.c
@@ -56,6 +56,25 @@ AVOutputFormat ff_ac3_muxer = {
#endif
#if CONFIG_ADX_MUXER
+
+static int adx_write_trailer(AVFormatContext *s)
+{
+ AVIOContext *pb = s->pb;
+ AVCodecContext *avctx = s->streams[0]->codec;
+
+ if (pb->seekable) {
+ int64_t file_size = avio_tell(pb);
+ uint64_t sample_count = (file_size - 36) / avctx->channels / 18 * 32;
+ if (sample_count <= UINT32_MAX) {
+ avio_seek(pb, 12, SEEK_SET);
+ avio_wb32(pb, sample_count);
+ avio_seek(pb, file_size, SEEK_SET);
+ }
+ }
+
+ return 0;
+}
+
AVOutputFormat ff_adx_muxer = {
.name = "adx",
.long_name = NULL_IF_CONFIG_SMALL("CRI ADX"),
@@ -64,6 +83,7 @@ AVOutputFormat ff_adx_muxer = {
.video_codec = AV_CODEC_ID_NONE,
.write_header = force_one_stream,
.write_packet = ff_raw_write_packet,
+ .write_trailer = adx_write_trailer,
.flags = AVFMT_NOTIMESTAMPS,
};
#endif