meta: add video damage region metadata

Add damage region meta
Implement damage region in video-src and export-sink
This commit is contained in:
Wim Taymans 2018-07-09 12:07:30 +02:00
parent c98fbfe0a9
commit f49ab32874
5 changed files with 100 additions and 31 deletions

View file

@ -35,7 +35,14 @@ extern "C" {
#define SPA_TYPE_META_BASE SPA_TYPE__Meta ":"
#define SPA_TYPE_META__Header SPA_TYPE_META_BASE "Header"
#define SPA_TYPE_META__VideoCrop SPA_TYPE_META_BASE "VideoCrop"
#define SPA_TYPE_META__Region SPA_TYPE_META_BASE "Region"
#define SPA_TYPE_META_REGION_BASE SPA_TYPE_META__Region ":"
#define SPA_TYPE_META__RegionArray SPA_TYPE_META_BASE "RegionArray"
#define SPA_TYPE_META_REGION_ARRAY_BASE SPA_TYPE_META__RegionArray ":"
#define SPA_TYPE_META__VideoCrop SPA_TYPE_META_REGION_BASE "VideoCrop"
#define SPA_TYPE_META__VideoDamage SPA_TYPE_META_REGION_ARRAY_BASE "VideoDamage"
/**
* A metadata element.
@ -72,25 +79,22 @@ struct spa_meta_header {
int64_t dts_offset; /**< decoding timestamp and a difference with pts */
};
/**
* Video cropping metadata
* a */
struct spa_meta_video_crop {
int32_t x, y; /**< x and y offsets */
int32_t width, height; /**< width and height */
/** metadata structure for Region or an array of these for RegionArray */
struct spa_meta_region {
struct spa_region region;
};
/**
* Describes a control location in the buffer.
*/
struct spa_meta_control {
uint32_t id; /**< control id */
uint32_t offset; /**< offset in buffer memory */
};
#define spa_meta_region_is_valid(m) ((m)->region.size.width != 0 && (m)->region.size.height != 0)
#define spa_meta_region_for_each(pos,meta) \
for (pos = spa_meta_first(meta); \
spa_meta_check(pos, meta); \
(pos)++)
struct spa_type_meta {
uint32_t Header;
uint32_t VideoCrop;
uint32_t VideoDamage;
};
static inline void spa_type_meta_map(struct spa_type_map *map, struct spa_type_meta *type)
@ -98,6 +102,7 @@ static inline void spa_type_meta_map(struct spa_type_map *map, struct spa_type_m
if (type->Header == 0) {
type->Header = spa_type_map_get_id(map, SPA_TYPE_META__Header);
type->VideoCrop = spa_type_map_get_id(map, SPA_TYPE_META__VideoCrop);
type->VideoDamage = spa_type_map_get_id(map, SPA_TYPE_META__VideoDamage);
}
}

View file

@ -55,12 +55,23 @@ enum spa_direction {
#define SPA_DIRECTION_REVERSE(d) ((d) ^ 1)
#define SPA_RECTANGLE(width,height) (struct spa_rectangle){ width, height }
struct spa_rectangle {
uint32_t width;
uint32_t height;
};
#define SPA_POINT(x,y) (struct spa_point){ x, y }
struct spa_point {
int32_t x;
int32_t y;
};
#define SPA_REGION(x,y,width,height) (struct spa_region){ SPA_POINT(x,y), SPA_RECTANGLE(width,height) }
struct spa_region {
struct spa_point position;
struct spa_rectangle size;
};
#define SPA_FRACTION(num,denom) (struct spa_fraction){ num, denom }
struct spa_fraction {
uint32_t num;

View file

@ -72,13 +72,22 @@ int spa_debug_buffer(const struct spa_buffer *buffer)
fprintf(stderr, " seq: %u\n", h->seq);
fprintf(stderr, " pts: %" PRIi64 "\n", h->pts);
fprintf(stderr, " dts_offset: %" PRIi64 "\n", h->dts_offset);
} else if (!strcmp(type_name, SPA_TYPE_META__VideoCrop)) {
struct spa_meta_video_crop *h = m->data;
fprintf(stderr, " struct spa_meta_video_crop:\n");
fprintf(stderr, " x: %d\n", h->x);
fprintf(stderr, " y: %d\n", h->y);
fprintf(stderr, " width: %d\n", h->width);
fprintf(stderr, " height: %d\n", h->height);
} else if (strstr(type_name, SPA_TYPE_META_REGION_BASE) == type_name) {
struct spa_meta_region *h = m->data;
fprintf(stderr, " struct spa_meta_region:\n");
fprintf(stderr, " x: %d\n", h->region.position.x);
fprintf(stderr, " y: %d\n", h->region.position.y);
fprintf(stderr, " width: %d\n", h->region.size.width);
fprintf(stderr, " height: %d\n", h->region.size.height);
} else if (strstr(type_name, SPA_TYPE_META_REGION_ARRAY_BASE) == type_name) {
struct spa_meta_region *p;
fprintf(stderr, " struct spa_meta_region_array:\n");
spa_meta_region_for_each(p, m) {
fprintf(stderr, " x: %d\n", p->region.position.x);
fprintf(stderr, " y: %d\n", p->region.position.y);
fprintf(stderr, " width: %d\n", p->region.size.width);
fprintf(stderr, " height: %d\n", p->region.size.height);
}
} else {
fprintf(stderr, " Unknown:\n");
spa_debug_dump_mem(m->data, m->size);