[Theora] theoraToRGB, and a problem with it

David Kment davidkment at web.de
Fri Nov 25 06:43:55 PST 2005


ok, now that is fixed. but the problem which i am fighting with since 
weeks is still present.
the RGB output looks weird, like if a color channel is missing.

but when using the conversion in some external program, with infile and 
outfile, it works perfectly (see code on bottom).

this problem just occurs when working with 2 buffers instead of 2 
files.... :(

demo code:

#include <stdio.h>

#define clip(a) (((a)&256) ? ((a)>>31)^(-1) : (a))

int main(void) {

  FILE* ifp = fopen("yuv.raw", "rb");
  FILE* ofp = fopen("rgb.raw", "ab");

  int offset = 0, y, u, v;

  while(offset < 512 * 384 * 3) {

    y = fgetc(ifp) - 16;
    u = fgetc(ifp) - 128;
    v = fgetc(ifp) - 128;

    fputc(clip((298 * y + 409 * v + 128) >> 8), ofp);
    fputc(clip((298 * y + 100 * u - 208 * v + 128) >> 8), ofp);
    fputc(clip((298 * y + 516 * u + 128) >> 8), ofp);

    offset += 3;
  }

  fclose(ifp);
  fclose(ofp);

  return 0;
}




More information about the Theora mailing list