1/*
2 * Copyright (c) 2007-2012 Intel Corporation. All Rights Reserved.
3 *
4 * Permission is hereby granted, free of charge, to any person obtaining a
5 * copy of this software and associated documentation files (the
6 * "Software"), to deal in the Software without restriction, including
7 * without limitation the rights to use, copy, modify, merge, publish,
8 * distribute, sub license, and/or sell copies of the Software, and to
9 * permit persons to whom the Software is furnished to do so, subject to
10 * the following conditions:
11 *
12 * The above copyright notice and this permission notice (including the
13 * next paragraph) shall be included in all copies or substantial portions
14 * of the Software.
15 *
16 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
17 * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
18 * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT.
19 * IN NO EVENT SHALL INTEL AND/OR ITS SUPPLIERS BE LIABLE FOR
20 * ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
21 * TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
22 * SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
23 */
24
25/**
26 * \file va_dec_jpeg.h
27 * \brief The JPEG decoding API
28 *
29 * This file contains the \ref api_dec_jpeg "JPEG decoding API".
30 */
31
32#ifndef VA_DEC_JPEG_H
33#define VA_DEC_JPEG_H
34
35#ifdef __cplusplus
36extern "C" {
37#endif
38
39#include <va/va.h>
40
41/**
42 * \defgroup api_dec_jpeg JPEG decoding API
43 *
44 * This JPEG decoding API supports Baseline profile only.
45 *
46 * @{
47 */
48
49/**
50 * \brief Picture parameter for JPEG decoding.
51 *
52 * This structure holds information from the frame header, along with
53 * definitions from additional segments.
54 */
55typedef struct _VAPictureParameterBufferJPEGBaseline {
56    /** \brief Picture width in pixels. */
57    unsigned short      picture_width;
58    /** \brief Picture height in pixels. */
59    unsigned short      picture_height;
60
61    struct {
62        /** \brief Component identifier (Ci). */
63        unsigned char   component_id;
64        /** \brief Horizontal sampling factor (Hi). */
65        unsigned char   h_sampling_factor;
66        /** \brief Vertical sampling factor (Vi). */
67        unsigned char   v_sampling_factor;
68        /* \brief Quantization table selector (Tqi). */
69        unsigned char   quantiser_table_selector;
70    }                   components[255];
71    /** \brief Number of components in frame (Nf). */
72    unsigned char       num_components;
73    /** \brief Input color space 0: YUV, 1: RGB, 2: BGR, others: reserved */
74    unsigned char       color_space;
75    /** \brief Set to VA_ROTATION_* for a single rotation angle reported by VAConfigAttribDecJPEG. */
76    unsigned int 	rotation;
77} VAPictureParameterBufferJPEGBaseline;
78
79/**
80 * \brief Quantization table for JPEG decoding.
81 *
82 * This structure holds the complete quantization tables. This is an
83 * aggregation of all quantization table (DQT) segments maintained by
84 * the application. i.e. up to 4 quantization tables are stored in
85 * there for baseline profile.
86 *
87 * The #load_quantization_table array can be used as a hint to notify
88 * the VA driver implementation about which table(s) actually changed
89 * since the last submission of this buffer.
90 */
91typedef struct _VAIQMatrixBufferJPEGBaseline {
92    /** \brief Specifies which #quantiser_table is valid. */
93    unsigned char       load_quantiser_table[4];
94    /** \brief Quanziation tables indexed by table identifier (Tqi). */
95    unsigned char       quantiser_table[4][64];
96} VAIQMatrixBufferJPEGBaseline;
97
98/**
99 * \brief Huffman table for JPEG decoding.
100 *
101 * This structure holds the complete Huffman tables. This is an
102 * aggregation of all Huffman table (DHT) segments maintained by the
103 * application. i.e. up to 2 Huffman tables are stored in there for
104 * baseline profile.
105 *
106 * The #load_huffman_table array can be used as a hint to notify the
107 * VA driver implementation about which table(s) actually changed
108 * since the last submission of this buffer.
109 */
110typedef struct _VAHuffmanTableBufferJPEGBaseline {
111    /** \brief Specifies which #huffman_table is valid. */
112    unsigned char       load_huffman_table[2];
113    /** \brief Huffman tables indexed by table identifier (Th). */
114    struct {
115        /** @name DC table (up to 12 categories) */
116        /**@{*/
117        /** \brief Number of Huffman codes of length i + 1 (Li). */
118        unsigned char   num_dc_codes[16];
119        /** \brief Value associated with each Huffman code (Vij). */
120        unsigned char   dc_values[12];
121        /**@}*/
122        /** @name AC table (2 special codes + up to 16 * 10 codes) */
123        /**@{*/
124        /** \brief Number of Huffman codes of length i + 1 (Li). */
125        unsigned char   num_ac_codes[16];
126        /** \brief Value associated with each Huffman code (Vij). */
127        unsigned char   ac_values[162];
128        /** \brief Padding to 4-byte boundaries. Must be set to zero. */
129        unsigned char   pad[2];
130        /**@}*/
131    }                   huffman_table[2];
132} VAHuffmanTableBufferJPEGBaseline;
133
134/**
135 * \brief Slice parameter for JPEG decoding.
136 *
137 * This structure holds information from the scan header, along with
138 * definitions from additional segments. The associated slice data
139 * buffer holds all entropy coded segments (ECS) in the scan.
140 */
141typedef struct _VASliceParameterBufferJPEGBaseline {
142    /** @name Codec-independent Slice Parameter Buffer base. */
143    /**@{*/
144    /** \brief Number of bytes in the slice data buffer for this slice. */
145    unsigned int        slice_data_size;
146    /** \brief The offset to the first byte of the first MCU. */
147    unsigned int        slice_data_offset;
148    /** \brief Slice data buffer flags. See \c VA_SLICE_DATA_FLAG_xxx. */
149    unsigned int        slice_data_flag;
150    /**@}*/
151
152    /** \brief Scan horizontal position. */
153    unsigned int        slice_horizontal_position;
154    /** \brief Scan vertical position. */
155    unsigned int        slice_vertical_position;
156
157    struct {
158        /** \brief Scan component selector (Csj). */
159        unsigned char   component_selector;
160        /** \brief DC entropy coding table selector (Tdj). */
161        unsigned char   dc_table_selector;
162        /** \brief AC entropy coding table selector (Taj). */
163        unsigned char   ac_table_selector;
164    }                   components[4];
165    /** \brief Number of components in scan (Ns). */
166    unsigned char       num_components;
167
168    /** \brief Restart interval definition (Ri). */
169    unsigned short      restart_interval;
170    /** \brief Number of MCUs in a scan. */
171    unsigned int        num_mcus;
172} VASliceParameterBufferJPEGBaseline;
173
174/**@}*/
175
176#ifdef __cplusplus
177}
178#endif
179
180#endif /* VA_DEC_JPEG_H */
181