/*
resizer-yuv
for use with mjpegtools.

Copyright (C) Jan Panteltje  2002

resizer-yuv is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation; either version 2, or (at your option)
any later version.
  
subtitler-yuv is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
GNU General Public License for more details.
  
You should have received a copy of the GNU General Public License
along with GNU Make; see the file COPYING.  If not, write to
the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA. 
*/

resizer-yuv-0.4

What it is:
This resizes 720x576 DVB-s (digital satellite PAL) video to 352x576 CVD
(China Video Disk, also known as D/2 DVD half resolution standard), without the
artifacts (saw tooth like effects) that yuvscaler causes. 
OTHER FORMATS ARE NOT SUPPORTED AT THIS MOMENT, and may cause severe
artifacts.

A n order low pass filer using 1 - exp(-x^2 / b) is used before the 
resizing (horizontal only), to remove any frequency components above
the sample frequency, thus preventing artifacts.
Some artefact are introduced by the FTT followed by reverse FFT.

Artefacts removed are especially those in striped clothing, patterns in a
tie, etc (high frequency aliasing).
Artefacts introduced are vertical edges at low frequency objects, for
example large surfaces of constant luminance or color.
In general however on many materials resizer-yuv looks better then yuvscaler.
Run a test and compare what you like most, and use that.

I took this code from transcode bbmpeg resize.c, and gave it an yuv
interface conform mjpegtools.

Also I used low pass pre-filtering using fft followed by reverse fft,
to prevent aliasing in the high frequency range.
This uses the very cool fft fftw-2.1.3.tar.gz library from:
http://www.fftw.org/download.html

Use the version best suited for your processor.
resizer-yuv will run tests to find out the best fft algo if you specify
the -m flag on the command line.


This is Linux software.
released under the GPL.

To compile and install:
Type 
make

If the linker complains about 'getline' not found, then perhaps you
do not have GNU libc, try commenting out at the end of resizer.h:
//#define NO_GNU_C
and type make again.

make install
make install.man

resizer-yuv -h
shows some command line options.
man resizer-yuv
shows the manual (not formatted yet), you can also read resizer-yuv.man
in this distribution with any text editor.

To use:
resizer-yuv is designed to be used with the mjpeg tools package, located at
http://mjpeg.sourceforge.net/

Example script, to convert 720x576 DVB-s satellite PAL to CVD 352x576:
(use -s in mpeg2dec only on multiplexed streams).

cat $1 | \
mpeg2dec \
-s \
-o YUV \
| \
./resizer-yuv \
-x 352 \
-y 576 \
-v \
| \
mpeg2enc \
--video-bitrate 2500 \
--interlace-mode 1 \
--video-buffer 230 \
--min-gop-size 6 \
--max-gop-size 15 \
--reduction-4x4 1 \
--reduction-2x2 1 \
--quantisation 5 \
--frame-rate 3 \
--aspect 2 \
--format 3 \
--video-norm p \
--playback-field-order t \
-o ./test-cvd.mpg


Homepage of resizer-yuv:
http://www.home.zonnet.nl/panteltje/subtitles/

Jan Panteltje
panteltje@yahoo.com
