]> git.nihav.org Git - nihav.git/commitdiff
nihav-ms/imaadpcmenc: set proper block size if timebase allows it
authorKostya Shishkov <kostya.shishkov@gmail.com>
Fri, 21 Mar 2025 13:32:24 +0000 (14:32 +0100)
committerKostya Shishkov <kostya.shishkov@gmail.com>
Fri, 21 Mar 2025 13:32:24 +0000 (14:32 +0100)
nihav-ms/src/codecs/imaadpcmenc.rs

index f5c6df0c83ce18bd9274b3bcb9639aa34c624f0e..eee51b8993a5368c4ec73a00af21069f0dd252fa 100644 (file)
@@ -201,6 +201,9 @@ impl NAEncoder for IMAADPCMEncoder {
                 if outinfo.block_len == 0 {
                     outinfo.block_len = DEFAULT_BLOCK_LEN;
                 }
+                if outinfo.block_len == 1 && encinfo.tb_den != outinfo.sample_rate {
+                    outinfo.block_len = ((u64::from(outinfo.sample_rate) * u64::from(encinfo.tb_num) / u64::from(encinfo.tb_den) + 3) & !3) as usize;
+                }
                 if outinfo.block_len < 2 {
                     outinfo.block_len = 2;
                 }