accel_vaapi.h 4.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136
  1. /*
  2. * Copyright (C) 2008 the xine project
  3. *
  4. * This file is part of xine, a free video player.
  5. *
  6. * xine is free software; you can redistribute it and/or modify
  7. * it under the terms of the GNU General Public License as published by
  8. * the Free Software Foundation; either version 2 of the License, or
  9. * (at your option) any later version.
  10. *
  11. * xine is distributed in the hope that it will be useful,
  12. * but WITHOUT ANY WARRANTY; without even the implied warranty of
  13. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  14. * GNU General Public License for more details.
  15. *
  16. * You should have received a copy of the GNU General Public License
  17. * along with this program; if not, write to the Free Software
  18. * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110, USA
  19. *
  20. *
  21. * Common acceleration definitions for vdpau
  22. *
  23. *
  24. */
  25. #ifndef HAVE_XINE_ACCEL_VAAPI_H
  26. #define HAVE_XINE_ACCEL_VAAPI_H
  27. #ifdef __cplusplus
  28. extern "C" {
  29. #endif
  30. #ifdef HAVE_CONFIG_H
  31. #include "config.h"
  32. #endif
  33. #include <va/va_x11.h>
  34. #include <pthread.h>
  35. #ifdef HAVE_FFMPEG_AVUTIL_H
  36. # include <avcodec.h>
  37. #else
  38. # include <libavcodec/avcodec.h>
  39. #endif
  40. #if LIBAVCODEC_VERSION_MAJOR >= 53 || (LIBAVCODEC_VERSION_MAJOR == 52 && LIBAVCODEC_VERSION_MINOR >= 32)
  41. # define AVVIDEO 2
  42. #else
  43. # define AVVIDEO 1
  44. # define pp_context pp_context_t
  45. # define pp_mode pp_mode_t
  46. #endif
  47. #define NUM_OUTPUT_SURFACES 22
  48. #define SURFACE_FREE 0
  49. #define SURFACE_ALOC 1
  50. #define SURFACE_RELEASE 2
  51. #define SURFACE_RENDER 3
  52. #define SURFACE_RENDER_RELEASE 5
  53. struct vaapi_equalizer {
  54. VADisplayAttribute brightness;
  55. VADisplayAttribute contrast;
  56. VADisplayAttribute hue;
  57. VADisplayAttribute saturation;
  58. };
  59. typedef struct ff_vaapi_context_s ff_vaapi_context_t;
  60. struct ff_vaapi_context_s {
  61. VADisplay va_display;
  62. VAContextID va_context_id;
  63. VAConfigID va_config_id;
  64. int width;
  65. int height;
  66. int sw_width;
  67. int sw_height;
  68. int va_profile;
  69. unsigned int va_colorspace;
  70. VAImage va_subpic_image;
  71. VASubpictureID va_subpic_id;
  72. int va_subpic_width;
  73. int va_subpic_height;
  74. int is_bound;
  75. void *gl_surface;
  76. unsigned int soft_head;
  77. unsigned int valid_context;
  78. unsigned int va_head;
  79. unsigned int va_soft_head;
  80. vo_driver_t *driver;
  81. unsigned int last_sub_image_fmt;
  82. VASurfaceID last_sub_surface_id;
  83. struct vaapi_equalizer va_equalizer;
  84. VAImageFormat *va_image_formats;
  85. int va_num_image_formats;
  86. VAImageFormat *va_subpic_formats;
  87. int va_num_subpic_formats;
  88. };
  89. typedef struct ff_vaapi_surface_s ff_vaapi_surface_t;
  90. typedef struct vaapi_accel_s vaapi_accel_t;
  91. struct ff_vaapi_surface_s {
  92. unsigned int index;
  93. vaapi_accel_t *accel;
  94. VASurfaceID va_surface_id;
  95. unsigned int status;
  96. };
  97. struct vaapi_accel_s {
  98. unsigned int index;
  99. vo_frame_t *vo_frame;
  100. #if AVVIDEO > 1
  101. int (*avcodec_decode_video2)(vo_frame_t *frame_gen, AVCodecContext *avctx, AVFrame *picture,
  102. int *got_picture_ptr, AVPacket *avpkt);
  103. #else
  104. int (*avcodec_decode_video)(vo_frame_t *frame_gen, AVCodecContext *avctx, AVFrame *picture,
  105. int *got_picture_ptr, uint8_t *buf, int buf_size);
  106. #endif
  107. VAStatus (*vaapi_init)(vo_frame_t *frame_gen, int va_profile, int width, int height, int softrender);
  108. int (*profile_from_imgfmt)(vo_frame_t *frame_gen, enum PixelFormat pix_fmt, int codec_id, int vaapi_mpeg_sofdec);
  109. ff_vaapi_context_t *(*get_context)(vo_frame_t *frame_gen);
  110. int (*guarded_render)(vo_frame_t *frame_gen);
  111. ff_vaapi_surface_t *(*get_vaapi_surface)(vo_frame_t *frame_gen);
  112. void (*render_vaapi_surface)(vo_frame_t *frame_gen, ff_vaapi_surface_t *va_surface);
  113. void (*release_vaapi_surface)(vo_frame_t *frame_gen, ff_vaapi_surface_t *va_surface);
  114. };
  115. #ifdef __cplusplus
  116. }
  117. #endif
  118. #endif