[Ffmpeg-devel] [PATCH] ffmpeg.c: resample when wanted
Tomi Ollila
tomi.ollila
Sat Sep 10 22:22:22 CEST 2005
Hi
A few days ago I tried to crop and rescale one 4:3 recording to 16:9
format. The original material had resolution 720x576 and I gave options
-croptop 92 -cropbotton 52 -s 720x576 to ffmpeg to do the job.
To my suprise this was no-op. No cropping and no scaling (I've been
succesful with this earlyer, but my input material must have been
704x576...)
After many iterations and so (option tuning, reordering, many ffmpeg
recompilations) which none helped I browsed through ffmpeg.c source;
and there it was:
--8<----8<--
} else if ((codec->width == icodec->width +
(frame_padleft + frame_padright)) &&
(codec->height == icodec->height +
(frame_padtop + frame_padbottom))) {
ost->video_resample = 0;
ost->video_crop = 0;
ost->video_pad = 1;
--8<----8<--
Original 720x576, requested 720x576, all paddingss 0: that matched, it just
ignored the fact that I wanted to crop it and then rescale (resample)
back to the original resolution (with aspect 16:9).
--
I've created patch that fixes this. The initial thought is that
if after cropping and padding the source the resolution won't be
the target one resampling is needed. If not, it is checked whether
padding and/or cropping is requested.
I also wrote a test script to test all these cases, which are:
1) no resampling nor cropping nor padding
2) crop
3) pad
4) crop and pad (which doesn't work (no change there)) (*)
5) resample
6) resample, crop
7) resample, pad
8) resample, crop, pad
All tests (except that 4) produced expected results (though I
did not check whether padding were done before or after resampling...)
The (gzipped) patch (against cvs 2005/09/10) is attached at the end
of this mail. It is also available at
http://www.iki.fi/too/ffmpeg-reqcropad.patch
The test script is available at
http://www.iki.fi/too/ffmpeg-reqcropad-test-20050910.sh
(*) test case 4 above: with my limited knowledge I don't know
what to do with this. The unpatched code just ignored one
or either case. Here instead of outputting junk around the
pictures there are 3 options: 1) ignore either crop or pad,
2) forbid giving both options (when not resamping(!?)) and
3) fix the issue. (or 4: don't do anything and confuse users
that do such peculiar things ;))
Anyway, I wish you see the patch good to be applied.
Tomi
-------------- next part --------------
A non-text attachment was scrubbed...
Name: ffmpeg-reqcropad.patch.gz
Type: application/x-gzip
Size: 906 bytes
Desc: patch to fix resample when needed.
URL: <http://lists.mplayerhq.hu/pipermail/ffmpeg-devel/attachments/20050910/4935ae77/attachment.bin>
More information about the ffmpeg-devel
mailing list