annotate libmpcodecs/vf_expand.c @ 9986:4bdd248d372e

Start fixing gabbucino changes that broke the package. Those can go back when package gets overhaul.
author eyck
date Fri, 25 Apr 2003 13:57:17 +0000
parents f9222b8a5166
children 30cad6ad9dbc
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
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
1972c3475d93 mp_image.h and img_format.h moved to libmpcodecs
arpi
parents: 5530
diff changeset
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
a4b6e7caaa4b Add support for the new option stuff.
albeu
parents: 9593
diff changeset
21 #include "m_option.h"
a4b6e7caaa4b Add support for the new option stuff.
albeu
parents: 9593
diff changeset
22 #include "m_struct.h"
a4b6e7caaa4b Add support for the new option stuff.
albeu
parents: 9593
diff changeset
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
a4b6e7caaa4b Add support for the new option stuff.
albeu
parents: 9593
diff changeset
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;
d0d029fda134 video filter layer - written from scratch, but inspired a lot by Fredrik Kuivinen's patch
arpi
parents:
diff changeset
29 mp_image_t *dmpi;
5644
f1465a280612 (buggy) osd support, disabled for now, mencoder needs fixes to compile
arpi
parents: 5607
diff changeset
30 int osd;
5669
391931fa79a6 enabled new OSD code in -vop expand, subtitles rendering support to mencoder
arpi
parents: 5644
diff changeset
31 unsigned char* fb_ptr;
9594
a4b6e7caaa4b Add support for the new option stuff.
albeu
parents: 9593
diff changeset
32 } vf_priv_dflt = {
a4b6e7caaa4b Add support for the new option stuff.
albeu
parents: 9593
diff changeset
33 -1,-1,
a4b6e7caaa4b Add support for the new option stuff.
albeu
parents: 9593
diff changeset
34 -1,-1,
a4b6e7caaa4b Add support for the new option stuff.
albeu
parents: 9593
diff changeset
35 NULL,
a4b6e7caaa4b Add support for the new option stuff.
albeu
parents: 9593
diff changeset
36 0,
a4b6e7caaa4b Add support for the new option stuff.
albeu
parents: 9593
diff changeset
37 NULL
5507
d0d029fda134 video filter layer - written from scratch, but inspired a lot by Fredrik Kuivinen's patch
arpi
parents:
diff changeset
38 };
d0d029fda134 video filter layer - written from scratch, but inspired a lot by Fredrik Kuivinen's patch
arpi
parents:
diff changeset
39
6060
61f39b98ba4d keep aspect ratio - based on Fredrik Kuivinen's idea
arpi
parents: 5921
diff changeset
40 extern int opt_screen_size_x;
61f39b98ba4d keep aspect ratio - based on Fredrik Kuivinen's idea
arpi
parents: 5921
diff changeset
41 extern int opt_screen_size_y;
61f39b98ba4d keep aspect ratio - based on Fredrik Kuivinen's idea
arpi
parents: 5921
diff changeset
42
5507
d0d029fda134 video filter layer - written from scratch, but inspired a lot by Fredrik Kuivinen's patch
arpi
parents:
diff changeset
43 //===========================================================================//
5644
f1465a280612 (buggy) osd support, disabled for now, mencoder needs fixes to compile
arpi
parents: 5607
diff changeset
44 #ifdef OSD_SUPPORT
f1465a280612 (buggy) osd support, disabled for now, mencoder needs fixes to compile
arpi
parents: 5607
diff changeset
45
f1465a280612 (buggy) osd support, disabled for now, mencoder needs fixes to compile
arpi
parents: 5607
diff changeset
46 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
47 static int orig_w,orig_h;
f1465a280612 (buggy) osd support, disabled for now, mencoder needs fixes to compile
arpi
parents: 5607
diff changeset
48
f1465a280612 (buggy) osd support, disabled for now, mencoder needs fixes to compile
arpi
parents: 5607
diff changeset
49 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
50 // 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
51 //printf("OSD clear: %d;%d %dx%d \n",x0,y0,w,h);
391931fa79a6 enabled new OSD code in -vop expand, subtitles rendering support to mencoder
arpi
parents: 5644
diff changeset
52 vf_mpi_clear(vf->priv->dmpi,x0,y0,w,h);
5644
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
f1465a280612 (buggy) osd support, disabled for now, mencoder needs fixes to compile
arpi
parents: 5607
diff changeset
55 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
56 if(!vo_osd_changed_flag) return;
f1465a280612 (buggy) osd support, disabled for now, mencoder needs fixes to compile
arpi
parents: 5607
diff changeset
57 // split it to 4 parts:
f1465a280612 (buggy) osd support, disabled for now, mencoder needs fixes to compile
arpi
parents: 5607
diff changeset
58 if(y0<vf->priv->exp_y){
f1465a280612 (buggy) osd support, disabled for now, mencoder needs fixes to compile
arpi
parents: 5607
diff changeset
59 // it has parts above the image:
f1465a280612 (buggy) osd support, disabled for now, mencoder needs fixes to compile
arpi
parents: 5607
diff changeset
60 int y=y0+h;
f1465a280612 (buggy) osd support, disabled for now, mencoder needs fixes to compile
arpi
parents: 5607
diff changeset
61 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
62 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
63 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
64 h-=y-y0;y0=y;
f1465a280612 (buggy) osd support, disabled for now, mencoder needs fixes to compile
arpi
parents: 5607
diff changeset
65 }
f1465a280612 (buggy) osd support, disabled for now, mencoder needs fixes to compile
arpi
parents: 5607
diff changeset
66 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
67 // it has parts under the image:
f1465a280612 (buggy) osd support, disabled for now, mencoder needs fixes to compile
arpi
parents: 5607
diff changeset
68 int y=y0;
f1465a280612 (buggy) osd support, disabled for now, mencoder needs fixes to compile
arpi
parents: 5607
diff changeset
69 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
70 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
71 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
72 h=y-y0;
f1465a280612 (buggy) osd support, disabled for now, mencoder needs fixes to compile
arpi
parents: 5607
diff changeset
73 }
f1465a280612 (buggy) osd support, disabled for now, mencoder needs fixes to compile
arpi
parents: 5607
diff changeset
74 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
75 // 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
76 }
f1465a280612 (buggy) osd support, disabled for now, mencoder needs fixes to compile
arpi
parents: 5607
diff changeset
77
f1465a280612 (buggy) osd support, disabled for now, mencoder needs fixes to compile
arpi
parents: 5607
diff changeset
78 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
79 unsigned char* dst;
391931fa79a6 enabled new OSD code in -vop expand, subtitles rendering support to mencoder
arpi
parents: 5644
diff changeset
80 if(!vo_osd_changed_flag && vf->priv->dmpi->planes[0]==vf->priv->fb_ptr){
391931fa79a6 enabled new OSD code in -vop expand, subtitles rendering support to mencoder
arpi
parents: 5644
diff changeset
81 // 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
82 // untouched!
391931fa79a6 enabled new OSD code in -vop expand, subtitles rendering support to mencoder
arpi
parents: 5644
diff changeset
83 if(x0<vf->priv->exp_x){
391931fa79a6 enabled new OSD code in -vop expand, subtitles rendering support to mencoder
arpi
parents: 5644
diff changeset
84 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
85 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
86 }
391931fa79a6 enabled new OSD code in -vop expand, subtitles rendering support to mencoder
arpi
parents: 5644
diff changeset
87 if(y0<vf->priv->exp_y){
391931fa79a6 enabled new OSD code in -vop expand, subtitles rendering support to mencoder
arpi
parents: 5644
diff changeset
88 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
89 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
90 }
391931fa79a6 enabled new OSD code in -vop expand, subtitles rendering support to mencoder
arpi
parents: 5644
diff changeset
91 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
92 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
93 }
391931fa79a6 enabled new OSD code in -vop expand, subtitles rendering support to mencoder
arpi
parents: 5644
diff changeset
94 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
95 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
96 }
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(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
99 // printf("OSD redraw: %d;%d %dx%d \n",x0,y0,w,h);
391931fa79a6 enabled new OSD code in -vop expand, subtitles rendering support to mencoder
arpi
parents: 5644
diff changeset
100 dst=vf->priv->dmpi->planes[0]+
5644
f1465a280612 (buggy) osd support, disabled for now, mencoder needs fixes to compile
arpi
parents: 5607
diff changeset
101 vf->priv->dmpi->stride[0]*y0+
f1465a280612 (buggy) osd support, disabled for now, mencoder needs fixes to compile
arpi
parents: 5607
diff changeset
102 (vf->priv->dmpi->bpp>>3)*x0;
f1465a280612 (buggy) osd support, disabled for now, mencoder needs fixes to compile
arpi
parents: 5607
diff changeset
103 switch(vf->priv->dmpi->imgfmt){
f1465a280612 (buggy) osd support, disabled for now, mencoder needs fixes to compile
arpi
parents: 5607
diff changeset
104 case IMGFMT_BGR15:
f1465a280612 (buggy) osd support, disabled for now, mencoder needs fixes to compile
arpi
parents: 5607
diff changeset
105 case IMGFMT_RGB15:
f1465a280612 (buggy) osd support, disabled for now, mencoder needs fixes to compile
arpi
parents: 5607
diff changeset
106 vo_draw_alpha_rgb15(w,h,src,srca,stride,dst,vf->priv->dmpi->stride[0]);
f1465a280612 (buggy) osd support, disabled for now, mencoder needs fixes to compile
arpi
parents: 5607
diff changeset
107 break;
f1465a280612 (buggy) osd support, disabled for now, mencoder needs fixes to compile
arpi
parents: 5607
diff changeset
108 case IMGFMT_BGR16:
f1465a280612 (buggy) osd support, disabled for now, mencoder needs fixes to compile
arpi
parents: 5607
diff changeset
109 case IMGFMT_RGB16:
f1465a280612 (buggy) osd support, disabled for now, mencoder needs fixes to compile
arpi
parents: 5607
diff changeset
110 vo_draw_alpha_rgb16(w,h,src,srca,stride,dst,vf->priv->dmpi->stride[0]);
f1465a280612 (buggy) osd support, disabled for now, mencoder needs fixes to compile
arpi
parents: 5607
diff changeset
111 break;
f1465a280612 (buggy) osd support, disabled for now, mencoder needs fixes to compile
arpi
parents: 5607
diff changeset
112 case IMGFMT_BGR24:
f1465a280612 (buggy) osd support, disabled for now, mencoder needs fixes to compile
arpi
parents: 5607
diff changeset
113 case IMGFMT_RGB24:
f1465a280612 (buggy) osd support, disabled for now, mencoder needs fixes to compile
arpi
parents: 5607
diff changeset
114 vo_draw_alpha_rgb24(w,h,src,srca,stride,dst,vf->priv->dmpi->stride[0]);
f1465a280612 (buggy) osd support, disabled for now, mencoder needs fixes to compile
arpi
parents: 5607
diff changeset
115 break;
f1465a280612 (buggy) osd support, disabled for now, mencoder needs fixes to compile
arpi
parents: 5607
diff changeset
116 case IMGFMT_BGR32:
f1465a280612 (buggy) osd support, disabled for now, mencoder needs fixes to compile
arpi
parents: 5607
diff changeset
117 case IMGFMT_RGB32:
f1465a280612 (buggy) osd support, disabled for now, mencoder needs fixes to compile
arpi
parents: 5607
diff changeset
118 vo_draw_alpha_rgb32(w,h,src,srca,stride,dst,vf->priv->dmpi->stride[0]);
f1465a280612 (buggy) osd support, disabled for now, mencoder needs fixes to compile
arpi
parents: 5607
diff changeset
119 break;
f1465a280612 (buggy) osd support, disabled for now, mencoder needs fixes to compile
arpi
parents: 5607
diff changeset
120 case IMGFMT_YV12:
f1465a280612 (buggy) osd support, disabled for now, mencoder needs fixes to compile
arpi
parents: 5607
diff changeset
121 case IMGFMT_I420:
f1465a280612 (buggy) osd support, disabled for now, mencoder needs fixes to compile
arpi
parents: 5607
diff changeset
122 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
123 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
124 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
125 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
126 case IMGFMT_Y8:
5644
f1465a280612 (buggy) osd support, disabled for now, mencoder needs fixes to compile
arpi
parents: 5607
diff changeset
127 vo_draw_alpha_yv12(w,h,src,srca,stride,dst,vf->priv->dmpi->stride[0]);
f1465a280612 (buggy) osd support, disabled for now, mencoder needs fixes to compile
arpi
parents: 5607
diff changeset
128 break;
f1465a280612 (buggy) osd support, disabled for now, mencoder needs fixes to compile
arpi
parents: 5607
diff changeset
129 case IMGFMT_YUY2:
f1465a280612 (buggy) osd support, disabled for now, mencoder needs fixes to compile
arpi
parents: 5607
diff changeset
130 vo_draw_alpha_yuy2(w,h,src,srca,stride,dst,vf->priv->dmpi->stride[0]);
f1465a280612 (buggy) osd support, disabled for now, mencoder needs fixes to compile
arpi
parents: 5607
diff changeset
131 break;
f1465a280612 (buggy) osd support, disabled for now, mencoder needs fixes to compile
arpi
parents: 5607
diff changeset
132 case IMGFMT_UYVY:
f1465a280612 (buggy) osd support, disabled for now, mencoder needs fixes to compile
arpi
parents: 5607
diff changeset
133 vo_draw_alpha_yuy2(w,h,src,srca,stride,dst+1,vf->priv->dmpi->stride[0]);
f1465a280612 (buggy) osd support, disabled for now, mencoder needs fixes to compile
arpi
parents: 5607
diff changeset
134 break;
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
f1465a280612 (buggy) osd support, disabled for now, mencoder needs fixes to compile
arpi
parents: 5607
diff changeset
138 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
139 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
140 // printf("======================================\n");
5644
f1465a280612 (buggy) osd support, disabled for now, mencoder needs fixes to compile
arpi
parents: 5607
diff changeset
141 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
142 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
143 // yep, we're expanding image, not just copy.
391931fa79a6 enabled new OSD code in -vop expand, subtitles rendering support to mencoder
arpi
parents: 5644
diff changeset
144 if(vf->priv->dmpi->planes[0]!=vf->priv->fb_ptr){
391931fa79a6 enabled new OSD code in -vop expand, subtitles rendering support to mencoder
arpi
parents: 5644
diff changeset
145 // 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
146 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
147 } else {
391931fa79a6 enabled new OSD code in -vop expand, subtitles rendering support to mencoder
arpi
parents: 5644
diff changeset
148 // partial clear:
391931fa79a6 enabled new OSD code in -vop expand, subtitles rendering support to mencoder
arpi
parents: 5644
diff changeset
149 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
150 }
5644
f1465a280612 (buggy) osd support, disabled for now, mencoder needs fixes to compile
arpi
parents: 5607
diff changeset
151 }
f1465a280612 (buggy) osd support, disabled for now, mencoder needs fixes to compile
arpi
parents: 5607
diff changeset
152 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
153 // 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
154 // ugly method, but note that codecs with DR support does the same...
9594
a4b6e7caaa4b Add support for the new option stuff.
albeu
parents: 9593
diff changeset
155 if(vf->priv->dmpi)
a4b6e7caaa4b Add support for the new option stuff.
albeu
parents: 9593
diff changeset
156 vf->priv->fb_ptr=vf->priv->dmpi->planes[0];
5644
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
f1465a280612 (buggy) osd support, disabled for now, mencoder needs fixes to compile
arpi
parents: 5607
diff changeset
159 #endif
f1465a280612 (buggy) osd support, disabled for now, mencoder needs fixes to compile
arpi
parents: 5607
diff changeset
160 //===========================================================================//
5507
d0d029fda134 video filter layer - written from scratch, but inspired a lot by Fredrik Kuivinen's patch
arpi
parents:
diff changeset
161
d0d029fda134 video filter layer - written from scratch, but inspired a lot by Fredrik Kuivinen's patch
arpi
parents:
diff changeset
162 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
163 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
164 unsigned int flags, unsigned int outfmt){
6525
0a7be46617d8 yvu9 and if09 support
alex
parents: 6060
diff changeset
165 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
166 // calculate the missing parameters:
5921
20ccb89222bc expand=-1:-50:0:0 -> mwidth:mheight+50:0:0
pontscho
parents: 5878
diff changeset
167 #if 0
5507
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_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
169 if(vf->priv->exp_h<height) vf->priv->exp_h=height;
5921
20ccb89222bc expand=-1:-50:0:0 -> mwidth:mheight+50:0:0
pontscho
parents: 5878
diff changeset
170 #else
20ccb89222bc expand=-1:-50:0:0 -> mwidth:mheight+50:0:0
pontscho
parents: 5878
diff changeset
171 if ( vf->priv->exp_w == -1 ) vf->priv->exp_w=width;
20ccb89222bc expand=-1:-50:0:0 -> mwidth:mheight+50:0:0
pontscho
parents: 5878
diff changeset
172 else if (vf->priv->exp_w < -1 ) vf->priv->exp_w=width - vf->priv->exp_w;
20ccb89222bc expand=-1:-50:0:0 -> mwidth:mheight+50:0:0
pontscho
parents: 5878
diff changeset
173 else if ( vf->priv->exp_w<width ) vf->priv->exp_w=width;
20ccb89222bc expand=-1:-50:0:0 -> mwidth:mheight+50:0:0
pontscho
parents: 5878
diff changeset
174 if ( vf->priv->exp_h == -1 ) vf->priv->exp_h=height;
20ccb89222bc expand=-1:-50:0:0 -> mwidth:mheight+50:0:0
pontscho
parents: 5878
diff changeset
175 else if ( vf->priv->exp_h < -1 ) vf->priv->exp_h=height - vf->priv->exp_h;
20ccb89222bc expand=-1:-50:0:0 -> mwidth:mheight+50:0:0
pontscho
parents: 5878
diff changeset
176 else if( vf->priv->exp_h<height ) vf->priv->exp_h=height;
20ccb89222bc expand=-1:-50:0:0 -> mwidth:mheight+50:0:0
pontscho
parents: 5878
diff changeset
177 #endif
5687
f19dff1456ed don't allow invalid parameters
arpi
parents: 5671
diff changeset
178 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;
f19dff1456ed don't allow invalid parameters
arpi
parents: 5671
diff changeset
179 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
180 vf->priv->fb_ptr=NULL;
6060
61f39b98ba4d keep aspect ratio - based on Fredrik Kuivinen's idea
arpi
parents: 5921
diff changeset
181
61f39b98ba4d keep aspect ratio - based on Fredrik Kuivinen's idea
arpi
parents: 5921
diff changeset
182 if(!opt_screen_size_x && !opt_screen_size_y){
61f39b98ba4d keep aspect ratio - based on Fredrik Kuivinen's idea
arpi
parents: 5921
diff changeset
183 d_width=d_width*vf->priv->exp_w/width;
61f39b98ba4d keep aspect ratio - based on Fredrik Kuivinen's idea
arpi
parents: 5921
diff changeset
184 d_height=d_height*vf->priv->exp_h/height;
61f39b98ba4d keep aspect ratio - based on Fredrik Kuivinen's idea
arpi
parents: 5921
diff changeset
185 }
61f39b98ba4d keep aspect ratio - based on Fredrik Kuivinen's idea
arpi
parents: 5921
diff changeset
186 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
187 }
d0d029fda134 video filter layer - written from scratch, but inspired a lot by Fredrik Kuivinen's patch
arpi
parents:
diff changeset
188
d0d029fda134 video filter layer - written from scratch, but inspired a lot by Fredrik Kuivinen's patch
arpi
parents:
diff changeset
189 // there are 4 cases:
d0d029fda134 video filter layer - written from scratch, but inspired a lot by Fredrik Kuivinen's patch
arpi
parents:
diff changeset
190 // 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
191 // 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
192 // 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
193 // 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
194
d0d029fda134 video filter layer - written from scratch, but inspired a lot by Fredrik Kuivinen's patch
arpi
parents:
diff changeset
195 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
196 // 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
197 #ifdef OSD_SUPPORT
f1465a280612 (buggy) osd support, disabled for now, mencoder needs fixes to compile
arpi
parents: 5607
diff changeset
198 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
199 // check if we have to render osd!
f1465a280612 (buggy) osd support, disabled for now, mencoder needs fixes to compile
arpi
parents: 5607
diff changeset
200 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
201 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
202 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
203 }
f1465a280612 (buggy) osd support, disabled for now, mencoder needs fixes to compile
arpi
parents: 5607
diff changeset
204 #endif
5507
d0d029fda134 video filter layer - written from scratch, but inspired a lot by Fredrik Kuivinen's patch
arpi
parents:
diff changeset
205 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
206 (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
207 // try full DR !
9495
2837f8da12c4 experimental slices support
arpi
parents: 9279
diff changeset
208 mpi->priv=vf->priv->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
209 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
210 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
211 MAX(vf->priv->exp_h, mpi->height+vf->priv->exp_y));
9495
2837f8da12c4 experimental slices support
arpi
parents: 9279
diff changeset
212 #if 1
2837f8da12c4 experimental slices support
arpi
parents: 9279
diff changeset
213 if((vf->priv->dmpi->flags & MP_IMGFLAG_DRAW_CALLBACK) &&
2837f8da12c4 experimental slices support
arpi
parents: 9279
diff changeset
214 !(vf->priv->dmpi->flags & MP_IMGFLAG_DIRECT)){
2837f8da12c4 experimental slices support
arpi
parents: 9279
diff changeset
215 printf("Full DR not possible, trying SLICES instead!\n");
2837f8da12c4 experimental slices support
arpi
parents: 9279
diff changeset
216 return;
2837f8da12c4 experimental slices support
arpi
parents: 9279
diff changeset
217 }
2837f8da12c4 experimental slices support
arpi
parents: 9279
diff changeset
218 #endif
5507
d0d029fda134 video filter layer - written from scratch, but inspired a lot by Fredrik Kuivinen's patch
arpi
parents:
diff changeset
219 // 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
220 if(mpi->flags&MP_IMGFLAG_PLANAR){
d0d029fda134 video filter layer - written from scratch, but inspired a lot by Fredrik Kuivinen's patch
arpi
parents:
diff changeset
221 mpi->planes[0]=vf->priv->dmpi->planes[0]+
d0d029fda134 video filter layer - written from scratch, but inspired a lot by Fredrik Kuivinen's patch
arpi
parents:
diff changeset
222 vf->priv->exp_y*vf->priv->dmpi->stride[0]+vf->priv->exp_x;
6525
0a7be46617d8 yvu9 and if09 support
alex
parents: 6060
diff changeset
223 mpi->planes[1]=vf->priv->dmpi->planes[1]+
6539
79b536a37e40 better planar support, chroma subsampling support and Y8/Y800 support
alex
parents: 6537
diff changeset
224 (vf->priv->exp_y>>mpi->chroma_y_shift)*vf->priv->dmpi->stride[1]+(vf->priv->exp_x>>mpi->chroma_x_shift);
6525
0a7be46617d8 yvu9 and if09 support
alex
parents: 6060
diff changeset
225 mpi->planes[2]=vf->priv->dmpi->planes[2]+
6539
79b536a37e40 better planar support, chroma subsampling support and Y8/Y800 support
alex
parents: 6537
diff changeset
226 (vf->priv->exp_y>>mpi->chroma_y_shift)*vf->priv->dmpi->stride[2]+(vf->priv->exp_x>>mpi->chroma_x_shift);
5507
d0d029fda134 video filter layer - written from scratch, but inspired a lot by Fredrik Kuivinen's patch
arpi
parents:
diff changeset
227 mpi->stride[1]=vf->priv->dmpi->stride[1];
d0d029fda134 video filter layer - written from scratch, but inspired a lot by Fredrik Kuivinen's patch
arpi
parents:
diff changeset
228 mpi->stride[2]=vf->priv->dmpi->stride[2];
d0d029fda134 video filter layer - written from scratch, but inspired a lot by Fredrik Kuivinen's patch
arpi
parents:
diff changeset
229 } else {
d0d029fda134 video filter layer - written from scratch, but inspired a lot by Fredrik Kuivinen's patch
arpi
parents:
diff changeset
230 mpi->planes[0]=vf->priv->dmpi->planes[0]+
d0d029fda134 video filter layer - written from scratch, but inspired a lot by Fredrik Kuivinen's patch
arpi
parents:
diff changeset
231 vf->priv->exp_y*vf->priv->dmpi->stride[0]+
d0d029fda134 video filter layer - written from scratch, but inspired a lot by Fredrik Kuivinen's patch
arpi
parents:
diff changeset
232 vf->priv->exp_x*(vf->priv->dmpi->bpp/8);
d0d029fda134 video filter layer - written from scratch, but inspired a lot by Fredrik Kuivinen's patch
arpi
parents:
diff changeset
233 }
5530
e974e82be748 copy width too
arpi
parents: 5507
diff changeset
234 mpi->stride[0]=vf->priv->dmpi->stride[0];
e974e82be748 copy width too
arpi
parents: 5507
diff changeset
235 mpi->width=vf->priv->dmpi->width;
5507
d0d029fda134 video filter layer - written from scratch, but inspired a lot by Fredrik Kuivinen's patch
arpi
parents:
diff changeset
236 mpi->flags|=MP_IMGFLAG_DIRECT;
9495
2837f8da12c4 experimental slices support
arpi
parents: 9279
diff changeset
237 mpi->flags&=~MP_IMGFLAG_DRAW_CALLBACK;
2837f8da12c4 experimental slices support
arpi
parents: 9279
diff changeset
238 // vf->priv->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
239 }
d0d029fda134 video filter layer - written from scratch, but inspired a lot by Fredrik Kuivinen's patch
arpi
parents:
diff changeset
240 }
d0d029fda134 video filter layer - written from scratch, but inspired a lot by Fredrik Kuivinen's patch
arpi
parents:
diff changeset
241
9495
2837f8da12c4 experimental slices support
arpi
parents: 9279
diff changeset
242 static void start_slice(struct vf_instance_s* vf, mp_image_t *mpi){
2837f8da12c4 experimental slices support
arpi
parents: 9279
diff changeset
243 // printf("start_slice called! flag=%d\n",mpi->flags&MP_IMGFLAG_DRAW_CALLBACK);
2837f8da12c4 experimental slices support
arpi
parents: 9279
diff changeset
244 if(!vf->next->draw_slice){
2837f8da12c4 experimental slices support
arpi
parents: 9279
diff changeset
245 mpi->flags&=~MP_IMGFLAG_DRAW_CALLBACK;
2837f8da12c4 experimental slices support
arpi
parents: 9279
diff changeset
246 return;
2837f8da12c4 experimental slices support
arpi
parents: 9279
diff changeset
247 }
2837f8da12c4 experimental slices support
arpi
parents: 9279
diff changeset
248 // they want slices!!! allocate the buffer.
2837f8da12c4 experimental slices support
arpi
parents: 9279
diff changeset
249 if(!mpi->priv)
2837f8da12c4 experimental slices support
arpi
parents: 9279
diff changeset
250 mpi->priv=vf->priv->dmpi=vf_get_image(vf->next,mpi->imgfmt,
2837f8da12c4 experimental slices support
arpi
parents: 9279
diff changeset
251 // MP_IMGTYPE_TEMP, MP_IMGFLAG_ACCEPT_STRIDE | MP_IMGFLAG_PREFER_ALIGNED_STRIDE,
2837f8da12c4 experimental slices support
arpi
parents: 9279
diff changeset
252 mpi->type, mpi->flags,
2837f8da12c4 experimental slices support
arpi
parents: 9279
diff changeset
253 MAX(vf->priv->exp_w, mpi->width +vf->priv->exp_x),
2837f8da12c4 experimental slices support
arpi
parents: 9279
diff changeset
254 MAX(vf->priv->exp_h, mpi->height+vf->priv->exp_y));
2837f8da12c4 experimental slices support
arpi
parents: 9279
diff changeset
255 if(!(vf->priv->dmpi->flags&MP_IMGFLAG_DRAW_CALLBACK))
2837f8da12c4 experimental slices support
arpi
parents: 9279
diff changeset
256 printf("WARNING! next filter doesn't support SLICES, get ready for sig11...\n"); // shouldn't happen.
2837f8da12c4 experimental slices support
arpi
parents: 9279
diff changeset
257 }
2837f8da12c4 experimental slices support
arpi
parents: 9279
diff changeset
258
2837f8da12c4 experimental slices support
arpi
parents: 9279
diff changeset
259 static void draw_slice(struct vf_instance_s* vf,
2837f8da12c4 experimental slices support
arpi
parents: 9279
diff changeset
260 unsigned char** src, int* stride, int w,int h, int x, int y){
2837f8da12c4 experimental slices support
arpi
parents: 9279
diff changeset
261 // printf("draw_slice() called %d at %d\n",h,y);
2837f8da12c4 experimental slices support
arpi
parents: 9279
diff changeset
262 vf_next_draw_slice(vf,src,stride,w,h,x+vf->priv->exp_x,y+vf->priv->exp_y);
2837f8da12c4 experimental slices support
arpi
parents: 9279
diff changeset
263 }
2837f8da12c4 experimental slices support
arpi
parents: 9279
diff changeset
264
7368
a894e99c1e51 changing return type of put_image void->int
arpi
parents: 7052
diff changeset
265 static int put_image(struct vf_instance_s* vf, mp_image_t *mpi){
9495
2837f8da12c4 experimental slices support
arpi
parents: 9279
diff changeset
266 if(mpi->flags&MP_IMGFLAG_DIRECT || mpi->flags&MP_IMGFLAG_DRAW_CALLBACK){
6761
cb1180ccac76 DR1+IPB support (works only with ffmpeg12, as libmpeg2 doesn't accept stride)
arpi
parents: 6539
diff changeset
267 vf->priv->dmpi=mpi->priv;
9594
a4b6e7caaa4b Add support for the new option stuff.
albeu
parents: 9593
diff changeset
268 if(!vf->priv->dmpi) { printf("Why do we get NULL \n"); return 0; }
9495
2837f8da12c4 experimental slices support
arpi
parents: 9279
diff changeset
269 mpi->priv=NULL;
9582
c9012dcd3a70 clear black bands when using slices
arpi
parents: 9495
diff changeset
270 if(mpi->flags&MP_IMGFLAG_DRAW_CALLBACK){
c9012dcd3a70 clear black bands when using slices
arpi
parents: 9495
diff changeset
271 if(vf->priv->exp_y>0)
c9012dcd3a70 clear black bands when using slices
arpi
parents: 9495
diff changeset
272 vf_next_draw_slice(vf, vf->priv->dmpi->planes, vf->priv->dmpi->stride,
c9012dcd3a70 clear black bands when using slices
arpi
parents: 9495
diff changeset
273 vf->priv->dmpi->w,vf->priv->exp_y,0,0);
c9012dcd3a70 clear black bands when using slices
arpi
parents: 9495
diff changeset
274 if(vf->priv->exp_y+mpi->h<vf->priv->dmpi->h)
c9012dcd3a70 clear black bands when using slices
arpi
parents: 9495
diff changeset
275 vf_next_draw_slice(vf, vf->priv->dmpi->planes, vf->priv->dmpi->stride,
c9012dcd3a70 clear black bands when using slices
arpi
parents: 9495
diff changeset
276 vf->priv->dmpi->w,vf->priv->dmpi->h-(vf->priv->exp_y+mpi->h),
c9012dcd3a70 clear black bands when using slices
arpi
parents: 9495
diff changeset
277 0,vf->priv->exp_y+mpi->h);
c9012dcd3a70 clear black bands when using slices
arpi
parents: 9495
diff changeset
278 }
5644
f1465a280612 (buggy) osd support, disabled for now, mencoder needs fixes to compile
arpi
parents: 5607
diff changeset
279 #ifdef OSD_SUPPORT
f1465a280612 (buggy) osd support, disabled for now, mencoder needs fixes to compile
arpi
parents: 5607
diff changeset
280 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
281 #endif
7368
a894e99c1e51 changing return type of put_image void->int
arpi
parents: 7052
diff changeset
282 // we've used DR, so we're ready...
9279
12741a866acd fixed palette support
arpi
parents: 8869
diff changeset
283 if(!(mpi->flags&MP_IMGFLAG_PLANAR))
12741a866acd fixed palette support
arpi
parents: 8869
diff changeset
284 vf->priv->dmpi->planes[1] = mpi->planes[1]; // passthrough rgb8 palette
7368
a894e99c1e51 changing return type of put_image void->int
arpi
parents: 7052
diff changeset
285 return vf_next_put_image(vf,vf->priv->dmpi);
5507
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
d0d029fda134 video filter layer - written from scratch, but inspired a lot by Fredrik Kuivinen's patch
arpi
parents:
diff changeset
288 // hope we'll get DR buffer:
d0d029fda134 video filter layer - written from scratch, but inspired a lot by Fredrik Kuivinen's patch
arpi
parents:
diff changeset
289 vf->priv->dmpi=vf_get_image(vf->next,mpi->imgfmt,
d0d029fda134 video filter layer - written from scratch, but inspired a lot by Fredrik Kuivinen's patch
arpi
parents:
diff changeset
290 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
291 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
292
d0d029fda134 video filter layer - written from scratch, but inspired a lot by Fredrik Kuivinen's patch
arpi
parents:
diff changeset
293 // copy mpi->dmpi...
d0d029fda134 video filter layer - written from scratch, but inspired a lot by Fredrik Kuivinen's patch
arpi
parents:
diff changeset
294 if(mpi->flags&MP_IMGFLAG_PLANAR){
d0d029fda134 video filter layer - written from scratch, but inspired a lot by Fredrik Kuivinen's patch
arpi
parents:
diff changeset
295 memcpy_pic(vf->priv->dmpi->planes[0]+
d0d029fda134 video filter layer - written from scratch, but inspired a lot by Fredrik Kuivinen's patch
arpi
parents:
diff changeset
296 vf->priv->exp_y*vf->priv->dmpi->stride[0]+vf->priv->exp_x,
d0d029fda134 video filter layer - written from scratch, but inspired a lot by Fredrik Kuivinen's patch
arpi
parents:
diff changeset
297 mpi->planes[0], mpi->w, mpi->h,
d0d029fda134 video filter layer - written from scratch, but inspired a lot by Fredrik Kuivinen's patch
arpi
parents:
diff changeset
298 vf->priv->dmpi->stride[0],mpi->stride[0]);
6525
0a7be46617d8 yvu9 and if09 support
alex
parents: 6060
diff changeset
299 memcpy_pic(vf->priv->dmpi->planes[1]+
6539
79b536a37e40 better planar support, chroma subsampling support and Y8/Y800 support
alex
parents: 6537
diff changeset
300 (vf->priv->exp_y>>mpi->chroma_y_shift)*vf->priv->dmpi->stride[1]+(vf->priv->exp_x>>mpi->chroma_x_shift),
79b536a37e40 better planar support, chroma subsampling support and Y8/Y800 support
alex
parents: 6537
diff changeset
301 mpi->planes[1], mpi->chroma_width, mpi->chroma_height,
6525
0a7be46617d8 yvu9 and if09 support
alex
parents: 6060
diff changeset
302 vf->priv->dmpi->stride[1],mpi->stride[1]);
0a7be46617d8 yvu9 and if09 support
alex
parents: 6060
diff changeset
303 memcpy_pic(vf->priv->dmpi->planes[2]+
6539
79b536a37e40 better planar support, chroma subsampling support and Y8/Y800 support
alex
parents: 6537
diff changeset
304 (vf->priv->exp_y>>mpi->chroma_y_shift)*vf->priv->dmpi->stride[2]+(vf->priv->exp_x>>mpi->chroma_x_shift),
79b536a37e40 better planar support, chroma subsampling support and Y8/Y800 support
alex
parents: 6537
diff changeset
305 mpi->planes[2], mpi->chroma_width, mpi->chroma_height,
6525
0a7be46617d8 yvu9 and if09 support
alex
parents: 6060
diff changeset
306 vf->priv->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
307 } else {
d0d029fda134 video filter layer - written from scratch, but inspired a lot by Fredrik Kuivinen's patch
arpi
parents:
diff changeset
308 memcpy_pic(vf->priv->dmpi->planes[0]+
d0d029fda134 video filter layer - written from scratch, but inspired a lot by Fredrik Kuivinen's patch
arpi
parents:
diff changeset
309 vf->priv->exp_y*vf->priv->dmpi->stride[0]+vf->priv->exp_x*(vf->priv->dmpi->bpp/8),
d0d029fda134 video filter layer - written from scratch, but inspired a lot by Fredrik Kuivinen's patch
arpi
parents:
diff changeset
310 mpi->planes[0], mpi->w*(vf->priv->dmpi->bpp/8), mpi->h,
d0d029fda134 video filter layer - written from scratch, but inspired a lot by Fredrik Kuivinen's patch
arpi
parents:
diff changeset
311 vf->priv->dmpi->stride[0],mpi->stride[0]);
9279
12741a866acd fixed palette support
arpi
parents: 8869
diff changeset
312 vf->priv->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
313 }
5644
f1465a280612 (buggy) osd support, disabled for now, mencoder needs fixes to compile
arpi
parents: 5607
diff changeset
314 #ifdef OSD_SUPPORT
f1465a280612 (buggy) osd support, disabled for now, mencoder needs fixes to compile
arpi
parents: 5607
diff changeset
315 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
316 #endif
7368
a894e99c1e51 changing return type of put_image void->int
arpi
parents: 7052
diff changeset
317 return vf_next_put_image(vf,vf->priv->dmpi);
5507
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 //===========================================================================//
d0d029fda134 video filter layer - written from scratch, but inspired a lot by Fredrik Kuivinen's patch
arpi
parents:
diff changeset
321
5644
f1465a280612 (buggy) osd support, disabled for now, mencoder needs fixes to compile
arpi
parents: 5607
diff changeset
322 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
323 #ifdef OSD_SUPPORT
f1465a280612 (buggy) osd support, disabled for now, mencoder needs fixes to compile
arpi
parents: 5607
diff changeset
324 switch(request){
f1465a280612 (buggy) osd support, disabled for now, mencoder needs fixes to compile
arpi
parents: 5607
diff changeset
325 case VFCTRL_DRAW_OSD:
f1465a280612 (buggy) osd support, disabled for now, mencoder needs fixes to compile
arpi
parents: 5607
diff changeset
326 if(vf->priv->osd) return CONTROL_TRUE;
f1465a280612 (buggy) osd support, disabled for now, mencoder needs fixes to compile
arpi
parents: 5607
diff changeset
327 }
f1465a280612 (buggy) osd support, disabled for now, mencoder needs fixes to compile
arpi
parents: 5607
diff changeset
328 #endif
f1465a280612 (buggy) osd support, disabled for now, mencoder needs fixes to compile
arpi
parents: 5607
diff changeset
329 return vf_next_control(vf,request,data);
f1465a280612 (buggy) osd support, disabled for now, mencoder needs fixes to compile
arpi
parents: 5607
diff changeset
330 }
f1465a280612 (buggy) osd support, disabled for now, mencoder needs fixes to compile
arpi
parents: 5607
diff changeset
331
5507
d0d029fda134 video filter layer - written from scratch, but inspired a lot by Fredrik Kuivinen's patch
arpi
parents:
diff changeset
332 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
333 vf->config=config;
5644
f1465a280612 (buggy) osd support, disabled for now, mencoder needs fixes to compile
arpi
parents: 5607
diff changeset
334 vf->control=control;
9495
2837f8da12c4 experimental slices support
arpi
parents: 9279
diff changeset
335 vf->start_slice=start_slice;
2837f8da12c4 experimental slices support
arpi
parents: 9279
diff changeset
336 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
337 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
338 vf->put_image=put_image;
9594
a4b6e7caaa4b Add support for the new option stuff.
albeu
parents: 9593
diff changeset
339 if(!vf->priv) {
5507
d0d029fda134 video filter layer - written from scratch, but inspired a lot by Fredrik Kuivinen's patch
arpi
parents:
diff changeset
340 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
341 vf->priv->exp_x=
d0d029fda134 video filter layer - written from scratch, but inspired a lot by Fredrik Kuivinen's patch
arpi
parents:
diff changeset
342 vf->priv->exp_y=
d0d029fda134 video filter layer - written from scratch, but inspired a lot by Fredrik Kuivinen's patch
arpi
parents:
diff changeset
343 vf->priv->exp_w=
d0d029fda134 video filter layer - written from scratch, but inspired a lot by Fredrik Kuivinen's patch
arpi
parents:
diff changeset
344 vf->priv->exp_h=-1;
7768
f5223b78ebf6 10l bug, found by valgrind :)
arpi
parents: 7368
diff changeset
345 vf->priv->osd=0;
f5223b78ebf6 10l bug, found by valgrind :)
arpi
parents: 7368
diff changeset
346 // parse args ->
9594
a4b6e7caaa4b Add support for the new option stuff.
albeu
parents: 9593
diff changeset
347 } // if(!vf->priv)
5644
f1465a280612 (buggy) osd support, disabled for now, mencoder needs fixes to compile
arpi
parents: 5607
diff changeset
348 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
349 &vf->priv->exp_w,
d0d029fda134 video filter layer - written from scratch, but inspired a lot by Fredrik Kuivinen's patch
arpi
parents:
diff changeset
350 &vf->priv->exp_h,
d0d029fda134 video filter layer - written from scratch, but inspired a lot by Fredrik Kuivinen's patch
arpi
parents:
diff changeset
351 &vf->priv->exp_x,
5644
f1465a280612 (buggy) osd support, disabled for now, mencoder needs fixes to compile
arpi
parents: 5607
diff changeset
352 &vf->priv->exp_y,
f1465a280612 (buggy) osd support, disabled for now, mencoder needs fixes to compile
arpi
parents: 5607
diff changeset
353 &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
354 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
355 vf->priv->exp_w,
d0d029fda134 video filter layer - written from scratch, but inspired a lot by Fredrik Kuivinen's patch
arpi
parents:
diff changeset
356 vf->priv->exp_h,
d0d029fda134 video filter layer - written from scratch, but inspired a lot by Fredrik Kuivinen's patch
arpi
parents:
diff changeset
357 vf->priv->exp_x,
5644
f1465a280612 (buggy) osd support, disabled for now, mencoder needs fixes to compile
arpi
parents: 5607
diff changeset
358 vf->priv->exp_y,
f1465a280612 (buggy) osd support, disabled for now, mencoder needs fixes to compile
arpi
parents: 5607
diff changeset
359 vf->priv->osd);
5507
d0d029fda134 video filter layer - written from scratch, but inspired a lot by Fredrik Kuivinen's patch
arpi
parents:
diff changeset
360 return 1;
d0d029fda134 video filter layer - written from scratch, but inspired a lot by Fredrik Kuivinen's patch
arpi
parents:
diff changeset
361 }
d0d029fda134 video filter layer - written from scratch, but inspired a lot by Fredrik Kuivinen's patch
arpi
parents:
diff changeset
362
9594
a4b6e7caaa4b Add support for the new option stuff.
albeu
parents: 9593
diff changeset
363 #define ST_OFF(f) M_ST_OFF(struct vf_priv_s,f)
a4b6e7caaa4b Add support for the new option stuff.
albeu
parents: 9593
diff changeset
364 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
365 {"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
366 {"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
367 {"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
368 {"y", ST_OFF(exp_y), CONF_TYPE_INT, M_OPT_MIN, -1, 0, NULL},
9594
a4b6e7caaa4b Add support for the new option stuff.
albeu
parents: 9593
diff changeset
369 {"osd", ST_OFF(osd), CONF_TYPE_FLAG, 0 , 0, 1, NULL},
a4b6e7caaa4b Add support for the new option stuff.
albeu
parents: 9593
diff changeset
370 { NULL, NULL, 0, 0, 0, 0, NULL }
a4b6e7caaa4b Add support for the new option stuff.
albeu
parents: 9593
diff changeset
371 };
a4b6e7caaa4b Add support for the new option stuff.
albeu
parents: 9593
diff changeset
372
a4b6e7caaa4b Add support for the new option stuff.
albeu
parents: 9593
diff changeset
373 static m_struct_t vf_opts = {
a4b6e7caaa4b Add support for the new option stuff.
albeu
parents: 9593
diff changeset
374 "expand",
a4b6e7caaa4b Add support for the new option stuff.
albeu
parents: 9593
diff changeset
375 sizeof(struct vf_priv_s),
a4b6e7caaa4b Add support for the new option stuff.
albeu
parents: 9593
diff changeset
376 &vf_priv_dflt,
a4b6e7caaa4b Add support for the new option stuff.
albeu
parents: 9593
diff changeset
377 vf_opts_fields
a4b6e7caaa4b Add support for the new option stuff.
albeu
parents: 9593
diff changeset
378 };
a4b6e7caaa4b Add support for the new option stuff.
albeu
parents: 9593
diff changeset
379
a4b6e7caaa4b Add support for the new option stuff.
albeu
parents: 9593
diff changeset
380
a4b6e7caaa4b Add support for the new option stuff.
albeu
parents: 9593
diff changeset
381
5507
d0d029fda134 video filter layer - written from scratch, but inspired a lot by Fredrik Kuivinen's patch
arpi
parents:
diff changeset
382 vf_info_t vf_info_expand = {
5644
f1465a280612 (buggy) osd support, disabled for now, mencoder needs fixes to compile
arpi
parents: 5607
diff changeset
383 #ifdef OSD_SUPPORT
f1465a280612 (buggy) osd support, disabled for now, mencoder needs fixes to compile
arpi
parents: 5607
diff changeset
384 "expanding & osd",
f1465a280612 (buggy) osd support, disabled for now, mencoder needs fixes to compile
arpi
parents: 5607
diff changeset
385 #else
5507
d0d029fda134 video filter layer - written from scratch, but inspired a lot by Fredrik Kuivinen's patch
arpi
parents:
diff changeset
386 "expanding",
5644
f1465a280612 (buggy) osd support, disabled for now, mencoder needs fixes to compile
arpi
parents: 5607
diff changeset
387 #endif
5507
d0d029fda134 video filter layer - written from scratch, but inspired a lot by Fredrik Kuivinen's patch
arpi
parents:
diff changeset
388 "expand",
d0d029fda134 video filter layer - written from scratch, but inspired a lot by Fredrik Kuivinen's patch
arpi
parents:
diff changeset
389 "A'rpi",
d0d029fda134 video filter layer - written from scratch, but inspired a lot by Fredrik Kuivinen's patch
arpi
parents:
diff changeset
390 "",
9593
e9a2af584986 Add the new -vf option wich is the same as vop in reverse order.
albeu
parents: 9582
diff changeset
391 open,
9594
a4b6e7caaa4b Add support for the new option stuff.
albeu
parents: 9593
diff changeset
392 &vf_opts
5507
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
d0d029fda134 video filter layer - written from scratch, but inspired a lot by Fredrik Kuivinen's patch
arpi
parents:
diff changeset
395 //===========================================================================//