2 * Routines for EVS dissection
3 * Copyright 2018, Anders Broman <anders.broman[at]ericsson.com>
5 * Wireshark - Network traffic analyzer
6 * By Gerald Combs <gerald@wireshark.org>
7 * Copyright 1998 Gerald Combs
9 * SPDX-License-Identifier: GPL-2.0-or-later
12 * 3GPP TS 26.445 A.2 EVS RTP Payload Format
17 #include <epan/packet.h>
18 #include <epan/prefs.h>
19 #include <epan/proto_data.h>
21 #include <wsutil/str_util.h>
22 #include <wsutil/utf8_entities.h>
23 #include "packet-rtp.h"
25 void proto_register_evs(void);
26 void proto_reg_handoff_evs(void);
28 static dissector_handle_t evs_handle
;
30 static bool evs_hf_only
;
32 /* Initialize the protocol and registered fields */
36 static int hf_evs_packet_length
;
37 static int hf_evs_voice_data
;
38 static int hf_evs_h_bit
;
39 static int hf_evs_cmr_t
;
40 static int hf_evs_cmr_t0_d
;
41 static int hf_evs_cmr_t1_d
;
42 static int hf_evs_cmr_t2_d
;
43 static int hf_evs_cmr_t3_d
;
44 static int hf_evs_cmr_t4_d
;
45 static int hf_evs_cmr_t5_d
;
46 static int hf_evs_cmr_t6_d
;
47 static int hf_evs_cmr_t7_d
;
48 static int hf_evs_f_bit
;
49 static int hf_evs_mode_bit
;
50 static int hf_evs_toc_spare
;
51 static int hf_evs_amr_wb_q_bit
;
52 static int hf_evs_bit_rate_mode_0
;
53 static int hf_evs_bit_rate_mode_1
;
54 static int hf_evs_cmr_amr_io
;
56 static int hf_evs_reserved_1bit
;
57 static int hf_evs_celp_switch_to_mdct_core
;
58 static int hf_evs_celp_mdct_core
;
59 static int hf_evs_tcx_or_hq_mdct_core
;
60 static int hf_evs_sid_cng
;
61 static int hf_evs_celp_sample_rate
;
62 static int hf_evs_core_sample_rate
;
63 static int hf_evs_132_bwctrf_idx
;
64 static int hf_evs_28_frame_type
;
65 static int hf_evs_28_bw_ppp_nelp
;
66 static int hf_evs_72_80_bwct_idx
;
67 static int hf_evs_320_bwct_idx
;
68 static int hf_evs_640_bwct_idx
;
71 static int ett_evs_header
;
72 static int ett_evs_speech
;
73 static int ett_evs_voice_data
;
75 static const value_string evs_protected_payload_sizes_value
[] = {
76 { 48, "EVS Primary SID 2.4" },
77 { 56, "Special case" },
78 { 136, "EVS AMR-WB IO 6.6" },
79 { 144, "EVS Primary 7.2" },
80 { 160, "EVS Primary 8.0" },
81 { 184, "EVS AMR-WB IO 8.85" },
82 { 192, "EVS Primary 9.6" },
83 { 256, "EVS AMR-WB IO 12.65" },
84 { 264, "EVS Primary 13.2" },
85 { 288, "EVS AMR-WB IO 14.25" },
86 { 320, "EVS AMR-WB IO 15.85" },
87 { 328, "EVS Primary 16.4" },
88 { 368, "EVS AMR-WB IO 18.25" },
89 { 400, "EVS AMR-WB IO 19.85" },
90 { 464, "EVS AMR-WB IO 23.05" },
91 { 480, "EVS AMR-WB IO 23.85" },
92 { 488, "EVS Primary 24.4" },
93 { 640, "EVS Primary 32.0" },
94 { 960, "EVS Primary 48.0" },
95 { 1280, "EVS Primary 64.0" },
96 { 1920, "EVS Primary 96.0" },
97 { 2560, "EVS Primary 128.0" },
101 static const value_string evs_d_bits_t0_values
[] = {
102 { 0x0, "NB 5.9 kbps (VBR)" },
103 { 0x1, "NB 7.2 kbps" },
104 { 0x2, "NB 8.0 kbps" },
105 { 0x3, "NB 9.6 kbps" },
106 { 0x4, "NB 13.2 kbps" },
107 { 0x5, "NB 16.4 kbps" },
108 { 0x6, "NB 24.4 kbps" },
121 static const value_string evs_d_bits_t1_values
[] = {
122 { 0x0, "AMR-WB IO 6.6 kbps (mode-set 0)" },
123 { 0x1, "AMR-WB IO 8.8 kbps (mode-set 1)" },
124 { 0x2, "AMR-WB IO 12.65 kbps (mode-set 2)" },
125 { 0x3, "AMR-WB IO 14.25 kbps (mode-set 3)" },
126 { 0x4, "AMR-WB IO 15.85 kbps (mode-set 4)" },
127 { 0x5, "AMR-WB IO 18.25 kbps (mode-set 5)" },
128 { 0x6, "AMR-WB IO 19.85 kbps (mode-set 6)" },
129 { 0x7, "AMR-WB IO 23.05 kbps (mode-set 7)" },
130 { 0x8, "AMR-WB IO 23.85 kbps (mode-set 8)" },
142 static const value_string evs_d_bits_t2_values
[] = {
143 { 0x0, "WB 5.9 kbps (VBR)" },
144 { 0x1, "WB 7.2 kbps" },
145 { 0x2, "WB 8 kbps" },
146 { 0x3, "WB 9.6 kbps" },
147 { 0x4,"WB 13.2 kbps" },
148 { 0x5,"WB 16.4 kbps" },
149 { 0x6,"WB 24.4 kbps" },
150 { 0x7,"WB 32 kbps" },
151 { 0x8,"WB 48 kbps" },
152 { 0x9,"WB 64 kbps" },
153 { 0xa,"WB 96 kbps" },
154 { 0xb,"WB 128 kbps" },
162 static const value_string evs_d_bits_t3_values
[] = {
166 { 0x3, "SWB 9.6 kbps" },
167 { 0x4, "SWB 13.2 kbps" },
168 { 0x5, "SWB 16.4 kbps" },
169 { 0x6, "SWB 24.4 kbps" },
170 { 0x7, "SWB 32 kbps" },
171 { 0x8, "SWB 48 kbps" },
172 { 0x9, "SWB 64 kbps" },
173 { 0xa, "SWB 96 kbps" },
174 { 0xb, "SWB 128 kbps" },
182 static const value_string evs_d_bits_t4_values
[] = {
188 { 0x5, "FB 16.4 kbps" },
189 { 0x6, "FB 24.4 kbps" },
190 { 0x7, "FB 32 kbps" },
191 { 0x8, "FB 48 kbps" },
192 { 0x9, "FB 64 kbps" },
193 { 0xa, "FB 96 kbps" },
194 { 0xb, "FB 128 kbps" },
202 static const value_string evs_d_bits_t5_values
[] = {
203 { 0x0, "WB 13.2 kbps CA-L-O2" },
204 { 0x1, "WB 13.2 kbps CA-L-O3" },
205 { 0x2, "WB 13.2 kbps CA-L-O5" },
206 { 0x3, "WB 13.2 kbps CA-L-O7" },
207 { 0x4, "WB 13.2 kbps CA-H-O2" },
208 { 0x5, "WB 13.2 kbps CA-H-O3" },
209 { 0x6, "WB 13.2 kbps CA-H-O5" },
210 { 0x7, "WB 13.2 kbps CA-H-O7" },
222 static const value_string evs_d_bits_t6_values
[] = {
223 { 0x0, "SWB 13.2 kbps CA-L-O2" },
224 { 0x1, "SWB 13.2 kbps CA-L-O3" },
225 { 0x2, "SWB 13.2 kbps CA-L-O5" },
226 { 0x3, "SWB 13.2 kbps CA-L-O7" },
227 { 0x4, "SWB 13.2 kbps CA-H-O2" },
228 { 0x5, "SWB 13.2 kbps CA-H-O3" },
229 { 0x6, "SWB 13.2 kbps CA-H-O5" },
230 { 0x7, "SWB 13.2 kbps CA-H-O7" },
242 static const value_string evs_d_bits_t7_values
[] = {
262 static const value_string evs_bit_rate_mode_0_values
[] = {
263 { 0x0, "Primary 2.8 kbps" },
264 { 0x1, "Primary 7.2 kbps" },
265 { 0x2, "Primary 8.0 kbps" },
266 { 0x3, "Primary 9.6 kbps" },
267 { 0x4, "Primary 13.2 kbps" },
268 { 0x5, "Primary 16.4 kbps" },
269 { 0x6, "Primary 24.4 kbps" },
270 { 0x7, "Primary 32.0 kbps" },
271 { 0x8, "Primary 48.0 kbps" },
272 { 0x9, "Primary 64.0 kbps" },
273 { 0xa, "Primary 96.0 kbps" },
274 { 0xb, "Primary 128.0 kbps" },
275 { 0xc, "Primary 2.4 kbps SID" },
276 { 0xd, "For future use" },
277 { 0xe, "SPEECH_LOST" },
282 static const value_string evs_bit_rate_mode_1_values
[] = {
283 { 0x0, "AMR-WB IO 6.6 kbps" },
284 { 0x1, "AMR-WB IO 8.85 kbps" },
285 { 0x2, "AMR-WB IO 12.65 kbps" },
286 { 0x3, "AMR-WB IO 14.24 kbps" },
287 { 0x4, "AMR-WB IO 15.85 kbps" },
288 { 0x5, "AMR-WB IO 18.25 kbps" },
289 { 0x6, "AMR-WB IO 19.85 kbps" },
290 { 0x7, "AMR-WB IO 23.05 kbps" },
291 { 0x8, "AMR-WB IO 23.85 kbps" },
292 { 0x9, "AMR-WB IO 2.0 kbps SID" },
293 { 0xa, "For future use" },
294 { 0xb, "For future use" },
295 { 0xc, "For future use" },
296 { 0xd, "For future use" },
297 { 0xe, "SPEECH_LOST" },
303 static const value_string evs_cmr_amr_io_values
[] = {
304 { 0x0, "AMR-WB IO 6.6 kbps" },
305 { 0x1, "AMR-WB IO 8.85 kbps" },
306 { 0x2, "AMR-WB IO 12.65 kbps" },
307 { 0x3, "AMR-WB IO 15.85 kbps" },
308 { 0x4, "AMR-WB IO 18.25 kbps" },
309 { 0x5, "AMR-WB IO 23.05 kbps" },
310 { 0x6, "AMR-WB IO 23.85 kbps" },
315 static const true_false_string tfs_evs_h_bit
= {
320 static const true_false_string tfs_evs_f_bit
= {
321 "Speech frame follows",
322 "Last frame in payload"
325 static const true_false_string toc_evs_q_bit_vals
= {
327 "Severely damaged frame"
330 static const value_string evs_bw_values
[] = {
338 static const value_string evs_celp_switch_to_mdct_core_values
[] = {
344 static const value_string evs_celp_or_mdct_core_values
[] = {
350 static const value_string evs_tcx_or_hq_mdct_core_values
[] = {
351 { 0x0, "HQ-MDCT core" },
356 static const value_string evs_sid_cng_values
[] = {
357 { 0x0, "LP-CNG SID" },
362 static const value_string evs_sid_celp_sample_rate_values
[] = {
368 static const value_string evs_132_bwctrf_idx_vals
[] = {
369 { 0x0, "NB generic" },
370 { 0x1, "NB voiced" },
371 { 0x2, "NB transition" },
373 { 0x4, "NB inactive" },
374 { 0x5, "WB generic" },
375 { 0x6, "WB voiced" },
376 { 0x7, "WB transition" },
378 { 0x9, "WB inactive" },
379 { 0xa, "SWB generic" },
380 { 0xb, "SWB voiced" },
381 { 0xc, "SWB transition" },
382 { 0xd, "SWB audio" },
383 { 0xe, "SWB inactive" },
384 { 0xf, "NB generic" },
385 { 0x10, "NB voiced" },
386 { 0x11, "WB generic" },
387 { 0x12, "WB voiced" },
388 { 0x13, "SWB generic" },
389 { 0x14, "SWB voiced" },
390 { 0x15, "WB generic" },
391 { 0x16, "WB unvoiced" },
392 { 0x17, "WB voiced" },
393 { 0x18, "WB inactive" },
394 { 0x19, "SWB generic" },
395 { 0x1a, "SWB unvoiced" },
396 { 0x1b, "SWB voiced" },
397 { 0x1c, "SWB inactive" },
398 { 0x1d, "NB lrMDCT" },
399 { 0x1e, "WB lrMDCT" },
400 { 0x1f, "SWB lrMDCT" },
404 static const value_string evs_28_frame_type_vals
[] = {
405 { 0x0, "Primary PPP/NELP" },
406 { 0x1, "AMR-WB IO SID" },
410 static const value_string evs_28_bw_ppp_nelp_vals
[] = {
418 static const value_string evs_72_80_bwct_idx_vals
[] = {
419 { 0x0, "NB generic" },
420 { 0x1, "NB unvoiced" },
421 { 0x2, "NB voiced" },
422 { 0x3, "NB transition" },
424 { 0x5, "NB inactive" },
425 { 0x6, "WB generic" },
426 { 0x7, "WB unvoiced" },
427 { 0x8, "WB voiced" },
428 { 0x9, "WB transition" },
430 { 0xb, "WB inactive" },
431 { 0xc, "NB generic" },
432 { 0xd, "WB generic" },
433 { 0xe, "NB lrMDCT" },
437 static const value_string evs_320_bwct_idx_vals
[] = {
438 { 0x0, "WB generic" },
439 { 0x1, "WB transition" },
440 { 0x2, "WB inactive" },
441 { 0x3, "SWB generic" },
442 { 0x4, "SWB transition" },
443 { 0x5, "SWB inactive" },
444 { 0x6, "FB generic" },
445 { 0x7, "FB transition" },
446 { 0x8, "FB inactive" },
447 { 0x9, "WB generic" },
448 { 0xa, "WB transition" },
449 { 0xb, "SWB generic" },
450 { 0xc, "SWB transition" },
451 { 0xd, "FB generic" },
452 { 0xe, "FB transition" },
456 static const value_string evs_640_bwct_idx_vals
[] = {
457 { 0x0, "WB generic" },
458 { 0x1, "WB transition" },
459 { 0x2, "WB inactive" },
460 { 0x3, "SWB generic" },
461 { 0x4, "SWB transition" },
462 { 0x5, "SWB inactive" },
463 { 0x6, "FB generic" },
464 { 0x7, "FB transition" },
465 { 0x8, "FB inactive" },
466 { 0x9, "SWB generic" },
467 { 0xa, "SWB transition" },
468 { 0xb, "FB generic" },
469 { 0xc, "FB transition" },
474 dissect_evs_cmr(tvbuff_t
*tvb
, packet_info
*pinfo _U_
, proto_tree
*evs_tree
, int offset
, uint8_t cmr_oct
)
479 uint8_t t_bits
= (cmr_oct
& 0x70) >> 4;
480 uint8_t d_bits
= (cmr_oct
& 0x0f);
482 tree
= proto_tree_add_subtree(evs_tree
, tvb
, offset
, 1, ett_evs_header
, &item
, "CMR");
488 static int * const flags_t0
[] = {
495 str
= val_to_str_const(d_bits
, evs_d_bits_t0_values
, "Unknown value");
496 proto_item_append_text(item
, " %s",str
);
497 proto_tree_add_bitmask_list(tree
, tvb
, offset
, 1, flags_t0
, ENC_BIG_ENDIAN
);
502 static int * const flags_t1
[] = {
509 str
= val_to_str_const(d_bits
, evs_d_bits_t1_values
, "Unknown value");
510 proto_item_append_text(item
, " %s",str
);
511 proto_tree_add_bitmask_list(tree
, tvb
, offset
, 1, flags_t1
, ENC_BIG_ENDIAN
);
516 static int * const flags_t2
[] = {
523 str
= val_to_str_const(d_bits
, evs_d_bits_t2_values
, "Unknown value");
524 proto_item_append_text(item
, " %s",str
);
525 proto_tree_add_bitmask_list(tree
, tvb
, offset
, 1, flags_t2
, ENC_BIG_ENDIAN
);
530 static int * const flags_t3
[] = {
537 str
= val_to_str_const(d_bits
, evs_d_bits_t3_values
, "Unknown value");
538 proto_item_append_text(item
, " %s",str
);
539 proto_tree_add_bitmask_list(tree
, tvb
, offset
, 1, flags_t3
, ENC_BIG_ENDIAN
);
544 static int * const flags_t4
[] = {
551 str
= val_to_str_const(d_bits
, evs_d_bits_t4_values
, "Unknown value");
552 proto_item_append_text(item
, " %s",str
);
553 proto_tree_add_bitmask_list(tree
, tvb
, offset
, 1, flags_t4
, ENC_BIG_ENDIAN
);
558 static int * const flags_t5
[] = {
565 str
= val_to_str_const(d_bits
, evs_d_bits_t5_values
, "Unknown value");
566 proto_item_append_text(item
, " %s",str
);
567 proto_tree_add_bitmask_list(tree
, tvb
, offset
, 1, flags_t5
, ENC_BIG_ENDIAN
);
572 static int * const flags_t6
[] = {
579 str
= val_to_str_const(d_bits
, evs_d_bits_t6_values
, "Unknown value");
580 proto_item_append_text(item
, " %s",str
);
581 proto_tree_add_bitmask_list(tree
, tvb
, offset
, 1, flags_t6
, ENC_BIG_ENDIAN
);
586 static int * const flags_t7
[] = {
593 str
= val_to_str_const(d_bits
, evs_d_bits_t7_values
, "Unknown value");
594 proto_item_append_text(item
, " %s",str
);
595 proto_tree_add_bitmask_list(tree
, tvb
, offset
, 1, flags_t7
, ENC_BIG_ENDIAN
);
599 DISSECTOR_ASSERT_NOT_REACHED();
603 col_append_fstr(pinfo
->cinfo
, COL_INFO
, ", %s", str
);
606 /* Code to actually dissect the packets */
608 dissect_evs(tvbuff_t
*tvb
, packet_info
*pinfo
, proto_tree
*tree
, void* data _U_
)
611 proto_tree
*evs_tree
, *sub_tree
, *vd_tree
;
612 int offset
= 0 , bit_offset
= 0;
613 int packet_len
, idx
, speech_data_len
;
616 uint8_t oct
, h_bit
, toc_f_bit
, evs_mode_b
;
617 int num_toc
, num_data
;
619 bool is_compact
= false;
620 struct _rtp_pkt_info
*rtp_pkt_info
= p_get_proto_data(pinfo
->pool
, pinfo
, proto_rtp
, pinfo
->curr_layer_num
-1);
621 struct _rtp_info
*rtp_info
= NULL
;
622 bool rtmp_enforce_hf_only
= false;
624 /* Make entries in Protocol column and Info column on summary display */
625 col_set_str(pinfo
->cinfo
, COL_PROTOCOL
, "EVS");
627 ti
= proto_tree_add_item(tree
, proto_evs
, tvb
, 0, -1, ENC_NA
);
628 evs_tree
= proto_item_add_subtree(ti
, ett_evs
);
629 packet_len
= tvb_reported_length(tvb
);
631 /* A.2.3.2 ignore sizes if hf-only=1 */
633 rtp_info
= (struct _rtp_info
*)data
;
634 if (rtp_info
->info_payload_fmtp_map
) {
635 char *tmp
= wmem_map_lookup(rtp_info
->info_payload_fmtp_map
, "hf-only");
636 if (g_strcmp0(tmp
, "1") == 0) {
637 rtmp_enforce_hf_only
= true;
642 /* Find out if we have one of the reserved packet sizes*/
643 if (!(rtmp_enforce_hf_only
|| evs_hf_only
)) {
644 num_bits
= packet_len
* 8;
646 num_bits
+= rtp_pkt_info
->padding_len
* 8; /* take into account RTP padding if any */
647 if (num_bits
== 56) {
648 /* A.2.1.3 Special case for 56 bit payload size (EVS Primary or EVS AMR-WB IO SID) */
649 /* The resulting ambiguity between EVS Primary 2.8 kbps and EVS AMR-WB IO SID frames is resolved through the
650 most significant bit (MSB) of the first byte of the payload. By definition, the first data bit d(0) of the EVS Primary 2.8
651 kbps is always set to '0'.
653 oct
= tvb_get_bits8(tvb
, bit_offset
, 1);
655 /* EVS Primary 2.8 kbps */
656 str
= "EVS Primary 2.8";
659 /* EVS AMR-WB IO SID */
660 str
= "EVS AMR-WB IO SID";
663 str
= try_val_to_str_idx(num_bits
, evs_protected_payload_sizes_value
, &idx
);
671 /* A.2.1 EVS codec Compact Format */
672 proto_tree_add_subtree(evs_tree
, tvb
, offset
, -1, ett_evs_header
, &ti
, "Framing Mode: Compact");
673 proto_item_set_generated(ti
);
675 /* One of the protected payload sizes, no further dissection currently.*/
676 col_append_fstr(pinfo
->cinfo
, COL_INFO
, ", %s", str
);
677 proto_tree_add_int_format(evs_tree
, hf_evs_packet_length
, tvb
, offset
, 1, packet_len
* 8, " %s, packet_len %i bits", str
, packet_len
* 8);
678 if (strncmp(str
, "EVS A", 5) == 0) {
679 /* A.2.1.2 Compact format for EVS AMR-WB IO mode */
681 proto_tree_add_item(evs_tree
, hf_evs_cmr_amr_io
, tvb
, offset
, 1, ENC_BIG_ENDIAN
);
684 vd_tree
= proto_tree_add_subtree(evs_tree
, tvb
, offset
, -1, ett_evs_voice_data
, NULL
, "Voice Data");
685 switch (packet_len
) {
686 case 17: /* 136 EVS AMR-WB IO 6.6 */
687 case 23: /* 184 EVS AMR-WB IO 8.85 */
688 case 32: /* 256 EVS AMR-WB IO 12.65 */
689 case 36: /* 288 EVS AMR-WB IO 14.25 */
690 case 40: /* 320 EVS AMR-WB IO 15.85 */
691 case 46: /* 368 EVS AMR-WB IO 18.25 */
692 case 50: /* 400 EVS AMR-WB IO 19.85 */
693 case 58: /* 464 EVS AMR-WB IO 23.05 */
694 case 60: /* 480 EVS AMR-WB IO 23.85 */
695 /* A.2.1.2 Compact format for EVS AMR-WB IO mode (except SID)
696 * In the Compact format for EVS AMR-WB IO mode, except SID, the RTP payload consists of one 3-bit CMR field,
697 * one coded frame, and zero-padding bits if necessary.
700 proto_tree_add_item(evs_tree
, hf_evs_cmr_amr_io
, tvb
, offset
, 1, ENC_BIG_ENDIAN
);
702 case 6: /* 48 EVS Primary SID 2.4 */
703 /* 7.2 Bit allocation for SID frames in the DTX operation */
704 /* CNG type flag 1 bit */
705 proto_tree_add_bits_ret_val(vd_tree
, hf_evs_sid_cng
, tvb
, bit_offset
, 1, &value
, ENC_BIG_ENDIAN
);
708 /* FD-CNG SID frame */
709 /* Bandwidth indicator 2 bits */
710 proto_tree_add_bits_item(vd_tree
, hf_evs_bw
, tvb
, bit_offset
, 2, ENC_BIG_ENDIAN
);
712 /* CELP sample rate 1 bit*/
713 proto_tree_add_bits_item(vd_tree
, hf_evs_celp_sample_rate
, tvb
, bit_offset
, 1, ENC_BIG_ENDIAN
);
714 /* Global gain 7 bits */
715 /* Spectral band and energy 37 bits */
717 /* LP-CNG SID frame */
718 /* Bandwidth indicator 1 bit */
719 oct
= tvb_get_bits8(tvb
, bit_offset
, 1);
720 proto_tree_add_uint_bits_format_value(vd_tree
, hf_evs_bw
, tvb
, bit_offset
, 1, 1, ENC_BIG_ENDIAN
, "%s (%u)",
721 val_to_str_const(1 << oct
, evs_bw_values
, "Unknown value"), oct
);
723 /* Core sampling rate indicator */
724 proto_tree_add_bits_item(vd_tree
, hf_evs_core_sample_rate
, tvb
, bit_offset
, 1, ENC_BIG_ENDIAN
);
727 case 7: /* 56 EVS Primary SID 2.8 */
728 /* A.2.1.3 Special case for 56 bit payload size (EVS Primary or EVS AMR-WB IO SID) */
729 /* The resulting ambiguity between EVS Primary 2.8 kbps and EVS AMR-WB IO SID frames is resolved through the
730 most significant bit (MSB) of the first byte of the payload. By definition, the first data bit d(0) of the EVS Primary 2.8
731 kbps is always set to '0'.
733 proto_tree_add_bits_ret_val(vd_tree
, hf_evs_28_frame_type
, tvb
, bit_offset
, 1, &value
, ENC_BIG_ENDIAN
);
736 /* Primary PPP/NELP frame */
737 proto_tree_add_bits_item(vd_tree
, hf_evs_28_bw_ppp_nelp
, tvb
, bit_offset
, 2, ENC_BIG_ENDIAN
);
740 case 18: /* 144 EVS Primary 7.2 */
741 case 20: /* 160 EVS Primary 8.0 */
742 /* 7.1.1 Bit allocation at VBR 5.9, 7.2 – 9.6 kbps
743 * Note that the BW and CT parameters are combined together to form a single index at 7.2 and 8.0 kbps. This index
744 * conveys the information whether CELP core or HQ-MDCT core is used.
747 proto_tree_add_bits_item(vd_tree
, hf_evs_72_80_bwct_idx
, tvb
, bit_offset
, 4, ENC_BIG_ENDIAN
);
749 case 24: /* 192 EVS Primary 9.6 */
750 /* 7.1.1 Bit allocation at VBR 5.9, 7.2 – 9.6 kbps */
752 proto_tree_add_bits_item(vd_tree
, hf_evs_bw
, tvb
, bit_offset
, 2, ENC_BIG_ENDIAN
);
754 case 33: /* 264 EVS Primary 13.2 */
755 /* 7.1.2 Bit allocation at 13.2 kbps
756 * The EVS codec encodes NB, WB and SWB content at 13.2 kbps with CELP core, HQ-MDCT core, or TCX core.
757 * For WB signals, the CELP core uses TBE or FD extension layer. For SWB signals, the CELP core uses TBE or FD extension layer,
758 * and the TCX core uses IGF extension layer
761 proto_tree_add_bits_item(vd_tree
, hf_evs_132_bwctrf_idx
, tvb
, bit_offset
, 5, ENC_BIG_ENDIAN
);
763 case 41: /* 328 EVS Primary 16.4 */
764 /* 7.1.3 Bit allocation at 16.4 and 24.4 kbps */
766 proto_tree_add_bits_item(vd_tree
, hf_evs_bw
, tvb
, bit_offset
, 2, ENC_BIG_ENDIAN
);
769 proto_tree_add_bits_item(vd_tree
, hf_evs_reserved_1bit
, tvb
, bit_offset
, 1, ENC_BIG_ENDIAN
);
771 case 61: /* 488 EVS Primary 24.4 */
772 /* 7.1.3 Bit allocation at 16.4 and 24.4 kbps */
774 proto_tree_add_bits_item(vd_tree
, hf_evs_bw
, tvb
, bit_offset
, 2, ENC_BIG_ENDIAN
);
777 proto_tree_add_bits_item(vd_tree
, hf_evs_reserved_1bit
, tvb
, bit_offset
, 1, ENC_BIG_ENDIAN
);
779 /* CELP/MDCT core flag 1 */
780 proto_tree_add_bits_ret_val(vd_tree
, hf_evs_celp_mdct_core
, tvb
, bit_offset
, 1, &value
, ENC_BIG_ENDIAN
);
782 /* In the case of MDCT-based core, the next bit decides whether HQ-MDCT core or TCX core is used */
785 proto_tree_add_bits_ret_val(vd_tree
, hf_evs_tcx_or_hq_mdct_core
, tvb
, bit_offset
, 1, &value
, ENC_BIG_ENDIAN
);
788 case 80: /* 640 EVS Primary 32 */
789 /* 7.1.4 Bit allocation at 32 kbps */
790 /* CELP/MDCT core flag 1 */
791 proto_tree_add_bits_ret_val(vd_tree
, hf_evs_celp_mdct_core
, tvb
, bit_offset
, 1, &value
, ENC_BIG_ENDIAN
);
793 /* In the case of MDCT-based core, the next bit decides whether HQ-MDCT core or TCX core is used */
796 proto_tree_add_bits_ret_val(vd_tree
, hf_evs_tcx_or_hq_mdct_core
, tvb
, bit_offset
, 1, &value
, ENC_BIG_ENDIAN
);
801 proto_tree_add_bits_item(vd_tree
, hf_evs_bw
, tvb
, bit_offset
, 2, ENC_BIG_ENDIAN
);
805 proto_tree_add_bits_item(vd_tree
, hf_evs_320_bwct_idx
, tvb
, bit_offset
, 4, ENC_BIG_ENDIAN
);
808 case 160: /* 1280 EVS Primary 64 */
809 /* 7.1.5 Bit allocation at 48, 64, 96 and 128 kbps */
810 /* CELP/MDCT core flag 1 */
811 proto_tree_add_bits_ret_val(vd_tree
, hf_evs_celp_mdct_core
, tvb
, bit_offset
, 1, &value
, ENC_BIG_ENDIAN
);
815 proto_tree_add_bits_ret_val(vd_tree
, hf_evs_celp_switch_to_mdct_core
, tvb
, bit_offset
, 1, &value
, ENC_BIG_ENDIAN
);
818 /* CELP sample rate 1 bit*/
819 proto_tree_add_bits_item(vd_tree
, hf_evs_celp_sample_rate
, tvb
, bit_offset
, 1, ENC_BIG_ENDIAN
);
823 proto_tree_add_bits_item(vd_tree
, hf_evs_bw
, tvb
, bit_offset
, 2, ENC_BIG_ENDIAN
);
826 proto_tree_add_bits_item(vd_tree
, hf_evs_640_bwct_idx
, tvb
, bit_offset
, 4, ENC_BIG_ENDIAN
);
829 case 120: /* 960 EVS Primary 48 */
830 case 240: /* 1920 EVS Primary 96 */
831 case 320: /* 2560 EVS Primary 128 */
832 /* 7.1.5 Bit allocation at 48, 64, 96 and 128 kbps */
834 proto_tree_add_bits_item(vd_tree
, hf_evs_bw
, tvb
, bit_offset
, 2, ENC_BIG_ENDIAN
);
837 proto_tree_add_bits_item(vd_tree
, hf_evs_reserved_1bit
, tvb
, bit_offset
, 1, ENC_BIG_ENDIAN
);
846 /* A.2.2 EVS codec Header-Full format */
847 proto_tree_add_subtree(evs_tree
, tvb
, offset
, -1, ett_evs_header
, &ti
, "Framing Mode: Header-full");
848 proto_item_set_generated(ti
);
850 /*proto_tree_add_int_format(evs_tree, hf_evs_packet_length, tvb, offset, 1, packet_len * 8, "packet_len %i bits", packet_len * 8);*/
851 oct
= tvb_get_uint8(tvb
, offset
);
856 dissect_evs_cmr(tvb
, pinfo
, evs_tree
, offset
, oct
);
862 oct
= tvb_get_uint8(tvb
, offset
);
863 toc_f_bit
= (oct
& 0x40) >> 6;
864 evs_mode_b
= (oct
& 0x20) >> 5;
867 sub_tree
= proto_tree_add_subtree_format(evs_tree
, tvb
, offset
, 1, ett_evs_header
, NULL
, " TOC # %u",
870 if (evs_mode_b
== 0) {
871 static int * const flags_toc_mode_0
[] = {
876 &hf_evs_bit_rate_mode_0
,
880 proto_tree_add_bitmask_list(sub_tree
, tvb
, offset
, 1, flags_toc_mode_0
, ENC_BIG_ENDIAN
);
881 str
= val_to_str_const((oct
& 0x0f), evs_bit_rate_mode_0_values
, "Unknown value");
883 static int * const flags_toc_mode_1
[] = {
887 &hf_evs_amr_wb_q_bit
,
888 &hf_evs_bit_rate_mode_1
,
891 proto_tree_add_bitmask_list(sub_tree
, tvb
, offset
, 1, flags_toc_mode_1
, ENC_BIG_ENDIAN
);
892 str
= val_to_str_const((oct
& 0x0f), evs_bit_rate_mode_1_values
, "Unknown value");
894 col_append_fstr(pinfo
->cinfo
, COL_INFO
, ", %s", str
);
896 } while (toc_f_bit
== 1);
898 speech_data_len
= (packet_len
- offset
) / num_toc
;
902 col_append_fstr(pinfo
->cinfo
, COL_INFO
, "%s (%u frame%s in packet)", UTF8_HORIZONTAL_ELLIPSIS
, num_data
, plurality(num_data
, "", "s"));
903 while (num_data
> 0) {
904 proto_tree
*speech_tree
;
906 speech_tree
= proto_tree_add_subtree_format(evs_tree
, tvb
, offset
, speech_data_len
, ett_evs_speech
, NULL
, "Speech frame for TOC # %u",
908 proto_tree_add_item(speech_tree
, hf_evs_voice_data
, tvb
, offset
, speech_data_len
, ENC_NA
);
909 offset
+= speech_data_len
;
918 proto_register_evs(void)
920 module_t
*evs_module
;
921 /*expert_module_t* expert_evs;*/
923 static hf_register_info hf
[] = {
924 { &hf_evs_packet_length
,
925 { "Packet length", "evs.packet_length",
926 FT_INT32
, BASE_DEC
, NULL
, 0x0,
929 { &hf_evs_voice_data
,
930 { "Voice data", "evs.voice_data",
931 FT_BYTES
, BASE_NONE
, NULL
, 0x0,
935 { "Header Type identification bit (H)", "evs.h_bit",
936 FT_BOOLEAN
, 8, TFS(&tfs_evs_h_bit
), 0x80,
940 { "Type of Request(T)", "evs.cmr_t",
941 FT_UINT8
, BASE_DEC
, NULL
, 0x70,
945 { "D", "evs.cmr_t0_d",
946 FT_UINT8
, BASE_DEC
, VALS(evs_d_bits_t0_values
), 0x0f,
950 { "D", "evs.cmr_t1_d",
951 FT_UINT8
, BASE_DEC
, VALS(evs_d_bits_t1_values
), 0x0f,
955 { "D", "evs.cmr_t3_d",
956 FT_UINT8
, BASE_DEC
, VALS(evs_d_bits_t2_values
), 0x0f,
960 { "D", "evs.cmr_t3_d",
961 FT_UINT8
, BASE_DEC
, VALS(evs_d_bits_t3_values
), 0x0f,
965 { "D", "evs.cmr_t4_d",
966 FT_UINT8
, BASE_DEC
, VALS(evs_d_bits_t4_values
), 0x0f,
970 { "D", "evs.cmr_t5_d",
971 FT_UINT8
, BASE_DEC
, VALS(evs_d_bits_t5_values
), 0x0f,
975 { "D", "evs.cmr_t6_d",
976 FT_UINT8
, BASE_DEC
, VALS(evs_d_bits_t6_values
), 0x0f,
980 { "D", "evs.cmr_t7_d",
981 FT_UINT8
, BASE_DEC
, VALS(evs_d_bits_t7_values
), 0x0f,
985 { "EVS Mode", "evs.mode_bit",
986 FT_UINT8
, BASE_DEC
, NULL
, 0x20,
990 { "Unused", "evs.toc_spare",
991 FT_UINT8
, BASE_DEC
, NULL
, 0x10,
994 { &hf_evs_amr_wb_q_bit
,
995 { "AMR WB Q bit", "evs.amr_wb_q_bit",
996 FT_BOOLEAN
, 8, TFS(&toc_evs_q_bit_vals
), 0x10,
1000 { &hf_evs_bit_rate_mode_0
,
1001 { "EVS mode and bit rate", "evs.bit_rate_mode_0",
1002 FT_UINT8
, BASE_DEC
, VALS(evs_bit_rate_mode_0_values
), 0x0f,
1005 { &hf_evs_bit_rate_mode_1
,
1006 { "EVS mode and bit rate", "evs.bit_rate_mode_1",
1007 FT_UINT8
, BASE_DEC
, VALS(evs_bit_rate_mode_1_values
), 0x0f,
1012 FT_BOOLEAN
, 8, TFS(&tfs_evs_f_bit
), 0x40,
1015 { &hf_evs_cmr_amr_io
,
1016 { "CMR", "evs.cmr_amr_io",
1017 FT_UINT8
, BASE_DEC
, VALS(evs_cmr_amr_io_values
), 0xe0,
1022 FT_UINT8
, BASE_DEC
, VALS(evs_bw_values
), 0x0,
1025 { &hf_evs_reserved_1bit
,
1026 { "Reserved", "evs.reserved_1bit",
1027 FT_UINT8
, BASE_DEC
, NULL
, 0x0,
1030 { &hf_evs_celp_switch_to_mdct_core
,
1031 { "CELP->HQ-MDCT core", "evs.celp_switch_to_mdct_core",
1032 FT_UINT8
, BASE_DEC
, VALS(evs_celp_switch_to_mdct_core_values
), 0x0,
1035 { &hf_evs_celp_mdct_core
,
1036 { "CELP/MDCT core", "evs.celp_mdct_core",
1037 FT_UINT8
, BASE_DEC
, VALS(evs_celp_or_mdct_core_values
), 0x0,
1040 { &hf_evs_tcx_or_hq_mdct_core
,
1041 { "TCX/HQ-MDCT core", "evs.tcx_hq_mdct_core",
1042 FT_UINT8
, BASE_DEC
, VALS(evs_tcx_or_hq_mdct_core_values
), 0x0,
1046 { "CNG type", "evs.sid.cng",
1047 FT_UINT8
, BASE_DEC
, VALS(evs_sid_cng_values
), 0x0,
1050 { &hf_evs_celp_sample_rate
,
1051 { "CELP Sample Rate", "evs.sid.celp_sample_rate",
1052 FT_UINT8
, BASE_DEC
, VALS(evs_sid_celp_sample_rate_values
), 0x0,
1055 { &hf_evs_core_sample_rate
,
1056 { "Core sampling rate indicator", "evs.sid.core_sample_rate",
1057 FT_UINT8
, BASE_DEC
, VALS(evs_sid_celp_sample_rate_values
), 0x0,
1060 { &hf_evs_132_bwctrf_idx
,
1061 { "BW CT RF Index", "evs.132.bwctrf_idx",
1062 FT_UINT8
, BASE_DEC
, VALS(evs_132_bwctrf_idx_vals
), 0x0,
1065 { &hf_evs_28_frame_type
,
1066 { "Frame type", "evs.28.frame_type",
1067 FT_UINT8
, BASE_DEC
, VALS(evs_28_frame_type_vals
), 0x0,
1070 { &hf_evs_28_bw_ppp_nelp
,
1071 { "BW PPP/NELP", "evs.28.bw_ppp_nelp",
1072 FT_UINT8
, BASE_DEC
, VALS(evs_28_bw_ppp_nelp_vals
), 0x0,
1075 { &hf_evs_72_80_bwct_idx
,
1076 { "BW CT Index", "evs.72.80.bwct_idx",
1077 FT_UINT8
, BASE_DEC
, VALS(evs_72_80_bwct_idx_vals
), 0x0,
1080 { &hf_evs_320_bwct_idx
,
1081 { "BW CT Index", "evs.320.bwct_idx",
1082 FT_UINT8
, BASE_DEC
, VALS(evs_320_bwct_idx_vals
), 0x0,
1085 { &hf_evs_640_bwct_idx
,
1086 { "BW CT Index", "evs.640.bwct_idx",
1087 FT_UINT8
, BASE_DEC
, VALS(evs_640_bwct_idx_vals
), 0x0,
1093 /* Setup protocol subtree array */
1094 static int *ett
[] = {
1098 &ett_evs_voice_data
,
1102 /* Register the protocol name and description */
1103 proto_evs
= proto_register_protocol("Enhanced Voice Services", "EVS", "evs");
1105 /* Required function calls to register the header fields and subtrees used */
1106 proto_register_field_array(proto_evs
, hf
, array_length(hf
));
1107 proto_register_subtree_array(ett
, array_length(ett
));
1109 evs_module
= prefs_register_protocol(proto_evs
, NULL
);
1111 prefs_register_obsolete_preference(evs_module
, "dynamic.payload.type");
1112 prefs_register_bool_preference(evs_module
, "hf_only",
1113 "Header-Full format only",
1114 "Decode payload assuming that Header-Full format only is used",
1117 evs_handle
= register_dissector("evs", dissect_evs
, proto_evs
);
1121 proto_reg_handoff_evs(void)
1123 dissector_add_string("rtp_dyn_payload_type", "EVS", evs_handle
);
1124 dissector_add_uint_range_with_preference("rtp.pt", "", evs_handle
);
1125 proto_rtp
= proto_get_id_by_filter_name("rtp");
1129 * Editor modelines - https://www.wireshark.org/tools/modelines.html
1134 * indent-tabs-mode: nil
1137 * vi: set shiftwidth=4 tabstop=8 expandtab:
1138 * :indentSize=4:tabSize=8:noTabs=true: