Ticket #12901: longeraudiograph.patch

File longeraudiograph.patch, 4.8 KB (added by J.Pilk@…, 8 years ago)
  • mythtv-master/mythtv/libs/libmythtv/mythplayer.cpp

    old new  
    41374137    QMutexLocker locker(&osdLock);
    41384138    if (!osd)
    41394139        return false;
    4140 
     4140   
     4141    int frames2buf = 32 ;
    41414142    m_audiograph.SetPainter(videoOutput->GetOSDPainter());
    41424143    int sample_rate = GetAudio()->GetSampleRate();
    41434144    m_audiograph.SetSampleRate(sample_rate);
    4144     m_audiograph.SetSampleCount((unsigned)(sample_rate / video_frame_rate));
     4145    m_audiograph.SetSampleCount((unsigned)( frames2buf * sample_rate / video_frame_rate));
    41454146    GetAudio()->addVisual(&m_audiograph);
    41464147
    41474148    savedAudioTimecodeOffset = tc_wrap[TC_AUDIO];
  • mythtv-master/mythtv/libs/libmyth/audio/audiooutputgraph.cpp

         
         
    old new  
    1717
    1818#define LOC QString("AOG::%1").arg(__func__)
    1919
    20 const int kBufferMilliSecs = 500;
     20const int kBufferMilliSecs = 1600;
    2121
    2222/*
    2323 * Audio data buffer
     
    2727public:
    2828    Buffer() :
    2929        m_maxSamples(0),
    30         m_sample_rate(44100),
     30        m_sample_rate(48000),
    3131        m_tcFirst(0), m_tcNext(0),
    3232        m_bits(0),
    3333        m_channels(0),
     
    5151            timecode = m_tcNext;
    5252
    5353        int64_t tc1 = timecode - Samples2MS(m_maxSamples / 2);
    54         if (tc1 < (int64_t)m_tcFirst)
    55             tc1 = m_tcFirst;
    56 
     54 
    5755        int64_t tc2 = tc1 + Samples2MS(m_maxSamples);
    58         if (tc2 > (int64_t)m_tcNext)
    59         {
    60             tc2 = m_tcNext;
    61             if (tc2 < tc1 + (int64_t)Samples2MS(m_maxSamples))
    62             {
    63                 tc1 = tc2 - Samples2MS(m_maxSamples);
    64                 if (tc1 < (int64_t)m_tcFirst)
    65                     tc1 = m_tcFirst;
    66             }
    67         }
     56 
    6857        return range_t(tc1, tc2);
    6958    }
    7059
     
    9483
    9584        unsigned samples = Bytes2Samples(len);
    9685        uint64_t tcNext = timecode + Samples2MS(samples);
    97 
    98         if (qAbs(timecode - m_tcNext) <= 1)
     86       
     87       
     88        int64_t discontinuity = timecode - m_tcNext ;
     89        if (qAbs(discontinuity) <=  1L )
    9990        {
    10091            Append(b, len, bits);
    10192            m_tcNext = tcNext;
     
    126117
    127118    const int16_t* Data16(const range_t &avail) const
    128119    {
    129         unsigned start = MS2Samples(avail.first - m_tcFirst);
     120        unsigned start = 0 ; // MS2Samples(avail.first - m_tcFirst);
    130121        return reinterpret_cast< const int16_t* >(constData() + start * BytesPerSample());
    131122    }
    132123
     
    274265
    275266    LOG(VB_PLAYBACK, LOG_INFO, LOC +
    276267        QString("(%1) using [%2..%3] avail [%4..%5]")
    277         .arg(timecode).arg(avail.first).arg(avail.second)
    278         .arg(m_buffer->First()).arg(m_buffer->Next()) );
    279 
    280     const int width = m_buffer->Samples(avail);
    281     if (width <= 0)
    282         return 0;
     268        .arg(timecode).arg(avail.first).arg(avail.second - avail.first)
     269        .arg(m_buffer->First()).arg(m_buffer->Next() - m_buffer->First()) );
     270   
     271    const int frames2show = 32 , bufwidth = 1280 , imwidth = 512 ;
     272
     273//    const int bufwidth = m_buffer->Samples(avail);
     274//    if (bufwidth <= 0)
     275//        return 0;
    283276
    284277    const unsigned range = 1U << m_buffer->BitsPerChannel();
    285278    const double threshold = 20 * log10(1.0 / range); // 16bit=-96.3296dB => ~6dB/bit
     
    287280    if (height <= 0)
    288281        return 0;
    289282
    290     QImage image(width, height, QImage::Format_ARGB32);
     283    QImage image(imwidth, height, QImage::Format_ARGB32);
    291284    image.fill(0);
    292285
    293286    const int channels = m_buffer->Channels();
    294287
    295288    // Assume signed 16 bit/sample
    296289    const int16_t *p = m_buffer->Data16(avail);
    297 
    298     for (int x = 0; x < width; ++x)
     290   
     291    int bufstep = bufwidth/imwidth , pstep = bufstep * channels ;
     292    for (int x = 0; x < imwidth; x++ )
    299293    {
    300294        int left = p[0];
    301295        int right = channels > 1 ? p[1] : left;
    302         p += channels;
     296        p += pstep;   
    303297
    304298        unsigned avg = qAbs(left) + qAbs(right);
    305299        double db = 20 * log10( (double)(avg ? avg : 1) / range);
     
    316310            v = height - 1;
    317311        else if (v < 0)
    318312            v = 0;
    319 
    320         for (int y = 0; y <= v; ++y)
    321             image.setPixel(x, height - 1 - y, rgb);
     313       
     314        for ( int y = 0; y <= v ; y++ )
     315        {
     316                image.setPixel( x , height - 1 - y , rgb );
     317        }
     318       
     319   
    322320    }
     321   
     322    // show frame markers
     323    QRgb rgb = qRgb(255, 255, 255) ;
     324    int v = (height * 7 / 8) ;
     325    for (int x = 0; x < imwidth ; x += (imwidth / frames2show) )
     326    {
     327         for ( int y = 0; y <= v ; y++ )
     328        {
     329                image.setPixel( x , height - 1 - y , rgb );
     330        }
     331    }   
     332   
    323333
    324334    MythImage *mi = new MythImage(m_painter);
    325335    mi->Assign(image);