diff options
author | Xiang, Haihao <haihao.xiang@intel.com> | 2012-10-31 16:47:51 +0800 |
---|---|---|
committer | Xiang, Haihao <haihao.xiang@intel.com> | 2012-10-31 22:04:07 +0800 |
commit | 3c506db67e84234319c0cfa37fee635ba1a5c2da (patch) | |
tree | 90f5b603deb7b640d9a4f0c9b9468cbef3d29a8c | |
parent | 6fdd5a24a5099d45a01da5a9f1337d26749898bb (diff) | |
download | vaapi-intel-driver-3c506db67e84234319c0cfa37fee635ba1a5c2da.tar.gz vaapi-intel-driver-3c506db67e84234319c0cfa37fee635ba1a5c2da.tar.bz2 vaapi-intel-driver-3c506db67e84234319c0cfa37fee635ba1a5c2da.zip |
Unify the code for xxx_free_avc_surface
Signed-off-by: Xiang, Haihao <haihao.xiang@intel.com>
-rwxr-xr-x | src/gen6_mfd.c | 29 | ||||
-rw-r--r-- | src/gen6_mfd.h | 7 | ||||
-rw-r--r-- | src/gen75_mfd.c | 31 | ||||
-rwxr-xr-x | src/gen7_mfd.c | 29 | ||||
-rw-r--r-- | src/gen7_mfd.h | 7 | ||||
-rw-r--r-- | src/i965_avc_bsd.c | 31 | ||||
-rw-r--r-- | src/i965_avc_bsd.h | 8 | ||||
-rw-r--r-- | src/i965_decoder.h | 31 |
8 files changed, 64 insertions, 109 deletions
diff --git a/src/gen6_mfd.c b/src/gen6_mfd.c index 7329d8f..b3ee17f 100755 --- a/src/gen6_mfd.c +++ b/src/gen6_mfd.c @@ -26,6 +26,10 @@ * */ +#ifndef HAVE_GEN_AVC_SURFACE +#define HAVE_GEN_AVC_SURFACE 1 +#endif + #include <stdio.h> #include <stdlib.h> #include <string.h> @@ -167,37 +171,20 @@ gen6_mfd_avc_frame_store_index(VADriverContextP ctx, } } -static void -gen6_mfd_free_avc_surface(void **data) -{ - struct gen6_avc_surface *gen6_avc_surface = *data; - - if (!gen6_avc_surface) - return; - - dri_bo_unreference(gen6_avc_surface->dmv_top); - gen6_avc_surface->dmv_top = NULL; - dri_bo_unreference(gen6_avc_surface->dmv_bottom); - gen6_avc_surface->dmv_bottom = NULL; - - free(gen6_avc_surface); - *data = NULL; -} - static void gen6_mfd_init_avc_surface(VADriverContextP ctx, VAPictureParameterBufferH264 *pic_param, struct object_surface *obj_surface) { struct i965_driver_data *i965 = i965_driver_data(ctx); - struct gen6_avc_surface *gen6_avc_surface = obj_surface->private_data; + GenAvcSurface *gen6_avc_surface = obj_surface->private_data; int height_in_mbs; - obj_surface->free_private_data = gen6_mfd_free_avc_surface; + obj_surface->free_private_data = gen_free_avc_surface; height_in_mbs = ((pic_param->picture_height_in_mbs_minus1 + 1) & 0xff); /* frame height */ if (!gen6_avc_surface) { - gen6_avc_surface = calloc(sizeof(struct gen6_avc_surface), 1); + gen6_avc_surface = calloc(sizeof(GenAvcSurface), 1); assert((obj_surface->size & 0x3f) == 0); obj_surface->private_data = gen6_avc_surface; } @@ -577,7 +564,7 @@ gen6_mfd_avc_directmode_state(VADriverContextP ctx, struct i965_driver_data *i965 = i965_driver_data(ctx); struct intel_batchbuffer *batch = gen6_mfd_context->base.batch; struct object_surface *obj_surface; - struct gen6_avc_surface *gen6_avc_surface; + GenAvcSurface *gen6_avc_surface; VAPictureH264 *va_pic; int i, j; diff --git a/src/gen6_mfd.h b/src/gen6_mfd.h index 6e20364..de131d6 100644 --- a/src/gen6_mfd.h +++ b/src/gen6_mfd.h @@ -35,13 +35,6 @@ #include <intel_bufmgr.h> #include "i965_decoder.h" -struct gen6_avc_surface -{ - dri_bo *dmv_top; - dri_bo *dmv_bottom; - int dmv_bottom_flag; -}; - #define GEN6_VC1_I_PICTURE 0 #define GEN6_VC1_P_PICTURE 1 #define GEN6_VC1_B_PICTURE 2 diff --git a/src/gen75_mfd.c b/src/gen75_mfd.c index 1aa41bc..80b7881 100644 --- a/src/gen75_mfd.c +++ b/src/gen75_mfd.c @@ -27,6 +27,10 @@ * */ +#ifndef HAVE_GEN_AVC_SURFACE +#define HAVE_GEN_AVC_SURFACE 1 +#endif + #include <stdio.h> #include <stdlib.h> #include <string.h> @@ -172,38 +176,21 @@ gen75_mfd_avc_frame_store_index(VADriverContextP ctx, } } -static void -gen75_mfd_free_avc_surface(void **data) -{ - struct gen7_avc_surface *gen7_avc_surface = *data; - - if (!gen7_avc_surface) - return; - - dri_bo_unreference(gen7_avc_surface->dmv_top); - gen7_avc_surface->dmv_top = NULL; - dri_bo_unreference(gen7_avc_surface->dmv_bottom); - gen7_avc_surface->dmv_bottom = NULL; - - free(gen7_avc_surface); - *data = NULL; -} - static void gen75_mfd_init_avc_surface(VADriverContextP ctx, VAPictureParameterBufferH264 *pic_param, struct object_surface *obj_surface) { struct i965_driver_data *i965 = i965_driver_data(ctx); - struct gen7_avc_surface *gen7_avc_surface = obj_surface->private_data; + GenAvcSurface *gen7_avc_surface = obj_surface->private_data; int width_in_mbs, height_in_mbs; - obj_surface->free_private_data = gen75_mfd_free_avc_surface; + obj_surface->free_private_data = gen_free_avc_surface; width_in_mbs = pic_param->picture_width_in_mbs_minus1 + 1; height_in_mbs = pic_param->picture_height_in_mbs_minus1 + 1; /* frame height */ if (!gen7_avc_surface) { - gen7_avc_surface = calloc(sizeof(struct gen7_avc_surface), 1); + gen7_avc_surface = calloc(sizeof(GenAvcSurface), 1); assert((obj_surface->size & 0x3f) == 0); obj_surface->private_data = gen7_avc_surface; } @@ -818,7 +805,7 @@ gen75_mfd_avc_directmode_state_bplus(VADriverContextP ctx, struct i965_driver_data *i965 = i965_driver_data(ctx); struct intel_batchbuffer *batch = gen7_mfd_context->base.batch; struct object_surface *obj_surface; - struct gen7_avc_surface *gen7_avc_surface; + GenAvcSurface *gen7_avc_surface; VAPictureH264 *va_pic; int i, j; @@ -905,7 +892,7 @@ gen75_mfd_avc_directmode_state(VADriverContextP ctx, struct i965_driver_data *i965 = i965_driver_data(ctx); struct intel_batchbuffer *batch = gen7_mfd_context->base.batch; struct object_surface *obj_surface; - struct gen7_avc_surface *gen7_avc_surface; + GenAvcSurface *gen7_avc_surface; VAPictureH264 *va_pic; int i, j; diff --git a/src/gen7_mfd.c b/src/gen7_mfd.c index f2cabdb..4d3a260 100755 --- a/src/gen7_mfd.c +++ b/src/gen7_mfd.c @@ -26,6 +26,10 @@ * */ +#ifndef HAVE_GEN_AVC_SURFACE +#define HAVE_GEN_AVC_SURFACE 1 +#endif + #include <stdio.h> #include <stdlib.h> #include <string.h> @@ -168,38 +172,21 @@ gen7_mfd_avc_frame_store_index(VADriverContextP ctx, } } -static void -gen7_mfd_free_avc_surface(void **data) -{ - struct gen7_avc_surface *gen7_avc_surface = *data; - - if (!gen7_avc_surface) - return; - - dri_bo_unreference(gen7_avc_surface->dmv_top); - gen7_avc_surface->dmv_top = NULL; - dri_bo_unreference(gen7_avc_surface->dmv_bottom); - gen7_avc_surface->dmv_bottom = NULL; - - free(gen7_avc_surface); - *data = NULL; -} - static void gen7_mfd_init_avc_surface(VADriverContextP ctx, VAPictureParameterBufferH264 *pic_param, struct object_surface *obj_surface) { struct i965_driver_data *i965 = i965_driver_data(ctx); - struct gen7_avc_surface *gen7_avc_surface = obj_surface->private_data; + GenAvcSurface *gen7_avc_surface = obj_surface->private_data; int width_in_mbs, height_in_mbs; - obj_surface->free_private_data = gen7_mfd_free_avc_surface; + obj_surface->free_private_data = gen_free_avc_surface; width_in_mbs = pic_param->picture_width_in_mbs_minus1 + 1; height_in_mbs = pic_param->picture_height_in_mbs_minus1 + 1; /* frame height */ if (!gen7_avc_surface) { - gen7_avc_surface = calloc(sizeof(struct gen7_avc_surface), 1); + gen7_avc_surface = calloc(sizeof(GenAvcSurface), 1); assert((obj_surface->size & 0x3f) == 0); obj_surface->private_data = gen7_avc_surface; } @@ -585,7 +572,7 @@ gen7_mfd_avc_directmode_state(VADriverContextP ctx, struct i965_driver_data *i965 = i965_driver_data(ctx); struct intel_batchbuffer *batch = gen7_mfd_context->base.batch; struct object_surface *obj_surface; - struct gen7_avc_surface *gen7_avc_surface; + GenAvcSurface *gen7_avc_surface; VAPictureH264 *va_pic; int i, j; diff --git a/src/gen7_mfd.h b/src/gen7_mfd.h index 08d9e3a..0700c80 100644 --- a/src/gen7_mfd.h +++ b/src/gen7_mfd.h @@ -35,13 +35,6 @@ #include <intel_bufmgr.h> #include "i965_decoder.h" -struct gen7_avc_surface -{ - dri_bo *dmv_top; - dri_bo *dmv_bottom; - int dmv_bottom_flag; -}; - #define GEN7_VC1_I_PICTURE 0 #define GEN7_VC1_P_PICTURE 1 #define GEN7_VC1_B_PICTURE 2 diff --git a/src/i965_avc_bsd.c b/src/i965_avc_bsd.c index 612d0ee..667e29f 100644 --- a/src/i965_avc_bsd.c +++ b/src/i965_avc_bsd.c @@ -30,6 +30,10 @@ #include <string.h> #include <assert.h> +#ifndef HAVE_GEN_AVC_SURFACE +#define HAVE_GEN_AVC_SURFACE 1 +#endif + #include "intel_batchbuffer.h" #include "intel_driver.h" @@ -40,23 +44,6 @@ #include "i965_media.h" #include "i965_decoder_utils.h" -static void -i965_avc_bsd_free_avc_bsd_surface(void **data) -{ - struct i965_avc_bsd_surface *avc_bsd_surface = *data; - - if (!avc_bsd_surface) - return; - - dri_bo_unreference(avc_bsd_surface->dmv_top); - avc_bsd_surface->dmv_top = NULL; - dri_bo_unreference(avc_bsd_surface->dmv_bottom); - avc_bsd_surface->dmv_bottom = NULL; - - free(avc_bsd_surface); - *data = NULL; -} - static void i965_avc_bsd_init_avc_bsd_surface(VADriverContextP ctx, struct object_surface *obj_surface, @@ -64,18 +51,16 @@ i965_avc_bsd_init_avc_bsd_surface(VADriverContextP ctx, struct i965_h264_context *i965_h264_context) { struct i965_driver_data *i965 = i965_driver_data(ctx); - struct i965_avc_bsd_context *i965_avc_bsd_context = &i965_h264_context->i965_avc_bsd_context; - struct i965_avc_bsd_surface *avc_bsd_surface = obj_surface->private_data; + GenAvcSurface *avc_bsd_surface = obj_surface->private_data; - obj_surface->free_private_data = i965_avc_bsd_free_avc_bsd_surface; + obj_surface->free_private_data = gen_free_avc_surface; if (!avc_bsd_surface) { - avc_bsd_surface = calloc(sizeof(struct i965_avc_bsd_surface), 1); + avc_bsd_surface = calloc(sizeof(GenAvcSurface), 1); assert((obj_surface->size & 0x3f) == 0); obj_surface->private_data = avc_bsd_surface; } - avc_bsd_surface->ctx = i965_avc_bsd_context; avc_bsd_surface->dmv_bottom_flag = (pic_param->pic_fields.bits.field_pic_flag && !pic_param->seq_fields.bits.direct_8x8_inference_flag); @@ -404,7 +389,7 @@ i965_avc_bsd_buf_base_state(VADriverContextP ctx, int i, j; VAPictureH264 *va_pic; struct object_surface *obj_surface; - struct i965_avc_bsd_surface *avc_bsd_surface; + GenAvcSurface *avc_bsd_surface; i965_avc_bsd_context = &i965_h264_context->i965_avc_bsd_context; diff --git a/src/i965_avc_bsd.h b/src/i965_avc_bsd.h index 25606ba..7f83007 100644 --- a/src/i965_avc_bsd.h +++ b/src/i965_avc_bsd.h @@ -42,14 +42,6 @@ struct i965_avc_bsd_context } mpr_row_store; }; -struct i965_avc_bsd_surface -{ - struct i965_avc_bsd_context *ctx; - dri_bo *dmv_top; - dri_bo *dmv_bottom; - int dmv_bottom_flag; -}; - void i965_avc_bsd_pipeline(VADriverContextP, struct decode_state *, void *h264_context); void i965_avc_bsd_decode_init(VADriverContextP, void *h264_context); Bool i965_avc_bsd_ternimate(struct i965_avc_bsd_context *); diff --git a/src/i965_decoder.h b/src/i965_decoder.h index b771100..5e66118 100644 --- a/src/i965_decoder.h +++ b/src/i965_decoder.h @@ -26,6 +26,8 @@ #define I965_DECODER_H #include <stdint.h> +#include <stdlib.h> + #include <va/va.h> #include <intel_bufmgr.h> @@ -43,6 +45,35 @@ struct gen_buffer { int valid; }; +#if HAVE_GEN_AVC_SURFACE + +typedef struct gen_avc_surface GenAvcSurface; +struct gen_avc_surface +{ + dri_bo *dmv_top; + dri_bo *dmv_bottom; + int dmv_bottom_flag; +}; + +static void +gen_free_avc_surface(void **data) +{ + GenAvcSurface *avc_surface = *data; + + if (!avc_surface) + return; + + dri_bo_unreference(avc_surface->dmv_top); + avc_surface->dmv_top = NULL; + dri_bo_unreference(avc_surface->dmv_bottom); + avc_surface->dmv_bottom = NULL; + + free(avc_surface); + *data = NULL; +} + +#endif + struct hw_context * gen75_dec_hw_context_init(VADriverContextP ctx, struct object_config *obj_config); |