mirror of
https://gitlab.freedesktop.org/pipewire/pipewire.git
synced 2025-11-01 22:58:50 -04:00
videoconvert: support planar formats
Keep track of the per-place strides and sizes and use that to fill the output buffer.
This commit is contained in:
parent
ea7cfb9e94
commit
241ec04d88
1 changed files with 30 additions and 8 deletions
|
|
@ -119,6 +119,9 @@ struct dir {
|
||||||
int width;
|
int width;
|
||||||
int height;
|
int height;
|
||||||
|
|
||||||
|
ptrdiff_t linesizes[4];
|
||||||
|
size_t size[4];
|
||||||
|
|
||||||
unsigned int control:1;
|
unsigned int control:1;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
@ -1518,7 +1521,6 @@ static int port_set_format(void *object,
|
||||||
struct dir *dir = &this->dir[direction];
|
struct dir *dir = &this->dir[direction];
|
||||||
struct dir *odir = &this->dir[SPA_DIRECTION_REVERSE(direction)];
|
struct dir *odir = &this->dir[SPA_DIRECTION_REVERSE(direction)];
|
||||||
enum AVPixelFormat pix_fmt;
|
enum AVPixelFormat pix_fmt;
|
||||||
int linesizes[4];
|
|
||||||
|
|
||||||
if (info.media_type != SPA_MEDIA_TYPE_video) {
|
if (info.media_type != SPA_MEDIA_TYPE_video) {
|
||||||
spa_log_error(this->log, "unexpected types %d/%d",
|
spa_log_error(this->log, "unexpected types %d/%d",
|
||||||
|
|
@ -1531,20 +1533,36 @@ static int port_set_format(void *object,
|
||||||
}
|
}
|
||||||
switch (info.media_subtype) {
|
switch (info.media_subtype) {
|
||||||
case SPA_MEDIA_SUBTYPE_raw:
|
case SPA_MEDIA_SUBTYPE_raw:
|
||||||
|
{
|
||||||
|
int linesizes[4];
|
||||||
|
|
||||||
pix_fmt = format_to_pix_fmt(info.info.raw.format);
|
pix_fmt = format_to_pix_fmt(info.info.raw.format);
|
||||||
av_image_fill_linesizes(linesizes, pix_fmt, info.info.raw.size.width);
|
av_image_fill_linesizes(linesizes, pix_fmt, info.info.raw.size.width);
|
||||||
port->stride = linesizes[0];
|
port->stride = linesizes[0];
|
||||||
port->size = port->stride * info.info.raw.size.height;
|
port->blocks = 0;
|
||||||
|
for (int i = 0; i < 4; i++) {
|
||||||
|
dir->linesizes[i] = linesizes[i];
|
||||||
|
if (linesizes[i])
|
||||||
|
port->blocks++;
|
||||||
|
}
|
||||||
|
av_image_fill_plane_sizes(dir->size,
|
||||||
|
pix_fmt, info.info.raw.size.height,
|
||||||
|
dir->linesizes);
|
||||||
|
port->size = av_image_get_buffer_size(pix_fmt,
|
||||||
|
info.info.raw.size.width,
|
||||||
|
info.info.raw.size.height, this->max_align);
|
||||||
|
|
||||||
break;
|
break;
|
||||||
|
}
|
||||||
case SPA_MEDIA_SUBTYPE_mjpg:
|
case SPA_MEDIA_SUBTYPE_mjpg:
|
||||||
port->stride = 0;
|
port->stride = 0;
|
||||||
port->size = info.info.mjpg.size.width * info.info.mjpg.size.height;
|
port->size = info.info.mjpg.size.width * info.info.mjpg.size.height;
|
||||||
|
port->blocks = 1;
|
||||||
break;
|
break;
|
||||||
default:
|
default:
|
||||||
spa_log_error(this->log, "unsupported subtype %d", info.media_subtype);
|
spa_log_error(this->log, "unsupported subtype %d", info.media_subtype);
|
||||||
return -ENOTSUP;
|
return -ENOTSUP;
|
||||||
}
|
}
|
||||||
port->blocks = 1;
|
|
||||||
dir->format = info;
|
dir->format = info;
|
||||||
dir->have_format = true;
|
dir->have_format = true;
|
||||||
if (odir->have_format) {
|
if (odir->have_format) {
|
||||||
|
|
@ -1868,8 +1886,10 @@ static int impl_node_process(void *object)
|
||||||
f->format = in->pix_fmt;
|
f->format = in->pix_fmt;
|
||||||
f->width = in->width;
|
f->width = in->width;
|
||||||
f->height = in->height;
|
f->height = in->height;
|
||||||
f->data[0] = sbuf->datas[0];
|
for (uint_fast32_t i = 0; i < sbuf->buf->n_datas; ++i) {
|
||||||
f->linesize[0] = sbuf->buf->datas[0].chunk->stride;
|
f->data[i] = sbuf->datas[i];
|
||||||
|
f->linesize[i] = sbuf->buf->datas[i].chunk->stride;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/* do conversion */
|
/* do conversion */
|
||||||
|
|
@ -1899,9 +1919,11 @@ static int impl_node_process(void *object)
|
||||||
sizes[0] = this->encoder.packet->size;
|
sizes[0] = this->encoder.packet->size;
|
||||||
strides[0] = 1;
|
strides[0] = 1;
|
||||||
} else {
|
} else {
|
||||||
datas[0] = f->data[0];
|
for (uint_fast32_t i = 0; i < dbuf->buf->n_datas; ++i) {
|
||||||
strides[0] = f->linesize[0];
|
datas[i] = f->data[i];
|
||||||
sizes[0] = strides[0] * out->height;
|
strides[i] = f->linesize[i];
|
||||||
|
sizes[i] = out->size[i];
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/* write to output */
|
/* write to output */
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue