mirror of
https://gitlab.freedesktop.org/gstreamer/gstreamer.git
synced 2025-02-22 14:06:23 +00:00
omxvideoenc: factor out gst_omx_video_enc_copy_plane()
No semantic change, I'm going to use it to copy GRAY8 buffers which is actually a single plane 8-bits format.
This commit is contained in:
parent
5e6090056d
commit
2a620d5bbd
1 changed files with 50 additions and 37 deletions
|
@ -2680,26 +2680,17 @@ gst_omx_video_enc_flush (GstVideoEncoder * encoder)
|
||||||
}
|
}
|
||||||
|
|
||||||
static gboolean
|
static gboolean
|
||||||
gst_omx_video_enc_semi_planar_manual_copy (GstOMXVideoEnc * self,
|
gst_omx_video_enc_copy_plane (GstOMXVideoEnc * self, guint i,
|
||||||
GstBuffer * inbuf, GstOMXBuffer * outbuf, const GstVideoFormatInfo * finfo)
|
GstVideoFrame * frame, GstOMXBuffer * outbuf,
|
||||||
|
const GstVideoFormatInfo * finfo)
|
||||||
{
|
{
|
||||||
GstVideoInfo *info = &self->input_state->info;
|
|
||||||
OMX_PARAM_PORTDEFINITIONTYPE *port_def = &self->enc_in_port->port_def;
|
OMX_PARAM_PORTDEFINITIONTYPE *port_def = &self->enc_in_port->port_def;
|
||||||
GstVideoFrame frame;
|
|
||||||
gint i, j, height, width;
|
|
||||||
guint8 *src, *dest;
|
guint8 *src, *dest;
|
||||||
gint src_stride, dest_stride;
|
gint src_stride, dest_stride;
|
||||||
|
gint j, height, width;
|
||||||
|
|
||||||
outbuf->omx_buf->nFilledLen = 0;
|
src_stride = GST_VIDEO_FRAME_COMP_STRIDE (frame, i);
|
||||||
|
|
||||||
if (!gst_video_frame_map (&frame, info, inbuf, GST_MAP_READ)) {
|
|
||||||
GST_ERROR_OBJECT (self, "Invalid input buffer size");
|
|
||||||
return FALSE;
|
|
||||||
}
|
|
||||||
dest_stride = port_def->format.video.nStride;
|
dest_stride = port_def->format.video.nStride;
|
||||||
|
|
||||||
for (i = 0; i < 2; i++) {
|
|
||||||
src_stride = GST_VIDEO_FRAME_COMP_STRIDE (&frame, i);
|
|
||||||
/* XXX: Try this if no stride was set */
|
/* XXX: Try this if no stride was set */
|
||||||
if (dest_stride == 0)
|
if (dest_stride == 0)
|
||||||
dest_stride = src_stride;
|
dest_stride = src_stride;
|
||||||
|
@ -2709,9 +2700,9 @@ gst_omx_video_enc_semi_planar_manual_copy (GstOMXVideoEnc * self,
|
||||||
dest +=
|
dest +=
|
||||||
port_def->format.video.nSliceHeight * port_def->format.video.nStride;
|
port_def->format.video.nSliceHeight * port_def->format.video.nStride;
|
||||||
|
|
||||||
src = GST_VIDEO_FRAME_COMP_DATA (&frame, i);
|
src = GST_VIDEO_FRAME_COMP_DATA (frame, i);
|
||||||
height = GST_VIDEO_FRAME_COMP_HEIGHT (&frame, i);
|
height = GST_VIDEO_FRAME_COMP_HEIGHT (frame, i);
|
||||||
width = GST_VIDEO_FRAME_COMP_WIDTH (&frame, i) * (i == 0 ? 1 : 2);
|
width = GST_VIDEO_FRAME_COMP_WIDTH (frame, i) * (i == 0 ? 1 : 2);
|
||||||
|
|
||||||
if (GST_VIDEO_FORMAT_INFO_BITS (finfo) == 10)
|
if (GST_VIDEO_FORMAT_INFO_BITS (finfo) == 10)
|
||||||
/* Need ((width + 2) / 3) 32-bits words */
|
/* Need ((width + 2) / 3) 32-bits words */
|
||||||
|
@ -2720,7 +2711,6 @@ gst_omx_video_enc_semi_planar_manual_copy (GstOMXVideoEnc * self,
|
||||||
if (dest + dest_stride * height >
|
if (dest + dest_stride * height >
|
||||||
outbuf->omx_buf->pBuffer + outbuf->omx_buf->nAllocLen) {
|
outbuf->omx_buf->pBuffer + outbuf->omx_buf->nAllocLen) {
|
||||||
GST_ERROR_OBJECT (self, "Invalid output buffer size");
|
GST_ERROR_OBJECT (self, "Invalid output buffer size");
|
||||||
gst_video_frame_unmap (&frame);
|
|
||||||
return FALSE;
|
return FALSE;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -2734,6 +2724,29 @@ gst_omx_video_enc_semi_planar_manual_copy (GstOMXVideoEnc * self,
|
||||||
outbuf->omx_buf->nFilledLen +=
|
outbuf->omx_buf->nFilledLen +=
|
||||||
GST_VIDEO_FORMAT_INFO_SCALE_HEIGHT (finfo, i,
|
GST_VIDEO_FORMAT_INFO_SCALE_HEIGHT (finfo, i,
|
||||||
port_def->format.video.nSliceHeight) * port_def->format.video.nStride;
|
port_def->format.video.nSliceHeight) * port_def->format.video.nStride;
|
||||||
|
return TRUE;
|
||||||
|
}
|
||||||
|
|
||||||
|
static gboolean
|
||||||
|
gst_omx_video_enc_semi_planar_manual_copy (GstOMXVideoEnc * self,
|
||||||
|
GstBuffer * inbuf, GstOMXBuffer * outbuf, const GstVideoFormatInfo * finfo)
|
||||||
|
{
|
||||||
|
GstVideoInfo *info = &self->input_state->info;
|
||||||
|
GstVideoFrame frame;
|
||||||
|
gint i;
|
||||||
|
|
||||||
|
outbuf->omx_buf->nFilledLen = 0;
|
||||||
|
|
||||||
|
if (!gst_video_frame_map (&frame, info, inbuf, GST_MAP_READ)) {
|
||||||
|
GST_ERROR_OBJECT (self, "Invalid input buffer size");
|
||||||
|
return FALSE;
|
||||||
|
}
|
||||||
|
|
||||||
|
for (i = 0; i < 2; i++) {
|
||||||
|
if (!gst_omx_video_enc_copy_plane (self, i, &frame, outbuf, finfo)) {
|
||||||
|
gst_video_frame_unmap (&frame);
|
||||||
|
return FALSE;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
gst_video_frame_unmap (&frame);
|
gst_video_frame_unmap (&frame);
|
||||||
|
|
Loading…
Reference in a new issue