Function libdav1d_sys::dav1d_get_picture
source · pub unsafe extern "C" fn dav1d_get_picture(
c: *mut Dav1dContext,
out: *mut Dav1dPicture,
) -> c_int
Expand description
Return a decoded picture.
@param c Input decoder instance. @param out Output frame. The caller assumes ownership of the returned reference.
@return 0: Success, and a frame is returned. DAV1D_ERR(EAGAIN): Not enough data to output a frame. dav1d_send_data() should be called with new input. Other negative DAV1D_ERR codes: Error during decoding or because of invalid passed-in arguments.
@note To drain buffered frames from the decoder (i.e. on end of stream), call this function until it returns DAV1D_ERR(EAGAIN).
@code{.c} Dav1dData data = { 0 }; Dav1dPicture p = { 0 }; int res;
read_data(&data); do { res = dav1d_send_data(c, &data); // Keep going even if the function can’t consume the current data packet. It eventually will after one or more frames have been returned in this loop. if (res < 0 && res != DAV1D_ERR(EAGAIN)) free_and_abort(); res = dav1d_get_picture(c, &p); if (res < 0) { if (res != DAV1D_ERR(EAGAIN)) free_and_abort(); } else output_and_unref_picture(&p); // Stay in the loop as long as there’s data to consume. } while (data.sz || read_data(&data) == SUCCESS);
// Handle EOS by draining all buffered frames. do { res = dav1d_get_picture(c, &p); if (res < 0) { if (res != DAV1D_ERR(EAGAIN)) free_and_abort(); } else output_and_unref_picture(&p); } while (res == 0); @endcode