Libav
Data Structures | Functions

Functions for working with AVPicture. More...

Data Structures

struct  AVPicture
 four components are given, that's all. More...
 

Functions

int avpicture_alloc (AVPicture *picture, enum AVPixelFormat pix_fmt, int width, int height)
 Allocate memory for a picture. More...
 
void avpicture_free (AVPicture *picture)
 Free a picture previously allocated by avpicture_alloc(). More...
 
int avpicture_fill (AVPicture *picture, uint8_t *ptr, enum AVPixelFormat pix_fmt, int width, int height)
 Fill in the AVPicture fields. More...
 
int avpicture_layout (const AVPicture *src, enum AVPixelFormat pix_fmt, int width, int height, unsigned char *dest, int dest_size)
 Copy pixel data from an AVPicture into a buffer. More...
 
int avpicture_get_size (enum AVPixelFormat pix_fmt, int width, int height)
 Calculate the size in bytes that a picture of the given width and height would occupy if stored in the given picture format. More...
 
attribute_deprecated int avpicture_deinterlace (AVPicture *dst, const AVPicture *src, enum AVPixelFormat pix_fmt, int width, int height)
 deinterlace - if not supported return -1 More...
 
void av_picture_copy (AVPicture *dst, const AVPicture *src, enum AVPixelFormat pix_fmt, int width, int height)
 Copy image src to dst. More...
 
int av_picture_crop (AVPicture *dst, const AVPicture *src, enum AVPixelFormat pix_fmt, int top_band, int left_band)
 Crop image top and left side. More...
 
int av_picture_pad (AVPicture *dst, const AVPicture *src, int height, int width, enum AVPixelFormat pix_fmt, int padtop, int padbottom, int padleft, int padright, int *color)
 Pad image. More...
 

Detailed Description

Functions for working with AVPicture.

Function Documentation

int avpicture_alloc ( AVPicture picture,
enum AVPixelFormat  pix_fmt,
int  width,
int  height 
)

Allocate memory for a picture.

Call avpicture_free() to free it.

See Also
avpicture_fill()
Parameters
picturethe picture to be filled in
pix_fmtthe format of the picture
widththe width of the picture
heightthe height of the picture
Returns
zero if successful, a negative value if not

Definition at line 101 of file avpicture.c.

Referenced by ff_create_schro_frame(), and qtrle_encode_init().

void avpicture_free ( AVPicture picture)

Free a picture previously allocated by avpicture_alloc().

The data buffer used by the AVPicture is freed, but the AVPicture structure itself is not.

Parameters
picturethe AVPicture to be freed

Definition at line 114 of file avpicture.c.

Referenced by free_schro_frame(), and qtrle_encode_end().

int avpicture_fill ( AVPicture picture,
uint8_t ptr,
enum AVPixelFormat  pix_fmt,
int  width,
int  height 
)

Fill in the AVPicture fields.

The fields of the given AVPicture are filled in by using the 'ptr' address which points to the image data buffer. Depending on the specified picture format, one or multiple image data pointers and line sizes will be set. If a planar format is specified, several pointers will be set pointing to the different picture planes and the line sizes of the different planes will be stored in the lines_sizes array. Call with ptr == NULL to get the required size for the ptr buffer.

To allocate the buffer and fill in the AVPicture fields in one call, use avpicture_alloc().

Parameters
pictureAVPicture whose fields are to be filled in
ptrBuffer which will contain or contains the actual image data
pix_fmtThe format in which the picture data is stored.
widththe width of the image in pixels
heightthe height of the image in pixels
Returns
size of the image data in bytes

Definition at line 34 of file avpicture.c.

Referenced by alloc_picture(), avpicture_get_size(), copy_frame(), and raw_decode().

int avpicture_layout ( const AVPicture src,
enum AVPixelFormat  pix_fmt,
int  width,
int  height,
unsigned char *  dest,
int  dest_size 
)

Copy pixel data from an AVPicture into a buffer.

The data is stored compactly, without any gaps for alignment or padding which may be applied by avpicture_fill().

See Also
avpicture_get_size()
Parameters
[in]srcAVPicture containing image data
[in]pix_fmtThe format in which the picture data is stored.
[in]widththe width of the image in pixels.
[in]heightthe height of the image in pixels.
[out]destA buffer into which picture data will be copied.
[in]dest_sizeThe size of 'dest'.
Returns
The number of bytes written to dest, or a negative value (error code) on error.

Definition at line 49 of file avpicture.c.

Referenced by encode_frame(), libschroedinger_frame_from_data(), and raw_encode().

int avpicture_get_size ( enum AVPixelFormat  pix_fmt,
int  width,
int  height 
)

Calculate the size in bytes that a picture of the given width and height would occupy if stored in the given picture format.

Note that this returns the size of a compact representation as generated by avpicture_layout(), which can be smaller than the size required for e.g. avpicture_fill().

Parameters
pix_fmtthe given picture format
widththe width of the image
heightthe height of the image
Returns
Image data size in bytes or -1 on error (e.g. too large dimensions).

Definition at line 85 of file avpicture.c.

Referenced by alloc_picture(), avpicture_layout(), dc1394_read_common(), encode_frame(), libschroedinger_encode_init(), pam_encode_frame(), pnm_encode_frame(), pnm_parse(), raw_encode(), raw_init_decoder(), rawvideo_read_packet(), targa_encode_frame(), v4l2_read_header(), vble_decode_init(), and yuv4_read_packet().

attribute_deprecated int avpicture_deinterlace ( AVPicture dst,
const AVPicture src,
enum AVPixelFormat  pix_fmt,
int  width,
int  height 
)

deinterlace - if not supported return -1

Deprecated:
  • use yadif (in libavfilter) instead

Definition at line 461 of file imgconvert.c.

void av_picture_copy ( AVPicture dst,
const AVPicture src,
enum AVPixelFormat  pix_fmt,
int  width,
int  height 
)

Copy image src to dst.

Wraps av_picture_data_copy() above.

Definition at line 119 of file avpicture.c.

Referenced by copy_frame(), qtrle_encode_frame(), queue_picture(), and roq_decode_frame().

int av_picture_crop ( AVPicture dst,
const AVPicture src,
enum AVPixelFormat  pix_fmt,
int  top_band,
int  left_band 
)

Crop image top and left side.

Definition at line 267 of file imgconvert.c.

int av_picture_pad ( AVPicture dst,
const AVPicture src,
int  height,
int  width,
enum AVPixelFormat  pix_fmt,
int  padtop,
int  padbottom,
int  padleft,
int  padright,
int *  color 
)

Pad image.

Definition at line 290 of file imgconvert.c.