FreeCalypso > hg > gsm-codec-lib
view hrutil/hex2rpf.c @ 586:b21ea4ab586d
libgsmhr1: update for TW-TS-002 version 1.2.0
The component of libgsmhr1 being changed is RTP input functions;
the change is accepting FT=1 (invalid SID) frames both with and
without payload data bits.
author | Mychaela Falconia <falcon@freecalypso.org> |
---|---|
date | Mon, 10 Mar 2025 02:03:31 +0000 |
parents | 62fe499ffc15 |
children |
line wrap: on
line source
/* * This program reads a TW-TS-005 Annex B hexadecimal file and converts it to * ETSI TS 101 318 raw packed format (good frames only, 14 bytes per frame). */ #include <stdio.h> #include <stdint.h> #include <stdlib.h> #include <string.h> #include <strings.h> #include "../libgsmhr1/tw_gsmhr.h" #include "../libtest/tw5reader.h" main(argc, argv) char **argv; { FILE *inf, *outf; unsigned lineno; uint8_t frame[TWTS005_MAX_FRAME], canon[GSMHR_FRAME_LEN_5993]; unsigned frame_len, ft; int rc; if (argc != 3) { fprintf(stderr, "usage: %s input.hex output.hrpf\n", argv[0]); exit(1); } inf = fopen(argv[1], "r"); if (!inf) { perror(argv[1]); exit(1); } outf = fopen(argv[2], "w"); if (!outf) { perror(argv[2]); exit(1); } lineno = 0; for (;;) { rc = twts005_read_frame(inf, &lineno, frame, &frame_len); if (rc < 0) { fprintf(stderr, "%s line %u: not valid TW-TS-005\n", argv[1], lineno); exit(1); } if (!rc) break; rc = gsmhr_rtp_in_preen(frame, frame_len, canon); if (rc < 0) { fprintf(stderr, "%s line %u: not a valid GSM-HR frame\n", argv[1], lineno); exit(1); } ft = canon[0] >> 4; switch (ft) { case 0: break; case 2: gsmhr_ts101318_set_sid_codeword(canon + 1); break; default: fprintf(stderr, "%s line %u: frame type %u not valid for RPF\n", argv[1], lineno, ft); exit(1); } fwrite(canon + 1, 1, GSMHR_FRAME_LEN_RPF, outf); } exit(0); }