From 886334fcf825d2b69e29953640c2da200f415e17 Mon Sep 17 00:00:00 2001 From: Dan Dennedy Date: Thu, 19 Aug 2010 01:21:31 -0700 Subject: [PATCH] Improve audio waveform resault reliability. This scales the audio sample rate up to meet the requested image resolution, 16 KHz at a time. --- src/framework/mlt_frame.c | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/src/framework/mlt_frame.c b/src/framework/mlt_frame.c index 3b644d13..546d5b47 100644 --- a/src/framework/mlt_frame.c +++ b/src/framework/mlt_frame.c @@ -698,6 +698,13 @@ unsigned char *mlt_frame_get_waveform( mlt_frame this, int w, int h ) double fps = mlt_producer_get_fps( mlt_producer_cut_parent( producer ) ); int samples = mlt_sample_calculator( fps, frequency, mlt_frame_get_position( this ) ); + // Increase audio resolution proportional to requested image size + while ( samples < w ) + { + frequency += 16000; + samples = mlt_sample_calculator( fps, frequency, mlt_frame_get_position( this ) ); + } + // Get the pcm data mlt_frame_get_audio( this, (void**)&pcm, &format, &frequency, &channels, &samples ); @@ -711,8 +718,7 @@ unsigned char *mlt_frame_get_waveform( mlt_frame this, int w, int h ) // Render vertical lines int16_t *ubound = pcm + samples * channels; int skip = samples / w; - if ( !skip ) - return NULL; + skip = !skip ? 1 : skip; unsigned char gray = 0xFF / skip; int i, j, k; -- 2.39.2