]> git.sesse.net Git - mlt/commitdiff
framework/mlt_frame.c
authorlilo_booter <lilo_booter@d19143bc-622f-0410-bfdd-b5b2a6649095>
Sun, 10 Jul 2005 04:39:57 +0000 (04:39 +0000)
committerlilo_booter <lilo_booter@d19143bc-622f-0410-bfdd-b5b2a6649095>
Sun, 10 Jul 2005 04:39:57 +0000 (04:39 +0000)
framework/mlt_frame.h
+ Added sample calculator (samples to current frame)

framework/mlt_repository.c
+ Symbols exported from plugins

modules/kino/filehandler.cc
modules/kino/filehandler.h
+ Audio handling of dv mov

git-svn-id: https://mlt.svn.sourceforge.net/svnroot/mlt/trunk/mlt@755 d19143bc-622f-0410-bfdd-b5b2a6649095

src/framework/mlt_frame.c
src/framework/mlt_frame.h
src/framework/mlt_repository.c
src/modules/kino/filehandler.cc
src/modules/kino/filehandler.h

index 2c67e761bab89cb801c7af8b223a14db292f9639..dcd5ec7557960b8aebb51597a0929f9cd50176b7 100644 (file)
@@ -1065,3 +1065,32 @@ int mlt_sample_calculator( float fps, int frequency, int64_t position )
 
        return samples;
 }
+
+int64_t mlt_sample_calculator_to_now( float fps, int frequency, int64_t frame )
+{
+       int64_t samples = 0;
+
+       // TODO: Correct rules for NTSC and drop the * 100 hack
+       if ( ( int )( fps * 100 ) == 2997 )
+       {
+               samples = ( ( double )( frame * frequency ) / 30 );
+               switch( frequency )
+               {
+                       case 48000:
+                               samples += 2 * ( frame / 5 );
+                               break;
+                       case 44100:
+                               samples += frame + ( frame / 2 ) - ( frame / 30 ) + ( frame / 300 );
+                               break;
+                       case 32000:
+                               samples += ( 2 * frame ) - ( frame / 4 ) - ( frame / 29 );
+                               break;
+               }
+       }
+       else if ( fps != 0 )
+       {
+               samples = ( ( frame * frequency ) / ( int )fps );
+       }
+
+       return samples;
+}
index f81a453a1e0d3b99f40013494bc639373d545453..3752f3ad7c0070018b7b5a9bbece9cd99501f7da 100644 (file)
@@ -82,6 +82,7 @@ extern uint8_t *mlt_frame_rescale_yuv422( mlt_frame self, int owidth, int oheigh
 extern void mlt_resize_yuv422( uint8_t *output, int owidth, int oheight, uint8_t *input, int iwidth, int iheight );
 extern int mlt_frame_mix_audio( mlt_frame self, mlt_frame that, float weight_start, float weight_end, int16_t **buffer, mlt_audio_format *format, int *frequency, int *channels, int *samples  );
 extern int mlt_sample_calculator( float fps, int frequency, int64_t position );
+extern int64_t mlt_sample_calculator_to_now( float fps, int frequency, int64_t position );
 
 /* this macro scales rgb into the yuv gamut, y is scaled by 219/255 and uv by 224/255 */
 #define RGB2YUV(r, g, b, y, u, v)\
index d0dbcd9699bc0ab8511187e3f02018acf54fa51f..45a2e9258afed7c946a0d699df812bfa6f45e201 100644 (file)
@@ -90,7 +90,7 @@ static void *construct_instance( mlt_properties service_properties, const char *
                construct_full_file( full_file, prefix, file );
 
                // Open the shared object
-               object = dlopen( full_file, RTLD_NOW );
+               object = dlopen( full_file, RTLD_NOW | RTLD_GLOBAL );
                if ( object != NULL )
                {
                        // Set it on the properties
index 67412fda8cbdab34deecc949293d6a1200801934..dc57a300bbba4ede385af57746eb3f1a7a317f08 100644 (file)
 
 #include "config.h"
 
+extern "C" {
+#include <framework/mlt_frame.h>
+}
+
 #include <string>
 #include <iostream>
 #include <sstream>
@@ -895,15 +899,22 @@ int QtHandler::GetFrame( uint8_t *data, int frameNum )
                if ( ! isFullyInitialized )
                        AllocateAudioBuffers();
 
+               // Fetch the frequency of the audio track and calc number of samples needed
                int frequency = quicktime_sample_rate( fd, 0 );
-               int samples = ( int )( frequency / quicktime_frame_rate( fd, 0 ) );
-               for ( int i = 0; i < channels; i++ )
-               {
-                       quicktime_set_audio_position( fd, ( int64_t )( frameNum * samples ), 0 );
-                       quicktime_decode_audio( fd, audioChannelBuffer[ i ], NULL, (long) samples, i );
-               }
+               float fps = ( data[ 3 ] & 0x80 ) ? 25.0f : 29.97f;
+               int samples = mlt_sample_calculator( fps, frequency, frameNum );
+               int64_t seek = mlt_sample_calculator_to_now( fps, frequency, frameNum );
+
+               // Obtain a dv encoder and initialise it with minimal info
                dv_encoder_t *encoder = dv_encoder_new( 0, 0, 0 );
+               encoder->isPAL = ( data[ 3 ] & 0x80 );
                encoder->samples_this_frame = samples;
+
+               // Seek to the calculated position and decode
+               quicktime_set_audio_position( fd, seek, 0 );
+               lqt_decode_audio( fd, audioChannelBuffer, NULL, (long) samples );
+
+               // Encode the audio on the frame and done
                dv_encode_full_audio( encoder, audioChannelBuffer, channels, frequency, data );
                dv_encoder_free( encoder );
        }
index 7b7d5ab07bc469d8925e737f69e44514c14213fc..d7292ab2d9c14ae52af62d6fe47a89a5c8c0f316 100644 (file)
@@ -180,7 +180,7 @@ protected:
 
 
 #ifdef HAVE_LIBQUICKTIME
-#include <quicktime.h>
+#include <lqt.h>
 
 class QtHandler: public FileHandler
 {