FFmpeg
Data Structures | Macros | Functions | Variables
rkmppenc.c File Reference
#include "config_components.h"
#include <assert.h>
#include <stdbool.h>
#include <rockchip/mpp_frame.h>
#include <rockchip/mpp_packet.h>
#include <rockchip/rk_mpi.h>
#include "libavutil/avassert.h"
#include "libavutil/hwcontext.h"
#include "libavutil/hwcontext_drm.h"
#include "libavutil/imgutils.h"
#include "libavutil/log.h"
#include "libavutil/mem.h"
#include "libavutil/opt.h"
#include "avcodec.h"
#include "codec_internal.h"
#include "encode.h"
#include "hwconfig.h"

Go to the source code of this file.

Data Structures

struct  RKMPPEncoderContext
 

Macros

#define RKMPP_TIME_BASE   AV_TIME_BASE_Q
 
#define RKMPP_ALIGN_SIZE   16
 
#define OFFSET(x)   offsetof(RKMPPEncoderContext, x)
 
#define VE   AV_OPT_FLAG_VIDEO_PARAM | AV_OPT_FLAG_ENCODING_PARAM
 
#define RKMPP_ENC(NAME, ID)
 

Functions

static av_cold int rkmpp_close_encoder (AVCodecContext *avctx)
 
static int rkmpp_create_frame_buf (AVCodecContext *avctx)
 
static int rkmpp_export_extradata (AVCodecContext *avctx)
 
static av_cold int rkmpp_init_encoder (AVCodecContext *avctx)
 
static int rkmpp_output_pkt (AVCodecContext *avctx, AVPacket *pkt, MppPacket packet)
 
static int rkmpp_set_hw_frame (AVCodecContext *avctx, MppFrame frame)
 
static int rkmpp_set_sw_frame (AVCodecContext *avctx, MppFrame frame)
 
static int rkmpp_send_frame (AVCodecContext *avctx)
 
static int rkmpp_receive (AVCodecContext *avctx, AVPacket *pkt)
 
static av_cold void rkmpp_flush (AVCodecContext *avctx)
 

Variables

static enum AVPixelFormat rkmpp_pix_fmts []
 
static const AVCodecHWConfigInternal *const rkmpp_hw_configs []
 
static const AVOption rkmpp_options []
 
static const AVClass rkmpp_enc_class
 

Macro Definition Documentation

◆ RKMPP_TIME_BASE

#define RKMPP_TIME_BASE   AV_TIME_BASE_Q

Definition at line 45 of file rkmppenc.c.

◆ RKMPP_ALIGN_SIZE

#define RKMPP_ALIGN_SIZE   16

Definition at line 46 of file rkmppenc.c.

◆ OFFSET

#define OFFSET (   x)    offsetof(RKMPPEncoderContext, x)

Definition at line 536 of file rkmppenc.c.

◆ VE

Definition at line 537 of file rkmppenc.c.

◆ RKMPP_ENC

#define RKMPP_ENC (   NAME,
  ID 
)
Value:
const FFCodec ff_##NAME##_rkmpp_encoder = { \
.p.name = #NAME "_rkmpp", \
CODEC_LONG_NAME(#NAME " (rkmpp)"), \
.p.type = AVMEDIA_TYPE_VIDEO, \
.p.id = ID, \
.p.capabilities = AV_CODEC_CAP_DR1 | AV_CODEC_CAP_DELAY | \
AV_CODEC_CAP_HARDWARE | AV_CODEC_CAP_ENCODER_FLUSH, \
.priv_data_size = sizeof(RKMPPEncoderContext), \
.color_ranges = AVCOL_RANGE_MPEG | AVCOL_RANGE_JPEG, \
.init = rkmpp_init_encoder, \
FF_CODEC_RECEIVE_PACKET_CB(rkmpp_receive), \
.close = rkmpp_close_encoder, \
.flush = rkmpp_flush, \
.p.priv_class = &rkmpp_enc_class, \
.caps_internal = FF_CODEC_CAP_INIT_CLEANUP, \
.p.wrapper_name = "rkmpp", \
.hw_configs = rkmpp_hw_configs, \
};

Definition at line 557 of file rkmppenc.c.

Function Documentation

◆ rkmpp_close_encoder()

static av_cold int rkmpp_close_encoder ( AVCodecContext avctx)
static

Definition at line 74 of file rkmppenc.c.

◆ rkmpp_create_frame_buf()

static int rkmpp_create_frame_buf ( AVCodecContext avctx)
static

Definition at line 104 of file rkmppenc.c.

Referenced by rkmpp_init_encoder().

◆ rkmpp_export_extradata()

static int rkmpp_export_extradata ( AVCodecContext avctx)
static

Definition at line 137 of file rkmppenc.c.

Referenced by rkmpp_init_encoder().

◆ rkmpp_init_encoder()

static av_cold int rkmpp_init_encoder ( AVCodecContext avctx)
static

Definition at line 182 of file rkmppenc.c.

◆ rkmpp_output_pkt()

static int rkmpp_output_pkt ( AVCodecContext avctx,
AVPacket pkt,
MppPacket  packet 
)
static

Definition at line 310 of file rkmppenc.c.

Referenced by rkmpp_receive().

◆ rkmpp_set_hw_frame()

static int rkmpp_set_hw_frame ( AVCodecContext avctx,
MppFrame  frame 
)
static

Definition at line 365 of file rkmppenc.c.

Referenced by rkmpp_send_frame().

◆ rkmpp_set_sw_frame()

static int rkmpp_set_sw_frame ( AVCodecContext avctx,
MppFrame  frame 
)
static

Definition at line 415 of file rkmppenc.c.

Referenced by rkmpp_send_frame().

◆ rkmpp_send_frame()

static int rkmpp_send_frame ( AVCodecContext avctx)
static

Definition at line 448 of file rkmppenc.c.

Referenced by rkmpp_receive().

◆ rkmpp_receive()

static int rkmpp_receive ( AVCodecContext avctx,
AVPacket pkt 
)
static

Definition at line 490 of file rkmppenc.c.

◆ rkmpp_flush()

static av_cold void rkmpp_flush ( AVCodecContext avctx)
static

Definition at line 524 of file rkmppenc.c.

Variable Documentation

◆ rkmpp_pix_fmts

enum AVPixelFormat rkmpp_pix_fmts[]
static
Initial value:

Definition at line 67 of file rkmppenc.c.

◆ rkmpp_hw_configs

const AVCodecHWConfigInternal* const rkmpp_hw_configs[]
static
Initial value:
= {
HW_CONFIG_ENCODER_FRAMES(DRM_PRIME, DRM),
}

Definition at line 531 of file rkmppenc.c.

◆ rkmpp_options

const AVOption rkmpp_options[]
static
Initial value:
= {
{"rc", "rate-control mode",
OFFSET(rc_mode), AV_OPT_TYPE_INT, { .i64 = MPP_ENC_RC_MODE_VBR }, MPP_ENC_RC_MODE_VBR, INT_MAX, VE, .unit = "rc"},
{"vbr", "Variable bitrate mode",
0, AV_OPT_TYPE_CONST, {.i64 = MPP_ENC_RC_MODE_VBR}, 0, 0, VE, .unit = "rc"},
{"cbr", "Constant bitrate mode",
0, AV_OPT_TYPE_CONST, {.i64 = MPP_ENC_RC_MODE_CBR}, 0, 0, VE, .unit = "rc"},
{"avbr", "Adaptive bit rate mode",
0, AV_OPT_TYPE_CONST, {.i64 = MPP_ENC_RC_MODE_AVBR}, 0, 0, VE, .unit = "rc"},
{NULL},
}

Definition at line 538 of file rkmppenc.c.

◆ rkmpp_enc_class

const AVClass rkmpp_enc_class
static
Initial value:
= {
.class_name = "rkmpp_enc",
.item_name = av_default_item_name,
.option = rkmpp_options,
}

Definition at line 550 of file rkmppenc.c.

rkmpp_flush
static av_cold void rkmpp_flush(AVCodecContext *avctx)
Definition: rkmppenc.c:524
OFFSET
#define OFFSET(x)
Definition: rkmppenc.c:536
FF_CODEC_CAP_INIT_CLEANUP
#define FF_CODEC_CAP_INIT_CLEANUP
The codec allows calling the close function for deallocation even if the init function returned a fai...
Definition: codec_internal.h:42
rkmpp_hw_configs
static const AVCodecHWConfigInternal *const rkmpp_hw_configs[]
Definition: rkmppenc.c:531
AVCOL_RANGE_JPEG
@ AVCOL_RANGE_JPEG
Full range content.
Definition: pixfmt.h:777
AV_PIX_FMT_DRM_PRIME
@ AV_PIX_FMT_DRM_PRIME
DRM-managed buffers exposed through PRIME buffer sharing.
Definition: pixfmt.h:351
rkmpp_receive
static int rkmpp_receive(AVCodecContext *avctx, AVPacket *pkt)
Definition: rkmppenc.c:490
FFCodec
Definition: codec_internal.h:127
FFCodec::p
AVCodec p
The public AVCodec.
Definition: codec_internal.h:131
AV_CODEC_CAP_ENCODER_FLUSH
#define AV_CODEC_CAP_ENCODER_FLUSH
This encoder can be flushed using avcodec_flush_buffers().
Definition: codec.h:151
rkmpp_pix_fmts
static enum AVPixelFormat rkmpp_pix_fmts[]
Definition: rkmppenc.c:67
rkmpp_close_encoder
static av_cold int rkmpp_close_encoder(AVCodecContext *avctx)
Definition: rkmppenc.c:74
AV_PIX_FMT_YUV420P
@ AV_PIX_FMT_YUV420P
planar YUV 4:2:0, 12bpp, (1 Cr & Cb sample per 2x2 Y samples)
Definition: pixfmt.h:73
LIBAVUTIL_VERSION_INT
#define LIBAVUTIL_VERSION_INT
Definition: version.h:85
NULL
#define NULL
Definition: coverity.c:32
CODEC_PIXFMTS_ARRAY
#define CODEC_PIXFMTS_ARRAY(array)
Definition: codec_internal.h:393
av_default_item_name
const char * av_default_item_name(void *ptr)
Return the context name.
Definition: log.c:241
rkmpp_enc_class
static const AVClass rkmpp_enc_class
Definition: rkmppenc.c:550
ID
#define ID(_0)
Definition: mov_chan.c:240
AV_CODEC_CAP_DR1
#define AV_CODEC_CAP_DR1
Codec uses get_buffer() or get_encode_buffer() for allocating buffers and supports custom allocators.
Definition: codec.h:52
rkmpp_options
static const AVOption rkmpp_options[]
Definition: rkmppenc.c:538
HW_CONFIG_ENCODER_FRAMES
#define HW_CONFIG_ENCODER_FRAMES(format, device_type_)
Definition: hwconfig.h:98
AVCodec::name
const char * name
Name of the codec implementation.
Definition: codec.h:179
AVCOL_RANGE_MPEG
@ AVCOL_RANGE_MPEG
Narrow or limited range content.
Definition: pixfmt.h:760
AV_PIX_FMT_NV12
@ 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
VE
#define VE
Definition: rkmppenc.c:537
rkmpp_init_encoder
static av_cold int rkmpp_init_encoder(AVCodecContext *avctx)
Definition: rkmppenc.c:182
AV_PIX_FMT_NONE
@ AV_PIX_FMT_NONE
Definition: pixfmt.h:72
AV_OPT_TYPE_INT
@ AV_OPT_TYPE_INT
Underlying C type is int.
Definition: opt.h:259
AV_CODEC_CAP_DELAY
#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:76
AVMEDIA_TYPE_VIDEO
@ AVMEDIA_TYPE_VIDEO
Definition: avutil.h:200
RKMPPEncoderContext
Definition: rkmppenc.c:48
rc_mode
mfxU16 rc_mode
Definition: qsvenc.c:141
AV_OPT_TYPE_CONST
@ AV_OPT_TYPE_CONST
Special option type for declaring named constants.
Definition: opt.h:299