如何在Android用FFmpeg+SDL2.0解码显示图像
2个回答
2017-08-14
展开全部
创建一个VideoPicture结构体用来保存解码出来的图像。12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091/**SDL_Lesson.c**Createdon:Aug12,2014*Author:clarck*/#include#include#include"SDL.h"#include"SDL_thread.h"#include"SDL_events.h"#include"../include/logger.h"#include"../ffmpeg/include/libavcodec/avcodec.h"#include"../ffmpeg/include/libavformat/avformat.h"#include"../ffmpeg/include/libavutil/pixfmt.h"#include"../ffmpeg/include/libswscale/swscale.h"#include"../ffmpeg/include/libswresample/swresample.h"#defineSDL_AUDIO_BUFFER_SIZE1024#defineMAX_AUDIO_SIZE(5*16*1024)#defineMAX_VIDEO_SIZE(5*256*1024)#defineFF_ALLOC_EVENT(SDL_USEREVENT)#defineFF_REFRESH_EVENT(SDL_USEREVENT+1)#defineFF_QUIT_EVENT(SDL_USEREVENT+2)#defineVIDEO_PICTURE_QUEUE_SIZE1#defineAVCODEC_MAX_AUDIO_FRAME_SIZE192000//1secondof48khz32bitaudiotypedefstructPacketQueue{AVPacketList*first_pkt,*last_pkt;intnb_packets;intsize;SDL_mutex*mutex;SDL_cond*cond;}PacketQueue;typedefstructVideoPicture{SDL_Window*screen;SDL_Renderer*renderer;SDL_Texture*bmp;AVFrame*rawdata;intwidth,height;/*sourceheight&width*/intallocated;}VideoPicture;typedefstructVideoState{charfilename[1024];AVFormatContext*ic;intvideoStream,audioStream;AVStream*audio_st;AVFrame*audio_frame;PacketQueueaudioq;unsignedintaudio_buf_size;unsignedintaudio_buf_index;AVPacketaudio_pkt;uint8_t*audio_pkt_data;intaudio_pkt_size;uint8_t*audio_buf;DECLARE_ALIGNED(16,uint8_t,audio_buf2)[AVCODEC_MAX_AUDIO_FRAME_SIZE*4];enumAVSampleFormataudio_src_fmt;enumAVSampleFormataudio_tgt_fmt;intaudio_src_channels;intaudio_tgt_channels;int64_taudio_src_channel_layout;int64_taudio_tgt_channel_layout;intaudio_src_freq;intaudio_tgt_freq;structSwrContext*swr_ctx;AVStream*video_st;PacketQueuevideoq;VideoPicturepictq[VIDEO_PICTURE_QUEUE_SIZE];intpictq_size,pictq_rindex,pictq_windex;SDL_mutex*pictq_mutex;SDL_cond*pictq_cond;SDL_Thread*parse_tid;SDL_Thread*audio_tid;SDL_Thread*video_tid;AVIOContext*io_ctx;structSwsContext*sws_ctx;intquit;}VideoState;VideoState*global_video_state;
已赞过
已踩过<
评论
收起
你对这个回答的评价是?
2017-08-14
展开全部
创建一个VideoPicture结构体用来保存解码出来的图像。/**SDL_Lesson.c**Createdon:Aug12,2014*Author:clarck*/#include#include#include"SDL.h"#include"SDL_thread.h"#include"SDL_events.h"#include"../include/logger.h"#include"../ffmpeg/include/libavcodec/avcodec.h"#include"../ffmpeg/include/libavformat/avformat.h"#include"../ffmpeg/include/libavutil/pixfmt.h"#include"../ffmpeg/include/libswscale/swscale.h"#include"../ffmpeg/include/libswresample/swresample.h"#defineSDL_AUDIO_BUFFER_SIZE1024#defineMAX_AUDIO_SIZE(5*16*1024)#defineMAX_VIDEO_SIZE(5*256*1024)#defineFF_ALLOC_EVENT(SDL_USEREVENT)#defineFF_REFRESH_EVENT(SDL_USEREVENT+1)#defineFF_QUIT_EVENT(SDL_USEREVENT+2)#defineVIDEO_PICTURE_QUEUE_SIZE1#defineAVCODEC_MAX_AUDIO_FRAME_SIZE192000//1secondof48khz32bitaudiotypedefstructPacketQueue{AVPacketList*first_pkt,*last_pkt;intnb_packets;intsize;SDL_mutex*mutex;SDL_cond*cond;}PacketQueue;typedefstructVideoPicture{SDL_Window*screen;SDL_Renderer*renderer;SDL_Texture*bmp;AVFrame*rawdata;intwidth,height;/*sourceheight&width*/intallocated;}VideoPicture;typedefstructVideoState{charfilename[1024];AVFormatContext*ic;intvideoStream,audioStream;AVStream*audio_st;AVFrame*audio_frame;PacketQueueaudioq;unsignedintaudio_buf_size;unsignedintaudio_buf_index;AVPacketaudio_pkt;uint8_t*audio_pkt_data;intaudio_pkt_size;uint8_t*audio_buf;DECLARE_ALIGNED(16,uint8_t,audio_buf2)[AVCODEC_MAX_AUDIO_FRAME_SIZE*4];enumAVSampleFormataudio_src_fmt;enumAVSampleFormataudio_tgt_fmt;intaudio_src_channels;intaudio_tgt_channels;int64_taudio_src_channel_layout;int64_taudio_tgt_channel_layout;intaudio_src_freq;intaudio_tgt_freq;structSwrContext*swr_ctx;AVStream*video_st;PacketQueuevideoq;VideoPicturepictq[VIDEO_PICTURE_QUEUE_SIZE];intpictq_size,pictq_rindex,pictq_windex;SDL_mutex*pictq_mutex;SDL_cond*pictq_cond;SDL_Thread*parse_tid;SDL_Thread*audio_tid;SDL_Thread*video_tid;AVIOContext*io_ctx;structSwsContext*sws_ctx;intquit;}VideoState;VideoState*global_video_state;
本回答被提问者采纳
已赞过
已踩过<
评论
收起
你对这个回答的评价是?
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询