kdrive: Do a little more cleanup from the XV struct deduplication.

Signed-off-by: Eric Anholt <eric@anholt.net>
Reviewed-by: Adam Jackson <ajax@redhat.com>
This commit is contained in:
Eric Anholt 2014-04-06 08:12:35 +01:00
parent 1d90e8811a
commit 0edc0a78fb
3 changed files with 19 additions and 29 deletions

View File

@ -69,7 +69,7 @@ static Bool ephyrXVPrivSetAdaptorsHooks(EphyrXVPriv * a_this);
static Bool ephyrXVPrivRegisterAdaptors(EphyrXVPriv * a_this,
ScreenPtr a_screen);
static Bool ephyrXVPrivIsAttrValueValid(KdAttributePtr a_attrs,
static Bool ephyrXVPrivIsAttrValueValid(XvAttributePtr a_attrs,
int a_attrs_len,
const char *a_attr_name,
int a_attr_value, Bool *a_is_valid);
@ -363,7 +363,7 @@ translate_xv_attributes(KdVideoAdaptorPtr adaptor,
it = xcb_xv_query_port_attributes_attributes_iterator(reply);
for (i = 0; i < reply->num_attributes; i++) {
KdAttributePtr attribute = &adaptor->pAttributes[i];
XvAttributePtr attribute = &adaptor->pAttributes[i];
attribute->flags = it.data->flags;
attribute->min_value = it.data->min;
@ -397,7 +397,7 @@ translate_xv_image_formats(KdVideoAdaptorPtr adaptor,
return FALSE;
adaptor->nImages = reply->num_formats;
adaptor->pImages = calloc(reply->num_formats, sizeof(KdImageRec));
adaptor->pImages = calloc(reply->num_formats, sizeof(XvImageRec));
if (!adaptor->pImages) {
free(reply);
return FALSE;
@ -405,7 +405,7 @@ translate_xv_image_formats(KdVideoAdaptorPtr adaptor,
formats = xcb_xv_list_image_formats_format(reply);
for (i = 0; i < reply->num_formats; i++) {
KdImagePtr image = &adaptor->pImages[i];
XvImagePtr image = &adaptor->pImages[i];
image->id = formats[i].id;
image->type = formats[i].type;
@ -655,7 +655,7 @@ ephyrXVPrivRegisterAdaptors(EphyrXVPriv * a_this, ScreenPtr a_screen)
}
static Bool
ephyrXVPrivIsAttrValueValid(KdAttributePtr a_attrs,
ephyrXVPrivIsAttrValueValid(XvAttributePtr a_attrs,
int a_attrs_len,
const char *a_attr_name,
int a_attr_value, Bool *a_is_valid)

View File

@ -295,15 +295,11 @@ KdXVInitAdaptors(ScreenPtr pScreen, KdVideoAdaptorPtr * infoPtr, int number)
XvPortRecPrivatePtr portPriv;
XvPortPtr pPort, pp;
int numPort;
KdAttributePtr attributePtr;
XvAttributePtr pAttribute, pat;
KdVideoFormatPtr formatPtr;
XvFormatPtr pFormat, pf;
int numFormat, totFormat;
KdVideoEncodingPtr encodingPtr;
XvEncodingPtr pEncode, pe;
KdImagePtr imagePtr;
XvImagePtr pImage, pi;
int numVisuals;
VisualPtr pVisual;
int i;
@ -381,26 +377,24 @@ KdXVInitAdaptors(ScreenPtr pScreen, KdVideoAdaptorPtr * infoPtr, int number)
}
if (adaptorPtr->nImages &&
(pImage = calloc(adaptorPtr->nImages, sizeof(XvImageRec)))) {
for (i = 0, pi = pImage, imagePtr = adaptorPtr->pImages;
i < adaptorPtr->nImages; i++, pi++, imagePtr++) {
memcpy(pi, imagePtr, sizeof(*pi));
}
(pa->pImages = calloc(adaptorPtr->nImages, sizeof(XvImageRec)))) {
memcpy(pa->pImages, adaptorPtr->pImages,
adaptorPtr->nImages * sizeof(XvImageRec));
pa->nImages = adaptorPtr->nImages;
pa->pImages = pImage;
}
if (adaptorPtr->nAttributes &&
(pAttribute =
calloc(adaptorPtr->nAttributes, sizeof(XvAttributeRec)))) {
for (pat = pAttribute, attributePtr = adaptorPtr->pAttributes, i =
0; i < adaptorPtr->nAttributes; pat++, i++, attributePtr++) {
memcpy(pat, attributePtr, sizeof(*pat));
pat->name = strdup(attributePtr->name);
(pa->pAttributes = calloc(adaptorPtr->nAttributes,
sizeof(XvAttributeRec)))) {
memcpy(pa->pAttributes, adaptorPtr->pAttributes,
adaptorPtr->nAttributes * sizeof(XvAttributeRec));
for (i = 0; i < adaptorPtr->nAttributes; i++) {
pa->pAttributes[i].name =
strdup(adaptorPtr->pAttributes[i].name);
}
pa->nAttributes = adaptorPtr->nAttributes;
pa->pAttributes = pAttribute;
}
totFormat = adaptorPtr->nFormats;

View File

@ -56,8 +56,6 @@ of the copyright holder.
#define VIDEO_OVERLAID_STILLS 0x00000008
#define VIDEO_CLIP_TO_VIEWPORT 0x00000010
typedef XvImageRec KdImageRec, *KdImagePtr;
typedef struct {
KdScreenInfo *screen;
int id;
@ -131,8 +129,6 @@ typedef struct {
short class;
} KdVideoFormatRec, *KdVideoFormatPtr;
typedef XvAttributeRec KdAttributeRec, *KdAttributePtr;
typedef struct {
unsigned int type;
int flags;
@ -144,9 +140,9 @@ typedef struct {
int nPorts;
DevUnion *pPortPrivates;
int nAttributes;
KdAttributePtr pAttributes;
XvAttributePtr pAttributes;
int nImages;
KdImagePtr pImages;
XvImagePtr pImages;
PutVideoFuncPtr PutVideo;
PutStillFuncPtr PutStill;
GetVideoFuncPtr GetVideo;