[FFmpeg-cvslog] r17899 - in trunk/libavcodec: avcodec.h mpegvideo.c
gb
subversion
Mon Mar 9 09:04:41 CET 2009
Author: gb
Date: Mon Mar 9 09:04:41 2009
New Revision: 17899
Log:
Add private HW accel data infrastructure.
Modified:
trunk/libavcodec/avcodec.h
trunk/libavcodec/mpegvideo.c
Modified: trunk/libavcodec/avcodec.h
==============================================================================
--- trunk/libavcodec/avcodec.h Mon Mar 9 05:17:12 2009 (r17898)
+++ trunk/libavcodec/avcodec.h Mon Mar 9 09:04:41 2009 (r17899)
@@ -807,6 +807,13 @@ typedef struct AVPanScan{
* - decoding: Read by user.\
*/\
int64_t reordered_opaque;\
+\
+ /**\
+ * hardware accelerator private data (FFmpeg allocated)\
+ * - encoding: unused\
+ * - decoding: Set by libavcodec\
+ */\
+ void *hwaccel_data_private;\
#define FF_QSCALE_TYPE_MPEG1 0
@@ -2456,6 +2463,15 @@ typedef struct AVHWAccel {
* @return zero if successful, a negative value otherwise
*/
int (*end_frame)(AVCodecContext *avctx);
+
+ /**
+ * Size of HW accelerator private data.
+ *
+ * Private data is allocated with av_malloc() before
+ * AVCodecContext::get_buffer() and deallocated after
+ * AVCodecContext::release_buffer().
+ */
+ int priv_data_size;
} AVHWAccel;
/**
Modified: trunk/libavcodec/mpegvideo.c
==============================================================================
--- trunk/libavcodec/mpegvideo.c Mon Mar 9 05:17:12 2009 (r17898)
+++ trunk/libavcodec/mpegvideo.c Mon Mar 9 09:04:41 2009 (r17899)
@@ -170,6 +170,7 @@ void ff_copy_picture(Picture *dst, Pictu
static void free_frame_buffer(MpegEncContext *s, Picture *pic)
{
s->avctx->release_buffer(s->avctx, (AVFrame*)pic);
+ av_freep(&pic->hwaccel_data_private);
}
/**
@@ -179,10 +180,22 @@ static int alloc_frame_buffer(MpegEncCon
{
int r;
+ if (s->avctx->hwaccel) {
+ assert(!pic->hwaccel_data_private);
+ if (s->avctx->hwaccel->priv_data_size) {
+ pic->hwaccel_data_private = av_malloc(s->avctx->hwaccel->priv_data_size);
+ if (!pic->hwaccel_data_private) {
+ av_log(s->avctx, AV_LOG_ERROR, "alloc_frame_buffer() failed (hwaccel private data allocation)\n");
+ return -1;
+ }
+ }
+ }
+
r = s->avctx->get_buffer(s->avctx, (AVFrame*)pic);
if (r<0 || !pic->age || !pic->type || !pic->data[0]) {
av_log(s->avctx, AV_LOG_ERROR, "get_buffer() failed (%d %d %d %p)\n", r, pic->age, pic->type, pic->data[0]);
+ av_freep(&pic->hwaccel_data_private);
return -1;
}
More information about the ffmpeg-cvslog
mailing list