source: titan/libdreamdvd/main.h @ 42984

Last change on this file since 42984 was 14963, checked in by nit, 8 years ago

[titan] change to unix format

File size: 8.5 KB
Line 
1/*
2 * DreamDVD V0.9 - DVD-Player for Dreambox
3 * Copyright (C) 2007 by Seddi
4 *
5 * This DVD Player is based upon the great work from the libdvdnav project,
6 * a52dec library, ffmpeg and the knowledge from all the people who made
7 * watching DVD within linux possible.
8 *
9 * DreamDVD 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 * DreamDVD is distributed in the hope that it will be useful,
15 * but WITHOUT ANY WARRANTY; without even the implied warranty of
16 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
17 * GNU General Public License for more details.
18 *
19 * You should have received a copy of the GNU General Public License
20 * along with this program; if not, write to the Free Software
21 * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA  02111-1307, USA
22 *
23 * part of libdreamdvd
24 */
25
26#ifndef __MAIN_H__
27#define __MAIN_H__
28
29#include "libdreamdvd_config.h"
30
31#if defined(__sh__)
32#define CONVERT_TO_DVB_COMPLIANT_AC3
33#else
34// set to 1 if a start screen should be displayed
35#define SHOW_START_SCREEN 1
36
37#define CONVERT_TO_DVB_COMPLIANT_AC3
38#define CONVERT_TO_DVB_COMPLIANT_DTS
39#endif
40#define NUM_SPU_BACKBUFFER 8
41
42#include <fcntl.h>
43#include <stdio.h>
44#include <stdlib.h>
45#include <string.h>
46#include <unistd.h>
47#include <signal.h>
48#include <inttypes.h>
49#include <sys/types.h>
50#include <sys/stat.h>
51#include <sys/ioctl.h>
52#include <sys/mman.h>
53#include <sys/time.h>
54#include <netinet/in.h>
55#include <byteswap.h>
56#include <errno.h>
57#include <poll.h>
58
59#include <dvdnav/dvdnav.h>
60#include "ddvdlib.h"
61
62#if SHOW_START_SCREEN == 1
63#include "logo.h" // startup screen
64#endif
65
66#ifndef BYTE_ORDER
67#error "no BYTE_ORDER defined!!!!"
68#endif
69
70#if defined(HAVE_LINUX_DVB_VERSION_H)
71#include <linux/dvb/video.h>
72#include <linux/dvb/audio.h>
73#define CONFIG_API_VERSION 3
74#elif defined(HAVE_OST_DMX_H)
75#include <ost/video.h>
76#include <ost/audio.h>
77#define CONFIG_API_VERSION 1
78#include <ost/video.h>
79#include <ost/audio.h>
80#endif
81
82#define BUFFER_SIZE 4096
83#define AC3_BUFFER_SIZE (6*1024*16)
84
85#if CONFIG_API_VERSION == 1
86#define VIDEO_GET_PTS           _IOR('o', 1, unsigned int*)
87#endif
88#if CONFIG_API_VERSION == 3
89#ifndef VIDEO_GET_PTS
90#define VIDEO_GET_PTS              _IOR('o', 57, unsigned long long)
91#endif
92#endif
93
94#define CLAMP(x)     ((x < 0) ? 0 : ((x > 255) ? 255 : x))
95#define CELL_STILL       0x02
96#define NAV_STILL        0x04
97#define TRUE 1
98#define FALSE 0
99#define SAAIOSWSS      10 /* set wide screen signaling data */
100#define SAAIOSENC       4 /* set encoder (pal/ntsc) */
101#define SAA_WSS_43F     0
102#define SAA_WSS_169F    7
103#define SAA_WSS_OFF     8
104#define SAA_NTSC        0
105#define SAA_PAL         1
106
107#define MAX_AUDIO       8
108#define MAX_SPU         32
109
110typedef struct ddvd_spudec_clut_struct {
111#if BYTE_ORDER == BIG_ENDIAN
112        uint8_t entry0  : 4;
113        uint8_t entry1  : 4;
114        uint8_t entry2  : 4;
115        uint8_t entry3  : 4;
116#else
117        uint8_t entry1  : 4;
118        uint8_t entry0  : 4;
119        uint8_t entry3  : 4;
120        uint8_t entry2  : 4;
121#endif
122} ddvd_spudec_clut_t;
123
124enum {SPU_NOP, SPU_SHOW, SPU_HIDE, SPU_FORCE};
125struct ddvd_spu_return {
126        int display_time;
127        int x_start;
128        int x_end;
129        int y_start;
130        int y_end;
131        int force_hide;
132};
133
134struct ddvd_resize_return {
135        int x_start;
136        int x_end;
137        int y_start;
138        int y_end;     
139       
140        int x_offset, y_offset, width, height;
141};
142
143// some global stuff
144
145dvdnav_t *dvdnav;
146dvdnav_cell_change_event_t ddvd_lastCellEventInfo;
147
148int ddvd_wait_for_user;
149int ddvd_clear_buttons;
150int ddvd_lpcm_count;
151int ddvd_iframerun;
152int ddvd_still_frame;
153int ddvd_iframesend;
154int ddvd_last_iframe_len;
155int ddvd_spu_ptr,ddvd_display_time;
156int ddvd_spu_backptr,ddvd_spu_backnr;
157int ddvd_lbb_changed;
158
159enum {TOFF, SLOWFW, FASTFW, SLOWBW, FASTBW};
160int ddvd_trickmode,ddvd_trickspeed;
161
162enum {STOP, PLAY, PAUSE};
163int ddvd_playmode;
164
165int ddvd_wait_timer_active;
166uint64_t ddvd_wait_timer_end;
167
168int ddvd_spu_timer_active;
169uint64_t ddvd_spu_timer_end;
170
171int ddvd_trick_timer_active;
172uint64_t ddvd_trick_timer_end;
173
174unsigned char *ddvd_lbb, *ddvd_lbb2;
175int ddvd_output_fd, ddvd_fdvideo, ddvd_fdaudio, ddvd_ac3_fd;
176
177int ddvd_screeninfo_xres, ddvd_screeninfo_yres, ddvd_screeninfo_stride;
178
179unsigned short ddvd_rd[256],ddvd_gn[256],ddvd_bl[256],ddvd_tr[256];
180
181struct ddvd_size_evt {
182        int width;
183        int height;
184        int aspect;
185};
186
187struct ddvd_framerate_evt {
188        int framerate;
189};
190
191struct ddvd_progressive_evt {
192        int progressive;
193};
194
195
196/* struct for ddvd nav handle*/
197struct ddvd {
198        /* config options */
199        char language[2];                               // iso code (de, en, ...)
200        int aspect;                                             // 0-> 4:3 1-> 16:9 2-> 16:10
201        int tv_mode;                                    // 0-> letterbox 1-> pan_scan 2-> justscale
202        int tv_mode2;                                   // 0-> letterbox 1-> pan_scan 2-> justscale
203        int tv_system;                                  // 0-> PAL 1-> NTSC
204        int ac3thru;                                    // 0-> internal soft decoding 1-> ac3 pass thru to optical out
205        unsigned char *lfb;                             // framebuffer to render subtitles and menus
206        int xres;                                               // x resolution of the framebuffer (normally 720, we dont scale inside libdreamdvd)
207        int yres;                                               // y resolution of the framebuffer (normally 576, we dont scale inside libdreamdvd)
208        int stride;                                             // line_length of the framebuffer (normally 720*bypp, but not always like on DM7025)
209        int bypp;                                               // the bytes per pixel only 1 (8bit framebuffer) or 4 (32bit) are supported
210        int canscale;
211        int key_pipe[2];                                // pipe for sending a command/remote control key (sizeof(int)) to the player
212        int message_pipe[2];                    // pipe for getting player status, osd time and text as well as 8bit color tables
213        char *dvd_path;                         // the path of a dvd block device ("/dev/dvd"), an iso-file ("/hdd/dvd.iso")
214                                                                        // or a dvd file structure ("/hdd/dvd/mymovie") to play
215        /* buffer for actual states */
216        char title_string[96];
217        struct ddvd_color last_col[4];  // colortable (8Bit mode), 4 colors
218        struct ddvd_time last_time;             // last playing time for osd
219        int last_trickspeed;                    // last trickspeed for osd
220        char last_string[512];                  // last text message for frontend/osd
221        int last_audio_id;                              // active audio id
222        int last_audio_type;                    // active audio type
223        uint16_t last_audio_lang;               // active audio language
224        int last_spu_id;                                // active subtitle id
225        uint16_t last_spu_lang;                 // active subtitle language
226        struct ddvd_size_evt last_size;
227        struct ddvd_framerate_evt last_framerate;
228        struct ddvd_progressive_evt last_progressive;
229        uint64_t next_time_update;
230       
231        int in_menu;
232        int resume_title;                               // title, chapter, block for resuming dvd or
233        int resume_chapter;                             // getting actual resume position
234        uint32_t resume_block;
235        int resume_audio_id;
236        int resume_audio_lock;
237        int resume_spu_id;
238        int resume_spu_lock;
239        int should_resume;
240        struct ddvd_resize_return blit_area;
241        int angle_current;
242        int angle_num;
243
244        int audio_format[MAX_AUDIO];
245        int spu_map[MAX_SPU];
246       
247// needed for titan
248#if defined(__sh__)
249        int dvd_aspect;
250#endif
251};
252
253/* internal functions */
254static struct           ddvd_time ddvd_get_osd_time(struct ddvd *playerconfig);
255static int              ddvd_readpipe(int pipefd, void *dest, size_t bytes, int blocked_read);
256static int              ddvd_check_aspect(int dvd_aspect, int dvd_scale_perm, int tv_aspect, int tv_mode);
257static uint64_t         ddvd_get_time(void);
258static void             ddvd_play_empty(int device_clear);
259static void             ddvd_device_clear(void);
260static struct           ddvd_spu_return ddvd_spu_decode_data(const uint8_t * buffer, int len);
261static void             ddvd_blit_to_argb(void *_dst, const void *_src, int pix);
262#if CONFIG_API_VERSION == 3
263static void             ddvd_set_pcr_offset(void);
264static void             ddvd_unset_pcr_offset(void);
265#endif
266struct                          ddvd_resize_return ddvd_resize_pixmap_xbpp(unsigned char *pixmap, int xsource, int ysource, int xdest, int ydest, int xoffset, int yoffset, int xstart, int xend, int ystart, int yend, int colors);
267struct                          ddvd_resize_return ddvd_resize_pixmap_xbpp_smooth(unsigned char *pixmap, int xsource, int ysource, int xdest, int ydest, int xoffset, int yoffset, int xstart, int xend, int ystart, int yend, int colors);
268struct                          ddvd_resize_return ddvd_resize_pixmap_1bpp(unsigned char *pixmap, int xsource, int ysource, int xdest, int ydest, int xoffset, int yoffset, int xstart, int xend, int ystart, int yend, int colors);
269struct                          ddvd_resize_return (*ddvd_resize_pixmap)(unsigned char *pixmap, int xsource, int ysource, int xdest, int ydest, int xoffset, int yoffset, int xstart, int xend, int ystart, int yend, int colors);
270struct                          ddvd_resize_return (*ddvd_resize_pixmap_spu)(unsigned char *pixmap, int xsource, int ysource, int xdest, int ydest, int xoffset, int yoffset, int xstart, int xend, int ystart, int yend, int colors);
271
272#endif
Note: See TracBrowser for help on using the repository browser.