[FFmpeg-cvslog] vocenc: fix sample rate rounding direction

Michael Niedermayer git at videolan.org
Mon Jun 25 03:48:06 CEST 2012


ffmpeg | branch: master | Michael Niedermayer <michaelni at gmx.at> | Mon Jun 25 03:14:27 2012 +0200| [bacbbd2b03210f7e2faecb1b320a3e7e7a57b041] | committer: Michael Niedermayer

vocenc: fix sample rate rounding direction

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

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

 libavformat/vocenc.c    |    4 ++--
 tests/ref/lavf/voc      |    2 +-
 tests/ref/lavf/voc_s16  |    2 +-
 tests/ref/seek/lavf_voc |   24 ++++++++++++------------
 4 files changed, 16 insertions(+), 16 deletions(-)

diff --git a/libavformat/vocenc.c b/libavformat/vocenc.c
index beb72b8..1ea4dbc 100644
--- a/libavformat/vocenc.c
+++ b/libavformat/vocenc.c
@@ -64,13 +64,13 @@ static int voc_write_packet(AVFormatContext *s, AVPacket *pkt)
             if (s->streams[0]->codec->channels > 1) {
                 avio_w8(pb, VOC_TYPE_EXTENDED);
                 avio_wl24(pb, 4);
-                avio_wl16(pb, 65536-256000000/(enc->sample_rate*enc->channels));
+                avio_wl16(pb, 65536-(256000000 + enc->sample_rate*enc->channels/2)/(enc->sample_rate*enc->channels));
                 avio_w8(pb, enc->codec_tag);
                 avio_w8(pb, enc->channels - 1);
             }
             avio_w8(pb, VOC_TYPE_VOICE_DATA);
             avio_wl24(pb, pkt->size + 2);
-            avio_w8(pb, 256 - 1000000 / enc->sample_rate);
+            avio_w8(pb, 256 - (1000000 + enc->sample_rate/2) / enc->sample_rate);
             avio_w8(pb, enc->codec_tag);
         }
         voc->param_written = 1;
diff --git a/tests/ref/lavf/voc b/tests/ref/lavf/voc
index ea903b6..062da63 100644
--- a/tests/ref/lavf/voc
+++ b/tests/ref/lavf/voc
@@ -1,3 +1,3 @@
-5c4ee01048e7a8a138a97e80cf7a1924 *./tests/data/lavf/lavf.voc
+e4cefbeb4c20f5735de1877fbcfd8d1d *./tests/data/lavf/lavf.voc
 45261 ./tests/data/lavf/lavf.voc
 ./tests/data/lavf/lavf.voc CRC=0x74b2b546
diff --git a/tests/ref/lavf/voc_s16 b/tests/ref/lavf/voc_s16
index d53c950..d404fe3 100644
--- a/tests/ref/lavf/voc_s16
+++ b/tests/ref/lavf/voc_s16
@@ -1,3 +1,3 @@
-8ed10b311e49b4d4b18679b126492159 *./tests/data/lavf/lavf.s16.voc
+1d7be2b6527b76a33d2185ec6fb23f91 *./tests/data/lavf/lavf.s16.voc
 180437 ./tests/data/lavf/lavf.s16.voc
 ./tests/data/lavf/lavf.s16.voc CRC=0x7bd585ff
diff --git a/tests/ref/seek/lavf_voc b/tests/ref/seek/lavf_voc
index 387aef6..833d763 100644
--- a/tests/ref/seek/lavf_voc
+++ b/tests/ref/seek/lavf_voc
@@ -1,27 +1,27 @@
 ret: 0         st: 0 flags:1 dts: 0.000000 pts: 0.000000 pos:     32 size:  1024
 ret:-1         st:-1 flags:0  ts:-1.000000
 ret:-1         st:-1 flags:1  ts: 1.894167
-ret:-1         st: 0 flags:0  ts: 0.788335
-ret:-1         st: 0 flags:1  ts:-0.317508
+ret:-1         st: 0 flags:0  ts: 0.788330
+ret:-1         st: 0 flags:1  ts:-0.317494
 ret:-1         st:-1 flags:0  ts: 2.576668
 ret:-1         st:-1 flags:1  ts: 1.470835
-ret:-1         st: 0 flags:0  ts: 0.365006
-ret:-1         st: 0 flags:1  ts:-0.740837
+ret:-1         st: 0 flags:0  ts: 0.365012
+ret:-1         st: 0 flags:1  ts:-0.740834
 ret:-1         st:-1 flags:0  ts: 2.153336
 ret:-1         st:-1 flags:1  ts: 1.047503
-ret:-1         st: 0 flags:0  ts:-0.058323
-ret:-1         st: 0 flags:1  ts: 2.835834
+ret:-1         st: 0 flags:0  ts:-0.058328
+ret:-1         st: 0 flags:1  ts: 2.835848
 ret:-1         st:-1 flags:0  ts: 1.730004
 ret:-1         st:-1 flags:1  ts: 0.624171
-ret:-1         st: 0 flags:0  ts:-0.481652
-ret:-1         st: 0 flags:1  ts: 2.412505
+ret:-1         st: 0 flags:0  ts:-0.481669
+ret:-1         st: 0 flags:1  ts: 2.412507
 ret:-1         st:-1 flags:0  ts: 1.306672
 ret:-1         st:-1 flags:1  ts: 0.200839
-ret:-1         st: 0 flags:0  ts:-0.905003
-ret:-1         st: 0 flags:1  ts: 1.989176
+ret:-1         st: 0 flags:0  ts:-0.904986
+ret:-1         st: 0 flags:1  ts: 1.989167
 ret:-1         st:-1 flags:0  ts: 0.883340
 ret:-1         st:-1 flags:1  ts:-0.222493
-ret:-1         st: 0 flags:0  ts: 2.671668
-ret:-1         st: 0 flags:1  ts: 1.565847
+ret:-1         st: 0 flags:0  ts: 2.671673
+ret:-1         st: 0 flags:1  ts: 1.565849
 ret:-1         st:-1 flags:0  ts: 0.460008
 ret:-1         st:-1 flags:1  ts:-0.645825



More information about the ffmpeg-cvslog mailing list