16 #ifndef OPENSHOT_FFMPEG_READER_H 
   17 #define OPENSHOT_FFMPEG_READER_H 
  106         AVFormatContext *pFormatCtx;
 
  107         int videoStream, audioStream;
 
  108         AVCodecContext *pCodecCtx, *aCodecCtx;
 
  110         AVBufferRef *hw_device_ctx = NULL; 
 
  112         AVStream *pStream, *aStream;
 
  116         bool is_duration_known;
 
  117         bool check_interlace;
 
  119         int max_concurrent_frames;
 
  129         std::shared_ptr<openshot::Frame> last_video_frame;
 
  133         int64_t seeking_frame;
 
  136         int64_t seek_audio_frame_found;
 
  137         int64_t seek_video_frame_found;
 
  140         int64_t largest_frame_processed;
 
  141         int64_t current_video_frame;
 
  146         double pts_offset_seconds;
 
  147         double audio_pts_seconds;
 
  148         double video_pts_seconds;
 
  149         int64_t NO_PTS_OFFSET;
 
  153         SwsContext *img_convert_ctx = 
nullptr;        
 
  155         AVFrame *pFrameRGB_cached = 
nullptr;          
 
  157         int hw_de_supported = 0;    
 
  159         AVPixelFormat hw_de_av_pix_fmt = AV_PIX_FMT_NONE;
 
  160         AVHWDeviceType hw_de_av_device_type = AV_HWDEVICE_TYPE_NONE;
 
  161         int IsHardwareDecodeSupported(
int codecid);
 
  168         bool CheckSeek(
bool is_video);
 
  171         void CheckWorkingFrames(int64_t requested_frame);
 
  174         int64_t ConvertFrameToAudioPTS(int64_t frame_number);
 
  177         int64_t ConvertFrameToVideoPTS(int64_t frame_number);
 
  180         int64_t ConvertVideoPTStoFrame(int64_t pts);
 
  183         std::shared_ptr<openshot::Frame> CreateFrame(int64_t requested_frame);
 
  195         int64_t GetPacketPTS();
 
  201         bool IsPartialFrame(int64_t requested_frame);
 
  204         void ProcessVideoPacket(int64_t requested_frame);
 
  207         void ProcessAudioPacket(int64_t requested_frame);
 
  210         std::shared_ptr<openshot::Frame> ReadStream(int64_t requested_frame);
 
  213         void RemoveAVFrame(AVFrame *);
 
  216         void RemoveAVPacket(AVPacket *);
 
  219         void Seek(int64_t requested_frame);
 
  224         void UpdatePTSOffset();
 
  227         void UpdateAudioInfo();
 
  230         void UpdateVideoInfo();
 
  246         FFmpegReader(
const std::string& path, 
bool inspect_reader=
true);
 
  252         void Close() 
override;
 
  261         std::shared_ptr<openshot::Frame> 
GetFrame(int64_t requested_frame) 
override;
 
  264         bool IsOpen()
 override { 
return is_open; };
 
  267         std::string 
Name()
 override { 
return "FFmpegReader"; };
 
  270         std::string 
Json() 
const override; 
 
  271         void SetJson(
const std::string value) 
override; 
 
  276         void Open() 
override;