• <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 楊粼波 閱讀(1775) 評論(0)  編輯 收藏 引用

            久久婷婷五月综合国产尤物app | 久久久亚洲裙底偷窥综合| 区久久AAA片69亚洲| 久久国产欧美日韩精品| 7777久久亚洲中文字幕| 久久亚洲AV永久无码精品| 精品多毛少妇人妻AV免费久久 | 久久久久AV综合网成人| 欧美激情精品久久久久久久九九九 | 麻豆精品久久久久久久99蜜桃 | 欧美午夜A∨大片久久 | 久久99国产精品久久| 狠狠色丁香婷婷久久综合五月| 国产麻豆精品久久一二三| 午夜精品久久久内射近拍高清 | 国产高清国内精品福利99久久| 欧美亚洲国产精品久久| 99久久精品费精品国产| 国产成人久久AV免费| 久久99九九国产免费看小说| 99久久国产免费福利| 久久国产精品久久| 久久久久高潮毛片免费全部播放 | 亚洲Av无码国产情品久久| 99久久亚洲综合精品网站| 久久精品国产亚洲av麻豆小说| 欧美精品乱码99久久蜜桃| 久久精品无码一区二区app| 久久久久中文字幕| 国产精品对白刺激久久久| 天天躁日日躁狠狠久久| 亚洲国产精品无码久久久不卡| 性欧美大战久久久久久久| 久久无码人妻精品一区二区三区| 国产精品九九久久精品女同亚洲欧美日韩综合区| 无码人妻少妇久久中文字幕蜜桃| 一级a性色生活片久久无少妇一级婬片免费放 | 亚洲国产成人久久精品影视| 狠狠色丁香久久综合婷婷| 99久久99久久精品国产片| 久久综合亚洲色HEZYO国产|