Commit 0a731e45 authored by Michael Niedermayer's avatar Michael Niedermayer

Merge commit '72b7441a'

* commit '72b7441a':
  lavc: add Intel libmfx-based H.264 encoder

Conflicts:
	Changelog
	libavcodec/version.h
Merged-by: 's avatarMichael Niedermayer <michaelni@gmx.at>
parents d985976e 72b7441a
......@@ -10,6 +10,7 @@ version <next>:
- Drop support for nvenc API before 5.0
- nvenc H265 encoder
- Detelecine filter
- Intel QSV-accelerated H.264 encoding
version 2.6:
......
......@@ -1892,6 +1892,7 @@ CONFIG_EXTRA="
qpeldsp
qsv
qsvdec
qsvenc
rangecoder
riffdec
riffenc
......@@ -2075,6 +2076,7 @@ mpegaudiodsp_select="dct"
mpegvideo_select="blockdsp h264chroma hpeldsp idctdsp me_cmp videodsp"
mpegvideoenc_select="me_cmp mpegvideo pixblockdsp qpeldsp"
qsvdec_select="qsv"
qsvenc_select="qsv"
# decoders / encoders
aac_decoder_select="imdct15 mdct sinewin"
......@@ -2150,6 +2152,8 @@ h264_decoder_select="cabac golomb h264chroma h264dsp h264pred h264qpel startcode
h264_decoder_suggest="error_resilience"
h264_qsv_decoder_deps="libmfx"
h264_qsv_decoder_select="h264_mp4toannexb_bsf h264_parser qsvdec h264_qsv_hwaccel"
h264_qsv_encoder_deps="libmfx"
h264_qsv_encoder_select="qsvenc"
hevc_decoder_select="bswapdsp cabac golomb videodsp"
huffyuv_decoder_select="bswapdsp huffyuvdsp llviddsp"
huffyuv_encoder_select="bswapdsp huffman huffyuvencdsp llviddsp"
......
......@@ -94,6 +94,7 @@ OBJS-$(CONFIG_PIXBLOCKDSP) += pixblockdsp.o
OBJS-$(CONFIG_QPELDSP) += qpeldsp.o
OBJS-$(CONFIG_QSV) += qsv.o
OBJS-$(CONFIG_QSVDEC) += qsvdec.o
OBJS-$(CONFIG_QSVENC) += qsvenc.o
OBJS-$(CONFIG_RANGECODER) += rangecoder.o
RDFT-OBJS-$(CONFIG_HARDCODED_TABLES) += sin_tables.o
OBJS-$(CONFIG_RDFT) += rdft.o $(RDFT-OBJS-yes)
......@@ -270,6 +271,7 @@ OBJS-$(CONFIG_H264_DECODER) += h264.o h264_cabac.o h264_cavlc.o \
h264_refs.o h264_sei.o h264_slice.o
OBJS-$(CONFIG_H264_VDA_DECODER) += vda_h264_dec.o
OBJS-$(CONFIG_H264_QSV_DECODER) += qsvdec_h264.o
OBJS-$(CONFIG_H264_QSV_ENCODER) += qsvenc_h264.o
OBJS-$(CONFIG_HEVC_DECODER) += hevc.o hevc_mvs.o hevc_ps.o hevc_sei.o \
hevc_cabac.o hevc_refs.o hevcpred.o \
hevcdsp.o hevc_filter.o
......
......@@ -554,6 +554,7 @@ void avcodec_register_all(void)
/* external libraries, that shouldn't be used by default if one of the
* above is available */
REGISTER_ENCODER(LIBOPENH264, libopenh264);
REGISTER_ENCODER(H264_QSV, h264_qsv);
/* parsers */
REGISTER_PARSER(AAC, aac);
......
......@@ -21,11 +21,24 @@
#ifndef AVCODEC_QSV_INTERNAL_H
#define AVCODEC_QSV_INTERNAL_H
#include <mfx/mfxvideo.h>
#include "libavutil/frame.h"
#define QSV_VERSION_MAJOR 1
#define QSV_VERSION_MINOR 1
#define ASYNC_DEPTH_DEFAULT 4 // internal parallelism
typedef struct QSVFrame {
AVFrame *frame;
mfxFrameSurface1 *surface;
mfxFrameSurface1 surface_internal;
struct QSVFrame *next;
} QSVFrame;
/**
* Convert a libmfx error code into a libav error code.
*/
......
......@@ -32,15 +32,7 @@
#include "libavutil/pixfmt.h"
#include "avcodec.h"
typedef struct QSVFrame {
AVFrame *frame;
mfxFrameSurface1 *surface;
mfxFrameSurface1 surface_internal;
struct QSVFrame *next;
} QSVFrame;
#include "qsv_internal.h"
typedef struct QSVContext {
// the session used for decoding
......
This diff is collapsed.
/*
* Intel MediaSDK QSV encoder utility functions
*
* copyright (c) 2013 Yukinori Yamazoe
*
* This file is part of FFmpeg.
*
* FFmpeg is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
* License as published by the Free Software Foundation; either
* version 2.1 of the License, or (at your option) any later version.
*
* FFmpeg is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public
* License along with FFmpeg; if not, write to the Free Software
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
*/
#ifndef AVCODEC_QSVENC_H
#define AVCODEC_QSVENC_H
#include <stdint.h>
#include <sys/types.h>
#include <mfx/mfxvideo.h>
#include "libavutil/avutil.h"
#include "avcodec.h"
#include "qsv_internal.h"
typedef struct QSVEncContext {
AVCodecContext *avctx;
QSVFrame *work_frames;
mfxSession session;
mfxSession internal_session;
int packet_size;
mfxVideoParam param;
mfxFrameAllocRequest req;
mfxExtCodingOption extco;
mfxExtBuffer *extparam[1];
// options set by the caller
int async_depth;
int idr_interval;
int profile;
int preset;
int avbr_accuracy;
int avbr_convergence;
} QSVEncContext;
int ff_qsv_enc_init(AVCodecContext *avctx, QSVEncContext *q);
int ff_qsv_encode(AVCodecContext *avctx, QSVEncContext *q,
AVPacket *pkt, const AVFrame *frame, int *got_packet);
int ff_qsv_enc_close(AVCodecContext *avctx, QSVEncContext *q);
#endif /* AVCODEC_QSVENC_H */
/*
* Intel MediaSDK QSV based H.264 enccoder
*
* copyright (c) 2013 Yukinori Yamazoe
*
* This file is part of FFmpeg.
*
* FFmpeg is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
* License as published by the Free Software Foundation; either
* version 2.1 of the License, or (at your option) any later version.
*
* FFmpeg is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public
* License along with FFmpeg; if not, write to the Free Software
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
*/
#include <stdint.h>
#include <sys/types.h>
#include <mfx/mfxvideo.h>
#include "libavutil/opt.h"
#include "avcodec.h"
#include "internal.h"
#include "h264.h"
#include "qsv.h"
#include "qsv_internal.h"
#include "qsvenc.h"
typedef struct QSVH264EncContext {
AVClass *class;
QSVEncContext qsv;
} QSVH264EncContext;
static av_cold int qsv_enc_init(AVCodecContext *avctx)
{
QSVH264EncContext *q = avctx->priv_data;
return ff_qsv_enc_init(avctx, &q->qsv);
}
static int qsv_enc_frame(AVCodecContext *avctx, AVPacket *pkt,
const AVFrame *frame, int *got_packet)
{
QSVH264EncContext *q = avctx->priv_data;
return ff_qsv_encode(avctx, &q->qsv, pkt, frame, got_packet);
}
static av_cold int qsv_enc_close(AVCodecContext *avctx)
{
QSVH264EncContext *q = avctx->priv_data;
return ff_qsv_enc_close(avctx, &q->qsv);
}
#define OFFSET(x) offsetof(QSVH264EncContext, x)
#define VE AV_OPT_FLAG_VIDEO_PARAM | AV_OPT_FLAG_ENCODING_PARAM
static const AVOption options[] = {
{ "async_depth", "Maximum processing parallelism", OFFSET(qsv.async_depth), AV_OPT_TYPE_INT, { .i64 = ASYNC_DEPTH_DEFAULT }, 0, INT_MAX, VE },
{ "idr_interval", "Distance (in I-frames) between IDR frames", OFFSET(qsv.idr_interval), AV_OPT_TYPE_INT, { .i64 = 0 }, 0, INT_MAX, VE },
{ "avbr_accuracy", "Accuracy of the AVBR ratecontrol", OFFSET(qsv.avbr_accuracy), AV_OPT_TYPE_INT, { .i64 = 0 }, 0, INT_MAX, VE },
{ "avbr_convergence", "Convergence of the AVBR ratecontrol", OFFSET(qsv.avbr_convergence), AV_OPT_TYPE_INT, { .i64 = 0 }, 0, INT_MAX, VE },
{ "profile", NULL, OFFSET(qsv.profile), AV_OPT_TYPE_INT, { .i64 = MFX_PROFILE_UNKNOWN }, 0, INT_MAX, VE, "profile" },
{ "unknown" , NULL, 0, AV_OPT_TYPE_CONST, { .i64 = MFX_PROFILE_UNKNOWN }, INT_MIN, INT_MAX, VE, "profile" },
{ "baseline", NULL, 0, AV_OPT_TYPE_CONST, { .i64 = MFX_PROFILE_AVC_BASELINE }, INT_MIN, INT_MAX, VE, "profile" },
{ "main" , NULL, 0, AV_OPT_TYPE_CONST, { .i64 = MFX_PROFILE_AVC_MAIN }, INT_MIN, INT_MAX, VE, "profile" },
{ "high" , NULL, 0, AV_OPT_TYPE_CONST, { .i64 = MFX_PROFILE_AVC_HIGH }, INT_MIN, INT_MAX, VE, "profile" },
{ "preset", NULL, OFFSET(qsv.preset), AV_OPT_TYPE_INT, { .i64 = MFX_TARGETUSAGE_BALANCED }, 0, 7, VE, "preset" },
{ "fast", NULL, 0, AV_OPT_TYPE_CONST, { .i64 = MFX_TARGETUSAGE_BEST_SPEED }, INT_MIN, INT_MAX, VE, "preset" },
{ "medium", NULL, 0, AV_OPT_TYPE_CONST, { .i64 = MFX_TARGETUSAGE_BALANCED }, INT_MIN, INT_MAX, VE, "preset" },
{ "slow", NULL, 0, AV_OPT_TYPE_CONST, { .i64 = MFX_TARGETUSAGE_BEST_QUALITY }, INT_MIN, INT_MAX, VE, "preset" },
{ NULL },
};
static const AVClass class = {
.class_name = "h264_qsv encoder",
.item_name = av_default_item_name,
.option = options,
.version = LIBAVUTIL_VERSION_INT,
};
static const AVCodecDefault qsv_enc_defaults[] = {
{ "b", "1M" },
{ "refs", "0" },
// same as the x264 default
{ "g", "250" },
{ "bf", "3" },
{ "coder", "ac" },
{ "flags", "+cgop" },
{ NULL },
};
AVCodec ff_h264_qsv_encoder = {
.name = "h264_qsv",
.long_name = NULL_IF_CONFIG_SMALL("H.264 / AVC / MPEG-4 AVC / MPEG-4 part 10 (Intel Quick Sync Video acceleration)"),
.priv_data_size = sizeof(QSVH264EncContext),
.type = AVMEDIA_TYPE_VIDEO,
.id = AV_CODEC_ID_H264,
.init = qsv_enc_init,
.encode2 = qsv_enc_frame,
.close = qsv_enc_close,
.capabilities = CODEC_CAP_DELAY,
.pix_fmts = (const enum AVPixelFormat[]){ AV_PIX_FMT_NV12,
AV_PIX_FMT_QSV,
AV_PIX_FMT_NONE },
.priv_class = &class,
.defaults = qsv_enc_defaults,
};
......@@ -29,7 +29,7 @@
#include "libavutil/version.h"
#define LIBAVCODEC_VERSION_MAJOR 56
#define LIBAVCODEC_VERSION_MINOR 30
#define LIBAVCODEC_VERSION_MINOR 31
#define LIBAVCODEC_VERSION_MICRO 100
#define LIBAVCODEC_VERSION_INT AV_VERSION_INT(LIBAVCODEC_VERSION_MAJOR, \
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment