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.

73 lines
1.7KB

  1. /*
  2. * This file is part of Libav.
  3. *
  4. * Libav is free software; you can redistribute it and/or
  5. * modify it under the terms of the GNU Lesser General Public
  6. * License as published by the Free Software Foundation; either
  7. * version 2.1 of the License, or (at your option) any later version.
  8. *
  9. * Libav is distributed in the hope that it will be useful,
  10. * but WITHOUT ANY WARRANTY; without even the implied warranty of
  11. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
  12. * Lesser General Public License for more details.
  13. *
  14. * You should have received a copy of the GNU Lesser General Public
  15. * License along with Libav; if not, write to the Free Software
  16. * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
  17. */
  18. #include "config.h"
  19. #include "libavutil/mem.h"
  20. #include "vda.h"
  21. #include "vda_internal.h"
  22. #if CONFIG_H264_VDA_HWACCEL
  23. AVVDAContext *av_vda_alloc_context(void)
  24. {
  25. AVVDAContext *ret = av_mallocz(sizeof(*ret));
  26. if (ret)
  27. ret->output_callback = ff_vda_output_callback;
  28. return ret;
  29. }
  30. int av_vda_default_init(AVCodecContext *avctx)
  31. {
  32. avctx->hwaccel_context = av_vda_alloc_context();
  33. if (!avctx->hwaccel_context)
  34. return AVERROR(ENOMEM);
  35. return ff_vda_default_init(avctx);
  36. }
  37. void av_vda_default_free(AVCodecContext *avctx)
  38. {
  39. ff_vda_default_free(avctx);
  40. av_freep(&avctx->hwaccel_context);
  41. }
  42. void ff_vda_default_free(AVCodecContext *avctx)
  43. {
  44. AVVDAContext *vda = avctx->hwaccel_context;
  45. if (vda && vda->decoder)
  46. VDADecoderDestroy(vda->decoder);
  47. }
  48. #else
  49. AVVDAContext *av_vda_alloc_context(void)
  50. {
  51. return NULL;
  52. }
  53. int av_vda_default_init(AVCodecContext *avctx)
  54. {
  55. return AVERROR(ENOSYS);
  56. }
  57. void av_vda_default_free(AVCodecContext *ctx)
  58. {
  59. }
  60. #endif