g711dec.c

来自「linux下的sip voip程序」· C语言 代码 · 共 73 行

C
73
字号
#include <stdio.h>#define BIAS    132    /* バイアスの猛 */void disp_c(unsigned char value);void disp_s(short value);short g711decode(unsigned char ulaw_sample);int main(int argv, char **argc){    int i;    unsigned char mu[8]={            /* デコ〖ド涟 | デコ〖ド稿 */         0, /* 0 000 0000 | 1000001010000100 */        17, /* 0 001 0001 | 1100001110000100 */        34, /* 0 010 0010 | 1110001100000100 */        51, /* 0 011 0011 | 1111001001000100 */        68, /* 0 100 0100 | 1111100110100100 */        89, /* 0 101 1001 | 1111110110110100 */       108, /* 0 110 1100 | 1111111101001100 */       123  /* 0 111 1011 | 1111111111100000 */    };    /* テスト */    for (i = 0; i < 8; i++ ){        disp_c(mu[i]);        g711decode( mu[i] );         printf("\n");    }    return 0;}/* デコ〖ド簇眶 */short g711decode(unsigned char ulaw_sample){    short audio_sample;    int t;    ulaw_sample = ~ulaw_sample;    t = ((ulaw_sample & 0x0f) << 3) + BIAS;    t <<= (ulaw_sample & 0x70) >> 4;    audio_sample = ((ulaw_sample & 0x80) ? (BIAS - t) : (t - BIAS));    return audio_sample;}/* shortの2渴眶山绩簇眶 */void disp_s(short value){    int i;    printf("\t");    for( i = 0x8000; i > 0; i >>= 1 ){       if(value & i ){           printf("1");       }else{           printf("0");       }    }}/* unsigned char の2渴眶山绩簇眶 */void disp_c(unsigned char value){    int i;    printf("\t");    for( i = 0x80; i > 0; i >>= 1 ){        if(value & i ){            printf("1");        }else{            printf("0");        }    }}

⌨️ 快捷键说明

复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?