Back to home page

EIC code displayed by LXR

 
 

    


Warning, file /include/opencascade/Media_Frame.hxx was not indexed or was modified since last indexation (in which case cross-reference links may be missing, inaccurate or erroneous).

0001 // Created by: Kirill GAVRILOV
0002 // Copyright (c) 2019 OPEN CASCADE SAS
0003 //
0004 // This file is part of Open CASCADE Technology software library.
0005 //
0006 // This library is free software; you can redistribute it and/or modify it under
0007 // the terms of the GNU Lesser General Public License version 2.1 as published
0008 // by the Free Software Foundation, with special exception defined in the file
0009 // OCCT_LGPL_EXCEPTION.txt. Consult the file LICENSE_LGPL_21.txt included in OCCT
0010 // distribution for complete text of the license and disclaimer of any warranty.
0011 //
0012 // Alternatively, this file may be used under the terms of Open CASCADE
0013 // commercial license or contractual agreement.
0014 
0015 #ifndef _Media_Frame_HeaderFile
0016 #define _Media_Frame_HeaderFile
0017 
0018 #include <NCollection_Vec2.hxx>
0019 #include <Standard_TypeDef.hxx>
0020 #include <Image_PixMap.hxx>
0021 #include <Standard_Transient.hxx>
0022 #include <Standard_Type.hxx>
0023 
0024 struct AVFrame;
0025 
0026 //! AVFrame wrapper - the frame (decoded image/audio sample data) holder.
0027 class Media_Frame : public Standard_Transient
0028 {
0029   DEFINE_STANDARD_RTTIEXT(Media_Frame, Standard_Transient)
0030 public:
0031   //! Convert pixel format from FFmpeg (AVPixelFormat) to OCCT.
0032   Standard_EXPORT static Image_Format FormatFFmpeg2Occt(int theFormat);
0033 
0034   //! Convert pixel format from OCCT to FFmpeg (AVPixelFormat).
0035   //! Returns -1 (AV_PIX_FMT_NONE) if undefined.
0036   Standard_EXPORT static int FormatOcct2FFmpeg(Image_Format theFormat);
0037 
0038   //! Swap AVFrame* within two frames.
0039   Standard_EXPORT static void Swap(const occ::handle<Media_Frame>& theFrame1,
0040                                    const occ::handle<Media_Frame>& theFrame2);
0041 
0042 public:
0043   //! Empty constructor
0044   Standard_EXPORT Media_Frame();
0045 
0046   //! Destructor
0047   Standard_EXPORT ~Media_Frame() override;
0048 
0049   //! Return true if frame does not contain any data.
0050   Standard_EXPORT bool IsEmpty() const;
0051 
0052   //! av_frame_unref() wrapper.
0053   Standard_EXPORT void Unref();
0054 
0055   //! Return image dimensions.
0056   NCollection_Vec2<int> Size() const { return NCollection_Vec2<int>(SizeX(), SizeY()); }
0057 
0058   //! Return image width.
0059   Standard_EXPORT int SizeX() const;
0060 
0061   //! Return image height.
0062   Standard_EXPORT int SizeY() const;
0063 
0064   //! Return pixel format (AVPixelFormat).
0065   Standard_EXPORT int Format() const;
0066 
0067   //! Return TRUE if YUV range is full.
0068   Standard_EXPORT bool IsFullRangeYUV() const;
0069 
0070   //! Access data plane for specified Id.
0071   Standard_EXPORT uint8_t* Plane(int thePlaneId) const;
0072 
0073   //! @return linesize in bytes for specified data plane
0074   Standard_EXPORT int LineSize(int thePlaneId) const;
0075 
0076   //! @return frame timestamp estimated using various heuristics, in stream time base
0077   Standard_EXPORT int64_t BestEffortTimestamp() const;
0078 
0079   //! Return frame.
0080   const AVFrame* Frame() const { return myFrame; }
0081 
0082   //! Return frame.
0083   AVFrame* ChangeFrame() { return myFrame; }
0084 
0085   //! Return presentation timestamp (PTS).
0086   double Pts() const { return myFramePts; }
0087 
0088   //! Set presentation timestamp (PTS).
0089   void SetPts(double thePts) { myFramePts = thePts; }
0090 
0091   //! Return PAR.
0092   float PixelAspectRatio() const { return myPixelRatio; }
0093 
0094   //! Set PAR.
0095   void SetPixelAspectRatio(float theRatio) { myPixelRatio = theRatio; }
0096 
0097   //! Return locked state.
0098   bool IsLocked() const { return myIsLocked; }
0099 
0100   //! Lock/free frame for edition.
0101   void SetLocked(bool theToLock) { myIsLocked = theToLock; }
0102 
0103 public:
0104   //! Wrap allocated image pixmap.
0105   Standard_EXPORT bool InitWrapper(const occ::handle<Image_PixMap>& thePixMap);
0106 
0107 protected:
0108   AVFrame* myFrame;      //!< frame
0109   double   myFramePts;   //!< presentation timestamp
0110   float    myPixelRatio; //!< pixel aspect ratio
0111   bool     myIsLocked;   //!< locked state
0112 };
0113 
0114 #endif // _Media_Frame_HeaderFile