]> git.sesse.net Git - vlc/blobdiff - modules/codec/ogt/ogt.h
Scale bitmaps for 4:3 output
[vlc] / modules / codec / ogt / ogt.h
index 7f142ae28511cc0674b167b421c8d0bd8af6c157..e021f7c1cc380ddc37296d5cefbe7b4cba8c9438 100644 (file)
@@ -2,18 +2,18 @@
  * ogt.h : Overlay Graphics Text (SVCD subtitles) decoder thread interface
  *****************************************************************************
  * Copyright (C) 2003 VideoLAN
- * $Id: ogt.h,v 1.1 2003/12/07 22:14:26 rocky Exp $
+ * $Id: ogt.h,v 1.5 2003/12/27 01:49:59 rocky Exp $
  *
- * Authors: Rocky Bernstein 
- *   based on code from: 
+ * Author: Rocky Bernstein
+ *   based on code from:
  *       Julio Sanchez Fernandez (http://subhandler.sourceforge.net)
- *       Samuel Hocevar <sam@zoy.org>
+ *       Sam Hocevar <sam@zoy.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
  * (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
@@ -27,7 +27,9 @@
 #define DECODE_DBG_EXT         1 /* Calls from external routines */
 #define DECODE_DBG_CALL        2 /* all calls */
 #define DECODE_DBG_PACKET      4 /* packet assembly info */
-#define DECODE_DBG_INFO        8 
+#define DECODE_DBG_IMAGE       8 /* image bitmaps */
+#define DECODE_DBG_TRANSFORM  16 /* bitmap transformations */
+#define DECODE_DBG_INFO       32
 
 #define DECODE_DEBUG 1
 #if DECODE_DEBUG
    if (p_sys && p_sys->i_debug & mask) \
      msg_Dbg(p_dec, "%s: "s, __func__ , ##args)
 #else
-#define dbg_print(mask, s, args...) 
+#define dbg_print(mask, s, args...)
 #endif
 
 #define LOG_ERR(args...)  msg_Err( p_input, args )
 #define LOG_WARN(args...) msg_Warn( p_input, args )
 
 #define GETINT16(p) ( (p[0] <<  8) +  p[1] ); p +=2;
-   
-#define GETINT32(p) ( (p[0] << 24) +  (p[1] << 16) +   \
-                     (p[2] <<  8) +  (p[3]) ) ; p += 4;
+
+#define GETINT32(p) ( (p[0] << 24) +  (p[1] << 16) +    \
+                      (p[2] <<  8) +  (p[3]) ) ; p += 4;
+
+
+/* The number of color palette entries allowed in a subtitle. */
+#define NUM_SUBTITLE_COLORS 4 
 
 typedef enum  {
   SUBTITLE_BLOCK_EMPTY,
@@ -52,93 +58,96 @@ typedef enum  {
   SUBTITLE_BLOCK_COMPLETE
 } packet_state_t;
 
+/* FIXME: REMOVE THE BELOW. */
 /* Color and transparency of a pixel or a palette (CLUT) entry */
 typedef struct ogt_yuvt_val_s {
-  u_int8_t y;
-  u_int8_t u;
-  u_int8_t v;
-  u_int8_t t;
-} ogt_yuvt_val_t;
+  uint8_t y;
+  uint8_t u;
+  uint8_t v;
+  uint8_t t;
+} ogt_yuvt_t;
+
+/* The storage used by one pixel */
+#define PIXEL_SIZE 4
+
+/* Size in bytes of YUV portion above. */ 
+#define YUV_SIZE 3
+
+/* Transparency plane. NOTE: see vlc_video.h for V_PLANE */
+#define T_PLANE  V_PLANE+1
 
 struct decoder_sys_t
 {
-#ifndef FIXED
-  int i_rle_size; /*REMOVE WHEN WE'VE GONE OVER ALL CODE*/
-#endif
-  int i_debug;            /* debugging mask */
-
-  int b_packetizer;
-  
-  mtime_t i_pts;          /* Start PTS of subtitle block */
-  int i_spu_size;        /* size of the allocated subtitle_data */
-  int i_spu;
+  int            i_debug; /* debugging mask */
+  mtime_t        i_pts;   /* Start PTS of subtitle block */
+  int            i_spu;
   packet_state_t state;   /* data-gathering state for this subtitle */
-  u_int16_t i_image;      /* image number in the subtitle stream; 0 is the 
+
+  uint16_t       i_image; /* image number in the subtitle stream; 0 is the 
                             first one. */
-  u_int8_t  i_packet;     /* packet number for above image number; 0 is the 
+  uint8_t        i_packet;/* packet number for above image number; 0 is the 
                             first one. */
+  block_t        *p_block;/* Bytes of the packet. */
   
-  block_t *p_block;       /* Bytes of the packet. */
-  
-  uint8_t buffer[65536 + 20 ]; /* we will never overflow more than 11 bytes if I'm right */
-
+  uint8_t buffer[65536 + 20 ]; /* we will never overflow more than 11
+                                 bytes if I'm right */
+  int     b_packetizer;
+  int     i_spu_size;    /* goal for subtitle_data_pos while gathering,
+                            size of used subtitle_data later */
   vout_thread_t *p_vout;
 
+  /* FIXME: Remove this? */
+  uint8_t *subtitle_data;      /* buffer used to accumulate data from
+                                  successive packets in the same subtitle */
+  int subtitle_data_size;      /* size of the allocated subtitle_data */
+
   /* Move into subpicture_sys_t? */
-  u_int16_t comp_image_offset; /* offset from subtitle_data to compressed
+  uint16_t comp_image_offset;  /* offset from subtitle_data to compressed
                                   image data */
   int comp_image_length;       /* size of the compressed image data */
-  int first_field_offset;
-  int second_field_offset;
-
-  int metadata_offset;         /* offset to data describing the image */
-  int metadata_length;         /* length of metadata */
+  int second_field_offset;      /* offset of odd raster lines */
+  int metadata_offset;          /* offset to data describing the image */
+  int metadata_length;          /* length of metadata */
 
   int subtitle_data_pos;       /* where to write next chunk */
-  int subtitle_data_length;    /* goal for subtitle_data_pos while gathering,
-                                  length of used subtitle_data later */
 
-  u_int32_t duration;          /* how long to display the image, 0 stands
-                                  for "until next sub" */
+  uint32_t i_duration;         /* how long to display the image, 0 stands
+                                  for "until next subtitle" */
 
-  u_int16_t i_x_start, i_y_start; /* position of top leftmost pixel of
+  uint16_t i_x_start, i_y_start; /* position of top leftmost pixel of
                                     image when displayed */
-  u_int16_t i_width, i_height; /* dimensions in pixels of image */
+  uint16_t i_width, i_height;  /* dimensions in pixels of image */
 
-  ogt_yuvt_val_t pi_palette[4];
-  ogt_yuvt_val_t pi_palette_highlight[4];
+  ogt_yuvt_t pi_palette[NUM_SUBTITLE_COLORS];
 
-  u_int8_t i_options;
-  u_int8_t i_options2;
-  u_int8_t i_cmd;
-  u_int32_t i_cmd_arg;
+  uint8_t i_options;
+  uint8_t i_options2;
+  uint8_t i_cmd;
+  uint32_t i_cmd_arg;
 };
 
 struct subpicture_sys_t
 {
-    mtime_t i_pts;                                 /* presentation timestamp */
+  mtime_t i_pts;                /* presentation timestamp */
 
-    int   pi_offset[2];                              /* byte offsets to data */
-    void *p_data;
+  u_int8_t *p_data;             /* Image data one byte T, Y, U, V */
 
-    /* Color information */
-    vlc_bool_t b_palette;
-    uint8_t    pi_alpha[4];
-    uint8_t    pi_yuv[4][3];
-
-    /* Link to our input */
-    vlc_object_t * p_input;
-
-    /* Cropping properties */
-    vlc_mutex_t  lock;
-    vlc_bool_t   b_crop;
-    unsigned int i_x_start, i_y_start, i_x_end, i_y_end;
+  /* Color information */
+  vlc_bool_t b_palette;
+  
+  /* Link to our input */
+  vlc_object_t * p_input;
+  
+  /* Cropping properties */
+  vlc_mutex_t  lock;
+  vlc_bool_t   b_crop;
+  unsigned int i_x_start, i_y_start, i_x_end, i_y_end;
 };
 
 /*****************************************************************************
  * Prototypes
  *****************************************************************************/
+void E_(ParseHeader)( decoder_t *, uint8_t *, block_t *  );
 void E_(ParsePacket)( decoder_t * );
-
 void E_(RenderSPU)  ( vout_thread_t *, picture_t *, const subpicture_t * );