mirror of
https://gitlab.freedesktop.org/gstreamer/gstreamer.git
synced 2025-01-11 09:55:36 +00:00
videotestsrc: make and copy palette
This commit is contained in:
parent
f3f08e829d
commit
d73dcb6af3
2 changed files with 37 additions and 0 deletions
|
@ -654,6 +654,28 @@ gst_video_test_src_decide_allocation (GstBaseSrc * bsrc, GstQuery * query)
|
|||
return GST_BASE_SRC_CLASS (parent_class)->decide_allocation (bsrc, query);
|
||||
}
|
||||
|
||||
static void
|
||||
fill_palette_RGB8P (guint32 * palette)
|
||||
{
|
||||
/* build poor man's palette, taken from ffmpegcolorspace */
|
||||
static const guint8 pal_value[6] = { 0x00, 0x33, 0x66, 0x99, 0xcc, 0xff };
|
||||
gint i, r, g, b;
|
||||
|
||||
i = 0;
|
||||
for (r = 0; r < 6; r++) {
|
||||
for (g = 0; g < 6; g++) {
|
||||
for (b = 0; b < 6; b++) {
|
||||
palette[i++] =
|
||||
(0xffU << 24) | (pal_value[r] << 16) | (pal_value[g] << 8) |
|
||||
pal_value[b];
|
||||
}
|
||||
}
|
||||
}
|
||||
palette[i++] = 0; /* 100% transparent, i == 6*6*6 */
|
||||
while (i < 256)
|
||||
palette[i++] = 0xff000000;
|
||||
}
|
||||
|
||||
static gboolean
|
||||
gst_video_test_src_setcaps (GstBaseSrc * bsrc, GstCaps * caps)
|
||||
{
|
||||
|
@ -699,11 +721,19 @@ gst_video_test_src_setcaps (GstBaseSrc * bsrc, GstCaps * caps)
|
|||
g_free (videotestsrc->tmpline2);
|
||||
g_free (videotestsrc->tmpline_u8);
|
||||
g_free (videotestsrc->tmpline_u16);
|
||||
g_free (videotestsrc->palette);
|
||||
videotestsrc->tmpline_u8 = g_malloc (info.width + 8);
|
||||
videotestsrc->tmpline = g_malloc ((info.width + 8) * 4);
|
||||
videotestsrc->tmpline2 = g_malloc ((info.width + 8) * 4);
|
||||
videotestsrc->tmpline_u16 = g_malloc ((info.width + 16) * 8);
|
||||
|
||||
if (GST_VIDEO_INFO_FORMAT (&info) == GST_VIDEO_FORMAT_RGB8P) {
|
||||
videotestsrc->palette = g_new (guint32, 256);
|
||||
fill_palette_RGB8P (videotestsrc->palette);
|
||||
} else {
|
||||
videotestsrc->palette = NULL;
|
||||
}
|
||||
|
||||
videotestsrc->accum_rtime += videotestsrc->running_time;
|
||||
videotestsrc->accum_frames += videotestsrc->n_frames;
|
||||
|
||||
|
@ -836,6 +866,10 @@ gst_video_test_src_fill (GstPushSrc * psrc, GstBuffer * buffer)
|
|||
|
||||
src->make_image (src, &frame);
|
||||
|
||||
if (src->palette) {
|
||||
memcpy (GST_VIDEO_FRAME_PLANE_DATA (&frame, 1), src->palette, 256 * 4);
|
||||
}
|
||||
|
||||
gst_video_frame_unmap (&frame);
|
||||
|
||||
GST_BUFFER_DTS (buffer) =
|
||||
|
@ -909,6 +943,8 @@ gst_video_test_src_stop (GstBaseSrc * basesrc)
|
|||
src->tmpline_u8 = NULL;
|
||||
g_free (src->tmpline_u16);
|
||||
src->tmpline_u16 = NULL;
|
||||
g_free (src->palette);
|
||||
src->palette = NULL;
|
||||
|
||||
return TRUE;
|
||||
}
|
||||
|
|
|
@ -162,6 +162,7 @@ struct _GstVideoTestSrc {
|
|||
gint horizontal_speed;
|
||||
|
||||
void (*make_image) (GstVideoTestSrc *v, GstVideoFrame *frame);
|
||||
guint32 *palette;
|
||||
|
||||
/* temporary AYUV/ARGB scanline */
|
||||
guint8 *tmpline_u8;
|
||||
|
|
Loading…
Reference in a new issue