User Tools

Site Tools




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);



AVCodecContext *avctx

A AVCodecContext pointer to the codec context.


AVFrame *picture

A pointer to the AVFrame in which the decoded video frame will be stored.


int *got_picture_ptr

An int pointer to which zero is written if no frame could be decompressed, otherwise, it is nonzero.


uint8_t *buf

The input buffer.


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/avcodec_decode_video.txt · Last modified: 2007/11/22 16:49 by deva