Rate This Document
Findability
Accuracy
Completeness
Readability

GSMHR

Decodes 112-bit GSMHR audio data streams into the PCM format.

The function calling process is as follows:

  1. Obtain the size of the memory to be applied for decoding (dstBufLen).
  2. Initialize the HmppaGsmhrDecodePolicy_16s structure by calling HMPPA_Gsmhr_DecodeInit_8u16s.
  3. Call the main function HMPPA_Gsmhr_Decode_8u16s for decoding.
  4. Call HMPPA_Gsmhr_DecodeRelease_8u16s to release the memory contained in the HmppaGsmhrDecodePolicy_16s structure.

The function interface declaration is as follows:

  • Obtaining the size of the memory to be applied for decoding:

    HmppResult HMPPA_Gsmhr_GetDecodeDstBufLen_8u16s(const uint8_t *src, int32_t len, int32_t *dstBufLen);

  • Initialization:

    HmppResult HMPPA_Gsmhr_DecodeInit_8u16s(HmppaGsmhrDecodePolicy_16s **policy);

  • Decoding:

    HmppResult HMPPA_Gsmhr_Decode_8u16s(const uint8_t *src, int32_t len, int16_t *dst, HmppaGsmhrDecodePolicy_16s *policy, int32_t *bytesConsumed, int64_t *bytesDecoded);

  • Release:

    HmppResult HMPPA_Gsmhr_DecodeRelease_8u16s(HmppaGsmhrDecodePolicy_16s *policy);

Parameters

Parameter

Description

Value Range

Input/Output

src

Pointer to the GSMHR stream to be decoded

The value cannot be NULL.

Input

len

Length of the GSMHR stream to be decoded, in bytes

(0, INT_MAX]

Input

dst

Pointer to the destination vector

The value cannot be NULL.

Output

policy

Pointer to the GSMHR structure

The value cannot be NULL.

Input/Output

bytesConsumed

Pointer to the data stream length (in bytes) actually consumed for decoding

  • Input: can be left blank or not
  • Output: If the input is left blank, no output is generated. If the input is configured, the output range is [0, len].

Output

bytesDecoded

Pointer to the data stream length (in bytes) of the actual decoded output

  • Input: can be left blank or not
  • Output: If the input is left blank, no output is generated. If the input is configured, the output range is [0, Theoretical output data stream length after decoding].

Output

Return Value

  • Success: HMPP_STS_NO_ERR
  • Failure: An error code is returned.

Error Codes

Error Code

Description

HMPP_STS_NULL_PTR_ERR

Any of the input pointers is NULL.

HMPP_STS_SIZE_ERR

The value of len is not a positive number.

HMPP_STS_SIZE_WRN

The src is not completely decoded.

Example

#include<stdlib.h>
#include<stdio.h>
#include"hmppa.h"
#define ONE_FRAME_GSM 14
#define ONE_FRAME_PCM 160
int main(int argc, char* argv[])
{
    if (argc <3) {
        printf("%s in.gsmfr out.pcm\n", argv[0]);
        return 0;
    }
    FILE *file =fopen(argv[1], "rb");
    if (file ==NULL) {
        printf("Open File %s Failed\n", argv[1]);
        return 0;
    }
    fseek(file, 0, SEEK_END);
    int32_t srcLen =ftell(file);
    int32_t dstLen;
    HMPPA_Gsmhr_GetDecodeDstBufLen_8u16s(srcLen, &dstLen);
    fseek(file, 0, SEEK_SET);
    unsigned char src[srcLen];
    short pcm[dstLen];
    HmppaGsmhrDecodePolicy_16s *policy;
    HMPPA_Gsmhr_DecodeInit_8u16s(&policy);
    FILE *out = fopen(argv[2], "wb");
    if (out == NULL) {
        printf("Open File %s Failed\n", argv[2]);
        return 0;
    }
    fread(src, sizeof(unsignedchar), srcLen, file);
    int bytesConsumed, bytesDecoded;
    int res = HMPPA_Gsmhr_Decode_8u16s(src, srcLen, pcm, policy, &bytesConsumed, &bytesDecoded);
    HMPPA_Gsmhr_DecodeRelease_8u16s(policy);
    printf("bytesConsumed = %d, bytesDecoded = %d, res = %d\n", bytesConsumed, bytesDecoded, res);
    fwrite(pcm, sizeof(short), bytesDecoded / 2, out);
}

Output:

bytesConsumed = 2212, bytesDecoded = 50560, res = 0