1From dbbb71cf2b859901f3ed5b1e8b4dfec92651af35 Mon Sep 17 00:00:00 2001
2From: Jiajian Wu <jair.wu@rock-chips.com>
3Date: Tue, 11 Oct 2022 09:21:10 +0800
4Subject: [PATCH] riff: Fix bps caculation error for ADPCM
5
6The bps shall be caculated according to:
7ADPCM: rate * blockalign / ((blockalign - ch * 7) * 2)
8DVI ADPCM: rate * blockalign / ((blockalign - ch * 4) * 2)
9cus the sample size is 4bit in ADPCM witch is half
10of raw pcm.
11
12Signed-off-by: Jiajian Wu <jair.wu@rock-chips.com>
13---
14 gst-libs/gst/riff/riff-media.c | 4 ++--
15 1 file changed, 2 insertions(+), 2 deletions(-)
16
17diff --git a/gst-libs/gst/riff/riff-media.c b/gst-libs/gst/riff/riff-media.c
18index 21200a1..deb8e65 100644
19--- a/gst-libs/gst/riff/riff-media.c
20+++ b/gst-libs/gst/riff/riff-media.c
21@@ -1298,7 +1298,7 @@ gst_riff_create_audio_caps (guint16 codec_id,
22          * would probably confuse timing */
23         strf->av_bps = 0;
24         if (strf->channels != 0 && strf->rate != 0 && strf->blockalign != 0) {
25-          int spb = ((strf->blockalign - strf->channels * 7) / 2) * 2;
26+          int spb = (strf->blockalign - strf->channels * 7) * 2;
27           strf->av_bps =
28               gst_util_uint64_scale_int (strf->rate, strf->blockalign, spb);
29           GST_DEBUG ("fixing av_bps to calculated value %d of MS ADPCM",
30@@ -1420,7 +1420,7 @@ gst_riff_create_audio_caps (guint16 codec_id,
31          * as this would probably confuse timing */
32         strf->av_bps = 0;
33         if (strf->channels != 0 && strf->rate != 0 && strf->blockalign != 0) {
34-          int spb = ((strf->blockalign - strf->channels * 4) / 2) * 2;
35+          int spb = (strf->blockalign - strf->channels * 4) * 2;
36           strf->av_bps =
37               gst_util_uint64_scale_int (strf->rate, strf->blockalign, spb);
38           GST_DEBUG ("fixing av_bps to calculated value %d of IMA DVI ADPCM",
39--
402.25.1
41
42