Exemplo n.º 1
0
dv_decoder_t *dv_decoder_alloc( )
{
	// We'll return a dv_decoder
	dv_decoder_t *this = NULL;

	// Lock the mutex
	pthread_mutex_lock( &decoder_lock );

	// Create the properties if necessary
	if ( dv_decoders == NULL )
	{
		// Create the properties
		dv_decoders = mlt_properties_new( );

		// Create the stack
		mlt_properties_set_data( dv_decoders, "stack", mlt_deque_init( ), 0, ( mlt_destructor )mlt_deque_close, NULL );

		// Register the properties for clean up
		mlt_factory_register_for_clean_up( dv_decoders, ( mlt_destructor )mlt_properties_close );
	}

	// Now try to obtain a decoder
	if ( dv_decoders != NULL )
	{
		// Obtain the stack
		mlt_deque stack = mlt_properties_get_data( dv_decoders, "stack", NULL );

		// Pop the top of the stack
		this = mlt_deque_pop_back( stack );

		// Create a new decoder if none available
		if ( this == NULL )
		{
			// We'll need a unique property ID for this
			char label[ 256 ];

			// Configure the decoder
			this = dv_decoder_new( FALSE, FALSE, FALSE );
			this->quality = DV_QUALITY_COLOR | DV_QUALITY_AC_2;
			this->audio->arg_audio_emphasis = 2;
			dv_set_audio_correction( this, DV_AUDIO_CORRECT_AVERAGE );
			dv_set_error_log( this, NULL );

			// Register it with the properties to ensure clean up
			sprintf( label, "%p", this );
			mlt_properties_set_data( dv_decoders, label, this, 0, ( mlt_destructor )dv_decoder_free, NULL );
		}
	}

	// Unlock the mutex
	pthread_mutex_unlock( &decoder_lock );

	return this;
}
Exemplo n.º 2
0
DVFrame::DVFrame()
{
//#ifdef HAVE_LIBDV

	decoder = dv_decoder_new( 0, 0, 0 );
	decoder->quality = DV_QUALITY_COLOR | DV_QUALITY_AC_1;
	decoder->audio->arg_audio_emphasis = 2;
	dv_set_audio_correction ( decoder, DV_AUDIO_CORRECT_AVERAGE );
	FILE* libdv_log = fopen( "/dev/null", "w" );
	dv_set_error_log( decoder, libdv_log );
//#else

	//if ( maps_initialized == false )
	//{

		//for ( int n = 0; n < 1944; ++n )
		//{
			//int sequence1 = ( ( n / 3 ) + 2 * ( n % 3 ) ) % 6;
			//int sequence2 = sequence1 + 6;
			//int block = 3 * ( n % 3 ) + ( ( n % 54 ) / 18 );

			//block = 6 + block * 16;
			//{
				//register int byte = 8 + 2 * ( n / 54 );
				//palmap_ch1[ n ] = sequence1 * 150 * 80 + block * 80 + byte;
				//palmap_ch2[ n ] = sequence2 * 150 * 80 + block * 80 + byte;
				//byte += ( n / 54 );
				//palmap_2ch1[ n ] = sequence1 * 150 * 80 + block * 80 + byte;
				//palmap_2ch2[ n ] = sequence2 * 150 * 80 + block * 80 + byte;
			//}
		//}
		//for ( int n = 0; n < 1620; ++n )
		//{
			//int sequence1 = ( ( n / 3 ) + 2 * ( n % 3 ) ) % 5;
			//int sequence2 = sequence1 + 5;
			//int block = 3 * ( n % 3 ) + ( ( n % 45 ) / 15 );

			//block = 6 + block * 16;
			//{
				//register int byte = 8 + 2 * ( n / 45 );
				//ntscmap_ch1[ n ] = sequence1 * 150 * 80 + block * 80 + byte;
				//ntscmap_ch2[ n ] = sequence2 * 150 * 80 + block * 80 + byte;
				//byte += ( n / 45 );
				//ntscmap_2ch1[ n ] = sequence1 * 150 * 80 + block * 80 + byte;
				//ntscmap_2ch2[ n ] = sequence2 * 150 * 80 + block * 80 + byte;
			//}
		//}
		//for ( int y = 0x700; y <= 0x7ff; ++y )
			//compmap[ y ] = ( y - 0x600 ) << 6;
		//for ( int y = 0x600; y <= 0x6ff; ++y )
			//compmap[ y ] = ( y - 0x500 ) << 5;
		//for ( int y = 0x500; y <= 0x5ff; ++y )
			//compmap[ y ] = ( y - 0x400 ) << 4;
		//for ( int y = 0x400; y <= 0x4ff; ++y )
			//compmap[ y ] = ( y - 0x300 ) << 3;
		//for ( int y = 0x300; y <= 0x3ff; ++y )
			//compmap[ y ] = ( y - 0x200 ) << 2;
		//for ( int y = 0x200; y <= 0x2ff; ++y )
			//compmap[ y ] = ( y - 0x100 ) << 1;
		//for ( int y = 0x000; y <= 0x1ff; ++y )
			//compmap[ y ] = y;
		//for ( int y = 0x800; y <= 0xfff; ++y )
			//compmap[ y ] = -1 - compmap[ 0xfff - y ];
		//maps_initialized = true;
	//}
//#endif
	for ( int n = 0; n < 4; n++ )
		audio_buffers[ n ] = ( int16_t * ) malloc( 2 * DV_AUDIO_MAX_SAMPLES * sizeof( int16_t ) );
}