diff options
author | Austin Yuan <shengquan.yuan@intel.com> | 2013-06-08 10:22:36 +0800 |
---|---|---|
committer | buildbot <buildbot@intel.com> | 2013-07-09 19:28:36 -0700 |
commit | 7d9a3d51091eff4c2c32653ad011ecae99dad4fe (patch) | |
tree | 2e10579bc758a7fa033dd1ec87bffcaf006a0ffd /va | |
parent | 7b38de70eec885e25c0603c56732bd80db48e911 (diff) | |
download | libva-7d9a3d51091eff4c2c32653ad011ecae99dad4fe.tar.gz |
Sync with new fdo staging branch
BZ: 119038
Change-Id: I4bf6b90e3bf0bee8f09a919d0a5fd548a1be5238
Signed-off-by: Austin Yuan <shengquan.yuan@intel.com>
Signed-off-by: pingshix <pingx.shi@intel.com>
Reviewed-on: http://android.intel.com:8080/115742
Reviewed-by: Sun, Jing A <jing.a.sun@intel.com>
Reviewed-by: Guo, Nana N <nana.n.guo@intel.com>
Reviewed-by: Wang, Kun K <kun.k.wang@intel.com>
Reviewed-by: buildbot <buildbot@intel.com>
Tested-by: buildbot <buildbot@intel.com>
Diffstat (limited to 'va')
-rwxr-xr-x | va/Android.mk | 1 | ||||
-rw-r--r-- | va/Makefile.am | 1 | ||||
-rwxr-xr-x | va/va.c | 175 | ||||
-rwxr-xr-x | va/va.h | 134 | ||||
-rwxr-xr-x | va/va_backend.h | 9 | ||||
-rw-r--r-- | va/va_enc_jpeg.h | 158 | ||||
-rw-r--r-- | va/va_enc_mpeg2.h | 10 | ||||
-rwxr-xr-x | va/va_trace.c | 209 | ||||
-rwxr-xr-x | va/va_trace.h | 7 | ||||
-rw-r--r-- | va/va_vpp.h | 110 |
10 files changed, 669 insertions, 145 deletions
diff --git a/va/Android.mk b/va/Android.mk index 127e960..fdf2f2f 100755 --- a/va/Android.mk +++ b/va/Android.mk @@ -68,6 +68,7 @@ LOCAL_COPY_HEADERS := \ va_dec_vp8.h \ va_enc.h \ va_enc_h264.h \ + va_enc_jpeg.h \ va_enc_vp8.h \ va_backend.h \ va_drmcommon.h \ diff --git a/va/Makefile.am b/va/Makefile.am index 9a3cd2f..6163017 100644 --- a/va/Makefile.am +++ b/va/Makefile.am @@ -49,6 +49,7 @@ libva_source_h = \ va_drmcommon.h \ va_enc.h \ va_enc_h264.h \ + va_enc_jpeg.h \ va_enc_vp8.h \ va_enc_mpeg2.h \ va_tpi.h \ @@ -675,12 +675,148 @@ VAStatus vaQueryConfigAttributes ( return ctx->vtable->vaQueryConfigAttributes( ctx, config_id, profile, entrypoint, attrib_list, num_attribs); } +/* XXX: this is a slow implementation that will be removed */ +static VAStatus +va_impl_query_surface_attributes( + VADriverContextP ctx, + VAConfigID config, + VASurfaceAttrib *out_attribs, + unsigned int *out_num_attribs_ptr +) +{ + VASurfaceAttrib *attribs = NULL; + unsigned int num_attribs, n; + VASurfaceAttrib *out_attrib; + unsigned int out_num_attribs; + VAImageFormat *image_formats = NULL; + int num_image_formats, i; + VAStatus va_status; + + /* List of surface attributes to query */ + struct va_surface_attrib_map { + VASurfaceAttribType type; + VAGenericValueType value_type; + }; + static const struct va_surface_attrib_map attribs_map[] = { + { VASurfaceAttribMinWidth, VAGenericValueTypeInteger }, + { VASurfaceAttribMaxWidth, VAGenericValueTypeInteger }, + { VASurfaceAttribMinHeight, VAGenericValueTypeInteger }, + { VASurfaceAttribMaxHeight, VAGenericValueTypeInteger }, + { VASurfaceAttribMemoryType, VAGenericValueTypeInteger }, + { VASurfaceAttribNone, } + }; + + if (!out_attribs || !out_num_attribs_ptr) + return VA_STATUS_ERROR_INVALID_PARAMETER; + if (!ctx->vtable->vaGetSurfaceAttributes) + return VA_STATUS_ERROR_UNIMPLEMENTED; + + num_image_formats = ctx->max_image_formats; + image_formats = malloc(num_image_formats * sizeof(*image_formats)); + if (!image_formats) { + va_status = VA_STATUS_ERROR_ALLOCATION_FAILED; + goto end; + } + + va_status = ctx->vtable->vaQueryImageFormats( + ctx, image_formats, &num_image_formats); + if (va_status != VA_STATUS_SUCCESS) + goto end; + + num_attribs = VASurfaceAttribCount + num_image_formats; + attribs = malloc(num_attribs * sizeof(*attribs)); + if (!attribs) { + va_status = VA_STATUS_ERROR_ALLOCATION_FAILED; + goto end; + } + + /* Initialize with base surface attributes, except pixel-formats */ + for (n = 0; attribs_map[n].type != VASurfaceAttribNone; n++) { + VASurfaceAttrib * const attrib = &attribs[n]; + attrib->type = attribs_map[n].type; + attrib->flags = VA_SURFACE_ATTRIB_GETTABLE; + attrib->value.type = attribs_map[n].value_type; + } + + /* Append image formats */ + for (i = 0; i < num_image_formats; i++) { + VASurfaceAttrib * const attrib = &attribs[n]; + attrib->type = VASurfaceAttribPixelFormat; + attrib->flags = VA_SURFACE_ATTRIB_GETTABLE|VA_SURFACE_ATTRIB_SETTABLE; + attrib->value.type = VAGenericValueTypeInteger; + attrib->value.value.i = image_formats[i].fourcc; + if (++n == num_attribs) { + va_status = VA_STATUS_ERROR_ALLOCATION_FAILED; + goto end; + } + } + num_attribs = n; + + va_status = ctx->vtable->vaGetSurfaceAttributes( + ctx, config, attribs, num_attribs); + if (va_status != VA_STATUS_SUCCESS) + goto end; + + /* Remove invalid entries */ + out_num_attribs = 0; + for (n = 0; n < num_attribs; n++) { + VASurfaceAttrib * const attrib = &attribs[n]; + + if (attrib->flags == VA_SURFACE_ATTRIB_NOT_SUPPORTED) + continue; + + // Accept all surface attributes that are not pixel-formats + if (attrib->type != VASurfaceAttribPixelFormat) { + out_num_attribs++; + continue; + } + + // Drop invalid pixel-format attribute + if (!attrib->value.value.i) { + attrib->flags = VA_SURFACE_ATTRIB_NOT_SUPPORTED; + continue; + } + + // Check for duplicates + int is_duplicate = 0; + for (i = n - 1; i >= 0 && !is_duplicate; i--) { + const VASurfaceAttrib * const prev_attrib = &attribs[i]; + if (prev_attrib->type != VASurfaceAttribPixelFormat) + break; + is_duplicate = prev_attrib->value.value.i == attrib->value.value.i; + } + if (is_duplicate) + attrib->flags = VA_SURFACE_ATTRIB_NOT_SUPPORTED; + else + out_num_attribs++; + } + + if (*out_num_attribs_ptr < out_num_attribs) { + *out_num_attribs_ptr = out_num_attribs; + va_status = VA_STATUS_ERROR_MAX_NUM_EXCEEDED; + goto end; + } + + out_attrib = out_attribs; + for (n = 0; n < num_attribs; n++) { + const VASurfaceAttrib * const attrib = &attribs[n]; + if (attrib->flags == VA_SURFACE_ATTRIB_NOT_SUPPORTED) + continue; + *out_attrib++ = *attrib; + } + +end: + free(attribs); + free(image_formats); + return va_status; +} + VAStatus -vaGetSurfaceAttributes( +vaQuerySurfaceAttributes( VADisplay dpy, VAConfigID config, VASurfaceAttrib *attrib_list, - unsigned int num_attribs + unsigned int *num_attribs ) { VADriverContextP ctx; @@ -691,11 +827,15 @@ vaGetSurfaceAttributes( if (!ctx) return VA_STATUS_ERROR_INVALID_DISPLAY; - if (!ctx->vtable->vaGetSurfaceAttributes) - return VA_STATUS_ERROR_UNIMPLEMENTED; + if (!ctx->vtable->vaQuerySurfaceAttributes) + vaStatus = va_impl_query_surface_attributes(ctx, config, + attrib_list, num_attribs); + else + vaStatus = ctx->vtable->vaQuerySurfaceAttributes(ctx, config, + attrib_list, num_attribs); + + VA_TRACE_LOG(va_TraceQuerySurfaceAttributes, dpy, config, attrib_list, num_attribs); - vaStatus = ctx->vtable->vaGetSurfaceAttributes(ctx, config, - attrib_list, num_attribs); return vaStatus; } @@ -720,16 +860,14 @@ vaCreateSurfaces( return VA_STATUS_ERROR_INVALID_DISPLAY; if (ctx->vtable->vaCreateSurfaces2) - return ctx->vtable->vaCreateSurfaces2(ctx, format, width, height, + vaStatus = ctx->vtable->vaCreateSurfaces2(ctx, format, width, height, surfaces, num_surfaces, attrib_list, num_attribs); - - if (attrib_list && num_attribs > 0) - return VA_STATUS_ERROR_ATTR_NOT_SUPPORTED; - - vaStatus = ctx->vtable->vaCreateSurfaces(ctx, width, height, format, - num_surfaces, surfaces); - + else if (attrib_list && num_attribs > 0) + vaStatus = VA_STATUS_ERROR_ATTR_NOT_SUPPORTED; + else + vaStatus = ctx->vtable->vaCreateSurfaces(ctx, width, height, format, + num_surfaces, surfaces); VA_TRACE_LOG(va_TraceCreateSurfaces, dpy, width, height, format, num_surfaces, surfaces, attrib_list, num_attribs); @@ -745,10 +883,17 @@ VAStatus vaDestroySurfaces ( ) { VADriverContextP ctx; + VAStatus vaStatus; + CHECK_DISPLAY(dpy); ctx = CTX(dpy); - return ctx->vtable->vaDestroySurfaces( ctx, surface_list, num_surfaces ); + VA_TRACE_LOG(va_TraceDestroySurfaces, + dpy, surface_list, num_surfaces); + + vaStatus = ctx->vtable->vaDestroySurfaces( ctx, surface_list, num_surfaces ); + + return vaStatus; } VAStatus vaCreateContext ( @@ -406,20 +406,41 @@ typedef enum */ VAConfigAttribEncMacroblockInfo = 16, /** - * \brief Auto reference frame management. Read-Write. + * \brief Auto reference frame management. Read-only * * This attribute determines whether the driver supports auto reference management * - * If driver supports, and application sets it to true, application only needs to set scratch - * reference surfaces via VAPictureParameterBufferH264: ReferenceFrames. The scratch surfaces - * number is determined by the maximum number of RefPicList0 and RefPicList0 which can be queried from + * If driver supports, application only needs to set scratch reference surfaces + * via VAPictureParameterBufferH264:ReferenceFrames. The scratch surfaces number is + * determined by the maximum number of RefPicList0 and RefPicList0 which can be queried from * VAConfigAttribEncMaxRefFrames. Application doesn't need to set VAPictureParameterBufferH264:CurrPic - * and VAEncSliceParameterBufferH264:RefPicList. Driver will manage the reference frames internally + * and VAEncSliceParameterBufferH264:RefPicList. Driver will manage the reference frames internally * and choose the best reference frames. Which scratch surface is used for reconstructed frame and which * surfaces are used for reference frames will be fedback via VACodedBufferSegment - * */ VAConfigAttribEncAutoReference = 17, + /** + * \brief Maximum picture width. Read-only. + * + * This attribute determines the maximum picture width the driver supports + * for a given configuration. + */ + VAConfigAttribMaxPictureWidth = 18, + /** + * \brief Maximum picture height. Read-only. + * + * This attribute determines the maximum picture height the driver supports + * for a given configuration. + */ + VAConfigAttribMaxPictureHeight = 19, + /** + * \brief JPEG encoding attribute. Read-only. + * + * This attribute exposes a number of capabilities of the underlying + * JPEG implementation. The attribute value is partitioned into fields as defined in the + * VAConfigAttribValEncJPEG union. + */ + VAConfigAttribEncJPEG = 20, /**@}*/ VAConfigAttribTypeMax } VAConfigAttribType; @@ -483,6 +504,8 @@ typedef struct _VAConfigAttrib { #define VA_ENC_PACKED_HEADER_SLICE 0x00000004 /** \brief Driver supports misc packed headers. e.g. SEI for H.264. */ #define VA_ENC_PACKED_HEADER_MISC 0x00000008 +/** \brief Driver supports raw packed header, see VAEncPackedHeaderRawData */ +#define VA_ENC_PACKED_HEADER_RAW_DATA 0x0000000C /**@}*/ /** @name Attribute values for VAConfigAttribEncInterlaced */ @@ -509,6 +532,25 @@ typedef struct _VAConfigAttrib { #define VA_ENC_SLICE_STRUCTURE_ARBITRARY_MACROBLOCKS 0x00000002 /**@}*/ +/** \brief Attribute value for VAConfigAttribEncJPEG */ +typedef union _VAConfigAttribValEncJPEG { + struct { + /** \brief set to 1 for arithmatic coding. */ + unsigned int arithmatic_coding_mode : 1; + /** \brief set to 1 for progressive dct. */ + unsigned int progressive_dct_mode : 1; + /** \brief set to 1 for non-interleaved. */ + unsigned int non_interleaved_mode : 1; + /** \brief set to 1 for differential. */ + unsigned int differential_mode : 1; + unsigned int max_num_components : 3; + unsigned int max_num_scans : 4; + unsigned int max_num_huffman_tables : 3; + unsigned int max_num_quantization_tables : 3; + } bits; + unsigned int value; +} VAConfigAttribValEncJPEG; + /* * if an attribute is not applicable for a given * profile/entrypoint pair, then set the value to the following @@ -777,37 +819,48 @@ typedef struct _VASurfaceAttribExternalBuffers { /**@}*/ /** - * \brief Get surface attributes for the supplied config. + * \brief Queries surface attributes for the supplied config. + * + * Unlike vaGetSurfaceAttributes(), this function queries for all + * supported attributes for the supplied VA @config. In particular, if + * the underlying hardware supports the creation of VA surfaces in + * various formats, then this function will enumerate all pixel + * formats that are supported. * - * This function retrieves the surface attributes matching the supplied - * config. The caller shall provide an \c attrib_list with all attributes - * to be retrieved. Upon successful return, the attributes in \c attrib_list - * are updated with the requested value. Unknown attributes or attributes - * that are not supported for the given config will have their \c flags - * field set to \c VA_SURFACE_ATTRIB_NOT_SUPPORTED. + * The \c attrib_list array is allocated by the user and \c + * num_attribs shall be initialized to the number of allocated + * elements in that array. Upon successful return, the actual number + * of attributes will be overwritten into \c num_attribs. Otherwise, + * \c VA_STATUS_ERROR_MAX_NUM_EXCEEDED is returned and \c num_attribs + * is adjusted to the number of elements that would be returned if + * enough space was available. + * + * Note: it is perfectly valid to pass NULL to the \c attrib_list + * argument when vaQuerySurfaceAttributes() is used to determine the + * actual number of elements that need to be allocated. * * @param[in] dpy the VA display * @param[in] config the config identifying a codec or a video * processing pipeline - * @param[in,out] attrib_list the list of attributes on input, with at - * least \c type fields filled in, and possibly \c value fields whenever - * necessary. The updated list of attributes and flags on output - * @param[in] num_attribs the number of attributes supplied in the - * \c attrib_list array + * @param[out] attrib_list the output array of #VASurfaceAttrib elements + * @param[in,out] num_attribs the number of elements allocated on + * input, the number of elements actually filled in output */ VAStatus -vaGetSurfaceAttributes( +vaQuerySurfaceAttributes( VADisplay dpy, VAConfigID config, VASurfaceAttrib *attrib_list, - unsigned int num_attribs + unsigned int *num_attribs ); /** * \brief Creates an array of surfaces * * Creates an array of surfaces. The optional list of attributes shall - * be constructed and verified through vaGetSurfaceAttributes(). + * be constructed and validated through vaGetSurfaceAttributes() or + * constructed based based on what the underlying hardware could + * expose through vaQuerySurfaceAttributes(). * * @param[in] dpy the VA display * @param[in] format the desired surface format. See \c VA_RT_FORMAT_* @@ -936,10 +989,8 @@ typedef enum * color balance (#VAProcFilterParameterBufferColorBalance), etc. */ VAProcFilterParameterBufferType = 42, - VAParsePictureParameterBufferType = 43, VAParseSliceHeaderGroupBufferType = 44, - VABufferTypeMax } VABufferType; @@ -967,8 +1018,9 @@ typedef enum { * \brief Packed raw header. * * Packed raw data header can be used by the client to insert a header - * into the bitstream data buffer at the point it is passed, without - * any handling or interpretation by the implementation. + * into the bitstream data buffer at the point it is passed, the driver + * will handle the raw packed header based on "has_emulation_bytes" field + * in the packed header parameter structure. */ VAEncPackedHeaderRawData = 4, /** \brief Misc packed header. See codec-specific definitions. */ @@ -1104,28 +1156,6 @@ typedef struct _VASliceParameterBufferBase unsigned int slice_data_flag; /* see VA_SLICE_DATA_FLAG_XXX definitions */ } VASliceParameterBufferBase; - -/**************************** - * JEPG data structure - ***************************/ -typedef struct _VAQMatrixBufferJPEG -{ - int load_lum_quantiser_matrix; - int load_chroma_quantiser_matrix; - unsigned char lum_quantiser_matrix[64]; - unsigned char chroma_quantiser_matrix[64]; -} VAQMatrixBufferJPEG; - -typedef struct _VAEncPictureParameterBufferJPEG -{ - VASurfaceID reconstructed_picture; - unsigned short picture_width; - unsigned short picture_height; - VABufferID coded_buf; -} VAEncPictureParameterBufferJPEG; - -#include <va/va_dec_jpeg.h> - /**************************** * MPEG-2 data structures ****************************/ @@ -1847,6 +1877,16 @@ VAStatus vaBufferSetNumElements ( #define VA_CODED_BUF_STATUS_SINGLE_NALU 0x10000000 /** + * \brief The coded buffer segment contains a private data. + * + * This flag indicates that the coded buffer segment contains + * private data. This flag can be used to exchange private data + * between the client and the driver. Private data should follow + * regular coded data in the coded buffer segement list. + */ +#define VA_CODED_BUF_STATUS_PRIVATE_DATA 0x80000000 + +/** * \brief Coded buffer segment. * * #VACodedBufferSegment is an element of a linked list describing diff --git a/va/va_backend.h b/va/va_backend.h index 2d7cfc7..875ea34 100755 --- a/va/va_backend.h +++ b/va/va_backend.h @@ -392,6 +392,7 @@ struct VADriverVTable VASurfaceID surface ); + /* DEPRECATED */ VAStatus (*vaGetSurfaceAttributes)( VADriverContextP dpy, @@ -411,6 +412,14 @@ struct VADriverVTable VASurfaceAttrib *attrib_list, unsigned int num_attribs ); + + VAStatus + (*vaQuerySurfaceAttributes)( + VADriverContextP dpy, + VAConfigID config, + VASurfaceAttrib *attrib_list, + unsigned int *num_attribs + ); }; struct VADriverContext diff --git a/va/va_enc_jpeg.h b/va/va_enc_jpeg.h new file mode 100644 index 0000000..be6b36e --- /dev/null +++ b/va/va_enc_jpeg.h @@ -0,0 +1,158 @@ +/* + * Copyright (c) 2007-2013 Intel Corporation. All Rights Reserved. + * + * Permission is hereby granted, free of charge, to any person obtaining a + * copy of this software and associated documentation files (the + * "Software"), to deal in the Software without restriction, including + * without limitation the rights to use, copy, modify, merge, publish, + * distribute, sub license, and/or sell copies of the Software, and to + * permit persons to whom the Software is furnished to do so, subject to + * the following conditions: + * + * The above copyright notice and this permission notice (including the + * next paragraph) shall be included in all copies or substantial portions + * of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS + * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF + * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT. + * IN NO EVENT SHALL INTEL AND/OR ITS SUPPLIERS BE LIABLE FOR + * ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, + * TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE + * SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. + */ + +/** + * \file va_enc_jpeg.h + * \brief JPEG encoding API + * + * This file contains the \ref api_enc_jpeg "JPEG encoding API". + */ + +#ifndef VA_ENC_JPEG_H +#define VA_ENC_JPEG_H + +#ifdef __cplusplus +extern "C" { +#endif + +/** + * \defgroup api_enc_jpeg JPEG encoding API + * + * @{ + */ + +/** + * \brief JPEG Encoding Picture Parameter Buffer Structure + * + * This structure conveys picture level parameters. + * + */ +typedef struct _VAEncPictureParameterBufferJPEG +{ + /** \brief holds reconstructed picture. */ + VASurfaceID reconstructed_picture; + /** \brief picture width. */ + unsigned short picture_width; + /** \brief picture height. */ + unsigned short picture_height; + /** \brief holds coded data. */ + VABufferID coded_buf; + + /** + * \brief pic_flags + * + */ + union { + struct { + /** + * \brief profile: + * 0 - Baseline, 1 - Extended, 2 - Lossless, 3 - Hierarchical + */ + unsigned int profile : 2; + /** + * \brief progressive: + * 0 - sequential, 1 - extended, 2 - progressive + */ + unsigned int progressive : 1; + /** + * \brief huffman: + * 0 - arithmetic, 1 - huffman + */ + unsigned int huffman : 1; + /** + * \brief interleaved: + * 0 - non interleaved, 1 - interleaved + */ + unsigned int interleaved : 1; + /** + * \brief differential: + * 0 - non differential, 1 - differential + */ + unsigned int differential : 1; + } bits; + unsigned int value; + } pic_flags; + + /** \brief number of bits per sample. */ + unsigned char sample_bit_depth; + /** \brief total number of scans in image. */ + unsigned char num_scan; + /** \brief number of image components in frame. */ + unsigned short num_components; + /** \brief Component identifier (Ci). */ + unsigned char component_id[4]; + /** \brief Quantization table selector (Tqi). */ + unsigned char quantiser_table_selector[4]; + /** \brief number from 1 to 100 that specifies quality of image. */ + unsigned char quality; + +} VAEncPictureParameterBufferJPEG; + + +/** + * \brief Slice parameter for JPEG encoding. + * + * This structure conveys slice (scan) level parameters. + * + */ +typedef struct _VAEncSliceParameterBufferJPEG { + /** \brief Restart interval definition (Ri). */ + unsigned short restart_interval; + /** \brief number of image components in a scan. */ + unsigned short num_components; + struct { + /** \brief Scan component selector (Csj). */ + unsigned char component_selector; + /** \brief DC entropy coding table selector (Tdj). */ + unsigned char dc_table_selector; + /** \brief AC entropy coding table selector (Taj). */ + unsigned char ac_table_selector; + } components[4]; +} VAEncSliceParameterBufferJPEG; + +/** + * \brief Quantization table for JPEG encoding. + * + */ +typedef struct _VAQMatrixBufferJPEG +{ + /** \brief load luma quantization table. */ + int load_lum_quantiser_matrix; + /** \brief load chroma quantization table. */ + int load_chroma_quantiser_matrix; + /** \brief luma quantization table. */ + unsigned char lum_quantiser_matrix[64]; + /** \brief chroma quantization table. */ + unsigned char chroma_quantiser_matrix[64]; +} VAQMatrixBufferJPEG; + +/**@}*/ + +#include <va/va_dec_jpeg.h> + +#ifdef __cplusplus +} +#endif + +#endif /* VA_ENC_JPEG_H */ diff --git a/va/va_enc_mpeg2.h b/va/va_enc_mpeg2.h index bb119e4..cee974b 100644 --- a/va/va_enc_mpeg2.h +++ b/va/va_enc_mpeg2.h @@ -265,16 +265,6 @@ typedef struct _VAEncPictureParameterBufferMPEG2 { } bits; unsigned int value; } composite_display; - - /** \brief The length of user data - * - * Append user data after picture coding extension - * if user_data_length isn't 0. - * - */ - unsigned int user_data_length; - /** \brief User data */ - unsigned char user_data[16]; } VAEncPictureParameterBufferMPEG2; /** diff --git a/va/va_trace.c b/va/va_trace.c index 6c8aa15..936d4b6 100755 --- a/va/va_trace.c +++ b/va/va_trace.c @@ -28,6 +28,7 @@ #include "va_backend.h" #include "va_trace.h" #include "va_enc_h264.h" +#include "va_enc_jpeg.h" #include "va_dec_jpeg.h" #include <assert.h> #include <stdarg.h> @@ -41,6 +42,7 @@ #include <unistd.h> #include <time.h> #include <errno.h> +#include <pthread.h> /* * Env. to debug some issue, e.g. the decode/encode issue in a video conference scenerio: @@ -100,6 +102,7 @@ static struct _trace_context { unsigned int trace_frame_height; /* current frame height */ unsigned int trace_sequence_start; /* get a new sequence for encoding or not */ } trace_context[TRACE_CONTEXT_MAX]; /* trace five context at the same time */ +static pthread_mutex_t ctx_mutex = PTHREAD_MUTEX_INITIALIZER; #define DPY2INDEX(dpy) \ int idx; \ @@ -164,15 +167,18 @@ void va_TraceInit(VADisplay dpy) unsigned short suffix = 0xffff & ((unsigned int)time(NULL)); int trace_index = 0; FILE *tmp; - + + pthread_mutex_lock(&ctx_mutex); for (trace_index = 0; trace_index < TRACE_CONTEXT_MAX; trace_index++) if (trace_context[trace_index].dpy == 0) break; - - if (trace_index == TRACE_CONTEXT_MAX) + if (trace_index < TRACE_CONTEXT_MAX) + trace_context[trace_index].dpy = dpy; + pthread_mutex_unlock(&ctx_mutex); + + if (trace_index == TRACE_CONTEXT_MAX) return; - memset(&trace_context[trace_index], 0, sizeof(struct _trace_context)); if (va_parseConfig("LIBVA_TRACE", &env_value[0]) == 0) { FILE_NAME_SUFFIX(env_value); trace_context[trace_index].trace_log_fn = strdup(env_value); @@ -244,8 +250,6 @@ void va_TraceInit(VADisplay dpy) trace_context[trace_index].trace_surface_yoff); } } - - trace_context[trace_index].dpy = dpy; } @@ -475,9 +479,11 @@ void va_TraceCreateConfig( va_TraceMsg(idx, "\tprofile = %d\n", profile); va_TraceMsg(idx, "\tentrypoint = %d\n", entrypoint); va_TraceMsg(idx, "\tnum_attribs = %d\n", num_attribs); - for (i = 0; i < num_attribs; i++) { - va_TraceMsg(idx, "\t\tattrib_list[%d].type = 0x%08x\n", i, attrib_list[i].type); - va_TraceMsg(idx, "\t\tattrib_list[%d].value = 0x%08x\n", i, attrib_list[i].value); + if (attrib_list) { + for (i = 0; i < num_attribs; i++) { + va_TraceMsg(idx, "\t\tattrib_list[%d].type = 0x%08x\n", i, attrib_list[i].type); + va_TraceMsg(idx, "\t\tattrib_list[%d].value = 0x%08x\n", i, attrib_list[i].value); + } } va_TraceMsg(idx, NULL); @@ -519,6 +525,41 @@ void va_TraceCreateConfig( } } +static void va_TraceSurfaceAttributes( + int idx, + VASurfaceAttrib *attrib_list, + unsigned int *num_attribs +) +{ + int i, num; + VASurfaceAttrib *p; + + if (!attrib_list || !num_attribs) + return; + + p = attrib_list; + num = *num_attribs; + if (num > VASurfaceAttribCount) + num = VASurfaceAttribCount; + + for (i=0; i<num; i++) { + va_TraceMsg(idx, "\tattrib_list[%i] =\n", i); + + va_TraceMsg(idx, "\t\ttype = %d\n", p->type); + va_TraceMsg(idx, "\t\tflags = %d\n", p->flags); + va_TraceMsg(idx, "\t\tvalue.type = %d\n", p->value.type); + if (p->value.type == VAGenericValueTypeInteger) + va_TraceMsg(idx, "\t\tvalue.value.i = 0x%08x\n", p->value.value.i); + else if (p->value.type == VAGenericValueTypeFloat) + va_TraceMsg(idx, "\t\tvalue.value.f = %f\n", p->value.value.f); + else if (p->value.type == VAGenericValueTypePointer) + va_TraceMsg(idx, "\t\tvalue.value.p = %p\n", p->value.value.p); + else if (p->value.type == VAGenericValueTypeFunc) + va_TraceMsg(idx, "\t\tvalue.value.fn = %p\n", p->value.value.fn); + + p++; + } +} void va_TraceCreateSurfaces( VADisplay dpy, @@ -541,13 +582,37 @@ void va_TraceCreateSurfaces( va_TraceMsg(idx, "\tformat = %d\n", format); va_TraceMsg(idx, "\tnum_surfaces = %d\n", num_surfaces); - for (i = 0; i < num_surfaces; i++) - va_TraceMsg(idx, "\t\tsurfaces[%d] = 0x%08x\n", i, surfaces[i]); + if (surfaces) { + for (i = 0; i < num_surfaces; i++) + va_TraceMsg(idx, "\t\tsurfaces[%d] = 0x%08x\n", i, surfaces[i]); + } + + va_TraceSurfaceAttributes(idx, attrib_list, &num_attribs); va_TraceMsg(idx, NULL); } +void va_TraceDestroySurfaces( + VADisplay dpy, + VASurfaceID *surface_list, + int num_surfaces +) +{ + int i; + DPY2INDEX(dpy); + + TRACE_FUNCNAME(idx); + + if (surface_list) { + for (i = 0; i < num_surfaces; i++) + va_TraceMsg(idx, "\t\tsurfaces[%d] = 0x%08x\n", i, surface_list[i]); + } + + va_TraceMsg(idx, NULL); +} + + void va_TraceCreateContext( VADisplay dpy, VAConfigID config_id, @@ -563,18 +628,22 @@ void va_TraceCreateContext( DPY2INDEX(dpy); TRACE_FUNCNAME(idx); - + + va_TraceMsg(idx, "\tconfig = 0x%08x\n", config_id); va_TraceMsg(idx, "\twidth = %d\n", picture_width); va_TraceMsg(idx, "\theight = %d\n", picture_height); va_TraceMsg(idx, "\tflag = 0x%08x\n", flag); va_TraceMsg(idx, "\tnum_render_targets = %d\n", num_render_targets); - for (i=0; i<num_render_targets; i++) - va_TraceMsg(idx, "\t\trender_targets[%d] = 0x%08x\n", i, render_targets[i]); - va_TraceMsg(idx, "\tcontext = 0x%08x\n", *context); - va_TraceMsg(idx, NULL); - - trace_context[idx].trace_context = *context; - + if (render_targets) { + for (i=0; i<num_render_targets; i++) + va_TraceMsg(idx, "\t\trender_targets[%d] = 0x%08x\n", i, render_targets[i]); + } + if (context) { + va_TraceMsg(idx, "\tcontext = 0x%08x\n", *context); + trace_context[idx].trace_context = *context; + } else + trace_context[idx].trace_context = VA_INVALID_ID; + trace_context[idx].trace_frame_no = 0; trace_context[idx].trace_slice_no = 0; @@ -638,7 +707,8 @@ void va_TraceCreateBuffer ( TRACE_FUNCNAME(idx); va_TraceMsg(idx, "\tbuf_type=%s\n", buffer_type_to_string(type)); - va_TraceMsg(idx, "\tbuf_id=0x%x\n", *buf_id); + if (buf_id) + va_TraceMsg(idx, "\tbuf_id=0x%x\n", *buf_id); va_TraceMsg(idx, "\tsize=%d\n", size); va_TraceMsg(idx, "\tnum_elements=%d\n", num_elements); @@ -699,6 +769,9 @@ void va_TraceMapBuffer ( TRACE_FUNCNAME(idx); va_TraceMsg(idx, "\tbuf_id=0x%x\n", buf_id); va_TraceMsg(idx, "\tbuf_type=%s\n", buffer_type_to_string(type)); + if ((pbuf == NULL) || (*pbuf == NULL)) + return; + buf_list = (VACodedBufferSegment *)(*pbuf); while (buf_list != NULL) { va_TraceMsg(idx, "\tCodedbuf[%d] =\n", i++); @@ -2012,6 +2085,8 @@ static void va_TraceVAEncPictureParameterBufferJPEG( void *data) { VAEncPictureParameterBufferJPEG *p = (VAEncPictureParameterBufferJPEG *)data; + int i; + DPY2INDEX(dpy); va_TraceMsg(idx, "VAEncPictureParameterBufferJPEG\n"); @@ -2019,6 +2094,24 @@ static void va_TraceVAEncPictureParameterBufferJPEG( va_TraceMsg(idx, "\tcoded_buf = %08x\n", p->coded_buf); va_TraceMsg(idx, "\tpicture_width = %d\n", p->picture_width); va_TraceMsg(idx, "\tpicture_height = %d\n", p->picture_height); + va_TraceMsg(idx, "\tpic_flags.bits.profile = %d\n", p->pic_flags.bits.profile); + va_TraceMsg(idx, "\tpic_flags.bits.progressive = %d\n", p->pic_flags.bits.profile); + va_TraceMsg(idx, "\tpic_flags.bits.huffman = %d\n", p->pic_flags.bits.huffman); + va_TraceMsg(idx, "\tpic_flags.bits.interleaved = %d\n", p->pic_flags.bits.interleaved); + va_TraceMsg(idx, "\tpic_flags.bits.differential = %d\n", p->pic_flags.bits.differential); + va_TraceMsg(idx, "\tsample_bit_depth = %d\n", p->sample_bit_depth); + va_TraceMsg(idx, "\tnum_scan = %d\n", p->num_scan); + va_TraceMsg(idx, "\tnum_components = %d\n", p->num_components); + va_TraceMsg(idx, "\tcomponent_id[] = "); + for (i=0; i<4; i++) + va_TraceMsg(idx, "%d\t", p->component_id[i]); + va_TraceMsg(idx, "\n"); + va_TraceMsg(idx, "\tquantiser_table_selector[] = "); + for (i=0; i<4; i++) + va_TraceMsg(idx, "%d\t", p->quantiser_table_selector[i]); + va_TraceMsg(idx, "\n"); + va_TraceMsg(idx, "\tquality = %d\n", p->picture_height); + va_TraceMsg(idx, NULL); trace_context[idx].trace_codedbuf = p->coded_buf; @@ -2065,6 +2158,37 @@ static void va_TraceVAEncQMatrixBufferJPEG( return; } + +static void va_TraceVAEncSliceParameterBufferJPEG( + VADisplay dpy, + VAContextID context, + VABufferID buffer, + VABufferType type, + unsigned int size, + unsigned int num_elements, + void *data) +{ + VAEncSliceParameterBufferJPEG *p = (VAEncSliceParameterBufferJPEG *)data; + int i; + + DPY2INDEX(dpy); + + va_TraceMsg(idx, "VAEncSliceParameterBufferJPEG\n"); + va_TraceMsg(idx, "\trestart_interval = 0x%04x\n", p->restart_interval); + va_TraceMsg(idx, "\tnum_components = 0x%08x\n", p->num_components); + for (i=0; i<4; i++) { + va_TraceMsg(idx, "\tcomponents[%i] =\n "); + va_TraceMsg(idx, "\t\tcomponent_selector = %d\n", p->components[i].component_selector); + va_TraceMsg(idx, "\t\tdc_table_selector = %d\n", p->components[i].dc_table_selector); + va_TraceMsg(idx, "\t\tac_table_selector = %d\n", p->components[i].ac_table_selector); + } + + va_TraceMsg(idx, NULL); + + return; +} + + static void va_TraceH263Buf( VADisplay dpy, VAContextID context, @@ -2149,9 +2273,11 @@ static void va_TraceJPEGBuf( case VAProtectedSliceDataBufferType: case VAEncCodedBufferType: case VAEncSequenceParameterBufferType: - case VAEncSliceParameterBufferType: va_TraceVABuffers(dpy, context, buffer, type, size, num_elements, pbuf); break; + case VAEncSliceParameterBufferType: + va_TraceVAEncPictureParameterBufferJPEG(dpy, context, buffer, type, size, num_elements, pbuf); + break; case VAPictureParameterBufferType: va_TraceVAPictureParameterBufferJPEG(dpy, context, buffer, type, size, num_elements, pbuf); break; @@ -2387,8 +2513,11 @@ void va_TraceRenderPicture( va_TraceMsg(idx, "\tcontext = 0x%08x\n", context); va_TraceMsg(idx, "\tnum_buffers = %d\n", num_buffers); + if (buffers == NULL) + return; + for (i = 0; i < num_buffers; i++) { - unsigned char *pbuf; + unsigned char *pbuf = NULL; unsigned int j; /* get buffer type information */ @@ -2401,7 +2530,9 @@ void va_TraceRenderPicture( va_TraceMsg(idx, "\t num_elements = %d\n", num_elements); vaMapBuffer(dpy, buffers[i], (void **)&pbuf); - + if (pbuf == NULL) + continue; + switch (trace_context[idx].trace_profile) { case VAProfileMPEG2Simple: case VAProfileMPEG2Main: @@ -2514,6 +2645,23 @@ void va_TraceSyncSurface( va_TraceMsg(idx, NULL); } +void va_TraceQuerySurfaceAttributes( + VADisplay dpy, + VAConfigID config, + VASurfaceAttrib *attrib_list, + unsigned int *num_attribs +) +{ + DPY2INDEX(dpy); + + TRACE_FUNCNAME(idx); + va_TraceMsg(idx, "\tconfig = 0x%08x\n", config); + va_TraceSurfaceAttributes(idx, attrib_list, num_attribs); + + va_TraceMsg(idx, NULL); + +} + void va_TraceQuerySurfaceStatus( VADisplay dpy, @@ -2526,7 +2674,8 @@ void va_TraceQuerySurfaceStatus( TRACE_FUNCNAME(idx); va_TraceMsg(idx, "\trender_target = 0x%08x\n", render_target); - va_TraceMsg(idx, "\tstatus = 0x%08x\n", *status); + if (status) + va_TraceMsg(idx, "\tstatus = 0x%08x\n", *status); va_TraceMsg(idx, NULL); } @@ -2543,9 +2692,9 @@ void va_TraceQuerySurfaceError( TRACE_FUNCNAME(idx); va_TraceMsg(idx, "\tsurface = 0x%08x\n", surface); va_TraceMsg(idx, "\terror_status = 0x%08x\n", error_status); - if (error_status == VA_STATUS_ERROR_DECODING_ERROR) { + if (error_info && (error_status == VA_STATUS_ERROR_DECODING_ERROR)) { VASurfaceDecodeMBErrors *p = *error_info; - while (p->status != -1) { + while (p && (p->status != -1)) { va_TraceMsg(idx, "\t\tstatus = %d\n", p->status); va_TraceMsg(idx, "\t\tstart_mb = %d\n", p->start_mb); va_TraceMsg(idx, "\t\tend_mb = %d\n", p->end_mb); @@ -2578,8 +2727,11 @@ void va_TraceQueryDisplayAttributes ( DPY2INDEX(dpy); - va_TraceMsg(idx, "\tnum_attributes = %d\n", *num_attributes); + if (attr_list == NULL || num_attributes == NULL) + return; + va_TraceMsg(idx, "\tnum_attributes = %d\n", *num_attributes); + for (i=0; i<*num_attributes; i++) { va_TraceMsg(idx, "\tattr_list[%d] =\n"); va_TraceMsg(idx, "\t typ = 0x%08x\n", attr_list[i].type); @@ -2603,6 +2755,9 @@ static void va_TraceDisplayAttributes ( DPY2INDEX(dpy); va_TraceMsg(idx, "\tnum_attributes = %d\n", num_attributes); + if (attr_list == NULL) + return; + for (i=0; i<num_attributes; i++) { va_TraceMsg(idx, "\tattr_list[%d] =\n"); va_TraceMsg(idx, "\t typ = 0x%08x\n", attr_list[i].type); diff --git a/va/va_trace.h b/va/va_trace.h index e712201..56558bb 100755 --- a/va/va_trace.h +++ b/va/va_trace.h @@ -144,6 +144,13 @@ void va_TraceSyncSurface( VASurfaceID render_target ); +void va_TraceQuerySurfaceAttributes( + VADisplay dpy, + VAConfigID config, + VASurfaceAttrib *attrib_list, + unsigned int *num_attribs +); + void va_TraceQuerySurfaceStatus( VADisplay dpy, VASurfaceID render_target, diff --git a/va/va_vpp.h b/va/va_vpp.h index 427104d..8d64b39 100644 --- a/va/va_vpp.h +++ b/va/va_vpp.h @@ -247,14 +247,14 @@ typedef enum _VAProcFilterType { VAProcFilterSharpening, /** \brief Color balance parameters. */ VAProcFilterColorBalance, - /** \brief Color standard conversion. */ - VAProcFilterColorStandard, /** \brief Frame rate conversion. */ VAProcFilterFrameRateConversion, /** \brief Skin Tone Enhancement. */ VAProcFilterSkinToneEnhancement, /** \brief Total Color Correction. */ VAProcFilterTotalColorCorrection, + /** \brief Non-Linear Anamorphic Scaling. */ + VAProcFilterNonLinearAnamorphicScaling, /** \brief Number of video filters. */ VAProcFilterCount } VAProcFilterType; @@ -312,10 +312,37 @@ typedef enum _VAProcColorStandardType { VAProcColorStandardSMPTE240M, /** \brief Generic film. */ VAProcColorStandardGenericFilm, + /** \brief sRGB. */ + VAProcColorStandardSRGB, + /** \brief stRGB. */ + VAProcColorStandardSTRGB, + /** \brief xvYCC601. */ + VAProcColorStandardXVYCC601, + /** \brief xvYCC709. */ + VAProcColorStandardXVYCC709, /** \brief Number of color standards. */ VAProcColorStandardCount } VAProcColorStandardType; +/** \brief Total color correction types. */ +typedef enum _VAProcTotalColorCorrectionType { + VAProcTotalColorCorrectionNone = 0, + /** \brief Red Saturation. */ + VAProcTotalColorCorrectionRed, + /** \brief Green Saturation. */ + VAProcTotalColorCorrectionGreen, + /** \brief Blue Saturation. */ + VAProcTotalColorCorrectionBlue, + /** \brief Cyan Saturation. */ + VAProcTotalColorCorrectionCyan, + /** \brief Magenta Saturation. */ + VAProcTotalColorCorrectionMagenta, + /** \brief Yellow Saturation. */ + VAProcTotalColorCorrectionYellow, + /** \brief Number of color correction attributes. */ + VAProcTotalColorCorrectionCount +} VAProcTotalColorCorrectionType; + /** @name Video blending flags */ /**@{*/ /** \brief Global alpha blending. */ @@ -560,8 +587,7 @@ typedef struct _VAProcPipelineParameterBuffer { * \c VA_BOTTOM_FIELD. Note that any deinterlacing filter * (#VAProcFilterDeinterlacing) will override those flags. * - Color space conversion: \c VA_SRC_BT601, \c VA_SRC_BT709, - * \c VA_SRC_SMPTE_240. Note that any color standard filter - * (#VAProcFilterColorStandard) will override those flags. + * \c VA_SRC_SMPTE_240. * - Scaling: \c VA_FILTER_SCALING_DEFAULT, \c VA_FILTER_SCALING_FAST, * \c VA_FILTER_SCALING_HQ, \c VA_FILTER_SCALING_NL_ANAMORPHIC. */ @@ -762,14 +788,6 @@ typedef struct _VAProcFilterParameterBufferColorBalance { float value; } VAProcFilterParameterBufferColorBalance; -/** \brief Color standard filter parametrization. */ -typedef struct _VAProcFilterParameterBufferColorStandard { - /** \brief Filter type. Shall be set to #VAProcFilterColorStandard. */ - VAProcFilterType type; - /** \brief Color standard to use. */ - VAProcColorStandardType standard; -} VAProcFilterParameterBufferColorStandard; - /** \brief Frame rate conversion filter parametrization. */ typedef struct _VAProcFilterParamterBufferFrameRateConversion { /** \brief filter type. Shall be set to #VAProcFilterFrameRateConversion. */ @@ -787,24 +805,28 @@ typedef struct _VAProcFilterParamterBufferFrameRateConversion { VASurfaceID* output_frames; } VAProcFilterParameterBufferFrameRateConversion; -/** \brief Total Color Correction filter parametrization. */ -typedef struct _VAProcFilterParamterBufferTotalColorCorrection { - /** \brief filter type. Shall be set to #VAProcFilterTotalColorCorrection. */ - VAProcFilterType type; - /** \brief TCC Red Saturation. */ - float red; - /** \brief TCC Green Saturation. */ - float green; - /** \brief TCC Blue Saturation. */ - float blue; - /** \brief TCC cyan Saturation. */ - float cyan; - /** \brief TCC Magenta Saturation. */ - float magenta; - /** \brief TCC Yello Saturation. */ - float yellow; +/** \brief Total color correction filter parametrization. */ +typedef struct _VAProcFilterParameterBufferTotalColorCorrection { + /** \brief Filter type. Shall be set to #VAProcFilterTotalColorCorrection. */ + VAProcFilterType type; + /** \brief Color to correct. */ + VAProcTotalColorCorrectionType attrib; + /** \brief Color correction value. */ + float value; } VAProcFilterParameterBufferTotalColorCorrection; +/** \brief Non-Linear Anamorphic Scaling filter parametrization. */ +typedef struct _VAProcFilterParameterBufferNonLinearAnamorphicScaling { + /** \brief filter type. Shall be set to #VAProcFilterNonLinearAnamorphicScaling. */ + VAProcFilterType type; + /** \brief Vertical crop. */ + float vertical_crop; + /** \brief HLinear region. */ + float horizontal_linear_region; + /** \brief Non-linear crop. */ + float nonlinear_crop; +} VAProcFilterParameterBufferNonLinearAnamorphicScaling; + /** * \brief Default filter cap specification (single range value). * @@ -830,28 +852,24 @@ typedef struct _VAProcFilterCapColorBalance { VAProcFilterValueRange range; } VAProcFilterCapColorBalance; -/** \brief Capabilities specification for the color standard filter. */ -typedef struct _VAProcFilterCapColorStandard { - /** \brief Color standard type. */ - VAProcColorStandardType type; -} VAProcFilterCapColorStandard; - /** \brief Capabilities specification for the Total Color Correction filter. */ typedef struct _VAProcFilterCapTotalColorCorrection { - /** \brief Range of supported values for red saturation. */ - VAProcFilterValueRange red_range; - /** \brief Range of supported values for green saturation. */ - VAProcFilterValueRange green_range; - /** \brief Range of supported values for blue saturation. */ - VAProcFilterValueRange blue_range; - /** \brief Range of supported values for cyan saturation. */ - VAProcFilterValueRange cyan_range; - /** \brief Range of supported values for magenta saturation. */ - VAProcFilterValueRange magenta_range; - /** \brief Range of supported values for yellow saturation. */ - VAProcFilterValueRange yellow_range; + /** \brief Color to correct. */ + VAProcTotalColorCorrectionType type; + /** \brief Range of supported values for the specified color. */ + VAProcFilterValueRange range; } VAProcFilterCapTotalColorCorrection; +/** \brief Capabilities specification for the Non-Linear Anamorphic Scaling filter. */ +typedef struct _VAProcFilterCapNonLinearAnamorphicScaling { + /** \brief Range of supported values for the vertical crop. */ + VAProcFilterValueRange vertical_crop_range; + /** \brief Range of supported values for the horizontal linear region. */ + VAProcFilterValueRange horizontal_linear_region_range; + /** \brief Range of supported values for the non-linear crop. */ + VAProcFilterValueRange nonlinear_crop_range; +} VAProcFilterCapNonLinearAnamorphicScaling; + /** * \brief Queries video processing filters. * |