Exemplo n.º 1
0
Arquivo: k3btrm.cpp Projeto: KDE/k3b
void K3b::TRM::start( const K3b::Msf& length )
{
    if( KProtocolManager::useProxy() ) {
        QUrl proxy( KProtocolManager::proxyFor("http") );
        trm_SetProxy( d->trm, const_cast<char*>(proxy.host().toLatin1().constData()), short(proxy.port()) );
    }

    trm_SetPCMDataInfo( d->trm, 44100, 2, 16 );
    trm_SetSongLength( d->trm, length.totalFrames()/75 );
}
Exemplo n.º 2
0
bool K3bFFMpegFile::seek( const K3b::Msf& msf )
{
    d->outputBufferSize = 0;
    d->packetSize = 0;

    double seconds = (double)msf.totalFrames()/75.0;
    quint64 timestamp = (quint64)(seconds * (double)AV_TIME_BASE);

    // FIXME: do we really need the start_time and why?
#if LIBAVFORMAT_BUILD >= 4619
    return ( ::av_seek_frame( d->formatContext, -1, timestamp + d->formatContext->start_time, 0 ) >= 0 );
#else
    return ( ::av_seek_frame( d->formatContext, -1, timestamp + d->formatContext->start_time ) >= 0 );
#endif
}
Exemplo n.º 3
0
void K3b::FillStatusDisplay::Private::setCdSize( const K3b::Msf& size )
{
    // Remove check mark from the currently checked action
    if( QAction* checked = cdSizeGroup->checkedAction() ) {
        checked->setChecked( false );
    }

    switch( size.totalFrames() ) {
        case MediaSizeCd74Min:
        case 650*512:
            displayWidget->setCdSize( MediaSizeCd74Min );
            action74Min->setChecked( true );
            break;
        case MediaSizeCd80Min:
        case 700*512:
            displayWidget->setCdSize( MediaSizeCd80Min );
            action80Min->setChecked( true );
            break;
        case MediaSizeCd100Min:
        case 880*512:
            displayWidget->setCdSize( MediaSizeCd100Min );
            action100Min->setChecked( true );
            break;
        case MediaSizeDvd4Gb:
        case 2306867: // rounded 4.4*1024*512
            displayWidget->setCdSize( MediaSizeDvd4Gb );
            actionDvd4_7GB->setChecked( true );
            break;
        case MediaSizeDvd8Gb:
        case 8*1024*512:
            displayWidget->setCdSize( MediaSizeDvd8Gb );
            actionDvdDoubleLayer->setChecked( true );
            break;
        case MediaSizeBluRay25Gb:
        //case 25*1024*512:
            displayWidget->setCdSize( MediaSizeBluRay25Gb );
            actionBD25->setChecked( true );
            break;
        case MediaSizeBluRay50Gb:
        //case 50*1024*512:
            displayWidget->setCdSize( MediaSizeBluRay50Gb );
            actionBD50->setChecked( true );
            break;
        default:
            displayWidget->setCdSize( size );
            break;
    }
}
Exemplo n.º 4
0
bool K3bMadDecoder::seekInternal( const K3b::Msf& pos )
{
    //
    // we need to reset the complete mad stuff
    //
    if( !initDecoderInternal() )
        return false;

    //
    // search a position
    // This is all hacking, I don't really know what I am doing here... ;)
    //
    double mp3FrameSecs = static_cast<double>(d->firstHeader.duration.seconds)
                          + static_cast<double>(d->firstHeader.duration.fraction) / static_cast<double>(MAD_TIMER_RESOLUTION);

    double posSecs = static_cast<double>(pos.totalFrames()) / 75.0;

    // seekPosition to seek after frame i
    unsigned int frame = static_cast<unsigned int>( posSecs / mp3FrameSecs );

    // Rob said: 29 frames is the theoretically max frame reservoir limit (whatever that means...)
    // it seems that mad needs at most 29 frames to get ready
    unsigned int frameReservoirProtect = ( frame > 29 ? 29 : frame );

    frame -= frameReservoirProtect;

    // seek in the input file behind the already decoded data
    d->handle->inputSeek( d->seekPositions[frame] );

    qDebug() << "(K3bMadDecoder) Seeking to frame " << frame << " with "
             << frameReservoirProtect << " reservoir frames." << endl;

    // decode some frames ignoring MAD_ERROR_BADDATAPTR errors
    unsigned int i = 1;
    while( i <= frameReservoirProtect ) {
        d->handle->fillStreamBuffer();
        if( mad_frame_decode( d->handle->madFrame, d->handle->madStream ) ) {
            if( MAD_RECOVERABLE( d->handle->madStream->error ) ) {
                if( d->handle->madStream->error == MAD_ERROR_BUFLEN )
                    continue;
                else if( d->handle->madStream->error != MAD_ERROR_BADDATAPTR ) {
                    qDebug() << "(K3bMadDecoder) Seeking: recoverable mad error ("
                             << mad_stream_errorstr(d->handle->madStream) << ")" << endl;
                    continue;
                }
                else {
                    qDebug() << "(K3bMadDecoder) Seeking: ignoring ("
                             << mad_stream_errorstr(d->handle->madStream) << ")" << endl;
                }
            }
            else
                return false;
        }

        if( i == frameReservoirProtect )  // synth only the last frame (Rob said so ;)
            mad_synth_frame( d->handle->madSynth, d->handle->madFrame );

        ++i;
    }

    return true;
}