Merge JPEG decoding API from staging branch.
authorGwenole Beauchesne <gwenole.beauchesne@intel.com>
Fri, 13 Apr 2012 14:20:35 +0000 (16:20 +0200)
committerGwenole Beauchesne <gwenole.beauchesne@intel.com>
Thu, 26 Jul 2012 04:30:16 +0000 (06:30 +0200)
This API is only suitable to Baseline profile.

Cherry-pick'ed from:
336a563: add initial JPEG decoding API
8a7f92b: cosmetics (vertical align)
9092ecf: fix IQ matrix and Huffman table buffer name
5d30647: add "Baseline" suffix the existing data structures
6eefff7: document decoding API is only suitable to baseline profile
de2df79: include <va/va_dec_jpeg.h> into core VA header
979f0e1: drop JPEG-2000 fields from structures for baseline profile
8a6b12d: drop sample_precision since P=8 for baseline profile

Signed-off-by: Gwenole Beauchesne <gwenole.beauchesne@intel.com>
va/Makefile.am
va/va.h
va/va_dec_jpeg.h [new file with mode: 0644]

index bc70435..1c91dd7 100644 (file)
@@ -41,6 +41,7 @@ libva_source_h = \
        va.h                    \
        va_backend.h            \
        va_backend_tpi.h        \
+       va_dec_jpeg.h           \
        va_dummy.h              \
        va_tpi.h                \
        va_version.h            \
diff --git a/va/va.h b/va/va.h
index 471004e..914cf8d 100644 (file)
--- a/va/va.h
+++ b/va/va.h
@@ -631,94 +631,7 @@ typedef struct _VAEncPictureParameterBufferJPEG
     VABufferID coded_buf;
 } VAEncPictureParameterBufferJPEG;
 
-/* data struct for JPEG decoding */
-
-/* Quantization table */
-typedef struct _VAIQMatrixBufferJPEG
-{
-    int precision[4];                           /* valid value: 0(8-bits) , 1(16-bits), precision[Tq](Tq=0,1,2,3)
-                                                 * specifies precision for destination Tq 
-                                                 */
-    unsigned char quantiser_matrix[4][128];     /* quantiser_matrix[Tq](Tq=0,1,2,3) specifies a 
-                                                 * quantization table for destination Tq in zig-zag
-                                                 * scan order. Only the first 64 bytes are valid for each 
-                                                 * table if precision is 0(8-bits).
-                                                 */
-} VAIQMatrixBufferJPEG;
-
-#define VA_JPEG_SOF0    0xC0
-#define VA_JPEG_SOF1    0xC1
-#define VA_JPEG_SOF2    0xC2
-#define VA_JPEG_SOF3    0xC3
-#define VA_JPEG_SOF5    0xC5
-#define VA_JPEG_SOF6    0xC6
-#define VA_JPEG_SOF7    0xC7
-#define VA_JPEG_SOF9    0xC9
-#define VA_JPEG_SOF10   0xCA
-#define VA_JPEG_SOF11   0xCB
-#define VA_JPEG_SOF13   0xCD
-#define VA_JPEG_SOF14   0xCE
-
-/* JPEG Picture Parameter Buffer */
-typedef struct _VAPictureParameterBufferJPEG
-{
-    unsigned int type; /* SOFn */
-    unsigned int sample_precision;
-    unsigned int image_width;
-    unsigned int image_height;
-    unsigned int num_components;
-    struct {
-        unsigned char component_id;             /* Ci, the range is 0-255, see B.2.2 */
-        unsigned char h_sampling_factor;
-        unsigned char v_sampling_factor;
-        unsigned char quantiser_table_selector; /* Tqi, quantization table destination selector */
-    } components[4];
-
-    /* ROI (region of interest), for JPEG2000 */
-    struct {
-        int enabled;
-        int start_x;
-        int start_y;
-        int end_x;
-        int end_y;
-    } roi;
-
-    int rotation;
-} VAPictureParameterBufferJPEG;
-
-typedef struct _VAHuffmanTableBufferJPEG
-{
-    struct {
-        unsigned char dc_bits[16];      /* Number of Huffman codes of length i for DC */
-        unsigned char dc_huffval[20];   /* Value associated with each Huffman code for DC */
-        unsigned char ac_bits[16];      /* Number of Huffman codes of length i for AC */
-        unsigned char ac_huffval[256];  /* Value associated with each Huffman code for AC */
-    } huffman_table[4];                 /* Up to 4 huffman tables, huffman_table[Th](Th=0,1,2,3)
-                                         * specifies a buffman table for destination Th.
-                                         */
-
-} VAHuffmanTableBufferJPEG;
-
-/* JPEG Scan Parameter Buffer, The Scan of is similar to 
- * the Slice of other codecs */
-typedef struct _VASliceParameterBufferJPEG
-{
-    unsigned int slice_data_size;      /* number of bytes in the slice data buffer for this slice */
-    unsigned int slice_data_offset;    /* the offset to the first byte of slice data */
-    unsigned int slice_data_flag;      /* see VA_SLICE_DATA_FLAG_XXX definitions */
-    unsigned int slice_horizontal_position;
-    unsigned int slice_vertical_position;
-
-    unsigned int num_components;
-    struct {
-        int component_id;               /* Csj, it must match one of component_ids specified in VAPictureParameterBufferJPEG */
-        int dc_selector;                /* Tdj(0,1,2,3) */
-        int ac_selector;                /* Taj(0,1,2,3) */
-    } components[4];
-
-    int restart_interval; /* specifies the number of MCUs in restart interval, defined in DRI marker */
-    int num_mcus;       /* indicates the number of MCUs in a scan */
-} VASliceParameterBufferJPEG;
+#include <va/va_dec_jpeg.h>
 
 /****************************
  * MPEG-2 data structures
diff --git a/va/va_dec_jpeg.h b/va/va_dec_jpeg.h
new file mode 100644 (file)
index 0000000..f8858aa
--- /dev/null
@@ -0,0 +1,174 @@
+/*
+ * 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 <va/va.h>
+
+/**
+ * \defgroup api_dec_jpeg JPEG decoding API
+ *
+ * This JPEG decoding API supports Baseline profile only.
+ *
+ * @{
+ */
+
+/**
+ * \brief Picture parameter for JPEG decoding.
+ *
+ * This structure holds information from the frame header, along with
+ * definitions from additional segments.
+ */
+typedef struct _VAPictureParameterBufferJPEGBaseline {
+    /** \brief Picture width in pixels. */
+    unsigned short      picture_width;
+    /** \brief Picture height in pixels. */
+    unsigned short      picture_height;
+
+    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;
+} VAPictureParameterBufferJPEGBaseline;
+
+/**
+ * \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.
+ */
+typedef struct _VAIQMatrixBufferJPEGBaseline {
+    /** \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];
+} VAIQMatrixBufferJPEGBaseline;
+
+/**
+ * \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.
+ */
+typedef struct _VAHuffmanTableBufferJPEGBaseline {
+    /** \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];
+} VAHuffmanTableBufferJPEGBaseline;
+
+/**
+ * \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 _VASliceParameterBufferJPEGBaseline {
+    /** @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;
+} VASliceParameterBufferJPEGBaseline;
+
+/**@}*/
+
+#ifdef __cplusplus
+}
+#endif
+
+#endif /* VA_DEC_JPEG_H */