AVFrame* YUV2RGB( AVCodecContext * avctx, AVFrame * frame )
{
AVFrame* pFrameRGB=NULL;
pFrameRGB=avcodec_alloc_frame(); if(pFrameRGB==NULL)
return NULL;
// Determine required buffer size and allocate buffer int numBytes=avpicture_get_size(PIX_FMT_BGR24, avctx->width,avctx->height); uint8_t * buffer=(uint8_t *)av_malloc(numBytes*sizeof(uint8_t)); // Assign appropriate parts of buffer to image planes in pFrameRGB
// Note that pFrameRGB is an AVFrame, but AVFrame is a superset
// of AVPicture
avpicture_fill((AVPicture *)pFrameRGB, buffer, PIX_FMT_BGR24,avctx->width, avctx->height); struct SwsContext *img_convert_ctx=NULL;
img_convert_ctx=sws_getCachedContext(img_convert_ctx,avctx->width,
avctx->height, avctx->pix_fmt,avctx->width, avctx->height,
PIX_FMT_RGB24, SWS_BICUBIC,NULL, NULL, NULL);
if( !img_convert_ctx )
{
fprintf(stderr, "Cannot initialize sws conversion context\n");
} sws_scale(img_convert_ctx, (const uint8_t* const*)frame->data,
frame->linesize, 0, avctx->height, pFrameRGB->data,
pFrameRGB->linesize); return pFrameRGB;
}

  

pFrameRGB用完要free的

FFmpeg YUV2RGB的更多相关文章

  1. FFmpeg资料来源简单分析:libswscale的sws_getContext()

    ===================================================== FFmpeg库函数的源代码的分析文章: [骨架] FFmpeg源码结构图 - 解码 FFmp ...

  2. FFmpeg源代码简单分析:libswscale的sws_getContext()

    ===================================================== FFmpeg的库函数源代码分析文章列表: [架构图] FFmpeg源代码结构图 - 解码 F ...

  3. 使用FFmpeg解码并用swscale将YUV转为RGB

    #include <stdio.h> #include <libavcodec/avcodec.h> #include <libavformat/avformat.h&g ...

  4. 图像视频编码和FFmpeg(2)-----YUV格式介绍和应用

    本文不讲FFmpeg,而是讲YUV图像格式.因为摄像头拍摄出来的原始图像一般都是YUV格式.在FFmpeg中,视频是通过多张YUV图像而得到. YUV图像格式是什么,这个可以看一下维基百科.这个超链接 ...

  5. FFMPEG相关开源项目

    1.FFmpeg build for android random architectures with example jnihttps://github.com/appunite/AndroidF ...

  6. FFmpeg 播放 RTSP/Webcam 流

    本文将介绍 FFmpeg 如何播放 RTSP/Webcam/File 流.流程如下: RTSP/Webcam/File > FFmpeg open and decode to BGR/YUV & ...

  7. FFmpeg学习6:视音频同步

    在上一篇文章中,视频和音频是各自独立播放的,并不同步.本文主要描述了如何以音频的播放时长为基准,将视频同步到音频上以实现视音频的同步播放的.主要有以下几个方面的内容 视音频同步的简单介绍 DTS 和 ...

  8. FFmpeg 中AVPacket的使用

    AVPacket保存的是解码前的数据,也就是压缩后的数据.该结构本身不直接包含数据,其有一个指向数据域的指针,FFmpeg中很多的数据结构都使用这种方法来管理数据. AVPacket的使用通常离不开下 ...

  9. FFmpeg + SoundTouch实现音频的变调变速

    本文使用FFmpeg + SoundTouch实现将音频解码后,进行变调变速处理,并将处理后的结果保存为WAV文件. 主要有以下内容: 实现一个FFmpeg的工具类,保存多媒体文件所需的解码信息 将解 ...

随机推荐

  1. CSU 1240 低调,低调。

    原题链接:http://acm.csu.edu.cn/OnlineJudge/problem.php?id=1240 这道题已经做了很久了,加入给足够大的内存,谁都会做. 在一个数列中找一个只出现一次 ...

  2. mysql 导入数据到postgresql

    创建PG的表脚本 DROP TABLE IF EXISTS "public"."t_resource_info"; CREATE TABLE "pub ...

  3. 使用jdk自带的工具native2ascii 转换Unicode字符和汉字

    1.控制台转换 1.1 将汉字转为Unicode: C:\Program Files\Java\jdk1.5.0_04\bin>native2ascii 测试 \u6d4b\u8bd5 1.2 ...

  4. vs2013设置语言

    设置语言格式 [工具]-[选项]-[国际化]

  5. 【PAT】1002. A+B for Polynomials (25)

    1002. A+B for Polynomials (25) This time, you are supposed to find A+B where A and B are two polynom ...

  6. 在 github 中新建仓库后,如何上传文件到这个仓库里面。

    在 github 中新建仓库后,如何上传文件到这个仓库里面. libin@hglibin MINGW64 /e/github.io (master) $ git remote libin@hglibi ...

  7. Coding.net进阶,使用Git管理代码

    原文来自:http://conw.net/archives/18/ (我自己的博客,点击链接查看文章最新版本) Git是目前最流行的版本控制系统,这里以GitHub为例,介绍git的基本使用. Git ...

  8. 初识GeneXus产品

    本人由于工作原因接触了GeneXus产品,从使用到现在也有些年头了.从刚开始的不熟悉到现在使用GeneXus开发了很多项目,慢慢也总结了一些经验,当然中间也走了很多的弯路.对于在国内同样使用GeneX ...

  9. Implementing x / 6 Using Only Bit Manipulations

    This is an interesting question from one of the lab assignments in Introduction to Computer Systems, ...

  10. springMVC整合freemarker遇到的问题 maven

    java.lang.IllegalAccessError: tried to access method freemarker.ext.servlet.AllHttpScopesHashModel.& ...