From 336a563eb13b68b6db6ebf6a19ee9c9e8bc7db1c Mon Sep 17 00:00:00 2001 From: Gwenole Beauchesne Date: Fri, 13 Apr 2012 16:20:35 +0200 Subject: [PATCH] Add initial JPEG decoding API. This is work-in-progress API subject to changes. In particular, this API is only suitable to Baseline profile. Huffman and quantization tables also need to be refined. Signed-off-by: Gwenole Beauchesne --- va/Makefile.am | 1 + va/va.h | 1 + va/va_dec_jpeg.h | 194 +++++++++++++++++++++++++++++++++++++++++++++++++++++++ 3 files changed, 196 insertions(+) create mode 100644 va/va_dec_jpeg.h diff --git a/va/Makefile.am b/va/Makefile.am index 4270d69..c888c47 100644 --- a/va/Makefile.am +++ b/va/Makefile.am @@ -44,6 +44,7 @@ libva_source_h = \ va_backend_tpi.h \ va_backend_vpp.h \ va_compat.h \ + va_dec_jpeg.h \ va_dummy.h \ va_enc.h \ va_enc_h264.h \ diff --git a/va/va.h b/va/va.h index 8468f4d..463b464 100644 --- a/va/va.h +++ b/va/va.h @@ -788,6 +788,7 @@ typedef enum VAImageBufferType = 9, VAProtectedSliceDataBufferType = 10, VAQMatrixBufferType = 11, + VAHuffmanTableBufferType = 12, /* Following are encode buffer types */ VAEncCodedBufferType = 21, VAEncSequenceParameterBufferType = 22, diff --git a/va/va_dec_jpeg.h b/va/va_dec_jpeg.h new file mode 100644 index 0000000..53f1769 --- /dev/null +++ b/va/va_dec_jpeg.h @@ -0,0 +1,194 @@ +/* + * Copyright (c) 2007-2012 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_dec_jpeg.h + * \brief The JPEG decoding API + * + * This file contains the \ref api_dec_jpeg "JPEG decoding API". + */ + +#ifndef VA_DEC_JPEG_H +#define VA_DEC_JPEG_H + +#ifdef __cplusplus +extern "C" { +#endif + +#include + +/** + * \defgroup api_dec_jpeg JPEG decoding API + * + * WIP: this is work-in-progress API subject to change. + * + * @{ + */ + +/** + * \brief Picture parameter for JPEG decoding. + * + * This structure holds information from the frame header, along with + * definitions from additional segments. + */ +typedef struct _VAPictureParameterBufferJPEG { + /** \brief Picture width in pixels. */ + unsigned short picture_width; + /** \brief Picture height in pixels. */ + unsigned short picture_height; + /** \brief Sample precision (P). */ + unsigned char sample_precision; + + struct { + /** \brief Component identifier (Ci). */ + unsigned char component_id; + /** \brief Horizontal sampling factor (Hi). */ + unsigned char h_sampling_factor; + /** \brief Vertical sampling factor (Vi). */ + unsigned char v_sampling_factor; + /* \brief Quantization table selector (Tqi). */ + unsigned char quantiser_table_selector; + } components[255]; + /** \brief Number of components in frame (Nf). */ + unsigned char num_components; + + /** @name Cropping (JPEG-2000) */ + /**@{*/ + unsigned char frame_cropping_flag; + unsigned short frame_crop_left_offset; + unsigned short frame_crop_right_offset; + unsigned short frame_crop_top_offset; + unsigned short frame_crop_bottom_offset; + /**@}*/ + + /** \brief Rotation (JPEG-2000). See \c VA_ROTATION_xxx. */ + unsigned int rotation; +} VAPictureParameterBufferJPEG; + +/** + * \brief Quantization table for JPEG decoding. + * + * This structure holds the complete quantization tables. This is an + * aggregation of all quantization table (DQT) segments maintained by + * the application. i.e. up to 4 quantization tables are stored in + * there for baseline profile. + * + * The #load_quantization_table array can be used as a hint to notify + * the VA driver implementation about which table(s) actually changed + * since the last submission of this buffer. + * + * WIP: this is work-in-progress API subject to change, and only + * suitable to Baseline profile. + */ +typedef struct _VAIQMatrixParameterBufferJPEG { + /** \brief Specifies which #quantiser_table is valid. */ + unsigned char load_quantiser_table[4]; + /** \brief Quanziation tables indexed by table identifier (Tqi). */ + unsigned char quantiser_table[4][64]; +} VAIQMatrixParameterBufferJPEG; + +/** + * \brief Huffman table for JPEG decoding. + * + * This structure holds the complete Huffman tables. This is an + * aggregation of all Huffman table (DHT) segments maintained by the + * application. i.e. up to 2 Huffman tables are stored in there for + * baseline profile. + * + * The #load_huffman_table array can be used as a hint to notify the + * VA driver implementation about which table(s) actually changed + * since the last submission of this buffer. + * + * WIP: this is work-in-progress API subject to change, and only + * suitable to Baseline profile. + */ +typedef struct _VAHuffmanTableParameterBufferJPEG { + /** \brief Specifies which #huffman_table is valid. */ + unsigned char load_huffman_table[2]; + /** \brief Huffman tables indexed by table identifier (Th). */ + struct { + /** @name DC table (up to 12 categories) */ + /**@{*/ + /** \brief Number of Huffman codes of length i + 1 (Li). */ + unsigned char num_dc_codes[16]; + /** \brief Value associated with each Huffman code (Vij). */ + unsigned char dc_values[12]; + /**@}*/ + /** @name AC table (2 special codes + up to 16 * 10 codes) */ + /**@{*/ + /** \brief Number of Huffman codes of length i + 1 (Li). */ + unsigned char num_ac_codes[16]; + /** \brief Value associated with each Huffman code (Vij). */ + unsigned char ac_values[162]; + /**@}*/ + } huffman_table[2]; +} VAHuffmanTableParameterBufferJPEG; + +/** + * \brief Slice parameter for JPEG decoding. + * + * This structure holds information from the scan header, along with + * definitions from additional segments. The associated slice data + * buffer holds all entropy coded segments (ECS) in the scan. + */ +typedef struct _VASliceParameterBufferJPEG { + /** @name Codec-independent Slice Parameter Buffer base. */ + /**@{*/ + /** \brief Number of bytes in the slice data buffer for this slice. */ + unsigned int slice_data_size; + /** \brief The offset to the first byte of the first MCU. */ + unsigned int slice_data_offset; + /** \brief Slice data buffer flags. See \c VA_SLICE_DATA_FLAG_xxx. */ + unsigned int slice_data_flag; + /**@}*/ + + /** \brief Scan horizontal position. */ + unsigned int slice_horizontal_position; + /** \brief Scan vertical position. */ + unsigned int slice_vertical_position; + + 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]; + /** \brief Number of components in scan (Ns). */ + unsigned char num_components; + + /** \brief Restart interval definition (Ri). */ + unsigned short restart_interval; + /** \brief Number of MCUs in a scan. */ + unsigned int num_mcus; +} VASliceParameterBufferJPEG; + +/**@}*/ + +#ifdef __cplusplus +} +#endif + +#endif /* VA_DEC_JPEG_H */ -- 2.7.4