2 * Intel MediaSDK QSV based MJPEG encoder
4 * This file is part of FFmpeg.
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.
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.
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
23 #include <sys/types.h>
25 #include <mfx/mfxvideo.h>
27 #include "libavutil/common.h"
28 #include "libavutil/opt.h"
34 #include "qsv_internal.h"
37 typedef struct QSVMJPEGEncContext {
42 static av_cold int qsv_enc_init(AVCodecContext *avctx)
44 QSVMJPEGEncContext *q = avctx->priv_data;
46 return ff_qsv_enc_init(avctx, &q->qsv);
49 static int qsv_enc_frame(AVCodecContext *avctx, AVPacket *pkt,
50 const AVFrame *frame, int *got_packet)
52 QSVMJPEGEncContext *q = avctx->priv_data;
54 return ff_qsv_encode(avctx, &q->qsv, pkt, frame, got_packet);
57 static av_cold int qsv_enc_close(AVCodecContext *avctx)
59 QSVMJPEGEncContext *q = avctx->priv_data;
61 return ff_qsv_enc_close(avctx, &q->qsv);
64 #define OFFSET(x) offsetof(QSVMJPEGEncContext, x)
65 #define VE AV_OPT_FLAG_VIDEO_PARAM | AV_OPT_FLAG_ENCODING_PARAM
66 static const AVOption options[] = {
70 static const AVClass class = {
71 .class_name = "mjpeg_qsv encoder",
72 .item_name = av_default_item_name,
74 .version = LIBAVUTIL_VERSION_INT,
77 AVCodec ff_mjpeg_qsv_encoder = {
79 .long_name = NULL_IF_CONFIG_SMALL("MJPEG (Intel Quick Sync Video acceleration)"),
80 .priv_data_size = sizeof(QSVMJPEGEncContext),
81 .type = AVMEDIA_TYPE_VIDEO,
82 .id = AV_CODEC_ID_MJPEG,
84 .encode2 = qsv_enc_frame,
85 .close = qsv_enc_close,
86 .capabilities = AV_CODEC_CAP_DELAY,
87 .pix_fmts = (const enum AVPixelFormat[]){ AV_PIX_FMT_NV12,