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.

91 lines
2.7KB

  1. /*
  2. * Video Decode and Presentation API for UNIX (VDPAU) is used for
  3. * HW decode acceleration for MPEG-1/2, MPEG-4 ASP, H.264 and VC-1.
  4. *
  5. * Copyright (c) 2008 NVIDIA
  6. *
  7. * This file is part of Libav.
  8. *
  9. * Libav 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. * Libav 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 Libav; if not, write to the Free Software
  21. * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
  22. */
  23. #include <limits.h>
  24. #include "avcodec.h"
  25. #include "h264.h"
  26. #include "vc1.h"
  27. #undef NDEBUG
  28. #include <assert.h>
  29. #include "vdpau.h"
  30. #include "vdpau_internal.h"
  31. /**
  32. * @addtogroup VDPAU_Decoding
  33. *
  34. * @{
  35. */
  36. int ff_vdpau_common_start_frame(AVCodecContext *avctx,
  37. av_unused const uint8_t *buffer,
  38. av_unused uint32_t size)
  39. {
  40. AVVDPAUContext *hwctx = avctx->hwaccel_context;
  41. hwctx->bitstream_buffers_used = 0;
  42. return 0;
  43. }
  44. #if CONFIG_H263_VDPAU_HWACCEL || CONFIG_MPEG1_VDPAU_HWACCEL || \
  45. CONFIG_MPEG2_VDPAU_HWACCEL || CONFIG_MPEG4_VDPAU_HWACCEL || \
  46. CONFIG_VC1_VDPAU_HWACCEL || CONFIG_WMV3_VDPAU_HWACCEL
  47. int ff_vdpau_mpeg_end_frame(AVCodecContext *avctx)
  48. {
  49. AVVDPAUContext *hwctx = avctx->hwaccel_context;
  50. MpegEncContext *s = avctx->priv_data;
  51. VdpVideoSurface surf = ff_vdpau_get_surface_id(s->current_picture_ptr);
  52. hwctx->render(hwctx->decoder, surf, (void *)&hwctx->info,
  53. hwctx->bitstream_buffers_used, hwctx->bitstream_buffers);
  54. ff_mpeg_draw_horiz_band(s, 0, s->avctx->height);
  55. hwctx->bitstream_buffers_used = 0;
  56. return 0;
  57. }
  58. #endif
  59. int ff_vdpau_add_buffer(AVCodecContext *avctx,
  60. const uint8_t *buf, uint32_t size)
  61. {
  62. AVVDPAUContext *hwctx = avctx->hwaccel_context;
  63. VdpBitstreamBuffer *buffers = hwctx->bitstream_buffers;
  64. buffers = av_fast_realloc(buffers, &hwctx->bitstream_buffers_allocated,
  65. (hwctx->bitstream_buffers_used + 1) * sizeof(*buffers));
  66. if (!buffers)
  67. return AVERROR(ENOMEM);
  68. hwctx->bitstream_buffers = buffers;
  69. buffers += hwctx->bitstream_buffers_used++;
  70. buffers->struct_version = VDP_BITSTREAM_BUFFER_VERSION;
  71. buffers->bitstream = buf;
  72. buffers->bitstream_bytes = size;
  73. return 0;
  74. }
  75. /* @}*/