コード例 #1
0
ファイル: producer_libdv.c プロジェクト: bmatherly/mlt
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;
}
コード例 #2
0
ファイル: gstdvdec.c プロジェクト: slkwyy/gst-plugins-good
static GstStateChangeReturn
gst_dvdec_change_state (GstElement * element, GstStateChange transition)
{
  GstDVDec *dvdec = GST_DVDEC (element);
  GstStateChangeReturn ret;


  switch (transition) {
    case GST_STATE_CHANGE_NULL_TO_READY:
      break;
    case GST_STATE_CHANGE_READY_TO_PAUSED:
      dvdec->decoder =
          dv_decoder_new (0, dvdec->clamp_luma, dvdec->clamp_chroma);
      dvdec->decoder->quality = qualities[dvdec->quality];
      dv_set_error_log (dvdec->decoder, NULL);
      gst_video_info_init (&dvdec->vinfo);
      gst_segment_init (&dvdec->segment, GST_FORMAT_UNDEFINED);
      dvdec->src_negotiated = FALSE;
      dvdec->sink_negotiated = FALSE;
      dvdec->need_segment = FALSE;
      /* 
       * Enable this function call when libdv2 0.100 or higher is more
       * common
       */
      /* dv_set_quality (dvdec->decoder, qualities [dvdec->quality]); */
      break;
    case GST_STATE_CHANGE_PAUSED_TO_PLAYING:
      break;
    default:
      break;
  }

  ret = GST_ELEMENT_CLASS (parent_class)->change_state (element, transition);

  switch (transition) {
    case GST_STATE_CHANGE_PLAYING_TO_PAUSED:
      break;
    case GST_STATE_CHANGE_PAUSED_TO_READY:
      dv_decoder_free (dvdec->decoder);
      dvdec->decoder = NULL;
      if (dvdec->pool) {
        gst_buffer_pool_set_active (dvdec->pool, FALSE);
        gst_object_unref (dvdec->pool);
        dvdec->pool = NULL;
      }
      break;
    case GST_STATE_CHANGE_READY_TO_NULL:
      break;
    default:
      break;
  }
  return ret;
}
コード例 #3
0
ファイル: libdv.c プロジェクト: Cuchulain/cinelerra
dv_t* dv_new()
{
	dv_t *dv = calloc(1, sizeof(dv_t));
	if(!dv_initted)
	{
		pthread_mutexattr_t attr;
		dv_initted = 1;
//		dv_init();
		pthread_mutexattr_init(&attr);
		pthread_mutex_init(&dv_lock, &attr);
	}

	dv->decoder = dv_decoder_new(0, 0, 0);
	dv_set_error_log (dv->decoder, 0);
	dv->decoder->quality = DV_QUALITY_BEST;
	dv->decoder->prev_frame_decoded = 0;
	dv->use_mmx = 1;
	return dv;
}
コード例 #4
0
ファイル: dvframe.cpp プロジェクト: 6301158/ofx-dev
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 ) );
}