Subversion Repositories Kolibri OS

Rev

Blame | Last modification | View Log | RSS feed

  1. /*
  2.  * Copyright (c) 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_enc_mpeg2.h
  27.  * \brief The MPEG-2 encoding API
  28.  *
  29.  * This file contains the \ref api_enc_mpeg2 "MPEG-2 encoding API".
  30.  */
  31.  
  32. #ifndef _VA_ENC_MPEG2_H_
  33. #define _VA_ENC_MPEG2_H_
  34.  
  35. #ifdef __cplusplus
  36. extern "C" {
  37. #endif
  38.  
  39. /**
  40.  * \defgroup api_enc_mpeg2 MPEG-2 encoding API
  41.  *
  42.  * @{
  43.  */
  44.  
  45. /**
  46.  * \brief MPEG-2 Quantization Matrix Buffer
  47.  *
  48.  */
  49. typedef VAIQMatrixBufferMPEG2 VAQMatrixBufferMPEG2;
  50.  
  51. /**
  52.  * \brief Packed header types specific to MPEG-2 encoding.
  53.  *
  54.  * Types of packed headers generally used for MPEG-2 encoding.
  55.  */
  56. typedef enum {
  57.     /**
  58.      * \brief Packed Sequence Parameter Set (SPS).
  59.      *
  60.      */
  61.     VAEncPackedHeaderMPEG2_SPS = VAEncPackedHeaderSequence,
  62.     /**
  63.      * \brief Packed Picture Parameter Set (PPS).
  64.      *
  65.      */
  66.     VAEncPackedHeaderMPEG2_PPS = VAEncPackedHeaderPicture,
  67.     /**
  68.      * \brief Packed slice header.
  69.      *
  70.      */
  71.     VAEncPackedHeaderMPEG2_Slice = VAEncPackedHeaderSlice,
  72. } VAEncPackedHeaderTypeMPEG2;
  73.  
  74. /**
  75.  * \brief Sequence parameter for MPEG-2 encoding
  76.  *
  77.  * This structure holds information for \c sequence_header() and
  78.  * sequence_extension().
  79.  *
  80.  * If packed sequence headers mode is used, i.e. if the encoding
  81.  * pipeline was configured with the #VA_ENC_PACKED_HEADER_SEQUENCE
  82.  * flag, then the driver expects two more buffers to be provided to
  83.  * the same \c vaRenderPicture() as this buffer:
  84.  * - a #VAEncPackedHeaderParameterBuffer with type set to
  85.  *   VAEncPackedHeaderType::VAEncPackedHeaderSequence ;
  86.  * - a #VAEncPackedHeaderDataBuffer which holds the actual packed
  87.  *   header data.
  88.  *
  89.  */
  90. typedef struct _VAEncSequenceParameterBufferMPEG2 {
  91.     /** \brief Period between I frames. */
  92.     unsigned int intra_period;
  93.     /** \brief Period between I/P frames. */
  94.     unsigned int ip_period;
  95.     /** \brief Picture width.
  96.      *
  97.      * A 14bits unsigned inter, the lower 12bits
  98.      * is horizontal_size_value, and the upper
  99.      * 2bits is \c horizontal_size_extension
  100.      *
  101.      */
  102.     unsigned short picture_width;
  103.     /** \brief Picture height.
  104.      *
  105.      * A 14bits unsigned inter, the lower 12bits
  106.      * is vertical_size_value, and the upper 2bits is
  107.      * vertical_size_size_extension
  108.      *
  109.      */
  110.     unsigned short picture_height;
  111.     /**
  112.      * \brief Initial bitrate set for this sequence in CBR or VBR modes.
  113.      *
  114.      * This field represents the initial bitrate value for this
  115.      * sequence if CBR or VBR mode is used, i.e. if the encoder
  116.      * pipeline was created with a #VAConfigAttribRateControl
  117.      * attribute set to either \ref VA_RC_CBR or \ref VA_RC_VBR.
  118.      *
  119.      * bits_per_second may be derived from bit_rate.
  120.      *
  121.      */
  122.     unsigned int bits_per_second;
  123.     /**
  124.      * \brief Frame rate
  125.      *
  126.      * Derived from frame_rate_value, frame_rate_extension_n and
  127.      * frame_rate_extension_d
  128.      *
  129.      */
  130.     float frame_rate;
  131.     /** \brief Same as the element in sequence_header() */
  132.     unsigned short aspect_ratio_information;
  133.     /** \brief Define the size of VBV */
  134.     unsigned int vbv_buffer_size;
  135.  
  136.     union {
  137.         struct {
  138.             /** \brief Same as the element in Sequence extension() */
  139.             unsigned int profile_and_level_indication   : 8;
  140.             /** \brief Same as the element in Sequence extension() */
  141.             unsigned int progressive_sequence           : 1;
  142.             /** \brief Same as the element in Sequence extension() */
  143.             unsigned int chroma_format                  : 2;
  144.             /** \brief Same as the element in Sequence extension() */
  145.             unsigned int low_delay                      : 1;
  146.             /** \brief Same as the element in Sequence extension() */
  147.             unsigned int frame_rate_extension_n         : 2;
  148.             /** \brief Same as the element in Sequence extension() */
  149.             unsigned int frame_rate_extension_d         : 5;
  150.         } bits;
  151.         unsigned int value;
  152.     } sequence_extension;
  153.  
  154.     /** \brief Flag to indicate the following GOP header are being updated */
  155.     unsigned int new_gop_header;
  156.  
  157.     union {
  158.         struct {
  159.             /** \brief Time code */
  160.             unsigned int time_code                      : 25;
  161.             /** \brief Same as the element in GOP header */
  162.             unsigned int closed_gop                     : 1;
  163.             /** \brief SAme as the element in GOP header */
  164.             unsigned int broken_link                    : 1;
  165.         } bits;
  166.         unsigned int value;
  167.     } gop_header;
  168. } VAEncSequenceParameterBufferMPEG2;
  169.  
  170. /**
  171.  * \brief Picture parameter for MPEG-2 encoding
  172.  *
  173.  * This structure holds information for picture_header() and
  174.  * picture_coding_extension()
  175.  *
  176.  * If packed picture headers mode is used, i.e. if the encoding
  177.  * pipeline was configured with the #VA_ENC_PACKED_HEADER_PICTURE
  178.  * flag, then the driver expects two more buffers to be provided to
  179.  * the same \c vaRenderPicture() as this buffer:
  180.  * - a #VAEncPackedHeaderParameterBuffer with type set to
  181.  *   VAEncPackedHeaderType::VAEncPackedHeaderPicture ;
  182.  * - a #VAEncPackedHeaderDataBuffer which holds the actual packed
  183.  *   header data.
  184.  *
  185.  */
  186. typedef struct _VAEncPictureParameterBufferMPEG2 {
  187.     /** \brief Forward reference picture */
  188.     VASurfaceID forward_reference_picture;
  189.     /** \brief Backward reference picture */
  190.     VASurfaceID backward_reference_picture;
  191.     /** \brief Reconstructed(decoded) picture */
  192.     VASurfaceID reconstructed_picture;
  193.     /**
  194.      * \brief Output encoded bitstream.
  195.      *
  196.      * \ref coded_buf has type #VAEncCodedBufferType. It should be
  197.      * large enough to hold the compressed NAL slice and possibly SPS
  198.      * and PPS NAL units.
  199.      */
  200.     VABufferID coded_buf;
  201.     /**
  202.      * \brief Flag to indicate the picture is the last one or not.
  203.      *
  204.      * This fields holds 0 if the picture to be encoded is not
  205.      * the last one in the stream. Otherwise, it
  206.      * is \ref MPEG2_LAST_PICTURE_EOSTREAM.
  207.      */
  208.     unsigned char last_picture;
  209.     /** \brief Picture type */
  210.     VAEncPictureType picture_type;
  211.     /** \brief Same as the element in picture_header() */
  212.     unsigned int temporal_reference;
  213.     /** \brief Same as the element in picture_header() */
  214.     unsigned int vbv_delay;
  215.     /** \brief Same as the element in Picture coding extension */
  216.     unsigned char f_code[2][2];
  217.     union {
  218.         struct {
  219.             /** \brief Same as the element in Picture coding extension */
  220.             unsigned int intra_dc_precision             : 2;
  221.             /** \brief Same as the element in Picture coding extension */
  222.             unsigned int picture_structure              : 2;
  223.             /** \brief Same as the element in Picture coding extension */
  224.             unsigned int top_field_first                : 1;
  225.             /** \brief Same as the element in Picture coding extension */
  226.             unsigned int frame_pred_frame_dct           : 1;
  227.             /** \brief Same as the element in Picture coding extension */
  228.             unsigned int concealment_motion_vectors     : 1;
  229.             /** \brief Same as the element in Picture coding extension */
  230.             unsigned int q_scale_type                   : 1;
  231.             /** \brief Same as the element in Picture coding extension */
  232.             unsigned int intra_vlc_format               : 1;
  233.             /** \brief Same as the element in Picture coding extension */
  234.             unsigned int alternate_scan                 : 1;
  235.             /** \brief Same as the element in Picture coding extension */
  236.             unsigned int repeat_first_field             : 1;
  237.             /** \brief Same as the element in Picture coding extension */
  238.             unsigned int progressive_frame              : 1;
  239.             /** \brief Same as the element in Picture coding extension */
  240.             unsigned int composite_display_flag         : 1;
  241.         } bits;
  242.         unsigned int value;
  243.     } picture_coding_extension;
  244.  
  245.     /* \brief Parameters for composite display
  246.      *
  247.      * Valid only when omposite_display_flag is 1
  248.      */
  249.     union {
  250.         struct {
  251.             /** \brief Same as the element in Picture coding extension */            
  252.             unsigned int v_axis                         : 1;
  253.             /** \brief Same as the element in Picture coding extension */
  254.             unsigned int field_sequence                 : 3;
  255.             /** \brief Same as the element in Picture coding extension */
  256.             unsigned int sub_carrier                    : 1;
  257.             /** \brief Same as the element in Picture coding extension */
  258.             unsigned int burst_amplitude                : 7;
  259.             /** \brief Same as the element in Picture coding extension */
  260.             unsigned int sub_carrier_phase              : 8;
  261.         } bits;
  262.         unsigned int value;
  263.     } composite_display;
  264. } VAEncPictureParameterBufferMPEG2;
  265.  
  266. /**
  267.  * \brief Slice parameter for MPEG-2 encoding
  268.  *
  269.  */
  270. typedef struct _VAEncSliceParameterBufferMPEG2 {
  271.     /** \brief Starting MB address for this slice. */
  272.     unsigned int macroblock_address;
  273.     /** \brief Number of macroblocks in this slice. */
  274.     unsigned int num_macroblocks;
  275.     /** \brief Same as the element in slice() */
  276.     int quantiser_scale_code;
  277.     /** \brief Flag to indicate intra slice */
  278.     int is_intra_slice;
  279. } VAEncSliceParameterBufferMPEG2;
  280.  
  281. /**@}*/
  282.  
  283. #ifdef __cplusplus
  284. }
  285. #endif
  286.  
  287. #endif /* _VA_ENC_MPEG2_H_ */
  288.