1 /***************************************************************************
2                           \fn ADM_coreVideoFilter.h
3                           \brief Base class for Video Filters
4                            (c) Mean 2009
5  ***************************************************************************/
6 
7 /***************************************************************************
8  *                                                                         *
9  *   This program is free software; you can redistribute it and/or modify  *
10  *   it under the terms of the GNU General Public License as published by  *
11  *   the Free Software Foundation; either version 2 of the License, or     *
12  *   (at your option) any later version.                                   *
13  *                                                                         *
14  ***************************************************************************/
15 
16 #ifndef ADM_CORE_VIDEO_FILTER
17 #define  ADM_CORE_VIDEO_FILTER
18 
19 #include "ADM_coreVideoFilter6_export.h"
20 #include "BVector.h"
21 #include "ADM_confCouple.h"
22 #include "ADM_image.h"
23 #include "ADM_videoFilterCache.h"
24 #include "ADM_filterCategory.h"
25 #include "ADM_coreVideoFilterInternal.h"
26 
27 /**
28     \struct ADM_VideoFilterElement
29 */
30 typedef struct
31 {
32     uint32_t            tag; // Temporary filter tag
33     ADM_coreVideoFilter *instance;
34     int objectId;
35 }ADM_VideoFilterElement;
36 
37 /**
38     \struct FilterInfo
39     \brief Describes the video stream at this point in the filter chain
40 */
41 typedef struct
42 {
43     uint32_t width;
44     uint32_t height;
45     uint32_t frameIncrement; /// Average delta time between 2 frames in useconds ~ 1/fps
46     uint32_t timeBaseDen; // timebase denominator
47     uint32_t timeBaseNum; // timebase numerator
48     uint64_t totalDuration;     /// Duration of the whole stream in us
49 }FilterInfo;
50 
51 /**
52  *  \class ADM_coreVideoFilter
53  *  \brief base class for all video filters
54  */
55 class ADM_COREVIDEOFILTER6_EXPORT ADM_coreVideoFilter
56 {
57 protected:
58             FilterInfo            info;
59             uint32_t             nextFrame; // next frame to fetch, it is reset to 0 after a seek!
60             const char           *myName;
61 
62 public:
63                             ADM_coreVideoFilter(ADM_coreVideoFilter *previous,CONFcouple *conf=NULL);
64        virtual             ~ADM_coreVideoFilter();
65 
66        virtual const char   *getConfiguration(void);                   /// Return  current configuration as a human readable string
67        virtual bool         goToTime(uint64_t usSeek);                 /// Overide this if you have cleanup to do after a jump
68        virtual bool         getNextFrame(uint32_t *frameNumber,ADMImage *image)=0;              /// Dont mix getFrame & getNextFrame !
69        virtual bool         getNextFrameAs(ADM_HW_IMAGE type,uint32_t *frameNumber,ADMImage *image);              /// Request frame as type (hw accel)
70        virtual FilterInfo  *getInfo(void);                             /// Return picture parameters after this filter
71        virtual bool         getCoupledConf(CONFcouple **couples)=0 ;   /// Return the current filter configuration
72        virtual void         setCoupledConf(CONFcouple *couples)=0;
configure(void)73        virtual bool         configure(void) {return true;}             /// Start graphical user interface
getAbsoluteStartTime(void)74        virtual uint64_t     getAbsoluteStartTime(void)                 /// Return the absolute offset of the current frame. Used to display time of for filter
75                 {return previousFilter->getAbsoluteStartTime();}       /// Like subtitlers who need that
getTimeRange(uint64_t * start,uint64_t * end)76        virtual bool         getTimeRange(uint64_t *start, uint64_t *end) /// For partialized filters, the time they are active
77                 { *start=0; *end=previousFilter->getInfo()->totalDuration; return true; }
getSource()78                ADM_coreVideoFilter *getSource() {return previousFilter;} /// FOR INTERNAL USE ONLY
79 protected:
80             ADM_coreVideoFilter *previousFilter;
81 };
82 /**
83  *  \class ADM_coreVideoFilterCached
84  *  \brief Same as above but we use a cache. Beware of flushing the cash upon seeking!
85  */
86 class ADM_COREVIDEOFILTER6_EXPORT ADM_coreVideoFilterCached : public ADM_coreVideoFilter
87 {
88 protected:
89             VideoCache           *vidCache;
90 public:
91                             ADM_coreVideoFilterCached(int cacheSize,ADM_coreVideoFilter *previous,CONFcouple *conf=NULL);
92        virtual             ~ADM_coreVideoFilterCached();
93 
94        virtual bool         goToTime(uint64_t usSeek);                 /// Overide this if you have cleanup to do after a jump
95 };
96 
97 // Avisynth compatibility functions
98 ADM_COREVIDEOFILTER6_EXPORT int PutHintingData(uint8_t *video, unsigned int hint);
99 ADM_COREVIDEOFILTER6_EXPORT int GetHintingData(uint8_t *video, unsigned int *hint);
100 
101 extern ADM_COREVIDEOFILTER6_EXPORT BVector <ADM_VideoFilterElement> ADM_VideoFilters;
102 extern ADM_COREVIDEOFILTER6_EXPORT BVector <ADM_vf_plugin *> ADM_videoFilterPluginsList[VF_MAX];
103 
104 
105 #endif
106 // EOF
107