FFmpeg
 All Data Structures Namespaces Files Functions Variables Typedefs Enumerations Enumerator Macros Groups Pages
Data Structures | Functions

Functions for working with AVPicture. More...

Data Structures

struct  AVPicture
 Picture data structure. More...
 

Functions

int avpicture_alloc (AVPicture *picture, enum AVPixelFormat pix_fmt, int width, int height)
 Allocate memory for the pixels of a picture and setup the AVPicture fields for it. More...
 
void avpicture_free (AVPicture *picture)
 Free a picture previously allocated by avpicture_alloc(). More...
 
int avpicture_fill (AVPicture *picture, const uint8_t *ptr, enum AVPixelFormat pix_fmt, int width, int height)
 Setup the picture fields based on the specified image parameters and the provided image data buffer. 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 the pixels of a picture and setup the AVPicture fields for it.

Call avpicture_free() to free it.

Parameters
picturethe picture structure to be filled in
pix_fmtthe pixel format of the picture
widththe width of the picture
heightthe height of the picture
Returns
zero if successful, a negative error code otherwise
See Also
av_image_alloc(), avpicture_fill()

Definition at line 54 of file avpicture.c.

Referenced by ff_create_schro_frame(), gen_sub_bitmap(), 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 67 of file avpicture.c.

Referenced by free_schro_frame(), and qtrle_encode_end().

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

Setup the picture fields based on the specified image parameters and the provided image data buffer.

The picture fields are filled in by using the image data buffer pointed to by ptr.

If ptr is NULL, the function will fill only the picture linesize array and return the required size for the image buffer.

To allocate an image buffer and fill the picture data in one call, use avpicture_alloc().

Parameters
picturethe picture to be filled in
ptrbuffer where the image data is stored, or NULL
pix_fmtthe pixel format of the image
widththe width of the image in pixels
heightthe height of the image in pixels
Returns
the size in bytes required for src, a negative error code in case of failure
See Also
av_image_fill_arrays()

Definition at line 34 of file avpicture.c.

Referenced by copy_frame(), raw_decode(), sdl_write_packet(), and xv_write_packet().

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.

avpicture_get_size() can be used to compute the required size for the buffer to fill.

Parameters
srcsource picture with filled data
pix_fmtpicture pixel format
widthpicture width
heightpicture height
destdestination buffer
dest_sizedestination buffer size in bytes
Returns
the number of bytes written to dest, or a negative value (error code) on error, for example if the destination buffer is not big enough
See Also
av_image_copy_to_buffer()

Definition at line 41 of file avpicture.c.

Referenced by encode_frame(), lavfi_read_packet(), 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.

Parameters
pix_fmtpicture pixel format
widthpicture width
heightpicture height
Returns
the computed picture buffer size or a negative error code in case of error
See Also
av_image_get_buffer_size().

Definition at line 49 of file avpicture.c.

Referenced by dc1394_read_common(), ff_decklink_read_header(), frm_read_packet(), lavfi_read_packet(), libschroedinger_encode_init(), pnm_encode_frame(), pnm_parse(), raw_decode(), raw_encode(), rawvideo_read_header(), rawvideo_read_packet(), targa_encode_frame(), utvideo_decode_init(), utvideo_encode_init(), v4l2_read_header(), vble_decode_init(), and yuv4_read_header().

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 409 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_image_copy().

Definition at line 72 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 198 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 229 of file imgconvert.c.