annotate libvo/vo_dxr3.c @ 3897:3f08e7a185a1

updates
author arpi
date Sun, 30 Dec 2001 15:18:36 +0000
parents f832811cf89a
children 7c07bc1e0a81
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
2645
9d8d69fc517c ao_dxr3 by David Holm <dholm@telia.com>
arpi
parents:
diff changeset
1 /*
9d8d69fc517c ao_dxr3 by David Holm <dholm@telia.com>
arpi
parents:
diff changeset
2 * vo_dxr3.c - DXR3/H+ video out
9d8d69fc517c ao_dxr3 by David Holm <dholm@telia.com>
arpi
parents:
diff changeset
3 *
9d8d69fc517c ao_dxr3 by David Holm <dholm@telia.com>
arpi
parents:
diff changeset
4 * Copyright (C) 2001 David Holm <dholm@iname.com>
9d8d69fc517c ao_dxr3 by David Holm <dholm@telia.com>
arpi
parents:
diff changeset
5 *
9d8d69fc517c ao_dxr3 by David Holm <dholm@telia.com>
arpi
parents:
diff changeset
6 */
9d8d69fc517c ao_dxr3 by David Holm <dholm@telia.com>
arpi
parents:
diff changeset
7
9d8d69fc517c ao_dxr3 by David Holm <dholm@telia.com>
arpi
parents:
diff changeset
8 #include "fastmemcpy.h"
9d8d69fc517c ao_dxr3 by David Holm <dholm@telia.com>
arpi
parents:
diff changeset
9 #include <stdio.h>
9d8d69fc517c ao_dxr3 by David Holm <dholm@telia.com>
arpi
parents:
diff changeset
10 #include <stdlib.h>
9d8d69fc517c ao_dxr3 by David Holm <dholm@telia.com>
arpi
parents:
diff changeset
11 #include <string.h>
2921
ee37c7fc3022 dxr3-patch4 by David Holm
arpi
parents: 2866
diff changeset
12 #include <unistd.h>
ee37c7fc3022 dxr3-patch4 by David Holm
arpi
parents: 2866
diff changeset
13 #include <linux/em8300.h>
ee37c7fc3022 dxr3-patch4 by David Holm
arpi
parents: 2866
diff changeset
14 #include <sys/ioctl.h>
ee37c7fc3022 dxr3-patch4 by David Holm
arpi
parents: 2866
diff changeset
15 #include <sys/stat.h>
ee37c7fc3022 dxr3-patch4 by David Holm
arpi
parents: 2866
diff changeset
16 #include <sys/types.h>
ee37c7fc3022 dxr3-patch4 by David Holm
arpi
parents: 2866
diff changeset
17 #include <fcntl.h>
2645
9d8d69fc517c ao_dxr3 by David Holm <dholm@telia.com>
arpi
parents:
diff changeset
18 #include <stdio.h>
9d8d69fc517c ao_dxr3 by David Holm <dholm@telia.com>
arpi
parents:
diff changeset
19 #include <time.h>
9d8d69fc517c ao_dxr3 by David Holm <dholm@telia.com>
arpi
parents:
diff changeset
20
9d8d69fc517c ao_dxr3 by David Holm <dholm@telia.com>
arpi
parents:
diff changeset
21 #include "config.h"
9d8d69fc517c ao_dxr3 by David Holm <dholm@telia.com>
arpi
parents:
diff changeset
22 #include "video_out.h"
9d8d69fc517c ao_dxr3 by David Holm <dholm@telia.com>
arpi
parents:
diff changeset
23 #include "video_out_internal.h"
3432
5cb7caab5536 MP1E configure patch by D. Holm.
atmos4
parents: 3387
diff changeset
24 #ifdef USE_MP1E
3333
5c6cdf5490f0 Minor typo fix (which I thought I commited yesterday)
mswitch
parents: 3329
diff changeset
25 #include "../libmp1e/libmp1e.h"
3432
5cb7caab5536 MP1E configure patch by D. Holm.
atmos4
parents: 3387
diff changeset
26 #endif
2645
9d8d69fc517c ao_dxr3 by David Holm <dholm@telia.com>
arpi
parents:
diff changeset
27
2866
4f6190ab52e7 Added a temporary fix to the DXR3 win32 codec playback, win32 codecs might prove to play back an unscaled image!
mswitch
parents: 2770
diff changeset
28 #include "../postproc/rgb2rgb.h"
2645
9d8d69fc517c ao_dxr3 by David Holm <dholm@telia.com>
arpi
parents:
diff changeset
29 #ifdef HAVE_MMX
9d8d69fc517c ao_dxr3 by David Holm <dholm@telia.com>
arpi
parents:
diff changeset
30 #include "mmx.h"
9d8d69fc517c ao_dxr3 by David Holm <dholm@telia.com>
arpi
parents:
diff changeset
31 #endif
9d8d69fc517c ao_dxr3 by David Holm <dholm@telia.com>
arpi
parents:
diff changeset
32
3639
64ee21b3bd09 Modified the sync code once again, commented out hardware pts sync (I'll likely burn in hell before understanding how to get this bastard to sync well)
mswitch
parents: 3630
diff changeset
33 #include "aspect.h"
64ee21b3bd09 Modified the sync code once again, commented out hardware pts sync (I'll likely burn in hell before understanding how to get this bastard to sync well)
mswitch
parents: 3630
diff changeset
34
2645
9d8d69fc517c ao_dxr3 by David Holm <dholm@telia.com>
arpi
parents:
diff changeset
35 LIBVO_EXTERN (dxr3)
9d8d69fc517c ao_dxr3 by David Holm <dholm@telia.com>
arpi
parents:
diff changeset
36
3432
5cb7caab5536 MP1E configure patch by D. Holm.
atmos4
parents: 3387
diff changeset
37 #ifdef USE_MP1E
3329
529a001496c2 Switched from rte which caused alot of problems for some users to libmp1e.
mswitch
parents: 3232
diff changeset
38 rte_context *mp1e_context = NULL;
529a001496c2 Switched from rte which caused alot of problems for some users to libmp1e.
mswitch
parents: 3232
diff changeset
39 rte_codec *mp1e_codec = NULL;
3201
039a973b3dda Newest DXR3 patch (improved 1.0rc2) by David Holm.
atmos4
parents: 3186
diff changeset
40 rte_buffer mp1e_buffer;
3432
5cb7caab5536 MP1E configure patch by D. Holm.
atmos4
parents: 3387
diff changeset
41 #endif
2645
9d8d69fc517c ao_dxr3 by David Holm <dholm@telia.com>
arpi
parents:
diff changeset
42
3201
039a973b3dda Newest DXR3 patch (improved 1.0rc2) by David Holm.
atmos4
parents: 3186
diff changeset
43 static unsigned char *picture_data[3];
039a973b3dda Newest DXR3 patch (improved 1.0rc2) by David Holm.
atmos4
parents: 3186
diff changeset
44 static unsigned int picture_linesize[3];
3329
529a001496c2 Switched from rte which caused alot of problems for some users to libmp1e.
mswitch
parents: 3232
diff changeset
45
2770
b9732eaa82d9 DXR3 beta2 patch by David Holm.
atmos4
parents: 2732
diff changeset
46 static int v_width,v_height;
2866
4f6190ab52e7 Added a temporary fix to the DXR3 win32 codec playback, win32 codecs might prove to play back an unscaled image!
mswitch
parents: 2770
diff changeset
47 static int s_width,s_height;
2645
9d8d69fc517c ao_dxr3 by David Holm <dholm@telia.com>
arpi
parents:
diff changeset
48 static int s_pos_x,s_pos_y;
9d8d69fc517c ao_dxr3 by David Holm <dholm@telia.com>
arpi
parents:
diff changeset
49 static int d_pos_x,d_pos_y;
9d8d69fc517c ao_dxr3 by David Holm <dholm@telia.com>
arpi
parents:
diff changeset
50 static int osd_w,osd_h;
3329
529a001496c2 Switched from rte which caused alot of problems for some users to libmp1e.
mswitch
parents: 3232
diff changeset
51
2770
b9732eaa82d9 DXR3 beta2 patch by David Holm.
atmos4
parents: 2732
diff changeset
52 static int img_format = 0;
3329
529a001496c2 Switched from rte which caused alot of problems for some users to libmp1e.
mswitch
parents: 3232
diff changeset
53
2921
ee37c7fc3022 dxr3-patch4 by David Holm
arpi
parents: 2866
diff changeset
54 static int fd_control = -1;
ee37c7fc3022 dxr3-patch4 by David Holm
arpi
parents: 2866
diff changeset
55 static int fd_video = -1;
ee37c7fc3022 dxr3-patch4 by David Holm
arpi
parents: 2866
diff changeset
56 static int fd_spu = -1;
ee37c7fc3022 dxr3-patch4 by David Holm
arpi
parents: 2866
diff changeset
57 static int ioval = 0;
2645
9d8d69fc517c ao_dxr3 by David Holm <dholm@telia.com>
arpi
parents:
diff changeset
58
9d8d69fc517c ao_dxr3 by David Holm <dholm@telia.com>
arpi
parents:
diff changeset
59 static vo_info_t vo_info =
9d8d69fc517c ao_dxr3 by David Holm <dholm@telia.com>
arpi
parents:
diff changeset
60 {
9d8d69fc517c ao_dxr3 by David Holm <dholm@telia.com>
arpi
parents:
diff changeset
61 "DXR3/H+ video out",
9d8d69fc517c ao_dxr3 by David Holm <dholm@telia.com>
arpi
parents:
diff changeset
62 "dxr3",
9d8d69fc517c ao_dxr3 by David Holm <dholm@telia.com>
arpi
parents:
diff changeset
63 "David Holm <dholm@iname.com>",
9d8d69fc517c ao_dxr3 by David Holm <dholm@telia.com>
arpi
parents:
diff changeset
64 ""
9d8d69fc517c ao_dxr3 by David Holm <dholm@telia.com>
arpi
parents:
diff changeset
65 };
9d8d69fc517c ao_dxr3 by David Holm <dholm@telia.com>
arpi
parents:
diff changeset
66
3432
5cb7caab5536 MP1E configure patch by D. Holm.
atmos4
parents: 3387
diff changeset
67 #ifdef USE_MP1E
3201
039a973b3dda Newest DXR3 patch (improved 1.0rc2) by David Holm.
atmos4
parents: 3186
diff changeset
68 void write_dxr3( rte_context* context, void* data, size_t size, void* user_data )
039a973b3dda Newest DXR3 patch (improved 1.0rc2) by David Holm.
atmos4
parents: 3186
diff changeset
69 {
3828
063e5b0065a4 Brand new sync core, uses hw sync for everything.
mswitch
parents: 3759
diff changeset
70 if(ioctl(fd_video,EM8300_IOCTL_VIDEO_SETPTS,&vo_pts) < 0)
063e5b0065a4 Brand new sync core, uses hw sync for everything.
mswitch
parents: 3759
diff changeset
71 printf( "VO: [dxr3] Unable to set pts\n" );
3201
039a973b3dda Newest DXR3 patch (improved 1.0rc2) by David Holm.
atmos4
parents: 3186
diff changeset
72 write( fd_video, data, size );
039a973b3dda Newest DXR3 patch (improved 1.0rc2) by David Holm.
atmos4
parents: 3186
diff changeset
73 }
3432
5cb7caab5536 MP1E configure patch by D. Holm.
atmos4
parents: 3387
diff changeset
74 #endif
3201
039a973b3dda Newest DXR3 patch (improved 1.0rc2) by David Holm.
atmos4
parents: 3186
diff changeset
75
3218
8ba06b63f873 Fix green borders -> black borders, patch from D. Holm, also small fix to dxr3 ao.
atmos4
parents: 3208
diff changeset
76 static uint32_t init(uint32_t scr_width, uint32_t scr_height, uint32_t width, uint32_t height, uint32_t fullscreen, char *title, uint32_t format)
2645
9d8d69fc517c ao_dxr3 by David Holm <dholm@telia.com>
arpi
parents:
diff changeset
77 {
3639
64ee21b3bd09 Modified the sync code once again, commented out hardware pts sync (I'll likely burn in hell before understanding how to get this bastard to sync well)
mswitch
parents: 3630
diff changeset
78 int tmp1,tmp2;
2921
ee37c7fc3022 dxr3-patch4 by David Holm
arpi
parents: 2866
diff changeset
79 fd_control = open( "/dev/em8300", O_WRONLY );
ee37c7fc3022 dxr3-patch4 by David Holm
arpi
parents: 2866
diff changeset
80 if( fd_control < 1 )
2645
9d8d69fc517c ao_dxr3 by David Holm <dholm@telia.com>
arpi
parents:
diff changeset
81 {
2921
ee37c7fc3022 dxr3-patch4 by David Holm
arpi
parents: 2866
diff changeset
82 printf( "VO: [dxr3] Error opening /dev/em8300 for writing!\n" );
ee37c7fc3022 dxr3-patch4 by David Holm
arpi
parents: 2866
diff changeset
83 return -1;
ee37c7fc3022 dxr3-patch4 by David Holm
arpi
parents: 2866
diff changeset
84 }
ee37c7fc3022 dxr3-patch4 by David Holm
arpi
parents: 2866
diff changeset
85 fd_video = open( "/dev/em8300_mv", O_WRONLY );
ee37c7fc3022 dxr3-patch4 by David Holm
arpi
parents: 2866
diff changeset
86 if( fd_video < 0 )
ee37c7fc3022 dxr3-patch4 by David Holm
arpi
parents: 2866
diff changeset
87 {
ee37c7fc3022 dxr3-patch4 by David Holm
arpi
parents: 2866
diff changeset
88 printf( "VO: [dxr3] Error opening /dev/em8300_mv for writing!\n" );
ee37c7fc3022 dxr3-patch4 by David Holm
arpi
parents: 2866
diff changeset
89 return -1;
ee37c7fc3022 dxr3-patch4 by David Holm
arpi
parents: 2866
diff changeset
90 }
ee37c7fc3022 dxr3-patch4 by David Holm
arpi
parents: 2866
diff changeset
91 else printf( "VO: [dxr3] Opened /dev/em8300_mv\n" );
ee37c7fc3022 dxr3-patch4 by David Holm
arpi
parents: 2866
diff changeset
92 fd_spu = open( "/dev/em8300_sp", O_WRONLY );
ee37c7fc3022 dxr3-patch4 by David Holm
arpi
parents: 2866
diff changeset
93 if( fd_spu < 0 )
ee37c7fc3022 dxr3-patch4 by David Holm
arpi
parents: 2866
diff changeset
94 {
ee37c7fc3022 dxr3-patch4 by David Holm
arpi
parents: 2866
diff changeset
95 printf( "VO: [dxr3] Error opening /dev/em8300_sp for writing!\n" );
ee37c7fc3022 dxr3-patch4 by David Holm
arpi
parents: 2866
diff changeset
96 return -1;
2645
9d8d69fc517c ao_dxr3 by David Holm <dholm@telia.com>
arpi
parents:
diff changeset
97 }
9d8d69fc517c ao_dxr3 by David Holm <dholm@telia.com>
arpi
parents:
diff changeset
98
2770
b9732eaa82d9 DXR3 beta2 patch by David Holm.
atmos4
parents: 2732
diff changeset
99 /* Subpic code isn't working yet, don't set to ON
b9732eaa82d9 DXR3 beta2 patch by David Holm.
atmos4
parents: 2732
diff changeset
100 unless you are really sure what you are doing */
2921
ee37c7fc3022 dxr3-patch4 by David Holm
arpi
parents: 2866
diff changeset
101 ioval = EM8300_SPUMODE_OFF;
ee37c7fc3022 dxr3-patch4 by David Holm
arpi
parents: 2866
diff changeset
102 if( ioctl( fd_control, EM8300_IOCTL_SET_SPUMODE, &ioval ) < 0 )
ee37c7fc3022 dxr3-patch4 by David Holm
arpi
parents: 2866
diff changeset
103 {
ee37c7fc3022 dxr3-patch4 by David Holm
arpi
parents: 2866
diff changeset
104 printf( "VO: [dxr3] Unable to set subpicture mode!\n" );
ee37c7fc3022 dxr3-patch4 by David Holm
arpi
parents: 2866
diff changeset
105 return -1;
ee37c7fc3022 dxr3-patch4 by David Holm
arpi
parents: 2866
diff changeset
106 }
ee37c7fc3022 dxr3-patch4 by David Holm
arpi
parents: 2866
diff changeset
107
ee37c7fc3022 dxr3-patch4 by David Holm
arpi
parents: 2866
diff changeset
108 ioval = EM8300_PLAYMODE_PLAY;
2968
9989497ab31e Minor fixes by David.
atmos4
parents: 2921
diff changeset
109 if( ioctl( fd_control, EM8300_IOCTL_SET_PLAYMODE, &ioval ) < 0 )
2921
ee37c7fc3022 dxr3-patch4 by David Holm
arpi
parents: 2866
diff changeset
110 printf( "VO: [dxr3] Unable to set playmode!\n" );
ee37c7fc3022 dxr3-patch4 by David Holm
arpi
parents: 2866
diff changeset
111
2645
9d8d69fc517c ao_dxr3 by David Holm <dholm@telia.com>
arpi
parents:
diff changeset
112 img_format = format;
3861
f832811cf89a Some last minute changes to accomodate for anamorphic 1.85:1 and 2.35:1 movies... Needs more work, but this is good enough for now.
mswitch
parents: 3828
diff changeset
113 v_width = scr_width;
f832811cf89a Some last minute changes to accomodate for anamorphic 1.85:1 and 2.35:1 movies... Needs more work, but this is good enough for now.
mswitch
parents: 3828
diff changeset
114 v_height = scr_height;
2921
ee37c7fc3022 dxr3-patch4 by David Holm
arpi
parents: 2866
diff changeset
115
3639
64ee21b3bd09 Modified the sync code once again, commented out hardware pts sync (I'll likely burn in hell before understanding how to get this bastard to sync well)
mswitch
parents: 3630
diff changeset
116 /* Calculate screen res */
3861
f832811cf89a Some last minute changes to accomodate for anamorphic 1.85:1 and 2.35:1 movies... Needs more work, but this is good enough for now.
mswitch
parents: 3828
diff changeset
117 /*aspect_save_orig(v_width,v_height);
f832811cf89a Some last minute changes to accomodate for anamorphic 1.85:1 and 2.35:1 movies... Needs more work, but this is good enough for now.
mswitch
parents: 3828
diff changeset
118 aspect_save_prescale(width,height);
f832811cf89a Some last minute changes to accomodate for anamorphic 1.85:1 and 2.35:1 movies... Needs more work, but this is good enough for now.
mswitch
parents: 3828
diff changeset
119 aspect_save_screenres(702,575);*/ /* Reference values from DVD spec (711,483) (702,575) */
f832811cf89a Some last minute changes to accomodate for anamorphic 1.85:1 and 2.35:1 movies... Needs more work, but this is good enough for now.
mswitch
parents: 3828
diff changeset
120 /*aspect(&s_width,&s_height,A_ZOOM);*/
f832811cf89a Some last minute changes to accomodate for anamorphic 1.85:1 and 2.35:1 movies... Needs more work, but this is good enough for now.
mswitch
parents: 3828
diff changeset
121 s_width = (v_width+15)/16; s_width*=16;
f832811cf89a Some last minute changes to accomodate for anamorphic 1.85:1 and 2.35:1 movies... Needs more work, but this is good enough for now.
mswitch
parents: 3828
diff changeset
122 s_height = (v_height+15)/16; s_height*=16;
3639
64ee21b3bd09 Modified the sync code once again, commented out hardware pts sync (I'll likely burn in hell before understanding how to get this bastard to sync well)
mswitch
parents: 3630
diff changeset
123
64ee21b3bd09 Modified the sync code once again, commented out hardware pts sync (I'll likely burn in hell before understanding how to get this bastard to sync well)
mswitch
parents: 3630
diff changeset
124 /* Try to figure out whether to use ws output or not */
3861
f832811cf89a Some last minute changes to accomodate for anamorphic 1.85:1 and 2.35:1 movies... Needs more work, but this is good enough for now.
mswitch
parents: 3828
diff changeset
125 tmp1 = abs(height - ((width/4)*3));
f832811cf89a Some last minute changes to accomodate for anamorphic 1.85:1 and 2.35:1 movies... Needs more work, but this is good enough for now.
mswitch
parents: 3828
diff changeset
126 tmp2 = abs(height - (int)(width/2.35));
f832811cf89a Some last minute changes to accomodate for anamorphic 1.85:1 and 2.35:1 movies... Needs more work, but this is good enough for now.
mswitch
parents: 3828
diff changeset
127 printf( "%d:%d\n",s_width,s_height);
3639
64ee21b3bd09 Modified the sync code once again, commented out hardware pts sync (I'll likely burn in hell before understanding how to get this bastard to sync well)
mswitch
parents: 3630
diff changeset
128 if(tmp1 < tmp2)
64ee21b3bd09 Modified the sync code once again, commented out hardware pts sync (I'll likely burn in hell before understanding how to get this bastard to sync well)
mswitch
parents: 3630
diff changeset
129 {
64ee21b3bd09 Modified the sync code once again, commented out hardware pts sync (I'll likely burn in hell before understanding how to get this bastard to sync well)
mswitch
parents: 3630
diff changeset
130 tmp1 = EM8300_ASPECTRATIO_4_3;
64ee21b3bd09 Modified the sync code once again, commented out hardware pts sync (I'll likely burn in hell before understanding how to get this bastard to sync well)
mswitch
parents: 3630
diff changeset
131 printf( "VO: [dxr3] Setting aspect ratio to 4:3\n" );
64ee21b3bd09 Modified the sync code once again, commented out hardware pts sync (I'll likely burn in hell before understanding how to get this bastard to sync well)
mswitch
parents: 3630
diff changeset
132 }
64ee21b3bd09 Modified the sync code once again, commented out hardware pts sync (I'll likely burn in hell before understanding how to get this bastard to sync well)
mswitch
parents: 3630
diff changeset
133 else
64ee21b3bd09 Modified the sync code once again, commented out hardware pts sync (I'll likely burn in hell before understanding how to get this bastard to sync well)
mswitch
parents: 3630
diff changeset
134 {
64ee21b3bd09 Modified the sync code once again, commented out hardware pts sync (I'll likely burn in hell before understanding how to get this bastard to sync well)
mswitch
parents: 3630
diff changeset
135 tmp1 = EM8300_ASPECTRATIO_16_9;
64ee21b3bd09 Modified the sync code once again, commented out hardware pts sync (I'll likely burn in hell before understanding how to get this bastard to sync well)
mswitch
parents: 3630
diff changeset
136 printf( "VO: [dxr3] Setting aspect ratio to 16:9\n" );
64ee21b3bd09 Modified the sync code once again, commented out hardware pts sync (I'll likely burn in hell before understanding how to get this bastard to sync well)
mswitch
parents: 3630
diff changeset
137 }
64ee21b3bd09 Modified the sync code once again, commented out hardware pts sync (I'll likely burn in hell before understanding how to get this bastard to sync well)
mswitch
parents: 3630
diff changeset
138 ioctl(fd_control,EM8300_IOCTL_SET_ASPECTRATIO,&tmp1);
64ee21b3bd09 Modified the sync code once again, commented out hardware pts sync (I'll likely burn in hell before understanding how to get this bastard to sync well)
mswitch
parents: 3630
diff changeset
139 close(fd_control);
64ee21b3bd09 Modified the sync code once again, commented out hardware pts sync (I'll likely burn in hell before understanding how to get this bastard to sync well)
mswitch
parents: 3630
diff changeset
140
3232
d037e1201721 Added support for codecs that supports BGR24 (some opensource codecs and vivo)
mswitch
parents: 3218
diff changeset
141 if( format == IMGFMT_YV12 || format == IMGFMT_YUY2 || format == IMGFMT_BGR24 )
2645
9d8d69fc517c ao_dxr3 by David Holm <dholm@telia.com>
arpi
parents:
diff changeset
142 {
3432
5cb7caab5536 MP1E configure patch by D. Holm.
atmos4
parents: 3387
diff changeset
143 #ifdef USE_MP1E
2645
9d8d69fc517c ao_dxr3 by David Holm <dholm@telia.com>
arpi
parents:
diff changeset
144 int size;
3201
039a973b3dda Newest DXR3 patch (improved 1.0rc2) by David Holm.
atmos4
parents: 3186
diff changeset
145 enum rte_frame_rate frame_rate;
3630
f24527fc1b79 Removed conversion for yuy2, libmp1e supports this format, no need to cnovert it...
mswitch
parents: 3629
diff changeset
146 enum rte_pixformat pixel_format;
2645
9d8d69fc517c ao_dxr3 by David Holm <dholm@telia.com>
arpi
parents:
diff changeset
147
3201
039a973b3dda Newest DXR3 patch (improved 1.0rc2) by David Holm.
atmos4
parents: 3186
diff changeset
148 if( !rte_init() )
2968
9989497ab31e Minor fixes by David.
atmos4
parents: 2921
diff changeset
149 {
3329
529a001496c2 Switched from rte which caused alot of problems for some users to libmp1e.
mswitch
parents: 3232
diff changeset
150 printf( "VO: [dxr3] Unable to initialize MP1E!\n" );
3201
039a973b3dda Newest DXR3 patch (improved 1.0rc2) by David Holm.
atmos4
parents: 3186
diff changeset
151 return -1;
039a973b3dda Newest DXR3 patch (improved 1.0rc2) by David Holm.
atmos4
parents: 3186
diff changeset
152 }
039a973b3dda Newest DXR3 patch (improved 1.0rc2) by David Holm.
atmos4
parents: 3186
diff changeset
153
3629
a9d1ee93d1c9 Removed some old libavcodec code which would cause inproper scaling of some movies...
mswitch
parents: 3621
diff changeset
154 mp1e_context = rte_context_new( s_width, s_height, NULL );
3201
039a973b3dda Newest DXR3 patch (improved 1.0rc2) by David Holm.
atmos4
parents: 3186
diff changeset
155 rte_set_verbosity( mp1e_context, 0 );
039a973b3dda Newest DXR3 patch (improved 1.0rc2) by David Holm.
atmos4
parents: 3186
diff changeset
156
3629
a9d1ee93d1c9 Removed some old libavcodec code which would cause inproper scaling of some movies...
mswitch
parents: 3621
diff changeset
157 printf( "VO: [dxr3] %dx%d => %dx%d\n", v_width, v_height, s_width, s_height );
3232
d037e1201721 Added support for codecs that supports BGR24 (some opensource codecs and vivo)
mswitch
parents: 3218
diff changeset
158
3201
039a973b3dda Newest DXR3 patch (improved 1.0rc2) by David Holm.
atmos4
parents: 3186
diff changeset
159 if( !mp1e_context )
039a973b3dda Newest DXR3 patch (improved 1.0rc2) by David Holm.
atmos4
parents: 3186
diff changeset
160 {
039a973b3dda Newest DXR3 patch (improved 1.0rc2) by David Holm.
atmos4
parents: 3186
diff changeset
161 printf( "VO: [dxr3] Unable to create context!\n" );
039a973b3dda Newest DXR3 patch (improved 1.0rc2) by David Holm.
atmos4
parents: 3186
diff changeset
162 return -1;
039a973b3dda Newest DXR3 patch (improved 1.0rc2) by David Holm.
atmos4
parents: 3186
diff changeset
163 }
039a973b3dda Newest DXR3 patch (improved 1.0rc2) by David Holm.
atmos4
parents: 3186
diff changeset
164
039a973b3dda Newest DXR3 patch (improved 1.0rc2) by David Holm.
atmos4
parents: 3186
diff changeset
165 if( !rte_set_format( mp1e_context, "mpeg1" ) )
039a973b3dda Newest DXR3 patch (improved 1.0rc2) by David Holm.
atmos4
parents: 3186
diff changeset
166 {
039a973b3dda Newest DXR3 patch (improved 1.0rc2) by David Holm.
atmos4
parents: 3186
diff changeset
167 printf( "VO: [dxr3] Unable to set format\n" );
039a973b3dda Newest DXR3 patch (improved 1.0rc2) by David Holm.
atmos4
parents: 3186
diff changeset
168 return -1;
039a973b3dda Newest DXR3 patch (improved 1.0rc2) by David Holm.
atmos4
parents: 3186
diff changeset
169 }
039a973b3dda Newest DXR3 patch (improved 1.0rc2) by David Holm.
atmos4
parents: 3186
diff changeset
170
039a973b3dda Newest DXR3 patch (improved 1.0rc2) by David Holm.
atmos4
parents: 3186
diff changeset
171 rte_set_mode( mp1e_context, RTE_VIDEO );
039a973b3dda Newest DXR3 patch (improved 1.0rc2) by David Holm.
atmos4
parents: 3186
diff changeset
172 mp1e_codec = rte_codec_set( mp1e_context, RTE_STREAM_VIDEO, 0, "mpeg1-video" );
2866
4f6190ab52e7 Added a temporary fix to the DXR3 win32 codec playback, win32 codecs might prove to play back an unscaled image!
mswitch
parents: 2770
diff changeset
173
3201
039a973b3dda Newest DXR3 patch (improved 1.0rc2) by David Holm.
atmos4
parents: 3186
diff changeset
174 if( vo_fps < 24.0 ) frame_rate = RTE_RATE_1;
039a973b3dda Newest DXR3 patch (improved 1.0rc2) by David Holm.
atmos4
parents: 3186
diff changeset
175 else if( vo_fps < 25.0 ) frame_rate = RTE_RATE_2;
039a973b3dda Newest DXR3 patch (improved 1.0rc2) by David Holm.
atmos4
parents: 3186
diff changeset
176 else if( vo_fps < 29.97 ) frame_rate = RTE_RATE_3;
039a973b3dda Newest DXR3 patch (improved 1.0rc2) by David Holm.
atmos4
parents: 3186
diff changeset
177 else if( vo_fps < 30.0 ) frame_rate = RTE_RATE_4;
039a973b3dda Newest DXR3 patch (improved 1.0rc2) by David Holm.
atmos4
parents: 3186
diff changeset
178 else if( vo_fps < 50.0 ) frame_rate = RTE_RATE_5;
039a973b3dda Newest DXR3 patch (improved 1.0rc2) by David Holm.
atmos4
parents: 3186
diff changeset
179 else if( vo_fps < 59.97 ) frame_rate = RTE_RATE_6;
039a973b3dda Newest DXR3 patch (improved 1.0rc2) by David Holm.
atmos4
parents: 3186
diff changeset
180 else if( vo_fps < 60.0 ) frame_rate = RTE_RATE_7;
039a973b3dda Newest DXR3 patch (improved 1.0rc2) by David Holm.
atmos4
parents: 3186
diff changeset
181 else if( vo_fps > 60.0 ) frame_rate = RTE_RATE_8;
039a973b3dda Newest DXR3 patch (improved 1.0rc2) by David Holm.
atmos4
parents: 3186
diff changeset
182 else frame_rate = RTE_RATE_NORATE;
039a973b3dda Newest DXR3 patch (improved 1.0rc2) by David Holm.
atmos4
parents: 3186
diff changeset
183
3630
f24527fc1b79 Removed conversion for yuy2, libmp1e supports this format, no need to cnovert it...
mswitch
parents: 3629
diff changeset
184 if( format == IMGFMT_YUY2 )
f24527fc1b79 Removed conversion for yuy2, libmp1e supports this format, no need to cnovert it...
mswitch
parents: 3629
diff changeset
185 pixel_format = RTE_YUYV;
f24527fc1b79 Removed conversion for yuy2, libmp1e supports this format, no need to cnovert it...
mswitch
parents: 3629
diff changeset
186 else
f24527fc1b79 Removed conversion for yuy2, libmp1e supports this format, no need to cnovert it...
mswitch
parents: 3629
diff changeset
187 pixel_format = RTE_YUV420;
f24527fc1b79 Removed conversion for yuy2, libmp1e supports this format, no need to cnovert it...
mswitch
parents: 3629
diff changeset
188 if( !rte_set_video_parameters( mp1e_context, pixel_format, mp1e_context->width,
3201
039a973b3dda Newest DXR3 patch (improved 1.0rc2) by David Holm.
atmos4
parents: 3186
diff changeset
189 mp1e_context->height, frame_rate,
3828
063e5b0065a4 Brand new sync core, uses hw sync for everything.
mswitch
parents: 3759
diff changeset
190 3e6, "I" ) )
3201
039a973b3dda Newest DXR3 patch (improved 1.0rc2) by David Holm.
atmos4
parents: 3186
diff changeset
191 {
3329
529a001496c2 Switched from rte which caused alot of problems for some users to libmp1e.
mswitch
parents: 3232
diff changeset
192 printf( "VO: [dxr3] Unable to set mp1e context!\n" );
3201
039a973b3dda Newest DXR3 patch (improved 1.0rc2) by David Holm.
atmos4
parents: 3186
diff changeset
193 rte_context_destroy( mp1e_context );
039a973b3dda Newest DXR3 patch (improved 1.0rc2) by David Holm.
atmos4
parents: 3186
diff changeset
194 return -1;
039a973b3dda Newest DXR3 patch (improved 1.0rc2) by David Holm.
atmos4
parents: 3186
diff changeset
195 }
039a973b3dda Newest DXR3 patch (improved 1.0rc2) by David Holm.
atmos4
parents: 3186
diff changeset
196
039a973b3dda Newest DXR3 patch (improved 1.0rc2) by David Holm.
atmos4
parents: 3186
diff changeset
197 rte_set_input( mp1e_context, RTE_VIDEO, RTE_PUSH, TRUE, NULL, NULL, NULL );
3208
98a587aaf505 Support for YV12 with DXR3, patch by D. Holm.
atmos4
parents: 3201
diff changeset
198 rte_set_output( mp1e_context, (void*)write_dxr3, NULL, NULL );
3201
039a973b3dda Newest DXR3 patch (improved 1.0rc2) by David Holm.
atmos4
parents: 3186
diff changeset
199
039a973b3dda Newest DXR3 patch (improved 1.0rc2) by David Holm.
atmos4
parents: 3186
diff changeset
200 if( !rte_init_context( mp1e_context ) )
039a973b3dda Newest DXR3 patch (improved 1.0rc2) by David Holm.
atmos4
parents: 3186
diff changeset
201 {
3329
529a001496c2 Switched from rte which caused alot of problems for some users to libmp1e.
mswitch
parents: 3232
diff changeset
202 printf( "VO: [dxr3] Unable to init mp1e context!\n" );
3201
039a973b3dda Newest DXR3 patch (improved 1.0rc2) by David Holm.
atmos4
parents: 3186
diff changeset
203 rte_context_delete( mp1e_context );
039a973b3dda Newest DXR3 patch (improved 1.0rc2) by David Holm.
atmos4
parents: 3186
diff changeset
204 return -1;
039a973b3dda Newest DXR3 patch (improved 1.0rc2) by David Holm.
atmos4
parents: 3186
diff changeset
205 }
039a973b3dda Newest DXR3 patch (improved 1.0rc2) by David Holm.
atmos4
parents: 3186
diff changeset
206
3629
a9d1ee93d1c9 Removed some old libavcodec code which would cause inproper scaling of some movies...
mswitch
parents: 3621
diff changeset
207 osd_w=s_width;
a9d1ee93d1c9 Removed some old libavcodec code which would cause inproper scaling of some movies...
mswitch
parents: 3621
diff changeset
208 d_pos_x=(s_width-v_width)/2;
3208
98a587aaf505 Support for YV12 with DXR3, patch by D. Holm.
atmos4
parents: 3201
diff changeset
209 if(d_pos_x<0)
98a587aaf505 Support for YV12 with DXR3, patch by D. Holm.
atmos4
parents: 3201
diff changeset
210 {
98a587aaf505 Support for YV12 with DXR3, patch by D. Holm.
atmos4
parents: 3201
diff changeset
211 s_pos_x=-d_pos_x;d_pos_x=0;
3629
a9d1ee93d1c9 Removed some old libavcodec code which would cause inproper scaling of some movies...
mswitch
parents: 3621
diff changeset
212 osd_w=s_width;
2645
9d8d69fc517c ao_dxr3 by David Holm <dholm@telia.com>
arpi
parents:
diff changeset
213 } else s_pos_x=0;
9d8d69fc517c ao_dxr3 by David Holm <dholm@telia.com>
arpi
parents:
diff changeset
214
3629
a9d1ee93d1c9 Removed some old libavcodec code which would cause inproper scaling of some movies...
mswitch
parents: 3621
diff changeset
215 osd_h=s_height;
a9d1ee93d1c9 Removed some old libavcodec code which would cause inproper scaling of some movies...
mswitch
parents: 3621
diff changeset
216 d_pos_y=(s_height-v_height)/2;
3208
98a587aaf505 Support for YV12 with DXR3, patch by D. Holm.
atmos4
parents: 3201
diff changeset
217 if(d_pos_y<0)
98a587aaf505 Support for YV12 with DXR3, patch by D. Holm.
atmos4
parents: 3201
diff changeset
218 {
98a587aaf505 Support for YV12 with DXR3, patch by D. Holm.
atmos4
parents: 3201
diff changeset
219 s_pos_y=-d_pos_y;d_pos_y=0;
3629
a9d1ee93d1c9 Removed some old libavcodec code which would cause inproper scaling of some movies...
mswitch
parents: 3621
diff changeset
220 osd_h=s_height;
2645
9d8d69fc517c ao_dxr3 by David Holm <dholm@telia.com>
arpi
parents:
diff changeset
221 } else s_pos_y=0;
9d8d69fc517c ao_dxr3 by David Holm <dholm@telia.com>
arpi
parents:
diff changeset
222
3218
8ba06b63f873 Fix green borders -> black borders, patch from D. Holm, also small fix to dxr3 ao.
atmos4
parents: 3208
diff changeset
223 printf("VO: [dxr3] Position mapping: %d;%d => %d;%d\n",s_pos_x,s_pos_y,d_pos_x,d_pos_y);
3201
039a973b3dda Newest DXR3 patch (improved 1.0rc2) by David Holm.
atmos4
parents: 3186
diff changeset
224
3629
a9d1ee93d1c9 Removed some old libavcodec code which would cause inproper scaling of some movies...
mswitch
parents: 3621
diff changeset
225 size = s_width*s_height;
3201
039a973b3dda Newest DXR3 patch (improved 1.0rc2) by David Holm.
atmos4
parents: 3186
diff changeset
226
3759
a5f9c19f734f osd support, not for mpegpes
mswitch
parents: 3661
diff changeset
227 if( format == IMGFMT_YUY2 )
a5f9c19f734f osd support, not for mpegpes
mswitch
parents: 3661
diff changeset
228 {
a5f9c19f734f osd support, not for mpegpes
mswitch
parents: 3661
diff changeset
229 picture_data[0] = NULL;
a5f9c19f734f osd support, not for mpegpes
mswitch
parents: 3661
diff changeset
230 picture_linesize[0] = s_width * 2;
a5f9c19f734f osd support, not for mpegpes
mswitch
parents: 3661
diff changeset
231 }
a5f9c19f734f osd support, not for mpegpes
mswitch
parents: 3661
diff changeset
232 else
a5f9c19f734f osd support, not for mpegpes
mswitch
parents: 3661
diff changeset
233 {
a5f9c19f734f osd support, not for mpegpes
mswitch
parents: 3661
diff changeset
234 picture_data[0] = malloc((size * 3)/2);
a5f9c19f734f osd support, not for mpegpes
mswitch
parents: 3661
diff changeset
235 picture_data[1] = picture_data[0] + size;
a5f9c19f734f osd support, not for mpegpes
mswitch
parents: 3661
diff changeset
236 picture_data[2] = picture_data[1] + size / 4;
a5f9c19f734f osd support, not for mpegpes
mswitch
parents: 3661
diff changeset
237 picture_linesize[0] = s_width;
a5f9c19f734f osd support, not for mpegpes
mswitch
parents: 3661
diff changeset
238 picture_linesize[1] = s_width / 2;
a5f9c19f734f osd support, not for mpegpes
mswitch
parents: 3661
diff changeset
239 picture_linesize[2] = s_width / 2;
a5f9c19f734f osd support, not for mpegpes
mswitch
parents: 3661
diff changeset
240 }
3218
8ba06b63f873 Fix green borders -> black borders, patch from D. Holm, also small fix to dxr3 ao.
atmos4
parents: 3208
diff changeset
241
3201
039a973b3dda Newest DXR3 patch (improved 1.0rc2) by David Holm.
atmos4
parents: 3186
diff changeset
242
039a973b3dda Newest DXR3 patch (improved 1.0rc2) by David Holm.
atmos4
parents: 3186
diff changeset
243 if( !rte_start_encoding( mp1e_context ) )
2968
9989497ab31e Minor fixes by David.
atmos4
parents: 2921
diff changeset
244 {
3201
039a973b3dda Newest DXR3 patch (improved 1.0rc2) by David Holm.
atmos4
parents: 3186
diff changeset
245 printf( "VO: [dxr3] Unable to start mp1e encoding!\n" );
039a973b3dda Newest DXR3 patch (improved 1.0rc2) by David Holm.
atmos4
parents: 3186
diff changeset
246 uninit();
039a973b3dda Newest DXR3 patch (improved 1.0rc2) by David Holm.
atmos4
parents: 3186
diff changeset
247 return -1;
039a973b3dda Newest DXR3 patch (improved 1.0rc2) by David Holm.
atmos4
parents: 3186
diff changeset
248 }
2770
b9732eaa82d9 DXR3 beta2 patch by David Holm.
atmos4
parents: 2732
diff changeset
249
3639
64ee21b3bd09 Modified the sync code once again, commented out hardware pts sync (I'll likely burn in hell before understanding how to get this bastard to sync well)
mswitch
parents: 3630
diff changeset
250 if(format == IMGFMT_BGR24) yuv2rgb_init(24, MODE_BGR);
2770
b9732eaa82d9 DXR3 beta2 patch by David Holm.
atmos4
parents: 2732
diff changeset
251 return 0;
3432
5cb7caab5536 MP1E configure patch by D. Holm.
atmos4
parents: 3387
diff changeset
252 #endif
5cb7caab5536 MP1E configure patch by D. Holm.
atmos4
parents: 3387
diff changeset
253 return -1;
2770
b9732eaa82d9 DXR3 beta2 patch by David Holm.
atmos4
parents: 2732
diff changeset
254 }
2645
9d8d69fc517c ao_dxr3 by David Holm <dholm@telia.com>
arpi
parents:
diff changeset
255 else if(format==IMGFMT_MPEGPES)
9d8d69fc517c ao_dxr3 by David Holm <dholm@telia.com>
arpi
parents:
diff changeset
256 {
2921
ee37c7fc3022 dxr3-patch4 by David Holm
arpi
parents: 2866
diff changeset
257 printf( "VO: [dxr3] Format: MPEG-PES (no conversion needed)\n" );
2645
9d8d69fc517c ao_dxr3 by David Holm <dholm@telia.com>
arpi
parents:
diff changeset
258 return 0;
9d8d69fc517c ao_dxr3 by David Holm <dholm@telia.com>
arpi
parents:
diff changeset
259 }
9d8d69fc517c ao_dxr3 by David Holm <dholm@telia.com>
arpi
parents:
diff changeset
260
3614
6fef049b8fe4 Fix glitchy mpeg playback
mswitch
parents: 3432
diff changeset
261 printf( "VO: [dxr3] Format: Unsupported\n" );
2645
9d8d69fc517c ao_dxr3 by David Holm <dholm@telia.com>
arpi
parents:
diff changeset
262 return -1;
9d8d69fc517c ao_dxr3 by David Holm <dholm@telia.com>
arpi
parents:
diff changeset
263 }
9d8d69fc517c ao_dxr3 by David Holm <dholm@telia.com>
arpi
parents:
diff changeset
264
2866
4f6190ab52e7 Added a temporary fix to the DXR3 win32 codec playback, win32 codecs might prove to play back an unscaled image!
mswitch
parents: 2770
diff changeset
265 static const vo_info_t* get_info(void)
2645
9d8d69fc517c ao_dxr3 by David Holm <dholm@telia.com>
arpi
parents:
diff changeset
266 {
9d8d69fc517c ao_dxr3 by David Holm <dholm@telia.com>
arpi
parents:
diff changeset
267 return &vo_info;
9d8d69fc517c ao_dxr3 by David Holm <dholm@telia.com>
arpi
parents:
diff changeset
268 }
9d8d69fc517c ao_dxr3 by David Holm <dholm@telia.com>
arpi
parents:
diff changeset
269
2866
4f6190ab52e7 Added a temporary fix to the DXR3 win32 codec playback, win32 codecs might prove to play back an unscaled image!
mswitch
parents: 2770
diff changeset
270 static void draw_alpha(int x0, int y0, int w, int h, unsigned char* src, unsigned char *srca, int srcstride)
2645
9d8d69fc517c ao_dxr3 by David Holm <dholm@telia.com>
arpi
parents:
diff changeset
271 {
3759
a5f9c19f734f osd support, not for mpegpes
mswitch
parents: 3661
diff changeset
272 switch(img_format)
a5f9c19f734f osd support, not for mpegpes
mswitch
parents: 3661
diff changeset
273 {
a5f9c19f734f osd support, not for mpegpes
mswitch
parents: 3661
diff changeset
274 case IMGFMT_BGR24:
a5f9c19f734f osd support, not for mpegpes
mswitch
parents: 3661
diff changeset
275 case IMGFMT_YV12:
a5f9c19f734f osd support, not for mpegpes
mswitch
parents: 3661
diff changeset
276 vo_draw_alpha_yv12(w,h,src,srca,srcstride,picture_data[0]+(x0+d_pos_x)+(y0+d_pos_y)*picture_linesize[0],picture_linesize[0]);
a5f9c19f734f osd support, not for mpegpes
mswitch
parents: 3661
diff changeset
277 break;
a5f9c19f734f osd support, not for mpegpes
mswitch
parents: 3661
diff changeset
278 case IMGFMT_YUY2:
a5f9c19f734f osd support, not for mpegpes
mswitch
parents: 3661
diff changeset
279 vo_draw_alpha_yuy2(w,h,src,srca,srcstride,picture_data[0]+(x0+d_pos_x)*2+(y0+d_pos_y)*picture_linesize[0],picture_linesize[0]);
a5f9c19f734f osd support, not for mpegpes
mswitch
parents: 3661
diff changeset
280 break;
a5f9c19f734f osd support, not for mpegpes
mswitch
parents: 3661
diff changeset
281 }
2645
9d8d69fc517c ao_dxr3 by David Holm <dholm@telia.com>
arpi
parents:
diff changeset
282 }
9d8d69fc517c ao_dxr3 by David Holm <dholm@telia.com>
arpi
parents:
diff changeset
283
9d8d69fc517c ao_dxr3 by David Holm <dholm@telia.com>
arpi
parents:
diff changeset
284 static void draw_osd(void)
9d8d69fc517c ao_dxr3 by David Holm <dholm@telia.com>
arpi
parents:
diff changeset
285 {
3759
a5f9c19f734f osd support, not for mpegpes
mswitch
parents: 3661
diff changeset
286 vo_draw_text(osd_w,osd_h,draw_alpha);
2645
9d8d69fc517c ao_dxr3 by David Holm <dholm@telia.com>
arpi
parents:
diff changeset
287 }
9d8d69fc517c ao_dxr3 by David Holm <dholm@telia.com>
arpi
parents:
diff changeset
288
9d8d69fc517c ao_dxr3 by David Holm <dholm@telia.com>
arpi
parents:
diff changeset
289 static uint32_t draw_frame(uint8_t * src[])
9d8d69fc517c ao_dxr3 by David Holm <dholm@telia.com>
arpi
parents:
diff changeset
290 {
9d8d69fc517c ao_dxr3 by David Holm <dholm@telia.com>
arpi
parents:
diff changeset
291 if( img_format == IMGFMT_MPEGPES )
9d8d69fc517c ao_dxr3 by David Holm <dholm@telia.com>
arpi
parents:
diff changeset
292 {
2770
b9732eaa82d9 DXR3 beta2 patch by David Holm.
atmos4
parents: 2732
diff changeset
293 int data_left;
2645
9d8d69fc517c ao_dxr3 by David Holm <dholm@telia.com>
arpi
parents:
diff changeset
294 vo_mpegpes_t *p=(vo_mpegpes_t *)src[0];
3201
039a973b3dda Newest DXR3 patch (improved 1.0rc2) by David Holm.
atmos4
parents: 3186
diff changeset
295
3828
063e5b0065a4 Brand new sync core, uses hw sync for everything.
mswitch
parents: 3759
diff changeset
296 if(ioctl(fd_video,EM8300_IOCTL_VIDEO_SETPTS,&vo_pts) < 0)
063e5b0065a4 Brand new sync core, uses hw sync for everything.
mswitch
parents: 3759
diff changeset
297 printf( "VO: [dxr3] Unable to set pts\n" );
2645
9d8d69fc517c ao_dxr3 by David Holm <dholm@telia.com>
arpi
parents:
diff changeset
298 data_left = p->size;
9d8d69fc517c ao_dxr3 by David Holm <dholm@telia.com>
arpi
parents:
diff changeset
299 while( data_left )
2921
ee37c7fc3022 dxr3-patch4 by David Holm
arpi
parents: 2866
diff changeset
300 data_left -= write( fd_video, &((unsigned char*)p->data)[p->size-data_left], data_left );
ee37c7fc3022 dxr3-patch4 by David Holm
arpi
parents: 2866
diff changeset
301
2645
9d8d69fc517c ao_dxr3 by David Holm <dholm@telia.com>
arpi
parents:
diff changeset
302 return 0;
9d8d69fc517c ao_dxr3 by David Holm <dholm@telia.com>
arpi
parents:
diff changeset
303 }
3432
5cb7caab5536 MP1E configure patch by D. Holm.
atmos4
parents: 3387
diff changeset
304 #ifdef USE_MP1E
3208
98a587aaf505 Support for YV12 with DXR3, patch by D. Holm.
atmos4
parents: 3201
diff changeset
305 else if( img_format == IMGFMT_YUY2 )
98a587aaf505 Support for YV12 with DXR3, patch by D. Holm.
atmos4
parents: 3201
diff changeset
306 {
3759
a5f9c19f734f osd support, not for mpegpes
mswitch
parents: 3661
diff changeset
307 picture_data[0] = src[0];
3208
98a587aaf505 Support for YV12 with DXR3, patch by D. Holm.
atmos4
parents: 3201
diff changeset
308 return 0;
98a587aaf505 Support for YV12 with DXR3, patch by D. Holm.
atmos4
parents: 3201
diff changeset
309 }
3232
d037e1201721 Added support for codecs that supports BGR24 (some opensource codecs and vivo)
mswitch
parents: 3218
diff changeset
310 else if( img_format == IMGFMT_BGR24 )
d037e1201721 Added support for codecs that supports BGR24 (some opensource codecs and vivo)
mswitch
parents: 3218
diff changeset
311 {
d037e1201721 Added support for codecs that supports BGR24 (some opensource codecs and vivo)
mswitch
parents: 3218
diff changeset
312 int x,y,w=v_width,h=v_height;
d037e1201721 Added support for codecs that supports BGR24 (some opensource codecs and vivo)
mswitch
parents: 3218
diff changeset
313 unsigned char *s,*dY,*dU,*dV;
d037e1201721 Added support for codecs that supports BGR24 (some opensource codecs and vivo)
mswitch
parents: 3218
diff changeset
314
d037e1201721 Added support for codecs that supports BGR24 (some opensource codecs and vivo)
mswitch
parents: 3218
diff changeset
315 if(d_pos_x+w>picture_linesize[0]) w=picture_linesize[0]-d_pos_x;
3629
a9d1ee93d1c9 Removed some old libavcodec code which would cause inproper scaling of some movies...
mswitch
parents: 3621
diff changeset
316 if(d_pos_y+h>s_height) h=s_height-d_pos_y;
3232
d037e1201721 Added support for codecs that supports BGR24 (some opensource codecs and vivo)
mswitch
parents: 3218
diff changeset
317
d037e1201721 Added support for codecs that supports BGR24 (some opensource codecs and vivo)
mswitch
parents: 3218
diff changeset
318 s = src[0]+s_pos_y*(w*3);
d037e1201721 Added support for codecs that supports BGR24 (some opensource codecs and vivo)
mswitch
parents: 3218
diff changeset
319
d037e1201721 Added support for codecs that supports BGR24 (some opensource codecs and vivo)
mswitch
parents: 3218
diff changeset
320 dY = picture_data[0]+d_pos_y*picture_linesize[0];
d037e1201721 Added support for codecs that supports BGR24 (some opensource codecs and vivo)
mswitch
parents: 3218
diff changeset
321 dU = picture_data[1]+(d_pos_y/2)*picture_linesize[1];
d037e1201721 Added support for codecs that supports BGR24 (some opensource codecs and vivo)
mswitch
parents: 3218
diff changeset
322 dV = picture_data[2]+(d_pos_y/2)*picture_linesize[2];
d037e1201721 Added support for codecs that supports BGR24 (some opensource codecs and vivo)
mswitch
parents: 3218
diff changeset
323
3639
64ee21b3bd09 Modified the sync code once again, commented out hardware pts sync (I'll likely burn in hell before understanding how to get this bastard to sync well)
mswitch
parents: 3630
diff changeset
324 rgb24toyv12(s,dY,dU,dV,w,h,picture_linesize[0],picture_linesize[1],v_width*3);
3232
d037e1201721 Added support for codecs that supports BGR24 (some opensource codecs and vivo)
mswitch
parents: 3218
diff changeset
325
d037e1201721 Added support for codecs that supports BGR24 (some opensource codecs and vivo)
mswitch
parents: 3218
diff changeset
326 mp1e_buffer.data = picture_data[0];
d037e1201721 Added support for codecs that supports BGR24 (some opensource codecs and vivo)
mswitch
parents: 3218
diff changeset
327 mp1e_buffer.time = vo_pts/90000.0;
d037e1201721 Added support for codecs that supports BGR24 (some opensource codecs and vivo)
mswitch
parents: 3218
diff changeset
328 mp1e_buffer.user_data = NULL;
3759
a5f9c19f734f osd support, not for mpegpes
mswitch
parents: 3661
diff changeset
329 vo_draw_text(osd_w,osd_h,draw_alpha);
3232
d037e1201721 Added support for codecs that supports BGR24 (some opensource codecs and vivo)
mswitch
parents: 3218
diff changeset
330 rte_push_video_buffer( mp1e_context, &mp1e_buffer );
d037e1201721 Added support for codecs that supports BGR24 (some opensource codecs and vivo)
mswitch
parents: 3218
diff changeset
331
d037e1201721 Added support for codecs that supports BGR24 (some opensource codecs and vivo)
mswitch
parents: 3218
diff changeset
332 return 0;
d037e1201721 Added support for codecs that supports BGR24 (some opensource codecs and vivo)
mswitch
parents: 3218
diff changeset
333 }
3432
5cb7caab5536 MP1E configure patch by D. Holm.
atmos4
parents: 3387
diff changeset
334 #endif
2645
9d8d69fc517c ao_dxr3 by David Holm <dholm@telia.com>
arpi
parents:
diff changeset
335 return -1;
9d8d69fc517c ao_dxr3 by David Holm <dholm@telia.com>
arpi
parents:
diff changeset
336 }
9d8d69fc517c ao_dxr3 by David Holm <dholm@telia.com>
arpi
parents:
diff changeset
337
9d8d69fc517c ao_dxr3 by David Holm <dholm@telia.com>
arpi
parents:
diff changeset
338 static void flip_page (void)
9d8d69fc517c ao_dxr3 by David Holm <dholm@telia.com>
arpi
parents:
diff changeset
339 {
3432
5cb7caab5536 MP1E configure patch by D. Holm.
atmos4
parents: 3387
diff changeset
340 #ifdef USE_MP1E
3201
039a973b3dda Newest DXR3 patch (improved 1.0rc2) by David Holm.
atmos4
parents: 3186
diff changeset
341 if( img_format == IMGFMT_YV12 )
039a973b3dda Newest DXR3 patch (improved 1.0rc2) by David Holm.
atmos4
parents: 3186
diff changeset
342 {
039a973b3dda Newest DXR3 patch (improved 1.0rc2) by David Holm.
atmos4
parents: 3186
diff changeset
343 mp1e_buffer.data = picture_data[0];
039a973b3dda Newest DXR3 patch (improved 1.0rc2) by David Holm.
atmos4
parents: 3186
diff changeset
344 mp1e_buffer.time = vo_pts/90000.0;
039a973b3dda Newest DXR3 patch (improved 1.0rc2) by David Holm.
atmos4
parents: 3186
diff changeset
345 mp1e_buffer.user_data = NULL;
039a973b3dda Newest DXR3 patch (improved 1.0rc2) by David Holm.
atmos4
parents: 3186
diff changeset
346 rte_push_video_buffer( mp1e_context, &mp1e_buffer );
039a973b3dda Newest DXR3 patch (improved 1.0rc2) by David Holm.
atmos4
parents: 3186
diff changeset
347 }
3759
a5f9c19f734f osd support, not for mpegpes
mswitch
parents: 3661
diff changeset
348 else if( img_format == IMGFMT_YUY2 )
a5f9c19f734f osd support, not for mpegpes
mswitch
parents: 3661
diff changeset
349 {
a5f9c19f734f osd support, not for mpegpes
mswitch
parents: 3661
diff changeset
350 mp1e_buffer.data = picture_data[0];
a5f9c19f734f osd support, not for mpegpes
mswitch
parents: 3661
diff changeset
351 mp1e_buffer.time = vo_pts/90000.0;
a5f9c19f734f osd support, not for mpegpes
mswitch
parents: 3661
diff changeset
352 mp1e_buffer.user_data = NULL;
a5f9c19f734f osd support, not for mpegpes
mswitch
parents: 3661
diff changeset
353 rte_push_video_buffer( mp1e_context, &mp1e_buffer );
a5f9c19f734f osd support, not for mpegpes
mswitch
parents: 3661
diff changeset
354 }
3432
5cb7caab5536 MP1E configure patch by D. Holm.
atmos4
parents: 3387
diff changeset
355 #endif
2645
9d8d69fc517c ao_dxr3 by David Holm <dholm@telia.com>
arpi
parents:
diff changeset
356 }
9d8d69fc517c ao_dxr3 by David Holm <dholm@telia.com>
arpi
parents:
diff changeset
357
9d8d69fc517c ao_dxr3 by David Holm <dholm@telia.com>
arpi
parents:
diff changeset
358 static uint32_t draw_slice( uint8_t *srcimg[], int stride[], int w, int h, int x0, int y0 )
9d8d69fc517c ao_dxr3 by David Holm <dholm@telia.com>
arpi
parents:
diff changeset
359 {
9d8d69fc517c ao_dxr3 by David Holm <dholm@telia.com>
arpi
parents:
diff changeset
360 if( img_format == IMGFMT_YV12 )
3201
039a973b3dda Newest DXR3 patch (improved 1.0rc2) by David Holm.
atmos4
parents: 3186
diff changeset
361 {
3232
d037e1201721 Added support for codecs that supports BGR24 (some opensource codecs and vivo)
mswitch
parents: 3218
diff changeset
362 int y;
d037e1201721 Added support for codecs that supports BGR24 (some opensource codecs and vivo)
mswitch
parents: 3218
diff changeset
363 unsigned char *s,*s1;
d037e1201721 Added support for codecs that supports BGR24 (some opensource codecs and vivo)
mswitch
parents: 3218
diff changeset
364 unsigned char *d,*d1;
d037e1201721 Added support for codecs that supports BGR24 (some opensource codecs and vivo)
mswitch
parents: 3218
diff changeset
365
2645
9d8d69fc517c ao_dxr3 by David Holm <dholm@telia.com>
arpi
parents:
diff changeset
366 x0+=d_pos_x;
3232
d037e1201721 Added support for codecs that supports BGR24 (some opensource codecs and vivo)
mswitch
parents: 3218
diff changeset
367 y0+=d_pos_y;
3218
8ba06b63f873 Fix green borders -> black borders, patch from D. Holm, also small fix to dxr3 ao.
atmos4
parents: 3208
diff changeset
368
3201
039a973b3dda Newest DXR3 patch (improved 1.0rc2) by David Holm.
atmos4
parents: 3186
diff changeset
369 if(x0+w>picture_linesize[0]) w=picture_linesize[0]-x0;
3629
a9d1ee93d1c9 Removed some old libavcodec code which would cause inproper scaling of some movies...
mswitch
parents: 3621
diff changeset
370 if(y0+h>s_height) h=s_height-y0;
2645
9d8d69fc517c ao_dxr3 by David Holm <dholm@telia.com>
arpi
parents:
diff changeset
371
9d8d69fc517c ao_dxr3 by David Holm <dholm@telia.com>
arpi
parents:
diff changeset
372 s=srcimg[0]+s_pos_x+s_pos_y*stride[0];
3201
039a973b3dda Newest DXR3 patch (improved 1.0rc2) by David Holm.
atmos4
parents: 3186
diff changeset
373 d=picture_data[0]+x0+y0*picture_linesize[0];
3232
d037e1201721 Added support for codecs that supports BGR24 (some opensource codecs and vivo)
mswitch
parents: 3218
diff changeset
374 for(y=0;y<h;y++)
d037e1201721 Added support for codecs that supports BGR24 (some opensource codecs and vivo)
mswitch
parents: 3218
diff changeset
375 {
d037e1201721 Added support for codecs that supports BGR24 (some opensource codecs and vivo)
mswitch
parents: 3218
diff changeset
376 memcpy(d,s,w);
d037e1201721 Added support for codecs that supports BGR24 (some opensource codecs and vivo)
mswitch
parents: 3218
diff changeset
377 s+=stride[0];
d037e1201721 Added support for codecs that supports BGR24 (some opensource codecs and vivo)
mswitch
parents: 3218
diff changeset
378 d+=picture_linesize[0];
d037e1201721 Added support for codecs that supports BGR24 (some opensource codecs and vivo)
mswitch
parents: 3218
diff changeset
379 }
2645
9d8d69fc517c ao_dxr3 by David Holm <dholm@telia.com>
arpi
parents:
diff changeset
380
3218
8ba06b63f873 Fix green borders -> black borders, patch from D. Holm, also small fix to dxr3 ao.
atmos4
parents: 3208
diff changeset
381 w/=2;h/=2;x0/=2;y0/=2;
8ba06b63f873 Fix green borders -> black borders, patch from D. Holm, also small fix to dxr3 ao.
atmos4
parents: 3208
diff changeset
382
3208
98a587aaf505 Support for YV12 with DXR3, patch by D. Holm.
atmos4
parents: 3201
diff changeset
383 s=srcimg[1]+s_pos_x+s_pos_y*stride[1];
3218
8ba06b63f873 Fix green borders -> black borders, patch from D. Holm, also small fix to dxr3 ao.
atmos4
parents: 3208
diff changeset
384 d=picture_data[1]+x0+y0*picture_linesize[1];
3232
d037e1201721 Added support for codecs that supports BGR24 (some opensource codecs and vivo)
mswitch
parents: 3218
diff changeset
385 s1=srcimg[2]+s_pos_x+s_pos_y*stride[2];
d037e1201721 Added support for codecs that supports BGR24 (some opensource codecs and vivo)
mswitch
parents: 3218
diff changeset
386 d1=picture_data[2]+x0+y0*picture_linesize[2];
d037e1201721 Added support for codecs that supports BGR24 (some opensource codecs and vivo)
mswitch
parents: 3218
diff changeset
387 for(y=0;y<h;y++)
d037e1201721 Added support for codecs that supports BGR24 (some opensource codecs and vivo)
mswitch
parents: 3218
diff changeset
388 {
d037e1201721 Added support for codecs that supports BGR24 (some opensource codecs and vivo)
mswitch
parents: 3218
diff changeset
389 memcpy(d,s,w);
d037e1201721 Added support for codecs that supports BGR24 (some opensource codecs and vivo)
mswitch
parents: 3218
diff changeset
390 memcpy(d1,s1,w);
d037e1201721 Added support for codecs that supports BGR24 (some opensource codecs and vivo)
mswitch
parents: 3218
diff changeset
391 s+=stride[1];s1+=stride[2];
d037e1201721 Added support for codecs that supports BGR24 (some opensource codecs and vivo)
mswitch
parents: 3218
diff changeset
392 d+=picture_linesize[1];d1+=picture_linesize[2];
d037e1201721 Added support for codecs that supports BGR24 (some opensource codecs and vivo)
mswitch
parents: 3218
diff changeset
393 }
2645
9d8d69fc517c ao_dxr3 by David Holm <dholm@telia.com>
arpi
parents:
diff changeset
394
9d8d69fc517c ao_dxr3 by David Holm <dholm@telia.com>
arpi
parents:
diff changeset
395 return 0;
9d8d69fc517c ao_dxr3 by David Holm <dholm@telia.com>
arpi
parents:
diff changeset
396 }
9d8d69fc517c ao_dxr3 by David Holm <dholm@telia.com>
arpi
parents:
diff changeset
397
9d8d69fc517c ao_dxr3 by David Holm <dholm@telia.com>
arpi
parents:
diff changeset
398 return -1;
9d8d69fc517c ao_dxr3 by David Holm <dholm@telia.com>
arpi
parents:
diff changeset
399 }
9d8d69fc517c ao_dxr3 by David Holm <dholm@telia.com>
arpi
parents:
diff changeset
400
9d8d69fc517c ao_dxr3 by David Holm <dholm@telia.com>
arpi
parents:
diff changeset
401
9d8d69fc517c ao_dxr3 by David Holm <dholm@telia.com>
arpi
parents:
diff changeset
402 static uint32_t
9d8d69fc517c ao_dxr3 by David Holm <dholm@telia.com>
arpi
parents:
diff changeset
403 query_format(uint32_t format)
9d8d69fc517c ao_dxr3 by David Holm <dholm@telia.com>
arpi
parents:
diff changeset
404 {
3828
063e5b0065a4 Brand new sync core, uses hw sync for everything.
mswitch
parents: 3759
diff changeset
405 if(format==IMGFMT_MPEGPES) return 0x2|0x4|256;
3432
5cb7caab5536 MP1E configure patch by D. Holm.
atmos4
parents: 3387
diff changeset
406 #ifdef USE_MP1E
3828
063e5b0065a4 Brand new sync core, uses hw sync for everything.
mswitch
parents: 3759
diff changeset
407 if(format==IMGFMT_YV12) return 0x1|0x4|256;
063e5b0065a4 Brand new sync core, uses hw sync for everything.
mswitch
parents: 3759
diff changeset
408 if(format==IMGFMT_YUY2) return 0x1|0x4|256;
063e5b0065a4 Brand new sync core, uses hw sync for everything.
mswitch
parents: 3759
diff changeset
409 if(format==IMGFMT_BGR24) return 0x1|0x4|256;
3374
c49a9b272c44 fixed typo
alex
parents: 3333
diff changeset
410 else printf( "VO: [dxr3] Format unsupported, mail dholm@iname.com\n" );
3432
5cb7caab5536 MP1E configure patch by D. Holm.
atmos4
parents: 3387
diff changeset
411 #else
5cb7caab5536 MP1E configure patch by D. Holm.
atmos4
parents: 3387
diff changeset
412 else printf( "VO: [dxr3] You have disabled libmp1e support, you won't be able to play this format!\n" );
5cb7caab5536 MP1E configure patch by D. Holm.
atmos4
parents: 3387
diff changeset
413 #endif
2645
9d8d69fc517c ao_dxr3 by David Holm <dholm@telia.com>
arpi
parents:
diff changeset
414 return 0;
9d8d69fc517c ao_dxr3 by David Holm <dholm@telia.com>
arpi
parents:
diff changeset
415 }
9d8d69fc517c ao_dxr3 by David Holm <dholm@telia.com>
arpi
parents:
diff changeset
416
3208
98a587aaf505 Support for YV12 with DXR3, patch by D. Holm.
atmos4
parents: 3201
diff changeset
417 static void uninit(void)
2645
9d8d69fc517c ao_dxr3 by David Holm <dholm@telia.com>
arpi
parents:
diff changeset
418 {
2968
9989497ab31e Minor fixes by David.
atmos4
parents: 2921
diff changeset
419 printf( "VO: [dxr3] Uninitializing\n" );
3201
039a973b3dda Newest DXR3 patch (improved 1.0rc2) by David Holm.
atmos4
parents: 3186
diff changeset
420 if( picture_data[0] ) free(picture_data[0]);
039a973b3dda Newest DXR3 patch (improved 1.0rc2) by David Holm.
atmos4
parents: 3186
diff changeset
421 if( fd_video ) close(fd_video);
039a973b3dda Newest DXR3 patch (improved 1.0rc2) by David Holm.
atmos4
parents: 3186
diff changeset
422 if( fd_spu ) close(fd_spu);
2645
9d8d69fc517c ao_dxr3 by David Holm <dholm@telia.com>
arpi
parents:
diff changeset
423 }
9d8d69fc517c ao_dxr3 by David Holm <dholm@telia.com>
arpi
parents:
diff changeset
424
9d8d69fc517c ao_dxr3 by David Holm <dholm@telia.com>
arpi
parents:
diff changeset
425
9d8d69fc517c ao_dxr3 by David Holm <dholm@telia.com>
arpi
parents:
diff changeset
426 static void check_events(void)
9d8d69fc517c ao_dxr3 by David Holm <dholm@telia.com>
arpi
parents:
diff changeset
427 {
9d8d69fc517c ao_dxr3 by David Holm <dholm@telia.com>
arpi
parents:
diff changeset
428 }
9d8d69fc517c ao_dxr3 by David Holm <dholm@telia.com>
arpi
parents:
diff changeset
429