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

📄 voc.c

📁 uclinux 下的vlc播放器源代码
💻 C
📖 第 1 页 / 共 2 页
字号:
                else                    p_sys->i_loop_count--;            }            break;        case 8:             /*              * Block 8 is a big kludge to add stereo support to block 1 :             * A block of type 8 is always followed by a block of type 1             * and specifies the number of channels in that 1-block             * (normally block 1 are always mono). In practice, block type 9             * is used for stereo rather than 8             */            if( ( i_block_size != 4 )             || ( stream_Read( p_demux->s, buf, 4 ) < 4 ) )                goto corrupt;            if( buf[2] )            {                msg_Err( p_demux, "unsupported compression" );                return VLC_EGENERIC;            }            new_fmt.i_codec = VLC_FOURCC('u','8',' ',' ');            new_fmt.audio.i_channels = buf[3] + 1; /* can't be nul */            new_fmt.audio.i_rate = 256000000L /                          ((65536L - GetWLE(buf)) * new_fmt.audio.i_channels);            new_fmt.audio.i_bytes_per_frame = new_fmt.audio.i_channels;            new_fmt.audio.i_frame_length = 1;            new_fmt.audio.i_blockalign = new_fmt.audio.i_bytes_per_frame;            new_fmt.audio.i_bitspersample = 8 * new_fmt.audio.i_bytes_per_frame;            new_fmt.i_bitrate = new_fmt.audio.i_rate * 8;            /* read subsequent block 1 */            if( stream_Read( p_demux->s, buf, 4 ) < 4 )                return VLC_EGENERIC; /* EOF */                    i_block_size = GetDWLE( buf ) >> 8;            msg_Dbg( p_demux, "new block: type: %u, size: %u",                    (unsigned)*buf, i_block_size );            if( i_block_size < 2 )                goto corrupt;            i_block_size -= 2;            if( stream_Read( p_demux->s, buf, 2 ) < 2 )                goto corrupt;            if( buf[1] )            {                msg_Err( p_demux, "unsupported compression" );                return VLC_EGENERIC;            }            break;        case 9: /* newer data block with channel number and bits resolution */            if( i_block_size < 12 )                goto corrupt;            i_block_size -= 12;            if( ( stream_Read( p_demux->s, buf, 8 ) < 8 )             || ( stream_Read( p_demux->s, NULL, 4 ) < 4 ) )                goto corrupt;            new_fmt.audio.i_rate = GetDWLE( buf );            new_fmt.audio.i_bitspersample = buf[4];            new_fmt.audio.i_channels = buf[5];            switch( GetWLE( &buf[6] ) ) /* format */            {                case 0x0000: /* PCM */                    switch( new_fmt.audio.i_bitspersample )                    {                        case 8:                            new_fmt.i_codec = VLC_FOURCC('u','8',' ',' ');                            break;                        case 16:                            new_fmt.i_codec = VLC_FOURCC('u','1','6','l');                            break;                        default:                            msg_Err( p_demux, "unsupported bit res.: %u bits",                                     new_fmt.audio.i_bitspersample );                            return VLC_EGENERIC;                    }                    break;                case 0x0004: /* signed */                    switch( new_fmt.audio.i_bitspersample )                    {                        case 8:                            new_fmt.i_codec = VLC_FOURCC('s','8',' ',' ');                            break;                        case 16:                            new_fmt.i_codec = VLC_FOURCC('s','1','6','l');                            break;                        default:                            msg_Err( p_demux, "unsupported bit res.: %u bits",                                     new_fmt.audio.i_bitspersample );                            return VLC_EGENERIC;                    }                    break;                default:                     msg_Err( p_demux, "unsupported compression" );                    return VLC_EGENERIC;            }            new_fmt.audio.i_bytes_per_frame = new_fmt.audio.i_channels                * (new_fmt.audio.i_bitspersample / 8);            new_fmt.audio.i_frame_length = 1;            new_fmt.audio.i_blockalign = new_fmt.audio.i_bytes_per_frame;            new_fmt.i_bitrate = 8 * new_fmt.audio.i_rate                                     * new_fmt.audio.i_bytes_per_frame;            break;        default:            msg_Dbg( p_demux, "unknown block type %u - skipping block",                     (unsigned)*buf);        case 4: /* blocks of non-audio types can be skipped */        case 5:            if( stream_Read( p_demux->s, NULL, i_block_size ) < i_block_size )                goto corrupt;            i_block_size = 0;            break;    }    p_sys->i_block_start = stream_Tell( p_demux->s );    p_sys->i_block_end = p_sys->i_block_start + i_block_size;    if( i_block_size || p_sys->i_silence_countdown )    {        /* we've read a block with data in it - update decoder */        msg_Dbg( p_demux, "fourcc: %4.4s, channels: %d, "                 "freq: %d Hz, bitrate: %dKo/s, blockalign: %d, "                 "bits/samples: %d", (char *)&new_fmt.i_codec,                 new_fmt.audio.i_channels, new_fmt.audio.i_rate,                 new_fmt.i_bitrate / 8192, new_fmt.audio.i_blockalign,                 new_fmt.audio.i_bitspersample );        if( ( p_sys->p_es != NULL ) && fmtcmp( &p_sys->fmt, &new_fmt ) )        {            msg_Dbg( p_demux, "codec change needed" );            es_out_Del( p_demux->out, p_sys->p_es );            p_sys->p_es = NULL;        }        if( p_sys->p_es == NULL )        {            memcpy( &p_sys->fmt, &new_fmt, sizeof( p_sys->fmt ) );            date_Change( &p_sys->pts, p_sys->fmt.audio.i_rate, 1 );            p_sys->p_es = es_out_Add( p_demux->out, &p_sys->fmt );        }    }    return VLC_SUCCESS;corrupt:    msg_Err( p_demux, "corrupted file - halting demux" );    return VLC_EGENERIC;}/***************************************************************************** * Demux: read packet and send them to decoders ***************************************************************************** * Returns -1 in case of error, 0 in case of EOF, 1 otherwise *****************************************************************************/#define SAMPLES_BUFFER 1000static int Demux( demux_t *p_demux ){    demux_sys_t *p_sys = p_demux->p_sys;    block_t     *p_block;    int64_t     i_offset, i;    i_offset = stream_Tell( p_demux->s );    while( ( i_offset >= p_sys->i_block_end )         && ( p_sys->i_silence_countdown == 0 ) )        if( ReadBlockHeader( p_demux ) != VLC_SUCCESS )            return 0;    if( p_sys->i_silence_countdown == 0 )    {        i = ( p_sys->i_block_end - i_offset )            / p_sys->fmt.audio.i_bytes_per_frame;        if( i > SAMPLES_BUFFER )            i = SAMPLES_BUFFER;        p_block = stream_Block( p_demux->s,                                p_sys->fmt.audio.i_bytes_per_frame * i );        if( p_block == NULL )        {            msg_Warn( p_demux, "cannot read data" );            return 0;        }    }    else    {   /* emulates silence from the stream */        i = p_sys->i_silence_countdown;        if( i > SAMPLES_BUFFER )            i = SAMPLES_BUFFER;        p_block = block_New( p_demux, i );        if( p_block == NULL )            return VLC_ENOMEM;        memset( p_block->p_buffer, 0, i );        p_sys->i_silence_countdown -= i;    }    p_block->i_dts = p_block->i_pts =        date_Increment( &p_sys->pts, p_sys->fmt.audio.i_frame_length * i );    es_out_Control( p_demux->out, ES_OUT_SET_PCR, p_block->i_pts );    es_out_Send( p_demux->out, p_sys->p_es, p_block );    return 1;}/***************************************************************************** * Close: frees unused data *****************************************************************************/static void Close ( vlc_object_t * p_this ){    demux_sys_t *p_sys  = ((demux_t *)p_this)->p_sys;    free( p_sys );}/***************************************************************************** * Control: *****************************************************************************/static int Control( demux_t *p_demux, int i_query, va_list args ){    demux_sys_t *p_sys  = p_demux->p_sys;    return demux2_vaControlHelper( p_demux->s, p_sys->i_block_start,                                   p_sys->i_block_end,                                   p_sys->fmt.i_bitrate,                                   p_sys->fmt.audio.i_blockalign,                                   i_query, args );}

⌨️ 快捷键说明

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