Merge commit '4e70d66ded537cadd32dbd02a38c3d86a203c812'

* commit '4e70d66ded537cadd32dbd02a38c3d86a203c812':
  mpegvideo: fix allocation of the hwaccel_picture_private data
  lavc: update the doxy for avcodec_decode_{video,audio} wtih refcounting.

Merged-by: Michael Niedermayer <michaelni@gmx.at>
pull/13/head
Michael Niedermayer 12 years ago
commit 54b0bef390
  1. 34
      libavcodec/avcodec.h
  2. 8
      libavcodec/mpegvideo.c

@ -3628,11 +3628,17 @@ attribute_deprecated int avcodec_decode_audio3(AVCodecContext *avctx, int16_t *s
*
* @param avctx the codec context
* @param[out] frame The AVFrame in which to store decoded audio samples.
* Decoders request a buffer of a particular size by setting
* AVFrame.nb_samples prior to calling get_buffer(). The
* decoder may, however, only utilize part of the buffer by
* setting AVFrame.nb_samples to a smaller value in the
* output frame.
* The decoder will allocate a buffer for the decoded frame by
* calling the AVCodecContext.get_buffer2() callback.
* When AVCodecContext.refcounted_frames is set to 1, the frame is
* reference counted and the returned reference belongs to the
* caller. The caller must release the frame using av_frame_unref()
* when the frame is no longer needed. The caller may safely write
* to the frame if av_frame_is_writable() returns 1.
* When AVCodecContext.refcounted_frames is set to 0, the returned
* reference belongs to the decoder and is valid only until the
* next call to this function or until closing the decoder.
* The caller may not write to it.
* @param[out] got_frame_ptr Zero if no frame could be decoded, otherwise it is
* non-zero.
* @param[in] avpkt The input AVPacket containing the input buffer.
@ -3670,12 +3676,18 @@ int avcodec_decode_audio4(AVCodecContext *avctx, AVFrame *frame,
*
* @param avctx the codec context
* @param[out] picture The AVFrame in which the decoded video frame will be stored.
* Use avcodec_alloc_frame to get an AVFrame, the codec will
* allocate memory for the actual bitmap.
* with default get/release_buffer(), the decoder frees/reuses the bitmap as it sees fit.
* with overridden get/release_buffer() (needs CODEC_CAP_DR1) the user decides into what buffer the decoder
* decodes and the decoder tells the user once it does not need the data anymore,
* the user app can at this point free/reuse/keep the memory as it sees fit.
* Use av_frame_alloc() to get an AVFrame. The codec will
* allocate memory for the actual bitmap by calling the
* AVCodecContext.get_buffer2() callback.
* When AVCodecContext.refcounted_frames is set to 1, the frame is
* reference counted and the returned reference belongs to the
* caller. The caller must release the frame using av_frame_unref()
* when the frame is no longer needed. The caller may safely write
* to the frame if av_frame_is_writable() returns 1.
* When AVCodecContext.refcounted_frames is set to 0, the returned
* reference belongs to the decoder and is valid only until the
* next call to this function or until closing the decoder. The
* caller may not write to it.
*
* @param[in] avpkt The input AVpacket containing the input buffer.
* You can create such packet with av_init_packet() and by then setting

@ -269,11 +269,12 @@ static int alloc_frame_buffer(MpegEncContext *s, Picture *pic)
if (s->avctx->hwaccel) {
assert(!pic->hwaccel_picture_private);
if (s->avctx->hwaccel->priv_data_size) {
pic->hwaccel_picture_private = av_mallocz(s->avctx->hwaccel->priv_data_size);
if (!pic->hwaccel_picture_private) {
pic->hwaccel_priv_buf = av_buffer_allocz(s->avctx->hwaccel->priv_data_size);
if (!pic->hwaccel_priv_buf) {
av_log(s->avctx, AV_LOG_ERROR, "alloc_frame_buffer() failed (hwaccel private data allocation)\n");
return -1;
}
pic->hwaccel_picture_private = pic->hwaccel_priv_buf->data;
}
}
@ -293,7 +294,8 @@ static int alloc_frame_buffer(MpegEncContext *s, Picture *pic)
if (r < 0 || !pic->f.data[0]) {
av_log(s->avctx, AV_LOG_ERROR, "get_buffer() failed (%d %p)\n",
r, pic->f.data[0]);
av_freep(&pic->hwaccel_picture_private);
av_buffer_unref(&pic->hwaccel_priv_buf);
pic->hwaccel_picture_private = NULL;
return -1;
}

Loading…
Cancel
Save