=====avcodec_decode_video=====
====Overview====
Defined in ''avcodec.h''\\
Decodes a video frame from ''buf'' into ''picture''.\\
The avcodec_decode_video() function decodes a video frame from the input buffer ''buf'' of size ''buf_size''. To decode it, it makes use of the video codec which was coupled with ''avctx'' using avcodec_open(). The resulting decoded frame is stored in ''picture''.\\
**Warning:** The input buffer must be ''FF_INPUT_BUFFER_PADDING_SIZE'' larger than the actual read bytes because some optimized bitstream readers read 32 or 64 bits at once and could read over the end.\\
**Warning:** The end of the input buffer ''buf'' should be set to 0 to ensure that no overreading happens for damaged MPEG streams.\\
**Note:** You might have to align the input buffer ''buf'' and output buffer ''samples''. The alignment requirements depend on the CPU: on some CPUs it isn't necessary at all, on others it won't work at all if not aligned and on others it will work but it will have an impact on performance. In practice, the bitstream should have 4 byte alignment at minimum and all sample data should
be 16 byte aligned unless the CPU doesn't need it (AltiVec and SSE do). If the linesize is not a multiple of 16 then there's no sense in aligning the start of the buffer to 16.\\
int avcodec_decode_video(AVCodecContext *avctx,
AVFrame *picture,
int *got_picture_ptr,
uint8_t *buf,
int buf_size);
====Parameters====
===avctx===
AVCodecContext *avctx
A [[ffmpeg:AVCodecContext]] pointer to the codec context.
===picture===
AVFrame *picture
A pointer to the [[ffmpeg:AVFrame]] in which the decoded video frame will be stored.
===got_picture_ptr===
int *got_picture_ptr
An int pointer to which zero is written if no frame could be decompressed, otherwise, it is nonzero.
===buf===
uint8_t *buf
The input buffer.
===buf_size===
int buf_size
The size of the input buffer in bytes.
====Return value====
On error a negative value is returned, otherwise the number of bytes used or zero if no frame could be decompressed.
----
Back to [[ffmpeg:ffmpeg]]