Mercurial > mplayer.hg
annotate libmpcodecs/vf_expand.c @ 10274:cd8909001845
tivo demuxer moved down, its fileformat detection is unstable (misdetects mpeg-ps)
author | arpi |
---|---|
date | Mon, 09 Jun 2003 22:01:33 +0000 |
parents | 30cad6ad9dbc |
children | 87043624b0d8 |
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 |
d0d029fda134
video filter layer - written from scratch, but inspired a lot by Fredrik Kuivinen's patch
arpi
parents:
diff
changeset
|
7 #include "../config.h" |
d0d029fda134
video filter layer - written from scratch, but inspired a lot by Fredrik Kuivinen's patch
arpi
parents:
diff
changeset
|
8 #include "../mp_msg.h" |
d0d029fda134
video filter layer - written from scratch, but inspired a lot by Fredrik Kuivinen's patch
arpi
parents:
diff
changeset
|
9 |
5644
f1465a280612
(buggy) osd support, disabled for now, mencoder needs fixes to compile
arpi
parents:
5607
diff
changeset
|
10 #include "img_format.h" |
5607 | 11 #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
|
12 #include "vf.h" |
d0d029fda134
video filter layer - written from scratch, but inspired a lot by Fredrik Kuivinen's patch
arpi
parents:
diff
changeset
|
13 |
d0d029fda134
video filter layer - written from scratch, but inspired a lot by Fredrik Kuivinen's patch
arpi
parents:
diff
changeset
|
14 #include "../libvo/fastmemcpy.h" |
d0d029fda134
video filter layer - written from scratch, but inspired a lot by Fredrik Kuivinen's patch
arpi
parents:
diff
changeset
|
15 |
5644
f1465a280612
(buggy) osd support, disabled for now, mencoder needs fixes to compile
arpi
parents:
5607
diff
changeset
|
16 #ifdef OSD_SUPPORT |
f1465a280612
(buggy) osd support, disabled for now, mencoder needs fixes to compile
arpi
parents:
5607
diff
changeset
|
17 #include "../libvo/sub.h" |
f1465a280612
(buggy) osd support, disabled for now, mencoder needs fixes to compile
arpi
parents:
5607
diff
changeset
|
18 #include "../libvo/osd.h" |
f1465a280612
(buggy) osd support, disabled for now, mencoder needs fixes to compile
arpi
parents:
5607
diff
changeset
|
19 #endif |
f1465a280612
(buggy) osd support, disabled for now, mencoder needs fixes to compile
arpi
parents:
5607
diff
changeset
|
20 |
9594 | 21 #include "m_option.h" |
22 #include "m_struct.h" | |
23 | |
7052
f3b2f31332fc
allocating large enough buffer, fixes green stuff on top for encoding of height %16 != 0 videos
michael
parents:
6761
diff
changeset
|
24 #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
|
25 |
9594 | 26 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
|
27 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
|
28 int exp_x,exp_y; |
5644
f1465a280612
(buggy) osd support, disabled for now, mencoder needs fixes to compile
arpi
parents:
5607
diff
changeset
|
29 int osd; |
5669
391931fa79a6
enabled new OSD code in -vop expand, subtitles rendering support to mencoder
arpi
parents:
5644
diff
changeset
|
30 unsigned char* fb_ptr; |
9594 | 31 } vf_priv_dflt = { |
32 -1,-1, | |
33 -1,-1, | |
34 NULL, | |
35 0, | |
36 NULL | |
5507
d0d029fda134
video filter layer - written from scratch, but inspired a lot by Fredrik Kuivinen's patch
arpi
parents:
diff
changeset
|
37 }; |
d0d029fda134
video filter layer - written from scratch, but inspired a lot by Fredrik Kuivinen's patch
arpi
parents:
diff
changeset
|
38 |
6060 | 39 extern int opt_screen_size_x; |
40 extern int opt_screen_size_y; | |
41 | |
5507
d0d029fda134
video filter layer - written from scratch, but inspired a lot by Fredrik Kuivinen's patch
arpi
parents:
diff
changeset
|
42 //===========================================================================// |
5644
f1465a280612
(buggy) osd support, disabled for now, mencoder needs fixes to compile
arpi
parents:
5607
diff
changeset
|
43 #ifdef OSD_SUPPORT |
f1465a280612
(buggy) osd support, disabled for now, mencoder needs fixes to compile
arpi
parents:
5607
diff
changeset
|
44 |
f1465a280612
(buggy) osd support, disabled for now, mencoder needs fixes to compile
arpi
parents:
5607
diff
changeset
|
45 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
|
46 static int orig_w,orig_h; |
f1465a280612
(buggy) osd support, disabled for now, mencoder needs fixes to compile
arpi
parents:
5607
diff
changeset
|
47 |
f1465a280612
(buggy) osd support, disabled for now, mencoder needs fixes to compile
arpi
parents:
5607
diff
changeset
|
48 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
|
49 // 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
|
50 //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
|
51 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
|
52 } |
f1465a280612
(buggy) osd support, disabled for now, mencoder needs fixes to compile
arpi
parents:
5607
diff
changeset
|
53 |
f1465a280612
(buggy) osd support, disabled for now, mencoder needs fixes to compile
arpi
parents:
5607
diff
changeset
|
54 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
|
55 if(!vo_osd_changed_flag) return; |
f1465a280612
(buggy) osd support, disabled for now, mencoder needs fixes to compile
arpi
parents:
5607
diff
changeset
|
56 // split it to 4 parts: |
f1465a280612
(buggy) osd support, disabled for now, mencoder needs fixes to compile
arpi
parents:
5607
diff
changeset
|
57 if(y0<vf->priv->exp_y){ |
f1465a280612
(buggy) osd support, disabled for now, mencoder needs fixes to compile
arpi
parents:
5607
diff
changeset
|
58 // it has parts above the image: |
f1465a280612
(buggy) osd support, disabled for now, mencoder needs fixes to compile
arpi
parents:
5607
diff
changeset
|
59 int y=y0+h; |
f1465a280612
(buggy) osd support, disabled for now, mencoder needs fixes to compile
arpi
parents:
5607
diff
changeset
|
60 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
|
61 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
|
62 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
|
63 h-=y-y0;y0=y; |
f1465a280612
(buggy) osd support, disabled for now, mencoder needs fixes to compile
arpi
parents:
5607
diff
changeset
|
64 } |
f1465a280612
(buggy) osd support, disabled for now, mencoder needs fixes to compile
arpi
parents:
5607
diff
changeset
|
65 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
|
66 // it has parts under the image: |
f1465a280612
(buggy) osd support, disabled for now, mencoder needs fixes to compile
arpi
parents:
5607
diff
changeset
|
67 int y=y0; |
f1465a280612
(buggy) osd support, disabled for now, mencoder needs fixes to compile
arpi
parents:
5607
diff
changeset
|
68 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
|
69 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
|
70 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
|
71 h=y-y0; |
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(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
|
74 // 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
|
75 } |
f1465a280612
(buggy) osd support, disabled for now, mencoder needs fixes to compile
arpi
parents:
5607
diff
changeset
|
76 |
f1465a280612
(buggy) osd support, disabled for now, mencoder needs fixes to compile
arpi
parents:
5607
diff
changeset
|
77 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
|
78 unsigned char* dst; |
10140
30cad6ad9dbc
fix segfaults with slices. support slice rendering into a filter even
rfelker
parents:
9603
diff
changeset
|
79 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
|
80 // 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
|
81 // untouched! |
391931fa79a6
enabled new OSD code in -vop expand, subtitles rendering support to mencoder
arpi
parents:
5644
diff
changeset
|
82 if(x0<vf->priv->exp_x){ |
391931fa79a6
enabled new OSD code in -vop expand, subtitles rendering support to mencoder
arpi
parents:
5644
diff
changeset
|
83 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
|
84 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
|
85 } |
391931fa79a6
enabled new OSD code in -vop expand, subtitles rendering support to mencoder
arpi
parents:
5644
diff
changeset
|
86 if(y0<vf->priv->exp_y){ |
391931fa79a6
enabled new OSD code in -vop expand, subtitles rendering support to mencoder
arpi
parents:
5644
diff
changeset
|
87 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
|
88 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
|
89 } |
391931fa79a6
enabled new OSD code in -vop expand, subtitles rendering support to mencoder
arpi
parents:
5644
diff
changeset
|
90 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
|
91 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
|
92 } |
391931fa79a6
enabled new OSD code in -vop expand, subtitles rendering support to mencoder
arpi
parents:
5644
diff
changeset
|
93 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
|
94 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
|
95 } |
391931fa79a6
enabled new OSD code in -vop expand, subtitles rendering support to mencoder
arpi
parents:
5644
diff
changeset
|
96 } |
391931fa79a6
enabled new OSD code in -vop expand, subtitles rendering support to mencoder
arpi
parents:
5644
diff
changeset
|
97 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
|
98 // 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
|
99 dst=vf->dmpi->planes[0]+ |
30cad6ad9dbc
fix segfaults with slices. support slice rendering into a filter even
rfelker
parents:
9603
diff
changeset
|
100 vf->dmpi->stride[0]*y0+ |
30cad6ad9dbc
fix segfaults with slices. support slice rendering into a filter even
rfelker
parents:
9603
diff
changeset
|
101 (vf->dmpi->bpp>>3)*x0; |
30cad6ad9dbc
fix segfaults with slices. support slice rendering into a filter even
rfelker
parents:
9603
diff
changeset
|
102 switch(vf->dmpi->imgfmt){ |
5644
f1465a280612
(buggy) osd support, disabled for now, mencoder needs fixes to compile
arpi
parents:
5607
diff
changeset
|
103 case IMGFMT_BGR15: |
f1465a280612
(buggy) osd support, disabled for now, mencoder needs fixes to compile
arpi
parents:
5607
diff
changeset
|
104 case IMGFMT_RGB15: |
10140
30cad6ad9dbc
fix segfaults with slices. support slice rendering into a filter even
rfelker
parents:
9603
diff
changeset
|
105 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
|
106 break; |
f1465a280612
(buggy) osd support, disabled for now, mencoder needs fixes to compile
arpi
parents:
5607
diff
changeset
|
107 case IMGFMT_BGR16: |
f1465a280612
(buggy) osd support, disabled for now, mencoder needs fixes to compile
arpi
parents:
5607
diff
changeset
|
108 case IMGFMT_RGB16: |
10140
30cad6ad9dbc
fix segfaults with slices. support slice rendering into a filter even
rfelker
parents:
9603
diff
changeset
|
109 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
|
110 break; |
f1465a280612
(buggy) osd support, disabled for now, mencoder needs fixes to compile
arpi
parents:
5607
diff
changeset
|
111 case IMGFMT_BGR24: |
f1465a280612
(buggy) osd support, disabled for now, mencoder needs fixes to compile
arpi
parents:
5607
diff
changeset
|
112 case IMGFMT_RGB24: |
10140
30cad6ad9dbc
fix segfaults with slices. support slice rendering into a filter even
rfelker
parents:
9603
diff
changeset
|
113 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
|
114 break; |
f1465a280612
(buggy) osd support, disabled for now, mencoder needs fixes to compile
arpi
parents:
5607
diff
changeset
|
115 case IMGFMT_BGR32: |
f1465a280612
(buggy) osd support, disabled for now, mencoder needs fixes to compile
arpi
parents:
5607
diff
changeset
|
116 case IMGFMT_RGB32: |
10140
30cad6ad9dbc
fix segfaults with slices. support slice rendering into a filter even
rfelker
parents:
9603
diff
changeset
|
117 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
|
118 break; |
f1465a280612
(buggy) osd support, disabled for now, mencoder needs fixes to compile
arpi
parents:
5607
diff
changeset
|
119 case IMGFMT_YV12: |
f1465a280612
(buggy) osd support, disabled for now, mencoder needs fixes to compile
arpi
parents:
5607
diff
changeset
|
120 case IMGFMT_I420: |
f1465a280612
(buggy) osd support, disabled for now, mencoder needs fixes to compile
arpi
parents:
5607
diff
changeset
|
121 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
|
122 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
|
123 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
|
124 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
|
125 case IMGFMT_Y8: |
10140
30cad6ad9dbc
fix segfaults with slices. support slice rendering into a filter even
rfelker
parents:
9603
diff
changeset
|
126 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
|
127 break; |
f1465a280612
(buggy) osd support, disabled for now, mencoder needs fixes to compile
arpi
parents:
5607
diff
changeset
|
128 case IMGFMT_YUY2: |
10140
30cad6ad9dbc
fix segfaults with slices. support slice rendering into a filter even
rfelker
parents:
9603
diff
changeset
|
129 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
|
130 break; |
f1465a280612
(buggy) osd support, disabled for now, mencoder needs fixes to compile
arpi
parents:
5607
diff
changeset
|
131 case IMGFMT_UYVY: |
10140
30cad6ad9dbc
fix segfaults with slices. support slice rendering into a filter even
rfelker
parents:
9603
diff
changeset
|
132 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
|
133 break; |
f1465a280612
(buggy) osd support, disabled for now, mencoder needs fixes to compile
arpi
parents:
5607
diff
changeset
|
134 } |
f1465a280612
(buggy) osd support, disabled for now, mencoder needs fixes to compile
arpi
parents:
5607
diff
changeset
|
135 } |
f1465a280612
(buggy) osd support, disabled for now, mencoder needs fixes to compile
arpi
parents:
5607
diff
changeset
|
136 |
f1465a280612
(buggy) osd support, disabled for now, mencoder needs fixes to compile
arpi
parents:
5607
diff
changeset
|
137 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
|
138 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
|
139 // printf("======================================\n"); |
5644
f1465a280612
(buggy) osd support, disabled for now, mencoder needs fixes to compile
arpi
parents:
5607
diff
changeset
|
140 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
|
141 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
|
142 // 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
|
143 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
|
144 // double buffering, so we need full clear :( |
391931fa79a6
enabled new OSD code in -vop expand, subtitles rendering support to mencoder
arpi
parents:
5644
diff
changeset
|
145 remove_func(0,0,vf->priv->exp_w,vf->priv->exp_h); |
391931fa79a6
enabled new OSD code in -vop expand, subtitles rendering support to mencoder
arpi
parents:
5644
diff
changeset
|
146 } else { |
391931fa79a6
enabled new OSD code in -vop expand, subtitles rendering support to mencoder
arpi
parents:
5644
diff
changeset
|
147 // partial clear: |
391931fa79a6
enabled new OSD code in -vop expand, subtitles rendering support to mencoder
arpi
parents:
5644
diff
changeset
|
148 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
|
149 } |
5644
f1465a280612
(buggy) osd support, disabled for now, mencoder needs fixes to compile
arpi
parents:
5607
diff
changeset
|
150 } |
f1465a280612
(buggy) osd support, disabled for now, mencoder needs fixes to compile
arpi
parents:
5607
diff
changeset
|
151 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
|
152 // 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
|
153 // 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
|
154 if(vf->dmpi) |
30cad6ad9dbc
fix segfaults with slices. support slice rendering into a filter even
rfelker
parents:
9603
diff
changeset
|
155 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
|
156 } |
f1465a280612
(buggy) osd support, disabled for now, mencoder needs fixes to compile
arpi
parents:
5607
diff
changeset
|
157 |
f1465a280612
(buggy) osd support, disabled for now, mencoder needs fixes to compile
arpi
parents:
5607
diff
changeset
|
158 #endif |
f1465a280612
(buggy) osd support, disabled for now, mencoder needs fixes to compile
arpi
parents:
5607
diff
changeset
|
159 //===========================================================================// |
5507
d0d029fda134
video filter layer - written from scratch, but inspired a lot by Fredrik Kuivinen's patch
arpi
parents:
diff
changeset
|
160 |
d0d029fda134
video filter layer - written from scratch, but inspired a lot by Fredrik Kuivinen's patch
arpi
parents:
diff
changeset
|
161 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
|
162 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
|
163 unsigned int flags, unsigned int outfmt){ |
6525 | 164 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
|
165 // calculate the missing parameters: |
5921 | 166 #if 0 |
5507
d0d029fda134
video filter layer - written from scratch, but inspired a lot by Fredrik Kuivinen's patch
arpi
parents:
diff
changeset
|
167 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
|
168 if(vf->priv->exp_h<height) vf->priv->exp_h=height; |
5921 | 169 #else |
170 if ( vf->priv->exp_w == -1 ) vf->priv->exp_w=width; | |
171 else if (vf->priv->exp_w < -1 ) vf->priv->exp_w=width - vf->priv->exp_w; | |
172 else if ( vf->priv->exp_w<width ) vf->priv->exp_w=width; | |
173 if ( vf->priv->exp_h == -1 ) vf->priv->exp_h=height; | |
174 else if ( vf->priv->exp_h < -1 ) vf->priv->exp_h=height - vf->priv->exp_h; | |
175 else if( vf->priv->exp_h<height ) vf->priv->exp_h=height; | |
176 #endif | |
5687 | 177 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; |
178 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
|
179 vf->priv->fb_ptr=NULL; |
6060 | 180 |
181 if(!opt_screen_size_x && !opt_screen_size_y){ | |
182 d_width=d_width*vf->priv->exp_w/width; | |
183 d_height=d_height*vf->priv->exp_h/height; | |
184 } | |
185 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
|
186 } |
d0d029fda134
video filter layer - written from scratch, but inspired a lot by Fredrik Kuivinen's patch
arpi
parents:
diff
changeset
|
187 |
d0d029fda134
video filter layer - written from scratch, but inspired a lot by Fredrik Kuivinen's patch
arpi
parents:
diff
changeset
|
188 // there are 4 cases: |
d0d029fda134
video filter layer - written from scratch, but inspired a lot by Fredrik Kuivinen's patch
arpi
parents:
diff
changeset
|
189 // 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
|
190 // 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
|
191 // 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
|
192 // 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
|
193 |
d0d029fda134
video filter layer - written from scratch, but inspired a lot by Fredrik Kuivinen's patch
arpi
parents:
diff
changeset
|
194 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
|
195 // 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
|
196 #ifdef OSD_SUPPORT |
f1465a280612
(buggy) osd support, disabled for now, mencoder needs fixes to compile
arpi
parents:
5607
diff
changeset
|
197 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
|
198 // check if we have to render osd! |
f1465a280612
(buggy) osd support, disabled for now, mencoder needs fixes to compile
arpi
parents:
5607
diff
changeset
|
199 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
|
200 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
|
201 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
|
202 } |
f1465a280612
(buggy) osd support, disabled for now, mencoder needs fixes to compile
arpi
parents:
5607
diff
changeset
|
203 #endif |
5507
d0d029fda134
video filter layer - written from scratch, but inspired a lot by Fredrik Kuivinen's patch
arpi
parents:
diff
changeset
|
204 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
|
205 (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
|
206 // try full DR ! |
10140
30cad6ad9dbc
fix segfaults with slices. support slice rendering into a filter even
rfelker
parents:
9603
diff
changeset
|
207 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
|
208 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
|
209 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
|
210 MAX(vf->priv->exp_h, mpi->height+vf->priv->exp_y)); |
9495 | 211 #if 1 |
10140
30cad6ad9dbc
fix segfaults with slices. support slice rendering into a filter even
rfelker
parents:
9603
diff
changeset
|
212 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
|
213 !(vf->dmpi->flags & MP_IMGFLAG_DIRECT)){ |
9495 | 214 printf("Full DR not possible, trying SLICES instead!\n"); |
215 return; | |
216 } | |
217 #endif | |
5507
d0d029fda134
video filter layer - written from scratch, but inspired a lot by Fredrik Kuivinen's patch
arpi
parents:
diff
changeset
|
218 // 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
|
219 if(mpi->flags&MP_IMGFLAG_PLANAR){ |
10140
30cad6ad9dbc
fix segfaults with slices. support slice rendering into a filter even
rfelker
parents:
9603
diff
changeset
|
220 mpi->planes[0]=vf->dmpi->planes[0]+ |
30cad6ad9dbc
fix segfaults with slices. support slice rendering into a filter even
rfelker
parents:
9603
diff
changeset
|
221 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
|
222 mpi->planes[1]=vf->dmpi->planes[1]+ |
30cad6ad9dbc
fix segfaults with slices. support slice rendering into a filter even
rfelker
parents:
9603
diff
changeset
|
223 (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
|
224 mpi->planes[2]=vf->dmpi->planes[2]+ |
30cad6ad9dbc
fix segfaults with slices. support slice rendering into a filter even
rfelker
parents:
9603
diff
changeset
|
225 (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
|
226 mpi->stride[1]=vf->dmpi->stride[1]; |
30cad6ad9dbc
fix segfaults with slices. support slice rendering into a filter even
rfelker
parents:
9603
diff
changeset
|
227 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
|
228 } else { |
10140
30cad6ad9dbc
fix segfaults with slices. support slice rendering into a filter even
rfelker
parents:
9603
diff
changeset
|
229 mpi->planes[0]=vf->dmpi->planes[0]+ |
30cad6ad9dbc
fix segfaults with slices. support slice rendering into a filter even
rfelker
parents:
9603
diff
changeset
|
230 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
|
231 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
|
232 } |
10140
30cad6ad9dbc
fix segfaults with slices. support slice rendering into a filter even
rfelker
parents:
9603
diff
changeset
|
233 mpi->stride[0]=vf->dmpi->stride[0]; |
30cad6ad9dbc
fix segfaults with slices. support slice rendering into a filter even
rfelker
parents:
9603
diff
changeset
|
234 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
|
235 mpi->flags|=MP_IMGFLAG_DIRECT; |
9495 | 236 mpi->flags&=~MP_IMGFLAG_DRAW_CALLBACK; |
10140
30cad6ad9dbc
fix segfaults with slices. support slice rendering into a filter even
rfelker
parents:
9603
diff
changeset
|
237 // 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
|
238 } |
d0d029fda134
video filter layer - written from scratch, but inspired a lot by Fredrik Kuivinen's patch
arpi
parents:
diff
changeset
|
239 } |
d0d029fda134
video filter layer - written from scratch, but inspired a lot by Fredrik Kuivinen's patch
arpi
parents:
diff
changeset
|
240 |
9495 | 241 static void start_slice(struct vf_instance_s* vf, mp_image_t *mpi){ |
242 // printf("start_slice called! flag=%d\n",mpi->flags&MP_IMGFLAG_DRAW_CALLBACK); | |
243 if(!vf->next->draw_slice){ | |
244 mpi->flags&=~MP_IMGFLAG_DRAW_CALLBACK; | |
245 return; | |
246 } | |
247 // they want slices!!! allocate the buffer. | |
248 if(!mpi->priv) | |
10140
30cad6ad9dbc
fix segfaults with slices. support slice rendering into a filter even
rfelker
parents:
9603
diff
changeset
|
249 mpi->priv=vf->dmpi=vf_get_image(vf->next,mpi->imgfmt, |
9495 | 250 // MP_IMGTYPE_TEMP, MP_IMGFLAG_ACCEPT_STRIDE | MP_IMGFLAG_PREFER_ALIGNED_STRIDE, |
251 mpi->type, mpi->flags, | |
252 MAX(vf->priv->exp_w, mpi->width +vf->priv->exp_x), | |
253 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
|
254 if(!(vf->dmpi->flags&MP_IMGFLAG_DRAW_CALLBACK)) |
9495 | 255 printf("WARNING! next filter doesn't support SLICES, get ready for sig11...\n"); // shouldn't happen. |
256 } | |
257 | |
258 static void draw_slice(struct vf_instance_s* vf, | |
259 unsigned char** src, int* stride, int w,int h, int x, int y){ | |
260 // printf("draw_slice() called %d at %d\n",h,y); | |
261 vf_next_draw_slice(vf,src,stride,w,h,x+vf->priv->exp_x,y+vf->priv->exp_y); | |
262 } | |
263 | |
7368 | 264 static int put_image(struct vf_instance_s* vf, mp_image_t *mpi){ |
9495 | 265 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
|
266 vf->dmpi=mpi->priv; |
30cad6ad9dbc
fix segfaults with slices. support slice rendering into a filter even
rfelker
parents:
9603
diff
changeset
|
267 if(!vf->dmpi) { printf("Why do we get NULL \n"); return 0; } |
9495 | 268 mpi->priv=NULL; |
9582 | 269 if(mpi->flags&MP_IMGFLAG_DRAW_CALLBACK){ |
270 if(vf->priv->exp_y>0) | |
10140
30cad6ad9dbc
fix segfaults with slices. support slice rendering into a filter even
rfelker
parents:
9603
diff
changeset
|
271 vf_next_draw_slice(vf, vf->dmpi->planes, vf->dmpi->stride, |
30cad6ad9dbc
fix segfaults with slices. support slice rendering into a filter even
rfelker
parents:
9603
diff
changeset
|
272 vf->dmpi->w,vf->priv->exp_y,0,0); |
30cad6ad9dbc
fix segfaults with slices. support slice rendering into a filter even
rfelker
parents:
9603
diff
changeset
|
273 if(vf->priv->exp_y+mpi->h<vf->dmpi->h) |
30cad6ad9dbc
fix segfaults with slices. support slice rendering into a filter even
rfelker
parents:
9603
diff
changeset
|
274 vf_next_draw_slice(vf, vf->dmpi->planes, vf->dmpi->stride, |
30cad6ad9dbc
fix segfaults with slices. support slice rendering into a filter even
rfelker
parents:
9603
diff
changeset
|
275 vf->dmpi->w,vf->dmpi->h-(vf->priv->exp_y+mpi->h), |
9582 | 276 0,vf->priv->exp_y+mpi->h); |
277 } | |
5644
f1465a280612
(buggy) osd support, disabled for now, mencoder needs fixes to compile
arpi
parents:
5607
diff
changeset
|
278 #ifdef OSD_SUPPORT |
f1465a280612
(buggy) osd support, disabled for now, mencoder needs fixes to compile
arpi
parents:
5607
diff
changeset
|
279 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
|
280 #endif |
7368 | 281 // we've used DR, so we're ready... |
9279 | 282 if(!(mpi->flags&MP_IMGFLAG_PLANAR)) |
10140
30cad6ad9dbc
fix segfaults with slices. support slice rendering into a filter even
rfelker
parents:
9603
diff
changeset
|
283 vf->dmpi->planes[1] = mpi->planes[1]; // passthrough rgb8 palette |
30cad6ad9dbc
fix segfaults with slices. support slice rendering into a filter even
rfelker
parents:
9603
diff
changeset
|
284 return vf_next_put_image(vf,vf->dmpi); |
5507
d0d029fda134
video filter layer - written from scratch, but inspired a lot by Fredrik Kuivinen's patch
arpi
parents:
diff
changeset
|
285 } |
d0d029fda134
video filter layer - written from scratch, but inspired a lot by Fredrik Kuivinen's patch
arpi
parents:
diff
changeset
|
286 |
d0d029fda134
video filter layer - written from scratch, but inspired a lot by Fredrik Kuivinen's patch
arpi
parents:
diff
changeset
|
287 // hope we'll get DR buffer: |
10140
30cad6ad9dbc
fix segfaults with slices. support slice rendering into a filter even
rfelker
parents:
9603
diff
changeset
|
288 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
|
289 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
|
290 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
|
291 |
d0d029fda134
video filter layer - written from scratch, but inspired a lot by Fredrik Kuivinen's patch
arpi
parents:
diff
changeset
|
292 // copy mpi->dmpi... |
d0d029fda134
video filter layer - written from scratch, but inspired a lot by Fredrik Kuivinen's patch
arpi
parents:
diff
changeset
|
293 if(mpi->flags&MP_IMGFLAG_PLANAR){ |
10140
30cad6ad9dbc
fix segfaults with slices. support slice rendering into a filter even
rfelker
parents:
9603
diff
changeset
|
294 memcpy_pic(vf->dmpi->planes[0]+ |
30cad6ad9dbc
fix segfaults with slices. support slice rendering into a filter even
rfelker
parents:
9603
diff
changeset
|
295 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
|
296 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
|
297 vf->dmpi->stride[0],mpi->stride[0]); |
30cad6ad9dbc
fix segfaults with slices. support slice rendering into a filter even
rfelker
parents:
9603
diff
changeset
|
298 memcpy_pic(vf->dmpi->planes[1]+ |
30cad6ad9dbc
fix segfaults with slices. support slice rendering into a filter even
rfelker
parents:
9603
diff
changeset
|
299 (vf->priv->exp_y>>mpi->chroma_y_shift)*vf->dmpi->stride[1]+(vf->priv->exp_x>>mpi->chroma_x_shift), |
6539
79b536a37e40
better planar support, chroma subsampling support and Y8/Y800 support
alex
parents:
6537
diff
changeset
|
300 mpi->planes[1], mpi->chroma_width, mpi->chroma_height, |
10140
30cad6ad9dbc
fix segfaults with slices. support slice rendering into a filter even
rfelker
parents:
9603
diff
changeset
|
301 vf->dmpi->stride[1],mpi->stride[1]); |
30cad6ad9dbc
fix segfaults with slices. support slice rendering into a filter even
rfelker
parents:
9603
diff
changeset
|
302 memcpy_pic(vf->dmpi->planes[2]+ |
30cad6ad9dbc
fix segfaults with slices. support slice rendering into a filter even
rfelker
parents:
9603
diff
changeset
|
303 (vf->priv->exp_y>>mpi->chroma_y_shift)*vf->dmpi->stride[2]+(vf->priv->exp_x>>mpi->chroma_x_shift), |
6539
79b536a37e40
better planar support, chroma subsampling support and Y8/Y800 support
alex
parents:
6537
diff
changeset
|
304 mpi->planes[2], mpi->chroma_width, mpi->chroma_height, |
10140
30cad6ad9dbc
fix segfaults with slices. support slice rendering into a filter even
rfelker
parents:
9603
diff
changeset
|
305 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
|
306 } else { |
10140
30cad6ad9dbc
fix segfaults with slices. support slice rendering into a filter even
rfelker
parents:
9603
diff
changeset
|
307 memcpy_pic(vf->dmpi->planes[0]+ |
30cad6ad9dbc
fix segfaults with slices. support slice rendering into a filter even
rfelker
parents:
9603
diff
changeset
|
308 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
|
309 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
|
310 vf->dmpi->stride[0],mpi->stride[0]); |
30cad6ad9dbc
fix segfaults with slices. support slice rendering into a filter even
rfelker
parents:
9603
diff
changeset
|
311 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
|
312 } |
5644
f1465a280612
(buggy) osd support, disabled for now, mencoder needs fixes to compile
arpi
parents:
5607
diff
changeset
|
313 #ifdef OSD_SUPPORT |
f1465a280612
(buggy) osd support, disabled for now, mencoder needs fixes to compile
arpi
parents:
5607
diff
changeset
|
314 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
|
315 #endif |
10140
30cad6ad9dbc
fix segfaults with slices. support slice rendering into a filter even
rfelker
parents:
9603
diff
changeset
|
316 return vf_next_put_image(vf,vf->dmpi); |
5507
d0d029fda134
video filter layer - written from scratch, but inspired a lot by Fredrik Kuivinen's patch
arpi
parents:
diff
changeset
|
317 } |
d0d029fda134
video filter layer - written from scratch, but inspired a lot by Fredrik Kuivinen's patch
arpi
parents:
diff
changeset
|
318 |
d0d029fda134
video filter layer - written from scratch, but inspired a lot by Fredrik Kuivinen's patch
arpi
parents:
diff
changeset
|
319 //===========================================================================// |
d0d029fda134
video filter layer - written from scratch, but inspired a lot by Fredrik Kuivinen's patch
arpi
parents:
diff
changeset
|
320 |
5644
f1465a280612
(buggy) osd support, disabled for now, mencoder needs fixes to compile
arpi
parents:
5607
diff
changeset
|
321 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
|
322 #ifdef OSD_SUPPORT |
f1465a280612
(buggy) osd support, disabled for now, mencoder needs fixes to compile
arpi
parents:
5607
diff
changeset
|
323 switch(request){ |
f1465a280612
(buggy) osd support, disabled for now, mencoder needs fixes to compile
arpi
parents:
5607
diff
changeset
|
324 case VFCTRL_DRAW_OSD: |
f1465a280612
(buggy) osd support, disabled for now, mencoder needs fixes to compile
arpi
parents:
5607
diff
changeset
|
325 if(vf->priv->osd) return CONTROL_TRUE; |
f1465a280612
(buggy) osd support, disabled for now, mencoder needs fixes to compile
arpi
parents:
5607
diff
changeset
|
326 } |
f1465a280612
(buggy) osd support, disabled for now, mencoder needs fixes to compile
arpi
parents:
5607
diff
changeset
|
327 #endif |
f1465a280612
(buggy) osd support, disabled for now, mencoder needs fixes to compile
arpi
parents:
5607
diff
changeset
|
328 return vf_next_control(vf,request,data); |
f1465a280612
(buggy) osd support, disabled for now, mencoder needs fixes to compile
arpi
parents:
5607
diff
changeset
|
329 } |
f1465a280612
(buggy) osd support, disabled for now, mencoder needs fixes to compile
arpi
parents:
5607
diff
changeset
|
330 |
5507
d0d029fda134
video filter layer - written from scratch, but inspired a lot by Fredrik Kuivinen's patch
arpi
parents:
diff
changeset
|
331 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
|
332 vf->config=config; |
5644
f1465a280612
(buggy) osd support, disabled for now, mencoder needs fixes to compile
arpi
parents:
5607
diff
changeset
|
333 vf->control=control; |
9495 | 334 vf->start_slice=start_slice; |
335 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
|
336 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
|
337 vf->put_image=put_image; |
9594 | 338 if(!vf->priv) { |
5507
d0d029fda134
video filter layer - written from scratch, but inspired a lot by Fredrik Kuivinen's patch
arpi
parents:
diff
changeset
|
339 vf->priv=malloc(sizeof(struct vf_priv_s)); |
d0d029fda134
video filter layer - written from scratch, but inspired a lot by Fredrik Kuivinen's patch
arpi
parents:
diff
changeset
|
340 vf->priv->exp_x= |
d0d029fda134
video filter layer - written from scratch, but inspired a lot by Fredrik Kuivinen's patch
arpi
parents:
diff
changeset
|
341 vf->priv->exp_y= |
d0d029fda134
video filter layer - written from scratch, but inspired a lot by Fredrik Kuivinen's patch
arpi
parents:
diff
changeset
|
342 vf->priv->exp_w= |
d0d029fda134
video filter layer - written from scratch, but inspired a lot by Fredrik Kuivinen's patch
arpi
parents:
diff
changeset
|
343 vf->priv->exp_h=-1; |
7768 | 344 vf->priv->osd=0; |
345 // parse args -> | |
9594 | 346 } // if(!vf->priv) |
5644
f1465a280612
(buggy) osd support, disabled for now, mencoder needs fixes to compile
arpi
parents:
5607
diff
changeset
|
347 if(args) sscanf(args, "%d:%d:%d:%d:%d", |
5507
d0d029fda134
video filter layer - written from scratch, but inspired a lot by Fredrik Kuivinen's patch
arpi
parents:
diff
changeset
|
348 &vf->priv->exp_w, |
d0d029fda134
video filter layer - written from scratch, but inspired a lot by Fredrik Kuivinen's patch
arpi
parents:
diff
changeset
|
349 &vf->priv->exp_h, |
d0d029fda134
video filter layer - written from scratch, but inspired a lot by Fredrik Kuivinen's patch
arpi
parents:
diff
changeset
|
350 &vf->priv->exp_x, |
5644
f1465a280612
(buggy) osd support, disabled for now, mencoder needs fixes to compile
arpi
parents:
5607
diff
changeset
|
351 &vf->priv->exp_y, |
f1465a280612
(buggy) osd support, disabled for now, mencoder needs fixes to compile
arpi
parents:
5607
diff
changeset
|
352 &vf->priv->osd); |
8869
9df3c03b2ffe
use mp_msg for messages. prolly more filters need to be fixed like this too
rfelker
parents:
7768
diff
changeset
|
353 mp_msg(MSGT_VFILTER, MSGL_INFO, "Expand: %d x %d, %d ; %d (-1=autodetect) osd: %d\n", |
5507
d0d029fda134
video filter layer - written from scratch, but inspired a lot by Fredrik Kuivinen's patch
arpi
parents:
diff
changeset
|
354 vf->priv->exp_w, |
d0d029fda134
video filter layer - written from scratch, but inspired a lot by Fredrik Kuivinen's patch
arpi
parents:
diff
changeset
|
355 vf->priv->exp_h, |
d0d029fda134
video filter layer - written from scratch, but inspired a lot by Fredrik Kuivinen's patch
arpi
parents:
diff
changeset
|
356 vf->priv->exp_x, |
5644
f1465a280612
(buggy) osd support, disabled for now, mencoder needs fixes to compile
arpi
parents:
5607
diff
changeset
|
357 vf->priv->exp_y, |
f1465a280612
(buggy) osd support, disabled for now, mencoder needs fixes to compile
arpi
parents:
5607
diff
changeset
|
358 vf->priv->osd); |
5507
d0d029fda134
video filter layer - written from scratch, but inspired a lot by Fredrik Kuivinen's patch
arpi
parents:
diff
changeset
|
359 return 1; |
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 |
9594 | 362 #define ST_OFF(f) M_ST_OFF(struct vf_priv_s,f) |
363 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
|
364 {"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
|
365 {"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
|
366 {"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
|
367 {"y", ST_OFF(exp_y), CONF_TYPE_INT, M_OPT_MIN, -1, 0, NULL}, |
9594 | 368 {"osd", ST_OFF(osd), CONF_TYPE_FLAG, 0 , 0, 1, NULL}, |
369 { NULL, NULL, 0, 0, 0, 0, NULL } | |
370 }; | |
371 | |
372 static m_struct_t vf_opts = { | |
373 "expand", | |
374 sizeof(struct vf_priv_s), | |
375 &vf_priv_dflt, | |
376 vf_opts_fields | |
377 }; | |
378 | |
379 | |
380 | |
5507
d0d029fda134
video filter layer - written from scratch, but inspired a lot by Fredrik Kuivinen's patch
arpi
parents:
diff
changeset
|
381 vf_info_t vf_info_expand = { |
5644
f1465a280612
(buggy) osd support, disabled for now, mencoder needs fixes to compile
arpi
parents:
5607
diff
changeset
|
382 #ifdef OSD_SUPPORT |
f1465a280612
(buggy) osd support, disabled for now, mencoder needs fixes to compile
arpi
parents:
5607
diff
changeset
|
383 "expanding & osd", |
f1465a280612
(buggy) osd support, disabled for now, mencoder needs fixes to compile
arpi
parents:
5607
diff
changeset
|
384 #else |
5507
d0d029fda134
video filter layer - written from scratch, but inspired a lot by Fredrik Kuivinen's patch
arpi
parents:
diff
changeset
|
385 "expanding", |
5644
f1465a280612
(buggy) osd support, disabled for now, mencoder needs fixes to compile
arpi
parents:
5607
diff
changeset
|
386 #endif |
5507
d0d029fda134
video filter layer - written from scratch, but inspired a lot by Fredrik Kuivinen's patch
arpi
parents:
diff
changeset
|
387 "expand", |
d0d029fda134
video filter layer - written from scratch, but inspired a lot by Fredrik Kuivinen's patch
arpi
parents:
diff
changeset
|
388 "A'rpi", |
d0d029fda134
video filter layer - written from scratch, but inspired a lot by Fredrik Kuivinen's patch
arpi
parents:
diff
changeset
|
389 "", |
9593
e9a2af584986
Add the new -vf option wich is the same as vop in reverse order.
albeu
parents:
9582
diff
changeset
|
390 open, |
9594 | 391 &vf_opts |
5507
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 //===========================================================================// |