mirror of
https://gitlab.freedesktop.org/gstreamer/gstreamer.git
synced 2024-11-27 20:21:24 +00:00
vdpau: use G_N_ELEMENTS instead of hardcoding array sizes
This commit is contained in:
parent
9661b77ea1
commit
f1799ce0d6
3 changed files with 8 additions and 11 deletions
|
@ -39,13 +39,13 @@ gst_vdp_video_to_yuv_caps (GstCaps * caps, GstVdpDevice * device)
|
||||||
|
|
||||||
if (gst_structure_get_int (structure, "chroma-type", &chroma_type)) {
|
if (gst_structure_get_int (structure, "chroma-type", &chroma_type)) {
|
||||||
/* calculate fourcc from chroma_type */
|
/* calculate fourcc from chroma_type */
|
||||||
for (i = 0; i < N_FORMATS; i++) {
|
for (i = 0; i < G_N_ELEMENTS (formats); i++) {
|
||||||
if (formats[i].chroma_type == chroma_type) {
|
if (formats[i].chroma_type == chroma_type) {
|
||||||
fourcc = g_slist_append (fourcc, GINT_TO_POINTER (formats[i].fourcc));
|
fourcc = g_slist_append (fourcc, GINT_TO_POINTER (formats[i].fourcc));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
for (i = 0; i < N_FORMATS; i++) {
|
for (i = 0; i < G_N_ELEMENTS (formats); i++) {
|
||||||
fourcc = g_slist_append (fourcc, GINT_TO_POINTER (formats[i].fourcc));
|
fourcc = g_slist_append (fourcc, GINT_TO_POINTER (formats[i].fourcc));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -92,7 +92,7 @@ gst_vdp_yuv_to_video_caps (GstCaps * caps, GstVdpDevice * device)
|
||||||
gint chroma_type = -1;
|
gint chroma_type = -1;
|
||||||
|
|
||||||
/* calculate chroma type from fourcc */
|
/* calculate chroma type from fourcc */
|
||||||
for (i = 0; i < N_FORMATS; i++) {
|
for (i = 0; i < G_N_ELEMENTS (formats); i++) {
|
||||||
if (formats[i].fourcc == fourcc) {
|
if (formats[i].fourcc == fourcc) {
|
||||||
chroma_type = formats[i].chroma_type;
|
chroma_type = formats[i].chroma_type;
|
||||||
break;
|
break;
|
||||||
|
|
|
@ -144,7 +144,7 @@ gst_vdp_video_buffer_get_allowed_yuv_caps (GstVdpDevice * device)
|
||||||
gint i;
|
gint i;
|
||||||
|
|
||||||
caps = gst_caps_new_empty ();
|
caps = gst_caps_new_empty ();
|
||||||
for (i = 0; i < N_CHROMA_TYPES; i++) {
|
for (i = 0; i < G_N_ELEMENTS (chroma_types); i++) {
|
||||||
VdpStatus status;
|
VdpStatus status;
|
||||||
VdpBool is_supported;
|
VdpBool is_supported;
|
||||||
guint32 max_w, max_h;
|
guint32 max_w, max_h;
|
||||||
|
@ -164,7 +164,7 @@ gst_vdp_video_buffer_get_allowed_yuv_caps (GstVdpDevice * device)
|
||||||
if (is_supported) {
|
if (is_supported) {
|
||||||
gint j;
|
gint j;
|
||||||
|
|
||||||
for (j = 0; j < N_FORMATS; j++) {
|
for (j = 0; j < G_N_ELEMENTS (formats); j++) {
|
||||||
if (formats[j].chroma_type != chroma_types[i])
|
if (formats[j].chroma_type != chroma_types[i])
|
||||||
continue;
|
continue;
|
||||||
|
|
||||||
|
@ -204,7 +204,7 @@ gst_vdp_video_buffer_get_allowed_video_caps (GstVdpDevice * device)
|
||||||
gint i;
|
gint i;
|
||||||
|
|
||||||
caps = gst_caps_new_empty ();
|
caps = gst_caps_new_empty ();
|
||||||
for (i = 0; i < N_CHROMA_TYPES; i++) {
|
for (i = 0; i < G_N_ELEMENTS (chroma_types); i++) {
|
||||||
VdpStatus status;
|
VdpStatus status;
|
||||||
VdpBool is_supported;
|
VdpBool is_supported;
|
||||||
guint32 max_w, max_h;
|
guint32 max_w, max_h;
|
||||||
|
|
|
@ -51,13 +51,10 @@ typedef struct
|
||||||
guint32 fourcc;
|
guint32 fourcc;
|
||||||
} GstVdpVideoBufferFormats;
|
} GstVdpVideoBufferFormats;
|
||||||
|
|
||||||
#define N_CHROMA_TYPES 3
|
static const VdpChromaType chroma_types[] =
|
||||||
#define N_FORMATS 7
|
|
||||||
|
|
||||||
static const VdpChromaType chroma_types[N_CHROMA_TYPES] =
|
|
||||||
{ VDP_CHROMA_TYPE_420, VDP_CHROMA_TYPE_422, VDP_CHROMA_TYPE_444 };
|
{ VDP_CHROMA_TYPE_420, VDP_CHROMA_TYPE_422, VDP_CHROMA_TYPE_444 };
|
||||||
|
|
||||||
static const GstVdpVideoBufferFormats formats[N_FORMATS] = {
|
static const GstVdpVideoBufferFormats formats[] = {
|
||||||
{
|
{
|
||||||
VDP_CHROMA_TYPE_420,
|
VDP_CHROMA_TYPE_420,
|
||||||
VDP_YCBCR_FORMAT_YV12,
|
VDP_YCBCR_FORMAT_YV12,
|
||||||
|
|
Loading…
Reference in a new issue