From ac3fe558425f8df6813fbb9b5cf28f6b6c16a7cf Mon Sep 17 00:00:00 2001 From: "jianfeng.zheng" Date: Mon, 12 Jun 2023 11:02:18 +0800 Subject: [PATCH] add VAProfileAVSJizhun and VAProfileAVSGuangdian Signed-off-by: jianfeng.zheng --- doc/Makefile.am | 1 + doc/meson.build | 1 + va/Makefile.am | 1 + va/meson.build | 1 + va/va.h | 5 +- va/va_dec_avs.h | 144 ++++++++++++++++++++++++++++++++++++++++++++++++ va/va_str.c | 2 + va/va_trace.c | 27 +++++++++ 8 files changed, 181 insertions(+), 1 deletion(-) create mode 100644 va/va_dec_avs.h diff --git a/doc/Makefile.am b/doc/Makefile.am index 378aba1fd..cc9169312 100644 --- a/doc/Makefile.am +++ b/doc/Makefile.am @@ -45,6 +45,7 @@ VA_HEADER_FILES = \ $(VA_HEADER_DIR)/va_dec_vp8.h \ $(VA_HEADER_DIR)/va_dec_vp9.h \ $(VA_HEADER_DIR)/va_dec_av1.h \ + $(VA_HEADER_DIR)/va_dec_avs.h \ $(VA_HEADER_DIR)/va_prot.h \ $(VA_HEADER_DIR)/va_vpp.h \ $(NULL) diff --git a/doc/meson.build b/doc/meson.build index e736a6b60..03c876748 100644 --- a/doc/meson.build +++ b/doc/meson.build @@ -22,6 +22,7 @@ libva_headers_doc = [ 'va_dec_vp8.h', 'va_dec_vp9.h', 'va_dec_av1.h', + 'va_dec_avs.h', 'va_prot.h', 'va_vpp.h' ] diff --git a/va/Makefile.am b/va/Makefile.am index 8d16d422c..389d654dd 100644 --- a/va/Makefile.am +++ b/va/Makefile.am @@ -48,6 +48,7 @@ libva_source_h = \ va_dec_jpeg.h \ va_dec_vp8.h \ va_dec_vp9.h \ + va_dec_avs.h \ va_drmcommon.h \ va_egl.h \ va_enc_hevc.h \ diff --git a/va/meson.build b/va/meson.build index 372ae89ff..4917b93b8 100644 --- a/va/meson.build +++ b/va/meson.build @@ -27,6 +27,7 @@ libva_headers = [ 'va_dec_vp8.h', 'va_dec_vp9.h', 'va_dec_av1.h', + 'va_dec_avs.h', 'va_drmcommon.h', 'va_egl.h', 'va_enc_hevc.h', diff --git a/va/va.h b/va/va.h index d3a88616e..940157276 100644 --- a/va/va.h +++ b/va/va.h @@ -538,7 +538,9 @@ typedef enum { VAProfileHEVCSccMain444_10 = 34, /** \brief Profile ID used for protected video playback. */ VAProfileProtected = 35, - VAProfileH264High10 = 36 + VAProfileH264High10 = 36, + VAProfileAVSJizhun = 37, // Chinese GB/T 20090.2—2006 + VAProfileAVSGuangdian = 38, // Chinese GY/T 257.1—2012 } VAProfile; /** @@ -5300,6 +5302,7 @@ typedef union _VACopyOption { */ VAStatus vaCopy(VADisplay dpy, VACopyObject * dst, VACopyObject * src, VACopyOption option); +#include #include #include #include diff --git a/va/va_dec_avs.h b/va/va_dec_avs.h new file mode 100644 index 000000000..497b67d4f --- /dev/null +++ b/va/va_dec_avs.h @@ -0,0 +1,144 @@ +/* + * Copyright (c) 2022 MTHREADS 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_dec_avs.h + * \brief The AVS decoding API + * + * This file contains the \ref api_dec_avs "AVS decoding API". + */ + +#ifndef VA_DEC_AVS_H +#define VA_DEC_AVS_H + +#include + +#ifdef __cplusplus +extern "C" { +#endif + +/** + * \defgroup api_dec_avs AVS decoding API + * + * This AVS decoding API supports Jizhun & Guangdian profiles. + * + * @{ + */ + +typedef enum { + VA_AVS_I_IMG = 0, + VA_AVS_P_IMG = 1, + VA_AVS_B_IMG = 2, +} VAAVSPicType; + +typedef struct _VAPictureAVS { + VASurfaceID surface_id; + uint32_t flags; + uint32_t poc; + + /** \brief Reserved bytes for future use, must be zero */ + uint32_t va_reserved[VA_PADDING_LOW]; +} VAPictureAVS; + +/* flags in VAPictureAVS could be OR of the following */ +#define VA_PICTURE_AVS_INVALID 0x00000001 +#define VA_PICTURE_AVS_TOP_FIELD 0x00000002 +#define VA_PICTURE_AVS_BOTTOM_FIELD 0x00000004 + +/** + * \brief AVS Decoding Picture Parameter Buffer Structure + * + * This structure conveys picture level parameters and should be sent once + * per frame. + */ +typedef struct _VAPictureParameterBufferAVS { + VAPictureAVS curr_pic; + VAPictureAVS ref_list[2]; + + uint16_t width; // coded width + uint16_t height; // coded height + + uint16_t picture_type : 2; // VAAVSPicType + uint16_t progressive_seq_flag : 1; + uint16_t progressive_frame_flag : 1; + uint16_t picture_structure_flag : 1; // 0:field coding, 1:frame coding + uint16_t fixed_pic_qp_flag : 1; + uint16_t picture_qp : 6; + uint16_t loop_filter_disable_flag : 1; + uint16_t skip_mode_flag_flag : 1; + uint16_t picture_reference_flag : 1; + uint16_t no_forward_reference_flag : 1; + + int8_t alpha_c_offset; + int8_t beta_offset; + + struct { + uint16_t guangdian_flag : 1; + uint16_t aec_flag : 1; + uint16_t weight_quant_flag : 1; + uint16_t pb_field_enhanced_flag : 1; + uint16_t reserved : 12; + int8_t chroma_quant_param_delta_cb; + int8_t chroma_quant_param_delta_cr; + uint8_t wqm_8x8[64]; + } guangdian_fields; + + /** \brief Reserved bytes for future use, must be zero */ + uint32_t va_reserved[VA_PADDING_MEDIUM]; +} VAPictureParameterBufferAVS; + +/** + * \brief AVS Slice Parameter Buffer Structure + * + * Slice data buffer of VASliceDataBufferType is used to send the bitstream data. + * When send AVS slice data, start code and slice header should be included. + */ +typedef struct _VASliceParameterBufferAVS { + uint32_t slice_data_size; /* number of bytes in the slice data buffer for this slice */ + uint32_t slice_data_offset; /* the offset to the first byte of slice data */ + uint32_t slice_data_flag; /* see VA_SLICE_DATA_FLAG_XXX defintions */ + uint32_t mb_data_bit_offset; /* offset to the first bit of MB from the first byte of slice data (slice_data_offset) */ + + uint32_t slice_vertical_pos : 16; /* first mb row of the slice */ + uint32_t fixed_slice_qp_flag : 1; + uint32_t slice_qp : 6; + uint32_t slice_weight_pred_flag : 1; + uint32_t mb_weight_pred_flag : 1; + + uint8_t luma_scale[4]; + int8_t luma_shift[4]; + uint8_t chroma_scale[4]; + int8_t chroma_shift[4]; + + /** \brief Reserved bytes for future use, must be zero */ + uint32_t va_reserved[VA_PADDING_LOW]; +} VASliceParameterBufferAVS; + +/**@}*/ + +#ifdef __cplusplus +} +#endif + +#endif /* VA_DEC_AVS_H */ diff --git a/va/va_str.c b/va/va_str.c index 3d96f9b66..efb14fe45 100644 --- a/va/va_str.c +++ b/va/va_str.c @@ -38,6 +38,8 @@ const char *vaProfileStr(VAProfile profile) TOSTR(VAProfileH264Main); TOSTR(VAProfileH264High); TOSTR(VAProfileH264High10); + TOSTR(VAProfileAVSJizhun); + TOSTR(VAProfileAVSGuangdian); TOSTR(VAProfileVC1Simple); TOSTR(VAProfileVC1Main); TOSTR(VAProfileVC1Advanced); diff --git a/va/va_trace.c b/va/va_trace.c index 365708cff..268e38540 100644 --- a/va/va_trace.c +++ b/va/va_trace.c @@ -5571,6 +5571,26 @@ static void va_TraceVC1Buf( } } +static void va_TraceAVSBuf( + VADisplay dpy, + VAContextID context, + VABufferID buffer, + VABufferType type, + unsigned int size, + unsigned int num_elements, + void *pbuf +) +{ + DPY2TRACECTX(dpy, context, VA_INVALID_ID); + + switch (type) { + + default: + va_TraceVABuffers(dpy, context, buffer, type, size, num_elements, pbuf); + break; + } +} + static void va_TraceProcFilterParameterBufferDeinterlacing( VADisplay dpy, @@ -5930,6 +5950,13 @@ void va_TraceRenderPicture( va_TraceAV1Buf(dpy, context, buffers[i], type, size, num_elements, pbuf + size * j); } break; + case VAProfileAVSJizhun: + case VAProfileAVSGuangdian: + for (j = 0; j < num_elements; j++) { + va_TraceMsg(trace_ctx, "\telement[%d] = \n", j); + va_TraceAVSBuf(dpy, context, buffers[i], type, size, num_elements, pbuf + size * j); + } + break; default: break; }