]> git.nihav.org Git - nihav.git/commitdiff
msadpcmenc: set proper block size if it can be calculated from timebase
authorKostya Shishkov <kostya.shishkov@gmail.com>
Fri, 21 Mar 2025 13:30:42 +0000 (14:30 +0100)
committerKostya Shishkov <kostya.shishkov@gmail.com>
Fri, 21 Mar 2025 13:30:42 +0000 (14:30 +0100)
nihav-ms/src/codecs/msadpcm.rs

index 78966149f548bc8cc8bc52bda25b3482d44f6feb..ef1fd9665ea585bf7627587711e7b1be4c347358 100644 (file)
@@ -323,6 +323,9 @@ impl NAEncoder for MSADPCMEncoder {
                 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;
                 }