mirror of
				https://gitlab.freedesktop.org/pipewire/pipewire.git
				synced 2025-11-03 09:01:54 -05:00 
			
		
		
		
	Fix compilation with -Werror=float-conversion
Better make the conversions explicit so that we don't get any surprises. Fixes #4065
This commit is contained in:
		
							parent
							
								
									50870aac57
								
							
						
					
					
						commit
						1ae4374ccf
					
				
					 71 changed files with 286 additions and 284 deletions
				
			
		| 
						 | 
				
			
			@ -63,7 +63,7 @@ static void on_process(void *userdata)
 | 
			
		|||
		for (n = c; n < n_samples; n += n_channels)
 | 
			
		||||
			max = fmaxf(max, fabsf(samples[n]));
 | 
			
		||||
 | 
			
		||||
		peak = SPA_CLAMP(max * 30, 0, 39);
 | 
			
		||||
		peak = (uint32_t)SPA_CLAMPF(max * 30, 0.f, 39.f);
 | 
			
		||||
 | 
			
		||||
		fprintf(stdout, "channel %d: |%*s%*s| peak:%f\n",
 | 
			
		||||
				c, peak+1, "*", 40 - peak, "", max);
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
| 
						 | 
				
			
			@ -16,17 +16,17 @@
 | 
			
		|||
#include <pipewire/pipewire.h>
 | 
			
		||||
#include <pipewire/filter.h>
 | 
			
		||||
 | 
			
		||||
#define M_PI_M2 ( M_PI + M_PI )
 | 
			
		||||
#define M_PI_M2f ( M_PIf + M_PIf )
 | 
			
		||||
 | 
			
		||||
#define DEFAULT_RATE		44100
 | 
			
		||||
#define DEFAULT_FREQ		440
 | 
			
		||||
#define DEFAULT_VOLUME		0.7
 | 
			
		||||
#define DEFAULT_VOLUME		0.7f
 | 
			
		||||
 | 
			
		||||
struct data;
 | 
			
		||||
 | 
			
		||||
struct port {
 | 
			
		||||
	struct data *data;
 | 
			
		||||
	double accumulator;
 | 
			
		||||
	float accumulator;
 | 
			
		||||
};
 | 
			
		||||
 | 
			
		||||
struct data {
 | 
			
		||||
| 
						 | 
				
			
			@ -61,11 +61,11 @@ static void on_process(void *userdata, struct spa_io_position *position)
 | 
			
		|||
		return;
 | 
			
		||||
 | 
			
		||||
	for (i = 0; i < n_samples; i++) {
 | 
			
		||||
		out_port->accumulator += M_PI_M2 * DEFAULT_FREQ / DEFAULT_RATE;
 | 
			
		||||
		if (out_port->accumulator >= M_PI_M2)
 | 
			
		||||
			out_port->accumulator -= M_PI_M2;
 | 
			
		||||
		out_port->accumulator += M_PI_M2f * DEFAULT_FREQ / DEFAULT_RATE;
 | 
			
		||||
		if (out_port->accumulator >= M_PI_M2f)
 | 
			
		||||
			out_port->accumulator -= M_PI_M2f;
 | 
			
		||||
 | 
			
		||||
		*out++ = sin(out_port->accumulator) * DEFAULT_VOLUME;
 | 
			
		||||
		*out++ = sinf(out_port->accumulator) * DEFAULT_VOLUME;
 | 
			
		||||
	}
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
| 
						 | 
				
			
			@ -17,17 +17,17 @@
 | 
			
		|||
 | 
			
		||||
#include <pipewire/pipewire.h>
 | 
			
		||||
 | 
			
		||||
#define M_PI_M2 ( M_PI + M_PI )
 | 
			
		||||
#define M_PI_M2f ( M_PIf + M_PIf )
 | 
			
		||||
 | 
			
		||||
#define DEFAULT_RATE		44100
 | 
			
		||||
#define DEFAULT_CHANNELS	2
 | 
			
		||||
#define DEFAULT_VOLUME		0.7
 | 
			
		||||
#define DEFAULT_VOLUME		0.7f
 | 
			
		||||
 | 
			
		||||
struct data {
 | 
			
		||||
	struct pw_main_loop *loop;
 | 
			
		||||
	struct pw_stream *stream;
 | 
			
		||||
 | 
			
		||||
	double accumulator;
 | 
			
		||||
	float accumulator;
 | 
			
		||||
};
 | 
			
		||||
 | 
			
		||||
static void fill_f32(struct data *d, void *dest, int n_frames)
 | 
			
		||||
| 
						 | 
				
			
			@ -36,11 +36,11 @@ static void fill_f32(struct data *d, void *dest, int n_frames)
 | 
			
		|||
	int i, c;
 | 
			
		||||
 | 
			
		||||
        for (i = 0; i < n_frames; i++) {
 | 
			
		||||
                d->accumulator += M_PI_M2 * 440 / DEFAULT_RATE;
 | 
			
		||||
                if (d->accumulator >= M_PI_M2)
 | 
			
		||||
                        d->accumulator -= M_PI_M2;
 | 
			
		||||
                d->accumulator += M_PI_M2f * 440 / DEFAULT_RATE;
 | 
			
		||||
                if (d->accumulator >= M_PI_M2f)
 | 
			
		||||
                        d->accumulator -= M_PI_M2f;
 | 
			
		||||
 | 
			
		||||
                val = sin(d->accumulator) * DEFAULT_VOLUME;
 | 
			
		||||
                val = sinf(d->accumulator) * DEFAULT_VOLUME;
 | 
			
		||||
                for (c = 0; c < DEFAULT_CHANNELS; c++)
 | 
			
		||||
                        *dst++ = val;
 | 
			
		||||
        }
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
| 
						 | 
				
			
			@ -29,7 +29,7 @@
 | 
			
		|||
 | 
			
		||||
#include "sdl.h"
 | 
			
		||||
 | 
			
		||||
#define M_PI_M2 ( M_PI + M_PI )
 | 
			
		||||
#define M_PI_M2f ( M_PIf + M_PIf )
 | 
			
		||||
 | 
			
		||||
#define MAX_BUFFERS	64
 | 
			
		||||
 | 
			
		||||
| 
						 | 
				
			
			@ -65,7 +65,7 @@ struct data {
 | 
			
		|||
	struct spa_io_buffers *io;
 | 
			
		||||
	struct spa_io_sequence *io_notify;
 | 
			
		||||
	uint32_t io_notify_size;
 | 
			
		||||
	double param_accum;
 | 
			
		||||
	float param_accum;
 | 
			
		||||
 | 
			
		||||
	uint8_t buffer[1024];
 | 
			
		||||
 | 
			
		||||
| 
						 | 
				
			
			@ -106,13 +106,13 @@ static void update_param(struct data *data)
 | 
			
		|||
	spa_pod_builder_control(&b, 0, SPA_CONTROL_Properties);
 | 
			
		||||
	spa_pod_builder_push_object(&b, &f[1], SPA_TYPE_OBJECT_Props, 0);
 | 
			
		||||
	spa_pod_builder_prop(&b, SPA_PROP_contrast, 0);
 | 
			
		||||
	spa_pod_builder_float(&b, (sin(data->param_accum) * 127.0) + 127.0);
 | 
			
		||||
	spa_pod_builder_float(&b, (sinf(data->param_accum) * 127.0f) + 127.0f);
 | 
			
		||||
	spa_pod_builder_pop(&b, &f[1]);
 | 
			
		||||
	spa_pod_builder_pop(&b, &f[0]);
 | 
			
		||||
 | 
			
		||||
        data->param_accum += M_PI_M2 / 30.0;
 | 
			
		||||
        if (data->param_accum >= M_PI_M2)
 | 
			
		||||
                data->param_accum -= M_PI_M2;
 | 
			
		||||
        data->param_accum += M_PI_M2f / 30.0f;
 | 
			
		||||
        if (data->param_accum >= M_PI_M2f)
 | 
			
		||||
                data->param_accum -= M_PI_M2f;
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
static int impl_send_command(void *object, const struct spa_command *command)
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
| 
						 | 
				
			
			@ -23,7 +23,7 @@
 | 
			
		|||
 | 
			
		||||
#include <pipewire/pipewire.h>
 | 
			
		||||
 | 
			
		||||
#define M_PI_M2 ( M_PI + M_PI )
 | 
			
		||||
#define M_PI_M2f ( M_PIf + M_PIf )
 | 
			
		||||
 | 
			
		||||
#define BUFFER_SAMPLES	128
 | 
			
		||||
#define MAX_BUFFERS	32
 | 
			
		||||
| 
						 | 
				
			
			@ -64,8 +64,8 @@ struct data {
 | 
			
		|||
	uint32_t n_buffers;
 | 
			
		||||
	struct spa_list empty;
 | 
			
		||||
 | 
			
		||||
	double accumulator;
 | 
			
		||||
	double volume_accum;
 | 
			
		||||
	float accumulator;
 | 
			
		||||
	float volume_accum;
 | 
			
		||||
};
 | 
			
		||||
 | 
			
		||||
static void update_volume(struct data *data)
 | 
			
		||||
| 
						 | 
				
			
			@ -81,13 +81,13 @@ static void update_volume(struct data *data)
 | 
			
		|||
	spa_pod_builder_control(&b, 0, SPA_CONTROL_Properties);
 | 
			
		||||
	spa_pod_builder_push_object(&b, &f[1], SPA_TYPE_OBJECT_Props, 0);
 | 
			
		||||
	spa_pod_builder_prop(&b, SPA_PROP_volume, 0);
 | 
			
		||||
	spa_pod_builder_float(&b, (sin(data->volume_accum) / 2.0) + 0.5);
 | 
			
		||||
	spa_pod_builder_float(&b, (sinf(data->volume_accum) / 2.0f) + 0.5f);
 | 
			
		||||
	spa_pod_builder_pop(&b, &f[1]);
 | 
			
		||||
	spa_pod_builder_pop(&b, &f[0]);
 | 
			
		||||
 | 
			
		||||
        data->volume_accum += M_PI_M2 / 1000.0;
 | 
			
		||||
        if (data->volume_accum >= M_PI_M2)
 | 
			
		||||
                data->volume_accum -= M_PI_M2;
 | 
			
		||||
        data->volume_accum += M_PI_M2f / 1000.0f;
 | 
			
		||||
        if (data->volume_accum >= M_PI_M2f)
 | 
			
		||||
                data->volume_accum -= M_PI_M2f;
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
static int impl_send_command(void *object, const struct spa_command *command)
 | 
			
		||||
| 
						 | 
				
			
			@ -364,11 +364,11 @@ static void fill_f32(struct data *d, void *dest, int avail)
 | 
			
		|||
        for (i = 0; i < n_samples; i++) {
 | 
			
		||||
		float val;
 | 
			
		||||
 | 
			
		||||
                d->accumulator += M_PI_M2 * 440 / d->format.rate;
 | 
			
		||||
                if (d->accumulator >= M_PI_M2)
 | 
			
		||||
                        d->accumulator -= M_PI_M2;
 | 
			
		||||
                d->accumulator += M_PI_M2f * 440 / d->format.rate;
 | 
			
		||||
                if (d->accumulator >= M_PI_M2f)
 | 
			
		||||
                        d->accumulator -= M_PI_M2f;
 | 
			
		||||
 | 
			
		||||
                val = sin(d->accumulator);
 | 
			
		||||
                val = sinf(d->accumulator);
 | 
			
		||||
 | 
			
		||||
                for (c = 0; c < d->format.channels; c++)
 | 
			
		||||
                        *dst++ = val;
 | 
			
		||||
| 
						 | 
				
			
			@ -385,11 +385,11 @@ static void fill_s16(struct data *d, void *dest, int avail)
 | 
			
		|||
        for (i = 0; i < n_samples; i++) {
 | 
			
		||||
                int16_t val;
 | 
			
		||||
 | 
			
		||||
                d->accumulator += M_PI_M2 * 440 / d->format.rate;
 | 
			
		||||
                if (d->accumulator >= M_PI_M2)
 | 
			
		||||
                        d->accumulator -= M_PI_M2;
 | 
			
		||||
                d->accumulator += M_PI_M2f * 440 / d->format.rate;
 | 
			
		||||
                if (d->accumulator >= M_PI_M2f)
 | 
			
		||||
                        d->accumulator -= M_PI_M2f;
 | 
			
		||||
 | 
			
		||||
                val = (int16_t) (sin(d->accumulator) * 32767.0);
 | 
			
		||||
                val = (int16_t) (sinf(d->accumulator) * 32767.0f);
 | 
			
		||||
 | 
			
		||||
                for (c = 0; c < d->format.channels; c++)
 | 
			
		||||
                        *dst++ = val;
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
| 
						 | 
				
			
			@ -128,10 +128,10 @@ on_process(void *_data, struct spa_io_position *position)
 | 
			
		|||
	for (i = 0; i < data->position->video.size.height; i++) {
 | 
			
		||||
		struct pixel *p = (struct pixel *) src;
 | 
			
		||||
		for (j = 0; j < data->position->video.size.width; j++) {
 | 
			
		||||
			dst[j * 4 + 0] = SPA_CLAMP(p[j].r * 255.0f, 0, 255);
 | 
			
		||||
			dst[j * 4 + 1] = SPA_CLAMP(p[j].g * 255.0f, 0, 255);
 | 
			
		||||
			dst[j * 4 + 2] = SPA_CLAMP(p[j].b * 255.0f, 0, 255);
 | 
			
		||||
			dst[j * 4 + 3] = SPA_CLAMP(p[j].a * 255.0f, 0, 255);
 | 
			
		||||
			dst[j * 4 + 0] = SPA_CLAMP((uint8_t)(p[j].r * 255.0f), 0, 255);
 | 
			
		||||
			dst[j * 4 + 1] = SPA_CLAMP((uint8_t)(p[j].g * 255.0f), 0, 255);
 | 
			
		||||
			dst[j * 4 + 2] = SPA_CLAMP((uint8_t)(p[j].b * 255.0f), 0, 255);
 | 
			
		||||
			dst[j * 4 + 3] = SPA_CLAMP((uint8_t)(p[j].a * 255.0f), 0, 255);
 | 
			
		||||
		}
 | 
			
		||||
		src += sstride;
 | 
			
		||||
		dst += dstride;
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
| 
						 | 
				
			
			@ -123,18 +123,18 @@ static void on_process(void *userdata)
 | 
			
		|||
	}
 | 
			
		||||
	if ((mc = spa_buffer_find_meta_data(buf, SPA_META_VideoCrop, sizeof(*mc)))) {
 | 
			
		||||
		data->crop = (sin(data->accumulator) + 1.0) * 32.0;
 | 
			
		||||
		mc->region.position.x = data->crop;
 | 
			
		||||
		mc->region.position.y = data->crop;
 | 
			
		||||
		mc->region.size.width = data->position->video.size.width - data->crop*2;
 | 
			
		||||
		mc->region.size.height = data->position->video.size.height - data->crop*2;
 | 
			
		||||
		mc->region.position.x = (int32_t)data->crop;
 | 
			
		||||
		mc->region.position.y = (int32_t)data->crop;
 | 
			
		||||
		mc->region.size.width = data->position->video.size.width - (int32_t)(data->crop*2);
 | 
			
		||||
		mc->region.size.height = data->position->video.size.height - (int32_t)(data->crop*2);
 | 
			
		||||
	}
 | 
			
		||||
	if ((mcs = spa_buffer_find_meta_data(buf, SPA_META_Cursor, sizeof(*mcs)))) {
 | 
			
		||||
		struct spa_meta_bitmap *mb;
 | 
			
		||||
		uint32_t *bitmap, color;
 | 
			
		||||
 | 
			
		||||
		mcs->id = 1;
 | 
			
		||||
		mcs->position.x = (sin(data->accumulator) + 1.0) * 160.0 + 80;
 | 
			
		||||
		mcs->position.y = (cos(data->accumulator) + 1.0) * 100.0 + 50;
 | 
			
		||||
		mcs->position.x = (int32_t)((sin(data->accumulator) + 1.0) * 160.0 + 80);
 | 
			
		||||
		mcs->position.y = (int32_t)((cos(data->accumulator) + 1.0) * 100.0 + 50);
 | 
			
		||||
		mcs->hotspot.x = 0;
 | 
			
		||||
		mcs->hotspot.y = 0;
 | 
			
		||||
		mcs->bitmap_offset = sizeof(struct spa_meta_cursor);
 | 
			
		||||
| 
						 | 
				
			
			@ -147,7 +147,7 @@ static void on_process(void *userdata)
 | 
			
		|||
		mb->offset = sizeof(struct spa_meta_bitmap);
 | 
			
		||||
 | 
			
		||||
		bitmap = SPA_PTROFF(mb, mb->offset, uint32_t);
 | 
			
		||||
		color = (cos(data->accumulator) + 1.0) * (1 << 23);
 | 
			
		||||
		color = (uint32_t)((cos(data->accumulator) + 1.0) * (1 << 23));
 | 
			
		||||
		color |= 0xff000000;
 | 
			
		||||
 | 
			
		||||
		draw_elipse(bitmap, mb->size.width, mb->size.height, color);
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
| 
						 | 
				
			
			@ -197,10 +197,10 @@ on_process(void *_data)
 | 
			
		|||
			for (i = 0; i < data->size.height; i++) {
 | 
			
		||||
				struct pixel *p = (struct pixel *) src;
 | 
			
		||||
				for (j = 0; j < data->size.width; j++) {
 | 
			
		||||
					dst[j * 4 + 0] = SPA_CLAMP(p[j].r * 255.0f, 0, 255);
 | 
			
		||||
					dst[j * 4 + 1] = SPA_CLAMP(p[j].g * 255.0f, 0, 255);
 | 
			
		||||
					dst[j * 4 + 2] = SPA_CLAMP(p[j].b * 255.0f, 0, 255);
 | 
			
		||||
					dst[j * 4 + 3] = SPA_CLAMP(p[j].a * 255.0f, 0, 255);
 | 
			
		||||
					dst[j * 4 + 0] = SPA_CLAMP((uint8_t)(p[j].r * 255.0f), 0u, 255u);
 | 
			
		||||
					dst[j * 4 + 1] = SPA_CLAMP((uint8_t)(p[j].g * 255.0f), 0u, 255u);
 | 
			
		||||
					dst[j * 4 + 2] = SPA_CLAMP((uint8_t)(p[j].b * 255.0f), 0u, 255u);
 | 
			
		||||
					dst[j * 4 + 3] = SPA_CLAMP((uint8_t)(p[j].a * 255.0f), 0u, 255u);
 | 
			
		||||
				}
 | 
			
		||||
				src += sstride;
 | 
			
		||||
				dst += dstride;
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
| 
						 | 
				
			
			@ -205,10 +205,10 @@ on_process(void *_data)
 | 
			
		|||
			for (i = 0; i < data->size.height; i++) {
 | 
			
		||||
				struct pixel *p = (struct pixel *) src;
 | 
			
		||||
				for (j = 0; j < data->size.width; j++) {
 | 
			
		||||
					dst[j * 4 + 0] = SPA_CLAMP(p[j].r * 255.0f, 0, 255);
 | 
			
		||||
					dst[j * 4 + 1] = SPA_CLAMP(p[j].g * 255.0f, 0, 255);
 | 
			
		||||
					dst[j * 4 + 2] = SPA_CLAMP(p[j].b * 255.0f, 0, 255);
 | 
			
		||||
					dst[j * 4 + 3] = SPA_CLAMP(p[j].a * 255.0f, 0, 255);
 | 
			
		||||
					dst[j * 4 + 0] = SPA_CLAMP((uint8_t)(p[j].r * 255.0f), 0u, 255u);
 | 
			
		||||
					dst[j * 4 + 1] = SPA_CLAMP((uint8_t)(p[j].g * 255.0f), 0u, 255u);
 | 
			
		||||
					dst[j * 4 + 2] = SPA_CLAMP((uint8_t)(p[j].b * 255.0f), 0u, 255u);
 | 
			
		||||
					dst[j * 4 + 3] = SPA_CLAMP((uint8_t)(p[j].a * 255.0f), 0u, 255u);
 | 
			
		||||
				}
 | 
			
		||||
				src += sstride;
 | 
			
		||||
				dst += dstride;
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
| 
						 | 
				
			
			@ -111,18 +111,18 @@ static void on_process(void *userdata)
 | 
			
		|||
	}
 | 
			
		||||
	if ((mc = spa_buffer_find_meta_data(buf, SPA_META_VideoCrop, sizeof(*mc)))) {
 | 
			
		||||
		data->crop = (sin(data->accumulator) + 1.0) * 32.0;
 | 
			
		||||
		mc->region.position.x = data->crop;
 | 
			
		||||
		mc->region.position.y = data->crop;
 | 
			
		||||
		mc->region.size.width = data->format.size.width - data->crop*2;
 | 
			
		||||
		mc->region.size.height = data->format.size.height - data->crop*2;
 | 
			
		||||
		mc->region.position.x = (int32_t)data->crop;
 | 
			
		||||
		mc->region.position.y = (int32_t)data->crop;
 | 
			
		||||
		mc->region.size.width = data->format.size.width - (int32_t)(data->crop*2);
 | 
			
		||||
		mc->region.size.height = data->format.size.height - (int32_t)(data->crop*2);
 | 
			
		||||
	}
 | 
			
		||||
	if ((mcs = spa_buffer_find_meta_data(buf, SPA_META_Cursor, sizeof(*mcs)))) {
 | 
			
		||||
		struct spa_meta_bitmap *mb;
 | 
			
		||||
		uint32_t *bitmap, color;
 | 
			
		||||
 | 
			
		||||
		mcs->id = 1;
 | 
			
		||||
		mcs->position.x = (sin(data->accumulator) + 1.0) * 160.0 + 80;
 | 
			
		||||
		mcs->position.y = (cos(data->accumulator) + 1.0) * 100.0 + 50;
 | 
			
		||||
		mcs->position.x = (int32_t)((sin(data->accumulator) + 1.0) * 160.0 + 80);
 | 
			
		||||
		mcs->position.y = (int32_t)((cos(data->accumulator) + 1.0) * 100.0 + 50);
 | 
			
		||||
		mcs->hotspot.x = 0;
 | 
			
		||||
		mcs->hotspot.y = 0;
 | 
			
		||||
		mcs->bitmap_offset = sizeof(struct spa_meta_cursor);
 | 
			
		||||
| 
						 | 
				
			
			@ -135,7 +135,7 @@ static void on_process(void *userdata)
 | 
			
		|||
		mb->offset = sizeof(struct spa_meta_bitmap);
 | 
			
		||||
 | 
			
		||||
		bitmap = SPA_PTROFF(mb, mb->offset, uint32_t);
 | 
			
		||||
		color = (cos(data->accumulator) + 1.0) * (1 << 23);
 | 
			
		||||
		color = (uint32_t)((cos(data->accumulator) + 1.0) * (1 << 23));
 | 
			
		||||
		color |= 0xff000000;
 | 
			
		||||
 | 
			
		||||
		draw_elipse(bitmap, mb->size.width, mb->size.height, color);
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
| 
						 | 
				
			
			@ -185,18 +185,18 @@ static void on_process(void *userdata)
 | 
			
		|||
	}
 | 
			
		||||
	if ((mc = spa_buffer_find_meta_data(buf, SPA_META_VideoCrop, sizeof(*mc)))) {
 | 
			
		||||
		data->crop = (sin(data->accumulator) + 1.0) * 32.0;
 | 
			
		||||
		mc->region.position.x = data->crop;
 | 
			
		||||
		mc->region.position.y = data->crop;
 | 
			
		||||
		mc->region.size.width = data->format.size.width - data->crop*2;
 | 
			
		||||
		mc->region.size.height = data->format.size.height - data->crop*2;
 | 
			
		||||
		mc->region.position.x = (int32_t)data->crop;
 | 
			
		||||
		mc->region.position.y = (int32_t)data->crop;
 | 
			
		||||
		mc->region.size.width = data->format.size.width - (int32_t)(data->crop*2);
 | 
			
		||||
		mc->region.size.height = data->format.size.height - (int32_t)(data->crop*2);
 | 
			
		||||
	}
 | 
			
		||||
	if ((mcs = spa_buffer_find_meta_data(buf, SPA_META_Cursor, sizeof(*mcs)))) {
 | 
			
		||||
		struct spa_meta_bitmap *mb;
 | 
			
		||||
		uint32_t *bitmap, color;
 | 
			
		||||
 | 
			
		||||
		mcs->id = 1;
 | 
			
		||||
		mcs->position.x = (sin(data->accumulator) + 1.0) * 160.0 + 80;
 | 
			
		||||
		mcs->position.y = (cos(data->accumulator) + 1.0) * 100.0 + 50;
 | 
			
		||||
		mcs->position.x = (int32_t)((sin(data->accumulator) + 1.0) * 160.0 + 80);
 | 
			
		||||
		mcs->position.y = (int32_t)((cos(data->accumulator) + 1.0) * 100.0 + 50);
 | 
			
		||||
		mcs->hotspot.x = 0;
 | 
			
		||||
		mcs->hotspot.y = 0;
 | 
			
		||||
		mcs->bitmap_offset = sizeof(struct spa_meta_cursor);
 | 
			
		||||
| 
						 | 
				
			
			@ -209,7 +209,7 @@ static void on_process(void *userdata)
 | 
			
		|||
		mb->offset = sizeof(struct spa_meta_bitmap);
 | 
			
		||||
 | 
			
		||||
		bitmap = SPA_PTROFF(mb, mb->offset, uint32_t);
 | 
			
		||||
		color = (cos(data->accumulator) + 1.0) * (1 << 23);
 | 
			
		||||
		color = (uint32_t)((cos(data->accumulator) + 1.0) * (1 << 23));
 | 
			
		||||
		color |= 0xff000000;
 | 
			
		||||
 | 
			
		||||
		draw_elipse(bitmap, mb->size.width, mb->size.height, color);
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
| 
						 | 
				
			
			@ -115,18 +115,18 @@ static void on_process(void *userdata)
 | 
			
		|||
	}
 | 
			
		||||
	if ((mc = spa_buffer_find_meta_data(buf, SPA_META_VideoCrop, sizeof(*mc)))) {
 | 
			
		||||
		data->crop = (sin(data->accumulator) + 1.0) * 32.0;
 | 
			
		||||
		mc->region.position.x = data->crop;
 | 
			
		||||
		mc->region.position.y = data->crop;
 | 
			
		||||
		mc->region.size.width = data->format.size.width - data->crop*2;
 | 
			
		||||
		mc->region.size.height = data->format.size.height - data->crop*2;
 | 
			
		||||
		mc->region.position.x = (int32_t)data->crop;
 | 
			
		||||
		mc->region.position.y = (int32_t)data->crop;
 | 
			
		||||
		mc->region.size.width = data->format.size.width - (int32_t)(data->crop*2);
 | 
			
		||||
		mc->region.size.height = data->format.size.height - (int32_t)(data->crop*2);
 | 
			
		||||
	}
 | 
			
		||||
	if ((mcs = spa_buffer_find_meta_data(buf, SPA_META_Cursor, sizeof(*mcs)))) {
 | 
			
		||||
		struct spa_meta_bitmap *mb;
 | 
			
		||||
		uint32_t *bitmap, color;
 | 
			
		||||
 | 
			
		||||
		mcs->id = 1;
 | 
			
		||||
		mcs->position.x = (sin(data->accumulator) + 1.0) * 160.0 + 80;
 | 
			
		||||
		mcs->position.y = (cos(data->accumulator) + 1.0) * 100.0 + 50;
 | 
			
		||||
		mcs->position.x = (int32_t)((sin(data->accumulator) + 1.0) * 160.0 + 80);
 | 
			
		||||
		mcs->position.y = (int32_t)((cos(data->accumulator) + 1.0) * 100.0 + 50);
 | 
			
		||||
		mcs->hotspot.x = 0;
 | 
			
		||||
		mcs->hotspot.y = 0;
 | 
			
		||||
		mcs->bitmap_offset = sizeof(struct spa_meta_cursor);
 | 
			
		||||
| 
						 | 
				
			
			@ -139,7 +139,7 @@ static void on_process(void *userdata)
 | 
			
		|||
		mb->offset = sizeof(struct spa_meta_bitmap);
 | 
			
		||||
 | 
			
		||||
		bitmap = SPA_PTROFF(mb, mb->offset, uint32_t);
 | 
			
		||||
		color = (cos(data->accumulator) + 1.0) * (1 << 23);
 | 
			
		||||
		color = (uint32_t)((cos(data->accumulator) + 1.0) * (1 << 23));
 | 
			
		||||
		color |= 0xff000000;
 | 
			
		||||
 | 
			
		||||
		draw_elipse(bitmap, mb->size.width, mb->size.height, color);
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
| 
						 | 
				
			
			@ -111,18 +111,18 @@ static void on_process(void *userdata)
 | 
			
		|||
	}
 | 
			
		||||
	if ((mc = spa_buffer_find_meta_data(buf, SPA_META_VideoCrop, sizeof(*mc)))) {
 | 
			
		||||
		data->crop = (sin(data->accumulator) + 1.0) * 32.0;
 | 
			
		||||
		mc->region.position.x = data->crop;
 | 
			
		||||
		mc->region.position.y = data->crop;
 | 
			
		||||
		mc->region.size.width = data->format.size.width - data->crop*2;
 | 
			
		||||
		mc->region.size.height = data->format.size.height - data->crop*2;
 | 
			
		||||
		mc->region.position.x = (int32_t)data->crop;
 | 
			
		||||
		mc->region.position.y = (int32_t)data->crop;
 | 
			
		||||
		mc->region.size.width = data->format.size.width - (int32_t)(data->crop*2);
 | 
			
		||||
		mc->region.size.height = data->format.size.height - (int32_t)(data->crop*2);
 | 
			
		||||
	}
 | 
			
		||||
	if ((mcs = spa_buffer_find_meta_data(buf, SPA_META_Cursor, sizeof(*mcs)))) {
 | 
			
		||||
		struct spa_meta_bitmap *mb;
 | 
			
		||||
		uint32_t *bitmap, color;
 | 
			
		||||
 | 
			
		||||
		mcs->id = 1;
 | 
			
		||||
		mcs->position.x = (sin(data->accumulator) + 1.0) * 160.0 + 80;
 | 
			
		||||
		mcs->position.y = (cos(data->accumulator) + 1.0) * 100.0 + 50;
 | 
			
		||||
		mcs->position.x = (int32_t)((sin(data->accumulator) + 1.0) * 160.0 + 80);
 | 
			
		||||
		mcs->position.y = (int32_t)((cos(data->accumulator) + 1.0) * 100.0 + 50);
 | 
			
		||||
		mcs->hotspot.x = 0;
 | 
			
		||||
		mcs->hotspot.y = 0;
 | 
			
		||||
		mcs->bitmap_offset = sizeof(struct spa_meta_cursor);
 | 
			
		||||
| 
						 | 
				
			
			@ -135,7 +135,7 @@ static void on_process(void *userdata)
 | 
			
		|||
		mb->offset = sizeof(struct spa_meta_bitmap);
 | 
			
		||||
 | 
			
		||||
		bitmap = SPA_PTROFF(mb, mb->offset, uint32_t);
 | 
			
		||||
		color = (cos(data->accumulator) + 1.0) * (1 << 23);
 | 
			
		||||
		color = (uint32_t)((cos(data->accumulator) + 1.0) * (1 << 23));
 | 
			
		||||
		color |= 0xff000000;
 | 
			
		||||
 | 
			
		||||
		draw_elipse(bitmap, mb->size.width, mb->size.height, color);
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
		Loading…
	
	Add table
		Add a link
		
	
		Reference in a new issue