[Ffmpeg-devel] cropping + rescaling broken?

Luca Abeni lucabe72
Tue Mar 7 11:15:44 CET 2006

Hi all,

maybe I finally understood why the resampling code is confusing me so
I suspect that img_resample_full_init() is broken: it works well when
rescaling without cropping but it fails miserably when rescaling and
cropping are used together.

How to test:
1) configure and compile ffmpeg (latest version from CVS)
2) ./output_example test.y4m
3) ./ffmpeg -i /tmp/test.y4m -s 352x576 -croptop 144 -cropbottom 144 out.y4m
   and look at the result... It looks ok. In fact, ffmpeg is not 
   rescaling (-croptop and -cropbottom decrease the output height by
   144 + 144 = 288, so the final result is 288 and no rescaling is
   needed). BTW, it does not seem to crop too... Basically, it seems 
   that ffmpeg is not doing anything :) Is this the intended behaviour?
4) ./ffmpeg -i /tmp/test.y4m -s 356x576 -croptop 144 -cropbottom 144 out.y4m
   and look at the result... It's completely wrong! Why? Because this 
   time ffmpeg does both rescaling (output width = 356) and cropping. 
   -croptop and -cropbottom decrease the output size by 144 + 144 = 
   288, so img_resample_full_init() is passed oheight = 288. But then it
   computes s->pad_oheight = oheight - (padtop + padbottom) = 288 - 144 - 144 =
   = 0... So it tries to rescale to 0!!!

So, now I have a (maybe naive) question. What are -croptop and
-cropbottom supposed to do? It seems to me that in both the two examples
I gave above they are not behaving correctly... Or am I misunderstanding
how they are intended to work?

What's the correct way to fix the bug I encountered? Let me know, so
that I can go on with the swscaler integration (I am currently stuck
with this cropping & padding stufff... My new code reproduces the
current ffmpeg behaviour, but this behaviour seems broken to me...)

Copy this in your signature, if you think it is important:
                               N O    W A R ! ! !

 Email.it, the professional e-mail, gratis per te: http://www.email.it/f
 Biglietti da visita premium GRATUITI. Offerta in scadenza?
 Clicca qui: http://adv.email.it/cgi-bin/foclick.cgi?mid=4834&d=7-3

More information about the ffmpeg-devel mailing list