comparison libmpcodecs/vf.c @ 6875:255b150a75a5

- some reorder/cleanup of mp_image flags - support for _ACCEPT_ALIGNED_STRIDE && _PREFER_ALIGNED_STRIDE
author arpi
date Fri, 02 Aug 2002 22:55:54 +0000
parents ed26b2d781e9
children c167153136b8
comparison
equal deleted inserted replaced
6874:58e730c20213 6875:255b150a75a5
110 } 110 }
111 } 111 }
112 112
113 mp_image_t* vf_get_image(vf_instance_t* vf, unsigned int outfmt, int mp_imgtype, int mp_imgflag, int w, int h){ 113 mp_image_t* vf_get_image(vf_instance_t* vf, unsigned int outfmt, int mp_imgtype, int mp_imgflag, int w, int h){
114 mp_image_t* mpi=NULL; 114 mp_image_t* mpi=NULL;
115 int w2=w; //(mp_imgflag&MP_IMGFLAG_ACCEPT_STRIDE)?((w+15)&(~15)):w; 115 int w2=(mp_imgflag&MP_IMGFLAG_ACCEPT_ALIGNED_STRIDE)?((w+15)&(~15)):w;
116 116
117 if(vf->put_image==vf_next_put_image){ 117 if(vf->put_image==vf_next_put_image){
118 // passthru mode, if the plugin uses the fallback/default put_image() code 118 // passthru mode, if the plugin uses the fallback/default put_image() code
119 return vf_get_image(vf->next,outfmt,mp_imgtype,mp_imgflag,w,h); 119 return vf_get_image(vf->next,outfmt,mp_imgtype,mp_imgflag,w,h);
120 } 120 }
146 vf->imgctx.static_idx^=1; 146 vf->imgctx.static_idx^=1;
147 break; 147 break;
148 } 148 }
149 if(mpi){ 149 if(mpi){
150 mpi->type=mp_imgtype; 150 mpi->type=mp_imgtype;
151 mpi->flags&=~(MP_IMGFLAG_PRESERVE|MP_IMGFLAG_READABLE|MP_IMGFLAG_DIRECT); 151 // keep buffer allocation status & color flags only:
152 mpi->flags|=mp_imgflag&(MP_IMGFLAG_PRESERVE|MP_IMGFLAG_READABLE|MP_IMGFLAG_ACCEPT_STRIDE|MP_IMGFLAG_ACCEPT_WIDTH|MP_IMGFLAG_ALIGNED_STRIDE|MP_IMGFLAG_DRAW_CALLBACK); 152 // mpi->flags&=~(MP_IMGFLAG_PRESERVE|MP_IMGFLAG_READABLE|MP_IMGFLAG_DIRECT);
153 mpi->flags&=MP_IMGFLAG_ALLOCATED|MP_IMGFLAG_TYPE_DISPLAYED|MP_IMGFLAGMASK_COLORS;
154 // accept restrictions & draw_slice flags only:
155 mpi->flags|=mp_imgflag&(MP_IMGFLAGMASK_RESTRICTIONS|MP_IMGFLAG_DRAW_CALLBACK);
153 if(!vf->draw_slice) mpi->flags&=~MP_IMGFLAG_DRAW_CALLBACK; 156 if(!vf->draw_slice) mpi->flags&=~MP_IMGFLAG_DRAW_CALLBACK;
154 if((mpi->width!=w2 || mpi->height!=h) && !(mpi->flags&MP_IMGFLAG_DIRECT)){ 157 if((mpi->width!=w2 || mpi->height!=h) && !(mpi->flags&MP_IMGFLAG_DIRECT)){
155 mpi->width=w2; 158 mpi->width=w2; mpi->chroma_width=w2>>mpi->chroma_x_shift;
156 mpi->height=h; 159 mpi->height=h; mpi->chroma_height=h>>mpi->chroma_y_shift;
157 if(mpi->flags&MP_IMGFLAG_ALLOCATED){ 160 if(mpi->flags&MP_IMGFLAG_ALLOCATED){
158 // need to re-allocate buffer memory: 161 // need to re-allocate buffer memory:
159 free(mpi->planes[0]); 162 free(mpi->planes[0]);
160 mpi->flags&=~MP_IMGFLAG_ALLOCATED; 163 mpi->flags&=~MP_IMGFLAG_ALLOCATED;
161 } 164 }
166 // check libvo first! 169 // check libvo first!
167 if(vf->get_image) vf->get_image(vf,mpi); 170 if(vf->get_image) vf->get_image(vf,mpi);
168 171
169 if(!(mpi->flags&MP_IMGFLAG_DIRECT)){ 172 if(!(mpi->flags&MP_IMGFLAG_DIRECT)){
170 // non-direct and not yet allocated image. allocate it! 173 // non-direct and not yet allocated image. allocate it!
174
175 // check if codec prefer aligned stride:
176 if(mp_imgflag&MP_IMGFLAG_PREFER_ALIGNED_STRIDE){
177 int align=(mpi->flags&MP_IMGFLAG_PLANAR &&
178 mpi->flags&MP_IMGFLAG_YUV) ?
179 (8<<mpi->chroma_x_shift)-1 : 15; // -- maybe FIXME
180 mpi->width=w2=((w+align)&(~align));
181 mpi->chroma_width=w2>>mpi->chroma_x_shift;
182 }
183
171 // IF09 - allocate space for 4. plane delta info - unused 184 // IF09 - allocate space for 4. plane delta info - unused
172 if (mpi->imgfmt == IMGFMT_IF09) 185 if (mpi->imgfmt == IMGFMT_IF09)
173 { 186 {
174 mpi->planes[0]=memalign(64, mpi->bpp*mpi->width*(mpi->height+2)/8+ 187 mpi->planes[0]=memalign(64, mpi->bpp*mpi->width*(mpi->height+2)/8+
175 mpi->chroma_width*mpi->chroma_height); 188 mpi->chroma_width*mpi->chroma_height);