1 /*
2  * replex.h
3  *
4  *
5  * Copyright (C) 2003 - 2006
6  *                    Marcus Metzler <mocm@metzlerbros.de>
7  *                    Metzler Brothers Systementwicklung GbR
8  *           (C) 2006 Reel Multimedia
9  *
10  * This program is free software; you can redistribute it and/or
11  * modify it under the terms of the GNU General Public License
12  * as published by the Free Software Foundation; either version 2
13  * of the License, or (at your option) any later version.
14  *
15  *
16  * This program is distributed in the hope that it will be useful,
17  * but WITHOUT ANY WARRANTY; without even the implied warranty of
18  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
19  * General Public License for more details.
20  *
21  *
22  * You should have received a copy of the GNU General Public License
23  * along with this program; if not, write to the Free Software
24  * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
25  * Or, point your browser to http://www.gnu.org/copyleft/gpl.html
26  *
27  */
28 
29 #ifndef _REPLEX_H_
30 #define _REPLEX_H_
31 
32 #include <inttypes.h>
33 #include "mpg_common.h"
34 #include "ts.h"
35 #include "element.h"
36 #include "ringbuffer.h"
37 #include "avi.h"
38 #include "multiplex.h"
39 
40 enum { S_SEARCH, S_FOUND, S_ERROR };
41 #define MIN_JUMP 100*CLOCK_MS;
42 #define MAXFRAME 2000
43 
44 struct replex {
45 #define REPLEX_TS  0
46 #define REPLEX_PS  1
47 #define REPLEX_AVI 2
48 	int itype;
49 	int otype;
50 	int ignore_pts;
51 	int keep_pts;
52 	uint64_t allow_jump;
53 	uint64_t inflength;
54 	uint64_t finread;
55 	int lastper;
56 	int avi_rest;
57 	int avi_vcount;
58 	int fd_in;
59 	int fd_out;
60 	int finish;
61 	int demux;
62 	int dmx_out[N_AC3+N_AUDIO+1];
63 	int analyze;
64 	avi_context ac;
65 	int vdr;
66 	int fillzero;
67 	int overflows;
68 	int max_overflows;
69 
70 	uint64_t video_delay;
71 	uint64_t audio_delay;
72 
73 #define INDEX_BUF (32000*32)
74 
75 	int audiobuf;
76 	int ac3buf;
77 	int videobuf;
78 
79   //ac3
80 	int ac3n;
81 	uint16_t ac3_id[N_AC3];
82 	pes_in_t pac3[N_AC3];
83 	index_unit current_ac3index[N_AC3];
84 	int ac3pes_abort[N_AC3];
85 	ringbuffer ac3rbuffer[N_AC3];
86 	ringbuffer index_ac3rbuffer[N_AC3];
87 	uint64_t ac3frame_count[N_AC3];
88 	audio_frame_t ac3frame[N_AC3];
89 	uint64_t first_ac3pts[N_AC3];
90 	int ac3_state[N_AUDIO];
91 	uint64_t last_ac3pts[N_AC3];
92 	uint64_t ac3_jump[N_AUDIO];
93 	uint64_t ac3pts_off[N_AC3];
94 	uint8_t  ac3fillframe[N_AC3][MAXFRAME];
95 	int  ac3filled[N_AC3];
96 
97 
98 // mpeg audio
99 	int apidn;
100 	uint16_t apid[N_AUDIO];
101 	pes_in_t paudio[N_AUDIO];
102 	index_unit current_aindex[N_AUDIO];
103 	int apes_abort[N_AUDIO];
104 	ringbuffer arbuffer[N_AUDIO];
105 	ringbuffer index_arbuffer[N_AUDIO];
106 	uint64_t aframe_count[N_AUDIO];
107 	audio_frame_t aframe[N_AUDIO];
108 	uint64_t first_apts[N_AUDIO];
109 	int audio_state[N_AUDIO];
110 	uint64_t last_apts[N_AUDIO];
111 	uint64_t audio_jump[N_AUDIO];
112 	uint64_t apts_off[N_AUDIO];
113 	uint8_t  afillframe[N_AC3][MAXFRAME];
114 	int  afilled[N_AC3];
115 
116 //mpeg video
117         uint16_t vpid;
118 	int first_iframe;
119 	pes_in_t pvideo;
120 	index_unit current_vindex;
121 	int vpes_abort;
122 	ringbuffer vrbuffer;
123 	ringbuffer index_vrbuffer;
124 	uint64_t vframe_count;
125 	uint64_t vgroup_count;
126 	sequence_t seq_head;
127 	uint64_t first_vpts;
128 	int video_state;
129 	uint64_t last_vpts;
130 	uint64_t video_jump;
131 	uint64_t vjump_pts;
132 
133 	void *priv;
134 	int scan_found;
135         char **inputFiles;
136         int inputIdx;
137 };
138 
139 void init_index(index_unit *iu);
140 #endif
141