Archive for March, 2008

shadow steps in blender?

Sunday, March 30th, 2008

Getting steps in shadows where you should be getting a smooth gradient in blender? If you are on Linux, make sure your X server is not running with a pixel depth of less than 24. I didn’t expect that this would affect the rendered images, as opposed to how they appear on screen, but it does. This affects flat surfaces with fairly dark shadows - you get a quantization effect that in hindsight should have shouted “pixel depth”…

ffmpeg upgrading

Tuesday, March 18th, 2008

Ffmpeg is the most changing-est library I know.

The “img_convert” method is on the way out. The replacement is to use the swscale library. Here’s a rough conversion between the two:

int stable_img_convert (AVPicture *dst, int dst_pix_fmt,
                        const AVPicture *src, int src_pix_fmt,
                        int src_width, int src_height) {
#ifdef OLD_FFMPEG
  return img_convert(dst,dst_pix_fmt,src,src_pix_fmt,src_width,src_height);
#else
  int w = src_width;
  int h = src_height;
  static struct SwsContext *img_convert_ctx = NULL;
  if (img_convert_ctx==NULL) {
    img_convert_ctx = sws_getContext(src_width, src_height,
                                     dst_pix_fmt,
                                     src_width, src_height,
                                     src_pix_fmt,
                                     0, NULL, NULL, NULL);
  }
  if (img_convert_ctx!=NULL) {
    sws_scale(img_convert_ctx, ((AVPicture*)src)->data,
              ((AVPicture*)src)->linesize, 0, src_height,
              ((AVPicture*)dst)->data, ((AVPicture*)dst)->linesize);
  } else {
    fprintf(stderr,“image conversion failed\n);
    return -1;
  }
  return 0;
#endif
}

To convert for real, you’ll need to factor out the static “SwsContext” object that gets created in the middle of the code; as it is you’d have big trouble if you are processing multiple streams or changing sources as you go along.