aarch64: Add assembly support for -fsanitize=hwaddress tagged globals.
[libav.git] / libavcodec / qsvenc_mpeg2.c
blob9986d8b1e4fd411c8d01bac7849f43fd4ab59728
1 /*
2 * Intel MediaSDK QSV based MPEG-2 encoder
4 * This file is part of Libav.
6 * Libav 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 * Libav 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 Libav; if not, write to the Free Software
18 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
22 #include <stdint.h>
23 #include <sys/types.h>
25 #include <mfx/mfxvideo.h>
27 #include "libavutil/common.h"
28 #include "libavutil/opt.h"
30 #include "avcodec.h"
31 #include "internal.h"
32 #include "qsv.h"
33 #include "qsv_internal.h"
34 #include "qsvenc.h"
36 typedef struct QSVMpeg2EncContext {
37 AVClass *class;
38 QSVEncContext qsv;
39 } QSVMpeg2EncContext;
41 static av_cold int qsv_enc_init(AVCodecContext *avctx)
43 QSVMpeg2EncContext *q = avctx->priv_data;
45 return ff_qsv_enc_init(avctx, &q->qsv);
48 static int qsv_enc_frame(AVCodecContext *avctx, AVPacket *pkt,
49 const AVFrame *frame, int *got_packet)
51 QSVMpeg2EncContext *q = avctx->priv_data;
53 return ff_qsv_encode(avctx, &q->qsv, pkt, frame, got_packet);
56 static av_cold int qsv_enc_close(AVCodecContext *avctx)
58 QSVMpeg2EncContext *q = avctx->priv_data;
60 return ff_qsv_enc_close(avctx, &q->qsv);
63 #define OFFSET(x) offsetof(QSVMpeg2EncContext, x)
64 #define VE AV_OPT_FLAG_VIDEO_PARAM | AV_OPT_FLAG_ENCODING_PARAM
65 static const AVOption options[] = {
66 QSV_COMMON_OPTS
68 { "profile", NULL, OFFSET(qsv.profile), AV_OPT_TYPE_INT, { .i64 = MFX_PROFILE_UNKNOWN }, 0, INT_MAX, VE, "profile" },
69 { "unknown", NULL, 0, AV_OPT_TYPE_CONST, { .i64 = MFX_PROFILE_UNKNOWN }, INT_MIN, INT_MAX, VE, "profile" },
70 { "simple", NULL, 0, AV_OPT_TYPE_CONST, { .i64 = MFX_PROFILE_MPEG2_SIMPLE }, INT_MIN, INT_MAX, VE, "profile" },
71 { "main", NULL, 0, AV_OPT_TYPE_CONST, { .i64 = MFX_PROFILE_MPEG2_MAIN }, INT_MIN, INT_MAX, VE, "profile" },
72 { "high", NULL, 0, AV_OPT_TYPE_CONST, { .i64 = MFX_PROFILE_MPEG2_HIGH }, INT_MIN, INT_MAX, VE, "profile" },
74 { NULL },
77 static const AVClass class = {
78 .class_name = "mpeg2_qsv encoder",
79 .item_name = av_default_item_name,
80 .option = options,
81 .version = LIBAVUTIL_VERSION_INT,
84 static const AVCodecDefault qsv_enc_defaults[] = {
85 { "b", "1M" },
86 { "refs", "0" },
87 // same as the x264 default
88 { "g", "250" },
89 { "bf", "3" },
91 { "flags", "+cgop" },
92 #if FF_API_PRIVATE_OPT
93 { "b_strategy", "-1" },
94 #endif
95 { NULL },
98 AVCodec ff_mpeg2_qsv_encoder = {
99 .name = "mpeg2_qsv",
100 .long_name = NULL_IF_CONFIG_SMALL("MPEG-2 video (Intel Quick Sync Video acceleration)"),
101 .priv_data_size = sizeof(QSVMpeg2EncContext),
102 .type = AVMEDIA_TYPE_VIDEO,
103 .id = AV_CODEC_ID_MPEG2VIDEO,
104 .init = qsv_enc_init,
105 .encode2 = qsv_enc_frame,
106 .close = qsv_enc_close,
107 .capabilities = AV_CODEC_CAP_DELAY | AV_CODEC_CAP_HYBRID,
108 .pix_fmts = (const enum AVPixelFormat[]){ AV_PIX_FMT_NV12,
109 AV_PIX_FMT_QSV,
110 AV_PIX_FMT_NONE },
111 .priv_class = &class,
112 .defaults = qsv_enc_defaults,
113 .caps_internal = FF_CODEC_CAP_INIT_CLEANUP,
114 .wrapper_name = "qsv",