zoukankan      html  css  js  c++  java
  • libmad 解码库用法

    //初始化
    mad_stream_init(&pDecoder->stream);
    mad_frame_init(&pDecoder->frame);
    mad_timer_reset(&(pDecoder->timer));
    mad_synth_init(&pDecoder->synth);
    mad_stream_options(&pDecoder->stream, MAD_OPTION_IGNORECRC);
    
    //解码过程
    mad_stream_buffer(stream, pBuffer, mlength);
    while(1){
            if(pMad->nMadFlag&MAD_HEADER_FLAG)
            {
                if(-1==mad_header_decode(&pMad->frame.header,&pMad->stream)){
                    if(!MAD_RECOVERABLE(pMad->stream.error))
                        break;
    
    
                }
                mResult=wzMadReadHeader(pBuffer,ulSize,&pMad->stream);
                MADDECODER_ERROR(mResult,nResult);
            }
            if(-1==mad_frame_decode(&pMad->frame,&pMad->stream))
            {
                if (!MAD_RECOVERABLE(pMad->stream.error))
                    break;
            }
            else
                pMad->nBadLastFrame=0;
            if(pMad->nMadFlag&MAD_FILTER_FLAG)
            {
                mResult=wzMadFilter(pBuffer,ulSize,
                    &pMad->stream,&pMad->frame);
                MADDECODER_ERROR(mResult,nResult);
            }
            mad_timer_add(&pMad->timer,pMad->frame.header.duration);
            mad_synth_frame(&pMad->synth,&pMad->frame);
            if(pMad->push_buffer)
            {
               //write file
                MADDECODER_ERROR(mResult,nResult);
            }
        }
    
    //释放资源
    mad_synth_finish(&pMad->synth);
    mad_frame_finish(&pMad->frame);
    mad_stream_finish(&pMad->stream);


    以上代码摘自官方例子,自己只是做了一些简单的修改。

    以上代码兼容所有平台。

    from:http://blog.csdn.net/weinyzhou/article/details/7657958

    版权所有,禁止转载


  • 相关阅读:
    Nginx proxy开启cache缓存
    Nginx Server 配置
    nginx 全局配置
    Nginx 配置文件解析
    Python-Scrapy框架
    Python-shutil模块
    os模块3
    os模块
    python os模块atime ,ctime,mtime意义
    Python-正则表达式
  • 原文地址:https://www.cnblogs.com/weinyzhou/p/4983480.html
Copyright © 2011-2022 走看看