/*
I ran these two tests:
testcase | ffmpeg -v 9 -loglevel 99 -f rawvideo -video_size 256x256 -pix_fmt bgr24 -i -                      -sws_flags lanczos -f rawvideo -pix_fmt yuv420p out1.raw
testcase | ffmpeg -v 9 -loglevel 99 -f rawvideo -video_size 256x256 -pix_fmt bgr24 -i - -filter format=rgb24 -sws_flags lanczos -f rawvideo -pix_fmt yuv420p out2.raw

Full console output is below.  testcase the executable built from this source file.






testcase | ffmpeg -v 9 -loglevel 99 -f rawvideo -video_size 256x256 -pix_fmt bgr24 -i -                      -sws_flags lanczos -f rawvideo -pix_fmt yuv420p out1.raw

ffmpeg version N-37541-g670229e Copyright (c) 2000-2012 the FFmpeg developers
  built on Feb  3 2012 20:07:47 with gcc 4.6.2
  configuration: --enable-gpl --enable-version3 --disable-w32threads --enable-ru
ntime-cpudetect --enable-avisynth --enable-bzlib --enable-frei0r --enable-libope
ncore-amrnb --enable-libopencore-amrwb --enable-libfreetype --enable-libgsm --en
able-libmp3lame --enable-libopenjpeg --enable-librtmp --enable-libschroedinger -
-enable-libspeex --enable-libtheora --enable-libvo-aacenc --enable-libvo-amrwben
c --enable-libvorbis --enable-libvpx --enable-libx264 --enable-libxavs --enable-
libxvid --enable-zlib
  libavutil      51. 37.100 / 51. 37.100
  libavcodec     54.  0.102 / 54.  0.102
  libavformat    54.  0.100 / 54.  0.100
  libavdevice    53.  4.100 / 53.  4.100
  libavfilter     2. 61.100 /  2. 61.100
  libswscale      2.  1.100 /  2.  1.100
  libswresample   0.  6.100 /  0.  6.100
  libpostproc    52.  0.100 / 52.  0.100
[rawvideo @ 003A98E0] All info found
[rawvideo @ 003A98E0] Estimating duration from bitrate, this may be inaccurate
Input #0, rawvideo, from 'pipe:':
  Duration: N/A, start: 0.000000, bitrate: N/A
    Stream #0:0, 1, 1/25: Video: rawvideo (BGR[24] / 0x18524742), bgr24, 256x256
, 1/25, 25 tbr, 25 tbn, 25 tbc
[buffer @ 003AFE80] w:256 h:256 pixfmt:bgr24 tb:1/1000000 sar:0/1 sws_param:
[buffersink @ 003AFF60] auto-inserting filter 'auto-inserted scale 0' between th
e filter 'src' and the filter 'out'
[scale @ 038540E0] w:256 h:256 fmt:bgr24 -> w:256 h:256 fmt:yuv420p flags:0x200
Output #0, rawvideo, to 'out1.raw':
  Metadata:
    encoder         : Lavf54.0.100
    Stream #0:0, 0, 1/90000: Video: rawvideo (I420 / 0x30323449), yuv420p, 256x2
56, 1/25, q=2-31, 200 kb/s, 90k tbn, 25 tbc
Stream mapping:
  Stream #0:0 -> #0:0 (rawvideo -> rawvideo)
frame=    1 fps=  0 q=0.0 Lsize=      96kB time=00:00:00.04 bitrate=19660.8kbits
/s
video:96kB audio:0kB global headers:0kB muxing overhead 0.000000%

testcase | ffmpeg -v 9 -loglevel 99 -f rawvideo -video_size 256x256 -pix_fmt bgr24 -i - -filter format=rgb24 -sws_flags lanczos -f rawvideo -pix_fmt yuv420p out2.raw

ffmpeg version N-37541-g670229e Copyright (c) 2000-2012 the FFmpeg developers
  built on Feb  3 2012 20:07:47 with gcc 4.6.2
  configuration: --enable-gpl --enable-version3 --disable-w32threads --enable-ru
ntime-cpudetect --enable-avisynth --enable-bzlib --enable-frei0r --enable-libope
ncore-amrnb --enable-libopencore-amrwb --enable-libfreetype --enable-libgsm --en
able-libmp3lame --enable-libopenjpeg --enable-librtmp --enable-libschroedinger -
-enable-libspeex --enable-libtheora --enable-libvo-aacenc --enable-libvo-amrwben
c --enable-libvorbis --enable-libvpx --enable-libx264 --enable-libxavs --enable-
libxvid --enable-zlib
  libavutil      51. 37.100 / 51. 37.100
  libavcodec     54.  0.102 / 54.  0.102
  libavformat    54.  0.100 / 54.  0.100
  libavdevice    53.  4.100 / 53.  4.100
  libavfilter     2. 61.100 /  2. 61.100
  libswscale      2.  1.100 /  2.  1.100
  libswresample   0.  6.100 /  0.  6.100
  libpostproc    52.  0.100 / 52.  0.100
[rawvideo @ 00369980] All info found
[rawvideo @ 00369980] Estimating duration from bitrate, this may be inaccurate
Input #0, rawvideo, from 'pipe:':
  Duration: N/A, start: 0.000000, bitrate: N/A
    Stream #0:0, 1, 1/25: Video: rawvideo (BGR[24] / 0x18524742), bgr24, 256x256
, 1/25, 25 tbr, 25 tbn, 25 tbc
[buffer @ 00369E80] w:256 h:256 pixfmt:bgr24 tb:1/1000000 sar:0/1 sws_param:
[buffersink @ 03973700] auto-inserting filter 'auto-inserted scale 0' between th
e filter 'Parsed_format_0' and the filter 'out'
[format @ 03973960] auto-inserting filter 'auto-inserted scale 1' between the fi
lter 'src' and the filter 'Parsed_format_0'
[scale @ 03974880] w:256 h:256 fmt:bgr24 -> w:256 h:256 fmt:rgb24 flags:0x200
[scale @ 03973900] w:256 h:256 fmt:rgb24 -> w:256 h:256 fmt:yuv420p flags:0x200
Output #0, rawvideo, to 'out2.raw':
  Metadata:
    encoder         : Lavf54.0.100
    Stream #0:0, 0, 1/90000: Video: rawvideo (I420 / 0x30323449), yuv420p, 256x2
56, 1/25, q=2-31, 200 kb/s, 90k tbn, 25 tbc
Stream mapping:
  Stream #0:0 -> #0:0 (rawvideo -> rawvideo)
frame=    1 fps=  0 q=0.0 Lsize=      96kB time=00:00:00.04 bitrate=19660.8kbits
/s
video:96kB audio:0kB global headers:0kB muxing overhead 0.000000%  

*/


#include <stdio.h>

#ifdef WIN32
#include <fcntl.h>
#endif

int main (void)
{
  int i, j;
  #ifdef WIN32
  setmode (fileno (stdout), O_BINARY);
  setmode (fileno (stdin), O_BINARY);
  #endif

  
  for (j = 0; j < 256; j++)
  {
    for (i = 0; i < 256; i++)
    {
      // format is bgr24
      // b: 0 to 240 step 16 in vertical 16 pixel stripes
      putchar (j / 16 * 16);
      // g: 0 to 240 step 16 in horizontal 16 pixel stripes
      putchar (i / 16 * 16);
      // r: constant 128
      putchar (128);
    }
  }
  return 0;
}

