📄 wrsprite.c
字号:
(void) JFWRITE(dest->pub.output_file, dest->iobuffer, dest->buffer_width); }}/* * Write out data rotated by 90 degrees. */static void put_pixel32bpp_rows_rotate_left_90 (j_decompress_ptr cinfo, djpeg_dest_ptr dinfo, JDIMENSION rows_supplied){ sprite_dest_ptr const dest = (sprite_dest_ptr) dinfo; register JDIMENSION col = cinfo->output_width; unsigned int offset; /* calculate offset for writing */ offset = dest->image_offset; offset += sizeof(unsigned int) * (cinfo->output_scanline - rows_supplied); if ( col < JPEG_MAX_DIMENSION ) { /* work across the columns */ while(col--) { unsigned int row; register unsigned int *bufferptr = (unsigned int *)dest->iobuffer; /* seek to the start of the row */ if (dest->outfile) { ASSERT(offset>=dest->image_offset); dest->seekdst(offset, dest->outfile); } else { ASSERT(0); } for (row = 0; row < rows_supplied; row++) { register const JSAMPLE FAR *ptr = dest->pub.buffer[row]; unsigned int pix; ptr += col*3; pix = layers_fb_PACK32( GETJSAMPLE( ptr[0] ), GETJSAMPLE( ptr[1] ), GETJSAMPLE( ptr[2] ), layers_OPAQUE ); *bufferptr++ = pix; } if (dest->outfile) { dest->putdst((unsigned char *)dest->iobuffer, sizeof(unsigned int)*rows_supplied, dest->outfile); } else { (void) JFWRITE(dest->pub.output_file, sizeof(unsigned int)*rows_supplied, dest->buffer_width); } offset += dest->stride; } }}/* * Write out data rotated by 270 degrees. */static void put_pixel32bpp_rows_rotate_left_270 (j_decompress_ptr cinfo, djpeg_dest_ptr dinfo, JDIMENSION rows_supplied){ sprite_dest_ptr const dest = (sprite_dest_ptr) dinfo; JDIMENSION col = cinfo->output_width; unsigned int offset; /* calculate offset for writing */ offset = dest->image_offset; offset += sizeof(unsigned int) * (cinfo->output_height-cinfo->output_scanline); offset += dest->stride * (col - 1); if ( col < JPEG_MAX_DIMENSION ) { /* work across the columns */ while(col--) { unsigned int row; register unsigned int *bufferptr = (unsigned int *)dest->iobuffer + rows_supplied; if (dest->outfile) { ASSERT(offset>=dest->image_offset); dest->seekdst(offset, dest->outfile); } else { ASSERT(0); } for (row = 0; row < rows_supplied; row++) { register const JSAMPLE FAR *ptr = dest->pub.buffer[row]; unsigned int pix; ptr += col*3; pix = layers_fb_PACK32( GETJSAMPLE( ptr[0] ), GETJSAMPLE( ptr[1] ), GETJSAMPLE( ptr[2] ), layers_OPAQUE ); *--bufferptr = pix; } if (dest->outfile) { dest->putdst((unsigned char *)dest->iobuffer, sizeof(unsigned int)*rows_supplied, dest->outfile); } else { (void) JFWRITE(dest->pub.output_file, sizeof(unsigned int)*rows_supplied, dest->buffer_width); } offset -= dest->stride; } }}/* * Output 4:2:2 YUV, given 24bit YUV data as input (order y,u,v). */static void put_pixel422_rows ( j_decompress_ptr cinfo, djpeg_dest_ptr dinfo, JDIMENSION rows_supplied ){ sprite_dest_ptr const dest = (sprite_dest_ptr) dinfo; unsigned int y; for (y = 0; y<rows_supplied; y++ ) { register const JSAMPLE FAR * ptr = dest->pub.buffer[y]; register unsigned int *bufferptr = (unsigned int *)dest->iobuffer; register JDIMENSION col = cinfo->output_width; if ( col < JPEG_MAX_DIMENSION) { /* process two pixels at a time */ for ( ; col >= 2; col-=2) { unsigned int pix; /* pack YUV, ignoring every other thing's UV */ pix = layers_fb_PACKYUV422( GETJSAMPLE( ptr[0] ), GETJSAMPLE( ptr[1] ), GETJSAMPLE( ptr[3] ), GETJSAMPLE( ptr[2] ) ); *bufferptr++ = pix; ptr += 6; } } if (col==1) { unsigned int pix; /* pack YUV, ignoring every other thing's UV */ pix = layers_fb_PACKYUV422( GETJSAMPLE( ptr[0] ), GETJSAMPLE( ptr[1] ), GETJSAMPLE( ptr[0] ), GETJSAMPLE( ptr[2] ) ); *bufferptr++ = pix; ptr += 6; } if (dest->outfile) { dest->putdst((unsigned char *)dest->iobuffer, dest->buffer_width, dest->outfile); } else { (void) JFWRITE(dest->pub.output_file, dest->iobuffer, dest->buffer_width); } }}/* * Output 4:2:2 YUV, given 24bit YUV data as input (order y,u,v). Rotate through * 180 degrees. */static void put_pixel422_rows_rotate_left_180 ( j_decompress_ptr cinfo, djpeg_dest_ptr dinfo, JDIMENSION rows_supplied ){ sprite_dest_ptr const dest = (sprite_dest_ptr) dinfo; unsigned int y; unsigned int offset; offset = dest->image_offset; offset += dest->stride * (cinfo->output_height-cinfo->output_scanline+rows_supplied-1); for (y=0;y <rows_supplied; y++) { register JDIMENSION col = cinfo->output_width; ASSERT(offset>=dest->image_offset); if ( col < JPEG_MAX_DIMENSION) { register const JSAMPLE FAR * ptr = dest->pub.buffer[y]+3*cinfo->output_width-6; register unsigned int *bufferptr = (unsigned int *)dest->iobuffer; /* process two pixels at a time */ for ( ; col >= 2; col-=2) { unsigned int pix; /* pack YUV, ignoring every other thing's UV */ pix = layers_fb_PACKYUV422( GETJSAMPLE( ptr[3] ), GETJSAMPLE( ptr[1] ), GETJSAMPLE( ptr[0] ), GETJSAMPLE( ptr[2] ) ); *bufferptr++ = pix; ptr -= 6; } if (col==1) { unsigned int pix; ptr+=3; /* pack YUV, ignoring every other thing's UV */ pix = layers_fb_PACKYUV422( GETJSAMPLE( ptr[0] ), GETJSAMPLE( ptr[1] ), GETJSAMPLE( ptr[0] ), GETJSAMPLE( ptr[2] ) ); *bufferptr++ = pix; ptr -= 6; } } if (dest->outfile) { dest->seekdst(offset, dest->outfile); dest->putdst((unsigned char *)dest->iobuffer, dest->buffer_width, dest->outfile); } else { ASSERT(0); (void) JFWRITE(dest->pub.output_file, dest->iobuffer, dest->buffer_width); } offset-=dest->stride; }}/* * Output 4:2:2 YUV, given 24bit YUV data as input (order y,u,v). Rotate through * 90 degrees. We output a pixel from each of the supplied rows (usually 8 or 16 * rows are supplied) into the buffer, in pairs. */static void put_pixel422_rows_rotate_left_90 ( j_decompress_ptr cinfo, djpeg_dest_ptr dinfo, JDIMENSION rows_supplied ){ sprite_dest_ptr const dest = (sprite_dest_ptr) dinfo; unsigned int y; unsigned int x; register JDIMENSION col = cinfo->output_width; unsigned int offset; offset = dest->image_offset; offset += dest->stride*(cinfo->output_width-1); offset += ((cinfo->output_scanline - rows_supplied)/2)*sizeof(unsigned int); if ( col < JPEG_MAX_DIMENSION) { for (x=0;x<col;x++) { /* start a row of output here */ register unsigned int *bufferptr = (unsigned int *)dest->iobuffer; ASSERT(offset >= dest->image_offset); for (y=0;y<(rows_supplied & ~1); y+=2) { register const JSAMPLE FAR * ptr1 = dest->pub.buffer[y]+3*x; /* ptr to 1st of pair of values to write */ register const JSAMPLE FAR * ptr2 = dest->pub.buffer[y+1]+3*x; /* ptr to 2nd of pair of values to write */ unsigned int pix; /* pack YUV, ignoring every other thing's UV */ pix = layers_fb_PACKYUV422( GETJSAMPLE( ptr1[0] ), /* Y from first pixel */ GETJSAMPLE( ptr1[1] ), /* U from first pixel */ GETJSAMPLE( ptr2[0] ), /* Y from second pixel */ GETJSAMPLE( ptr1[2] ) ); /* V from first pixel */ *bufferptr++ = pix; } if (y<rows_supplied) { /* deal with odd row at the end: just replicate the Y value */ register const JSAMPLE FAR * ptr1 = dest->pub.buffer[y]+3*x; /* ptr to 1st of pair of values to write */ unsigned int pix; /* pack YUV, ignoring every other thing's UV */ pix = layers_fb_PACKYUV422( GETJSAMPLE( ptr1[0] ), /* Y from first pixel */ GETJSAMPLE( ptr1[1] ), /* U from first pixel */ GETJSAMPLE( ptr1[0] ), /* Y from second pixel */ GETJSAMPLE( ptr1[2] ) ); /* V from first pixel */ *bufferptr++ = pix; y++; } if (dest->outfile) { /* seek: start at botoom, left and work up in each row. */ dest->seekdst(offset, dest->outfile); dest->putdst((unsigned char *)dest->iobuffer, sizeof(int)*(((rows_supplied+1)&~1)/2), dest->outfile); } else { ASSERT(0); (void) JFWRITE(dest->pub.output_file, dest->iobuffer, dest->buffer_width); } offset -= dest->stride; } }}/* * Output 4:2:2 YUV, given 24bit YUV data as input (order y,u,v). Rotate through * 270 degrees. We output a pixel from each of the supplied rows (usually 8 or 16 * rows are supplied) into the buffer, in pairs. */static void put_pixel422_rows_rotate_left_270 ( j_decompress_ptr cinfo, djpeg_dest_ptr dinfo, JDIMENSION rows_supplied ){ sprite_dest_ptr const dest = (sprite_dest_ptr) dinfo; unsigned int y; unsigned int x; register JDIMENSION col = cinfo->output_width; unsigned int offset; offset = dest->image_offset; offset +=((cinfo->output_height - cinfo->output_scanline)/2)*sizeof(unsigned int); if ( col < JPEG_MAX_DIMENSION) { for (x=0;x<col;x++) { register unsigned int *start; register unsigned int *bufferptr; /* start a row of output here */ ASSERT(offset >= dest->image_offset); if ( ((cinfo->output_height & 1) == 0) ) { start = ((unsigned int *)dest->iobuffer)+((rows_supplied)/2); bufferptr = start; ASSERT((rows_supplied & 1)==0); for (y=rows_supplied;y>=2; y-=2) { register const JSAMPLE FAR * ptr1 = dest->pub.buffer[rows_supplied-y+1]+3*x; /* ptr to 1st of pair of values to write */ register const JSAMPLE FAR * ptr2 = dest->pub.buffer[rows_supplied-y]+3*x; /* ptr to 2nd of pair of values to write */ unsigned int pix; /* pack YUV, ignoring every other thing's UV */
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -