AVPKit
com::avpkit::core::IVideoPicture Class Referenceabstract

Represents one raw (undecoded) picture in a video stream, plus a timestamp for when to display that video picture relative to other items in a IContainer. More...

#include <IVideoPicture.h>

Inheritance diagram for com::avpkit::core::IVideoPicture:
Collaboration diagram for com::avpkit::core::IVideoPicture:

Public Types

enum  PictType {
  DEFAULT_TYPE =0 , I_TYPE = 1 , P_TYPE = 2 , B_TYPE = 3 ,
  S_TYPE = 4 , SI_TYPE = 5 , SP_TYPE = 6 , BI_TYPE = 7
}
 The different types of images that we can set. More...
 
enum  FrameDataType {
  AV_FRAME_DATA_PANSCAN , AV_FRAME_DATA_A53_CC , AV_FRAME_DATA_STEREO3D , AV_FRAME_DATA_MATRIXENCODING ,
  AV_FRAME_DATA_DOWNMIX_INFO , AV_FRAME_DATA_REPLAYGAIN , AV_FRAME_DATA_DISPLAYMATRIX , AV_FRAME_DATA_AFD ,
  AV_FRAME_DATA_MOTION_VECTORS , AV_FRAME_DATA_SKIP_SAMPLES , AV_FRAME_DATA_AUDIO_SERVICE_TYPE , AV_FRAME_DATA_MASTERING_DISPLAY_METADATA ,
  AV_FRAME_DATA_GOP_TIMECODE , AV_FRAME_DATA_SPHERICAL , AV_FRAME_DATA_CONTENT_LIGHT_LEVEL , AV_FRAME_DATA_ICC_PROFILE
}
 

Public Member Functions

virtual bool isKeyFrame ()=0
 Is this a key frame? More...
 
virtual void setKeyFrame (bool aIsKey)=0
 Reset if this is a key frame or not. More...
 
virtual bool isComplete ()=0
 Is this picture completely decoded? More...
 
virtual int32_t getSize ()=0
 Total size in bytes of the decoded picture. More...
 
virtual int getWidth ()=0
 What is the width of the picture. More...
 
virtual int getHeight ()=0
 What is the height of the picture. More...
 
virtual IPixelFormat::Type getPixelType ()=0
 Returns the pixel format of the picture. More...
 
virtual int64_t getPts ()=0
 What is the Presentation Time Stamp (in Microseconds) of this picture. More...
 
virtual void setPts (int64_t value)=0
 Set the Presentation Time Stamp (in Microseconds) for this picture. More...
 
virtual int getQuality ()=0
 This value is the quality setting this VideoPicture had when it was decoded, or is the value to use when this picture is next encoded (if reset with setQuality() More...
 
virtual void setQuality (int newQuality)=0
 Set the Quality to a new value. More...
 
virtual int getDataLineSize (int lineNo)=0
 Return the size of each line in the VideoPicture data. More...
 
virtual void setComplete (bool aIsComplete, IPixelFormat::Type format, int width, int height, int64_t pts)=0
 After modifying the raw data in this buffer, call this function to let the object know it is now complete. More...
 
virtual bool copy (IVideoPicture *srcPicture)=0
 Copy the contents of the given picture into this picture. More...
 
virtual void render (bool drop=false, int64_t timeStamp=-1)=0
 Render this picture on configured surface. More...
 
virtual void * getOpaqueData ()=0
 
virtual PictType getPictureType ()=0
 Get the picture type. More...
 
virtual void setPictureType (PictType type)=0
 Set the picture type. More...
 
virtual void setSideData (FrameDataType type, com::avpkit::ferry::IBuffer *buffer)=0
 
- Public Member Functions inherited from com::avpkit::core::IMediaData
virtual int64_t getTimeStamp ()=0
 Get the time stamp of this object in getTimeBase() units. More...
 
virtual void setTimeStamp (int64_t aTimeStamp)=0
 Set the time stamp for this object in getTimeBase() units. More...
 
virtual IRationalgetTimeBase ()=0
 Get the time base that time stamps of this object are represented in. More...
 
virtual void setTimeBase (IRational *aBase)=0
 Set the time base that time stamps of this object are represented in. More...
 
virtual com::avpkit::ferry::IBuffergetData ()=0
 Get any underlying raw data available for this object. More...
 
virtual bool isKey ()=0
 Is this object a key object? i.e. More...
 
virtual void setData (com::avpkit::ferry::IBuffer *buffer)=0
 Sets the underlying buffer used by this object. More...
 
- Public Member Functions inherited from com::avpkit::ferry::RefCounted
virtual int32_t acquire ()
 Internal Only. More...
 
virtual int32_t release ()
 Internal Only. More...
 
virtual RefCountedcopyReference ()
 Create a new Java object that refers to the same native object. More...
 
virtual int32_t getCurrentRefCount ()
 Return the current reference count on this object. More...
 
void setJavaAllocator (void *allocator)
 This method is public but not part of the standard API. More...
 
void * getJavaAllocator ()
 This method is public but not part of the standard API. More...
 

Static Public Member Functions

static IVideoPicturemake (IPixelFormat::Type format, int width, int height)
 Get a new picture object. More...
 
static IVideoPicturemake (IVideoPicture *src)
 Get a new picture by copying the data in an existing frame. More...
 
static IVideoPicturemake (com::avpkit::ferry::IBuffer *buffer, IPixelFormat::Type format, int width, int height)
 Get a new picture object, by wrapping an existing com.avpkit.ferry.IBuffer. More...
 

Additional Inherited Members

- Protected Member Functions inherited from com::avpkit::ferry::RefCounted
virtual void destroy ()
 This method is called by RefCounted objects when their Ref Count reaches zero and they are about to be destroyed.
 
- Protected Attributes inherited from com::avpkit::ferry::RefCounted
AtomicIntegermRefCount
 This is the internal reference count, represented as an AtomicInteger to make sure it is thread safe.
 
void * mAllocator
 Not part of public API.
 

Detailed Description

Represents one raw (undecoded) picture in a video stream, plus a timestamp for when to display that video picture relative to other items in a IContainer.

All timestamps for this object are always in Microseconds.

Definition at line 39 of file IVideoPicture.h.

Member Enumeration Documentation

◆ FrameDataType

Enumerator
AV_FRAME_DATA_PANSCAN 

The data is the AVPanScan struct defined in libavcodec.

AV_FRAME_DATA_A53_CC 

ATSC A53 Part 4 Closed Captions.

A53 CC bitstream is stored as uint8_t in AVFrameSideData.data. The number of bytes of CC data is AVFrameSideData.size.

AV_FRAME_DATA_STEREO3D 

Stereoscopic 3d metadata.

The data is the AVStereo3D struct defined in libavutil/stereo3d.h.

AV_FRAME_DATA_MATRIXENCODING 

The data is the AVMatrixEncoding enum defined in libavutil/channel_layout.h.

AV_FRAME_DATA_DOWNMIX_INFO 

Metadata relevant to a downmix procedure.

The data is the AVDownmixInfo struct defined in libavutil/downmix_info.h.

AV_FRAME_DATA_REPLAYGAIN 

ReplayGain information in the form of the AVReplayGain struct.

AV_FRAME_DATA_DISPLAYMATRIX 

This side data contains a 3x3 transformation matrix describing an affine transformation that needs to be applied to the frame for correct presentation.

See libavutil/display.h for a detailed description of the data.

AV_FRAME_DATA_AFD 

Active Format Description data consisting of a single byte as specified in ETSI TS 101 154 using AVActiveFormatDescription enum.

AV_FRAME_DATA_MOTION_VECTORS 

Motion vectors exported by some codecs (on demand through the export_mvs flag set in the libavcodec AVCodecContext flags2 option).

The data is the AVMotionVector struct defined in libavutil/motion_vector.h.

AV_FRAME_DATA_SKIP_SAMPLES 

Recommmends skipping the specified number of samples.

This is exported only if the "skip_manual" AVOption is set in libavcodec. This has the same format as AV_PKT_DATA_SKIP_SAMPLES.

u32le number of samples to skip from start of this packet
u32le number of samples to skip from end of this packet
u8 reason for start skip
u8 reason for end skip (0=padding silence, 1=convergence)
AV_FRAME_DATA_AUDIO_SERVICE_TYPE 

This side data must be associated with an audio frame and corresponds to enum AVAudioServiceType defined in avcodec.h.

AV_FRAME_DATA_MASTERING_DISPLAY_METADATA 

Mastering display metadata associated with a video frame.

The payload is an AVMasteringDisplayMetadata type and contains information about the mastering display color volume.

AV_FRAME_DATA_GOP_TIMECODE 

The GOP timecode in 25 bit timecode format.

Data format is 64-bit integer. This is set on the first frame of a GOP that has a temporal reference of 0.

AV_FRAME_DATA_SPHERICAL 

The data represents the AVSphericalMapping structure defined in libavutil/spherical.h.

AV_FRAME_DATA_CONTENT_LIGHT_LEVEL 

Content light level (based on CTA-861.3).

This payload contains data in the form of the AVContentLightMetadata struct.

AV_FRAME_DATA_ICC_PROFILE 

The data contains an ICC profile as an opaque octet buffer following the format described by ISO 15076-1 with an optional name defined in the metadata key entry "name".

Definition at line 255 of file IVideoPicture.h.

255  {
332 
338 
344 
351  } FrameDataType;
@ AV_FRAME_DATA_CONTENT_LIGHT_LEVEL
Content light level (based on CTA-861.3).
@ AV_FRAME_DATA_MASTERING_DISPLAY_METADATA
Mastering display metadata associated with a video frame.
@ AV_FRAME_DATA_DISPLAYMATRIX
This side data contains a 3x3 transformation matrix describing an affine transformation that needs to...
@ AV_FRAME_DATA_ICC_PROFILE
The data contains an ICC profile as an opaque octet buffer following the format described by ISO 1507...
@ AV_FRAME_DATA_MOTION_VECTORS
Motion vectors exported by some codecs (on demand through the export_mvs flag set in the libavcodec A...
@ AV_FRAME_DATA_A53_CC
ATSC A53 Part 4 Closed Captions.
@ AV_FRAME_DATA_STEREO3D
Stereoscopic 3d metadata.
@ AV_FRAME_DATA_PANSCAN
The data is the AVPanScan struct defined in libavcodec.
@ AV_FRAME_DATA_MATRIXENCODING
The data is the AVMatrixEncoding enum defined in libavutil/channel_layout.h.
@ AV_FRAME_DATA_SPHERICAL
The data represents the AVSphericalMapping structure defined in libavutil/spherical....
@ AV_FRAME_DATA_AFD
Active Format Description data consisting of a single byte as specified in ETSI TS 101 154 using AVAc...
@ AV_FRAME_DATA_AUDIO_SERVICE_TYPE
This side data must be associated with an audio frame and corresponds to enum AVAudioServiceType defi...
@ AV_FRAME_DATA_DOWNMIX_INFO
Metadata relevant to a downmix procedure.
@ AV_FRAME_DATA_GOP_TIMECODE
The GOP timecode in 25 bit timecode format.
@ AV_FRAME_DATA_SKIP_SAMPLES
Recommmends skipping the specified number of samples.
@ AV_FRAME_DATA_REPLAYGAIN
ReplayGain information in the form of the AVReplayGain struct.

◆ PictType

The different types of images that we can set.

See also
getPictureType()

Definition at line 221 of file IVideoPicture.h.

221  {
222  DEFAULT_TYPE=0,
223  I_TYPE = 1,
224  P_TYPE = 2,
225  B_TYPE = 3,
226  S_TYPE = 4,
227  SI_TYPE = 5,
228  SP_TYPE = 6,
229  BI_TYPE = 7,
230  } PictType;
PictType
The different types of images that we can set.

Member Function Documentation

◆ copy()

virtual bool com::avpkit::core::IVideoPicture::copy ( IVideoPicture srcPicture)
pure virtual

Copy the contents of the given picture into this picture.

All buffers are copied by value, not be reference.

Parameters
srcPictureThe picture you want to copy.
Returns
true if a successful copy; false if not.

Implemented in com::avpkit::core::VideoPicture.

Referenced by make().

◆ getDataLineSize()

virtual int com::avpkit::core::IVideoPicture::getDataLineSize ( int  lineNo)
pure virtual

Return the size of each line in the VideoPicture data.

Usually there are no more than 4 lines, but the first line no that returns 0 is the end of the road.

Parameters
lineNoThe line you want to know the (byte) size of.
Returns
The size (in bytes) of that line in data.

Implemented in com::avpkit::core::VideoPicture.

◆ getHeight()

virtual int com::avpkit::core::IVideoPicture::getHeight ( )
pure virtual

What is the height of the picture.

Returns
the height of the picture

Implemented in com::avpkit::core::VideoPicture.

Referenced by com::avpkit::core::VideoPicture::copy(), com::avpkit::core::IPixelFormat::getYUV420PPixelOffset(), and make().

◆ getPictureType()

virtual PictType com::avpkit::core::IVideoPicture::getPictureType ( )
pure virtual

Get the picture type.

This will be set on decoding to tell you what type of packet this was decoded from, and when encoding is a request to the encoder for how to encode the picture.

The request may be ignored by your codec.

Returns
the picture type.

Implemented in com::avpkit::core::VideoPicture.

◆ getPixelType()

virtual IPixelFormat::Type com::avpkit::core::IVideoPicture::getPixelType ( )
pure virtual

Returns the pixel format of the picture.

Returns
the pixel format of the picture.

Implemented in com::avpkit::core::VideoPicture.

Referenced by com::avpkit::core::VideoPicture::copy(), com::avpkit::core::IPixelFormat::getYUV420PPixelOffset(), and make().

◆ getPts()

virtual int64_t com::avpkit::core::IVideoPicture::getPts ( )
pure virtual

What is the Presentation Time Stamp (in Microseconds) of this picture.

The PTS is is scaled so that 1 PTS = 1/1,000,000 of a second.

Returns
the presentation time stamp (pts)

Implemented in com::avpkit::core::VideoPicture.

Referenced by com::avpkit::core::VideoPicture::copy().

◆ getQuality()

virtual int com::avpkit::core::IVideoPicture::getQuality ( )
pure virtual

This value is the quality setting this VideoPicture had when it was decoded, or is the value to use when this picture is next encoded (if reset with setQuality()

Returns
The quality.

Implemented in com::avpkit::core::VideoPicture.

◆ getSize()

virtual int32_t com::avpkit::core::IVideoPicture::getSize ( )
pure virtual

Total size in bytes of the decoded picture.

Returns
number of bytes of decoded picture

Implements com::avpkit::core::IMediaData.

Implemented in com::avpkit::core::VideoPicture.

◆ getWidth()

virtual int com::avpkit::core::IVideoPicture::getWidth ( )
pure virtual

What is the width of the picture.

Returns
the width of the picture

Implemented in com::avpkit::core::VideoPicture.

Referenced by com::avpkit::core::VideoPicture::copy(), com::avpkit::core::IPixelFormat::getYUV420PPixelOffset(), and make().

◆ isComplete()

virtual bool com::avpkit::core::IVideoPicture::isComplete ( )
pure virtual

Is this picture completely decoded?

Returns
is this picture completely decoded?

Implemented in com::avpkit::core::VideoPicture.

Referenced by com::avpkit::core::VideoPicture::copy().

◆ isKeyFrame()

virtual bool com::avpkit::core::IVideoPicture::isKeyFrame ( )
pure virtual

Is this a key frame?

Returns
is this a key frame

Implemented in com::avpkit::core::VideoPicture.

◆ make() [1/3]

IVideoPicture * com::avpkit::core::IVideoPicture::make ( com::avpkit::ferry::IBuffer buffer,
IPixelFormat::Type  format,
int  width,
int  height 
)
static

Get a new picture object, by wrapping an existing com.avpkit.ferry.IBuffer.

Use this method if you have existing video data that you want to have us wrap and pass to FFmpeg. Note that if decoding into this video picture and the decoded data actually takes more space than is in this buffer, this object will release the reference to the passed in buffer and allocate a new buffer instead so the decode can continue.

Due to some decoders assembly optimizations, you should ensure the IBuffer you pass in has at least 8 more bytes than would typically be required based on the format, width and height.

Parameters
bufferThe com.avpkit.ferry.IBuffer to wrap.
formatThe pixel format (for example, YUV420P).
widthThe width of the picture, in pixels.
heightThe height of the picture, in pixels.
Returns
A new object, or null if we can't allocate one.

Definition at line 48 of file IVideoPicture.cpp.

51  {
52  Global::init();
53  return VideoPicture::make(buffer, format, width, height);
54  }
static void init()
Internal Only.
Definition: Global.cpp:157
static VideoPicture * make(IPixelFormat::Type format, int width, int height)
The default factory for a frame.

References com::avpkit::core::Global::init(), and com::avpkit::core::VideoPicture::make().

◆ make() [2/3]

IVideoPicture * com::avpkit::core::IVideoPicture::make ( IPixelFormat::Type  format,
int  width,
int  height 
)
static

Get a new picture object.

You can specify -1 for width and height, in which case all getData() methods will return error until AVPKIT decodes something into this frame. In general you should always try to specify the width and height.

Note that any buffers this objects needs will be lazily allocated (i.e. we won't actually grab all the memory until we need it).

This is useful because it allows you to hold a IVideoPicture object that remembers things like format, width, and height, but know that it doesn't actually take up a lot of memory until the first time someone tries to access that memory.

Parameters
formatThe pixel format (for example, YUV420P).
widthThe width of the picture, in pixels, or -1 if you want AVPKIT to guess when decoding.
heightThe height of the picture, in pixels, or -1 if you want AVPKIT to guess when decoding.
Returns
A new object, or null if we can't allocate one.

Definition at line 41 of file IVideoPicture.cpp.

42  {
43  Global::init();
44  return VideoPicture::make(format, width, height);
45  }

References com::avpkit::core::Global::init(), and com::avpkit::core::VideoPicture::make().

Referenced by make().

◆ make() [3/3]

IVideoPicture * com::avpkit::core::IVideoPicture::make ( IVideoPicture src)
static

Get a new picture by copying the data in an existing frame.

Parameters
srcThe picture to copy.
Returns
The new picture, or null on error.

Definition at line 58 of file IVideoPicture.cpp.

59  {
60  IVideoPicture* retval = 0;
61  Global::init();
62  try
63  {
64  if (!srcFrame)
65  throw std::runtime_error("no source data to copy");
66 
67  retval = IVideoPicture::make(srcFrame->getPixelType(), srcFrame->getWidth(), srcFrame->getHeight());
68  if (!retval)
69  throw std::runtime_error("could not allocate new frame");
70 
71  if (!retval->copy(srcFrame))
72  throw std::runtime_error("could not copy source frame");
73  }
74  catch (std::bad_alloc &e)
75  {
76  VS_REF_RELEASE(retval);
77  throw e;
78  }
79  catch (std::exception & e)
80  {
81  VS_LOG_DEBUG("got error: %s", e.what());
82  VS_REF_RELEASE(retval);
83  }
84  return retval;
85  }
static IVideoPicture * make(IPixelFormat::Type format, int width, int height)
Get a new picture object.

References copy(), getHeight(), getPixelType(), getWidth(), com::avpkit::core::Global::init(), and make().

◆ render()

virtual void com::avpkit::core::IVideoPicture::render ( bool  drop = false,
int64_t  timeStamp = -1 
)
pure virtual

Render this picture on configured surface.

Works only with HW accelerated com.avpkit.core.IPixelFormat. com.avpkit.core.IStreamCoder#setHardwareDecoding(IPixelFormat.Type, Object) must be called before opening decoder.

Implemented in com::avpkit::core::VideoPicture.

◆ setComplete()

virtual void com::avpkit::core::IVideoPicture::setComplete ( bool  aIsComplete,
IPixelFormat::Type  format,
int  width,
int  height,
int64_t  pts 
)
pure virtual

After modifying the raw data in this buffer, call this function to let the object know it is now complete.

Parameters
aIsCompleteIs this VideoPicture complete
formatThe pixel format of the data in this picture. Must match what the picture was originally constructed with.
widthThe width of the data in this picture. Must match what the picture was originally constructed with.
heightThe height of the data in this picture. Must match what the picture was originally constructed with.
ptsThe presentation timestamp of the picture that is now complete. The caller must ensure this PTS is in units of 1/1,000,000 seconds.

Implemented in com::avpkit::core::VideoPicture.

◆ setKeyFrame()

virtual void com::avpkit::core::IVideoPicture::setKeyFrame ( bool  aIsKey)
pure virtual

Reset if this is a key frame or not.

Note that regardless of how this flag is set, an IVideoPicture always contains raw video data (hence the key setting isn't really that important).

Parameters
aIsKeyTrue if a key frame; false if not.

Implemented in com::avpkit::core::VideoPicture.

◆ setPictureType()

virtual void com::avpkit::core::IVideoPicture::setPictureType ( PictType  type)
pure virtual

Set the picture type.

Parameters
typeThe type.
See also
getPictureType()

Implemented in com::avpkit::core::VideoPicture.

◆ setPts()

virtual void com::avpkit::core::IVideoPicture::setPts ( int64_t  value)
pure virtual

Set the Presentation Time Stamp (in Microseconds) for this picture.

See also
getPts()
Parameters
valuethe new timestamp

Implemented in com::avpkit::core::VideoPicture.

◆ setQuality()

virtual void com::avpkit::core::IVideoPicture::setQuality ( int  newQuality)
pure virtual

Set the Quality to a new value.

This will be used the next time this VideoPicture is encoded by a StreamCoder

Parameters
newQualityThe new quality.

Implemented in com::avpkit::core::VideoPicture.


The documentation for this class was generated from the following files: