Ticket #12901: longeraudiograph.patch
File longeraudiograph.patch, 4.8 KB (added by , 8 years ago) |
---|
-
mythtv-master/mythtv/libs/libmythtv/mythplayer.cpp
old new 4137 4137 QMutexLocker locker(&osdLock); 4138 4138 if (!osd) 4139 4139 return false; 4140 4140 4141 int frames2buf = 32 ; 4141 4142 m_audiograph.SetPainter(videoOutput->GetOSDPainter()); 4142 4143 int sample_rate = GetAudio()->GetSampleRate(); 4143 4144 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)); 4145 4146 GetAudio()->addVisual(&m_audiograph); 4146 4147 4147 4148 savedAudioTimecodeOffset = tc_wrap[TC_AUDIO]; -
mythtv-master/mythtv/libs/libmyth/audio/audiooutputgraph.cpp
old new 17 17 18 18 #define LOC QString("AOG::%1").arg(__func__) 19 19 20 const int kBufferMilliSecs = 500;20 const int kBufferMilliSecs = 1600; 21 21 22 22 /* 23 23 * Audio data buffer … … 27 27 public: 28 28 Buffer() : 29 29 m_maxSamples(0), 30 m_sample_rate(4 4100),30 m_sample_rate(48000), 31 31 m_tcFirst(0), m_tcNext(0), 32 32 m_bits(0), 33 33 m_channels(0), … … 51 51 timecode = m_tcNext; 52 52 53 53 int64_t tc1 = timecode - Samples2MS(m_maxSamples / 2); 54 if (tc1 < (int64_t)m_tcFirst) 55 tc1 = m_tcFirst; 56 54 57 55 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 68 57 return range_t(tc1, tc2); 69 58 } 70 59 … … 94 83 95 84 unsigned samples = Bytes2Samples(len); 96 85 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 ) 99 90 { 100 91 Append(b, len, bits); 101 92 m_tcNext = tcNext; … … 126 117 127 118 const int16_t* Data16(const range_t &avail) const 128 119 { 129 unsigned start = MS2Samples(avail.first - m_tcFirst);120 unsigned start = 0 ; // MS2Samples(avail.first - m_tcFirst); 130 121 return reinterpret_cast< const int16_t* >(constData() + start * BytesPerSample()); 131 122 } 132 123 … … 274 265 275 266 LOG(VB_PLAYBACK, LOG_INFO, LOC + 276 267 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; 283 276 284 277 const unsigned range = 1U << m_buffer->BitsPerChannel(); 285 278 const double threshold = 20 * log10(1.0 / range); // 16bit=-96.3296dB => ~6dB/bit … … 287 280 if (height <= 0) 288 281 return 0; 289 282 290 QImage image( width, height, QImage::Format_ARGB32);283 QImage image(imwidth, height, QImage::Format_ARGB32); 291 284 image.fill(0); 292 285 293 286 const int channels = m_buffer->Channels(); 294 287 295 288 // Assume signed 16 bit/sample 296 289 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++ ) 299 293 { 300 294 int left = p[0]; 301 295 int right = channels > 1 ? p[1] : left; 302 p += channels;296 p += pstep; 303 297 304 298 unsigned avg = qAbs(left) + qAbs(right); 305 299 double db = 20 * log10( (double)(avg ? avg : 1) / range); … … 316 310 v = height - 1; 317 311 else if (v < 0) 318 312 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 322 320 } 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 323 333 324 334 MythImage *mi = new MythImage(m_painter); 325 335 mi->Assign(image);