]> git.sesse.net Git - vlc/blobdiff - modules/codec/quicktime.c
avcodec: simplify picture references
[vlc] / modules / codec / quicktime.c
index 0b9959bd9f3640ab51b56cf9fdb40470f04ed6d7..885c758e7ca6c220cd7265c3196bfb91216e1929 100644 (file)
@@ -1,25 +1,25 @@
 /*****************************************************************************
  * quicktime.c: a quicktime decoder that uses the QT library/dll
  *****************************************************************************
- * Copyright (C) 2003, 2008 - 2009 the VideoLAN team
+ * Copyright (C) 2003, 2008 - 2009 VLC authors and VideoLAN
  * $Id$
  *
  * Authors: Laurent Aimar <fenrir at via.ecp.fr>
  *          Derk-Jan Hartman <hartman at videolan.org>>
  *
- * This program is free software; you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as published by
- * the Free Software Foundation; either version 2 of the License, or
+ * This program is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU Lesser General Public License as published by
+ * the Free Software Foundation; either version 2.1 of the License, or
  * (at your option) any later version.
  *
  * This program is distributed in the hope that it will be useful,
  * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
- * GNU General Public License for more details.
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Lesser General Public License for more details.
  *
- * You should have received a copy of the GNU General Public License
- * along with this program; if not, write to the Free Software
- * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston MA 02110-1301, USA.
+ * You should have received a copy of the GNU Lesser General Public License
+ * along with this program; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin Street, Fifth Floor, Boston MA 02110-1301, USA.
  *****************************************************************************/
 
 /*****************************************************************************
 
 #include <vlc_common.h>
 #include <vlc_plugin.h>
-#include <vlc_aout.h>
-#include <vlc_vout.h>
 #include <vlc_codec.h>
 
-#if !defined (__APPLE__) && !defined(WIN32)
+#if !defined (__APPLE__) && !defined(_WIN32)
 # define LOADER 1
 #endif
 
@@ -80,8 +78,10 @@ vlc_module_end ()
 static int           OpenAudio( decoder_t * );
 static int           OpenVideo( decoder_t * );
 
-static aout_buffer_t *DecodeAudio( decoder_t *, block_t ** );
+static block_t       *DecodeAudio( decoder_t *, block_t ** );
+#ifndef _WIN32
 static picture_t     *DecodeVideo( decoder_t *, block_t ** );
+#endif
 
 #define FCC( a, b , c, d ) \
     ((uint32_t)( ((a)<<24)|((b)<<16)|((c)<<8)|(d)))
@@ -144,7 +144,7 @@ struct decoder_sys_t
     unsigned int    InFrameSize;
     unsigned int    OutFrameSize;
 
-#ifndef WIN32
+#ifndef _WIN32
     /* Video */
     Component         (*FindNextComponent)
         ( Component prev, ComponentDescription* desc );
@@ -188,7 +188,7 @@ struct decoder_sys_t
     /* Output properties */
     uint8_t *           plane;
     mtime_t             pts;
-    audio_date_t        date;
+    date_t              date;
 
     int                 i_late; /* video */
 
@@ -215,7 +215,9 @@ static const int pi_channels_maps[6] =
 };
 
 static int QTAudioInit( decoder_t * );
+#ifndef _WIN32
 static int QTVideoInit( decoder_t * );
+#endif
 
 /*****************************************************************************
  * Open: probe the decoder and return score
@@ -230,7 +232,7 @@ static int Open( vlc_object_t *p_this )
 #ifdef __APPLE__
     OSErr err;
     SInt32 qtVersion, macosversion;
-    
+
     err = Gestalt(gestaltQuickTimeVersion, &qtVersion);
     err = Gestalt(gestaltSystemVersion, &macosversion);
 #ifndef NDEBUG
@@ -486,14 +488,14 @@ static int OpenAudio( decoder_t *p_dec )
     }
 
 
-    es_format_Init( &p_dec->fmt_out, AUDIO_ES, AOUT_FMT_S16_NE );
+    es_format_Init( &p_dec->fmt_out, AUDIO_ES, VLC_CODEC_S16N );
     p_dec->fmt_out.audio.i_rate = p_sys->OutputFormatInfo.sampleRate;
     p_dec->fmt_out.audio.i_channels = p_sys->OutputFormatInfo.numChannels;
     p_dec->fmt_out.audio.i_physical_channels =
     p_dec->fmt_out.audio.i_original_channels =
         pi_channels_maps[p_sys->OutputFormatInfo.numChannels];
 
-    aout_DateInit( &p_sys->date, p_dec->fmt_out.audio.i_rate );
+    date_Init( &p_sys->date, p_dec->fmt_out.audio.i_rate, 1 );
 
     p_sys->i_buffer      = 0;
     p_sys->i_buffer_size = 100*1000;
@@ -521,7 +523,7 @@ exit_error:
 /*****************************************************************************
  * DecodeAudio:
  *****************************************************************************/
-static aout_buffer_t *DecodeAudio( decoder_t *p_dec, block_t **pp_block )
+static block_t *DecodeAudio( decoder_t *p_dec, block_t **pp_block )
 {
     decoder_sys_t *p_sys = p_dec->p_sys;
 
@@ -579,7 +581,7 @@ static aout_buffer_t *DecodeAudio( decoder_t *p_dec, block_t **pp_block )
         if( p_sys->i_buffer_size < p_sys->i_buffer + p_block->i_buffer )
         {
             p_sys->i_buffer_size = p_sys->i_buffer + p_block->i_buffer + 1024;
-            p_sys->p_buffer = realloc( p_sys->p_buffer, p_sys->i_buffer_size );
+            p_sys->p_buffer = xrealloc( p_sys->p_buffer, p_sys->i_buffer_size );
         }
         memcpy( &p_sys->p_buffer[p_sys->i_buffer], p_block->p_buffer,
                 p_block->i_buffer );
@@ -615,12 +617,12 @@ static aout_buffer_t *DecodeAudio( decoder_t *p_dec, block_t **pp_block )
                          p_sys->i_buffer );
             }
 
-            if( p_sys->pts != 0 &&
-                p_sys->pts != aout_DateGet( &p_sys->date ) )
+            if( p_sys->pts > VLC_TS_INVALID &&
+                p_sys->pts != date_Get( &p_sys->date ) )
             {
-                aout_DateSet( &p_sys->date, p_sys->pts );
+                date_Set( &p_sys->date, p_sys->pts );
             }
-            else if( !aout_DateGet( &p_sys->date ) )
+            else if( !date_Get( &p_sys->date ) )
             {
                 return NULL;
             }
@@ -636,19 +638,20 @@ static aout_buffer_t *DecodeAudio( decoder_t *p_dec, block_t **pp_block )
 
     if( p_sys->i_out < p_sys->i_out_frames )
     {
-        aout_buffer_t *p_out;
+        block_t *p_out;
         int  i_frames = __MIN( p_sys->i_out_frames - p_sys->i_out, 1000 );
 
         p_out = decoder_NewAudioBuffer( p_dec, i_frames );
 
         if( p_out )
         {
-            p_out->start_date = aout_DateGet( &p_sys->date );
-            p_out->end_date = aout_DateIncrement( &p_sys->date, i_frames );
+            p_out->i_pts = date_Get( &p_sys->date );
+            p_out->i_length = date_Increment( &p_sys->date, i_frames )
+                              - p_out->i_pts;
 
             memcpy( p_out->p_buffer,
                     &p_sys->out_buffer[2 * p_sys->i_out * p_dec->fmt_out.audio.i_channels],
-                    p_out->i_nb_bytes );
+                    p_out->i_buffer );
 
             p_sys->i_out += i_frames;
         }
@@ -663,7 +666,7 @@ static aout_buffer_t *DecodeAudio( decoder_t *p_dec, block_t **pp_block )
  *****************************************************************************/
 static int OpenVideo( decoder_t *p_dec )
 {
-#ifndef WIN32
+#ifndef _WIN32
     decoder_sys_t *p_sys = malloc( sizeof( decoder_sys_t ) );
     if( !p_sys )
         return VLC_ENOMEM;
@@ -840,8 +843,9 @@ static int OpenVideo( decoder_t *p_dec )
     es_format_Init( &p_dec->fmt_out, VIDEO_ES, VLC_CODEC_YUYV);
     p_dec->fmt_out.video.i_width = p_dec->fmt_in.video.i_width;
     p_dec->fmt_out.video.i_height= p_dec->fmt_in.video.i_height;
-    p_dec->fmt_out.video.i_aspect = VOUT_ASPECT_FACTOR * p_dec->fmt_in.video.i_width / p_dec->fmt_in.video.i_height;
+    p_dec->fmt_out.video.i_sar_num = 1;
+    p_dec->fmt_out.video.i_sar_den = 1;
+
     vlc_mutex_unlock( &qt_mutex );
     return VLC_SUCCESS;
 
@@ -851,12 +855,14 @@ exit_error:
 #endif
     vlc_mutex_unlock( &qt_mutex );
 
-#endif /* !WIN32 */
+#else
+    VLC_UNUSED( p_dec );
+#endif /* !_WIN32 */
 
     return VLC_EGENERIC;
 }
 
-#ifndef WIN32
+#ifndef _WIN32
 /*****************************************************************************
  * DecodeVideo:
  *****************************************************************************/
@@ -891,7 +897,7 @@ static picture_t *DecodeVideo( decoder_t *p_dec, block_t **pp_block )
     p_block = *pp_block;
     *pp_block = NULL;
  
-    i_pts = p_block->i_pts ? p_block->i_pts : p_block->i_dts;
+    i_pts = p_block->i_pts > VLC_TS_INVALID ? p_block->i_pts : p_block->i_dts;
 
     mtime_t i_display_date = 0;
     if( !(p_block->i_flags & BLOCK_FLAG_PREROLL) )
@@ -906,7 +912,7 @@ static picture_t *DecodeVideo( decoder_t *p_dec, block_t **pp_block )
         p_sys->i_late = 0;
     }
 #ifndef NDEBUG
-    msg_Dbg( p_dec, "bufsize: %d", (int)p_block->i_buffer);
+    msg_Dbg( p_dec, "bufsize: %zu", p_block->i_buffer);
 #endif
 
     if( p_sys->i_late > 10 )
@@ -945,7 +951,7 @@ static picture_t *DecodeVideo( decoder_t *p_dec, block_t **pp_block )
     block_Release( p_block );
     return p_pic;
 }
-#endif /* !WIN32 */
+#endif /* !_WIN32 */
 
 /*****************************************************************************
  * QTAudioInit:
@@ -1014,7 +1020,7 @@ static int QTAudioInit( decoder_t *p_dec )
     return VLC_SUCCESS;
 }
 
-#ifndef WIN32
+#ifndef _WIN32
 /*****************************************************************************
  * QTVideoInit:
  *****************************************************************************/
@@ -1086,4 +1092,4 @@ static int QTVideoInit( decoder_t *p_dec )
 
     return VLC_SUCCESS;
 }
-#endif /* !WIN32 */
+#endif /* !_WIN32 */