博客
关于我
强烈建议你试试无所不能的chatGPT,快点击我
QImage下 rgb32 转为 yuv420
阅读量:2238 次
发布时间:2019-05-09

本文共 1867 字,大约阅读时间需要 6 分钟。

//qWarning() << "update";    QPixmap pixmap = this->grab();    QImage image = pixmap.toImage();    //qWarning() << "byteCount " << image.byteCount();//    BYTE * rgb = new BYTE[bufsize];//    BYTE * yuv = new BYTE[bufsize * 3 / 2];//    RGB2YUV(&pStream, &yuv, 4, 640, 480)    int w = image.width();    int h = image.height();   // image.invertPixels(QImage::InvertRgb);    //==============================================================    AVFrame *pFrameRGB = avcodec_alloc_frame();    // Determine required buffer size and allocate buffer    int numBytes1 = avpicture_get_size(PIX_FMT_RGB32, w, h);    uint8_t *buffer1 = (uint8_t *)av_malloc(numBytes1*sizeof(uint8_t));    avpicture_fill((AVPicture *)pFrameRGB, buffer1, PIX_FMT_RGB32, w, h);    pFrameRGB->data[0] = image.bits();    qWarning() << "numBytes1 " << numBytes1;    AVFrame *pFrameYUV = avcodec_alloc_frame();    // Determine required buffer size and allocate buffer    int numBytes2 = avpicture_get_size(AV_PIX_FMT_YUV420P, w, h);    uint8_t *buffer2 = (uint8_t *)av_malloc(numBytes2*sizeof(uint8_t));    avpicture_fill((AVPicture *)pFrameYUV, buffer2, AV_PIX_FMT_YUV420P, w, h);    qWarning() << "numBytes2 " << numBytes2;    SwsContext *  rgb_to_yuv_ctx = sws_getContext(w,h, PIX_FMT_RGB32,                                  w,h, AV_PIX_FMT_YUV420P,                                  SWS_BICUBIC, NULL,NULL,NULL);//    sws_scale(rgb_to_yuv_ctx, pFrameRGB->data, pFrameRGB->linesize, 0,//            pCodecCtx->height, pFrameYUV->data, pFrameYUV->linesize);    sws_scale(rgb_to_yuv_ctx, pFrameRGB->data, pFrameRGB->linesize, 0,                h, pFrameYUV->data, pFrameYUV->linesize);        int rc = LE_ESVideoData(instance, buffer2, numBytes2);    //qWarning() << rc << endl;    sws_freeContext(rgb_to_yuv_ctx);    av_free(buffer1);    av_free(buffer2);    av_free(pFrameRGB);    av_free(pFrameYUV);

转载地址:http://gpabb.baihongyu.com/

你可能感兴趣的文章
(一)alin‘s mysql学习笔记----概述
查看>>
(二)alin’s mysql学习笔记----mysql的存储引擎
查看>>
(三)alin’s mysql学习笔记----常用的join连接查询
查看>>
(四)alin’s mysql学习笔记----索引简介
查看>>
分布式系统中的幂等性的理解
查看>>
spring的注解开发中的常用注解(一)------@bean @Configuration @ComponentScan @Import @Scope @Lazy
查看>>
(五)alin’s mysql学习笔记----索引性能分析
查看>>
Spring中使用@Transactional注解进行事务管理的时候只有应用到 public 方法才有效
查看>>
springboot整合rabbitmq及rabbitmq的简单入门
查看>>
mysql事务和隔离级别笔记
查看>>
事务的传播属性(有坑点)自调用失效学习笔记
查看>>
REDIS缓存穿透,缓存击穿,缓存雪崩原因+解决方案
查看>>
动态代理实现AOP
查看>>
23种常见的java设计模式
查看>>
关于被final修饰的基本数据类型一些注意事项
查看>>
java Thread中,run方法和start方法的区别
查看>>
在 XML 中有 5 个预定义的实体引用
查看>>
XML 元素是可扩展的
查看>>
避免 XML 属性?针对元数据的 XML 属性
查看>>
XML DOM nodeType 属性值代表的意思
查看>>