diff options
| author | Carl Hetherington <cth@carlh.net> | 2016-08-16 13:24:05 +0100 |
|---|---|---|
| committer | Carl Hetherington <cth@carlh.net> | 2016-08-16 13:24:05 +0100 |
| commit | a9228a36ed335dc0a624f0d65b9a2d9e42bec3b0 (patch) | |
| tree | 142b81fc9c39c2cb9275db017083e3274eb8a2d4 /src/wx/video_waveform_plot.cc | |
| parent | 001cc50440d2cdc9edb70223454342c881acac2c (diff) | |
Slightly better plotting of video waveform.
Diffstat (limited to 'src/wx/video_waveform_plot.cc')
| -rw-r--r-- | src/wx/video_waveform_plot.cc | 27 |
1 files changed, 13 insertions, 14 deletions
diff --git a/src/wx/video_waveform_plot.cc b/src/wx/video_waveform_plot.cc index 794922bff..eb2cf97c6 100644 --- a/src/wx/video_waveform_plot.cc +++ b/src/wx/video_waveform_plot.cc @@ -138,37 +138,36 @@ VideoWaveformPlot::create_waveform () return; } - dcp::Size const size = _image->size(); - _waveform.reset (new Image (AV_PIX_FMT_RGB24, dcp::Size (size.width, size.height), true)); + dcp::Size const image_size = _image->size(); + int const waveform_height = GetSize().GetHeight() - _vertical_margin * 2; + _waveform.reset (new Image (AV_PIX_FMT_RGB24, dcp::Size (image_size.width, waveform_height), true)); - for (int x = 0; x < size.width; ++x) { + for (int x = 0; x < image_size.width; ++x) { /* Work out one vertical `slice' of waveform pixels. Each value in strip is the number of samples in image with the corresponding group of values. */ - int strip[size.height]; - for (int i = 0; i < size.height; ++i) { - strip[i] = 0; - } + int strip[waveform_height]; + memset (strip, 0, waveform_height * sizeof(int)); int* ip = _image->data (_component) + x; - for (int y = 0; y < size.height; ++y) { - strip[*ip * size.height / 4096]++; - ip += size.width; + for (int y = 0; y < image_size.height; ++y) { + strip[*ip * waveform_height / 4096]++; + ip += image_size.width; } /* Copy slice into the waveform */ uint8_t* wp = _waveform->data()[0] + x * 3; - for (int y = size.height - 1; y >= 0; --y) { - wp[0] = wp[1] = wp[2] = min (255, (strip[y] * 255 / size.height) * _contrast); + for (int y = waveform_height - 1; y >= 0; --y) { + wp[0] = wp[1] = wp[2] = min (255, (strip[y] * 255 / waveform_height) * _contrast); wp += _waveform->stride()[0]; } } _waveform = _waveform->scale ( - dcp::Size (GetSize().GetWidth() - 32, GetSize().GetHeight() - _vertical_margin * 2), - dcp::YUV_TO_RGB_REC709, AV_PIX_FMT_RGB24, false, true + dcp::Size (GetSize().GetWidth() - 32, waveform_height), + dcp::YUV_TO_RGB_REC709, AV_PIX_FMT_RGB24, false, false ); } |
