Revision 68e5d523

View differences:

libavcodec/avcodec.h
807 807
     * - decoding: Read by user.\
808 808
     */\
809 809
    int64_t reordered_opaque;\
810
\
811
    /**\
812
     * hardware accelerator private data (FFmpeg allocated)\
813
     * - encoding: unused\
814
     * - decoding: Set by libavcodec\
815
     */\
816
    void *hwaccel_data_private;\
810 817

  
811 818

  
812 819
#define FF_QSCALE_TYPE_MPEG1 0
......
2456 2463
     * @return zero if successful, a negative value otherwise
2457 2464
     */
2458 2465
    int (*end_frame)(AVCodecContext *avctx);
2466

  
2467
    /**
2468
     * Size of HW accelerator private data.
2469
     *
2470
     * Private data is allocated with av_malloc() before
2471
     * AVCodecContext::get_buffer() and deallocated after
2472
     * AVCodecContext::release_buffer().
2473
     */
2474
    int priv_data_size;
2459 2475
} AVHWAccel;
2460 2476

  
2461 2477
/**
libavcodec/mpegvideo.c
170 170
static void free_frame_buffer(MpegEncContext *s, Picture *pic)
171 171
{
172 172
    s->avctx->release_buffer(s->avctx, (AVFrame*)pic);
173
    av_freep(&pic->hwaccel_data_private);
173 174
}
174 175

  
175 176
/**
......
179 180
{
180 181
    int r;
181 182

  
183
    if (s->avctx->hwaccel) {
184
        assert(!pic->hwaccel_data_private);
185
        if (s->avctx->hwaccel->priv_data_size) {
186
            pic->hwaccel_data_private = av_malloc(s->avctx->hwaccel->priv_data_size);
187
            if (!pic->hwaccel_data_private) {
188
                av_log(s->avctx, AV_LOG_ERROR, "alloc_frame_buffer() failed (hwaccel private data allocation)\n");
189
                return -1;
190
            }
191
        }
192
    }
193

  
182 194
    r = s->avctx->get_buffer(s->avctx, (AVFrame*)pic);
183 195

  
184 196
    if (r<0 || !pic->age || !pic->type || !pic->data[0]) {
185 197
        av_log(s->avctx, AV_LOG_ERROR, "get_buffer() failed (%d %d %d %p)\n", r, pic->age, pic->type, pic->data[0]);
198
        av_freep(&pic->hwaccel_data_private);
186 199
        return -1;
187 200
    }
188 201

  

Also available in: Unified diff