1 /***************************************************************************
2 * *
3 * This program is free software; you can redistribute it and/or modify *
4 * it under the terms of the GNU General Public License as published by *
5 * the Free Software Foundation; either version 2 of the License, or *
6 * (at your option) any later version. *
7 * *
8 ***************************************************************************/
9
10 #include "ADM_default.h"
11 #include "ADM_videoFilterDynamic.h"
12
13
14 class AVDM_Reverse : public AVDMGenericVideoStream
15 {
16 VideoCache *vidCache;
17 public:
18
19 AVDM_Reverse(AVDMGenericVideoStream *in,CONFcouple *couples);
20 ~AVDM_Reverse(void);
21 uint8_t getFrameNumberNoAlloc(uint32_t frame, uint32_t *len,
22 ADMImage *data,uint32_t *flags);
23
24 char *printConf( void );
25 uint8_t configure(AVDMGenericVideoStream *in);
26 uint8_t getCoupledConf( CONFcouple **couples);
27 };
28
29 static FILTER_PARAM reverseParam={0,{""}};
30
31 VF_DEFINE_FILTER(AVDM_Reverse,reverseParam,
32 reverse,
33 QT_TR_NOOP("Reverse"),
34 1,
35 VF_TRANSFORM,
36 QT_TR_NOOP("Play video backward."));
37 /*************************************/
38
configure(AVDMGenericVideoStream * in)39 uint8_t AVDM_Reverse::configure(AVDMGenericVideoStream *in)
40 {
41 _in=in;
42 return 1;
43
44 }
45
printConf(void)46 char *AVDM_Reverse::printConf( void )
47 {
48 ADM_FILTER_DECLARE_CONF(" Reverse");
49
50 }
51
52
AVDM_Reverse(AVDMGenericVideoStream * in,CONFcouple * couples)53 AVDM_Reverse::AVDM_Reverse(AVDMGenericVideoStream *in,CONFcouple *couples)
54
55 {
56
57 int count = 0;
58 char buf[80];
59 unsigned int *p;
60
61 _in=in;
62 memcpy(&_info,_in->getInfo(),sizeof(_info));
63 _info.encoding=1;
64 vidCache=new VideoCache(18,in);
65 }
66 //________________________________________________________
getCoupledConf(CONFcouple ** couples)67 uint8_t AVDM_Reverse::getCoupledConf( CONFcouple **couples)
68 {
69 *couples=NULL;
70 return 1;
71 }
72 //________________________________________________________
~AVDM_Reverse(void)73 AVDM_Reverse::~AVDM_Reverse(void)
74 {
75
76 if(vidCache) delete vidCache;
77 vidCache=NULL;
78 }
getFrameNumberNoAlloc(uint32_t frame,uint32_t * len,ADMImage * data,uint32_t * flags)79 uint8_t AVDM_Reverse::getFrameNumberNoAlloc(uint32_t frame, uint32_t *len,
80 ADMImage *data,uint32_t *flags)
81 {
82
83 uint32_t num_frames,tgt;
84 ADMImage *src;
85
86 num_frames=_in->getInfo()->nb_frames; // ??
87 if(frame>=num_frames) return 0;
88
89 tgt=num_frames-frame-1;
90
91 src=vidCache->getImage(tgt);
92 if(!src) return 0;
93 data->duplicate(src);
94
95 vidCache->unlockAll();
96 return 1;
97 }
98 //EOF
99
100
101
102