From 6fd39f9d2c31ef1cb5672caf0f69a519708793a4 Mon Sep 17 00:00:00 2001 From: ddennedy Date: Mon, 30 Aug 2004 04:49:59 +0000 Subject: [PATCH] properly deal with evaluation of magnitude of 2s complement for waveform generation git-svn-id: https://mlt.svn.sourceforge.net/svnroot/mlt/trunk/mlt@400 d19143bc-622f-0410-bfdd-b5b2a6649095 --- src/framework/mlt_frame.c | 7 ++++--- 1 files changed, 4 insertions(+), 3 deletions(-) diff --git a/src/framework/mlt_frame.c b/src/framework/mlt_frame.c index fc67de8..5593c6b 100644 --- a/src/framework/mlt_frame.c +++ b/src/framework/mlt_frame.c @@ -369,10 +369,11 @@ unsigned char *mlt_frame_get_waveform( mlt_frame this, double fps, int w, int h // pcm data has channels interleaved for ( j = 0; j < channels; j++ ) { - // The height of a line is the ratio of the sample multiplied by + // Determine sample's magnitude from 2s complement; + int pcm_magnitude = *pcm < 0 ? ~(*pcm) + 1 : *pcm; + // The height of a line is the ratio of the magnitude multiplied by // half the vertical resolution - int pcm_scaled = ( int )( ( double )( *pcm ) / 32768 * h / 2 ); - int height = pcm_scaled < 0 ? -pcm_scaled : pcm_scaled; + int height = ( int )( ( double )( pcm_magnitude ) / 32768 * h / 2 ); // Determine the starting y coordinate - left channel above center, // right channel below - currently assumes 2 channels int displacement = ( h / 2 ) - ( 1 - j ) * height; -- 1.7.4.4