YUV422 to JPEG ---libjpeg 参考网页
来源:互联网 发布:拍孕肚用什么软件 编辑:程序博客网 时间:2024/06/03 15:27
找了好久终于找到一个例子,还没试验,先转载。
转自:http://blog.163.com/shuangxi_p/blog/static/107224272011374405634/
#include "jpeglib.h"
int yuv422_to_jpeg(unsigned char *data, int image_width, int image_height, FILE *fp, int quality)
{
struct jpeg_compress_struct cinfo;
struct jpeg_error_mgr jerr;
JSAMPROW row_pointer[1]; /* pointer to JSAMPLE row[s] */
int row_stride; /* physical row width in image buffer */
JSAMPIMAGE buffer;
int band,i,buf_width[3],buf_height[3], mem_size, max_line, counter;
unsigned char *yuv[3];
uint8_t *pSrc, *pDst;
yuv[0] = data;
yuv[1] = yuv[0] + (image_width * image_height);
yuv[2] = yuv[1] + (image_width * image_height) /2;
cinfo.err = jpeg_std_error(&jerr);
jpeg_create_compress(&cinfo);
jpeg_stdio_dest(&cinfo, fp);
cinfo.image_width = image_width; /* image width and height, in pixels */
cinfo.image_height = image_height;
cinfo.input_components = 3; /* # of color components per pixel */
cinfo.in_color_space = JCS_RGB; /* colorspace of input image */
jpeg_set_defaults(&cinfo);
jpeg_set_quality(&cinfo, quality, TRUE );
cinfo.raw_data_in = TRUE;
cinfo.jpeg_color_space = JCS_YCbCr;
cinfo.comp_info[0].h_samp_factor = 2;
cinfo.comp_info[0].v_samp_factor = 1;
jpeg_start_compress(&cinfo, TRUE);
buffer = (JSAMPIMAGE) (*cinfo.mem->alloc_small) ((j_common_ptr) &cinfo, JPOOL_IMAGE, 3 * sizeof(JSAMPARRAY));
for(band=0; band <3; band++)
{
buf_width[band] = cinfo.comp_info[band].width_in_blocks * DCTSIZE;
buf_height[band] = cinfo.comp_info[band].v_samp_factor * DCTSIZE;
buffer[band] = (*cinfo.mem->alloc_sarray) ((j_common_ptr) &cinfo, JPOOL_IMAGE, buf_width[band], buf_height[band]);
}
max_line = cinfo.max_v_samp_factor*DCTSIZE;
for(counter=0; cinfo.next_scanline < cinfo.image_height; counter++)
{
//buffer image copy.
for(band=0; band <3; band++)
{
mem_size = buf_width[band];
pDst = (uint8_t *) buffer[band][0];
pSrc = (uint8_t *) yuv[band] + counter*buf_height[band] * buf_width[band];
for(i=0; i <buf_height[band]; i++)
{
memcpy(pDst, pSrc, mem_size);
pSrc += buf_width[band];
pDst += buf_width[band];
}
}
jpeg_write_raw_data(&cinfo, buffer, max_line);
}
jpeg_finish_compress(&cinfo);
jpeg_destroy_compress(&cinfo);
return 0;
}
2.http://blog.csdn.net/axlrosek/archive/2007/03/29/1545496.aspx 当字典用
3.http://topic.csdn.net/u/20100518/17/98f52459-3158-492a-b6df-b1863336c6bb.html 改jpeglib.h头文件版本
4.http://blog.csdn.net/achellies/archive/2009/06/04/4238056.aspx 参考介绍
0 0
- YUV422 to JPEG ---libjpeg 参考网页
- encode RGB24 to jpeg, using libjpeg
- decoder jpeg to rgb 24, using libjpeg
- encode YUV420 to jpeg, using libjpeg
- ijl yuv422转jpeg
- ijl JPEG转Yuv422
- JPEG开源代码:libjpeg
- YUV422 to RGB565
- YUV422 to RGB 转换
- YUV422 to RGB565 Convert
- 使用libjpeg解码jpeg图片
- 使用libjpeg解码jpeg图片
- libjpeg-jpeg压缩与解压缩
- How to compile the IJG JPEG library (libjpeg) for Visual Studio 2010
- YUV422 to YUV420sp color invert
- 转载:libjpeg解码内存jpeg数据
- LibJpeg解码内存中的Jpeg数据
- 应用libjpeg提取jpeg质量因子
- Odoo8.0的弹窗通过标题栏进行移动
- 数字和日期之间的相互转换
- leetcode:Binary Tree Postorder Traversal
- java问题集锦
- android开发中常用的Eclipse快捷键详细解析
- YUV422 to JPEG ---libjpeg 参考网页
- Best Time to Buy and Sell Stock - LeetCode
- perl 包和模块
- Java 异常处理及其应用
- 【OpenCV入门教程之十七】OpenCV重映射 & SURF特征点检测合辑
- JavaWeb-17 (JDBC编程进阶2)
- setUp()、tearDown()、setUpBeforeClass()、tearDownAfterClass()的区分
- leetcode:Binary Tree Preorder Traversal
- PDM建模