mpeg2.h

Go to the documentation of this file.
00001 /* $Id$
00002  * mpeg2.h
00003  * Copyright (C) 2000-2003 Michel Lespinasse <walken@zoy.org>
00004  * Copyright (C) 1999-2000 Aaron Holtzman <aholtzma@ess.engr.uvic.ca>
00005  *
00006  * This file is part of mpeg2dec, a free MPEG-2 video stream decoder.
00007  * See http://libmpeg2.sourceforge.net/ for updates.
00008  *
00009  * mpeg2dec is free software; you can redistribute it and/or modify
00010  * it under the terms of the GNU General Public License as published by
00011  * the Free Software Foundation; either version 2 of the License, or
00012  * (at your option) any later version.
00013  *
00014  * mpeg2dec is distributed in the hope that it will be useful,
00015  * but WITHOUT ANY WARRANTY; without even the implied warranty of
00016  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
00017  * GNU General Public License for more details.
00018  *
00019  * You should have received a copy of the GNU General Public License
00020  * along with this program; if not, write to the Free Software
00021  * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
00022  */
00023 
00024 #ifndef MPEG2_H
00025 #define MPEG2_H
00026 
00027 #define MPEG2_VERSION(a,b,c) (((a)<<16)|((b)<<8)|(c))
00028 #define MPEG2_RELEASE MPEG2_VERSION (0, 4, 0)   /* 0.4.0 */
00029 
00030 #define SEQ_FLAG_MPEG2 1
00031 #define SEQ_FLAG_CONSTRAINED_PARAMETERS 2
00032 #define SEQ_FLAG_PROGRESSIVE_SEQUENCE 4
00033 #define SEQ_FLAG_LOW_DELAY 8
00034 #define SEQ_FLAG_COLOUR_DESCRIPTION 16
00035 
00036 #define SEQ_MASK_VIDEO_FORMAT 0xe0
00037 #define SEQ_VIDEO_FORMAT_COMPONENT 0
00038 #define SEQ_VIDEO_FORMAT_PAL 0x20
00039 #define SEQ_VIDEO_FORMAT_NTSC 0x40
00040 #define SEQ_VIDEO_FORMAT_SECAM 0x60
00041 #define SEQ_VIDEO_FORMAT_MAC 0x80
00042 #define SEQ_VIDEO_FORMAT_UNSPECIFIED 0xa0
00043 
00044 typedef struct mpeg2_sequence_s
00045 {
00046     unsigned int width, height;
00047     unsigned int chroma_width, chroma_height;
00048     unsigned int byte_rate;
00049     unsigned int vbv_buffer_size;
00050     uint32_t flags;
00051 
00052     unsigned int picture_width, picture_height;
00053     unsigned int display_width, display_height;
00054     unsigned int pixel_width, pixel_height;
00055     unsigned int frame_period;
00056 
00057     uint8_t profile_level_id;
00058     uint8_t colour_primaries;
00059     uint8_t transfer_characteristics;
00060     uint8_t matrix_coefficients;
00061     int aspect_ratio_information;
00062 } mpeg2_sequence_t;
00063 
00064 #define GOP_FLAG_DROP_FRAME 1
00065 #define GOP_FLAG_BROKEN_LINK 2
00066 #define GOP_FLAG_CLOSED_GOP 4
00067 
00068 typedef struct mpeg2_gop_s
00069 {
00070     uint8_t hours;
00071     uint8_t minutes;
00072     uint8_t seconds;
00073     uint8_t pictures;
00074     uint32_t flags;
00075 } mpeg2_gop_t;
00076 
00077 #define PIC_MASK_CODING_TYPE 7
00078 #define PIC_FLAG_CODING_TYPE_I 1
00079 #define PIC_FLAG_CODING_TYPE_P 2
00080 #define PIC_FLAG_CODING_TYPE_B 3
00081 #define PIC_FLAG_CODING_TYPE_D 4
00082 
00083 #define PIC_FLAG_TOP_FIELD_FIRST 8
00084 #define PIC_FLAG_PROGRESSIVE_FRAME 16
00085 #define PIC_FLAG_COMPOSITE_DISPLAY 32
00086 #define PIC_FLAG_SKIP 64
00087 #define PIC_FLAG_TAGS 128
00088 #define PIC_MASK_COMPOSITE_DISPLAY 0xfffff000
00089 
00090 typedef struct mpeg2_picture_s
00091 {
00092     unsigned int temporal_reference;
00093     unsigned int nb_fields;
00094     uint32_t tag, tag2;
00095     uint32_t flags;
00096     struct {
00097         int x, y;
00098     } display_offset[3];
00099 } mpeg2_picture_t;
00100 
00101 typedef struct mpeg2_fbuf_s
00102 {
00103     uint8_t * buf[3];
00104     void * id;
00105 } mpeg2_fbuf_t;
00106 
00107 typedef struct mpeg2_info_s
00108 {
00109     const mpeg2_sequence_t * sequence;
00110     const mpeg2_gop_t * gop;
00111     const mpeg2_picture_t * current_picture;
00112     const mpeg2_picture_t * current_picture_2nd;
00113     const mpeg2_fbuf_t * current_fbuf;
00114     const mpeg2_picture_t * display_picture;
00115     const mpeg2_picture_t * display_picture_2nd;
00116     const mpeg2_fbuf_t * display_fbuf;
00117     const mpeg2_fbuf_t * discard_fbuf;
00118     const uint8_t * user_data;
00119     unsigned int user_data_len;
00120 } mpeg2_info_t;
00121 
00122 typedef struct mpeg2dec_s mpeg2dec_t;
00123 typedef struct mpeg2_decoder_s mpeg2_decoder_t;
00124 
00125 typedef enum
00126 {
00127     STATE_BUFFER = 0,
00128     STATE_SEQUENCE = 1,
00129     STATE_SEQUENCE_REPEATED = 2,
00130     STATE_GOP = 3,
00131     STATE_PICTURE = 4,
00132     STATE_SLICE_1ST = 5,
00133     STATE_PICTURE_2ND = 6,
00134     STATE_SLICE = 7,
00135     STATE_END = 8,
00136     STATE_INVALID = 9,
00137     STATE_INVALID_END = 10
00138 } mpeg2_state_t;
00139 
00140 typedef struct mpeg2_convert_init_s
00141 {
00142     unsigned int id_size;
00143     unsigned int buf_size[3];
00144     void (* start) (void * id, const mpeg2_fbuf_t * fbuf,
00145                     const mpeg2_picture_t * picture, const mpeg2_gop_t * gop);
00146     void (* copy) (void * id, uint8_t * const * src, unsigned int v_offset);
00147 } mpeg2_convert_init_t;
00148 
00149 typedef enum
00150 {
00151     MPEG2_CONVERT_SET = 0,
00152     MPEG2_CONVERT_STRIDE = 1,
00153     MPEG2_CONVERT_START = 2
00154 } mpeg2_convert_stage_t;
00155 
00156 typedef int mpeg2_convert_t (int stage, void * id,
00157                  const mpeg2_sequence_t * sequence, int stride,
00158                  uint32_t accel, void * arg,
00159                  mpeg2_convert_init_t * result);
00160 int mpeg2_convert (mpeg2dec_t * mpeg2dec, mpeg2_convert_t convert, void * arg);
00161 int mpeg2_stride (mpeg2dec_t * mpeg2dec, int stride);
00162 void mpeg2_set_buf (mpeg2dec_t * mpeg2dec, uint8_t * buf[3], void * id);
00163 void mpeg2_custom_fbuf (mpeg2dec_t * mpeg2dec, int custom_fbuf);
00164 
00165 #define MPEG2_ACCEL_X86_MMX 1
00166 #define MPEG2_ACCEL_X86_3DNOW 2
00167 #define MPEG2_ACCEL_X86_MMXEXT 4
00168 #define MPEG2_ACCEL_PPC_ALTIVEC 1
00169 #define MPEG2_ACCEL_ALPHA 1
00170 #define MPEG2_ACCEL_ALPHA_MVI 2
00171 #define MPEG2_ACCEL_SPARC_VIS 1
00172 #define MPEG2_ACCEL_SPARC_VIS2 2
00173 #define MPEG2_ACCEL_DETECT 0x80000000
00174 
00175 uint32_t mpeg2_accel (uint32_t accel);
00176 mpeg2dec_t * mpeg2_init (void);
00177 const mpeg2_info_t * mpeg2_info (mpeg2dec_t * mpeg2dec);
00178 void mpeg2_close (mpeg2dec_t * mpeg2dec);
00179 
00180 void mpeg2_buffer (mpeg2dec_t * mpeg2dec, uint8_t * start, uint8_t * end);
00181 int mpeg2_getpos (mpeg2dec_t * mpeg2dec);
00182 mpeg2_state_t mpeg2_parse (mpeg2dec_t * mpeg2dec);
00183 
00184 void mpeg2_reset (mpeg2dec_t * mpeg2dec, int full_reset);
00185 void mpeg2_skip (mpeg2dec_t * mpeg2dec, int skip);
00186 void mpeg2_slice_region (mpeg2dec_t * mpeg2dec, int start, int end);
00187 
00188 void mpeg2_tag_picture (mpeg2dec_t * mpeg2dec, uint32_t tag, uint32_t tag2);
00189 
00190 void mpeg2_init_fbuf (mpeg2_decoder_t * decoder, uint8_t * current_fbuf[3],
00191               uint8_t * forward_fbuf[3], uint8_t * backward_fbuf[3]);
00192 
00193 typedef enum
00194 {
00195     MPEG2_ALLOC_MPEG2DEC = 0,
00196     MPEG2_ALLOC_CHUNK = 1,
00197     MPEG2_ALLOC_YUV = 2,
00198     MPEG2_ALLOC_CONVERT_ID = 3,
00199     MPEG2_ALLOC_CONVERTED = 4
00200 } mpeg2_alloc_t;
00201 
00202 void * mpeg2_malloc (unsigned size, mpeg2_alloc_t reason);
00203 void mpeg2_free (void * buf);
00204 void mpeg2_malloc_hooks (void * malloc (unsigned, mpeg2_alloc_t),
00205              int free (void *));
00206 
00207 #endif /* MPEG2_H */

Generated on Wed Aug 13 08:02:37 2008 for VLC by  doxygen 1.5.1