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