diff options
author | Mikhail Burakov <mburakov@mailbox.org> | 2023-04-02 20:41:20 +0200 |
---|---|---|
committer | Mikhail Burakov <mburakov@mailbox.org> | 2023-04-07 13:48:02 +0200 |
commit | 20ed57016563c10157093ed3785f17b5ce27fdca (patch) | |
tree | 73346b7a4b0ce66bf1d4b651f714fb1a315d247f /frame.c | |
parent | e59239d9eb7a48844104b2fbbcb96c069204950a (diff) |
Major rework of decoder implementation
Diffstat (limited to 'frame.c')
-rw-r--r-- | frame.c | 68 |
1 files changed, 0 insertions, 68 deletions
diff --git a/frame.c b/frame.c deleted file mode 100644 index dbb886f..0000000 --- a/frame.c +++ /dev/null @@ -1,68 +0,0 @@ -/* - * Copyright (C) 2023 Mikhail Burakov. This file is part of receiver. - * - * receiver is free software: you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * receiver is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with receiver. If not, see <https://www.gnu.org/licenses/>. - */ - -#include "frame.h" - -#include <errno.h> -#include <stdio.h> -#include <stdlib.h> -#include <string.h> -#include <unistd.h> - -#include "util.h" - -struct Frame* FrameCreate(uint32_t width, uint32_t height, uint32_t fourcc, - uint32_t nplanes, const struct FramePlane* planes) { - struct AUTO(Frame)* frame = malloc(sizeof(struct Frame)); - if (!frame) { - LOG("Failed to allocate frame (%s)", strerror(errno)); - return NULL; - } - *frame = (struct Frame){ - .width = width, - .height = height, - .fourcc = fourcc, - .nplanes = nplanes, - .planes[0] = {.dmabuf_fd = -1}, - .planes[1] = {.dmabuf_fd = -1}, - .planes[2] = {.dmabuf_fd = -1}, - .planes[3] = {.dmabuf_fd = -1}, - }; - - for (size_t i = 0; i < nplanes; i++) { - frame->planes[i] = (struct FramePlane){ - .dmabuf_fd = dup(planes[i].dmabuf_fd), - .pitch = planes[i].pitch, - .offset = planes[i].offset, - .modifier = planes[i].modifier, - }; - if (frame->planes[i].dmabuf_fd == -1) { - LOG("Failed to dup dmabuf fd (%s)", strerror(errno)); - return NULL; - } - } - - return RELEASE(frame); -} - -void FrameDestroy(struct Frame** frame) { - if (!frame || !*frame) return; - for (size_t i = (*frame)->nplanes; i; i--) { - if ((*frame)->planes[i].dmabuf_fd != -1) - close((*frame)->planes[i].dmabuf_fd); - } -} |