Mercurial > mplayer.hg
annotate libmpcodecs/vf_expand.c @ 22433:d4faccf8bcd7
Remove hack that sets demuxer->video->pts after seeking, it seems no longer needed.
author | reimar |
---|---|
date | Sun, 04 Mar 2007 15:13:38 +0000 |
parents | 0b262e00bc99 |
children | aeffa880c7d6 |
rev | line source |
---|---|
5669
391931fa79a6
enabled new OSD code in -vop expand, subtitles rendering support to mencoder
arpi
parents:
5644
diff
changeset
|
1 #define OSD_SUPPORT |
5644
f1465a280612
(buggy) osd support, disabled for now, mencoder needs fixes to compile
arpi
parents:
5607
diff
changeset
|
2 |
5507
d0d029fda134
video filter layer - written from scratch, but inspired a lot by Fredrik Kuivinen's patch
arpi
parents:
diff
changeset
|
3 #include <stdio.h> |
d0d029fda134
video filter layer - written from scratch, but inspired a lot by Fredrik Kuivinen's patch
arpi
parents:
diff
changeset
|
4 #include <stdlib.h> |
d0d029fda134
video filter layer - written from scratch, but inspired a lot by Fredrik Kuivinen's patch
arpi
parents:
diff
changeset
|
5 #include <string.h> |
d0d029fda134
video filter layer - written from scratch, but inspired a lot by Fredrik Kuivinen's patch
arpi
parents:
diff
changeset
|
6 |
17012 | 7 #include "config.h" |
8 #include "mp_msg.h" | |
18004
bcd805923554
Part2 of several printf2mp_msg changes in patch from Otvos Attila oattila AT chello DOT hu with LOTS of modifications by me
reynaldo
parents:
17906
diff
changeset
|
9 #include "help_mp.h" |
5507
d0d029fda134
video filter layer - written from scratch, but inspired a lot by Fredrik Kuivinen's patch
arpi
parents:
diff
changeset
|
10 |
5644
f1465a280612
(buggy) osd support, disabled for now, mencoder needs fixes to compile
arpi
parents:
5607
diff
changeset
|
11 #include "img_format.h" |
5607 | 12 #include "mp_image.h" |
5507
d0d029fda134
video filter layer - written from scratch, but inspired a lot by Fredrik Kuivinen's patch
arpi
parents:
diff
changeset
|
13 #include "vf.h" |
d0d029fda134
video filter layer - written from scratch, but inspired a lot by Fredrik Kuivinen's patch
arpi
parents:
diff
changeset
|
14 |
17012 | 15 #include "libvo/fastmemcpy.h" |
5507
d0d029fda134
video filter layer - written from scratch, but inspired a lot by Fredrik Kuivinen's patch
arpi
parents:
diff
changeset
|
16 |
5644
f1465a280612
(buggy) osd support, disabled for now, mencoder needs fixes to compile
arpi
parents:
5607
diff
changeset
|
17 #ifdef OSD_SUPPORT |
17012 | 18 #include "libvo/sub.h" |
19 #include "libvo/osd.h" | |
5644
f1465a280612
(buggy) osd support, disabled for now, mencoder needs fixes to compile
arpi
parents:
5607
diff
changeset
|
20 #endif |
f1465a280612
(buggy) osd support, disabled for now, mencoder needs fixes to compile
arpi
parents:
5607
diff
changeset
|
21 |
9594 | 22 #include "m_option.h" |
23 #include "m_struct.h" | |
24 | |
7052
f3b2f31332fc
allocating large enough buffer, fixes green stuff on top for encoding of height %16 != 0 videos
michael
parents:
6761
diff
changeset
|
25 #define MAX(a,b) ((a) > (b) ? (a) : (b)) |
f3b2f31332fc
allocating large enough buffer, fixes green stuff on top for encoding of height %16 != 0 videos
michael
parents:
6761
diff
changeset
|
26 |
9594 | 27 static struct vf_priv_s { |
5507
d0d029fda134
video filter layer - written from scratch, but inspired a lot by Fredrik Kuivinen's patch
arpi
parents:
diff
changeset
|
28 int exp_w,exp_h; |
d0d029fda134
video filter layer - written from scratch, but inspired a lot by Fredrik Kuivinen's patch
arpi
parents:
diff
changeset
|
29 int exp_x,exp_y; |
5644
f1465a280612
(buggy) osd support, disabled for now, mencoder needs fixes to compile
arpi
parents:
5607
diff
changeset
|
30 int osd; |
15939 | 31 double aspect; |
32 int round; | |
5669
391931fa79a6
enabled new OSD code in -vop expand, subtitles rendering support to mencoder
arpi
parents:
5644
diff
changeset
|
33 unsigned char* fb_ptr; |
21803
3acc4b00bcc6
allows OSD menu to be displayed when using MPEG PES video out
ben
parents:
20561
diff
changeset
|
34 int passthrough; |
15252 | 35 int first_slice; |
22027 | 36 } const vf_priv_dflt = { |
9594 | 37 -1,-1, |
38 -1,-1, | |
39 0, | |
15939 | 40 0., |
41 1, | |
15252 | 42 NULL, |
21803
3acc4b00bcc6
allows OSD menu to be displayed when using MPEG PES video out
ben
parents:
20561
diff
changeset
|
43 0, |
15252 | 44 0 |
5507
d0d029fda134
video filter layer - written from scratch, but inspired a lot by Fredrik Kuivinen's patch
arpi
parents:
diff
changeset
|
45 }; |
d0d029fda134
video filter layer - written from scratch, but inspired a lot by Fredrik Kuivinen's patch
arpi
parents:
diff
changeset
|
46 |
6060 | 47 extern int opt_screen_size_x; |
48 extern int opt_screen_size_y; | |
49 | |
5507
d0d029fda134
video filter layer - written from scratch, but inspired a lot by Fredrik Kuivinen's patch
arpi
parents:
diff
changeset
|
50 //===========================================================================// |
5644
f1465a280612
(buggy) osd support, disabled for now, mencoder needs fixes to compile
arpi
parents:
5607
diff
changeset
|
51 #ifdef OSD_SUPPORT |
f1465a280612
(buggy) osd support, disabled for now, mencoder needs fixes to compile
arpi
parents:
5607
diff
changeset
|
52 |
f1465a280612
(buggy) osd support, disabled for now, mencoder needs fixes to compile
arpi
parents:
5607
diff
changeset
|
53 static struct vf_instance_s* vf=NULL; // fixme (needs sub.c changes) |
f1465a280612
(buggy) osd support, disabled for now, mencoder needs fixes to compile
arpi
parents:
5607
diff
changeset
|
54 static int orig_w,orig_h; |
f1465a280612
(buggy) osd support, disabled for now, mencoder needs fixes to compile
arpi
parents:
5607
diff
changeset
|
55 |
f1465a280612
(buggy) osd support, disabled for now, mencoder needs fixes to compile
arpi
parents:
5607
diff
changeset
|
56 static void remove_func_2(int x0,int y0, int w,int h){ |
f1465a280612
(buggy) osd support, disabled for now, mencoder needs fixes to compile
arpi
parents:
5607
diff
changeset
|
57 // TODO: let's cleanup the place |
5669
391931fa79a6
enabled new OSD code in -vop expand, subtitles rendering support to mencoder
arpi
parents:
5644
diff
changeset
|
58 //printf("OSD clear: %d;%d %dx%d \n",x0,y0,w,h); |
10140
30cad6ad9dbc
fix segfaults with slices. support slice rendering into a filter even
rfelker
parents:
9603
diff
changeset
|
59 vf_mpi_clear(vf->dmpi,x0,y0,w,h); |
5644
f1465a280612
(buggy) osd support, disabled for now, mencoder needs fixes to compile
arpi
parents:
5607
diff
changeset
|
60 } |
f1465a280612
(buggy) osd support, disabled for now, mencoder needs fixes to compile
arpi
parents:
5607
diff
changeset
|
61 |
f1465a280612
(buggy) osd support, disabled for now, mencoder needs fixes to compile
arpi
parents:
5607
diff
changeset
|
62 static void remove_func(int x0,int y0, int w,int h){ |
f1465a280612
(buggy) osd support, disabled for now, mencoder needs fixes to compile
arpi
parents:
5607
diff
changeset
|
63 if(!vo_osd_changed_flag) return; |
f1465a280612
(buggy) osd support, disabled for now, mencoder needs fixes to compile
arpi
parents:
5607
diff
changeset
|
64 // split it to 4 parts: |
f1465a280612
(buggy) osd support, disabled for now, mencoder needs fixes to compile
arpi
parents:
5607
diff
changeset
|
65 if(y0<vf->priv->exp_y){ |
f1465a280612
(buggy) osd support, disabled for now, mencoder needs fixes to compile
arpi
parents:
5607
diff
changeset
|
66 // it has parts above the image: |
f1465a280612
(buggy) osd support, disabled for now, mencoder needs fixes to compile
arpi
parents:
5607
diff
changeset
|
67 int y=y0+h; |
f1465a280612
(buggy) osd support, disabled for now, mencoder needs fixes to compile
arpi
parents:
5607
diff
changeset
|
68 if(y>vf->priv->exp_y) y=vf->priv->exp_y; |
f1465a280612
(buggy) osd support, disabled for now, mencoder needs fixes to compile
arpi
parents:
5607
diff
changeset
|
69 remove_func_2(x0,y0,w,y-y0); |
f1465a280612
(buggy) osd support, disabled for now, mencoder needs fixes to compile
arpi
parents:
5607
diff
changeset
|
70 if(y0+h<=vf->priv->exp_y) return; |
f1465a280612
(buggy) osd support, disabled for now, mencoder needs fixes to compile
arpi
parents:
5607
diff
changeset
|
71 h-=y-y0;y0=y; |
f1465a280612
(buggy) osd support, disabled for now, mencoder needs fixes to compile
arpi
parents:
5607
diff
changeset
|
72 } |
f1465a280612
(buggy) osd support, disabled for now, mencoder needs fixes to compile
arpi
parents:
5607
diff
changeset
|
73 if(y0+h>vf->priv->exp_y+orig_h){ |
f1465a280612
(buggy) osd support, disabled for now, mencoder needs fixes to compile
arpi
parents:
5607
diff
changeset
|
74 // it has parts under the image: |
f1465a280612
(buggy) osd support, disabled for now, mencoder needs fixes to compile
arpi
parents:
5607
diff
changeset
|
75 int y=y0; |
f1465a280612
(buggy) osd support, disabled for now, mencoder needs fixes to compile
arpi
parents:
5607
diff
changeset
|
76 if(y<vf->priv->exp_y+orig_h) y=vf->priv->exp_y+orig_h; |
f1465a280612
(buggy) osd support, disabled for now, mencoder needs fixes to compile
arpi
parents:
5607
diff
changeset
|
77 remove_func_2(x0,y,w,y0+h-y); |
f1465a280612
(buggy) osd support, disabled for now, mencoder needs fixes to compile
arpi
parents:
5607
diff
changeset
|
78 if(y0>=vf->priv->exp_y+orig_h) return; |
f1465a280612
(buggy) osd support, disabled for now, mencoder needs fixes to compile
arpi
parents:
5607
diff
changeset
|
79 h=y-y0; |
f1465a280612
(buggy) osd support, disabled for now, mencoder needs fixes to compile
arpi
parents:
5607
diff
changeset
|
80 } |
f1465a280612
(buggy) osd support, disabled for now, mencoder needs fixes to compile
arpi
parents:
5607
diff
changeset
|
81 if(x0>=vf->priv->exp_x || x0+w<=vf->priv->exp_x+orig_w) return; |
f1465a280612
(buggy) osd support, disabled for now, mencoder needs fixes to compile
arpi
parents:
5607
diff
changeset
|
82 // TODO clear left and right side of the image if needed |
f1465a280612
(buggy) osd support, disabled for now, mencoder needs fixes to compile
arpi
parents:
5607
diff
changeset
|
83 } |
f1465a280612
(buggy) osd support, disabled for now, mencoder needs fixes to compile
arpi
parents:
5607
diff
changeset
|
84 |
f1465a280612
(buggy) osd support, disabled for now, mencoder needs fixes to compile
arpi
parents:
5607
diff
changeset
|
85 static void draw_func(int x0,int y0, int w,int h,unsigned char* src, unsigned char *srca, int stride){ |
5669
391931fa79a6
enabled new OSD code in -vop expand, subtitles rendering support to mencoder
arpi
parents:
5644
diff
changeset
|
86 unsigned char* dst; |
10140
30cad6ad9dbc
fix segfaults with slices. support slice rendering into a filter even
rfelker
parents:
9603
diff
changeset
|
87 if(!vo_osd_changed_flag && vf->dmpi->planes[0]==vf->priv->fb_ptr){ |
5669
391931fa79a6
enabled new OSD code in -vop expand, subtitles rendering support to mencoder
arpi
parents:
5644
diff
changeset
|
88 // ok, enough to update the area inside the video, leave the black bands |
391931fa79a6
enabled new OSD code in -vop expand, subtitles rendering support to mencoder
arpi
parents:
5644
diff
changeset
|
89 // untouched! |
391931fa79a6
enabled new OSD code in -vop expand, subtitles rendering support to mencoder
arpi
parents:
5644
diff
changeset
|
90 if(x0<vf->priv->exp_x){ |
391931fa79a6
enabled new OSD code in -vop expand, subtitles rendering support to mencoder
arpi
parents:
5644
diff
changeset
|
91 int tmp=vf->priv->exp_x-x0; |
391931fa79a6
enabled new OSD code in -vop expand, subtitles rendering support to mencoder
arpi
parents:
5644
diff
changeset
|
92 w-=tmp; src+=tmp; srca+=tmp; x0+=tmp; |
391931fa79a6
enabled new OSD code in -vop expand, subtitles rendering support to mencoder
arpi
parents:
5644
diff
changeset
|
93 } |
391931fa79a6
enabled new OSD code in -vop expand, subtitles rendering support to mencoder
arpi
parents:
5644
diff
changeset
|
94 if(y0<vf->priv->exp_y){ |
391931fa79a6
enabled new OSD code in -vop expand, subtitles rendering support to mencoder
arpi
parents:
5644
diff
changeset
|
95 int tmp=vf->priv->exp_y-y0; |
391931fa79a6
enabled new OSD code in -vop expand, subtitles rendering support to mencoder
arpi
parents:
5644
diff
changeset
|
96 h-=tmp; src+=tmp*stride; srca+=tmp*stride; y0+=tmp; |
391931fa79a6
enabled new OSD code in -vop expand, subtitles rendering support to mencoder
arpi
parents:
5644
diff
changeset
|
97 } |
391931fa79a6
enabled new OSD code in -vop expand, subtitles rendering support to mencoder
arpi
parents:
5644
diff
changeset
|
98 if(x0+w>vf->priv->exp_x+orig_w){ |
391931fa79a6
enabled new OSD code in -vop expand, subtitles rendering support to mencoder
arpi
parents:
5644
diff
changeset
|
99 w=vf->priv->exp_x+orig_w-x0; |
391931fa79a6
enabled new OSD code in -vop expand, subtitles rendering support to mencoder
arpi
parents:
5644
diff
changeset
|
100 } |
391931fa79a6
enabled new OSD code in -vop expand, subtitles rendering support to mencoder
arpi
parents:
5644
diff
changeset
|
101 if(y0+h>vf->priv->exp_y+orig_h){ |
391931fa79a6
enabled new OSD code in -vop expand, subtitles rendering support to mencoder
arpi
parents:
5644
diff
changeset
|
102 h=vf->priv->exp_y+orig_h-y0; |
391931fa79a6
enabled new OSD code in -vop expand, subtitles rendering support to mencoder
arpi
parents:
5644
diff
changeset
|
103 } |
391931fa79a6
enabled new OSD code in -vop expand, subtitles rendering support to mencoder
arpi
parents:
5644
diff
changeset
|
104 } |
391931fa79a6
enabled new OSD code in -vop expand, subtitles rendering support to mencoder
arpi
parents:
5644
diff
changeset
|
105 if(w<=0 || h<=0) return; // nothing to do... |
391931fa79a6
enabled new OSD code in -vop expand, subtitles rendering support to mencoder
arpi
parents:
5644
diff
changeset
|
106 // printf("OSD redraw: %d;%d %dx%d \n",x0,y0,w,h); |
10140
30cad6ad9dbc
fix segfaults with slices. support slice rendering into a filter even
rfelker
parents:
9603
diff
changeset
|
107 dst=vf->dmpi->planes[0]+ |
30cad6ad9dbc
fix segfaults with slices. support slice rendering into a filter even
rfelker
parents:
9603
diff
changeset
|
108 vf->dmpi->stride[0]*y0+ |
30cad6ad9dbc
fix segfaults with slices. support slice rendering into a filter even
rfelker
parents:
9603
diff
changeset
|
109 (vf->dmpi->bpp>>3)*x0; |
30cad6ad9dbc
fix segfaults with slices. support slice rendering into a filter even
rfelker
parents:
9603
diff
changeset
|
110 switch(vf->dmpi->imgfmt){ |
5644
f1465a280612
(buggy) osd support, disabled for now, mencoder needs fixes to compile
arpi
parents:
5607
diff
changeset
|
111 case IMGFMT_BGR15: |
f1465a280612
(buggy) osd support, disabled for now, mencoder needs fixes to compile
arpi
parents:
5607
diff
changeset
|
112 case IMGFMT_RGB15: |
10140
30cad6ad9dbc
fix segfaults with slices. support slice rendering into a filter even
rfelker
parents:
9603
diff
changeset
|
113 vo_draw_alpha_rgb15(w,h,src,srca,stride,dst,vf->dmpi->stride[0]); |
5644
f1465a280612
(buggy) osd support, disabled for now, mencoder needs fixes to compile
arpi
parents:
5607
diff
changeset
|
114 break; |
f1465a280612
(buggy) osd support, disabled for now, mencoder needs fixes to compile
arpi
parents:
5607
diff
changeset
|
115 case IMGFMT_BGR16: |
f1465a280612
(buggy) osd support, disabled for now, mencoder needs fixes to compile
arpi
parents:
5607
diff
changeset
|
116 case IMGFMT_RGB16: |
10140
30cad6ad9dbc
fix segfaults with slices. support slice rendering into a filter even
rfelker
parents:
9603
diff
changeset
|
117 vo_draw_alpha_rgb16(w,h,src,srca,stride,dst,vf->dmpi->stride[0]); |
5644
f1465a280612
(buggy) osd support, disabled for now, mencoder needs fixes to compile
arpi
parents:
5607
diff
changeset
|
118 break; |
f1465a280612
(buggy) osd support, disabled for now, mencoder needs fixes to compile
arpi
parents:
5607
diff
changeset
|
119 case IMGFMT_BGR24: |
f1465a280612
(buggy) osd support, disabled for now, mencoder needs fixes to compile
arpi
parents:
5607
diff
changeset
|
120 case IMGFMT_RGB24: |
10140
30cad6ad9dbc
fix segfaults with slices. support slice rendering into a filter even
rfelker
parents:
9603
diff
changeset
|
121 vo_draw_alpha_rgb24(w,h,src,srca,stride,dst,vf->dmpi->stride[0]); |
5644
f1465a280612
(buggy) osd support, disabled for now, mencoder needs fixes to compile
arpi
parents:
5607
diff
changeset
|
122 break; |
f1465a280612
(buggy) osd support, disabled for now, mencoder needs fixes to compile
arpi
parents:
5607
diff
changeset
|
123 case IMGFMT_BGR32: |
f1465a280612
(buggy) osd support, disabled for now, mencoder needs fixes to compile
arpi
parents:
5607
diff
changeset
|
124 case IMGFMT_RGB32: |
10140
30cad6ad9dbc
fix segfaults with slices. support slice rendering into a filter even
rfelker
parents:
9603
diff
changeset
|
125 vo_draw_alpha_rgb32(w,h,src,srca,stride,dst,vf->dmpi->stride[0]); |
5644
f1465a280612
(buggy) osd support, disabled for now, mencoder needs fixes to compile
arpi
parents:
5607
diff
changeset
|
126 break; |
f1465a280612
(buggy) osd support, disabled for now, mencoder needs fixes to compile
arpi
parents:
5607
diff
changeset
|
127 case IMGFMT_YV12: |
f1465a280612
(buggy) osd support, disabled for now, mencoder needs fixes to compile
arpi
parents:
5607
diff
changeset
|
128 case IMGFMT_I420: |
f1465a280612
(buggy) osd support, disabled for now, mencoder needs fixes to compile
arpi
parents:
5607
diff
changeset
|
129 case IMGFMT_IYUV: |
6537
ae203145245e
yv12 osd drawer is working for y8/y800/yvu9/if09 becouse it uses only Y-plane and Y-plane is the same for all these formats
alex
parents:
6525
diff
changeset
|
130 case IMGFMT_YVU9: |
ae203145245e
yv12 osd drawer is working for y8/y800/yvu9/if09 becouse it uses only Y-plane and Y-plane is the same for all these formats
alex
parents:
6525
diff
changeset
|
131 case IMGFMT_IF09: |
ae203145245e
yv12 osd drawer is working for y8/y800/yvu9/if09 becouse it uses only Y-plane and Y-plane is the same for all these formats
alex
parents:
6525
diff
changeset
|
132 case IMGFMT_Y800: |
ae203145245e
yv12 osd drawer is working for y8/y800/yvu9/if09 becouse it uses only Y-plane and Y-plane is the same for all these formats
alex
parents:
6525
diff
changeset
|
133 case IMGFMT_Y8: |
10140
30cad6ad9dbc
fix segfaults with slices. support slice rendering into a filter even
rfelker
parents:
9603
diff
changeset
|
134 vo_draw_alpha_yv12(w,h,src,srca,stride,dst,vf->dmpi->stride[0]); |
5644
f1465a280612
(buggy) osd support, disabled for now, mencoder needs fixes to compile
arpi
parents:
5607
diff
changeset
|
135 break; |
f1465a280612
(buggy) osd support, disabled for now, mencoder needs fixes to compile
arpi
parents:
5607
diff
changeset
|
136 case IMGFMT_YUY2: |
10140
30cad6ad9dbc
fix segfaults with slices. support slice rendering into a filter even
rfelker
parents:
9603
diff
changeset
|
137 vo_draw_alpha_yuy2(w,h,src,srca,stride,dst,vf->dmpi->stride[0]); |
5644
f1465a280612
(buggy) osd support, disabled for now, mencoder needs fixes to compile
arpi
parents:
5607
diff
changeset
|
138 break; |
f1465a280612
(buggy) osd support, disabled for now, mencoder needs fixes to compile
arpi
parents:
5607
diff
changeset
|
139 case IMGFMT_UYVY: |
10140
30cad6ad9dbc
fix segfaults with slices. support slice rendering into a filter even
rfelker
parents:
9603
diff
changeset
|
140 vo_draw_alpha_yuy2(w,h,src,srca,stride,dst+1,vf->dmpi->stride[0]); |
5644
f1465a280612
(buggy) osd support, disabled for now, mencoder needs fixes to compile
arpi
parents:
5607
diff
changeset
|
141 break; |
f1465a280612
(buggy) osd support, disabled for now, mencoder needs fixes to compile
arpi
parents:
5607
diff
changeset
|
142 } |
f1465a280612
(buggy) osd support, disabled for now, mencoder needs fixes to compile
arpi
parents:
5607
diff
changeset
|
143 } |
f1465a280612
(buggy) osd support, disabled for now, mencoder needs fixes to compile
arpi
parents:
5607
diff
changeset
|
144 |
f1465a280612
(buggy) osd support, disabled for now, mencoder needs fixes to compile
arpi
parents:
5607
diff
changeset
|
145 static void draw_osd(struct vf_instance_s* vf_,int w,int h){ |
f1465a280612
(buggy) osd support, disabled for now, mencoder needs fixes to compile
arpi
parents:
5607
diff
changeset
|
146 vf=vf_;orig_w=w;orig_h=h; |
5669
391931fa79a6
enabled new OSD code in -vop expand, subtitles rendering support to mencoder
arpi
parents:
5644
diff
changeset
|
147 // printf("======================================\n"); |
5644
f1465a280612
(buggy) osd support, disabled for now, mencoder needs fixes to compile
arpi
parents:
5607
diff
changeset
|
148 if(vf->priv->exp_w!=w || vf->priv->exp_h!=h || |
5669
391931fa79a6
enabled new OSD code in -vop expand, subtitles rendering support to mencoder
arpi
parents:
5644
diff
changeset
|
149 vf->priv->exp_x || vf->priv->exp_y){ |
391931fa79a6
enabled new OSD code in -vop expand, subtitles rendering support to mencoder
arpi
parents:
5644
diff
changeset
|
150 // yep, we're expanding image, not just copy. |
10140
30cad6ad9dbc
fix segfaults with slices. support slice rendering into a filter even
rfelker
parents:
9603
diff
changeset
|
151 if(vf->dmpi->planes[0]!=vf->priv->fb_ptr){ |
5669
391931fa79a6
enabled new OSD code in -vop expand, subtitles rendering support to mencoder
arpi
parents:
5644
diff
changeset
|
152 // double buffering, so we need full clear :( |
15099 | 153 if (vf->priv->exp_y > 0) |
154 remove_func_2(0,0,vf->priv->exp_w,vf->priv->exp_y); | |
155 if (vf->priv->exp_y+h < vf->priv->exp_h) | |
156 remove_func_2(0,vf->priv->exp_y+h,vf->priv->exp_w,vf->priv->exp_h-h-vf->priv->exp_y); | |
5669
391931fa79a6
enabled new OSD code in -vop expand, subtitles rendering support to mencoder
arpi
parents:
5644
diff
changeset
|
157 } else { |
391931fa79a6
enabled new OSD code in -vop expand, subtitles rendering support to mencoder
arpi
parents:
5644
diff
changeset
|
158 // partial clear: |
391931fa79a6
enabled new OSD code in -vop expand, subtitles rendering support to mencoder
arpi
parents:
5644
diff
changeset
|
159 vo_remove_text(vf->priv->exp_w,vf->priv->exp_h,remove_func); |
391931fa79a6
enabled new OSD code in -vop expand, subtitles rendering support to mencoder
arpi
parents:
5644
diff
changeset
|
160 } |
5644
f1465a280612
(buggy) osd support, disabled for now, mencoder needs fixes to compile
arpi
parents:
5607
diff
changeset
|
161 } |
f1465a280612
(buggy) osd support, disabled for now, mencoder needs fixes to compile
arpi
parents:
5607
diff
changeset
|
162 vo_draw_text(vf->priv->exp_w,vf->priv->exp_h,draw_func); |
5669
391931fa79a6
enabled new OSD code in -vop expand, subtitles rendering support to mencoder
arpi
parents:
5644
diff
changeset
|
163 // save buffer pointer for double buffering detection - yes, i know it's |
391931fa79a6
enabled new OSD code in -vop expand, subtitles rendering support to mencoder
arpi
parents:
5644
diff
changeset
|
164 // ugly method, but note that codecs with DR support does the same... |
10140
30cad6ad9dbc
fix segfaults with slices. support slice rendering into a filter even
rfelker
parents:
9603
diff
changeset
|
165 if(vf->dmpi) |
30cad6ad9dbc
fix segfaults with slices. support slice rendering into a filter even
rfelker
parents:
9603
diff
changeset
|
166 vf->priv->fb_ptr=vf->dmpi->planes[0]; |
5644
f1465a280612
(buggy) osd support, disabled for now, mencoder needs fixes to compile
arpi
parents:
5607
diff
changeset
|
167 } |
f1465a280612
(buggy) osd support, disabled for now, mencoder needs fixes to compile
arpi
parents:
5607
diff
changeset
|
168 |
f1465a280612
(buggy) osd support, disabled for now, mencoder needs fixes to compile
arpi
parents:
5607
diff
changeset
|
169 #endif |
f1465a280612
(buggy) osd support, disabled for now, mencoder needs fixes to compile
arpi
parents:
5607
diff
changeset
|
170 //===========================================================================// |
5507
d0d029fda134
video filter layer - written from scratch, but inspired a lot by Fredrik Kuivinen's patch
arpi
parents:
diff
changeset
|
171 |
d0d029fda134
video filter layer - written from scratch, but inspired a lot by Fredrik Kuivinen's patch
arpi
parents:
diff
changeset
|
172 static int config(struct vf_instance_s* vf, |
d0d029fda134
video filter layer - written from scratch, but inspired a lot by Fredrik Kuivinen's patch
arpi
parents:
diff
changeset
|
173 int width, int height, int d_width, int d_height, |
d0d029fda134
video filter layer - written from scratch, but inspired a lot by Fredrik Kuivinen's patch
arpi
parents:
diff
changeset
|
174 unsigned int flags, unsigned int outfmt){ |
21803
3acc4b00bcc6
allows OSD menu to be displayed when using MPEG PES video out
ben
parents:
20561
diff
changeset
|
175 if(outfmt == IMGFMT_MPEGPES) { |
3acc4b00bcc6
allows OSD menu to be displayed when using MPEG PES video out
ben
parents:
20561
diff
changeset
|
176 vf->priv->passthrough = 1; |
3acc4b00bcc6
allows OSD menu to be displayed when using MPEG PES video out
ben
parents:
20561
diff
changeset
|
177 return vf_next_config(vf,width,height,d_width,d_height,flags,outfmt); |
3acc4b00bcc6
allows OSD menu to be displayed when using MPEG PES video out
ben
parents:
20561
diff
changeset
|
178 } |
6525 | 179 if (outfmt == IMGFMT_IF09) return 0; |
5507
d0d029fda134
video filter layer - written from scratch, but inspired a lot by Fredrik Kuivinen's patch
arpi
parents:
diff
changeset
|
180 // calculate the missing parameters: |
5921 | 181 #if 0 |
5507
d0d029fda134
video filter layer - written from scratch, but inspired a lot by Fredrik Kuivinen's patch
arpi
parents:
diff
changeset
|
182 if(vf->priv->exp_w<width) vf->priv->exp_w=width; |
d0d029fda134
video filter layer - written from scratch, but inspired a lot by Fredrik Kuivinen's patch
arpi
parents:
diff
changeset
|
183 if(vf->priv->exp_h<height) vf->priv->exp_h=height; |
5921 | 184 #else |
185 if ( vf->priv->exp_w == -1 ) vf->priv->exp_w=width; | |
186 else if (vf->priv->exp_w < -1 ) vf->priv->exp_w=width - vf->priv->exp_w; | |
187 else if ( vf->priv->exp_w<width ) vf->priv->exp_w=width; | |
188 if ( vf->priv->exp_h == -1 ) vf->priv->exp_h=height; | |
189 else if ( vf->priv->exp_h < -1 ) vf->priv->exp_h=height - vf->priv->exp_h; | |
190 else if( vf->priv->exp_h<height ) vf->priv->exp_h=height; | |
191 #endif | |
15939 | 192 if (vf->priv->aspect) { |
20561
b7ed249cbc6e
Do not modify parsed command-line values on config,
reimar
parents:
18321
diff
changeset
|
193 float adjusted_aspect = vf->priv->aspect; |
b7ed249cbc6e
Do not modify parsed command-line values on config,
reimar
parents:
18321
diff
changeset
|
194 adjusted_aspect *= ((double)width/height) / ((double)d_width/d_height); |
b7ed249cbc6e
Do not modify parsed command-line values on config,
reimar
parents:
18321
diff
changeset
|
195 if (vf->priv->exp_h < vf->priv->exp_w / adjusted_aspect) { |
b7ed249cbc6e
Do not modify parsed command-line values on config,
reimar
parents:
18321
diff
changeset
|
196 vf->priv->exp_h = vf->priv->exp_w / adjusted_aspect + 0.5; |
15939 | 197 } else { |
20561
b7ed249cbc6e
Do not modify parsed command-line values on config,
reimar
parents:
18321
diff
changeset
|
198 vf->priv->exp_w = vf->priv->exp_h * adjusted_aspect + 0.5; |
15939 | 199 } |
200 } | |
15941 | 201 if (vf->priv->round > 1) { // round up. |
202 vf->priv->exp_w = (1 + (vf->priv->exp_w - 1) / vf->priv->round) * vf->priv->round; | |
15939 | 203 vf->priv->exp_h = (1 + (vf->priv->exp_h - 1) / vf->priv->round) * vf->priv->round; |
204 } | |
205 | |
5687 | 206 if(vf->priv->exp_x<0 || vf->priv->exp_x+width>vf->priv->exp_w) vf->priv->exp_x=(vf->priv->exp_w-width)/2; |
207 if(vf->priv->exp_y<0 || vf->priv->exp_y+height>vf->priv->exp_h) vf->priv->exp_y=(vf->priv->exp_h-height)/2; | |
5669
391931fa79a6
enabled new OSD code in -vop expand, subtitles rendering support to mencoder
arpi
parents:
5644
diff
changeset
|
208 vf->priv->fb_ptr=NULL; |
6060 | 209 |
210 if(!opt_screen_size_x && !opt_screen_size_y){ | |
211 d_width=d_width*vf->priv->exp_w/width; | |
212 d_height=d_height*vf->priv->exp_h/height; | |
213 } | |
214 return vf_next_config(vf,vf->priv->exp_w,vf->priv->exp_h,d_width,d_height,flags,outfmt); | |
5507
d0d029fda134
video filter layer - written from scratch, but inspired a lot by Fredrik Kuivinen's patch
arpi
parents:
diff
changeset
|
215 } |
d0d029fda134
video filter layer - written from scratch, but inspired a lot by Fredrik Kuivinen's patch
arpi
parents:
diff
changeset
|
216 |
d0d029fda134
video filter layer - written from scratch, but inspired a lot by Fredrik Kuivinen's patch
arpi
parents:
diff
changeset
|
217 // there are 4 cases: |
d0d029fda134
video filter layer - written from scratch, but inspired a lot by Fredrik Kuivinen's patch
arpi
parents:
diff
changeset
|
218 // codec --DR--> expand --DR--> vo |
d0d029fda134
video filter layer - written from scratch, but inspired a lot by Fredrik Kuivinen's patch
arpi
parents:
diff
changeset
|
219 // codec --DR--> expand -copy-> vo |
d0d029fda134
video filter layer - written from scratch, but inspired a lot by Fredrik Kuivinen's patch
arpi
parents:
diff
changeset
|
220 // codec -copy-> expand --DR--> vo |
d0d029fda134
video filter layer - written from scratch, but inspired a lot by Fredrik Kuivinen's patch
arpi
parents:
diff
changeset
|
221 // codec -copy-> expand -copy-> vo (worst case) |
d0d029fda134
video filter layer - written from scratch, but inspired a lot by Fredrik Kuivinen's patch
arpi
parents:
diff
changeset
|
222 |
d0d029fda134
video filter layer - written from scratch, but inspired a lot by Fredrik Kuivinen's patch
arpi
parents:
diff
changeset
|
223 static void get_image(struct vf_instance_s* vf, mp_image_t *mpi){ |
6761
cb1180ccac76
DR1+IPB support (works only with ffmpeg12, as libmpeg2 doesn't accept stride)
arpi
parents:
6539
diff
changeset
|
224 // if(mpi->type==MP_IMGTYPE_IPB) return; // not yet working |
5644
f1465a280612
(buggy) osd support, disabled for now, mencoder needs fixes to compile
arpi
parents:
5607
diff
changeset
|
225 #ifdef OSD_SUPPORT |
f1465a280612
(buggy) osd support, disabled for now, mencoder needs fixes to compile
arpi
parents:
5607
diff
changeset
|
226 if(vf->priv->osd && (mpi->flags&MP_IMGFLAG_PRESERVE)){ |
f1465a280612
(buggy) osd support, disabled for now, mencoder needs fixes to compile
arpi
parents:
5607
diff
changeset
|
227 // check if we have to render osd! |
f1465a280612
(buggy) osd support, disabled for now, mencoder needs fixes to compile
arpi
parents:
5607
diff
changeset
|
228 vo_update_osd(vf->priv->exp_w, vf->priv->exp_h); |
f1465a280612
(buggy) osd support, disabled for now, mencoder needs fixes to compile
arpi
parents:
5607
diff
changeset
|
229 if(vo_osd_check_range_update(vf->priv->exp_x,vf->priv->exp_y, |
f1465a280612
(buggy) osd support, disabled for now, mencoder needs fixes to compile
arpi
parents:
5607
diff
changeset
|
230 vf->priv->exp_x+mpi->w,vf->priv->exp_y+mpi->h)) return; |
f1465a280612
(buggy) osd support, disabled for now, mencoder needs fixes to compile
arpi
parents:
5607
diff
changeset
|
231 } |
f1465a280612
(buggy) osd support, disabled for now, mencoder needs fixes to compile
arpi
parents:
5607
diff
changeset
|
232 #endif |
5507
d0d029fda134
video filter layer - written from scratch, but inspired a lot by Fredrik Kuivinen's patch
arpi
parents:
diff
changeset
|
233 if(vf->priv->exp_w==mpi->width || |
d0d029fda134
video filter layer - written from scratch, but inspired a lot by Fredrik Kuivinen's patch
arpi
parents:
diff
changeset
|
234 (mpi->flags&(MP_IMGFLAG_ACCEPT_STRIDE|MP_IMGFLAG_ACCEPT_WIDTH)) ){ |
d0d029fda134
video filter layer - written from scratch, but inspired a lot by Fredrik Kuivinen's patch
arpi
parents:
diff
changeset
|
235 // try full DR ! |
10140
30cad6ad9dbc
fix segfaults with slices. support slice rendering into a filter even
rfelker
parents:
9603
diff
changeset
|
236 mpi->priv=vf->dmpi=vf_get_image(vf->next,mpi->imgfmt, |
7052
f3b2f31332fc
allocating large enough buffer, fixes green stuff on top for encoding of height %16 != 0 videos
michael
parents:
6761
diff
changeset
|
237 mpi->type, mpi->flags, |
f3b2f31332fc
allocating large enough buffer, fixes green stuff on top for encoding of height %16 != 0 videos
michael
parents:
6761
diff
changeset
|
238 MAX(vf->priv->exp_w, mpi->width +vf->priv->exp_x), |
f3b2f31332fc
allocating large enough buffer, fixes green stuff on top for encoding of height %16 != 0 videos
michael
parents:
6761
diff
changeset
|
239 MAX(vf->priv->exp_h, mpi->height+vf->priv->exp_y)); |
9495 | 240 #if 1 |
10140
30cad6ad9dbc
fix segfaults with slices. support slice rendering into a filter even
rfelker
parents:
9603
diff
changeset
|
241 if((vf->dmpi->flags & MP_IMGFLAG_DRAW_CALLBACK) && |
30cad6ad9dbc
fix segfaults with slices. support slice rendering into a filter even
rfelker
parents:
9603
diff
changeset
|
242 !(vf->dmpi->flags & MP_IMGFLAG_DIRECT)){ |
18004
bcd805923554
Part2 of several printf2mp_msg changes in patch from Otvos Attila oattila AT chello DOT hu with LOTS of modifications by me
reynaldo
parents:
17906
diff
changeset
|
243 mp_msg(MSGT_VFILTER, MSGL_INFO, MSGTR_MPCODECS_FullDRNotPossible); |
9495 | 244 return; |
245 } | |
246 #endif | |
5507
d0d029fda134
video filter layer - written from scratch, but inspired a lot by Fredrik Kuivinen's patch
arpi
parents:
diff
changeset
|
247 // set up mpi as a cropped-down image of dmpi: |
d0d029fda134
video filter layer - written from scratch, but inspired a lot by Fredrik Kuivinen's patch
arpi
parents:
diff
changeset
|
248 if(mpi->flags&MP_IMGFLAG_PLANAR){ |
10140
30cad6ad9dbc
fix segfaults with slices. support slice rendering into a filter even
rfelker
parents:
9603
diff
changeset
|
249 mpi->planes[0]=vf->dmpi->planes[0]+ |
30cad6ad9dbc
fix segfaults with slices. support slice rendering into a filter even
rfelker
parents:
9603
diff
changeset
|
250 vf->priv->exp_y*vf->dmpi->stride[0]+vf->priv->exp_x; |
30cad6ad9dbc
fix segfaults with slices. support slice rendering into a filter even
rfelker
parents:
9603
diff
changeset
|
251 mpi->planes[1]=vf->dmpi->planes[1]+ |
30cad6ad9dbc
fix segfaults with slices. support slice rendering into a filter even
rfelker
parents:
9603
diff
changeset
|
252 (vf->priv->exp_y>>mpi->chroma_y_shift)*vf->dmpi->stride[1]+(vf->priv->exp_x>>mpi->chroma_x_shift); |
30cad6ad9dbc
fix segfaults with slices. support slice rendering into a filter even
rfelker
parents:
9603
diff
changeset
|
253 mpi->planes[2]=vf->dmpi->planes[2]+ |
30cad6ad9dbc
fix segfaults with slices. support slice rendering into a filter even
rfelker
parents:
9603
diff
changeset
|
254 (vf->priv->exp_y>>mpi->chroma_y_shift)*vf->dmpi->stride[2]+(vf->priv->exp_x>>mpi->chroma_x_shift); |
30cad6ad9dbc
fix segfaults with slices. support slice rendering into a filter even
rfelker
parents:
9603
diff
changeset
|
255 mpi->stride[1]=vf->dmpi->stride[1]; |
30cad6ad9dbc
fix segfaults with slices. support slice rendering into a filter even
rfelker
parents:
9603
diff
changeset
|
256 mpi->stride[2]=vf->dmpi->stride[2]; |
5507
d0d029fda134
video filter layer - written from scratch, but inspired a lot by Fredrik Kuivinen's patch
arpi
parents:
diff
changeset
|
257 } else { |
10140
30cad6ad9dbc
fix segfaults with slices. support slice rendering into a filter even
rfelker
parents:
9603
diff
changeset
|
258 mpi->planes[0]=vf->dmpi->planes[0]+ |
30cad6ad9dbc
fix segfaults with slices. support slice rendering into a filter even
rfelker
parents:
9603
diff
changeset
|
259 vf->priv->exp_y*vf->dmpi->stride[0]+ |
30cad6ad9dbc
fix segfaults with slices. support slice rendering into a filter even
rfelker
parents:
9603
diff
changeset
|
260 vf->priv->exp_x*(vf->dmpi->bpp/8); |
5507
d0d029fda134
video filter layer - written from scratch, but inspired a lot by Fredrik Kuivinen's patch
arpi
parents:
diff
changeset
|
261 } |
10140
30cad6ad9dbc
fix segfaults with slices. support slice rendering into a filter even
rfelker
parents:
9603
diff
changeset
|
262 mpi->stride[0]=vf->dmpi->stride[0]; |
30cad6ad9dbc
fix segfaults with slices. support slice rendering into a filter even
rfelker
parents:
9603
diff
changeset
|
263 mpi->width=vf->dmpi->width; |
5507
d0d029fda134
video filter layer - written from scratch, but inspired a lot by Fredrik Kuivinen's patch
arpi
parents:
diff
changeset
|
264 mpi->flags|=MP_IMGFLAG_DIRECT; |
9495 | 265 mpi->flags&=~MP_IMGFLAG_DRAW_CALLBACK; |
10140
30cad6ad9dbc
fix segfaults with slices. support slice rendering into a filter even
rfelker
parents:
9603
diff
changeset
|
266 // vf->dmpi->flags&=~MP_IMGFLAG_DRAW_CALLBACK; |
5507
d0d029fda134
video filter layer - written from scratch, but inspired a lot by Fredrik Kuivinen's patch
arpi
parents:
diff
changeset
|
267 } |
d0d029fda134
video filter layer - written from scratch, but inspired a lot by Fredrik Kuivinen's patch
arpi
parents:
diff
changeset
|
268 } |
d0d029fda134
video filter layer - written from scratch, but inspired a lot by Fredrik Kuivinen's patch
arpi
parents:
diff
changeset
|
269 |
9495 | 270 static void start_slice(struct vf_instance_s* vf, mp_image_t *mpi){ |
271 // printf("start_slice called! flag=%d\n",mpi->flags&MP_IMGFLAG_DRAW_CALLBACK); | |
272 if(!vf->next->draw_slice){ | |
273 mpi->flags&=~MP_IMGFLAG_DRAW_CALLBACK; | |
274 return; | |
275 } | |
276 // they want slices!!! allocate the buffer. | |
277 if(!mpi->priv) | |
10140
30cad6ad9dbc
fix segfaults with slices. support slice rendering into a filter even
rfelker
parents:
9603
diff
changeset
|
278 mpi->priv=vf->dmpi=vf_get_image(vf->next,mpi->imgfmt, |
9495 | 279 // MP_IMGTYPE_TEMP, MP_IMGFLAG_ACCEPT_STRIDE | MP_IMGFLAG_PREFER_ALIGNED_STRIDE, |
15252 | 280 MP_IMGTYPE_TEMP, mpi->flags, |
9495 | 281 MAX(vf->priv->exp_w, mpi->width +vf->priv->exp_x), |
282 MAX(vf->priv->exp_h, mpi->height+vf->priv->exp_y)); | |
10140
30cad6ad9dbc
fix segfaults with slices. support slice rendering into a filter even
rfelker
parents:
9603
diff
changeset
|
283 if(!(vf->dmpi->flags&MP_IMGFLAG_DRAW_CALLBACK)) |
18004
bcd805923554
Part2 of several printf2mp_msg changes in patch from Otvos Attila oattila AT chello DOT hu with LOTS of modifications by me
reynaldo
parents:
17906
diff
changeset
|
284 mp_msg(MSGT_VFILTER, MSGL_WARN, MSGTR_MPCODECS_WarnNextFilterDoesntSupportSlices); // shouldn't happen. |
15252 | 285 vf->priv->first_slice = 1; |
9495 | 286 } |
287 | |
15252 | 288 static void draw_top_blackbar_slice(struct vf_instance_s* vf, |
289 unsigned char** src, int* stride, int w,int h, int x, int y){ | |
290 if(vf->priv->exp_y>0 && y == 0) { | |
14074
dc5eaa0795d7
call draw_slice in top-down order (fixes crash with -vf expand=...,scale)
henry
parents:
10311
diff
changeset
|
291 vf_next_draw_slice(vf, vf->dmpi->planes, vf->dmpi->stride, |
dc5eaa0795d7
call draw_slice in top-down order (fixes crash with -vf expand=...,scale)
henry
parents:
10311
diff
changeset
|
292 vf->dmpi->w,vf->priv->exp_y,0,0); |
15252 | 293 } |
294 | |
295 } | |
296 | |
297 static void draw_bottom_blackbar_slice(struct vf_instance_s* vf, | |
298 unsigned char** src, int* stride, int w,int h, int x, int y){ | |
15099 | 299 if(vf->priv->exp_y+vf->h<vf->dmpi->h && y+h == vf->h) { |
300 unsigned char *src2[MP_MAX_PLANES]; | |
301 src2[0] = vf->dmpi->planes[0] | |
302 + (vf->priv->exp_y+vf->h)*vf->dmpi->stride[0]; | |
303 if(vf->dmpi->flags&MP_IMGFLAG_PLANAR){ | |
304 src2[1] = vf->dmpi->planes[1] | |
305 + ((vf->priv->exp_y+vf->h)>>vf->dmpi->chroma_y_shift)*vf->dmpi->stride[1]; | |
306 src2[2] = vf->dmpi->planes[2] | |
307 + ((vf->priv->exp_y+vf->h)>>vf->dmpi->chroma_y_shift)*vf->dmpi->stride[2]; | |
308 } else { | |
309 src2[1] = vf->dmpi->planes[1]; // passthrough rgb8 palette | |
310 } | |
311 vf_next_draw_slice(vf, src2, vf->dmpi->stride, | |
14074
dc5eaa0795d7
call draw_slice in top-down order (fixes crash with -vf expand=...,scale)
henry
parents:
10311
diff
changeset
|
312 vf->dmpi->w,vf->dmpi->h-(vf->priv->exp_y+vf->h), |
dc5eaa0795d7
call draw_slice in top-down order (fixes crash with -vf expand=...,scale)
henry
parents:
10311
diff
changeset
|
313 0,vf->priv->exp_y+vf->h); |
15099 | 314 } |
9495 | 315 } |
316 | |
15252 | 317 static void draw_slice(struct vf_instance_s* vf, |
318 unsigned char** src, int* stride, int w,int h, int x, int y){ | |
319 // printf("draw_slice() called %d at %d\n",h,y); | |
320 | |
321 if (y == 0 && y+h == vf->h) { | |
322 // special case - only one slice | |
323 draw_top_blackbar_slice(vf, src, stride, w, h, x, y); | |
324 vf_next_draw_slice(vf,src,stride,w,h,x+vf->priv->exp_x,y+vf->priv->exp_y); | |
325 draw_bottom_blackbar_slice(vf, src, stride, w, h, x, y); | |
326 return; | |
327 } | |
328 if (vf->priv->first_slice) { | |
329 draw_top_blackbar_slice(vf, src, stride, w, h, x, y); | |
330 draw_bottom_blackbar_slice(vf, src, stride, w, h, x, y); | |
331 } | |
332 vf_next_draw_slice(vf,src,stride,w,h,x+vf->priv->exp_x,y+vf->priv->exp_y); | |
333 if (!vf->priv->first_slice) { | |
334 draw_top_blackbar_slice(vf, src, stride, w, h, x, y); | |
335 draw_bottom_blackbar_slice(vf, src, stride, w, h, x, y); | |
336 } | |
337 vf->priv->first_slice = 0; | |
338 } | |
339 | |
17906
20aca9baf5d8
passing pts through the filter layer (lets see if pts or cola comes out at the end)
michael
parents:
17102
diff
changeset
|
340 static int put_image(struct vf_instance_s* vf, mp_image_t *mpi, double pts){ |
21803
3acc4b00bcc6
allows OSD menu to be displayed when using MPEG PES video out
ben
parents:
20561
diff
changeset
|
341 if (vf->priv->passthrough) { |
3acc4b00bcc6
allows OSD menu to be displayed when using MPEG PES video out
ben
parents:
20561
diff
changeset
|
342 mp_image_t *dmpi = vf_get_image(vf->next, IMGFMT_MPEGPES, |
3acc4b00bcc6
allows OSD menu to be displayed when using MPEG PES video out
ben
parents:
20561
diff
changeset
|
343 MP_IMGTYPE_EXPORT, 0, mpi->w, mpi->h); |
3acc4b00bcc6
allows OSD menu to be displayed when using MPEG PES video out
ben
parents:
20561
diff
changeset
|
344 dmpi->planes[0]=mpi->planes[0]; |
3acc4b00bcc6
allows OSD menu to be displayed when using MPEG PES video out
ben
parents:
20561
diff
changeset
|
345 return vf_next_put_image(vf,dmpi, pts); |
3acc4b00bcc6
allows OSD menu to be displayed when using MPEG PES video out
ben
parents:
20561
diff
changeset
|
346 } |
3acc4b00bcc6
allows OSD menu to be displayed when using MPEG PES video out
ben
parents:
20561
diff
changeset
|
347 |
9495 | 348 if(mpi->flags&MP_IMGFLAG_DIRECT || mpi->flags&MP_IMGFLAG_DRAW_CALLBACK){ |
10140
30cad6ad9dbc
fix segfaults with slices. support slice rendering into a filter even
rfelker
parents:
9603
diff
changeset
|
349 vf->dmpi=mpi->priv; |
18004
bcd805923554
Part2 of several printf2mp_msg changes in patch from Otvos Attila oattila AT chello DOT hu with LOTS of modifications by me
reynaldo
parents:
17906
diff
changeset
|
350 if(!vf->dmpi) { mp_msg(MSGT_VFILTER, MSGL_WARN, MSGTR_MPCODECS_FunWhydowegetNULL); return 0; } |
9495 | 351 mpi->priv=NULL; |
5644
f1465a280612
(buggy) osd support, disabled for now, mencoder needs fixes to compile
arpi
parents:
5607
diff
changeset
|
352 #ifdef OSD_SUPPORT |
f1465a280612
(buggy) osd support, disabled for now, mencoder needs fixes to compile
arpi
parents:
5607
diff
changeset
|
353 if(vf->priv->osd) draw_osd(vf,mpi->w,mpi->h); |
f1465a280612
(buggy) osd support, disabled for now, mencoder needs fixes to compile
arpi
parents:
5607
diff
changeset
|
354 #endif |
7368 | 355 // we've used DR, so we're ready... |
9279 | 356 if(!(mpi->flags&MP_IMGFLAG_PLANAR)) |
10140
30cad6ad9dbc
fix segfaults with slices. support slice rendering into a filter even
rfelker
parents:
9603
diff
changeset
|
357 vf->dmpi->planes[1] = mpi->planes[1]; // passthrough rgb8 palette |
17906
20aca9baf5d8
passing pts through the filter layer (lets see if pts or cola comes out at the end)
michael
parents:
17102
diff
changeset
|
358 return vf_next_put_image(vf,vf->dmpi, pts); |
5507
d0d029fda134
video filter layer - written from scratch, but inspired a lot by Fredrik Kuivinen's patch
arpi
parents:
diff
changeset
|
359 } |
d0d029fda134
video filter layer - written from scratch, but inspired a lot by Fredrik Kuivinen's patch
arpi
parents:
diff
changeset
|
360 |
d0d029fda134
video filter layer - written from scratch, but inspired a lot by Fredrik Kuivinen's patch
arpi
parents:
diff
changeset
|
361 // hope we'll get DR buffer: |
10140
30cad6ad9dbc
fix segfaults with slices. support slice rendering into a filter even
rfelker
parents:
9603
diff
changeset
|
362 vf->dmpi=vf_get_image(vf->next,mpi->imgfmt, |
5507
d0d029fda134
video filter layer - written from scratch, but inspired a lot by Fredrik Kuivinen's patch
arpi
parents:
diff
changeset
|
363 MP_IMGTYPE_TEMP, MP_IMGFLAG_ACCEPT_STRIDE, |
d0d029fda134
video filter layer - written from scratch, but inspired a lot by Fredrik Kuivinen's patch
arpi
parents:
diff
changeset
|
364 vf->priv->exp_w, vf->priv->exp_h); |
d0d029fda134
video filter layer - written from scratch, but inspired a lot by Fredrik Kuivinen's patch
arpi
parents:
diff
changeset
|
365 |
d0d029fda134
video filter layer - written from scratch, but inspired a lot by Fredrik Kuivinen's patch
arpi
parents:
diff
changeset
|
366 // copy mpi->dmpi... |
d0d029fda134
video filter layer - written from scratch, but inspired a lot by Fredrik Kuivinen's patch
arpi
parents:
diff
changeset
|
367 if(mpi->flags&MP_IMGFLAG_PLANAR){ |
10140
30cad6ad9dbc
fix segfaults with slices. support slice rendering into a filter even
rfelker
parents:
9603
diff
changeset
|
368 memcpy_pic(vf->dmpi->planes[0]+ |
30cad6ad9dbc
fix segfaults with slices. support slice rendering into a filter even
rfelker
parents:
9603
diff
changeset
|
369 vf->priv->exp_y*vf->dmpi->stride[0]+vf->priv->exp_x, |
5507
d0d029fda134
video filter layer - written from scratch, but inspired a lot by Fredrik Kuivinen's patch
arpi
parents:
diff
changeset
|
370 mpi->planes[0], mpi->w, mpi->h, |
10140
30cad6ad9dbc
fix segfaults with slices. support slice rendering into a filter even
rfelker
parents:
9603
diff
changeset
|
371 vf->dmpi->stride[0],mpi->stride[0]); |
30cad6ad9dbc
fix segfaults with slices. support slice rendering into a filter even
rfelker
parents:
9603
diff
changeset
|
372 memcpy_pic(vf->dmpi->planes[1]+ |
30cad6ad9dbc
fix segfaults with slices. support slice rendering into a filter even
rfelker
parents:
9603
diff
changeset
|
373 (vf->priv->exp_y>>mpi->chroma_y_shift)*vf->dmpi->stride[1]+(vf->priv->exp_x>>mpi->chroma_x_shift), |
18321
22be226a5cf5
fixes a bug when copying the image into a destination buffer smaller than the source.
gpoirier
parents:
18004
diff
changeset
|
374 mpi->planes[1], (mpi->w>>mpi->chroma_x_shift), (mpi->h>>mpi->chroma_y_shift), |
10140
30cad6ad9dbc
fix segfaults with slices. support slice rendering into a filter even
rfelker
parents:
9603
diff
changeset
|
375 vf->dmpi->stride[1],mpi->stride[1]); |
30cad6ad9dbc
fix segfaults with slices. support slice rendering into a filter even
rfelker
parents:
9603
diff
changeset
|
376 memcpy_pic(vf->dmpi->planes[2]+ |
30cad6ad9dbc
fix segfaults with slices. support slice rendering into a filter even
rfelker
parents:
9603
diff
changeset
|
377 (vf->priv->exp_y>>mpi->chroma_y_shift)*vf->dmpi->stride[2]+(vf->priv->exp_x>>mpi->chroma_x_shift), |
18321
22be226a5cf5
fixes a bug when copying the image into a destination buffer smaller than the source.
gpoirier
parents:
18004
diff
changeset
|
378 mpi->planes[2], (mpi->w>>mpi->chroma_x_shift), (mpi->h>>mpi->chroma_y_shift), |
10140
30cad6ad9dbc
fix segfaults with slices. support slice rendering into a filter even
rfelker
parents:
9603
diff
changeset
|
379 vf->dmpi->stride[2],mpi->stride[2]); |
5507
d0d029fda134
video filter layer - written from scratch, but inspired a lot by Fredrik Kuivinen's patch
arpi
parents:
diff
changeset
|
380 } else { |
10140
30cad6ad9dbc
fix segfaults with slices. support slice rendering into a filter even
rfelker
parents:
9603
diff
changeset
|
381 memcpy_pic(vf->dmpi->planes[0]+ |
30cad6ad9dbc
fix segfaults with slices. support slice rendering into a filter even
rfelker
parents:
9603
diff
changeset
|
382 vf->priv->exp_y*vf->dmpi->stride[0]+vf->priv->exp_x*(vf->dmpi->bpp/8), |
30cad6ad9dbc
fix segfaults with slices. support slice rendering into a filter even
rfelker
parents:
9603
diff
changeset
|
383 mpi->planes[0], mpi->w*(vf->dmpi->bpp/8), mpi->h, |
30cad6ad9dbc
fix segfaults with slices. support slice rendering into a filter even
rfelker
parents:
9603
diff
changeset
|
384 vf->dmpi->stride[0],mpi->stride[0]); |
30cad6ad9dbc
fix segfaults with slices. support slice rendering into a filter even
rfelker
parents:
9603
diff
changeset
|
385 vf->dmpi->planes[1] = mpi->planes[1]; // passthrough rgb8 palette |
5507
d0d029fda134
video filter layer - written from scratch, but inspired a lot by Fredrik Kuivinen's patch
arpi
parents:
diff
changeset
|
386 } |
5644
f1465a280612
(buggy) osd support, disabled for now, mencoder needs fixes to compile
arpi
parents:
5607
diff
changeset
|
387 #ifdef OSD_SUPPORT |
f1465a280612
(buggy) osd support, disabled for now, mencoder needs fixes to compile
arpi
parents:
5607
diff
changeset
|
388 if(vf->priv->osd) draw_osd(vf,mpi->w,mpi->h); |
f1465a280612
(buggy) osd support, disabled for now, mencoder needs fixes to compile
arpi
parents:
5607
diff
changeset
|
389 #endif |
17906
20aca9baf5d8
passing pts through the filter layer (lets see if pts or cola comes out at the end)
michael
parents:
17102
diff
changeset
|
390 return vf_next_put_image(vf,vf->dmpi, pts); |
5507
d0d029fda134
video filter layer - written from scratch, but inspired a lot by Fredrik Kuivinen's patch
arpi
parents:
diff
changeset
|
391 } |
d0d029fda134
video filter layer - written from scratch, but inspired a lot by Fredrik Kuivinen's patch
arpi
parents:
diff
changeset
|
392 |
d0d029fda134
video filter layer - written from scratch, but inspired a lot by Fredrik Kuivinen's patch
arpi
parents:
diff
changeset
|
393 //===========================================================================// |
d0d029fda134
video filter layer - written from scratch, but inspired a lot by Fredrik Kuivinen's patch
arpi
parents:
diff
changeset
|
394 |
5644
f1465a280612
(buggy) osd support, disabled for now, mencoder needs fixes to compile
arpi
parents:
5607
diff
changeset
|
395 static int control(struct vf_instance_s* vf, int request, void* data){ |
f1465a280612
(buggy) osd support, disabled for now, mencoder needs fixes to compile
arpi
parents:
5607
diff
changeset
|
396 #ifdef OSD_SUPPORT |
f1465a280612
(buggy) osd support, disabled for now, mencoder needs fixes to compile
arpi
parents:
5607
diff
changeset
|
397 switch(request){ |
f1465a280612
(buggy) osd support, disabled for now, mencoder needs fixes to compile
arpi
parents:
5607
diff
changeset
|
398 case VFCTRL_DRAW_OSD: |
f1465a280612
(buggy) osd support, disabled for now, mencoder needs fixes to compile
arpi
parents:
5607
diff
changeset
|
399 if(vf->priv->osd) return CONTROL_TRUE; |
f1465a280612
(buggy) osd support, disabled for now, mencoder needs fixes to compile
arpi
parents:
5607
diff
changeset
|
400 } |
f1465a280612
(buggy) osd support, disabled for now, mencoder needs fixes to compile
arpi
parents:
5607
diff
changeset
|
401 #endif |
f1465a280612
(buggy) osd support, disabled for now, mencoder needs fixes to compile
arpi
parents:
5607
diff
changeset
|
402 return vf_next_control(vf,request,data); |
f1465a280612
(buggy) osd support, disabled for now, mencoder needs fixes to compile
arpi
parents:
5607
diff
changeset
|
403 } |
f1465a280612
(buggy) osd support, disabled for now, mencoder needs fixes to compile
arpi
parents:
5607
diff
changeset
|
404 |
21803
3acc4b00bcc6
allows OSD menu to be displayed when using MPEG PES video out
ben
parents:
20561
diff
changeset
|
405 static int query_format(struct vf_instance_s* vf, unsigned int fmt){ |
3acc4b00bcc6
allows OSD menu to be displayed when using MPEG PES video out
ben
parents:
20561
diff
changeset
|
406 return (vf_next_query_format(vf,fmt)); |
3acc4b00bcc6
allows OSD menu to be displayed when using MPEG PES video out
ben
parents:
20561
diff
changeset
|
407 } |
3acc4b00bcc6
allows OSD menu to be displayed when using MPEG PES video out
ben
parents:
20561
diff
changeset
|
408 |
5507
d0d029fda134
video filter layer - written from scratch, but inspired a lot by Fredrik Kuivinen's patch
arpi
parents:
diff
changeset
|
409 static int open(vf_instance_t *vf, char* args){ |
d0d029fda134
video filter layer - written from scratch, but inspired a lot by Fredrik Kuivinen's patch
arpi
parents:
diff
changeset
|
410 vf->config=config; |
5644
f1465a280612
(buggy) osd support, disabled for now, mencoder needs fixes to compile
arpi
parents:
5607
diff
changeset
|
411 vf->control=control; |
21803
3acc4b00bcc6
allows OSD menu to be displayed when using MPEG PES video out
ben
parents:
20561
diff
changeset
|
412 vf->query_format=query_format; |
9495 | 413 vf->start_slice=start_slice; |
414 vf->draw_slice=draw_slice; | |
5507
d0d029fda134
video filter layer - written from scratch, but inspired a lot by Fredrik Kuivinen's patch
arpi
parents:
diff
changeset
|
415 vf->get_image=get_image; |
d0d029fda134
video filter layer - written from scratch, but inspired a lot by Fredrik Kuivinen's patch
arpi
parents:
diff
changeset
|
416 vf->put_image=put_image; |
15939 | 417 mp_msg(MSGT_VFILTER, MSGL_INFO, "Expand: %d x %d, %d ; %d, osd: %d, aspect: %lf, round: %d\n", |
5507
d0d029fda134
video filter layer - written from scratch, but inspired a lot by Fredrik Kuivinen's patch
arpi
parents:
diff
changeset
|
418 vf->priv->exp_w, |
d0d029fda134
video filter layer - written from scratch, but inspired a lot by Fredrik Kuivinen's patch
arpi
parents:
diff
changeset
|
419 vf->priv->exp_h, |
d0d029fda134
video filter layer - written from scratch, but inspired a lot by Fredrik Kuivinen's patch
arpi
parents:
diff
changeset
|
420 vf->priv->exp_x, |
5644
f1465a280612
(buggy) osd support, disabled for now, mencoder needs fixes to compile
arpi
parents:
5607
diff
changeset
|
421 vf->priv->exp_y, |
15939 | 422 vf->priv->osd, |
423 vf->priv->aspect, | |
424 vf->priv->round); | |
5507
d0d029fda134
video filter layer - written from scratch, but inspired a lot by Fredrik Kuivinen's patch
arpi
parents:
diff
changeset
|
425 return 1; |
d0d029fda134
video filter layer - written from scratch, but inspired a lot by Fredrik Kuivinen's patch
arpi
parents:
diff
changeset
|
426 } |
d0d029fda134
video filter layer - written from scratch, but inspired a lot by Fredrik Kuivinen's patch
arpi
parents:
diff
changeset
|
427 |
9594 | 428 #define ST_OFF(f) M_ST_OFF(struct vf_priv_s,f) |
429 static m_option_t vf_opts_fields[] = { | |
9603
f9222b8a5166
And 10L their, i should have started to read vop.txt sooner ;)
albeu
parents:
9594
diff
changeset
|
430 {"w", ST_OFF(exp_w), CONF_TYPE_INT, 0, 0 ,0, NULL}, |
f9222b8a5166
And 10L their, i should have started to read vop.txt sooner ;)
albeu
parents:
9594
diff
changeset
|
431 {"h", ST_OFF(exp_h), CONF_TYPE_INT, 0, 0 ,0, NULL}, |
f9222b8a5166
And 10L their, i should have started to read vop.txt sooner ;)
albeu
parents:
9594
diff
changeset
|
432 {"x", ST_OFF(exp_x), CONF_TYPE_INT, M_OPT_MIN, -1, 0, NULL}, |
f9222b8a5166
And 10L their, i should have started to read vop.txt sooner ;)
albeu
parents:
9594
diff
changeset
|
433 {"y", ST_OFF(exp_y), CONF_TYPE_INT, M_OPT_MIN, -1, 0, NULL}, |
9594 | 434 {"osd", ST_OFF(osd), CONF_TYPE_FLAG, 0 , 0, 1, NULL}, |
15939 | 435 {"aspect", ST_OFF(aspect), CONF_TYPE_DOUBLE, M_OPT_MIN, 0, 0, NULL}, |
436 {"round", ST_OFF(round), CONF_TYPE_INT, M_OPT_MIN, 1, 0, NULL}, | |
9594 | 437 { NULL, NULL, 0, 0, 0, 0, NULL } |
438 }; | |
439 | |
440 static m_struct_t vf_opts = { | |
441 "expand", | |
442 sizeof(struct vf_priv_s), | |
443 &vf_priv_dflt, | |
444 vf_opts_fields | |
445 }; | |
446 | |
447 | |
448 | |
5507
d0d029fda134
video filter layer - written from scratch, but inspired a lot by Fredrik Kuivinen's patch
arpi
parents:
diff
changeset
|
449 vf_info_t vf_info_expand = { |
5644
f1465a280612
(buggy) osd support, disabled for now, mencoder needs fixes to compile
arpi
parents:
5607
diff
changeset
|
450 #ifdef OSD_SUPPORT |
f1465a280612
(buggy) osd support, disabled for now, mencoder needs fixes to compile
arpi
parents:
5607
diff
changeset
|
451 "expanding & osd", |
f1465a280612
(buggy) osd support, disabled for now, mencoder needs fixes to compile
arpi
parents:
5607
diff
changeset
|
452 #else |
5507
d0d029fda134
video filter layer - written from scratch, but inspired a lot by Fredrik Kuivinen's patch
arpi
parents:
diff
changeset
|
453 "expanding", |
5644
f1465a280612
(buggy) osd support, disabled for now, mencoder needs fixes to compile
arpi
parents:
5607
diff
changeset
|
454 #endif |
5507
d0d029fda134
video filter layer - written from scratch, but inspired a lot by Fredrik Kuivinen's patch
arpi
parents:
diff
changeset
|
455 "expand", |
d0d029fda134
video filter layer - written from scratch, but inspired a lot by Fredrik Kuivinen's patch
arpi
parents:
diff
changeset
|
456 "A'rpi", |
d0d029fda134
video filter layer - written from scratch, but inspired a lot by Fredrik Kuivinen's patch
arpi
parents:
diff
changeset
|
457 "", |
9593
e9a2af584986
Add the new -vf option wich is the same as vop in reverse order.
albeu
parents:
9582
diff
changeset
|
458 open, |
9594 | 459 &vf_opts |
5507
d0d029fda134
video filter layer - written from scratch, but inspired a lot by Fredrik Kuivinen's patch
arpi
parents:
diff
changeset
|
460 }; |
d0d029fda134
video filter layer - written from scratch, but inspired a lot by Fredrik Kuivinen's patch
arpi
parents:
diff
changeset
|
461 |
d0d029fda134
video filter layer - written from scratch, but inspired a lot by Fredrik Kuivinen's patch
arpi
parents:
diff
changeset
|
462 //===========================================================================// |