Commit Graph

70 Commits

Author SHA1 Message Date
Dmytro Bogovych 03c58c4572 - G.722: decode as 16 kHz audio, keep the 8 kHz RTP clock separate
G722Codec::info() reported an 8 kHz sample rate for its 16 kHz output (640
bytes of PCM per 20 ms frame, read as 40 ms at 8 kHz). AudioReceiver therefore
fetched packets at half the rate they arrived, and the high-water trim
discarded about 44% of every G.722 stream: 109 of 250 packets per 5 s, with the
buffer at 360 ms instead of 100 ms.

The 8 kHz figure is right for one thing: RFC 3551 keeps G.722's RTP clock at
8000. Codec::Info already had mTimestampUnit for that. G.722 now reports
mSamplerate 16000 and mTimestampUnit 1/8000, and Codec::rtpClockRate() gives
the clock rate. The uses of samplerate() that mean RTP time now use it:
- the jitter statistics in AudioReceiver::add;
- the timestamp-gap-to-milliseconds conversion in AudioReceiver;
- AudioStream's transmit timestamp unit and increment (numerically unchanged
  for every codec, including G.722).
PCM uses stay on samplerate(), so AudioStream now also feeds the G.722
encoder 16 kHz audio instead of 8 kHz. The factory still advertises G722/8000
in SDP, as it must; only its backwards comment is fixed.

AudioReceiver::infoFor() also applied a "G729A silence" rule to payload type
9, which is G.722; G.729 is 18. It now applies to PT 18. Other fixed-frame
payloads are timed proportionally, as AudioReceiver::add already does, so a
10 ms G.722 packet (half a 160-byte frame) counts as 10 ms, not 20.

Measured in vq-core with 16 replayed calls (NISQA speech; G.722 from ffmpeg
and pjmedia, G.711 controls of the same speech; 3 runs each, all identical):
- G.722 packet drops: 44% -> 0; buffer 100 ms like G.711; no underruns;
- Sevana MOS of every G.722 call now equals its G.711 control, normal and loud
  (with the previous code three calls read 4.45 against 4.25);
- DeadAir-01 0.68-0.89 -> 0.01-0.27 (G.711: 0.00-0.14); SilentCall within 0.01
  of G.711 for the ffmpeg-encoded calls (was 0.15-0.17 higher);
- AmpClipping on loud calls 0.004/0.001, as G.711; the 0.02-0.03 seen after
  the codec swap alone came from the dropped packets;
- G.711 results, packet counts, loss, jitter and audio durations unchanged.
The transmit path (AudioStream) builds but was not exercised; vq-core only
receives.

Needs the vq_net change that computes jitter with rtpClockRate().

Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
2026-09-21 18:03:58 +02:00
dmytro.bogovych e166bae1ea - clang format + naming improved 2026-09-03 10:03:42 +03:00
dmytro.bogovych 23a28c293b - audio decoding chain improving 2026-07-22 17:28:37 +03:00
dmytro.bogovych bbad9d27b4 - fix bad audio quality 2026-07-17 14:42:36 +03:00
dmytro.bogovych dc8cf6a12c - performance optimization 2026-06-30 20:43:08 +03:00
dmytro.bogovych e8a71d5b03 - optimize memory usage 2026-06-21 14:02:40 +03:00
dmytro.bogovych 1e020a7b5f - better internal statistics + memory performance optimization 2026-06-18 12:28:19 +03:00
dmytro.bogovych 2cb2a93d59 - performance optimizations 2026-06-17 14:18:31 +03:00
dmytro.bogovych 40f3b34b16 - fixes after review 2026-06-16 18:05:51 +03:00
dmytro.bogovych 27eefb34fe - fix DTX decoding 2026-05-30 18:11:03 +03:00
dmytro.bogovych b779a9f00f - fix audio decoding chain (extra silence could be generated in case of big network losses) 2026-05-23 15:51:46 +03:00
dmytro.bogovych dd21bc8c35 - fix packet time calculation for Opus codec 2026-05-22 13:36:28 +03:00
dmytro.bogovych cfdf1a0c77 - cleanup old non-used code + migration to std::chrono 2026-04-20 22:09:58 +03:00
dmytro.bogovych 06e8bf0b5d - fix logging - too much different subsystem names were used 2026-03-09 15:27:55 +03:00
dmytro.bogovych 549eb93db7 - fix Windows build issues 2026-02-26 13:33:29 +03:00
dmytro.bogovych 34fd9121ed - adopt RFC2833 decoder for pcap analyzer 2026-02-25 13:54:37 +03:00
dmytro.bogovych 06b39dd629 - improve packet loss reporting + initial DTMF RFC 2833 event reporting 2026-02-25 10:16:24 +03:00
dmytro.bogovych 03f662e5ce - fix packet loss reporting 2026-02-24 12:49:39 +03:00
dmytro.bogovych b5fe9e59c4 - fix AMR-WB decoder 2026-02-24 10:47:38 +03:00
dmytro.bogovych 783359c616 - fix clang build (build_linux.py) + fix problems reported by Kimi LLM 2026-02-23 20:40:59 +03:00
dmytro.bogovych 78d77c4e69 - work to improve the decoding process - many problems fixes + however there are problems yet 2026-02-20 13:16:13 +03:00
dmytro.bogovych 94f30b25e9 - improving the decoder 2026-02-19 15:27:32 +03:00
dmytro.bogovych 8f826e321c - use std::chrono types for timelength values 2026-02-13 08:38:27 +03:00
dmytro.bogovych bb1f92fa31 - minimize logging 2026-02-12 17:53:05 +03:00
dmytro.bogovych 260413fad1 - fixes 2026-01-30 08:25:17 +03:00
dmytro.bogovych f650eaccb7 - fixes + correct decode of DTX/CNG periods 2026-01-11 17:48:42 +03:00
dmytro.bogovych 11d4bf7495 - report packet loss timeline 2026-01-06 12:46:13 +03:00
dmytro.bogovych 83373cb586 - making rtphone buildable on Windows 2025-04-21 13:12:56 +03:00
dmytro.bogovych 8d0c8ba4de - source codes cleanups and minor fixes 2025-04-16 09:58:06 +03:00
dmytro.bogovych efbf9c5bf8 - send silence to audio decoder if packet is lost 2025-02-25 15:11:13 +03:00
dmytro.bogovych a7176fefeb - minor cleanups 2025-02-16 14:03:04 +03:00
dmytro.bogovych c45c686582 - fixes for pvqa_pcap project - lazy creation of codecs + compare timespec structures 2024-12-24 13:19:54 +03:00
dmytro.bogovych 4ba1ea7fa2 - fixes from pvqa_pcap 2024-12-23 17:39:45 +03:00
dmytro.bogovych 4d7ca3e4f3 - properly handle the badly decoded audio (which can happen due to payload type <-> codec inconsistency) 2024-11-16 16:33:21 +03:00
dmytro.bogovych 4cff4a0988 - more cleanups - use uuid library on the rtphone level + formatting fixed 2024-10-14 07:25:57 +03:00
dmytro.bogovych 677faa0615 - rename config.h to engine_config.h to avoid possible problems with include directories order 2023-11-26 16:32:51 +03:00
dmytro.bogovych 55445f6630 - work to merge latest changes into master branch 2023-05-10 11:03:48 +03:00
dmytro.bogovych 76aa7861f5 - refactoring 2023-04-21 09:59:18 +03:00
dmytro.bogovych 5bbdec8452 - better information about decoding results 2022-11-03 17:32:44 +03:00
dmytro.bogovych 83dd8f88b7 - fix compiler warning + make debugging easier 2022-10-30 18:36:06 +03:00
dmytro.bogovych eabc1b5c3d - add stun server IP setting + fix problem when processing incoming audio data 2022-09-08 20:54:01 +03:00
dmytro.bogovych 4c1241cd1e - fixes 2021-11-03 15:27:21 +02:00
dmytro.bogovych 1bfd84ec34 - more work on RTP early decoding 2021-09-06 15:00:49 +03:00
dmytro.bogovych 23b4283b89 - initial work to move decoding from audio callback 2021-09-06 14:21:44 +03:00
dmytro.bogovych 74b5aa69cb - ongoing work to fix issue with unstable audio 2021-08-06 18:31:42 +03:00
dmytro.bogovych e281a91af6 - missed reference to lround() 2021-07-10 18:31:18 +03:00
dmytro.bogovych cf1f206056 - minor fixes of warnings + counter of dropped packets 2021-07-02 14:08:44 +03:00
dmytro.bogovych 33465c33a1 - fixes for minimalistic builds (without AMR / EVS / Opus codecs) 2021-01-21 13:53:25 +02:00
dmytro.bogovych ed12569ad6 - switch to new PVQA & AQuA C++ interface 2020-06-27 21:50:40 +03:00
dmytro.bogovych 3f797bd09c - more work on EVS decoder 2020-06-16 09:09:15 +03:00