亚洲在线久爱草,狠狠天天香蕉网,天天搞日日干久草,伊人亚洲日本欧美

為了賬號安全,請及時綁定郵箱和手機立即綁定
已解決430363個問題,去搜搜看,總會有你想問的

如何在Android用FFmpeg解碼圖像

如何在Android用FFmpeg解碼圖像

慕村9548890 2018-10-01 12:12:08
查看完整描述

1 回答

?
動漫人物

TA貢獻1815條經驗 獲得超10個贊

 創建一個VideoPicture結構體用來保存解碼出來的圖像。

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
/* 
 * SDL_Lesson.c 
 * 
 *  Created on: Aug 12, 2014 
 *      Author: clarck 
 */ 
#include <jni.h> 
#include <android/native_window_jni.h> 
#include "SDL.h" 
#include "SDL_thread.h" 
#include "SDL_events.h" 
#include "../include/logger.h" 
#include "../ffmpeg/includebavcodec/avcodec.h" 
#include "../ffmpeg/includebavformat/avformat.h" 
#include "../ffmpeg/includebavutil/pixfmt.h" 
#include "../ffmpeg/includebswscale/swscale.h" 
#include "../ffmpeg/includebswresample/swresample.h" 
      
#define SDL_AUDIO_BUFFER_SIZE 1024 
      
#define MAX_AUDIO_SIZE (5 * 16 * 1024) 
#define MAX_VIDEO_SIZE (5 * 256 * 1024) 
      
#define FF_ALLOC_EVENT (SDL_USEREVENT) 
#define FF_REFRESH_EVENT (SDL_USEREVENT + 1) 
#define FF_QUIT_EVENT    (SDL_USEREVENT + 2) 
      
#define VIDEO_PICTURE_QUEUE_SIZE 1 
#define AVCODEC_MAX_AUDIO_FRAME_SIZE 192000 // 1 second of 48khz 32bit audio 
      
typedef struct PacketQueue { 
    AVPacketList *first_pkt, *last_pkt; 
    int nb_packets; 
    int size; 
    SDL_mutex *mutex; 
    SDL_cond *cond; 
} PacketQueue; 
      
typedef struct VideoPicture { 
    SDL_Window *screen; 
    SDL_Renderer *renderer; 
    SDL_Texture *bmp; 
      
    AVFrame* rawdata; 
    int width, height; /*source height & width*/ 
    int allocated; 
} VideoPicture; 
      
typedef struct VideoState { 
    char filename[1024]; 
    AVFormatContext *ic; 
    int videoStream, audioStream; 
    AVStream *audio_st; 
    AVFrame *audio_frame; 
    PacketQueue audioq; 
    unsigned int audio_buf_size; 
    unsigned int audio_buf_index; 
    AVPacket audio_pkt; 
    uint8_t *audio_pkt_data; 
    int audio_pkt_size; 
    uint8_t *audio_buf; 
    DECLARE_ALIGNED(16,uint8_t,audio_buf2) [AVCODEC_MAX_AUDIO_FRAME_SIZE * 4]; 
    enum AVSampleFormat audio_src_fmt; 
    enum AVSampleFormat audio_tgt_fmt; 
    int audio_src_channels; 
    int audio_tgt_channels; 
    int64_t audio_src_channel_layout; 
    int64_t audio_tgt_channel_layout; 
    int audio_src_freq; 
    int audio_tgt_freq; 
    struct SwrContext *swr_ctx; 
      
    AVStream *video_st; 
    PacketQueue videoq; 
      
    VideoPicture pictq[VIDEO_PICTURE_QUEUE_SIZE]; 
    int pictq_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; 
    struct SwsContext *sws_ctx; 
      
    int quit; 
} VideoState; 
      
VideoState *global_video_state; 


查看完整回答
反對 回復 2018-10-15
  • 1 回答
  • 0 關注
  • 837 瀏覽

添加回答

舉報

0/150
提交
取消
微信客服

購課補貼
聯系客服咨詢優惠詳情

幫助反饋 APP下載

慕課網APP
您的移動學習伙伴

公眾號

掃描二維碼
關注慕課網微信公眾號