Hi Jean-Luc,

Could you try the attached patch? I finally got the svn installed on my desktop, which is fast enough to actually process a DV stream (my laptop is a bit slow for it, and I thought the distortion was as a result). I've believed I fixed it, but at the moment the only sources I have to test with are 44.1 kHz NTSC. Please let me know how it works, and what sample rate/stream type (PAL or NTSC) you are using.

There appears to be an audio writing bug still, but I have yet to find it. Hopefully, now that reading is fixed (at least for me), I'll be able to find it quickly and patch it.

Thank,

Richard

Jean-Luc Coulon (f5ibh) wrote:

Hi Richard,

Le 22.01.2006 23:21:09, Richard Baverstock a écrit :

Does your original file play back fine? What sample rate are you rendering to? What sample rate is your source?


This doesnt occurs while doing the rendering. This occurs while playing a DV file.

I load any DV raw file. And I play it in the Compositor or the Viewer.

The audio is completely boken (hearing it).
This occurs only with SVN version 727

Regards

Jean-Luc
....



I've rebuilt cinelerra from SVN (revision 727) and the raw DV audio rendering in very bad. The audio is undecipherable. I've not this problem with svn revision 726.

I've just loaded a raw DV file without adding any effect.

Regards

Jean-Luc

------------------------------------------------------------------------

* Application(s) deleted before forwarding

--
------------------------------------------------------------
+ Richard Baverstock             + 2A Computer Engineering +
+ [EMAIL PROTECTED]  + University of Waterloo  +
+ +1 (519) 888-6232              + http://thebeever.com    +
+                                                          +
+ Blog: http://thebeever.com/pages/index.php?page_id=8     +
------------------------------------------------------------

Index: filedv.C
===================================================================
--- filedv.C	(revision 727)
+++ filedv.C	(working copy)
@@ -754,7 +754,7 @@
 		delete[] out_buffer[i];
 	delete[] out_buffer;
 
-//	audio_position += len;
+	audio_position += len;
 	
 	return result;
 }
@@ -928,72 +928,13 @@
 	}
 	else
 	{
-		// NTSC is a bit more of a challenge. Since various frames
-		// in each sample rate contain different number of samples,
-		// we need to make sure we point to the correct frame
-		// within the final "second".
-
 		// Frame at the start of the last second
-		int frame = pos / asset->sample_rate;			// This is actually the last full second
-
-		// Samples needed from the last second
-		int leftover = pos - frame * asset->sample_rate;
-
-		frame *= 30; 	// Now it's actually the frame. We use 30, since the below
-							// algorithm takes into account the dropped frames.
-							// If the frame rate happens to be a frame rate other than
-							// 29.97, this will be incorrect.
-
-		// Frame offset within the last second		
-		int sf_count = 0;
-
-		switch(asset->sample_rate)
-		{
-			case 48000:
-				for(; leftover >= 0; sf_count++)
-				{
-					frame++;
-					if(sf_count % 5 != 0)
-						leftover -= 1602;
-					else
-						leftover -= 1600;
-				}
-				break;
-			case 44100:
-				for(; leftover >= 0; sf_count++)
-				{
-					frame++;
-					if(sf_count % 300 == 0)
-						leftover -= 1471;
-					else if(sf_count % 30 == 0)
-						leftover -= 1470;
-					else if(sf_count % 2 == 0)
-						leftover -= 1472;
-					else
-						leftover -= 1471;
-				}
-				break;
-			case 32000:
-				for(; leftover >= 0; sf_count++)
-				{
-					frame++;
-					if(sf_count % 30 == 0)
-						leftover -= 1068;
-					else if(sf_count % 29 == 0)
-						leftover -= 1067;
-					else if(sf_count % 4 == 2)
-						leftover -= 1067;
-					else
-						leftover -= 1068;
-				}
-			default:
-				break;
-		}
+		int frame = (double) pos * asset->frame_rate / asset->sample_rate;
 		return frame;
 	}
 }
 
-
+// Get the sample offset from the frame start reported by get_audio_frame
 int FileDV::get_audio_offset(int64_t pos)
 {
 	if(isPAL)
@@ -1006,64 +947,12 @@
 	}
 	else
 	{
-		// NTSC is a bit more of a challenge. Since various frames
-		// in each sample rate contain different number of samples,
-		// we need to make sure we point to the correct frame
-		// within the final "second".
+		int frame = get_audio_frame(pos);
+		
+		// Samples needed from last frame
+		int leftover = pos - frame * asset->sample_rate / asset->frame_rate;
 
-		// Sample offset from the last frame.
-		int offset = 0;
-
-		// Samples needed from the last second
-		int leftover = pos % asset->sample_rate;
-
-		// Frame offset up to start of last second
-		int sf_count = pos * asset->frame_rate / asset->sample_rate;
-
-		switch(asset->sample_rate)
-		{
-			case 48000:
-				for(; leftover >= 0; sf_count++)
-				{
-					offset = leftover;
-					if(sf_count % 5 != 0)
-						leftover -= 1602;
-					else
-						leftover -= 1600;
-				}
-				break;
-			case 44100:
-				for(; leftover >= 0; sf_count++)
-				{
-					offset = leftover;
-					if(sf_count % 300 == 0)
-						leftover -= 1471;
-					else if(sf_count % 30 == 0)
-						leftover -= 1470;
-					else if(sf_count % 2 == 0)
-						leftover -= 1472;
-					else
-						leftover -= 1471;
-				}
-				break;
-			case 32000:
-				for(; leftover >= 0; sf_count++)
-				{
-					offset = leftover;
-					if(sf_count % 30 == 0)
-						leftover -= 1068;
-					else if(sf_count % 29 == 0)
-						leftover -= 1067;
-					else if(sf_count % 4 == 2)
-						leftover -= 1067;
-					else
-						leftover -= 1068;
-				}
-				break;
-			default:
-				break;
-		}
-		return offset;
+		return leftover;
 	}
 }
 

Reply via email to