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.

96 lines
2.8KB

  1. /*
  2. * Intel MediaSDK QSV based MPEG2 video decoder
  3. *
  4. * This file is part of FFmpeg.
  5. *
  6. * FFmpeg is free software; you can redistribute it and/or
  7. * modify it under the terms of the GNU Lesser General Public
  8. * License as published by the Free Software Foundation; either
  9. * version 2.1 of the License, or (at your option) any later version.
  10. *
  11. * FFmpeg 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 GNU
  14. * Lesser General Public License for more details.
  15. *
  16. * You should have received a copy of the GNU Lesser General Public
  17. * License along with FFmpeg; if not, write to the Free Software
  18. * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
  19. */
  20. #include <stdint.h>
  21. #include <string.h>
  22. #include "libavutil/common.h"
  23. #include "libavutil/opt.h"
  24. #include "avcodec.h"
  25. #include "qsvdec.h"
  26. typedef struct QSVMPVContext {
  27. AVClass *class;
  28. QSVContext qsv;
  29. } QSVMPVContext;
  30. static av_cold int qsv_decode_close(AVCodecContext *avctx)
  31. {
  32. QSVMPVContext *s = avctx->priv_data;
  33. ff_qsv_decode_close(&s->qsv);
  34. return 0;
  35. }
  36. static av_cold int qsv_decode_init(AVCodecContext *avctx)
  37. {
  38. return 0;
  39. }
  40. static int qsv_decode_frame(AVCodecContext *avctx, void *data,
  41. int *got_frame, AVPacket *avpkt)
  42. {
  43. QSVMPVContext *s = avctx->priv_data;
  44. AVFrame *frame = data;
  45. return ff_qsv_decode(avctx, &s->qsv, frame, got_frame, avpkt);
  46. }
  47. static void qsv_decode_flush(AVCodecContext *avctx)
  48. {
  49. }
  50. AVHWAccel ff_mpeg2_qsv_hwaccel = {
  51. .name = "mpeg2_qsv",
  52. .type = AVMEDIA_TYPE_VIDEO,
  53. .id = AV_CODEC_ID_MPEG2VIDEO,
  54. .pix_fmt = AV_PIX_FMT_QSV,
  55. };
  56. #define OFFSET(x) offsetof(QSVMPVContext, x)
  57. #define VD AV_OPT_FLAG_VIDEO_PARAM | AV_OPT_FLAG_DECODING_PARAM
  58. static const AVOption options[] = {
  59. { "async_depth", "Internal parallelization depth, the higher the value the higher the latency.", OFFSET(qsv.async_depth), AV_OPT_TYPE_INT, { .i64 = ASYNC_DEPTH_DEFAULT }, 0, INT_MAX, VD },
  60. { NULL },
  61. };
  62. static const AVClass class = {
  63. .class_name = "mpeg2_qsv",
  64. .item_name = av_default_item_name,
  65. .option = options,
  66. .version = LIBAVUTIL_VERSION_INT,
  67. };
  68. AVCodec ff_mpeg2_qsv_decoder = {
  69. .name = "mpeg2_qsv",
  70. .long_name = NULL_IF_CONFIG_SMALL("MPEG-2 video (Intel Quick Sync Video acceleration)"),
  71. .priv_data_size = sizeof(QSVMPVContext),
  72. .type = AVMEDIA_TYPE_VIDEO,
  73. .id = AV_CODEC_ID_MPEG2VIDEO,
  74. .init = qsv_decode_init,
  75. .decode = qsv_decode_frame,
  76. .flush = qsv_decode_flush,
  77. .close = qsv_decode_close,
  78. .capabilities = CODEC_CAP_DELAY,
  79. .priv_class = &class,
  80. };