Originally committed as revision 532 to svn://svn.ffmpeg.org/ffmpeg/trunktags/v0.5
| @@ -0,0 +1,40 @@ | |||
| # | |||
| # Makefile for tests | |||
| # (c) 2002 Gerard Lantau | |||
| # | |||
| include ../config.mak | |||
| VPATH=$(SRC_PATH)/tests | |||
| CFLAGS=-O2 -Wall -g | |||
| REFFILE=$(SRC_PATH)/tests/ffmpeg.regression.ref | |||
| all: test | |||
| # fast regression tests for all codecs | |||
| test mpeg4 mpeg: vsynth1/0.pgm asynth1.sw | |||
| @$(SRC_PATH)/tests/regression.sh $@ $(REFFILE) | |||
| # update the regression test with the current results | |||
| updatetest: | |||
| cp /tmp/ffmpeg.regression $(REFFILE) | |||
| # video generation | |||
| vsynth1/0.pgm: videogen | |||
| @mkdir -p vsynth1 | |||
| ./videogen 'vsynth1/' | |||
| videogen: videogen.c | |||
| $(CC) $(LDFLAGS) $(CFLAGS) -o $@ $< | |||
| # audio generation | |||
| asynth1.sw: audiogen | |||
| ./audiogen $@ | |||
| audiogen: audiogen.c | |||
| $(CC) $(LDFLAGS) $(CFLAGS) -o $@ $< | |||
| clean: | |||
| rm -rf vsynth1 | |||
| rm -f asynth1.sw *~ audiogen videogen | |||
| @@ -0,0 +1,168 @@ | |||
| /* | |||
| * Generates a synthetic stereo sound | |||
| * NOTE: no floats are used to guaranty a bit exact output. | |||
| */ | |||
| #include <stdlib.h> | |||
| #include <stdio.h> | |||
| #define NB_CHANNELS 2 | |||
| #define FE 44100 | |||
| static unsigned int myrnd(unsigned int *seed_ptr, int n) | |||
| { | |||
| unsigned int seed, val; | |||
| seed = *seed_ptr; | |||
| seed = (seed * 314159) + 1; | |||
| if (n == 256) { | |||
| val = seed >> 24; | |||
| } else { | |||
| val = seed % n; | |||
| } | |||
| *seed_ptr = seed; | |||
| return val; | |||
| } | |||
| #define FRAC_BITS 16 | |||
| #define FRAC_ONE (1 << FRAC_BITS) | |||
| #define COS_TABLE_BITS 7 | |||
| /* integer cosinus */ | |||
| static const unsigned short cos_table[(1 << COS_TABLE_BITS) + 2] = { | |||
| 0x8000, 0x7ffe, 0x7ff6, 0x7fea, 0x7fd9, 0x7fc2, 0x7fa7, 0x7f87, | |||
| 0x7f62, 0x7f38, 0x7f0a, 0x7ed6, 0x7e9d, 0x7e60, 0x7e1e, 0x7dd6, | |||
| 0x7d8a, 0x7d3a, 0x7ce4, 0x7c89, 0x7c2a, 0x7bc6, 0x7b5d, 0x7aef, | |||
| 0x7a7d, 0x7a06, 0x798a, 0x790a, 0x7885, 0x77fb, 0x776c, 0x76d9, | |||
| 0x7642, 0x75a6, 0x7505, 0x7460, 0x73b6, 0x7308, 0x7255, 0x719e, | |||
| 0x70e3, 0x7023, 0x6f5f, 0x6e97, 0x6dca, 0x6cf9, 0x6c24, 0x6b4b, | |||
| 0x6a6e, 0x698c, 0x68a7, 0x67bd, 0x66d0, 0x65de, 0x64e9, 0x63ef, | |||
| 0x62f2, 0x61f1, 0x60ec, 0x5fe4, 0x5ed7, 0x5dc8, 0x5cb4, 0x5b9d, | |||
| 0x5a82, 0x5964, 0x5843, 0x571e, 0x55f6, 0x54ca, 0x539b, 0x5269, | |||
| 0x5134, 0x4ffb, 0x4ec0, 0x4d81, 0x4c40, 0x4afb, 0x49b4, 0x486a, | |||
| 0x471d, 0x45cd, 0x447b, 0x4326, 0x41ce, 0x4074, 0x3f17, 0x3db8, | |||
| 0x3c57, 0x3af3, 0x398d, 0x3825, 0x36ba, 0x354e, 0x33df, 0x326e, | |||
| 0x30fc, 0x2f87, 0x2e11, 0x2c99, 0x2b1f, 0x29a4, 0x2827, 0x26a8, | |||
| 0x2528, 0x23a7, 0x2224, 0x209f, 0x1f1a, 0x1d93, 0x1c0c, 0x1a83, | |||
| 0x18f9, 0x176e, 0x15e2, 0x1455, 0x12c8, 0x113a, 0x0fab, 0x0e1c, | |||
| 0x0c8c, 0x0afb, 0x096b, 0x07d9, 0x0648, 0x04b6, 0x0324, 0x0192, | |||
| 0x0000, 0x0000, | |||
| }; | |||
| #define CSHIFT (FRAC_BITS - COS_TABLE_BITS - 2) | |||
| static int int_cos(int a) | |||
| { | |||
| int neg, v, f; | |||
| const unsigned short *p; | |||
| a = a & (FRAC_ONE - 1); /* modulo 2 * pi */ | |||
| if (a >= (FRAC_ONE / 2)) | |||
| a = FRAC_ONE - a; | |||
| neg = 0; | |||
| if (a > (FRAC_ONE / 4)) { | |||
| neg = -1; | |||
| a = (FRAC_ONE / 2) - a; | |||
| } | |||
| p = cos_table + (a >> CSHIFT); | |||
| /* linear interpolation */ | |||
| f = a & ((1 << CSHIFT) - 1); | |||
| v = p[0] + (((p[1] - p[0]) * f + (1 << (CSHIFT - 1))) >> CSHIFT); | |||
| v = (v ^ neg) - neg; | |||
| v = v << (FRAC_BITS - 15); | |||
| return v; | |||
| } | |||
| FILE *outfile; | |||
| void put_sample(int v) | |||
| { | |||
| fputc(v & 0xff, outfile); | |||
| fputc((v >> 8) & 0xff, outfile); | |||
| } | |||
| int main(int argc, char **argv) | |||
| { | |||
| int i, a, v, j, f, amp, ampa; | |||
| unsigned int seed = 1; | |||
| int tabf1[NB_CHANNELS], tabf2[NB_CHANNELS]; | |||
| int taba[NB_CHANNELS]; | |||
| if (argc != 2) { | |||
| printf("usage: %s file\n" | |||
| "generate a test raw 16 bit stereo audio stream\n", argv[0]); | |||
| exit(1); | |||
| } | |||
| outfile = fopen(argv[1], "w"); | |||
| if (!outfile) { | |||
| perror(argv[1]); | |||
| return 1; | |||
| } | |||
| /* 1 second of single freq sinus at 1000 Hz */ | |||
| a = 0; | |||
| for(i=0;i<1 * FE;i++) { | |||
| v = (int_cos(a) * 10000) >> FRAC_BITS; | |||
| for(j=0;j<NB_CHANNELS;j++) | |||
| put_sample(v); | |||
| a += (1000 * FRAC_ONE) / FE; | |||
| } | |||
| /* 1 second of varing frequency between 100 and 10000 Hz */ | |||
| a = 0; | |||
| for(i=0;i<1 * FE;i++) { | |||
| v = (int_cos(a) * 10000) >> FRAC_BITS; | |||
| for(j=0;j<NB_CHANNELS;j++) | |||
| put_sample(v); | |||
| f = 100 + (((10000 - 100) * i) / FE); | |||
| a += (f * FRAC_ONE) / FE; | |||
| } | |||
| /* 0.5 second of low amplitude white noise */ | |||
| for(i=0;i<FE / 2;i++) { | |||
| v = myrnd(&seed, 20000) - 10000; | |||
| for(j=0;j<NB_CHANNELS;j++) | |||
| put_sample(v); | |||
| } | |||
| /* 0.5 second of high amplitude white noise */ | |||
| for(i=0;i<FE / 2;i++) { | |||
| v = myrnd(&seed, 65535) - 32768; | |||
| for(j=0;j<NB_CHANNELS;j++) | |||
| put_sample(v); | |||
| } | |||
| /* stereo : 2 unrelated ramps */ | |||
| for(j=0;j<NB_CHANNELS;j++) { | |||
| taba[j] = 0; | |||
| tabf1[j] = 100 + myrnd(&seed, 5000); | |||
| tabf2[j] = 100 + myrnd(&seed, 5000); | |||
| } | |||
| for(i=0;i<1 * FE;i++) { | |||
| for(j=0;j<NB_CHANNELS;j++) { | |||
| v = (int_cos(taba[j]) * 10000) >> FRAC_BITS; | |||
| put_sample(v); | |||
| f = tabf1[j] + (((tabf2[j] - tabf1[j]) * i) / FE); | |||
| taba[j] += (f * FRAC_ONE) / FE; | |||
| } | |||
| } | |||
| /* stereo 500 Hz with varying volume */ | |||
| a = 0; | |||
| ampa = 0; | |||
| for(i=0;i<2 * FE;i++) { | |||
| for(j=0;j<NB_CHANNELS;j++) { | |||
| amp = ((FRAC_ONE + int_cos(ampa)) * 5000) >> FRAC_BITS; | |||
| if (j & 1) | |||
| amp = 10000 - amp; | |||
| v = (int_cos(a) * amp) >> FRAC_BITS; | |||
| put_sample(v); | |||
| a += (500 * FRAC_ONE) / FE; | |||
| ampa += (2 * FRAC_ONE) / FE; | |||
| } | |||
| } | |||
| fclose(outfile); | |||
| return 0; | |||
| } | |||
| @@ -0,0 +1,15 @@ | |||
| ffmpeg regression test | |||
| 5f79a1de94818e085d283612c979209e /tmp/a-mpeg1.mpg | |||
| ec8038d872249d000ef3ced8a929d852 /tmp/out.yuv | |||
| 0d2929a5ca7d59404ae302ceaef34ad0 /tmp/a-msmpeg4.avi | |||
| 78f75bae681ad659d8433be5c5be4355 /tmp/out.yuv | |||
| dbdfcaec083cb2ff9484369d51b5dd37 /tmp/a-h263.avi | |||
| dd556b4cab001f91594ed5198c0076e9 /tmp/out.yuv | |||
| fa29e99ad3314a5ef6881f3fcad374e7 /tmp/a-odivx.avi | |||
| 42d47bf027f72cba83ea23b9755937bd /tmp/out.yuv | |||
| ff06a0b59e445d2694185a08e1000801 /tmp/a-mjpeg.avi | |||
| 6551ec4dea416fa3e8f3538d206f236f /tmp/out.yuv | |||
| 21f8ff9f1daacd9133683bb4ea0f50a4 /tmp/a-mp2.mp2 | |||
| 66ba0fcbf3ed6310d54a71611e16a59c /tmp/out.wav | |||
| 048b9c3444c788bac6ce5cc3a8f4db00 /tmp/a-ac3.rm | |||
| ae59a9cf43ee96b3214567ce8a25aa31 /tmp/out.wav | |||
| @@ -0,0 +1,145 @@ | |||
| #!/bin/sh | |||
| # | |||
| # automatic regression test for ffmpeg | |||
| # | |||
| # | |||
| #set -x | |||
| set -e | |||
| # tests to do | |||
| if [ "$1" = "mpeg4" ] ; then | |||
| do_mpeg4=y | |||
| elif [ "$1" = "mpeg" ] ; then | |||
| do_mpeg=y | |||
| else | |||
| do_mpeg=y | |||
| do_msmpeg4=y | |||
| do_h263=y | |||
| do_mpeg4=y | |||
| do_mjpeg=y | |||
| #do_rv10=y #broken! | |||
| do_mp2=y | |||
| do_ac3=y | |||
| fi | |||
| # various files | |||
| ffmpeg="../ffmpeg" | |||
| outfile="/tmp/a-" | |||
| reffile="$2" | |||
| logfile="/tmp/ffmpeg.regression" | |||
| benchfile="/tmp/ffmpeg.bench" | |||
| raw_src="vsynth1/%d.pgm" | |||
| raw_dst="/tmp/out.yuv" | |||
| pcm_src="asynth1.sw" | |||
| pcm_dst="/tmp/out.wav" | |||
| function do_ffmpeg () | |||
| { | |||
| f="$1" | |||
| shift | |||
| echo $ffmpeg $* | |||
| $ffmpeg -benchmark $* > /tmp/bench.tmp | |||
| md5sum $f >> $logfile | |||
| expr match "`cat /tmp/bench.tmp`" '.*utime=\(.*s\)' > /tmp/bench2.tmp | |||
| echo `cat /tmp/bench2.tmp` $f >> $benchfile | |||
| } | |||
| echo "ffmpeg regression test" > $logfile | |||
| echo "ffmpeg benchmarks" > $benchfile | |||
| ################################### | |||
| if [ -n "$do_mpeg" ] ; then | |||
| # mpeg1 encoding | |||
| file=${outfile}mpeg1.mpg | |||
| do_ffmpeg $file -y -qscale 10 -f pgmyuv -i $raw_src -f mpegvideo $file | |||
| # mpeg1 decoding | |||
| do_ffmpeg $raw_dst -y -f mpegvideo -i $file -f rawvideo $raw_dst | |||
| # mpeg2 decoding | |||
| #do_ffmpeg /tmp/out-mpeg2.yuv -y -f mpegvideo -i a.vob \ | |||
| # -f rawvideo /tmp/out-mpeg2.yuv | |||
| fi | |||
| ################################### | |||
| if [ -n "$do_msmpeg4" ] ; then | |||
| # msmpeg4 encoding | |||
| file=${outfile}msmpeg4.avi | |||
| do_ffmpeg $file -y -qscale 10 -f pgmyuv -i $raw_src -an -vcodec msmpeg4 $file | |||
| # msmpeg4 decoding | |||
| do_ffmpeg $raw_dst -y -i $file -f rawvideo $raw_dst | |||
| fi | |||
| ################################### | |||
| if [ -n "$do_h263" ] ; then | |||
| # h263 encoding | |||
| file=${outfile}h263.avi | |||
| do_ffmpeg $file -y -qscale 10 -f pgmyuv -i $raw_src -s 352x288 -an -vcodec h263 $file | |||
| # h263p decoding | |||
| do_ffmpeg $raw_dst -y -i $file -f rawvideo $raw_dst | |||
| fi | |||
| ################################### | |||
| if [ -n "$do_mpeg4" ] ; then | |||
| # mpeg4 | |||
| file=${outfile}odivx.avi | |||
| do_ffmpeg $file -y -qscale 10 -f pgmyuv -i $raw_src -an -vcodec mpeg4 $file | |||
| # mpeg4 decoding | |||
| do_ffmpeg $raw_dst -y -i $file -f rawvideo $raw_dst | |||
| fi | |||
| ################################### | |||
| if [ -n "$do_mjpeg" ] ; then | |||
| # mjpeg | |||
| file=${outfile}mjpeg.avi | |||
| do_ffmpeg $file -y -qscale 10 -f pgmyuv -i $raw_src -an -vcodec mjpeg $file | |||
| # mjpeg decoding | |||
| do_ffmpeg $raw_dst -y -i $file -f rawvideo $raw_dst | |||
| fi | |||
| ################################### | |||
| if [ -n "$do_rv10" ] ; then | |||
| # rv10 encoding | |||
| file=${outfile}rv10.rm | |||
| do_ffmpeg $file -y -qscale 10 -f pgmyuv -i $raw_src -an $file | |||
| # rv10 decoding | |||
| do_ffmpeg $raw_dst -y -i $file -f rawvideo $raw_dst | |||
| fi | |||
| ################################### | |||
| if [ -n "$do_mp2" ] ; then | |||
| # mp2 encoding | |||
| file=${outfile}mp2.mp2 | |||
| do_ffmpeg $file -y -ab 128 -ac 2 -ar 44100 -f s16le -i $pcm_src $file | |||
| # mp2 decoding | |||
| do_ffmpeg $pcm_dst -y -i $file -f wav $pcm_dst | |||
| fi | |||
| ################################### | |||
| if [ -n "$do_ac3" ] ; then | |||
| # ac3 encoding | |||
| file=${outfile}ac3.rm | |||
| do_ffmpeg $file -y -ab 128 -ac 2 -f s16le -i $pcm_src -vn $file | |||
| # ac3 decoding | |||
| do_ffmpeg $pcm_dst -y -i $file -f wav $pcm_dst | |||
| fi | |||
| if diff -u $logfile $reffile ; then | |||
| echo | |||
| echo Regression test succeeded. | |||
| exit 0 | |||
| else | |||
| echo | |||
| echo Regression test: Error. | |||
| exit 1 | |||
| fi | |||
| @@ -0,0 +1,278 @@ | |||
| /* | |||
| * Generates a synthetic YUV video sequence suitable for codec testing. | |||
| * NOTE: no floats are used to guaranty a bit exact output. | |||
| */ | |||
| #include <stdlib.h> | |||
| #include <stdio.h> | |||
| #define SCALEBITS 8 | |||
| #define ONE_HALF (1 << (SCALEBITS - 1)) | |||
| #define FIX(x) ((int) ((x) * (1L<<SCALEBITS) + 0.5)) | |||
| typedef unsigned char UINT8; | |||
| static void rgb24_to_yuv420p(UINT8 *lum, UINT8 *cb, UINT8 *cr, | |||
| UINT8 *src, int width, int height) | |||
| { | |||
| int wrap, wrap3, x, y; | |||
| int r, g, b, r1, g1, b1; | |||
| UINT8 *p; | |||
| wrap = width; | |||
| wrap3 = width * 3; | |||
| p = src; | |||
| for(y=0;y<height;y+=2) { | |||
| for(x=0;x<width;x+=2) { | |||
| r = p[0]; | |||
| g = p[1]; | |||
| b = p[2]; | |||
| r1 = r; | |||
| g1 = g; | |||
| b1 = b; | |||
| lum[0] = (FIX(0.29900) * r + FIX(0.58700) * g + | |||
| FIX(0.11400) * b + ONE_HALF) >> SCALEBITS; | |||
| r = p[3]; | |||
| g = p[4]; | |||
| b = p[5]; | |||
| r1 += r; | |||
| g1 += g; | |||
| b1 += b; | |||
| lum[1] = (FIX(0.29900) * r + FIX(0.58700) * g + | |||
| FIX(0.11400) * b + ONE_HALF) >> SCALEBITS; | |||
| p += wrap3; | |||
| lum += wrap; | |||
| r = p[0]; | |||
| g = p[1]; | |||
| b = p[2]; | |||
| r1 += r; | |||
| g1 += g; | |||
| b1 += b; | |||
| lum[0] = (FIX(0.29900) * r + FIX(0.58700) * g + | |||
| FIX(0.11400) * b + ONE_HALF) >> SCALEBITS; | |||
| r = p[3]; | |||
| g = p[4]; | |||
| b = p[5]; | |||
| r1 += r; | |||
| g1 += g; | |||
| b1 += b; | |||
| lum[1] = (FIX(0.29900) * r + FIX(0.58700) * g + | |||
| FIX(0.11400) * b + ONE_HALF) >> SCALEBITS; | |||
| cb[0] = ((- FIX(0.16874) * r1 - FIX(0.33126) * g1 + | |||
| FIX(0.50000) * b1 + 4 * ONE_HALF - 1) >> (SCALEBITS + 2)) + 128; | |||
| cr[0] = ((FIX(0.50000) * r1 - FIX(0.41869) * g1 - | |||
| FIX(0.08131) * b1 + 4 * ONE_HALF - 1) >> (SCALEBITS + 2)) + 128; | |||
| cb++; | |||
| cr++; | |||
| p += -wrap3 + 2 * 3; | |||
| lum += -wrap + 2; | |||
| } | |||
| p += wrap3; | |||
| lum += wrap; | |||
| } | |||
| } | |||
| /* cif format */ | |||
| #define DEFAULT_WIDTH 352 | |||
| #define DEFAULT_HEIGHT 288 | |||
| #define DEFAULT_NB_PICT 125 /* 5 seconds */ | |||
| void pgmyuv_save(const char *filename, int w, int h, | |||
| unsigned char *rgb_tab) | |||
| { | |||
| FILE *f; | |||
| int i, h2, w2; | |||
| unsigned char *cb, *cr; | |||
| unsigned char *lum_tab, *cb_tab, *cr_tab; | |||
| lum_tab = malloc(w * h); | |||
| cb_tab = malloc((w * h) / 4); | |||
| cr_tab = malloc((w * h) / 4); | |||
| rgb24_to_yuv420p(lum_tab, cb_tab, cr_tab, rgb_tab, w, h); | |||
| f = fopen(filename,"w"); | |||
| fprintf(f, "P5\n%d %d\n%d\n", w, (h * 3) / 2, 255); | |||
| fwrite(lum_tab, 1, w * h, f); | |||
| h2 = h / 2; | |||
| w2 = w / 2; | |||
| cb = cb_tab; | |||
| cr = cr_tab; | |||
| for(i=0;i<h2;i++) { | |||
| fwrite(cb, 1, w2, f); | |||
| fwrite(cr, 1, w2, f); | |||
| cb += w2; | |||
| cr += w2; | |||
| } | |||
| fclose(f); | |||
| free(lum_tab); | |||
| free(cb_tab); | |||
| free(cr_tab); | |||
| } | |||
| unsigned char *rgb_tab; | |||
| int width, height, wrap; | |||
| void put_pixel(int x, int y, int r, int g, int b) | |||
| { | |||
| unsigned char *p; | |||
| if (x < 0 || x >= width || | |||
| y < 0 || y >= height) | |||
| return; | |||
| p = rgb_tab + y * wrap + x * 3; | |||
| p[0] = r; | |||
| p[1] = g; | |||
| p[2] = b; | |||
| } | |||
| static unsigned int myrnd(unsigned int *seed_ptr, int n) | |||
| { | |||
| unsigned int seed, val; | |||
| seed = *seed_ptr; | |||
| seed = (seed * 314159) + 1; | |||
| if (n == 256) { | |||
| val = seed >> 24; | |||
| } else { | |||
| val = seed % n; | |||
| } | |||
| *seed_ptr = seed; | |||
| return val; | |||
| } | |||
| #define NOISE_X 10 | |||
| #define NOISE_Y 30 | |||
| #define NOISE_W 26 | |||
| #define FRAC_BITS 8 | |||
| #define FRAC_ONE (1 << FRAC_BITS) | |||
| /* cosine approximate with 1-x^2 */ | |||
| int int_cos(int a) | |||
| { | |||
| int v, neg; | |||
| a = a & (FRAC_ONE - 1); | |||
| if (a >= (FRAC_ONE / 2)) | |||
| a = FRAC_ONE - a; | |||
| neg = 0; | |||
| if (a > (FRAC_ONE / 4)) { | |||
| neg = -1; | |||
| a = (FRAC_ONE / 2) - a; | |||
| } | |||
| v = FRAC_ONE - ((a * a) >> 4); | |||
| v = (v ^ neg) - neg; | |||
| return v; | |||
| } | |||
| #define NB_OBJS 10 | |||
| typedef struct VObj { | |||
| int x, y, w, h; | |||
| int r, g, b; | |||
| } VObj; | |||
| VObj objs[NB_OBJS]; | |||
| unsigned int seed = 1; | |||
| void gen_image(int num, int w, int h) | |||
| { | |||
| int r, g, b, x, y, i, dx, dy, x1, y1; | |||
| unsigned int seed1; | |||
| if (num == 0) { | |||
| for(i=0;i<NB_OBJS;i++) { | |||
| objs[i].x = myrnd(&seed, w); | |||
| objs[i].y = myrnd(&seed, h); | |||
| objs[i].w = myrnd(&seed, w / 4) + 10; | |||
| objs[i].h = myrnd(&seed, h / 4) + 10; | |||
| objs[i].r = myrnd(&seed, 256); | |||
| objs[i].g = myrnd(&seed, 256); | |||
| objs[i].b = myrnd(&seed, 256); | |||
| } | |||
| } | |||
| /* first a moving background with gradients */ | |||
| /* test motion estimation */ | |||
| dx = int_cos(num * FRAC_ONE / 50) * 35; | |||
| dy = int_cos(num * FRAC_ONE / 50 + FRAC_ONE / 10) * 30; | |||
| for(y=0;y<h;y++) { | |||
| for(x=0;x<w;x++) { | |||
| x1 = (x << FRAC_BITS) + dx; | |||
| y1 = (y << FRAC_BITS) + dx; | |||
| r = ((y1 * 7) >> FRAC_BITS) & 0xff; | |||
| g = (((x1 + y1) * 9) >> FRAC_BITS) & 0xff; | |||
| b = ((x1 * 5) >> FRAC_BITS) & 0xff; | |||
| put_pixel(x, y, r, g, b); | |||
| } | |||
| } | |||
| /* then some noise with very high intensity to test saturation */ | |||
| seed1 = num; | |||
| for(y=0;y<NOISE_W;y++) { | |||
| for(x=0;x<NOISE_W;x++) { | |||
| r = myrnd(&seed1, 256); | |||
| g = myrnd(&seed1, 256); | |||
| b = myrnd(&seed1, 256); | |||
| put_pixel(x + NOISE_X, y + NOISE_Y, r, g, b); | |||
| } | |||
| } | |||
| /* then moving objects */ | |||
| for(i=0;i<NB_OBJS;i++) { | |||
| VObj *p = &objs[i]; | |||
| seed1 = i; | |||
| for(y=0;y<p->h;y++) { | |||
| for(x=0;x<p->w;x++) { | |||
| r = p->r; | |||
| g = p->g; | |||
| b = p->b; | |||
| /* add a per object noise */ | |||
| r += myrnd(&seed1, 50); | |||
| g += myrnd(&seed1, 50); | |||
| b += myrnd(&seed1, 50); | |||
| put_pixel(x + p->x, y + p->y, r, g, b); | |||
| } | |||
| } | |||
| p->x += myrnd(&seed, 21) - 10; | |||
| p->y += myrnd(&seed, 21) - 10; | |||
| } | |||
| } | |||
| int main(int argc, char **argv) | |||
| { | |||
| int w, h, i; | |||
| char buf[1024]; | |||
| if (argc != 2) { | |||
| printf("usage: %s file\n" | |||
| "generate a test video stream\n", argv[0]); | |||
| exit(1); | |||
| } | |||
| #if 0 | |||
| for(i=0;i<256;i++) | |||
| printf("cos(%d)=%d\n", i, int_cos(i)); | |||
| #endif | |||
| w = DEFAULT_WIDTH; | |||
| h = DEFAULT_HEIGHT; | |||
| rgb_tab = malloc(w * h * 3); | |||
| wrap = w * 3; | |||
| width = w; | |||
| height = h; | |||
| for(i=0;i<DEFAULT_NB_PICT;i++) { | |||
| snprintf(buf, sizeof(buf), "%s%d.pgm", argv[1], i); | |||
| gen_image(i, w, h); | |||
| pgmyuv_save(buf, w, h, rgb_tab); | |||
| } | |||
| free(rgb_tab); | |||
| return 0; | |||
| } | |||