Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

vidmix: allow different pixel format #864

Merged
merged 1 commit into from
Jul 7, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions include/rem_vidmix.h
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@ typedef void (vidmix_frame_h)(uint64_t ts, const struct vidframe *frame,
void *arg);

int vidmix_alloc(struct vidmix **mixp);
void vidmix_set_fmt(struct vidmix *mix, enum vidfmt fmt);
int vidmix_source_alloc(struct vidmix_source **srcp, struct vidmix *mix,
const struct vidsz *sz, unsigned fps, bool content,
vidmix_frame_h *fh, void *arg);
Expand Down
25 changes: 21 additions & 4 deletions rem/vidmix/vidmix.c
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@ struct vidmix {
struct list srcl;
bool initialized;
uint32_t next_pidx;
enum vidfmt fmt;
};

struct vidmix_source {
Expand Down Expand Up @@ -347,6 +348,7 @@ int vidmix_alloc(struct vidmix **mixp)
goto out;
}

mix->fmt = VID_FMT_YUV420P;
mix->initialized = true;

out:
Expand All @@ -359,6 +361,21 @@ int vidmix_alloc(struct vidmix **mixp)
}


/**
* Set video mixer pixel format
*
* @param mix Video mixer
* @param fmt Pixel format
*/
void vidmix_set_fmt(struct vidmix *mix, enum vidfmt fmt)
{
if (!mix)
return;

mix->fmt = fmt;
}


/**
* Allocate a video mixer source
*
Expand Down Expand Up @@ -400,7 +417,7 @@ int vidmix_source_alloc(struct vidmix_source **srcp, struct vidmix *mix,
}

if (sz) {
err = vidframe_alloc(&src->frame_tx, VID_FMT_YUV420P, sz);
err = vidframe_alloc(&src->frame_tx, mix->fmt, sz);
if (err)
goto out;

Expand Down Expand Up @@ -584,7 +601,7 @@ int vidmix_source_set_size(struct vidmix_source *src, const struct vidsz *sz)
if (src->frame_tx && vidsz_cmp(&src->frame_tx->size, sz))
return 0;

err = vidframe_alloc(&frame, VID_FMT_YUV420P, sz);
err = vidframe_alloc(&frame, src->mix->fmt, sz);
if (err)
return err;

Expand Down Expand Up @@ -730,15 +747,15 @@ void vidmix_source_set_focus_idx(struct vidmix_source *src, uint32_t pidx)
*/
void vidmix_source_put(struct vidmix_source *src, const struct vidframe *frame)
{
if (!src || !frame || frame->fmt != VID_FMT_YUV420P)
if (!src || !frame || frame->fmt != src->mix->fmt)
return;

if (!src->frame_rx || !vidsz_cmp(&src->frame_rx->size, &frame->size)) {

struct vidframe *frm;
int err;

err = vidframe_alloc(&frm, VID_FMT_YUV420P, &frame->size);
err = vidframe_alloc(&frm, src->mix->fmt, &frame->size);
if (err)
return;

Expand Down