Subversion Repositories Kolibri OS

Rev

Blame | Last modification | View Log | RSS feed

  1. /**************************************************************************
  2.  *
  3.  * Copyright 2009 Younes Manton.
  4.  * All Rights Reserved.
  5.  *
  6.  * Permission is hereby granted, free of charge, to any person obtaining a
  7.  * copy of this software and associated documentation files (the
  8.  * "Software"), to deal in the Software without restriction, including
  9.  * without limitation the rights to use, copy, modify, merge, publish,
  10.  * distribute, sub license, and/or sell copies of the Software, and to
  11.  * permit persons to whom the Software is furnished to do so, subject to
  12.  * the following conditions:
  13.  *
  14.  * The above copyright notice and this permission notice (including the
  15.  * next paragraph) shall be included in all copies or substantial portions
  16.  * of the Software.
  17.  *
  18.  * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
  19.  * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
  20.  * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT.
  21.  * IN NO EVENT SHALL VMWARE AND/OR ITS SUPPLIERS BE LIABLE FOR
  22.  * ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
  23.  * TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
  24.  * SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
  25.  *
  26.  **************************************************************************/
  27.  
  28. #ifndef PIPE_VIDEO_CONTEXT_H
  29. #define PIPE_VIDEO_CONTEXT_H
  30.  
  31. #ifdef __cplusplus
  32. extern "C" {
  33. #endif
  34.  
  35. #include "pipe/p_video_state.h"
  36.  
  37. struct pipe_screen;
  38. struct pipe_surface;
  39. struct pipe_macroblock;
  40. struct pipe_picture_desc;
  41. struct pipe_fence_handle;
  42.  
  43. /**
  44.  * Gallium video codec for a specific format/profile
  45.  */
  46. struct pipe_video_codec
  47. {
  48.    struct pipe_context *context;
  49.  
  50.    enum pipe_video_profile profile;
  51.    unsigned level;
  52.    enum pipe_video_entrypoint entrypoint;
  53.    enum pipe_video_chroma_format chroma_format;
  54.    unsigned width;
  55.    unsigned height;
  56.    unsigned max_references;
  57.    bool expect_chunked_decode;
  58.  
  59.    /**
  60.     * destroy this video decoder
  61.     */
  62.    void (*destroy)(struct pipe_video_codec *codec);
  63.  
  64.    /**
  65.     * start decoding of a new frame
  66.     */
  67.    void (*begin_frame)(struct pipe_video_codec *codec,
  68.                        struct pipe_video_buffer *target,
  69.                        struct pipe_picture_desc *picture);
  70.  
  71.    /**
  72.     * decode a macroblock
  73.     */
  74.    void (*decode_macroblock)(struct pipe_video_codec *codec,
  75.                              struct pipe_video_buffer *target,
  76.                              struct pipe_picture_desc *picture,
  77.                              const struct pipe_macroblock *macroblocks,
  78.                              unsigned num_macroblocks);
  79.  
  80.    /**
  81.     * decode a bitstream
  82.     */
  83.    void (*decode_bitstream)(struct pipe_video_codec *codec,
  84.                             struct pipe_video_buffer *target,
  85.                             struct pipe_picture_desc *picture,
  86.                             unsigned num_buffers,
  87.                             const void * const *buffers,
  88.                             const unsigned *sizes);
  89.  
  90.    /**
  91.     * encode to a bitstream
  92.     */
  93.    void (*encode_bitstream)(struct pipe_video_codec *codec,
  94.                             struct pipe_video_buffer *source,
  95.                             struct pipe_resource *destination,
  96.                             void **feedback);
  97.  
  98.    /**
  99.     * end decoding of the current frame
  100.     */
  101.    void (*end_frame)(struct pipe_video_codec *codec,
  102.                      struct pipe_video_buffer *target,
  103.                      struct pipe_picture_desc *picture);
  104.  
  105.    /**
  106.     * flush any outstanding command buffers to the hardware
  107.     * should be called before a video_buffer is acessed by the state tracker again
  108.     */
  109.    void (*flush)(struct pipe_video_codec *codec);
  110.  
  111.    /**
  112.     * get encoder feedback
  113.     */
  114.    void (*get_feedback)(struct pipe_video_codec *codec, void *feedback, unsigned *size);
  115. };
  116.  
  117. /**
  118.  * output for decoding / input for displaying
  119.  */
  120. struct pipe_video_buffer
  121. {
  122.    struct pipe_context *context;
  123.  
  124.    enum pipe_format buffer_format;
  125.    enum pipe_video_chroma_format chroma_format;
  126.    unsigned width;
  127.    unsigned height;
  128.    bool interlaced;
  129.  
  130.    /**
  131.     * destroy this video buffer
  132.     */
  133.    void (*destroy)(struct pipe_video_buffer *buffer);
  134.  
  135.    /**
  136.     * get a individual sampler view for each plane
  137.     */
  138.    struct pipe_sampler_view **(*get_sampler_view_planes)(struct pipe_video_buffer *buffer);
  139.  
  140.    /**
  141.     * get a individual sampler view for each component
  142.     */
  143.    struct pipe_sampler_view **(*get_sampler_view_components)(struct pipe_video_buffer *buffer);
  144.  
  145.    /**
  146.     * get a individual surfaces for each plane
  147.     */
  148.    struct pipe_surface **(*get_surfaces)(struct pipe_video_buffer *buffer);
  149.  
  150.    /*
  151.     * auxiliary associated data
  152.     */
  153.    void *associated_data;
  154.  
  155.    /*
  156.     * codec where the associated data came from
  157.     */
  158.    struct pipe_video_codec *codec;
  159.  
  160.    /*
  161.     * destroy the associated data
  162.     */
  163.    void (*destroy_associated_data)(void *associated_data);
  164. };
  165.  
  166. #ifdef __cplusplus
  167. }
  168. #endif
  169.  
  170. #endif /* PIPE_VIDEO_CONTEXT_H */
  171.