StreamInfo Abs::init(const ParameterMap& params, const StreamInfo& in)
{
    if (in.size%2 != 0)
    {
        cerr << "ERROR: Abs input size should be even" << endl;
        return StreamInfo();
    }
    return StreamInfo(in, in.size/2);
}
Пример #2
0
//
// fill out descName for debugging if needed
// fDescName;       // for debugging output only, not read/written
//
void plNetMsgSDLState::ISetDescName() const
{
    if (fDescName.empty() && StreamInfo()->GetStreamLen() && !StreamInfo()->IsCompressed())
    {
        hsReadOnlyStream stream(StreamInfo()->GetStreamLen(), StreamInfo()->GetStreamBuf());
        /* This code can crash the game server sometimes -eap
        char* descName = nil;
        int ver;
        if (plStateDataRecord::ReadStreamHeader(&stream, &descName, &ver))
            fDescName = descName;
        delete [] descName;
        */
    }
}
bool Variation::init(const ParameterMap& params, const Ports<StreamInfo>& inp)
{
	assert(inp.size()==1);
	const StreamInfo& in = inp[0].data;
	outStreamInfo().add(StreamInfo(in,1));
    return true;
}
Пример #4
0
void plNetMsgGameMessage::ReadVersion(hsStream* s, hsResMgr* mgr)
{
    plNetMessage::ReadVersion(s, mgr);
    
    hsBitVector contentFlags;
    contentFlags.Read(s);
    
    if (contentFlags.IsBitSet(kNetGameMsgDeliveryTime))
    {
        if (s->ReadByte())
            fDeliveryTime.Read(s);
    }
    
    if (contentFlags.IsBitSet(kNetGameMsgGameMsg))
    {
        plMessage* gameMsg = plMessage::ConvertNoRef(mgr->ReadCreatableVersion(s));
        
        // write message (and label) to ram stream
        hsRAMStream ramStream;
        mgr->WriteCreatable(&ramStream, gameMsg);
        
        // put stream in net msg wrapper
        StreamInfo()->CopyStream(&ramStream);
        
        hsRefCnt_SafeUnRef(gameMsg);
    }
}
Пример #5
0
StreamInfo Chroma2::init(const ParameterMap& params, const StreamInfo& in)
{
	m_cqtSize = in.size;
	m_cqtMinFreq = getDoubleParam("CQTMinFreq",params);
	m_cqtMaxFreq = getDoubleParam("CQTMaxFreq",params);
	m_cqtNbBins = getIntParam("CQTBinsPerOctave",params);
	m_nbBinsSemitone = getIntParam("CZBinsPerSemitone",params);
	m_nbBins = getIntParam("CZNbCQTBinsAggregatedToPCPBin",params);
	if (m_nbBins<0)
		m_nbBins = m_cqtNbBins / 24;
	m_tuning = getDoubleParam("CZTuning",params);

	m_deviation = m_cqtNbBins * log2(m_tuning / m_cqtMinFreq);
	double deviationRealPart = m_deviation - floor(m_deviation);
	m_cqtMinFreq = m_cqtMinFreq * pow(2.0, deviationRealPart / m_cqtNbBins);
	m_tuningBin = 1 + ((int) floor(m_deviation) - 1) % (m_cqtNbBins / 12);
	m_Q = 1 / (pow(2.0, 1.0 / (double) m_cqtNbBins) - 1);
	m_K = log2(m_cqtMaxFreq / m_cqtMinFreq);
	m_nbNote = (int) floor(m_cqtSize * 12.0 * m_nbBinsSemitone / m_cqtNbBins);
	m_notePartial.resize(m_nbNote);
	m_notePartialA = (int) floor((double) m_nbBins / 2.0);
	if (m_tuningBin > (m_cqtNbBins / 12 - m_notePartialA))
		m_tuningBin = m_tuningBin - m_cqtNbBins / 12;
	m_notePartialFactor = m_cqtNbBins / (12 * m_nbBinsSemitone);
	m_pcpSize = 12 * m_nbBinsSemitone;
	m_pcp.resize(m_pcpSize);

	int firstCode = (int) round(m_nbBinsSemitone * (69.0 + 12.0 * log2(m_cqtMinFreq
			* pow(2.0, ((double)m_tuningBin / m_cqtNbBins)) / m_tuning )));
	m_pcpShift = firstCode % m_pcpSize;

    return StreamInfo(in,m_pcpSize);
}
void AmRtpReceiverThread::addStream(int sd, AmRtpStream* stream)
{
  streams_mut.lock();

  if(streams.find(sd) != streams.end()) {
    ERROR("trying to insert existing stream [%p] with sd=%i\n",
	  stream,sd);
    streams_mut.unlock();
    return;
  }

  if(nfds >= MAX_RTP_SESSIONS){
    streams_mut.unlock();
    ERROR("maximum number of sessions reached (%i)\n",
	  MAX_RTP_SESSIONS);
    throw string("maximum number of sessions reached");
  }

  fds[nfds].fd      = sd;
  fds[nfds].events  = POLLIN;
  fds[nfds].revents = 0;

  streams.insert(std::make_pair(sd,StreamInfo(nfds,stream)));
  nfds++;

  streams_mut.unlock();
}
StreamInfo FFT::init(const ParameterMap& params, const StreamInfo& in)
{
    int len = getIntParam("FFTLength", params);
    if (len == 0)
        len = in.size;
    string w = getStringParam("FFTWindow", params);
    if (w != "None")
    {
        if (w == "Hanning")
            m_window = ehanningPeriodic(in.size);
        else if (w == "Hamming")
            m_window = ehammingPeriodic(in.size);
        else
        {
            cerr << "FFT: invalid Window parameter value " << w << " ignore it !" << endl;
        }
    }
    // init plan
    m_nfft = len;
#ifdef WITH_FFTW3
    double* inFFT = (double*) fftw_malloc(m_nfft*sizeof(double));
    complex<double>* outFFT = (complex<double>*) fftw_malloc((m_nfft/2+1)*sizeof(complex<double>));
    m_plan = fftw_plan_dft_r2c_1d(m_nfft,inFFT,(fftw_complex*)outFFT,FFTW_MEASURE);
    fftw_free(inFFT);
    fftw_free(outFFT);
#else
    VectorXd infft(m_nfft);
    VectorXcd outfft(m_nfft/2+1);
    m_plan.fwd(outfft.data(),infft.data(),m_nfft);
#endif

    return StreamInfo(in,len+2);
}
bool FrameTokenizer::init(const ParameterMap& params, const Ports<StreamInfo>& inp)
{
	assert(inp.size()==1);
	const StreamInfo& in = inp[0].data;

    if (in.size > 1)
    {
        cerr << "ERROR: input of FrameTokenizer should be of size 1" << endl;
        return false;
    }
    m_blockSize = getIntParam("blockSize", params);
    if (m_blockSize<=0) {
    	cerr << "ERROR: invalid blockSize parameter !" << endl;
    }
    m_stepSize = getIntParam("stepSize", params);
    if (m_stepSize<=0) {
    	cerr << "ERROR: invalid stepSize parameter !" << endl;
    	return false;
    }

    outStreamInfo().add(StreamInfo());
	StreamInfo& outInfo = outStreamInfo()[0].data;
	outInfo.sampleRate = in.sampleRate;
	outInfo.frameLength = m_blockSize * in.frameLength;
	outInfo.sampleStep = m_stepSize * in.sampleStep;
	outInfo.size = m_blockSize;

    return true;
}
Пример #9
0
  bool MelFilterBank::init(const ParameterMap& params, const Ports<StreamInfo>& inp)
  {
    assert(inp.size()==1);
    const StreamInfo& in = inp[0].data;

    // build mel filter bank
    m_size = in.size;
    int nbMelFilters = getIntParam("MelNbFilters",params);
    double sampleRate = in.sampleRate;
    double freqMin = getDoubleParam("MelMinFreq",params);
    double freqMax = getDoubleParam("MelMaxFreq",params);
    // set freqMax to Nyquist frequency if greater than nyquist frequency
    freqMax = min(freqMax, sampleRate/2.0);
    double melFreqMin = 1127 * log(1 + freqMin / 700);
    double melFreqMax = 1127 * log(1 + freqMax / 700);

    VectorXd melPeak(nbMelFilters+2);
    VectorXd freqs(nbMelFilters+2);

    melPeak = VectorXd::LinSpaced(nbMelFilters+2,melFreqMin,melFreqMax);
    freqs = ((melPeak / 1127).array().exp() - 1.0) * 700.0;
    VectorXd fftFreqs(m_size);
    fftFreqs = VectorXd::LinSpaced(m_size,0,m_size-1) * sampleRate / ((m_size-1)*2);
    for (int b=1;b<nbMelFilters+1;b++)
    {
      double norm = 2.0 / (freqs(b+1)-freqs(b-1));
      VectorXd fullfilt(m_size);
      //		fullfilt.setZero(m_size);
      //		firstIndex i;
      //		fullfilt += where((fftFreqs(i)>freqs(b-1)) && (fftFreqs(i)<=freqs(b)),norm*(fftFreqs(i)-freqs(b-1))/(freqs(b)-freqs(b-1)),0.0);
      //		fullfilt += where((fftFreqs(i)>freqs(b)) && (fftFreqs(i)<freqs(b+1)),norm*(freqs(b+1)-fftFreqs(i))/(freqs(b+1)-freqs(b)),0.0);
      double ffmin = freqs(b-1);
      double ffmiddle = freqs(b);
      double ffmax = freqs(b+1);
      for (int i=0;i<m_size;i++) {
        if ((fftFreqs(i)<ffmin) || (fftFreqs(i)>ffmax)) {
          fullfilt(i) = 0;
          continue;
        }
        if (fftFreqs(i)<ffmiddle)
          fullfilt(i) = norm*(fftFreqs(i)-ffmin)/(ffmiddle-ffmin);
        else
          fullfilt(i) = norm*(ffmax-fftFreqs(i))/(ffmax-ffmiddle);
      }

      int fStart=0;
      while (fullfilt(fStart)==0.0) fStart++;
      int fEnd=fStart+1;
      while ((fEnd<m_size) && (fullfilt(fEnd)!=0.0)) fEnd++;
      m_filterStart.push_back(fStart);
      m_filters.push_back(RowVectorXd());
      m_filters.back() = fullfilt.segment(fStart,fEnd-fStart);
    }

    outStreamInfo().add(StreamInfo(in, m_filters.size()));
    return true;
  }
bool AC2LPC::init(const ParameterMap& params, const Ports<StreamInfo>& inp)
{
	assert(inp.size()==1);
	const StreamInfo& in = inp[0].data;

	m_nbCoeffs = getIntParam("LPCNbCoeffs",params);
	outStreamInfo().add(StreamInfo(in,m_nbCoeffs));
    return true;
}
Пример #11
0
bool Flux::init(const ParameterMap& params, const Ports<StreamInfo>& inp)
{
	assert(inp.size()==1);
	const StreamInfo& in = inp[0].data;

	m_onlyIncrease = (getStringParam("FluxSupport",params)=="Increase");
    outStreamInfo().add(StreamInfo(in,1));
    return true;
}
Пример #12
0
void plNetMsgSDLState::WriteVersion(hsStream* s, hsResMgr* mgr)
{
    plNetMsgStreamedObject::WriteVersion(s, mgr);
    
    hsBitVector contentFlags;
    contentFlags.SetBit(kSDLStateStream);
    contentFlags.SetBit(kSDLIsInitialState);
    contentFlags.SetBit(kSDLPersist);
    contentFlags.SetBit(kSDLAvatarState);
    contentFlags.Write(s);
    
    // kSDLStateStream
    s->WriteLE32(StreamInfo()->GetStreamLen());
    s->Write(StreamInfo()->GetStreamLen(), StreamInfo()->GetStreamBuf());
    s->WriteLE( fIsInitialState );
    s->WriteLE(fPersistOnServer);
    s->WriteLE(fIsAvatarState);
}
Пример #13
0
void PleoraVideo::InitPangoStreams()
{
    // Get actual width, height and payload size
    const int w = DeviceParam<int64_t>("Width");
    const int h = DeviceParam<int64_t>("Height");
    const uint32_t lSize = lDevice->GetPayloadSize();

    // Setup pangolin for stream
    PvGenEnum* lpixfmt = dynamic_cast<PvGenEnum*>( lDeviceParams->Get("PixelFormat") );
    const PixelFormat fmt = PleoraFormat(lpixfmt);
    streams.push_back(StreamInfo(fmt, w, h, (w*fmt.bpp)/8));
    size_bytes = lSize;
}
Пример #14
0
double          MediaStreamReaderImpl::Duration() const
{
   MediaStreamInfo streamInfo = StreamInfo();
   if ( streamInfo.IsVideo() )
      return NumFrames() / streamInfo.VideoFPS();

   if ( streamInfo.IsAudio() )
   {
      if ( streamInfo.audio.FormatTag() == 1 /*WAVE_FORMAT_PCM*/ )
         return TotalBytes() / streamInfo.audio.BlockAlign() / (double)streamInfo.audio.SamplesPerSec();

      return TotalBytes() / (double)streamInfo.audio.AvgBytesPerSec();
   }
   return 0;
}
Пример #15
0
void plNetMsgSDLState::ReadVersion(hsStream* s, hsResMgr* mgr)
{
    plNetMsgStreamedObject::ReadVersion(s, mgr);
    
    hsBitVector contentFlags;
    contentFlags.Read(s);
    
    if (contentFlags.IsBitSet(kSDLStateStream))
    {
        uint32_t len;
        s->LogReadLE(&len,"SDLState StreamLen");
        uint8_t* buf = new uint8_t[len];
        s->LogRead(len, buf,"SDLState StreamData");
        
        StreamInfo()->SetStreamLen(len);
        StreamInfo()->SetStreamBuf(buf);
    }
    if (contentFlags.IsBitSet(kSDLIsInitialState))
        s->LogReadLE( &fIsInitialState, "IsInitialAgeState" );
    if (contentFlags.IsBitSet(kSDLPersist))
        s->ReadLE(&fPersistOnServer);
    if (contentFlags.IsBitSet(kSDLAvatarState))
        s->ReadLE(&fIsAvatarState);
}
Пример #16
0
VideoJoiner::VideoJoiner(const std::vector<VideoInterface*>& src)
    : src(src), size_bytes(0)
{
    // Add individual streams
    for(size_t s=0; s< src.size(); ++s)
    {
        VideoInterface& vid = *src[s];
        for(size_t i=0; i < vid.Streams().size(); ++i)
        {
            const StreamInfo si = vid.Streams()[i];
            const VideoPixelFormat fmt = si.PixFormat();
            const Image<unsigned char> img_offset = si.StreamImage((unsigned char*)size_bytes);
            streams.push_back(StreamInfo(fmt, img_offset));
        }
        size_bytes += src[s]->SizeBytes();
    }
}
bool Difference::init(const ParameterMap& params, const Ports<StreamInfo>& inp)
{
	assert(inp.size()==1);
	const StreamInfo& in = inp[0].data;

	m_nbCoeffs = getIntParam("DiffNbCoeffs",params);
	if (m_nbCoeffs==0)
		m_nbCoeffs = in.size - 1;
	if (m_nbCoeffs > in.size-1)
	{
		cerr << "Warning: cannot compute " << m_nbCoeffs << " difference coefficients from input of size " << in.size << endl;
		m_nbCoeffs = in.size - 1;
		cerr << "take only " << m_nbCoeffs << " coefficients" << endl;
	}

	outStreamInfo().add(StreamInfo(in,m_nbCoeffs));
    return true;
}
Пример #18
0
//
// SetStreamSource event.  Updates the current vertex buffer.
//
void StateManager::SetStreamSource(UINT StreamNumber, HANDLE VBufferHandle, UINT OffsetInBytes, UINT Stride)
{
    if(VBufferHandle == NULL)
    {
        g_Context->Files.Assert << "SetStreamSource VBufferHandle NULL\n";
    }
    else if(VBuffers.find(VBufferHandle) == VBuffers.end())
    {
        g_Context->Files.Assert << "SetStreamSource VBufferHandle not in list: " << VBufferHandle << endl;
    }
    else if(StreamNumber >= MaxStreams)
    {
        g_Context->Files.Assert << "StreamNumber >= MaxStreams\n";
    }
    else
    {
        VBufferStreams[StreamNumber] = StreamInfo(VBuffers[VBufferHandle], OffsetInBytes, Stride);
    }
}
Пример #19
0
bool SpectralCrestFactorPerBand::init(const ParameterMap& params, const Ports<StreamInfo>& inp)
{
	assert(inp.size()==1);
	const StreamInfo& in = inp[0].data;
    m_inSize = in.size;

    double fs = in.sampleRate;
    int blockSize = (in.size-1)*2; // assume input is spectrum

    double hiedge = floor(fs/2);
    double loedge = hiedge * pow(2,round(log2(250.0/hiedge)));

    int k = 0;
    while (true)
    {
        k++;
        double f_lo_nom = loedge * pow(2,(double)(k-1)/4.0);
        double f_hi_nom = loedge * pow(2,(double)k/4.0);
        double f_lo = f_lo_nom * (1 - OVERLAP);
        double f_hi = f_hi_nom * (1 + OVERLAP);
        int i_lo = (int) round(f_lo / (fs/blockSize));
        int i_hi = (int) round(f_hi / (fs/blockSize));

        if (f_lo_nom >= hiedge) break;
        if (f_hi > fs/2) break;

        int grpsize = 1;
        if (f_lo_nom >= 1000)
        {
            grpsize = (int) round(pow(2, floor(log2(f_lo_nom/500.0))));
            i_hi = (int) round((double)(i_hi-i_lo+1)/grpsize)*grpsize + i_lo-1;
        }

    	bandinfo bi;
    	bi.start = i_lo;
    	bi.end = i_hi+1;
    	bi.group = grpsize;
        m_band.push_back(bi);
    }

    outStreamInfo().add(StreamInfo(in,m_band.size()));
    return true;
}
Пример #20
0
void View::RecordOnRender(const std::string& record_uri)
{
    PANGOLIN_UNUSED(record_uri);

#ifdef BUILD_PANGOLIN_VIDEO
    if(!context->recorder.IsOpen()) {
        Viewport area = GetBounds();
        context->record_view = this;
        context->recorder.Open(record_uri);
        std::vector<StreamInfo> streams;
        const PixelFormat fmt = PixelFormatFromString("RGB24");
        streams.push_back( StreamInfo(fmt, area.w, area.h, area.w * fmt.bpp / 8) );
        context->recorder.SetStreams(streams);
    }else{
        context->recorder.Close();
    }
#else
    std::cerr << "Error: Video Support hasn't been built into this library." << std::endl;
#endif // BUILD_PANGOLIN_VIDEO
}
Пример #21
0
void WAVStream::run()
{
	//char chunkID[5];
	//chunkID[4] = 0;
	//input_->getStream()->read(chunkID, 4);
	
	//cout << "CHUNK ID: " << chunkID << endl;
	
	streamInfo_ = StreamInfo();
	
	string chunkId = readString(4);
	if (chunkId.compare(WAVFormat::CHUNK_ID) != 0) {
		cerr << "ERROR: Invalid chunk ID. Stream may not be in WAV format." << endl;
		return;
	}
	
	int32_t chunkSize = readInt32();
	
	string chunkFormat = readString(4);
	if (chunkFormat.compare(WAVFormat::CHUNK_FORMAT) != 0) {
		cerr << "ERROR: Invalid chunk format. Stream may not be in WAV format." << endl;
		return;
	}
	
	chunkSize -= 4;
	
	formatRead_ = false;
	dataRead_ = false;
	
	dataInfo_ = DataInfo();
	
	while (chunkSize > 0) {
		chunkSize -= readSubchunk();
	}
	
	endStream();
	//if (backend_.isNotNull())
	//	backend_->endStream();
}
Пример #22
0
  bool Cepstrum::init(const ParameterMap& params, const Ports<StreamInfo>& inp)
  {
    assert(inp.size()==1);
    const StreamInfo& in = inp[0].data;

    m_ignoreFirst = getIntParam("CepsIgnoreFirstCoeff",params);
    m_nbCoeffs = getIntParam("CepsNbCoeffs",params);
    if (m_nbCoeffs+m_ignoreFirst>in.size)
    {
      cerr << "Warning: cannot compute " << m_nbCoeffs << " for input of size " << in.size << endl;
      m_nbCoeffs = in.size - m_ignoreFirst;
      cerr << "compute only " << m_nbCoeffs << " coefficients" << endl;
    }

    m_dctPlan.resize(in.size,in.size);
    for (int j=0;j<in.size;j++)
      m_dctPlan(0,j) = 1.0 / sqrt((double)in.size);
    for (int i=1;i<in.size;i++)
      for (int j=0;j<in.size;j++)
        m_dctPlan(i,j) = sqrt(2.0 / in.size) * cos(PI * (j + 0.5) * i / in.size);

    outStreamInfo().add(StreamInfo(in, m_nbCoeffs));
    return true;
  }
Пример #23
0
  bool SpecificLoudness::init(const ParameterMap& params, const Ports<StreamInfo>& inp)
  {
    assert(inp.size()==1);
    const StreamInfo& in = inp[0].data;

    // assume in->info().size is fft size
    // assume in->info().frameLength is frame size
    m_blockSize = in.frameLength;
    m_fftSize = in.size;
    m_bkBdLimits = new int[NB_BARK_BANDS+1];

    double tmp[m_fftSize];
    for (int i = 0; i < m_fftSize; i++)
    {
      tmp[i] = i * in.sampleRate / (double) m_blockSize;
      tmp[i] = 13 * atan(tmp[i] / 1315.8) + 3.5 * atan(pow(
            (tmp[i] / 7518), 2));
    }

    m_bkBdLimits[0] = 0;
    double currentBandEnd = tmp[m_fftSize-1] / NB_BARK_BANDS;
    int currentBarkBand = 1;
    for (int i = 0; i < m_fftSize; i++)
    {
      while (tmp[i] > currentBandEnd)
      {
        m_bkBdLimits[currentBarkBand++] = i;
        currentBandEnd = currentBarkBand * tmp[m_fftSize-1] / NB_BARK_BANDS;
      }
    }
    assert(currentBarkBand == NB_BARK_BANDS);
    m_bkBdLimits[NB_BARK_BANDS] = m_fftSize-1; // ignore last coeff

    outStreamInfo().add(StreamInfo(in,NB_BARK_BANDS));
    return true;
  }
void AvFormatDecoderDVD::PostProcessTracks(void)
{
    if (!ringBuffer)
        return;
    if (!ringBuffer->IsDVD())
        return;

    if (tracks[kTrackTypeAudio].size() > 1)
    {
        stable_sort(tracks[kTrackTypeAudio].begin(),
                    tracks[kTrackTypeAudio].end());

        int trackNo = -1;
        int dvdTrack = ringBuffer->DVD()->GetTrack(kTrackTypeAudio);

        for (uint i = 0; i < GetTrackCount(kTrackTypeAudio); i++)
        {
            LOG(VB_PLAYBACK, LOG_INFO, LOC +
                QString("DVD Audio Track Map Stream id #%1, av_stream_idx %2, MPEG stream 0x%3, lang %4")
                    .arg(tracks[kTrackTypeAudio][i].stream_id)
                    .arg(tracks[kTrackTypeAudio][i].av_stream_index)
                    .arg(ic->streams[tracks[kTrackTypeAudio][i].av_stream_index]->id,0,16)
                    .arg(iso639_key_toName(tracks[kTrackTypeAudio][i].language)));

            // Find the audio track in our list that maps to the
            // selected track in the ringbuffer (the ringbuffer's
            // list should be in the same order but can have gaps,
            // so we look for the track with the same index)
            if (tracks[kTrackTypeAudio][i].stream_id == dvdTrack)
                trackNo = i;
        }

        if (trackNo < 0 && GetTrackCount(kTrackTypeAudio) > 0)
        {
            // Take the first track
            trackNo = 0;
        }

        if (trackNo >= 0)
            SetTrack(kTrackTypeAudio, trackNo);
    }

    if (tracks[kTrackTypeSubtitle].size() > 0)
    {
        map<int,uint> lang_sub_cnt;
        map<int,int>  stream2idx;

        // First, create a map containing stream id -> track index
        // of the subtitle streams that have been found so far.
        for (uint n = 0; n < GetTrackCount(kTrackTypeSubtitle); n++)
        {
            int stream_id = tracks[kTrackTypeSubtitle][n].stream_id & 0x1f;

            stream2idx[stream_id] = n;
        }

        // Get all subtitle tracks from the DVD and filter out any that
        // are not mapped in the current program chain.
        sinfo_vec_t filteredTracks;

        if (!ringBuffer->DVD()->IsInMenu())
        {
            for (uint i = 0; i < 32; ++i)
            {
                int streamid = ringBuffer->DVD()->GetSubtitleTrackNum(i);
                if (streamid >= 0)
                {
                    // This stream is mapped in the current program chain
                    int lang = ringBuffer->DVD()->GetSubtitleLanguage(i);
                    int lang_indx = lang_sub_cnt[lang]++;
                    int trackNo = -1;

                    if (stream2idx.count(streamid) != 0)
                        trackNo = stream2idx[streamid];

                    if (trackNo == -1)
                    {
                        // Create a dummy track if the physical stream has not
                        // yet been seen.
                        filteredTracks.push_back(StreamInfo(-1, lang, lang_indx,
                                                            streamid, 0, 0, false, false, false));
                    }
                    else
                    {
                        // Otherwise use the real data
                        filteredTracks.push_back(tracks[kTrackTypeSubtitle][trackNo]);
                        filteredTracks.back().stream_id &= 0x1f;
                        filteredTracks.back().language = lang;
                        filteredTracks.back().language_index = lang_indx;
                    }
                }
            }
        }
        tracks[kTrackTypeSubtitle] = filteredTracks;

        stable_sort(tracks[kTrackTypeSubtitle].begin(),
                    tracks[kTrackTypeSubtitle].end());

        int trackNo = -1;
        int selectedStream = ringBuffer->DVD()->GetTrack(kTrackTypeSubtitle);

        // Now iterate over the sorted list and try to find the index of the
        // currently selected track.
        for (uint idx = 0; idx < GetTrackCount(kTrackTypeSubtitle); idx++)
        {
            const StreamInfo& stream = tracks[kTrackTypeSubtitle][idx];
            int avidx = stream.av_stream_index;
            QString mpegstream;

            if (avidx >= 0)
                mpegstream = QString( "0x%1").arg(ic->streams[avidx]->id,0,16);
            else
                mpegstream = "n/a";

            LOG(VB_PLAYBACK, LOG_INFO, LOC +
                QString("DVD Subtitle Track Map Stream id #%1, av_stream_idx %2, MPEG #%3, lang %4")
                    .arg(stream.stream_id)
                    .arg(stream.av_stream_index)
                    .arg(mpegstream)
                    .arg(iso639_key_toName(stream.language)));

            if ((selectedStream != -1) && (stream.stream_id == selectedStream))
                trackNo = (int)idx;
        }

        uint captionmode = m_parent->GetCaptionMode();
        int trackcount = (int)GetTrackCount(kTrackTypeSubtitle);

        if (captionmode == kDisplayAVSubtitle &&
            (trackNo < 0 || trackNo >= trackcount))
        {
            m_parent->EnableSubtitles(false);
        }
        else if (trackNo >= 0 && trackNo < trackcount)
        {
            SetTrack(kTrackTypeSubtitle, trackNo);
            m_parent->EnableSubtitles(true);
        }
    }
}
Пример #25
0
//数组AMOUNT中第一个数为分组密码算法的数量,以后依次为流密码,HASH,MAC,RNG的数量
extern const int AMOUNTS[] = {21,6,18,6,2};
extern const Cipher CIPHERS[] = {
	BlockInfo("AES",KL(AES),BS(AES)),BlockInfo("Blowfish",KL(Blowfish),BS(Blowfish)),
	BlockInfo("Camellia",KL(Camellia),BS(Camellia)),BlockInfo("CAST256",KL(CAST256),BS(CAST256)),
	BlockInfo("DES",KL(DES),BS(DES)),BlockInfo("MARS",KL(MARS),BS(MARS)),
	BlockInfo("IDEA",KL(IDEA),BS(IDEA)),BlockInfo("RC5",KL(RC5),BS(RC5)),
	BlockInfo("RC6",KL(RC6),BS(RC6)),BlockInfo("SEED",KL(SEED),BS(SEED)),
	BlockInfo("Serpent",KL(Serpent),BS(Serpent)),BlockInfo("SHACAL2",KL(SHACAL2),BS(SHACAL2)),
	BlockInfo("SKIPJACK",KL(SKIPJACK),BS(SKIPJACK)),BlockInfo("TEA",KL(TEA),BS(TEA)),
	BlockInfo("Twofish",KL(Twofish),BS(Twofish)),BlockInfo("XTEA",KL(XTEA),BS(XTEA)),
	BlockInfo("DES_EDE3",KL(DES_EDE3),BS(DES_EDE3)),BlockInfo("GOST",KL(GOST),BS(GOST)),
	BlockInfo("SHARK",KL(SHARK),BS(SHARK)),BlockInfo("Square",KL(Square),BS(Square)),
	BlockInfo("ThreeWay",KL(ThreeWay),BS(ThreeWay)),

	StreamInfo("Sosemanuk",KL(Sosemanuk),IL(Sosemanuk)),
	StreamInfo("Salsa20",KL(Salsa20),IL(Salsa20)),
	StreamInfo("XSalsa20",KL(XSalsa20),IL(XSalsa20)),
	StreamInfo("SEAL",KL(SEAL<>),IL(SEAL<>)),
	StreamInfo("PanamaCipher",KL(PanamaCipher<>),IL(PanamaCipher<>)),
	StreamInfo("RC4",KL(Weak::ARC4),IL(Weak::ARC4)),

	HashInfo("MD2",DS(Weak::MD2)),HashInfo("MD4",DS(Weak::MD4)),
	HashInfo("MD5",DS(Weak::MD5)),HashInfo("SHA1",DS(SHA1)),
	HashInfo("SHA256",DS(SHA256)),HashInfo("SHA224",DS(SHA224)),
	HashInfo("SHA512",DS(SHA512)),HashInfo("SHA384",DS(SHA384)),
	HashInfo("SHA3_224",DS(SHA3_224)),HashInfo("SHA3_256",DS(SHA3_256)),
	HashInfo("SHA3_384",DS(SHA3_384)),HashInfo("SHA3_512",DS(SHA3_512)),
	HashInfo("Tiger",DS(Tiger)),HashInfo("RIPEMD160",DS(RIPEMD160)),
	HashInfo("RIPEMD320",DS(RIPEMD320)),HashInfo("RIPEMD128",DS(RIPEMD128)),
	HashInfo("RIPEMD256",DS(RIPEMD256)),HashInfo("Whirlpool",DS(Whirlpool)),
Пример #26
0
void plNetMsgSharedState::CopySharedState(plNetSharedState* ss)
{
    hsRAMStream stream;
    ss->Write(&stream);
    StreamInfo()->CopyStream(&stream);
}
Пример #27
0
  bool AudioFileReader::init(const ParameterMap& params, const Ports<StreamInfo>& in)
  {
    m_resample = (getStringParam("Resample", params)=="yes");
    m_removemean = (getStringParam("RemoveMean",params)=="yes");
    m_scaleMax = getDoubleParam("ScaleMax",params);
    m_sampleRate = 	getIntParam("SampleRate",params);
    string filename = getStringParam("File", params);
    string timeStart = getStringParam("TimeStart",params);

    if (timeStart[timeStart.size()-1]=='s')
    {
      m_startSecond = atof(timeStart.substr(0,timeStart.size()-1).c_str());
    } else {
      cerr << "ERROR: invalid TimeStart parameter !" << endl;
      return false;
    }
    string timeLimit = getStringParam("TimeLimit",params);
    if (timeLimit[timeLimit.size()-1]=='s')
    {
      m_limitSecond = atof(timeLimit.substr(0,timeLimit.size()-1).c_str());
    } else {
      cerr << "ERROR: invalid TimeLimit parameter !" << endl;
      return false;
    }

    m_bufferSize = DataBlock::preferedBlockSize();
    m_readBuffer = new double[2*m_bufferSize]; // enough to read stereo if needed

    if (!openFile(filename))
      return false;
    
    // find mean and max if needed
    m_mean = 0;
    m_factor = 1;
    if (m_removemean || m_scaleMax>0)
    {
      m_rescale = true;

      int count = 0;
      double smean = 0;
      double smin = 0;
      double smax = 0;
      while (true) {
        int nbRead = readFramesIntoBuffer();
        if (nbRead==0)
          break;
        for (int i=0;i<nbRead;i++)
        {
          smean += m_readBuffer[i];
          if (m_readBuffer[i]<smin)
            smin = m_readBuffer[i];
          if (m_readBuffer[i]>smax)
            smax = m_readBuffer[i];
        }
        count += nbRead;
      }

      if (m_removemean)
        m_mean = smean / count;
      if (m_scaleMax>0)
        m_factor = m_scaleMax / max(abs( (smax-m_mean) ),abs( (smin-m_mean) ));

      int res = sf_seek(m_sndfile,0,SEEK_SET);
      if (res!=0)
      {
        cerr << "ERROR: cannot seek start in audio file !" << endl;
        return false;
      }

      if (verboseFlag)
        cerr << "INFO: remove mean of input signal (" << m_mean << ") and scale to " << m_scaleMax << endl;
      closeFile();
      if (!openFile(filename)) {
        cerr << "ERROR: cannot re-open file " << filename << " !" << endl; 
        return false;
      }
    }

    if ((!m_resample) && (m_sfinfo.samplerate != m_sampleRate)) {
      cerr << "ERROR: resampling is disabled and file has sample rate " << m_sfinfo.samplerate << " Hz. Expecting " << m_sampleRate << " Hz !" << endl;
      return false;
    }

    outStreamInfo().add(StreamInfo());
    StreamInfo& outInfo = outStreamInfo()[0].data;
    outInfo.size = 1;
    outInfo.sampleRate = m_sampleRate;
    outInfo.sampleStep = 1;
    outInfo.frameLength = 1;
    return true;
  }
Пример #28
0
_JATTA_EXPORT Jatta::PortAudio::StreamInfo Jatta::PortAudio::Stream::GetInfo()
{
    return StreamInfo(Pa_GetStreamInfo(stream));
}
Пример #29
0
plMessage* plNetMsgGameMessage::GetContainedMsg(hsResMgr* resmgr)
{
    hsReadOnlyStream s(StreamInfo()->GetStreamLen(), StreamInfo()->GetStreamBuf());
    return plMessage::ConvertNoRef((resmgr?resmgr:hsgResMgr::ResMgr())->ReadCreatable(&s));
}
Пример #30
0
_CGUL_EXPORT CGUL::PortAudio::StreamInfo CGUL::PortAudio::Stream::GetInfo()
{
    return StreamInfo(Pa_GetStreamInfo(stream));
}