FFmpeg
Loading...
Searching...
No Matches
qsvenc_jpeg.c
Go to the documentation of this file.
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
21
22#include <stdint.h>
23#include <sys/types.h>
24
25#include <mfxvideo.h>
26
27#include "libavutil/common.h"
28#include "libavutil/opt.h"
29
30#include "avcodec.h"
31#include "codec_internal.h"
32#include "qsv.h"
33#include "qsvenc.h"
34
39
41{
42 QSVMJPEGEncContext *q = avctx->priv_data;
43
44 return ff_qsv_enc_init(avctx, &q->qsv);
45}
46
48 const AVFrame *frame, int *got_packet)
49{
50 QSVMJPEGEncContext *q = avctx->priv_data;
51
52 return ff_qsv_encode(avctx, &q->qsv, pkt, frame, got_packet);
53}
54
56{
57 QSVMJPEGEncContext *q = avctx->priv_data;
58
59 return ff_qsv_enc_close(avctx, &q->qsv);
60}
61
62#define OFFSET(x) offsetof(QSVMJPEGEncContext, x)
63#define VE AV_OPT_FLAG_VIDEO_PARAM | AV_OPT_FLAG_ENCODING_PARAM
64static const AVOption options[] = {
65 { "async_depth", "Maximum processing parallelism", OFFSET(qsv.async_depth), AV_OPT_TYPE_INT, { .i64 = ASYNC_DEPTH_DEFAULT }, 1, INT_MAX, VE },
66 { NULL },
67};
68
69static const AVClass class = {
70 .class_name = "mjpeg_qsv encoder",
72 .option = options,
74};
75
77 { "global_quality", "80" },
78 { NULL },
79};
80
82 .p.name = "mjpeg_qsv",
83 CODEC_LONG_NAME("MJPEG (Intel Quick Sync Video acceleration)"),
84 .priv_data_size = sizeof(QSVMJPEGEncContext),
85 .p.type = AVMEDIA_TYPE_VIDEO,
86 .p.id = AV_CODEC_ID_MJPEG,
87 .init = qsv_enc_init,
89 .close = qsv_enc_close,
90 .p.capabilities = AV_CODEC_CAP_DELAY | AV_CODEC_CAP_HYBRID,
93 .color_ranges = AVCOL_RANGE_MPEG | AVCOL_RANGE_JPEG,
94 .p.priv_class = &class,
95 .defaults = qsv_enc_defaults,
96 .p.wrapper_name = "qsv",
97 .hw_configs = ff_qsv_enc_hw_configs,
98 .caps_internal = FF_CODEC_CAP_NOT_INIT_THREADSAFE,
99};
const FFCodec ff_mjpeg_qsv_encoder
Definition qsvenc_jpeg.c:81
#define VE
Definition amfenc_av1.c:30
Libavcodec external API header.
#define CODEC_PIXFMTS(...)
#define FF_CODEC_CAP_NOT_INIT_THREADSAFE
The codec is not known to be init-threadsafe (i.e.
#define FF_CODEC_ENCODE_CB(func)
#define CODEC_LONG_NAME(str)
common internal and external API header
#define NULL
Definition coverity.c:32
static AVPacket * pkt
static AVFrame * frame
@ AV_OPT_TYPE_INT
Underlying C type is int.
Definition opt.h:258
#define AV_CODEC_CAP_DELAY
Encoder or decoder requires flushing with NULL input at the end in order to give the complete and cor...
Definition codec.h:79
#define AV_CODEC_CAP_HYBRID
Codec is potentially backed by a hardware implementation, but not necessarily.
Definition codec.h:140
@ AV_CODEC_ID_MJPEG
Definition codec_id.h:57
const char * av_default_item_name(void *ptr)
Return the context name.
Definition log.c:241
@ AVMEDIA_TYPE_VIDEO
Definition avutil.h:200
#define LIBAVUTIL_VERSION_INT
Definition version.h:85
#define av_cold
Definition attributes.h:117
AVOptions.
@ AVCOL_RANGE_MPEG
Narrow or limited range content.
Definition pixfmt.h:766
@ AVCOL_RANGE_JPEG
Full range content.
Definition pixfmt.h:783
@ AV_PIX_FMT_NV12
planar YUV 4:2:0, 12bpp, 1 plane for Y and 1 plane for the UV components, which are interleaved (firs...
Definition pixfmt.h:96
@ AV_PIX_FMT_BGRA
packed BGRA 8:8:8:8, 32bpp, BGRABGRA...
Definition pixfmt.h:102
@ AV_PIX_FMT_YUYV422
packed YUV 4:2:2, 16bpp, Y0 Cb Y1 Cr
Definition pixfmt.h:74
@ AV_PIX_FMT_QSV
HW acceleration through QSV, data[3] contains a pointer to the mfxFrameSurface1 structure.
Definition pixfmt.h:247
#define ASYNC_DEPTH_DEFAULT
int ff_qsv_enc_close(AVCodecContext *avctx, QSVEncContext *q)
Definition qsvenc.c:2710
int ff_qsv_enc_init(AVCodecContext *avctx, QSVEncContext *q)
Definition qsvenc.c:1637
int ff_qsv_encode(AVCodecContext *avctx, QSVEncContext *q, AVPacket *pkt, const AVFrame *frame, int *got_packet)
Definition qsvenc.c:2642
const AVCodecHWConfigInternal *const ff_qsv_enc_hw_configs[]
Definition qsvenc.c:2762
static int qsv_enc_frame(AVCodecContext *avctx, AVPacket *pkt, const AVFrame *frame, int *got_packet)
Definition qsvenc_av1.c:138
static const FFCodecDefault qsv_enc_defaults[]
Definition qsvenc_av1.c:202
static av_cold int qsv_enc_init(AVCodecContext *avctx)
Definition qsvenc_av1.c:111
static av_cold int qsv_enc_close(AVCodecContext *avctx)
Definition qsvenc_av1.c:167
static int qsv_enc_frame(AVCodecContext *avctx, AVPacket *pkt, const AVFrame *frame, int *got_packet)
Definition qsvenc_jpeg.c:47
static av_cold int qsv_enc_init(AVCodecContext *avctx)
Definition qsvenc_jpeg.c:40
static av_cold int qsv_enc_close(AVCodecContext *avctx)
Definition qsvenc_jpeg.c:55
#define OFFSET(x)
Definition qsvenc_jpeg.c:62
Describe the class of an AVClass context structure.
Definition log.h:76
const char * class_name
The name of the class; usually it is the same name as the context structure type to which the AVClass...
Definition log.h:81
main external API structure.
Definition avcodec.h:443
void * priv_data
Definition avcodec.h:470
This structure describes decoded (raw) audio or video data.
Definition frame.h:472
AVOption.
Definition opt.h:428
This structure stores compressed data.
Definition packet.h:580
QSVEncContext qsv
Definition qsvenc_jpeg.c:37