You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

129 lines
4.3KB

  1. /*
  2. * VC-1 decode acceleration through VDPAU
  3. *
  4. * Copyright (c) 2008 NVIDIA
  5. * Copyright (c) 2013 Rémi Denis-Courmont
  6. *
  7. * This file is part of FFmpeg.
  8. *
  9. * FFmpeg is free software; you can redistribute it and/or
  10. * modify it under the terms of the GNU Lesser General Public
  11. * License as published by the Free Software Foundation; either
  12. * version 2.1 of the License, or (at your option) any later version.
  13. *
  14. * FFmpeg is distributed in the hope that it will be useful,
  15. * but WITHOUT ANY WARRANTY; without even the implied warranty of
  16. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
  17. * Lesser General Public License for more details.
  18. *
  19. * You should have received a copy of the GNU Lesser General Public
  20. * License along with FFmpeg; if not, write to the Free Software Foundation,
  21. * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
  22. */
  23. #include <vdpau/vdpau.h>
  24. #include "avcodec.h"
  25. #include "vc1.h"
  26. #include "vdpau.h"
  27. #include "vdpau_internal.h"
  28. static int vdpau_vc1_start_frame(AVCodecContext *avctx,
  29. const uint8_t *buffer, uint32_t size)
  30. {
  31. VC1Context * const v = avctx->priv_data;
  32. AVVDPAUContext *hwctx = avctx->hwaccel_context;
  33. MpegEncContext * const s = &v->s;
  34. VdpPictureInfoVC1 *info = &hwctx->info.vc1;
  35. VdpVideoSurface ref;
  36. /* fill LvPictureInfoVC1 struct */
  37. info->forward_reference = VDP_INVALID_HANDLE;
  38. info->backward_reference = VDP_INVALID_HANDLE;
  39. switch (s->pict_type) {
  40. case AV_PICTURE_TYPE_B:
  41. ref = ff_vdpau_get_surface_id(&s->next_picture);
  42. assert(ref != VDP_INVALID_HANDLE);
  43. info->backward_reference = ref;
  44. /* fall-through */
  45. case AV_PICTURE_TYPE_P:
  46. ref = ff_vdpau_get_surface_id(&s->last_picture);
  47. assert(ref != VDP_INVALID_HANDLE);
  48. info->forward_reference = ref;
  49. }
  50. info->slice_count = 0;
  51. if (v->bi_type)
  52. info->picture_type = 4;
  53. else
  54. info->picture_type = s->pict_type - 1 + s->pict_type / 3;
  55. info->frame_coding_mode = v->fcm;
  56. info->postprocflag = v->postprocflag;
  57. info->pulldown = v->broadcast;
  58. info->interlace = v->interlace;
  59. info->tfcntrflag = v->tfcntrflag;
  60. info->finterpflag = v->finterpflag;
  61. info->psf = v->psf;
  62. info->dquant = v->dquant;
  63. info->panscan_flag = v->panscanflag;
  64. info->refdist_flag = v->refdist_flag;
  65. info->quantizer = v->quantizer_mode;
  66. info->extended_mv = v->extended_mv;
  67. info->extended_dmv = v->extended_dmv;
  68. info->overlap = v->overlap;
  69. info->vstransform = v->vstransform;
  70. info->loopfilter = v->s.loop_filter;
  71. info->fastuvmc = v->fastuvmc;
  72. info->range_mapy_flag = v->range_mapy_flag;
  73. info->range_mapy = v->range_mapy;
  74. info->range_mapuv_flag = v->range_mapuv_flag;
  75. info->range_mapuv = v->range_mapuv;
  76. /* Specific to simple/main profile only */
  77. info->multires = v->multires;
  78. info->syncmarker = v->s.resync_marker;
  79. info->rangered = v->rangered | (v->rangeredfrm << 1);
  80. info->maxbframes = v->s.max_b_frames;
  81. info->deblockEnable = v->postprocflag & 1;
  82. info->pquant = v->pq;
  83. return ff_vdpau_common_start_frame(avctx, buffer, size);
  84. }
  85. static int vdpau_vc1_decode_slice(AVCodecContext *avctx,
  86. const uint8_t *buffer, uint32_t size)
  87. {
  88. AVVDPAUContext *hwctx = avctx->hwaccel_context;
  89. int val;
  90. val = ff_vdpau_add_buffer(avctx, buffer, size);
  91. if (val < 0)
  92. return val;
  93. hwctx->info.vc1.slice_count++;
  94. return 0;
  95. }
  96. #if CONFIG_WMV3_VDPAU_HWACCEL
  97. AVHWAccel ff_wmv3_vdpau_hwaccel = {
  98. .name = "wm3_vdpau",
  99. .type = AVMEDIA_TYPE_VIDEO,
  100. .id = AV_CODEC_ID_WMV3,
  101. .pix_fmt = AV_PIX_FMT_VDPAU,
  102. .start_frame = vdpau_vc1_start_frame,
  103. .end_frame = ff_vdpau_common_end_frame,
  104. .decode_slice = vdpau_vc1_decode_slice,
  105. };
  106. #endif
  107. AVHWAccel ff_vc1_vdpau_hwaccel = {
  108. .name = "vc1_vdpau",
  109. .type = AVMEDIA_TYPE_VIDEO,
  110. .id = AV_CODEC_ID_VC1,
  111. .pix_fmt = AV_PIX_FMT_VDPAU,
  112. .start_frame = vdpau_vc1_start_frame,
  113. .end_frame = ff_vdpau_common_end_frame,
  114. .decode_slice = vdpau_vc1_decode_slice,
  115. };