Main Page | Modules | Data Structures | File List | Data Fields | Globals

livido.h

Go to the documentation of this file.
00001 /*
00002     Linux Dynamic Objects header
00003 
00004     This header should be included by filters and by host applications
00005     using them, in order to be able to use and implement video filters.
00006  */
00007 
00121 #ifndef __LIVIDO_H__
00122 #define __LIVIDO_H__
00123 
00127 #include <inttypes.h>
00128 
00130 #include <stdlib.h>
00131 
00135 
00136 /*
00137   Process this file with doxygen to generate html documentation,
00138   or read thru it to explore the LiViDO API.
00139 */
00140 
00141 #define LIVIDO_ID "$Id: livido.h 64 2004-11-14 22:53:21Z jaromil $"
00142 
00143 
00144 
00145 #define LIVIDO_HEADER_VERSION 1
00146 
00147 
00148 struct livido_instance_template;
00149 typedef struct livido_instance_template livido_instance_template_t;
00150 
00151 struct livido_channel_template;
00152 typedef struct livido_channel_template livido_channel_template_t;
00153 
00154 struct livido_channel;
00155 typedef struct livido_channel livido_channel_t;
00156 
00157 struct livido_parameter_template;
00158 typedef struct livido_parameter_template livido_parameter_template_t;
00159 
00160 struct livido_parameter;
00161 typedef struct livido_parameter livido_parameter_t;
00162 
00163 struct livido_frame;
00164 typedef struct livido_frame livido_frame_t;
00165 
00166 struct livido_instance;
00167 typedef struct livido_instance livido_instance_t;
00168 
00169 
00170 
00199 #define LIVIDO_PALETTE_RGB24               1
00200 #define LIVIDO_PALETTE_RGB888              1
00201 #define LIVIDO_PALETTE_RGB32               2
00202 #define LIVIDO_PALETTE_RGBA8888            2
00203 #define LIVIDO_PALETTE_RGB161616           3
00204 #define LIVIDO_PALETTE_RGBA16161616        4
00205 #define LIVIDO_PALETTE_YUV888              5
00206 #define LIVIDO_PALETTE_YUVA8888            6
00207 #define LIVIDO_PALETTE_YUV161616           7
00208 #define LIVIDO_PALETTE_YUVA16161616        8
00209 #define LIVIDO_PALETTE_YUV422P             9
00210 #define LIVIDO_PALETTE_YUV420P             10
00211 #define LIVIDO_PALETTE_YUV444P             11
00212 #define LIVIDO_PALETTE_A8                  12
00213 #define LIVIDO_PALETTE_A16                 13
00214 #define LIVIDO_PALETTE_RGBFLOAT            14
00215 #define LIVIDO_PALETTE_RGBAFLOAT           15
00216 #define LIVIDO_PALETTE_AFLOAT              16
00217 #define LIVIDO_PALETTE_BGR888              17
00218 #define LIVIDO_PALETTE_YUYV8888            18
00219 #define LIVIDO_PALETTE_UYVY8888            19
00220 #define LIVIDO_PALETTE_RGB565              20
00221 #define LIVIDO_PALETTE_RGBX8888            21
00222 #define LIVIDO_PALETTE_A4                  22
00223 #define LIVIDO_PALETTE_A2                  23
00224 #define LIVIDO_PALETTE_A1                  24
00225 
00226 #define  LIVIDO_PALETTE_FIRST_CUSTOM 2048
00227 
00228 
00229 #define LIVIDO_PALETTE_END         (0x0)
00230 
00231 
00232 
00233 
00234 #define LIVIDO_PALETTE_BITS(p) ( \
00235         (p == LIVIDO_PALETTE_RGBAFLOAT)    ?  128 : \
00236         (p == LIVIDO_PALETTE_RGBFLOAT)     ?  96  : \
00237         (p == LIVIDO_PALETTE_RGBA16161616) ||       \
00238         (p == LIVIDO_PALETTE_YUVA16161616) ?  64  : \
00239         (p == LIVIDO_PALETTE_RGB161616)    ||       \
00240         (p == LIVIDO_PALETTE_YUV161616)    ?  48  : \
00241         (p == LIVIDO_PALETTE_RGBA8888)     ||       \
00242         (p == LIVIDO_PALETTE_RGBX8888)     ||       \
00243         (p == LIVIDO_PALETTE_YUVA8888)     ||       \
00244         (p == LIVIDO_PALETTE_AFLOAT)       ||       \
00245         (p == LIVIDO_PALETTE_YUV444P)      ?  32  : \
00246         (p == LIVIDO_PALETTE_RGB888)       ||       \
00247         (p == LIVIDO_PALETTE_BGR888)       ||       \
00248         (p == LIVIDO_PALETTE_YUV888)       ?  24  : \
00249         (p == LIVIDO_PALETTE_YUV422P)      ||       \
00250         (p == LIVIDO_PALETTE_YUYV8888)     ||       \
00251         (p == LIVIDO_PALETTE_UYVY8888)     ||       \
00252         (p == LIVIDO_PALETTE_RGB565)       ||       \
00253         (p == LIVIDO_PALETTE_A16)          ?  16  : \
00254         (p == LIVIDO_PALETTE_YUV420P)      ?  12  : \
00255         (p == LIVIDO_PALETTE_A8)           ?  8   : \
00256         (p == LIVIDO_PALETTE_A4)           ?  4   : \
00257         (p == LIVIDO_PALETTE_A2)           ?  2   : \
00258         (p == LIVIDO_PALETTE_A1)           ?  1   : 0)
00259 
00260 
00261 #define LIVIDO_PALETTE_IS_PLANAR(p) ( \
00262         (p == LIVIDO_PALETTE_YUV444P)      ||       \
00263         (p == LIVIDO_PALETTE_YUV422P)      ||       \
00264         (p == LIVIDO_PALETTE_YUV420P)      ?  1   : 0 )
00265 
00266 
00267 #define LIVIDO_PALETTE_IS_CUSTOM(p) ( \
00268         (p&2048) ? 1 : 0 )
00269 
00270 
00272 
00273 
00275 
00342 struct livido_channel_template {
00343 
00349   char *name; 
00350 
00355   int flags; 
00356 
00364   int *palettes; 
00365 
00380   int same_as; 
00381 
00382 
00390   int width;  
00391   int height; 
00392 
00393   struct livido_channel_template *next;
00395 
00396   char reserved[64]; 
00397 
00398 };
00399 
00403 #define LIVIDO_CHANNEL_OPTIONAL (1<<0)
00404 
00405 
00406 #define LIVIDO_CHANNEL_MASK (1<<1)
00407 
00408 
00409 #define LIVIDO_CHANNEL_SAME_AS_SIZE (1<<2)
00410 
00411 
00412 #define LIVIDO_CHANNEL_SAME_AS_PALETTE (1<<3)
00413 
00414 
00415 #define LIVIDO_CHANNEL_RESIZABLE (1<<4)
00416 
00417 
00418 
00420 
00421 
00422 
00423 
00424 
00425 
00426 
00427 
00428 
00429 
00430 
00431 
00433 
00453 
00454 
00470 typedef int (livido_init_f) (livido_instance_t*);
00471 
00481 typedef int (livido_deinit_f) (livido_instance_t*);
00482 
00493 typedef int (livido_process_f) (livido_instance_t*,
00494                                 livido_frame_t*, livido_frame_t*);
00495 
00496 
00499 #define LIVIDO_NO_ERROR                         0
00500 
00501 
00506 #define LIVIDO_ERROR_TOO_MANY_INSTANCES         1
00507 
00508 
00509 #define LIVIDO_ERROR_MEMORY_ALLOCATION          2
00510 
00511 
00512 #define LIVIDO_ERROR_OOB_PARAMETERS             3
00513 
00514 
00515 #define LIVIDO_ERROR_OOB_CHANNELS               4
00516 
00517 
00521 #define LIVIDO_ERROR_PHERIPHERY                 5
00522 
00523 
00524 #define LIVIDO_ERROR_INTERNAL                   6
00525 
00526 
00527 #define LIVIDO_ERROR_AUXILIARY                  7
00528 
00529 
00530 #define LIVIDO_ERROR_GET_PARAMETER              8
00531 
00532 
00533 #define LIVIDO_ERROR_SET_PARAMETER              9
00534 
00535 
00537 
00538 
00539 
00540 
00541 
00542 
00543 
00544 
00545 
00546 
00547 
00548 
00550 
00568 // parameters data types
00569 #define LIVIDO_PARAM_SWITCH             0x10  
00570 #define LIVIDO_PARAM_NUMBER             0x11  
00571 #define LIVIDO_PARAM_RGBA32             0x13  
00572 #define LIVIDO_PARAM_RGB24              0x14  
00573 #define LIVIDO_PARAM_COORD2D            0x15  
00574 #define LIVIDO_PARAM_STRING             0x16  
00575 #define LIVIDO_PARAM_POINTER            0x17  
00576 #define LIVIDO_PARAM_CUSTOM             0x18  
00577 
00578 
00579 
00580 
00588 #define LIVIDO_PARAMETER_NEEDS_INIT (1<<0) 
00589 
00590 #define LIVIDO_PARAMETER_INTERPOLATED (1<<1) 
00591 
00592 
00598 struct livido_parameter_template {
00601   const char *name; 
00602   
00604   const char *description; 
00605   
00606   const char *format; 
00607 
00608   const int type; 
00609 
00610   const int flags; 
00611 
00612   const int decimals; 
00613 
00614   const char *list_values; 
00615 
00616   const char *def; 
00617   
00618   const double min; 
00619   const double max; 
00620   const double step; 
00621 
00622 
00630   const char *hint;        
00631 
00632   const void *extra; 
00633 
00634   struct livido_parameter_template* next;
00636 
00637   char reserved[64]; 
00638 };
00639 
00640 
00648 struct livido_parameter {
00649 
00650   struct livido_parameter_template *templ;
00652 
00653   char *value; 
00654 
00655   int flags;   
00656 
00657   void *extra; 
00658   
00659   struct livido_parameter *next;
00661 
00662   char reserved[64]; 
00663 };
00664 
00665 
00668 
00669 #include <stdio.h>
00670 #include <stdarg.h>
00671 #include <string.h>
00672 
00691 int livido_set_parameter(livido_parameter_t *parameter, ...) {
00692   char tmp[1024];
00693   int len;
00694   va_list arg;
00695   int res;
00696   
00698   va_start(arg, parameter);
00699   
00701   res = vsnprintf(tmp, 1023, parameter->templ->format, arg);
00702 
00703   if(res<0) res = LIVIDO_ERROR_SET_PARAMETER;
00704   else {
00705     res = LIVIDO_NO_ERROR;
00706     if(parameter->value) free(parameter->value);
00707 
00708     len = strlen(tmp);
00709     parameter->value = calloc( len+1, sizeof(char) );
00710     strncpy(parameter->value, tmp, len);
00711 
00712   }
00713 
00714   va_end(arg);
00715   
00716   return res;
00717 }
00718 
00739 int livido_get_parameter(livido_parameter_t *parameter, ...) {
00740   va_list arg;
00741   const char *fmt;
00742   float *f;
00743   char *s;
00744   va_start(arg, parameter);
00745 
00747   fmt = parameter->templ->format;
00748   while (*fmt)
00749     switch(*fmt++) {
00750     case 's':           /* string */
00751       s = va_arg(arg, char *);
00752       sscanf(parameter->value, parameter->templ->format, s);
00753       //      fprintf(stderr,"get_parameter: string %s\n", s);
00754       break;
00755     case 'f':           /* int */
00756       f = va_arg(arg, float*);
00757       sscanf(parameter->value, parameter->templ->format, f);
00758       //      fprintf(stderr,"get_parameter: int %f\n", *f);
00759       break;
00760     }
00761   
00762 
00763   //  if(res == 0 || res == EOF) res = LIVIDO_ERROR_GET_PARAMETER;
00764   //  else res = LIVIDO_NO_ERROR;
00765 
00766   va_end(arg);
00767 
00768   return 0;
00769 }
00770 
00771 
00772 
00774 
00775 
00776 
00777 
00778 
00780 
00801 struct livido_instance_template {
00802 
00803   char *name; 
00804   char *author; 
00805   char *description; 
00806 
00807   int version; 
00808 
00809   int livido_api_version; 
00810 
00811   int flags;
00813 
00814 
00816 
00817 
00820   struct livido_parameter_template *in_parameter_templates;
00822 
00827   struct livido_parameter_template *out_parameter_templates;
00829 
00831 
00840   struct livido_channel_template *in_channel_templates;
00842 
00843   struct livido_channel_template *out_channel_templates;
00845 
00846 
00847   /* function pointers follow */
00848   livido_init_f                 *init;
00850   livido_deinit_f               *deinit;
00852   livido_process_f              *process;
00854 
00855   char *hints; 
00856 
00857   void *extra; 
00858 
00859   struct livido_instance_template *next;
00861 
00862   char reserved[64]; 
00863 };
00864 
00865 
00884 typedef struct livido_instance_template *(livido_setup_f) (void);
00885 
00886 
00887 /*
00888   The flags that can be set in livido_instance_template::flags
00889   define aspects of the filter functioning, they are flags set by the
00890   plugin on the filter template, the host should always check them
00891   carefully (i.e: if(property&LIVIDO_PROPERTY_*)
00892 
00893 */
00894 
00906 #define LIVIDO_PROPERTY_REALTIME (1<<0x0)
00907 
00908 
00915 #define LIVIDO_PROPERTY_CAN_DO_INPLACE (1<<0x1)
00916 
00917 
00922 #define LIVIDO_PROPERTY_TRANSITION (1<<0x2)
00923 
00924 
00928 #define LIVIDO_PROPERTY_CAN_DO_SCALED (1<<0x3)
00929 
00930 
00945 #define LIVIDO_PROPERTY_CAN_DO_WINDOWED (1<<0x4)
00946 
00947 
00948 
00949 #define LIVIDO_PROPERTY_SELF_AUTOMATION (1<<0x5)
00950 
00951 
00955 #define LIVIDO_PROPERTY_FPS_NEEDED (1<<0x6)
00956 
00957 
00962 #define LIVIDO_PROPERTY_HOST_CAN_RESIZE (1<<0x7)
00963 
00964 
00969 #define LIVIDO_PROPERTY_HOST_CAN_CHANGE_PALETTE (1<<0x8)
00970 
00971 
00973 
00974 
00975 
00976 
00977 
00978 
00979 
00980 
00981 
00982 
00983 
00984 
00985 
00986 
00987 
00988 
01016 struct livido_channel {
01017 
01018   struct livido_channel_template *templ;
01020 
01021   int flags; 
01022 
01023   int palette;
01025 
01026   int width; 
01027   int height; 
01028 
01029   int shift_h; 
01030   int shift_v; 
01031 
01038   int rowstrides[4]; 
01039 
01040   struct livido_channel *next;
01042 
01043   char reserved[64]; 
01044 };
01045 
01046 
01047 #define LIVIDO_CHANNEL_DISABLED (1<<0)
01048 
01049 
01050 
01052 
01053 
01054 
01055 
01056 
01057 
01059 
01096 typedef double livido_timecode_t;
01097 
01106 struct livido_frame {
01107 
01108   void *pixel_data[4];         
01109   
01110   struct livido_channel *channel;   
01111 
01112   livido_timecode_t timecode;
01114 
01115   void *extra;                 
01116 
01117   char reserved[64]; 
01118 };
01119 
01121 
01122 
01123 
01124 
01125 
01126 
01127 
01128 
01129 
01130 
01132 
01151 typedef void *(livido_malloc_f)(size_t); 
01152 typedef void  (livido_free_f)(void*); 
01153 typedef void *(livido_memcpy_f)(void*, const void*, size_t); 
01154 typedef void *(livido_memset_f)(void*, int, size_t); 
01155 
01160 typedef int (get_keyframe_cb)(void *ctx, livido_instance_t *instance, livido_parameter_t *p,
01161                               livido_timecode_t pos, livido_timecode_t keyframe );
01162 
01163 
01164 
01197 struct livido_instance {
01198   
01199   struct livido_instance_template *templ;
01201 
01202 
01203   struct livido_channel *in_channels; 
01204 
01205   struct livido_channel *out_channels; 
01206 
01207 
01208   struct livido_parameter *in_parameters; 
01209   
01210   struct livido_parameter *out_parameters; 
01211 
01212 
01213   get_keyframe_cb *keyframe_next; 
01214 
01215   get_keyframe_cb *keyframe_prev; 
01216 
01217                                  
01222   float fps; 
01223 
01228   float scale_x; 
01229   float scale_y; 
01230 
01234   float window_x;  
01235   float window_y; 
01236   float window_w; 
01237   float window_h; 
01238 
01243   int threads; 
01244 
01245 
01250   livido_malloc_f *malloc; 
01251   livido_free_f   *free;   
01252   livido_memcpy_f *memcpy; 
01253   livido_memset_f *memset; 
01254 
01255 
01256   void *internal; 
01257 
01258   char *error; 
01259 
01260   char reserved[64]; 
01261 };
01262 
01263 
01264 
01265 
01266 
01268 
01269 
01270 
01271 
01272 
01273 #endif // __LIVIDO_H__

Generated on Wed Apr 6 20:21:07 2005 for LiViDO by doxygen 1.3.4