| Line | Branch | Exec | Source |
|---|---|---|---|
| 1 | /* | ||
| 2 | * Copyright 2007 Bobby Bingham | ||
| 3 | * Copyright Stefano Sabatini <stefasab gmail com> | ||
| 4 | * Copyright Vitor Sessak <vitor1001 gmail com> | ||
| 5 | * | ||
| 6 | * This file is part of FFmpeg. | ||
| 7 | * | ||
| 8 | * FFmpeg is free software; you can redistribute it and/or | ||
| 9 | * modify it under the terms of the GNU Lesser General Public | ||
| 10 | * License as published by the Free Software Foundation; either | ||
| 11 | * version 2.1 of the License, or (at your option) any later version. | ||
| 12 | * | ||
| 13 | * FFmpeg is distributed in the hope that it will be useful, | ||
| 14 | * but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
| 15 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU | ||
| 16 | * Lesser General Public License for more details. | ||
| 17 | * | ||
| 18 | * You should have received a copy of the GNU Lesser General Public | ||
| 19 | * License along with FFmpeg; if not, write to the Free Software | ||
| 20 | * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA | ||
| 21 | */ | ||
| 22 | |||
| 23 | #include <string.h> | ||
| 24 | #include <stdio.h> | ||
| 25 | |||
| 26 | #include "libavutil/buffer.h" | ||
| 27 | #include "libavutil/cpu.h" | ||
| 28 | #include "libavutil/hwcontext.h" | ||
| 29 | #include "libavutil/pixfmt.h" | ||
| 30 | |||
| 31 | #include "avfilter.h" | ||
| 32 | #include "avfilter_internal.h" | ||
| 33 | #include "filters.h" | ||
| 34 | #include "framepool.h" | ||
| 35 | #include "video.h" | ||
| 36 | |||
| 37 | const AVFilterPad ff_video_default_filterpad[1] = { | ||
| 38 | { | ||
| 39 | .name = "default", | ||
| 40 | .type = AVMEDIA_TYPE_VIDEO, | ||
| 41 | } | ||
| 42 | }; | ||
| 43 | |||
| 44 | 114793 | AVFrame *ff_null_get_video_buffer(AVFilterLink *link, int w, int h) | |
| 45 | { | ||
| 46 | 114793 | return ff_get_video_buffer(link->dst->outputs[0], w, h); | |
| 47 | } | ||
| 48 | |||
| 49 | 126152 | AVFrame *ff_default_get_video_buffer2(AVFilterLink *link, int w, int h, int align) | |
| 50 | { | ||
| 51 | 126152 | FilterLinkInternal *const li = ff_link_internal(link); | |
| 52 | 126152 | AVFrame *frame = NULL; | |
| 53 | |||
| 54 |
1/2✗ Branch 0 not taken.
✓ Branch 1 taken 126152 times.
|
126152 | if (li->l.hw_frames_ctx && |
| 55 | ✗ | ((AVHWFramesContext*)li->l.hw_frames_ctx->data)->format == link->format) { | |
| 56 | int ret; | ||
| 57 | ✗ | frame = av_frame_alloc(); | |
| 58 | |||
| 59 | ✗ | if (!frame) | |
| 60 | ✗ | return NULL; | |
| 61 | |||
| 62 | ✗ | ret = av_hwframe_get_buffer(li->l.hw_frames_ctx, frame, 0); | |
| 63 | ✗ | if (ret < 0) | |
| 64 | ✗ | av_frame_free(&frame); | |
| 65 | |||
| 66 | ✗ | return frame; | |
| 67 | } | ||
| 68 | |||
| 69 |
1/2✗ Branch 1 not taken.
✓ Branch 2 taken 126152 times.
|
126152 | if (ff_frame_pool_video_reinit(&li->frame_pool, w, h, link->format, align) < 0) |
| 70 | ✗ | return NULL; | |
| 71 | |||
| 72 | 126152 | frame = ff_frame_pool_get(&li->frame_pool); | |
| 73 |
1/2✗ Branch 0 not taken.
✓ Branch 1 taken 126152 times.
|
126152 | if (!frame) |
| 74 | ✗ | return NULL; | |
| 75 | |||
| 76 | 126152 | frame->sample_aspect_ratio = link->sample_aspect_ratio; | |
| 77 | 126152 | frame->colorspace = link->colorspace; | |
| 78 | 126152 | frame->color_range = link->color_range; | |
| 79 | 126152 | frame->alpha_mode = link->alpha_mode; | |
| 80 | |||
| 81 | 126152 | return frame; | |
| 82 | } | ||
| 83 | |||
| 84 | 126152 | AVFrame *ff_default_get_video_buffer(AVFilterLink *link, int w, int h) | |
| 85 | { | ||
| 86 | 126152 | return ff_default_get_video_buffer2(link, w, h, av_cpu_max_align()); | |
| 87 | } | ||
| 88 | |||
| 89 | 238378 | AVFrame *ff_get_video_buffer(AVFilterLink *link, int w, int h) | |
| 90 | { | ||
| 91 | 238378 | AVFrame *ret = NULL; | |
| 92 | |||
| 93 | FF_TPRINTF_START(NULL, get_video_buffer); ff_tlog_link(NULL, link, 1); | ||
| 94 | |||
| 95 |
2/2✓ Branch 0 taken 116258 times.
✓ Branch 1 taken 122120 times.
|
238378 | if (link->dstpad->get_buffer.video) |
| 96 | 116258 | ret = link->dstpad->get_buffer.video(link, w, h); | |
| 97 | |||
| 98 |
2/2✓ Branch 0 taken 122120 times.
✓ Branch 1 taken 116258 times.
|
238378 | if (!ret) |
| 99 | 122120 | ret = ff_default_get_video_buffer(link, w, h); | |
| 100 | |||
| 101 | 238378 | return ret; | |
| 102 | } | ||
| 103 |