• <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>

            牽著老婆滿街逛

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

            CELT編碼解碼

            轉載自: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 楊粼波 閱讀(1767) 評論(0)  編輯 收藏 引用

            久久精品视频一| 久久se精品一区精品二区| 久久久久人妻一区精品| 伊人久久大香线蕉成人| 国产精品一久久香蕉产线看| 青青热久久综合网伊人| 久久天天躁狠狠躁夜夜不卡 | 无码国内精品久久人妻麻豆按摩| 久久久久人妻一区二区三区| 久久伊人精品青青草原高清| 伊人久久国产免费观看视频| 国产91色综合久久免费分享| 日本五月天婷久久网站| 一级做a爱片久久毛片| 久久久久久久免费视频| 99久久婷婷国产综合精品草原| 伊人久久大香线蕉精品不卡 | 色偷偷偷久久伊人大杳蕉| 久久93精品国产91久久综合| 77777亚洲午夜久久多喷| 久久精品免费一区二区| 无码任你躁久久久久久久| 精品精品国产自在久久高清| 无码专区久久综合久中文字幕 | 国内精品久久久久久99蜜桃| 亚洲欧美另类日本久久国产真实乱对白 | 久久性生大片免费观看性| 久久电影网2021| 久久精品国产91久久综合麻豆自制| 99久久99久久精品国产片果冻| 欧美日韩精品久久久久| 精品国产一区二区三区久久蜜臀| 国产精品久久久久AV福利动漫| 蜜臀久久99精品久久久久久小说 | 色综合久久最新中文字幕| 18岁日韩内射颜射午夜久久成人 | 曰曰摸天天摸人人看久久久| 国产情侣久久久久aⅴ免费| 午夜精品久久久久久久久| 精品熟女少妇av免费久久| 久久天堂AV综合合色蜜桃网 |