FFmpeg
 All Data Structures Namespaces Files Functions Variables Typedefs Enumerations Enumerator Macros Groups Pages
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 <mfx/mfxvideo.h>
26 
27 #include "libavutil/common.h"
28 #include "libavutil/opt.h"
29 
30 #include "avcodec.h"
31 #include "internal.h"
32 #include "h264.h"
33 #include "qsv.h"
34 #include "qsv_internal.h"
35 #include "qsvenc.h"
36 
37 typedef struct QSVMJPEGEncContext {
38  AVClass *class;
41 
43 {
44  QSVMJPEGEncContext *q = avctx->priv_data;
45 
46  return ff_qsv_enc_init(avctx, &q->qsv);
47 }
48 
50  const AVFrame *frame, int *got_packet)
51 {
52  QSVMJPEGEncContext *q = avctx->priv_data;
53 
54  return ff_qsv_encode(avctx, &q->qsv, pkt, frame, got_packet);
55 }
56 
58 {
59  QSVMJPEGEncContext *q = avctx->priv_data;
60 
61  return ff_qsv_enc_close(avctx, &q->qsv);
62 }
63 
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[] = {
67  { "async_depth", "Maximum processing parallelism", OFFSET(qsv.async_depth), AV_OPT_TYPE_INT, { .i64 = ASYNC_DEPTH_DEFAULT }, 1, INT_MAX, VE },
68  { NULL },
69 };
70 
71 static const AVClass class = {
72  .class_name = "mjpeg_qsv encoder",
73  .item_name = av_default_item_name,
74  .option = options,
76 };
77 
78 static const AVCodecDefault qsv_enc_defaults[] = {
79  { "global_quality", "80" },
80  { NULL },
81 };
82 
84  .name = "mjpeg_qsv",
85  .long_name = NULL_IF_CONFIG_SMALL("MJPEG (Intel Quick Sync Video acceleration)"),
86  .priv_data_size = sizeof(QSVMJPEGEncContext),
88  .id = AV_CODEC_ID_MJPEG,
89  .init = qsv_enc_init,
90  .encode2 = qsv_enc_frame,
91  .close = qsv_enc_close,
92  .capabilities = AV_CODEC_CAP_DELAY | AV_CODEC_CAP_HYBRID,
93  .pix_fmts = (const enum AVPixelFormat[]){ AV_PIX_FMT_NV12,
96  .priv_class = &class,
97  .defaults = qsv_enc_defaults,
98  .wrapper_name = "qsv",
99 };
#define NULL
Definition: coverity.c:32
This structure describes decoded (raw) audio or video data.
Definition: frame.h:226
AVOption.
Definition: opt.h:246
#define LIBAVUTIL_VERSION_INT
Definition: version.h:85
static av_cold int init(AVCodecContext *avctx)
Definition: avrndec.c:35
const char * av_default_item_name(void *ptr)
Return the context name.
Definition: log.c:191
QSVEncContext qsv
Definition: qsvenc_jpeg.c:39
static AVPacket pkt
AVCodec.
Definition: avcodec.h:3424
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:72
#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: avcodec.h:993
int ff_qsv_encode(AVCodecContext *avctx, QSVEncContext *q, AVPacket *pkt, const AVFrame *frame, int *got_packet)
Definition: qsvenc.c:1291
#define av_cold
Definition: attributes.h:82
AVOptions.
static AVFrame * frame
#define VE
Definition: qsvenc_jpeg.c:65
static av_cold int qsv_enc_init(AVCodecContext *avctx)
Definition: qsvenc_jpeg.c:42
int ff_qsv_enc_close(AVCodecContext *avctx, QSVEncContext *q)
Definition: qsvenc.c:1377
H.264 common definitions.
#define OFFSET(x)
Definition: qsvenc_jpeg.c:64
AVCodec ff_mjpeg_qsv_encoder
Definition: qsvenc_jpeg.c:83
static const AVCodecDefault qsv_enc_defaults[]
Definition: qsvenc_jpeg.c:78
#define NULL_IF_CONFIG_SMALL(x)
Return NULL if CONFIG_SMALL is true, otherwise the argument without modification. ...
Definition: internal.h:186
planar YUV 4:2:0, 12bpp, 1 plane for Y and 1 plane for the UV components, which are interleaved (firs...
Definition: pixfmt.h:89
const char * name
Name of the codec implementation.
Definition: avcodec.h:3431
static av_cold int qsv_enc_close(AVCodecContext *avctx)
Definition: qsvenc_jpeg.c:57
#define ASYNC_DEPTH_DEFAULT
Definition: qsv_internal.h:33
Libavcodec external API header.
main external API structure.
Definition: avcodec.h:1533
GLint GLenum type
Definition: opengl_enc.c:105
#define AV_CODEC_CAP_HYBRID
Codec is potentially backed by a hardware implementation, but not necessarily.
Definition: avcodec.h:1072
Describe the class of an AVClass context structure.
Definition: log.h:67
int ff_qsv_enc_init(AVCodecContext *avctx, QSVEncContext *q)
Definition: qsvenc.c:886
HW acceleration through QSV, data[3] contains a pointer to the mfxFrameSurface1 structure.
Definition: pixfmt.h:222
static enum AVPixelFormat pix_fmts[]
Definition: libkvazaar.c:266
static const AVOption options[]
Definition: qsvenc_jpeg.c:66
common internal api header.
common internal and external API header
static int qsv_enc_frame(AVCodecContext *avctx, AVPacket *pkt, const AVFrame *frame, int *got_packet)
Definition: qsvenc_jpeg.c:49
void * priv_data
Definition: avcodec.h:1560
AVPixelFormat
Pixel format.
Definition: pixfmt.h:64
This structure stores compressed data.
Definition: avcodec.h:1422