a
554325746@qq.com
2019-07-15 e6c8834e2aa2f3c1f46e588d94ae8ec6aa6c8dec
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
#ifndef _FFMPEG_FORMAT_CONTEXT_IN_H_
#define _FFMPEG_FORMAT_CONTEXT_IN_H_
 
#include <memory>
 
struct AVFormatContext;
struct AVDictionary;
struct AVStream;
struct AVCodecContext;
struct AVPacket;
struct AVFrame;
struct AVCodec;
 
namespace ffwrapper{
 
    class VideoProp;
    class CodedData;
    class FrameData;
 
    class FormatIn
    {
    public:
        explicit FormatIn(bool hw=true);
        ~FormatIn();
        
    public:
        int open(const char *filename, AVDictionary **options);
        bool findStreamInfo(AVDictionary **options);
 
        bool openCodec(const int type, AVDictionary **options);
        
        bool readPacket(AVPacket &pkt_out, int stream_index = 0);
        bool readPacket(std::shared_ptr<CodedData> &data, int stream_index = 0);
 
        int decode(AVFrame* &frame, AVPacket &pkt);
        int decode(std::shared_ptr<FrameData> &frame_data,
                    std::shared_ptr<CodedData> &data);
        
        int readFrame(AVFrame* &frame);
        int readFrame(std::shared_ptr<FrameData> &frame_data);
 
    private:
        bool allocCodec(AVCodec *dec, AVStream *s, AVDictionary **options);
    public:
        AVStream *getStream(int type = 0);
        AVCodecContext *getCodecContext(int type = 0);
    private:
         AVFormatContext     *ctx_;
         AVCodecContext         *dec_ctx_;
         int                 vs_idx_;
 
         bool                 hw_accl_;
 
    };
}
 
#endif