
Hi Phil,
The string ctor copies all the data, and then the istringstream ctor may or may not copy it all again (does anyone know?).
Did you see Kenny's email regarding boost::iostreams?
About libjpeg, thanks for pointing out one potential inefficiency. As far as I can tell rec_outbuf_height is set to 1 be default. A user can change that number to 2 or 4 but the lib would need to be recompiled. The user also need to set the UPSAMPLE_MERGING_SUPPORTED compiler flag.
Well, here's what it says in jpeglib.h:
/* Description of actual output image that will be returned to application. * These fields are computed by jpeg_start_decompress(). * You can also use jpeg_calc_output_dimensions() to determine these values * in advance of calling jpeg_start_decompress(). */
JDIMENSION output_width; /* scaled image width */ JDIMENSION output_height; /* scaled image height */ int out_color_components; /* # of color components in out_color_space */ int output_components; /* # of color components returned */ /* output_components is 1 (a colormap index) when quantizing colors; * otherwise it equals out_color_components. */ int rec_outbuf_height; /* min recommended height of scanline buffer */ /* If the buffer passed to jpeg_read_scanlines() is less than this many rows * high, space and time will be wasted due to unnecessary data copying. * Usually rec_outbuf_height will be 1 or 2, at most 4. */
To me, that looks like the library sets the value not the user.
There is a function called use_merged_upsample which returns only true when UPSAMPLE_MERGING_SUPPORTED is set during compilation. Otherwise cinfo->rec_outbuf_height = 1; That's the only assignment I can find in the whole libjpeg source code. Maybe I'm missing something? Regards, Christian