Revision d38c340f libavfilter/defaults.c
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