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.

93 lines
2.7KB

  1. /*
  2. * Intel MediaSDK QSV based MJPEG encoder
  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 <sys/types.h>
  22. #include <mfx/mfxvideo.h>
  23. #include "libavutil/common.h"
  24. #include "libavutil/opt.h"
  25. #include "avcodec.h"
  26. #include "internal.h"
  27. #include "h264.h"
  28. #include "qsv.h"
  29. #include "qsv_internal.h"
  30. #include "qsvenc.h"
  31. typedef struct QSVMJPEGEncContext {
  32. AVClass *class;
  33. QSVEncContext qsv;
  34. } QSVMJPEGEncContext;
  35. static av_cold int qsv_enc_init(AVCodecContext *avctx)
  36. {
  37. QSVMJPEGEncContext *q = avctx->priv_data;
  38. return ff_qsv_enc_init(avctx, &q->qsv);
  39. }
  40. static int qsv_enc_frame(AVCodecContext *avctx, AVPacket *pkt,
  41. const AVFrame *frame, int *got_packet)
  42. {
  43. QSVMJPEGEncContext *q = avctx->priv_data;
  44. return ff_qsv_encode(avctx, &q->qsv, pkt, frame, got_packet);
  45. }
  46. static av_cold int qsv_enc_close(AVCodecContext *avctx)
  47. {
  48. QSVMJPEGEncContext *q = avctx->priv_data;
  49. return ff_qsv_enc_close(avctx, &q->qsv);
  50. }
  51. #define OFFSET(x) offsetof(QSVMJPEGEncContext, x)
  52. #define VE AV_OPT_FLAG_VIDEO_PARAM | AV_OPT_FLAG_ENCODING_PARAM
  53. static const AVOption options[] = {
  54. { NULL },
  55. };
  56. static const AVClass class = {
  57. .class_name = "mjpeg_qsv encoder",
  58. .item_name = av_default_item_name,
  59. .option = options,
  60. .version = LIBAVUTIL_VERSION_INT,
  61. };
  62. AVCodec ff_mjpeg_qsv_encoder = {
  63. .name = "mjpeg_qsv",
  64. .long_name = NULL_IF_CONFIG_SMALL("MJPEG (Intel Quick Sync Video acceleration)"),
  65. .priv_data_size = sizeof(QSVMJPEGEncContext),
  66. .type = AVMEDIA_TYPE_VIDEO,
  67. .id = AV_CODEC_ID_MJPEG,
  68. .init = qsv_enc_init,
  69. .encode2 = qsv_enc_frame,
  70. .close = qsv_enc_close,
  71. .capabilities = AV_CODEC_CAP_DELAY | AV_CODEC_CAP_HYBRID,
  72. .pix_fmts = (const enum AVPixelFormat[]){ AV_PIX_FMT_NV12,
  73. AV_PIX_FMT_QSV,
  74. AV_PIX_FMT_NONE },
  75. .priv_class = &class,
  76. .wrapper_name = "qsv",
  77. };