FFmpeg
Loading...
Searching...
No Matches
amfenc.h
Go to the documentation of this file.
1/*
2* This file is part of FFmpeg.
3*
4* FFmpeg is free software; you can redistribute it and/or
5* modify it under the terms of the GNU Lesser General Public
6* License as published by the Free Software Foundation; either
7* version 2.1 of the License, or (at your option) any later version.
8*
9* FFmpeg is distributed in the hope that it will be useful,
10* but WITHOUT ANY WARRANTY; without even the implied warranty of
11* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
12* Lesser General Public License for more details.
13*
14* You should have received a copy of the GNU Lesser General Public
15* License along with FFmpeg; if not, write to the Free Software
16* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
17*/
18
19#ifndef AVCODEC_AMFENC_H
20#define AVCODEC_AMFENC_H
21
22#include <AMF/core/Factory.h>
23
24#include <AMF/components/ColorSpace.h>
25#include <AMF/components/VideoEncoderVCE.h>
26#include <AMF/components/VideoEncoderHEVC.h>
27#include <AMF/components/VideoEncoderAV1.h>
28
29#include "libavutil/fifo.h"
30
31#include "avcodec.h"
32#include "hwconfig.h"
33
34#define AMF_VERSION_ATLEAST(major, minor, release) \
35 (AMF_VERSION_MAJOR > (major) || (AMF_VERSION_MAJOR == (major) && AMF_VERSION_MINOR > (minor)) || (AMF_VERSION_MAJOR == (major) && AMF_VERSION_MINOR == (minor) && AMF_VERSION_RELEASE >= (release)))
36
37#define MAX_LOOKAHEAD_DEPTH 41
38
39/**
40* AMF encoder context
41*/
42
43typedef struct AMFEncoderContext {
45 // access to AMF runtime
47
48 //encoder
49 AMFComponent *encoder; ///< AMF encoder object
50 amf_bool eof; ///< flag indicating EOF happened
51 AMF_SURFACE_FORMAT format; ///< AMF surface format
54
58
59 // helpers to handle async calls
61
62 // shift dts back by max_b_frames in timing
68
69 // common encoder options
70
71 // Static options, have to be set before Init() call
72 int usage;
74 int level;
82
83 // Dynamic options, can be set after Init() call
84
90 int qp_i;
91 int qp_p;
92 int qp_b;
100 int aud;
107
108 // HEVC - specific options
109
118 int tier;
119
120 // AV1 - specific options
121
122 /* enum AMF_VIDEO_ENCODER_AV1_ALIGNMENT_MODE_ENUM, use int for AVOption */
123 int align;
124 /* enum AMF_VIDEO_ENCODER_AV1_AQ_MODE_ENUM */
126
127 // Preanalysis - specific options
128
145
146
148
150
151/**
152* Common encoder initization function
153*/
155/**
156* Common encoder termination function
157*/
159
160/**
161* Ecoding one frame - common function for all AMF encoders
162*/
164
165/**
166* Query the maximum PA lookahead buffer depth (AMF_PA_LOOKAHEAD_BUFFER_DEPTH).
167* Falls back to MAX_LOOKAHEAD_DEPTH for older headers/runtimes or query failure.
168* @return 0 and sets *out_max on success; a negative AVERROR on failure.
169*/
170int ff_amf_get_lookahead_depth_max(AVCodecContext *avctx, AMFComponent *encoder, amf_uint64 runtime_version, amf_int64 *out_max);
171
172/**
173* Clamp pa_lookahead_buffer_depth to the AMF-reported maximum and assign it to
174* the encoder. Call from within the preanalysis configuration block, before
175* encoder Init().
176*/
178
179/**
180* Size async_depth (hwsurfaces_in_queue_max) around the lookahead window: widen
181* it to hold the lookahead depth read back from the encoder, then cap it at the
182* AMF-reported lookahead maximum + 1. Call before encoder Init(), after all
183* lookahead/B-frame properties have been set.
184*/
186
187/**
188* Supported formats
189*/
190extern const enum AVPixelFormat ff_amf_pix_fmts[];
191
192/**
193* Error handling helper
194*/
195#define AMF_RETURN_IF_FALSE(avctx, exp, ret_value, /*message,*/ ...) \
196 if (!(exp)) { \
197 av_log(avctx, AV_LOG_ERROR, __VA_ARGS__); \
198 return ret_value; \
199 }
200
201#endif //AVCODEC_AMFENC_H
const AVCodecHWConfigInternal *const ff_amfenc_hw_configs[]
Definition amfenc.c:784
enum AVPixelFormat ff_amf_pix_fmts[]
Supported formats.
Definition amfenc.c:57
int ff_amf_encode_init(AVCodecContext *avctx)
Common encoder initization function.
Definition amfenc.c:355
void ff_amf_clamp_lookahead_depth(AVCodecContext *avctx, AMFEncoderContext *ctx)
Clamp pa_lookahead_buffer_depth to the AMF-reported maximum and assign it to the encoder.
Definition amfenc.c:193
void ff_amf_fit_async_depth(AVCodecContext *avctx, AMFEncoderContext *ctx)
Size async_depth (hwsurfaces_in_queue_max) around the lookahead window: widen it to hold the lookahea...
Definition amfenc.c:213
int ff_amf_receive_packet(AVCodecContext *avctx, AVPacket *avpkt)
Ecoding one frame - common function for all AMF encoders.
Definition amfenc.c:649
int ff_amf_get_lookahead_depth_max(AVCodecContext *avctx, AMFComponent *encoder, amf_uint64 runtime_version, amf_int64 *out_max)
Query the maximum PA lookahead buffer depth (AMF_PA_LOOKAHEAD_BUFFER_DEPTH).
Definition amfenc.c:171
int ff_amf_encode_close(AVCodecContext *avctx)
Common encoder termination function.
Definition amfenc.c:142
static AVFormatContext * ctx
Libavcodec external API header.
long long int64_t
Definition coverity.c:34
A generic FIFO API.
AVPixelFormat
Pixel format.
Definition pixfmt.h:71
AMF encoder context.
Definition amfenc.h:43
AMF_SURFACE_FORMAT format
AMF surface format.
Definition amfenc.h:51
int64_t submitted_frame
Definition amfenc.h:65
int b_frame_delta_qp
Definition amfenc.h:78
int pa_scene_change_detection_sensitivity
Definition amfenc.h:132
int pa_high_motion_quality_boost_mode
Definition amfenc.h:143
int header_insertion_mode
Definition amfenc.h:111
int pa_static_scene_detection_sensitivity
Definition amfenc.h:134
int pa_adaptive_mini_gop
Definition amfenc.h:144
AVFifo * output_list
Definition amfenc.h:67
int rate_control_mode
Definition amfenc.h:85
wchar_t * av_frame_property_name
Definition amfenc.h:53
int64_t dts_delay
Definition amfenc.h:64
AMFComponent * encoder
AMF encoder object.
Definition amfenc.h:49
int query_timeout_supported
Definition amfenc.h:57
AVFifo * timestamp_list
Definition amfenc.h:63
int ref_b_frame_delta_qp
Definition amfenc.h:79
int intra_refresh_mb
Definition amfenc.h:96
int hwsurfaces_in_queue_max
Definition amfenc.h:56
AVClass * avclass
Definition amfenc.h:44
AVBufferRef * device_ctx_ref
Definition amfenc.h:46
int qvbr_quality_level
Definition amfenc.h:103
int max_consecutive_b_frames
Definition amfenc.h:101
int smart_access_video
Definition amfenc.h:81
int pa_static_scene_detection
Definition amfenc.h:133
int pa_lookahead_buffer_depth
Definition amfenc.h:140
int pa_scene_change_detection
Definition amfenc.h:131
amf_bool eof
flag indicating EOF happened
Definition amfenc.h:50
wchar_t * pts_property_name
Definition amfenc.h:52
int64_t encoded_frame
Definition amfenc.h:66
int hw_high_motion_quality_boost
Definition amfenc.h:104
int hwsurfaces_in_queue
Definition amfenc.h:55
A reference to a data buffer.
Definition buffer.h:82
Describe the class of an AVClass context structure.
Definition log.h:76
main external API structure.
Definition avcodec.h:443
Definition fifo.c:35
This structure stores compressed data.
Definition packet.h:587