gst-plugins-nuvdemux/src/gstnuvdemux.h
author melunko
Tue Oct 24 15:02:26 2006 +0100 (2006-10-24)
branchtrunk
changeset 47 8bff300ebf50
child 56 24be83eaef89
permissions -rw-r--r--
[svn r48] Added gst-plugins-nuvdemux
     1 /* GStreamer
     2  * Copyright (C) <2006> Renato Araujo Oliveira Filho <renato.filho@indt.org.br>
     3  *                      Rosfran Borges <rosfran.borges@indt.org.br>
     4  *
     5  * This library is free software; you can redistribute it and/or
     6  * modify it under the terms of the GNU Library General Public
     7  * License as published by the Free Software Foundation; either
     8  * version 2 of the License, or (at your option) any later version.
     9  *
    10  * This library is distributed in the hope that it will be useful,
    11  * but WITHOUT ANY WARRANTY; without even the implied warranty of
    12  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
    13  * Library General Public License for more details.
    14  *
    15  * You should have received a copy of the GNU Library General Public
    16  * License along with this library; if not, write to the
    17  * Free Software Foundation, Inc., 59 Temple Place - Suite 330,
    18  * Boston, MA 02111-1307, USA.
    19  */
    20 
    21 #ifndef __GST_NUV_DEMUX_H__
    22 #define __GST_NUV_DEMUX_H__
    23 
    24 #include <gst/gst.h>
    25 
    26 #include <gst/base/gstadapter.h>
    27 
    28 G_BEGIN_DECLS
    29 
    30 #define GST_TYPE_NUV_DEMUX \
    31   (gst_nuv_demux_get_type ())
    32 #define GST_NUV_DEMUX(obj) \
    33   (G_TYPE_CHECK_INSTANCE_CAST ((obj), GST_TYPE_NUV_DEMUX, GstNuvDemux))
    34 #define GST_NUV_DEMUX_CLASS(klass) \
    35   (G_TYPE_CHECK_CLASS_CAST ((klass), GST_TYPE_NUV_DEMUX, GstNuvDemuxClass))
    36 #define GST_IS_NUV_DEMUX(obj) \
    37   (G_TYPE_CHECK_INSTANCE_TYPE ((obj), GST_TYPE_NUV_DEMUX))
    38 #define GST_IS_NUV_DEMUX_CLASS(klass) \
    39   (G_TYPE_CHECK_CLASS_TYPE ((klass), GST_TYPE_NUV_DEMUX))
    40 
    41 
    42 /* */
    43 typedef struct
    44 {
    45     gchar id[12];       /* "NuppelVideo\0" or "MythTVVideo\0" */
    46     gchar version[5];    /* "x.xx\0" */
    47 
    48     gint  i_width;
    49     gint  i_height;
    50     gint  i_width_desired;
    51     gint  i_height_desired;
    52 
    53     gchar i_mode;            /* P progressive, I interlaced */
    54 
    55     gdouble  d_aspect;       /* 1.0 squared pixel */
    56     gdouble  d_fps;
    57 
    58     gint     i_video_blocks; /* 0 no video, -1 unknown */
    59     gint     i_audio_blocks;
    60     gint     i_text_blocks;
    61 
    62     gint     i_keyframe_distance;
    63 
    64 } nuv_header;
    65 
    66 typedef struct
    67 {
    68     gchar i_type;        /* A: audio, V: video, S: sync; T: test
    69                            R: Seekpoint (string:RTjjjjjjjj)
    70                            D: Extra data for codec */
    71     gchar i_compression; /* V: 0 uncompressed
    72                               1 RTJpeg
    73                               2 RTJpeg+lzo
    74                               N black frame
    75                               L copy last
    76                            A: 0 uncompressed (44100 1-bits, 2ch)
    77                               1 lzo
    78                               2 layer 2
    79                               3 layer 3
    80                               F flac
    81                               S shorten
    82                               N null frame loudless
    83                               L copy last
    84                             S: B audio and vdeo sync point
    85                                A audio sync info (timecode == effective
    86                                     dsp frequency*100)
    87                                V next video sync (timecode == next video
    88                                     frame num)
    89                                S audio,video,text correlation */
    90     gchar i_keyframe;    /* 0 keyframe, else no no key frame */
    91     guint8 i_filters;  /* 0x01: gauss 5 pixel (8,2,2,2,2)/16
    92                            0x02: gauss 5 pixel (8,1,1,1,1)/12
    93                            0x04: cartoon filter */
    94 
    95     guint32 i_timecode;     /* ms */
    96 
    97     guint32 i_length;       /* V,A,T: length of following data
    98                            S: length of packet correl */
    99 } nuv_frame_header;
   100 
   101 /* FIXME Not sure of this one */
   102 typedef struct
   103 {
   104     gint             i_version;
   105     guint32		     i_video_fcc;
   106 
   107     guint32		     i_audio_fcc;
   108     gint             i_audio_sample_rate;
   109     gint             i_audio_bits_per_sample;
   110     gint             i_audio_channels;
   111     gint             i_audio_compression_ratio;
   112     gint             i_audio_quality;
   113     gint             i_rtjpeg_quality;
   114     gint             i_rtjpeg_luma_filter;
   115     gint             i_rtjpeg_chroma_filter;
   116     gint             i_lavc_bitrate;
   117     gint             i_lavc_qmin;
   118     gint             i_lavc_qmax;
   119     gint             i_lavc_maxqdiff;
   120     gint64         	 i_seekable_offset;
   121     gint64           i_keyframe_adjust_offset;
   122 
   123 } nuv_extended_header;
   124 
   125 typedef enum {
   126   GST_NUV_DEMUX_START,
   127   GST_NUV_DEMUX_HEADER_DATA,
   128   GST_NUV_DEMUX_EXTRA_DATA,
   129   GST_NUV_DEMUX_MPEG_DATA,
   130   GST_NUV_DEMUX_EXTEND_HEADER,
   131   GST_NUV_DEMUX_EXTEND_HEADER_DATA,
   132   GST_NUV_DEMUX_FRAME_HEADER,
   133   GST_NUV_DEMUX_MOVI,
   134   GST_NUV_DEMUX_INVALID_DATA
   135 } GstNuvDemuxState;
   136 
   137 typedef struct _GstNuvDemux {
   138   GstElement     parent;
   139 
   140   guint         mode;
   141   GstAdapter    *adapter; 
   142   guint64       video_offset;
   143   guint64       audio_offset;
   144 
   145   /* pads */
   146   GstPad        *sinkpad;
   147   GstPad        *src_video_pad;  
   148   GstPad        *src_audio_pad;
   149   gboolean      first_video;
   150   gboolean      first_audio;
   151 
   152   /* NUV decoding state */
   153   GstNuvDemuxState state;
   154   guint64        offset;
   155 
   156   /* Mpeg ExtraData */
   157   guint64       mpeg_data_size;
   158   GstBuffer     *mpeg_buffer;
   159   
   160   nuv_header *h;
   161   nuv_extended_header *eh;
   162   nuv_frame_header *fh;
   163 } GstNuvDemux;
   164 
   165 typedef struct _GstNuvDemuxClass {
   166   GstElementClass parent_class;
   167 } GstNuvDemuxClass;
   168 
   169 GType           gst_nuv_demux_get_type          (void);
   170 
   171 G_END_DECLS
   172 
   173 #endif /* __GST_NUV_DEMUX_H__ */