[FFmpeg-soc] expand filter (alternative to pad syntax)

Michael Niedermayer michaelni at gmx.at
Sun May 11 22:06:00 CEST 2008


On Sun, May 11, 2008 at 09:55:18PM +0200, Vitor Sessak wrote:
> Michael Niedermayer wrote:
> > On Sun, May 11, 2008 at 12:47:20PM +0100, vmrsss wrote:
> >> Hi Michael,
> >>
> >> 	Sorry, I need some clarification.
> >>
> >> On 11 May 2008, at 12:15, Michael Niedermayer wrote:
> >>>>  double a;               // required aspect
> >>> remove all aspect related code, you dont know what you are doing.
> >>> read about pixel vs display aspect ratio
> >> I am happy to remove aspect related code, I agree it is not  
> >> particularly useful. The idea is taken from mplayer and is to expand  
> >> the frame to fit a specific ratio instead of giving size. Upon  
> > 
> > hmm, i think i misunderstood the code, maybe it is useful to keep,
> > have you tested it?
> > 
> > 
> >> reflection, I agree with your remark (because I do understand pixel vs  
> >> aspect ratio very well :-)
> >>
> >>>>    /* copy slice (y, y+h) from the original frame */
> >>>>    for(plane = 0; plane < 3; plane++) {
> >>>>
> >>>>      if( plane == 0 ){
> >>>> 	vsub = hsub = 0;
> >>>>      }else{
> >>>> 	vsub = pad->vsub; hsub = pad->hsub;
> >>>>      }
> >>>>
> >>>>      j1 = ((pad->y + y) >>vsub) * out->linesize[plane];
> >>>>      j2 = (y >>vsub) * in->linesize[plane];
> >>>>
> >>>>      for(i = 0; i < (h >>vsub); i++){
> >>>>
> >>>> 	memset(out->data[plane] + j1, padcolor[plane], pad->x >>hsub);
> >>>> 	memcpy(out->data[plane] + j1 + (pad->x >>hsub),
> >>>> 	       in->data[plane]  + j2, in->w >>hsub);
> >>>> 	memset(out->data[plane] + j1 + ((pad->x + in->w) >>hsub),
> >>>> 	       padcolor[plane], k >>hsub);
> >>>>
> >>>> 	j1 += out->linesize[plane];
> >>>> 	j2 += in->linesize[plane];
> >>>>      }
> >>>>    }
> >>> unconditional copying is unacceptable
> >> help explain: Why unconditional? I am copying in->data between y and y 
> >> +h, which I assume is what draw_slice(...,y,h) entitles to do. Anyway,  
> >> more fittingly: how would you want that copying to be coded?
> > 
> > There should be no copy.
> > The source filter should directly draw into the larger buffer of the
> > destination filter.
> 
> How should it be done then? Something like:
> 
> static void end_frame(AVFilterLink *link)
> {
>      AVFilterLink* output = link->dst->outputs[0];
> 
>      avfilter_resize_video_buffer(link->currpic, pad->w, pad->h); // not
> yet existent function!
> 
>      draw_borders(link->currpic);
> 
>      for (i=0; i<4; i++)
>      link->currpic->data[i] += the quantity needed to pad top/left
> 
>      avfilter_draw_slice(output, 0, pad->h);
>      avfilter_end_frame(output);
> }
> 
> and avfilter_resize_video_buffer() implemented using av_realloc()?

not possible, the buffer could be from an API like directdraw, xv, sdl
or even a buffer on your video card. These almost certainly do not
provide a function to resize. Also av_realloc() can be very slow.

Anyway, mplayer can do it, so it can be done and actually i belived that
avfilter already was able to do such things but i do not know precissely
how ATM. So maybe that has not been completely implemented.

[...]
-- 
Michael     GnuPG fingerprint: 9FF2128B147EF6730BADF133611EC787040B0FAB

When you are offended at any man's fault, turn to yourself and study your
own failings. Then you will forget your anger. -- Epictetus
-------------- next part --------------
A non-text attachment was scrubbed...
Name: not available
Type: application/pgp-signature
Size: 189 bytes
Desc: Digital signature
URL: <http://lists.mplayerhq.hu/pipermail/ffmpeg-soc/attachments/20080511/e49f7dfd/attachment.pgp>


More information about the FFmpeg-soc mailing list