Revision d38c340f

View differences:

doc/APIchanges
12 12

  
13 13

  
14 14
API changes, most recent first:
15
2010-11-22 - r25826 - lavfi 1.65.0 - avfilter_get_video_buffer_ref_from_arrays()
16
  Add function avfilter_get_video_buffer_ref_from_arrays() in
17
  avfilter.h.
15 18

  
16 19
2010-11-21 - r25787 - lavcore 0.14.0 - audioconvert.h
17 20
  Add a public audio channel API in audioconvert.h, and deprecate the
libavfilter/avfilter.c
267 267
    return ret;
268 268
}
269 269

  
270
AVFilterBufferRef *
271
avfilter_get_video_buffer_ref_from_arrays(uint8_t *data[4], int linesize[4], int perms,
272
                                          int w, int h, enum PixelFormat format)
273
{
274
    AVFilterBuffer *pic = av_mallocz(sizeof(AVFilterBuffer));
275
    AVFilterBufferRef *picref = av_mallocz(sizeof(AVFilterBufferRef));
276

  
277
    if (!pic || !picref)
278
        goto fail;
279

  
280
    picref->buf = pic;
281
    picref->buf->free = ff_avfilter_default_free_buffer;
282
    if (!(picref->video = av_mallocz(sizeof(AVFilterBufferRefVideoProps))))
283
        goto fail;
284

  
285
    picref->video->w = w;
286
    picref->video->h = h;
287

  
288
    /* make sure the buffer gets read permission or it's useless for output */
289
    picref->perms = perms | AV_PERM_READ;
290

  
291
    pic->refcount = 1;
292
    picref->type = AVMEDIA_TYPE_VIDEO;
293
    picref->format = format;
294

  
295
    memcpy(pic->data,        data,          sizeof(pic->data));
296
    memcpy(pic->linesize,    linesize,      sizeof(pic->linesize));
297
    memcpy(picref->data,     pic->data,     sizeof(picref->data));
298
    memcpy(picref->linesize, pic->linesize, sizeof(picref->linesize));
299

  
300
    return picref;
301

  
302
fail:
303
    if (picref && picref->video)
304
        av_free(picref->video);
305
    av_free(picref);
306
    av_free(pic);
307
    return NULL;
308
}
309

  
270 310
AVFilterBufferRef *avfilter_get_audio_buffer(AVFilterLink *link, int perms,
271 311
                                             enum AVSampleFormat sample_fmt, int size,
272 312
                                             int64_t channel_layout, int planar)
libavfilter/avfilter.h
25 25
#include "libavutil/avutil.h"
26 26

  
27 27
#define LIBAVFILTER_VERSION_MAJOR  1
28
#define LIBAVFILTER_VERSION_MINOR 64
28
#define LIBAVFILTER_VERSION_MINOR 65
29 29
#define LIBAVFILTER_VERSION_MICRO  0
30 30

  
31 31
#define LIBAVFILTER_VERSION_INT AV_VERSION_INT(LIBAVFILTER_VERSION_MAJOR, \
......
649 649
                                          int w, int h);
650 650

  
651 651
/**
652
 * Create a buffer reference wrapped around an already allocated image
653
 * buffer.
654
 *
655
 * @param data pointers to the planes of the image to reference
656
 * @param linesize linesizes for the planes of the image to reference
657
 * @param perms the required access permissions
658
 * @param w the width of the image specified by the data and linesize arrays
659
 * @param h the height of the image specified by the data and linesize arrays
660
 * @param format the pixel format of the image specified by the data and linesize arrays
661
 */
662
AVFilterBufferRef *
663
avfilter_get_video_buffer_ref_from_arrays(uint8_t *data[4], int linesize[4], int perms,
664
                                          int w, int h, enum PixelFormat format);
665

  
666
/**
652 667
 * Request an audio samples buffer with a specific set of permissions.
653 668
 *
654 669
 * @param link           the output link to the filter from which the buffer will
libavfilter/defaults.c
37 37
 * alloc & free cycle currently implemented. */
38 38
AVFilterBufferRef *avfilter_default_get_video_buffer(AVFilterLink *link, int perms, int w, int h)
39 39
{
40
    AVFilterBuffer *pic = av_mallocz(sizeof(AVFilterBuffer));
41
    AVFilterBufferRef *ref = NULL;
42
    int i, tempsize;
43 40
    char *buf = NULL;
41
    int linesize[4], i, tempsize;
42
    uint8_t *data[4];
43
    AVFilterBufferRef *picref = NULL;
44 44

  
45
    if (!pic || !(ref = av_mallocz(sizeof(AVFilterBufferRef))))
46
        goto fail;
47

  
48
    ref->buf         = pic;
49
    ref->video       = av_mallocz(sizeof(AVFilterBufferRefVideoProps));
50
    ref->video->w    = w;
51
    ref->video->h    = h;
52

  
53
    /* make sure the buffer gets read permission or it's useless for output */
54
    ref->perms = perms | AV_PERM_READ;
55

  
56
    pic->refcount = 1;
57
    ref->format   = link->format;
58
    pic->free     = ff_avfilter_default_free_buffer;
59
    av_image_fill_linesizes(pic->linesize, ref->format, ref->video->w);
60

  
45
    av_image_fill_linesizes(linesize, link->format, w);
61 46
    for (i = 0; i < 4; i++)
62
        pic->linesize[i] = FFALIGN(pic->linesize[i], 16);
63

  
64
    tempsize = av_image_fill_pointers(pic->data, ref->format, ref->video->h, NULL, pic->linesize);
47
        linesize[i] = FFALIGN(linesize[i], 16);
48
    tempsize = av_image_fill_pointers(data, link->format, h, NULL, linesize);
65 49
    buf = av_malloc(tempsize + 16); // +2 is needed for swscaler, +16 to be
66 50
                                    // SIMD-friendly
67 51
    if (!buf)
68
        goto fail;
69
    av_image_fill_pointers(pic->data, ref->format, ref->video->h, buf, pic->linesize);
52
        return NULL;
70 53

  
71
    memcpy(ref->data,     pic->data,     sizeof(ref->data));
72
    memcpy(ref->linesize, pic->linesize, sizeof(ref->linesize));
54
    av_image_fill_pointers(data, link->format, h, buf, linesize);
73 55

  
74
    return ref;
56
    picref = avfilter_get_video_buffer_ref_from_arrays(data, linesize,
57
                                                       perms, w, h, link->format);
58
    if (!picref) {
59
        av_free(buf);
60
        return NULL;
61
    }
75 62

  
76
fail:
77
    av_free(buf);
78
    if (ref && ref->video)
79
        av_free(ref->video);
80
    av_free(ref);
81
    av_free(pic);
82
    return NULL;
63
    return picref;
83 64
}
84 65

  
85 66
AVFilterBufferRef *avfilter_default_get_audio_buffer(AVFilterLink *link, int perms,

Also available in: Unified diff