~ubuntu-dev/mplayer/ubuntu-feisty

« back to all changes in this revision

Viewing changes to libmpdemux/demux_avs.h

  • Committer: Reinhard Tartler
  • Date: 2006-07-08 08:45:33 UTC
  • Revision ID: siretart@tauware.de-20060708084533-dbc155bde7122e78
imported mplayer_0.99+1.0pre7try2+cvs20060117

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
/*
 
2
 * Demuxer for avisynth
 
3
 * Copyright (c) 2005 Gianluigi Tiesi <sherpya@netfarm.it>
 
4
 *
 
5
 * Avisynth C Interface Version 0.20
 
6
 * Copyright 2003 Kevin Atkinson
 
7
 *
 
8
 * This program is free software; you can redistribute it and/or
 
9
 * modify it under the terms of the GNU Library General Public
 
10
 * License as published by the Free Software Foundation; either
 
11
 * version 2 of the License, or (at your option) any later version.
 
12
 *
 
13
 * This library is distributed in the hope that it will be useful,
 
14
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 
15
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
 
16
 * Library General Public License for more details.
 
17
 *
 
18
 * You should have received a copy of the GNU Library General Public
 
19
 * License along with this library; if not, write to the
 
20
 * Free Software Foundation, Inc., 59 Temple Place - Suite 330,
 
21
 * Boston, MA 02111-1307, USA.
 
22
 */
 
23
 
 
24
enum { AVISYNTH_INTERFACE_VERSION = 2 };
 
25
 
 
26
enum
 
27
{
 
28
  AVS_SAMPLE_INT8  = 1<<0,
 
29
  AVS_SAMPLE_INT16 = 1<<1, 
 
30
  AVS_SAMPLE_INT24 = 1<<2,
 
31
  AVS_SAMPLE_INT32 = 1<<3,
 
32
  AVS_SAMPLE_FLOAT = 1<<4
 
33
};
 
34
 
 
35
enum
 
36
{
 
37
  AVS_PLANAR_Y=1<<0,
 
38
  AVS_PLANAR_U=1<<1,
 
39
  AVS_PLANAR_V=1<<2,
 
40
  AVS_PLANAR_ALIGNED=1<<3,
 
41
  AVS_PLANAR_Y_ALIGNED=AVS_PLANAR_Y|AVS_PLANAR_ALIGNED,
 
42
  AVS_PLANAR_U_ALIGNED=AVS_PLANAR_U|AVS_PLANAR_ALIGNED,
 
43
  AVS_PLANAR_V_ALIGNED=AVS_PLANAR_V|AVS_PLANAR_ALIGNED
 
44
};
 
45
 
 
46
// Colorspace properties.
 
47
enum
 
48
{
 
49
  AVS_CS_BGR = 1<<28,  
 
50
  AVS_CS_YUV = 1<<29,
 
51
  AVS_CS_INTERLEAVED = 1<<30,
 
52
  AVS_CS_PLANAR = 1<<31
 
53
};
 
54
 
 
55
// Specific colorformats
 
56
enum
 
57
{
 
58
  AVS_CS_UNKNOWN = 0,
 
59
  AVS_CS_BGR24 = 1<<0 | AVS_CS_BGR | AVS_CS_INTERLEAVED,
 
60
  AVS_CS_BGR32 = 1<<1 | AVS_CS_BGR | AVS_CS_INTERLEAVED,
 
61
  AVS_CS_YUY2 = 1<<2 | AVS_CS_YUV | AVS_CS_INTERLEAVED,
 
62
  AVS_CS_YV12 = 1<<3 | AVS_CS_YUV | AVS_CS_PLANAR,  // y-v-u, planar
 
63
  AVS_CS_I420 = 1<<4 | AVS_CS_YUV | AVS_CS_PLANAR,  // y-u-v, planar
 
64
  AVS_CS_IYUV = 1<<4 | AVS_CS_YUV | AVS_CS_PLANAR  // same as above
 
65
};
 
66
 
 
67
typedef struct AVS_Clip AVS_Clip;
 
68
typedef struct AVS_ScriptEnvironment AVS_ScriptEnvironment;
 
69
 
 
70
typedef struct AVS_Value AVS_Value;
 
71
struct AVS_Value {
 
72
  short type;  // 'a'rray, 'c'lip, 'b'ool, 'i'nt, 'f'loat, 's'tring, 'v'oid, or 'l'ong
 
73
               // for some function e'rror
 
74
  short array_size;
 
75
  union {
 
76
    void * clip; // do not use directly, use avs_take_clip
 
77
    char boolean;
 
78
    int integer;
 
79
    float floating_pt;
 
80
    const char * string;
 
81
    const AVS_Value * array;
 
82
  } d;
 
83
};
 
84
 
 
85
// AVS_VideoInfo is layed out identicly to VideoInfo
 
86
typedef struct AVS_VideoInfo {
 
87
  int width, height;    // width=0 means no video
 
88
  unsigned fps_numerator, fps_denominator;
 
89
  int num_frames;
 
90
 
 
91
  int pixel_type;
 
92
  
 
93
  int audio_samples_per_second;   // 0 means no audio
 
94
  int sample_type;
 
95
  uint64_t num_audio_samples;
 
96
  int nchannels;
 
97
 
 
98
  // Imagetype properties
 
99
 
 
100
  int image_type;
 
101
} AVS_VideoInfo;
 
102
 
 
103
typedef struct AVS_VideoFrameBuffer {
 
104
  BYTE * data;
 
105
  int data_size;
 
106
  // sequence_number is incremented every time the buffer is changed, so
 
107
  // that stale views can tell they're no longer valid.
 
108
  long sequence_number;
 
109
 
 
110
  long refcount;
 
111
} AVS_VideoFrameBuffer;
 
112
 
 
113
typedef struct AVS_VideoFrame {
 
114
  int refcount;
 
115
  AVS_VideoFrameBuffer * vfb;
 
116
  int offset, pitch, row_size, height, offsetU, offsetV, pitchUV;  // U&V offsets are from top of picture.
 
117
} AVS_VideoFrame;
 
118
 
 
119
static __inline AVS_Value avs_new_value_string(const char * v0)
 
120
{ AVS_Value v; v.type = 's'; v.d.string = v0; return v; }
 
121
 
 
122
static __inline AVS_Value avs_new_value_array(AVS_Value * v0, int size)
 
123
{ AVS_Value v; v.type = 'a'; v.d.array = v0; v.array_size = size; return v; }
 
124
 
 
125
 
 
126
static __inline int avs_is_error(AVS_Value v) { return v.type == 'e'; }
 
127
static __inline int avs_is_clip(AVS_Value v) { return v.type == 'c'; }
 
128
static __inline int avs_is_string(AVS_Value v) { return v.type == 's'; }
 
129
static __inline int avs_has_video(const AVS_VideoInfo * p) { return (p->width!=0); }
 
130
static __inline int avs_has_audio(const AVS_VideoInfo * p) { return (p->audio_samples_per_second!=0); }
 
131
 
 
132
static __inline const char * avs_as_string(AVS_Value v)
 
133
{ return avs_is_error(v) || avs_is_string(v) ? v.d.string : 0; }
 
134
 
 
135
/* Color spaces */
 
136
static __inline int avs_is_rgb(const AVS_VideoInfo * p)
 
137
{ return (p->pixel_type&AVS_CS_BGR); }
 
138
 
 
139
static __inline int avs_is_rgb24(const AVS_VideoInfo * p)
 
140
{ return (p->pixel_type&AVS_CS_BGR24)==AVS_CS_BGR24; } // Clear out additional properties
 
141
 
 
142
static __inline int avs_is_rgb32(const AVS_VideoInfo * p)
 
143
{ return (p->pixel_type & AVS_CS_BGR32) == AVS_CS_BGR32 ; }
 
144
 
 
145
static __inline int avs_is_yuy(const AVS_VideoInfo * p)
 
146
{ return (p->pixel_type&AVS_CS_YUV ); }
 
147
 
 
148
static __inline int avs_is_yuy2(const AVS_VideoInfo * p)
 
149
{ return (p->pixel_type & AVS_CS_YUY2) == AVS_CS_YUY2; }  
 
150
 
 
151
static __inline int avs_is_yv12(const AVS_VideoInfo * p)
 
152
{ return ((p->pixel_type & AVS_CS_YV12) == AVS_CS_YV12)||((p->pixel_type & AVS_CS_I420) == AVS_CS_I420); }       
 
153
 
 
154
static __inline int avs_bits_per_pixel(const AVS_VideoInfo * p) 
 
155
 
156
  switch (p->pixel_type) {
 
157
      case AVS_CS_BGR24: return 24;
 
158
      case AVS_CS_BGR32: return 32;
 
159
      case AVS_CS_YUY2:  return 16;
 
160
      case AVS_CS_YV12:
 
161
      case AVS_CS_I420:  return 12;
 
162
      default:           return 0;
 
163
    }
 
164
}