• <ins id="pjuwb"></ins>
    <blockquote id="pjuwb"><pre id="pjuwb"></pre></blockquote>
    <noscript id="pjuwb"></noscript>
          <sup id="pjuwb"><pre id="pjuwb"></pre></sup>
            <dd id="pjuwb"></dd>
            <abbr id="pjuwb"></abbr>

            牽著老婆滿街逛

            嚴(yán)以律己,寬以待人. 三思而后行.
            GMail/GTalk: yanglinbo#google.com;
            MSN/Email: tx7do#yahoo.com.cn;
            QQ: 3 0 3 3 9 6 9 2 0 .

            CELT編碼解碼

            轉(zhuǎn)載自:https://gist.github.com/haxar/2402477


            解碼:

             
            #include 
            <stdio.h>
            #include 
            <stdlib.h>
            #include 
            <stdint.h>
            #include 
            <string.h>
            #include 
            <unistd.h>
            #include 
            <errno.h>
             
            #include 
            "celt.h"
             
            int
            main(
            int argc, char **argv) {
                
            char data[2048= { };
                
            short pcm[2048= { };
                
            int rate        = 48000;
                
            int framesize   = 960;
                
            int channels    = 1;
                
            int tmp;
                
            int rem;
                
            void *mode;
                
            void *state;
                uint16_t len;
             
                
            while ((tmp = getopt(argc, argv, "r:f:c:")) != -1{
                    
            switch (tmp) {
                      
            case 'r':
                        rate 
            = atoi(optarg);
                        
            break;
                      
            case 'f':
                        framesize 
            = atoi(optarg);
                        
            break;
                      
            case 'c':
                        channels 
            = atoi(optarg);
                        
            break;
                    }

                }

                
            if (!(mode = celt_mode_create(rate, framesize, &tmp))) {
                    fprintf(stderr, 
            "error: celt_mode_create: %s\n", celt_strerror(tmp));
                    
            return 1;
                }

                
            if (!(state = celt_decoder_create_custom(mode, channels, &tmp))) {
                    fprintf(stderr, 
            "error: celt_decoder_create_custom: %s\n", celt_strerror(tmp));
                    celt_mode_destroy(mode);
                    
            return 1;
                }

             
                
            for (len = 0;;) {
                    
            if (!len) {
                        
            if (read(STDIN_FILENO, &len, sizeof(len)) != sizeof(len)) {
                            
            break;
                        }

                        
            if (len > sizeof(data)) {
                            fprintf(stderr, 
            "error: celt packet larger than buffer\n");
                            celt_decoder_destroy(state);
                            celt_mode_destroy(mode);
                            
            return 1;
                        }

                        rem 
            = len;
                    }

                    
            if ((tmp = read(STDIN_FILENO, data + (len - rem), rem)) < 0{
                        fprintf(stderr, 
            "error: read: %s\n", strerror(errno));
                        celt_decoder_destroy(state);
                        celt_mode_destroy(mode);
                        
            return 1;
                    }

                    
            if (!tmp) {
                        
            break;
                    }

                    
            if (tmp != rem) {
                        rem 
            -= tmp;
                        
            continue;
                    }

                    
            if ((tmp = celt_decode(state, (void *)data, len, pcm, framesize)) < 0{
                        fprintf(stderr, 
            "error: celt_decode: %s\n", celt_strerror(tmp));
                        celt_decoder_destroy(state);
                        celt_mode_destroy(mode);
                        
            return 1;
                    }

                    len 
            = 0;
                    
            if (write(STDOUT_FILENO, pcm, sizeof(*pcm) * framesize * channels) < 0{
                        fprintf(stderr, 
            "error: write: %s\n", strerror(errno));
                        celt_decoder_destroy(state);
                        celt_mode_destroy(mode);
                        
            return 1;
                    }

                }

             
                celt_decoder_destroy(state);
                celt_mode_destroy(mode);
             
                
            return 0;
            }



            編碼:
            #include <stdio.h>
            #include 
            <stdlib.h>
            #include 
            <stdint.h>
            #include 
            <string.h>
            #include 
            <unistd.h>
            #include 
            <errno.h>
             
            #include 
            "celt.h"
             
            int
            main(
            int argc, char **argv) {
                
            short pcm[2048= { };
                
            char data[2048= { };
                
            int rate        = 48000;
                
            int framesize   = 960;
                
            int channels    = 1;
                
            int bitrate     = 0;
                
            int variable    = 0;
                
            int prediction  = 2;
                
            int complexity  = 10;
                
            int tmp;
                
            int rem;
                
            void *mode;
                
            void *state;
                uint16_t len;
             
                
            while ((tmp = getopt(argc, argv, "r:f:c:b:vp:x:")) != -1{
                    
            switch (tmp) {
                      
            case 'r':
                        rate 
            = atoi(optarg);
                        
            break;
                      
            case 'f':
                        framesize 
            = atoi(optarg);
                        
            break;
                      
            case 'c':
                        channels 
            = atoi(optarg);
                        
            break;
                      
            case 'b':
                        bitrate 
            = atoi(optarg);
                        
            break;
                      
            case 'v':
                        variable 
            = 1;
                        
            break;
                      
            case 'p':
                        prediction 
            = atoi(optarg);
                        
            break;
                      
            case 'x':
                        complexity 
            = atoi(optarg);
                        
            break;
                    }

                }

                
            if (!(mode = celt_mode_create(rate, framesize, &tmp))) {
                    fprintf(stderr, 
            "error: celt_mode_create: %s\n", celt_strerror(tmp));
                    
            return 1;
                }

                
            if (!(state = celt_encoder_create_custom(mode, channels, &tmp))) {
                    fprintf(stderr, 
            "error: celt_encoder_create_custom: %s\n", celt_strerror(tmp));
                    celt_mode_destroy(mode);
                    
            return 1;
                }

                
            if (bitrate && celt_encoder_ctl(state, CELT_SET_BITRATE(bitrate)) != CELT_OK) {
                    fprintf(stderr, 
            "error: celt_encoder_ctl: CELT_SET_BITRATE: bitrate request failed\n");
                    celt_encoder_destroy(state);
                    celt_mode_destroy(mode);
                    
            return 1;
                }

                
            if (variable && celt_encoder_ctl(state, CELT_SET_VBR(variable)) != CELT_OK) {
                    fprintf(stderr, 
            "error: celt_encoder_ctl: CELT_SET_VBR: vbr request failed\n");
                    celt_encoder_destroy(state);
                    celt_mode_destroy(mode);
                    
            return 1;
                }

                
            if (celt_encoder_ctl(state, CELT_SET_PREDICTION(prediction)) != CELT_OK) {
                    fprintf(stderr, 
            "error: celt_encoder_ctl: CELT_SET_PREDICTION: prediction request failed\n");
                    celt_encoder_destroy(state);
                    celt_mode_destroy(mode);
                    
            return 1;
                }

                
            if (celt_encoder_ctl(state, CELT_SET_COMPLEXITY(complexity)) != CELT_OK) {
                    fprintf(stderr, 
            "error: celt_encoder_ctl: CELT_SET_COMPLEXITY: complexity 0 through 10 is only supported\n");
                    celt_encoder_destroy(state);
                    celt_mode_destroy(mode);
                    
            return 1;
                }

             
                
            for (len = 0;;) {
                    
            if (!len) {
                        len 
            = sizeof(*pcm) * framesize * channels;
                        
            if (len > sizeof(pcm)) {
                            fprintf(stderr, 
            "error: pcm frame larger than buffer\n");
                            celt_encoder_destroy(state);
                            celt_mode_destroy(mode);
                            
            return 1;
                        }

                        rem 
            = len;
                    }

                    
            if ((tmp = read(STDIN_FILENO, (void *)pcm + (len - rem), rem)) < 0{
                        fprintf(stderr, 
            "error: read: %s\n", strerror(errno));
                        celt_encoder_destroy(state);
                        celt_mode_destroy(mode);
                        
            return 1;
                    }

                    
            if (!tmp) {
                        
            break;
                    }

                    
            if (tmp != rem) {
                        rem 
            -= tmp;
                        
            continue;
                    }

                    
            if ((tmp = celt_encode(state, pcm, framesize, (void *)data, sizeof(data))) < 0{
                        fprintf(stderr, 
            "error: celt_encode: %s\n", celt_strerror(tmp));
                        celt_encoder_destroy(state);
                        celt_mode_destroy(mode);
                        
            return 1;
                    }

                    len 
            = tmp;
                    
            if (write(STDOUT_FILENO, &len, sizeof(len)) < 0 || write(STDOUT_FILENO, data, len) < 0{
                        fprintf(stderr, 
            "error: write: %s\n", strerror(errno));
                        celt_encoder_destroy(state);
                        celt_mode_destroy(mode);
                        
            return 1;
                    }

                    len 
            = 0;
                }

             
                celt_encoder_destroy(state);
                celt_mode_destroy(mode);
             
                
            return 0;
            }


            posted on 2013-02-10 13:09 楊粼波 閱讀(1764) 評(píng)論(0)  編輯 收藏 引用


            只有注冊(cè)用戶登錄后才能發(fā)表評(píng)論。
            網(wǎng)站導(dǎo)航: 博客園   IT新聞   BlogJava   博問(wèn)   Chat2DB   管理


            综合人妻久久一区二区精品| 久久国产亚洲高清观看| 天天影视色香欲综合久久| 久久婷婷色综合一区二区| 亚洲а∨天堂久久精品9966| 久久婷婷午色综合夜啪| 亚洲精品乱码久久久久久久久久久久 | 国产成人精品久久亚洲| 久久九色综合九色99伊人| 色偷偷91久久综合噜噜噜噜| 伊人久久大香线蕉综合Av| 国产精品对白刺激久久久| 国产精品99久久久久久董美香| 欧美色综合久久久久久| 狠狠色婷婷久久一区二区| 国产精品久久久久国产A级| 狠狠精品久久久无码中文字幕 | 久久综合给久久狠狠97色 | 精品熟女少妇aⅴ免费久久| 中文字幕无码久久精品青草 | 午夜精品久久久久久| 亚洲午夜久久久久久久久电影网| 国产精品久久久久久久久免费| 国内精品久久久久久久久电影网| 人妻无码精品久久亚瑟影视| 久久免费的精品国产V∧| 久久99精品久久久久久秒播 | 久久中文字幕一区二区| 欧美一级久久久久久久大| 久久人人妻人人爽人人爽| 久久精品成人免费观看97| 久久综合国产乱子伦精品免费| 久久精品成人免费国产片小草| 久久香蕉超碰97国产精品| 久久人人爽人人爽人人片AV麻豆| 久久精品国产亚洲av水果派| 免费一级欧美大片久久网| 99久久99久久精品免费看蜜桃 | 亚洲午夜精品久久久久久app| 99久久婷婷国产综合亚洲| 欧美日韩精品久久久免费观看|