]> git.sesse.net Git - vlc/commitdiff
* include/vlc_common.h, include/vlc_es.h: new video_palette_t structure.
authorGildas Bazin <gbazin@videolan.org>
Sun, 25 Jan 2004 21:39:37 +0000 (21:39 +0000)
committerGildas Bazin <gbazin@videolan.org>
Sun, 25 Jan 2004 21:39:37 +0000 (21:39 +0000)
* modules/codec/ffmpeg/*: support for palettized codecs.

include/vlc_common.h
include/vlc_es.h
modules/codec/ffmpeg/demux.c
modules/codec/ffmpeg/video.c

index d931212bd2143b335e50fbe4ea3631cc509ff1ad..260b4d04611590fe43dee9b595388a86e1c70977 100644 (file)
@@ -3,7 +3,7 @@
  * Collection of useful common types and macros definitions
  *****************************************************************************
  * Copyright (C) 1998, 1999, 2000 VideoLAN
- * $Id: vlc_common.h,v 1.104 2004/01/24 20:40:46 fenrir Exp $
+ * $Id: vlc_common.h,v 1.105 2004/01/25 21:39:37 gbazin Exp $
  *
  * Authors: Samuel Hocevar <sam@via.ecp.fr>
  *          Vincent Seguin <seguin@via.ecp.fr>
@@ -228,7 +228,8 @@ typedef struct stream_sys_t stream_sys_t;
 typedef struct audio_format_t audio_format_t;
 typedef struct video_format_t video_format_t;
 typedef struct subs_format_t subs_format_t;
-typedef struct es_format_t  es_format_t;
+typedef struct es_format_t es_format_t;
+typedef struct video_palette_t video_palette_t;
 
 /* NInput */
 typedef struct stream_t stream_t;
index 60ff56bcb7e122e10669630dd08958e8a00d85e9..f4c85d62fa5711fbb6aae50c62d0ed4f9adc4bde 100644 (file)
@@ -1,8 +1,8 @@
 /*****************************************************************************
- * vlc_es.h
+ * vlc_es.h: Elementary stream formats descriptions
  *****************************************************************************
  * Copyright (C) 1999-2001 VideoLAN
- * $Id: vlc_es.h,v 1.6 2004/01/19 18:15:29 fenrir Exp $
+ * $Id: vlc_es.h,v 1.7 2004/01/25 21:39:37 gbazin Exp $
  *
  * Authors: Laurent Aimar <fenrir@via.ecp.fr>
  *
 #define _VLC_ES_H 1
 
 /**
- * Description of a audio frame
+ * \file
+ * This file defines the elementary streams format types
  */
-struct audio_format_t
+
+/**
+ * video palette data
+ * \see viedo_format_t
+ * \see subs_format_t
+ */
+struct video_palette_t
 {
-    vlc_fourcc_t        i_format;
+    int i_dummy; /**< to keep the compatibility with ffmpeg's palette */
+
+    uint32_t palette[256]; /**< 4-byte ARGB palette entries, stored in native
+                            * byte order */
+};
 
-    unsigned int        i_rate;
+/**
+ * audio format description
+ */
+struct audio_format_t
+{
+    vlc_fourcc_t i_format;                          /**< audio format fourcc */
+    unsigned int i_rate;                              /**< audio sample-rate */
 
     /* Describes the channels configuration of the samples (ie. number of
      * channels which are available in the buffer, and positions). */
-    uint32_t            i_physical_channels;
+    uint32_t     i_physical_channels;
 
     /* Describes from which original channels, before downmixing, the
      * buffer is derived. */
-    uint32_t            i_original_channels;
+    uint32_t     i_original_channels;
 
     /* Optional - for A/52, SPDIF and DTS types : */
     /* Bytes used by one compressed frame, depends on bitrate. */
-    unsigned int        i_bytes_per_frame;
+    unsigned int i_bytes_per_frame;
 
     /* Number of sampleframes contained in one compressed frame. */
     unsigned int        i_frame_length;
@@ -60,7 +77,7 @@ struct audio_format_t
 };
 
 /**
- * Description of a video frame
+ * video format description
  */
 struct video_format_t
 {
@@ -78,10 +95,12 @@ struct video_format_t
 
     unsigned int i_frame_rate;                     /**< frame rate numerator */
     unsigned int i_frame_rate_base;              /**< frame rate denominator */
+
+    video_palette_t *p_palette;              /**< video palette from demuxer */
 };
 
 /**
- * Description of subs
+ * subtitles format description
  */
 struct subs_format_t
 {
@@ -174,4 +193,3 @@ static inline void es_format_Copy( es_format_t *dst, es_format_t *src )
 }
 
 #endif
-
index b89d54b891139e9d5a8b5eafab40dc547a50f9e9..e5233a0a5c24221920482f63e9b326f4ba7ad4c0 100644 (file)
@@ -2,7 +2,7 @@
  * demux.c: demuxer using ffmpeg (libavformat).
  *****************************************************************************
  * Copyright (C) 2004 VideoLAN
- * $Id: demux.c,v 1.3 2004/01/15 19:46:32 gbazin Exp $
+ * $Id: demux.c,v 1.4 2004/01/25 21:39:37 gbazin Exp $
  *
  * Authors: Laurent Aimar <fenrir@via.ecp.fr>
  *          Gildas Bazin <gbazin@netcourrier.com>
@@ -176,6 +176,11 @@ int E_(OpenDemux)( vlc_object_t *p_this )
             es_format_Init( &fmt, VIDEO_ES, fcc );
             fmt.video.i_width = cc->width;
             fmt.video.i_height = cc->height;
+            if( cc->palctrl )
+            {
+                fmt.video.p_palette = malloc( sizeof(video_palette_t) );
+                *fmt.video.p_palette = *(video_palette_t *)cc->palctrl;
+            }
             break;
         default:
             break;
index 34b2009855175cbe072561c0eae6d78d90cab8d8..dfb5a3707218ba365980574168df3b743b827e19 100644 (file)
@@ -2,7 +2,7 @@
  * video.c: video decoder using the ffmpeg library
  *****************************************************************************
  * Copyright (C) 1999-2001 VideoLAN
- * $Id: video.c,v 1.61 2004/01/18 21:30:25 fenrir Exp $
+ * $Id: video.c,v 1.62 2004/01/25 21:39:37 gbazin Exp $
  *
  * Authors: Laurent Aimar <fenrir@via.ecp.fr>
  *          Gildas Bazin <gbazin@netcourrier.com>
@@ -335,9 +335,13 @@ int E_(InitVideoDec)( decoder_t *p_dec, AVCodecContext *p_context,
     p_dec->fmt_out.i_cat = VIDEO_ES;
     p_dec->fmt_out.i_codec = ffmpeg_PixFmtToChroma( p_context->pix_fmt );
 
-    /* Setup dummy palette to avoid segfaults with some codecs */
+    /* Setup palette */
 #if LIBAVCODEC_BUILD >= 4688
-    p_sys->p_context->palctrl = &palette_control;
+    if( p_dec->fmt_in.video.p_palette )
+        p_sys->p_context->palctrl =
+            (AVPaletteControl *)p_dec->fmt_in.video.p_palette;
+    else
+        p_sys->p_context->palctrl = &palette_control;
 #endif
 
     /* ***** Open the codec ***** */