FFmpeg
Loading...
Searching...
No Matches
qsvenc_vp9.c
Go to the documentation of this file.
1/*
2 * Intel MediaSDK QSV based VP9 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 QSVVP9EncContext *q = avctx->priv_data;
43 q->qsv.low_power = 1;
44
45 return ff_qsv_enc_init(avctx, &q->qsv);
46}
47
49 const AVFrame *frame, int *got_packet)
50{
51 QSVVP9EncContext *q = avctx->priv_data;
52
53 return ff_qsv_encode(avctx, &q->qsv, pkt, frame, got_packet);
54}
55
57{
58 QSVVP9EncContext *q = avctx->priv_data;
59
60 return ff_qsv_enc_close(avctx, &q->qsv);
61}
62
63#define OFFSET(x) offsetof(QSVVP9EncContext, x)
64#define VE AV_OPT_FLAG_VIDEO_PARAM | AV_OPT_FLAG_ENCODING_PARAM
65static const AVOption options[] = {
67
68 { "profile", NULL, OFFSET(qsv.profile), AV_OPT_TYPE_INT, { .i64 = MFX_PROFILE_UNKNOWN }, 0, INT_MAX, VE, .unit = "profile" },
69 { "unknown", NULL, 0, AV_OPT_TYPE_CONST, { .i64 = MFX_PROFILE_UNKNOWN}, INT_MIN, INT_MAX, VE, .unit = "profile" },
70 { "profile0", NULL, 0, AV_OPT_TYPE_CONST, { .i64 = MFX_PROFILE_VP9_0 }, INT_MIN, INT_MAX, VE, .unit = "profile" },
71 { "profile1", NULL, 0, AV_OPT_TYPE_CONST, { .i64 = MFX_PROFILE_VP9_1 }, INT_MIN, INT_MAX, VE, .unit = "profile" },
72 { "profile2", NULL, 0, AV_OPT_TYPE_CONST, { .i64 = MFX_PROFILE_VP9_2 }, INT_MIN, INT_MAX, VE, .unit = "profile" },
73 { "profile3", NULL, 0, AV_OPT_TYPE_CONST, { .i64 = MFX_PROFILE_VP9_3 }, INT_MIN, INT_MAX, VE, .unit = "profile" },
74
75#if QSV_HAVE_EXT_VP9_TILES
76 /* The minimum tile width in luma pixels is 256, set maximum tile_cols to 32 for 8K video */
77 { "tile_cols", "Number of columns for tiled encoding", OFFSET(qsv.tile_cols), AV_OPT_TYPE_INT, { .i64 = 0 }, 0, 32, VE },
78 /* Set maximum tile_rows to 4 per VP9 spec */
79 { "tile_rows", "Number of rows for tiled encoding", OFFSET(qsv.tile_rows), AV_OPT_TYPE_INT, { .i64 = 0 }, 0, 4, VE },
80#else
81 { "tile_cols", "(not supported)", OFFSET(qsv.tile_cols), AV_OPT_TYPE_INT, { .i64 = 0 }, 0, 0, VE },
82 { "tile_rows", "(not supported)", OFFSET(qsv.tile_rows), AV_OPT_TYPE_INT, { .i64 = 0 }, 0, 0, VE },
83#endif
84
85 { NULL },
86};
87
88static const AVClass class = {
89 .class_name = "vp9_qsv encoder",
91 .option = options,
93};
94
96 { "b", "0" },
97 { "refs", "0" },
98 { "g", "250" },
99 { "trellis", "-1" },
100 { "flags", "+cgop" },
101 { NULL },
102};
103
105 .p.name = "vp9_qsv",
106 CODEC_LONG_NAME("VP9 video (Intel Quick Sync Video acceleration)"),
107 .priv_data_size = sizeof(QSVVP9EncContext),
108 .p.type = AVMEDIA_TYPE_VIDEO,
109 .p.id = AV_CODEC_ID_VP9,
110 .init = qsv_enc_init,
112 .close = qsv_enc_close,
113 .p.capabilities = AV_CODEC_CAP_DELAY | AV_CODEC_CAP_HYBRID,
116 .color_ranges = AVCOL_RANGE_MPEG | AVCOL_RANGE_JPEG,
117 .p.priv_class = &class,
118 .defaults = qsv_enc_defaults,
119 .caps_internal = FF_CODEC_CAP_NOT_INIT_THREADSAFE |
121 .p.wrapper_name = "qsv",
122 .hw_configs = ff_qsv_enc_hw_configs,
123};
const FFCodec ff_vp9_qsv_encoder
Definition qsvenc_vp9.c:104
#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)
#define FF_CODEC_CAP_INIT_CLEANUP
The codec allows calling the close function for deallocation even if the init function returned a fai...
common internal and external API header
#define NULL
Definition coverity.c:32
static AVPacket * pkt
static AVFrame * frame
@ AV_OPT_TYPE_CONST
Special option type for declaring named constants.
Definition opt.h:298
@ 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_VP9
Definition codec_id.h:217
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
#define AV_PIX_FMT_P010
Definition pixfmt.h:608
#define AV_PIX_FMT_XV30
Definition pixfmt.h:615
@ 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_VUYX
packed VUYX 4:4:4:4, 32bpp, Variant of VUYA where alpha channel is left undefined
Definition pixfmt.h:406
@ AV_PIX_FMT_QSV
HW acceleration through QSV, data[3] contains a pointer to the mfxFrameSurface1 structure.
Definition pixfmt.h:247
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
#define QSV_COMMON_OPTS
Definition qsvenc.h:54
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_vp9.c:48
static av_cold int qsv_enc_init(AVCodecContext *avctx)
Definition qsvenc_vp9.c:40
static av_cold int qsv_enc_close(AVCodecContext *avctx)
Definition qsvenc_vp9.c:56
#define OFFSET(x)
Definition qsvenc_vp9.c:63
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
int low_power
Definition qsvenc.h:256
QSVEncContext qsv
Definition qsvenc_vp9.c:37