⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 araw.c

📁 video linux conference
💻 C
📖 第 1 页 / 共 5 页
字号:
    msg_Dbg( p_dec, "samplerate:%dHz channels:%d bits/sample:%d",             p_dec->fmt_in.audio.i_rate, p_dec->fmt_in.audio.i_channels,             p_dec->fmt_in.audio.i_bitspersample );    if( p_dec->fmt_in.i_codec == VLC_FOURCC( 'f', 'l', '6', '4' ) )    {        p_dec->fmt_out.i_codec = p_dec->fmt_in.i_codec;        p_dec->fmt_in.audio.i_bitspersample = 64;    }    else if( p_dec->fmt_in.i_codec == VLC_FOURCC( 'f', 'l', '3', '2' ) )    {        p_dec->fmt_out.i_codec = p_dec->fmt_in.i_codec;        p_dec->fmt_in.audio.i_bitspersample = 32;    }    else if( p_dec->fmt_in.i_codec == VLC_FOURCC( 's', '3', '2', 'l' ) ||             p_dec->fmt_in.i_codec == VLC_FOURCC( 's', '3', '2', 'b' ) )    {        p_dec->fmt_out.i_codec = p_dec->fmt_in.i_codec;        p_dec->fmt_in.audio.i_bitspersample = 32;    }    else if( p_dec->fmt_in.i_codec == VLC_FOURCC( 's', '2', '4', 'l' ) ||             p_dec->fmt_in.i_codec == VLC_FOURCC( 's', '2', '4', 'b' ) )    {        p_dec->fmt_out.i_codec = p_dec->fmt_in.i_codec;        p_dec->fmt_in.audio.i_bitspersample = 24;    }    else if( p_dec->fmt_in.i_codec == VLC_FOURCC( 's', '1', '6', 'l' ) ||             p_dec->fmt_in.i_codec == VLC_FOURCC( 's', '1', '6', 'b' ) )    {        p_dec->fmt_out.i_codec = p_dec->fmt_in.i_codec;        p_dec->fmt_in.audio.i_bitspersample = 16;    }    else if( p_dec->fmt_in.i_codec == VLC_FOURCC( 's', '8', ' ', ' ' ) ||             p_dec->fmt_in.i_codec == VLC_FOURCC( 'u', '8', ' ', ' ' ) )    {        p_dec->fmt_out.i_codec = p_dec->fmt_in.i_codec;        p_dec->fmt_in.audio.i_bitspersample = 8;    }    else if( p_dec->fmt_in.i_codec == VLC_FOURCC( 'a', 'f', 'l', 't' ) )    {        switch( ( p_dec->fmt_in.audio.i_bitspersample + 7 ) / 8 )        {        case 4:            p_dec->fmt_out.i_codec = VLC_FOURCC('f','l','3','2');            break;        case 8:            p_dec->fmt_out.i_codec = VLC_FOURCC('f','l','6','4');            break;        default:            msg_Err( p_dec, "bad parameters(bits/sample)" );            return VLC_EGENERIC;        }    }    else if( p_dec->fmt_in.i_codec == VLC_FOURCC( 'a', 'r', 'a', 'w' ) )    {        switch( ( p_dec->fmt_in.audio.i_bitspersample + 7 ) / 8 )        {        case 1:            p_dec->fmt_out.i_codec = VLC_FOURCC('u','8',' ',' ');            break;        case 2:            p_dec->fmt_out.i_codec = VLC_FOURCC('s','1','6','l');            break;        case 3:            p_dec->fmt_out.i_codec = VLC_FOURCC('s','2','4','l');            break;        case 4:            p_dec->fmt_out.i_codec = VLC_FOURCC('s','3','2','l');            break;        default:            msg_Err( p_dec, "bad parameters(bits/sample)" );            return VLC_EGENERIC;        }    }    else if( p_dec->fmt_in.i_codec == VLC_FOURCC( 't', 'w', 'o', 's' ) )    {        switch( ( p_dec->fmt_in.audio.i_bitspersample + 7 ) / 8 )        {        case 1:            p_dec->fmt_out.i_codec = VLC_FOURCC('s','8',' ',' ');            break;        case 2:            p_dec->fmt_out.i_codec = VLC_FOURCC('s','1','6','b');            break;        case 3:            p_dec->fmt_out.i_codec = VLC_FOURCC('s','2','4','b');            break;        case 4:            p_dec->fmt_out.i_codec = VLC_FOURCC('s','3','2','b');            break;        default:            msg_Err( p_dec, "bad parameters(bits/sample)" );            return VLC_EGENERIC;        }    }    else if( p_dec->fmt_in.i_codec == VLC_FOURCC( 's', 'o', 'w', 't' ) )    {        switch( ( p_dec->fmt_in.audio.i_bitspersample + 7 ) / 8 )        {        case 1:            p_dec->fmt_out.i_codec = VLC_FOURCC('s','8',' ',' ');            break;        case 2:            p_dec->fmt_out.i_codec = VLC_FOURCC('s','1','6','l');            break;        case 3:            p_dec->fmt_out.i_codec = VLC_FOURCC('s','2','4','l');            break;        case 4:            p_dec->fmt_out.i_codec = VLC_FOURCC('s','3','2','l');            break;        default:            msg_Err( p_dec, "bad parameters(bits/sample)" );            return VLC_EGENERIC;        }    }    else if( p_dec->fmt_in.i_codec == VLC_FOURCC( 'a', 'l', 'a', 'w' ) )    {        p_dec->fmt_out.i_codec = AOUT_FMT_S16_NE;        p_sys->p_logtos16  = alawtos16;        p_dec->fmt_in.audio.i_bitspersample = 8;    }    else if( p_dec->fmt_in.i_codec == VLC_FOURCC( 'u', 'l', 'a', 'w' ) ||             p_dec->fmt_in.i_codec == VLC_FOURCC( 'm', 'l', 'a', 'w' ) )    {        p_dec->fmt_out.i_codec = AOUT_FMT_S16_NE;        p_sys->p_logtos16  = ulawtos16;        p_dec->fmt_in.audio.i_bitspersample = 8;    }    /* Set output properties */    p_dec->fmt_out.i_cat = AUDIO_ES;    p_dec->fmt_out.audio.i_rate = p_dec->fmt_in.audio.i_rate;    p_dec->fmt_out.audio.i_channels = p_dec->fmt_in.audio.i_channels;    p_dec->fmt_out.audio.i_bitspersample = p_dec->fmt_in.audio.i_bitspersample;    p_dec->fmt_out.audio.i_physical_channels =        p_dec->fmt_out.audio.i_original_channels =            pi_channels_maps[p_dec->fmt_in.audio.i_channels];    if( p_dec->fmt_in.audio.i_physical_channels )        p_dec->fmt_out.audio.i_physical_channels =            p_dec->fmt_in.audio.i_physical_channels;    if( p_dec->fmt_in.audio.i_original_channels )        p_dec->fmt_out.audio.i_original_channels =            p_dec->fmt_in.audio.i_original_channels;    if( p_dec->fmt_in.i_codec == VLC_FOURCC( 'a', 'l', 'a', 'w' ) ||        p_dec->fmt_in.i_codec == VLC_FOURCC( 'u', 'l', 'a', 'w' ) ||        p_dec->fmt_in.i_codec == VLC_FOURCC( 'm', 'l', 'a', 'w' ) )    {        p_dec->fmt_out.audio.i_bitspersample = 16;    }    aout_DateInit( &p_sys->end_date, p_dec->fmt_out.audio.i_rate );    aout_DateSet( &p_sys->end_date, 0 );    p_dec->pf_decode_audio = DecodeBlock;    return VLC_SUCCESS;}/**************************************************************************** * DecodeBlock: the whole thing **************************************************************************** * This function must be fed with whole samples (see nBlockAlign). ****************************************************************************/static aout_buffer_t *DecodeBlock( decoder_t *p_dec, block_t **pp_block ){    decoder_sys_t *p_sys = p_dec->p_sys;    block_t *p_block;    aout_buffer_t *p_out;    int i_samples;    if( !pp_block || !*pp_block ) return NULL;    p_block = *pp_block;    if( p_block->i_pts != 0 &&        p_block->i_pts != aout_DateGet( &p_sys->end_date ) )    {        aout_DateSet( &p_sys->end_date, p_block->i_pts );    }    else if( !aout_DateGet( &p_sys->end_date ) )    {        /* We've just started the stream, wait for the first PTS. */        block_Release( p_block );        return NULL;    }    /* Don't re-use the same pts twice */    p_block->i_pts = 0;    i_samples = p_block->i_buffer * 8 / p_dec->fmt_in.audio.i_bitspersample /        p_dec->fmt_in.audio.i_channels;    if( i_samples <= 0 )    {        block_Release( p_block );        return NULL;    }    /* Create chunks of max 1024 samples */    i_samples = __MIN( i_samples, 1024 );    p_out = p_dec->pf_aout_buffer_new( p_dec, i_samples );    if( p_out == NULL )    {        block_Release( p_block );        return NULL;    }    p_out->start_date = aout_DateGet( &p_sys->end_date );    p_out->end_date   = aout_DateIncrement( &p_sys->end_date, i_samples );    if( p_sys->p_logtos16 )    {        int16_t *s = (int16_t*)p_out->p_buffer;        unsigned int i;        for( i = 0; i < p_out->i_nb_bytes / 2; i++ )        {            *s++ = p_sys->p_logtos16[*p_block->p_buffer++];

⌨️ 快捷键说明

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