FFmpeg
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/VideoEncoderVCE.h>
25 #include <AMF/components/VideoEncoderHEVC.h>
26 
27 #include "libavutil/fifo.h"
28 
29 #include "avcodec.h"
30 
31 
32 /**
33 * AMF trace writer callback class
34 * Used to capture all AMF logging
35 */
36 
37 typedef struct AmfTraceWriter {
38  AMFTraceWriterVtbl *vtbl;
41 
42 /**
43 * AMF encoder context
44 */
45 
46 typedef struct AmfContext {
48  // access to AMF runtime
49  amf_handle library; ///< handle to DLL library
50  AMFFactory *factory; ///< pointer to AMF factory
51  AMFDebug *debug; ///< pointer to AMF debug interface
52  AMFTrace *trace; ///< pointer to AMF trace interface
53 
54  amf_uint64 version; ///< version of AMF runtime
55  AmfTraceWriter tracer; ///< AMF writer registered with AMF
56  AMFContext *context; ///< AMF context
57  //encoder
58  AMFComponent *encoder; ///< AMF encoder object
59  amf_bool eof; ///< flag indicating EOF happened
60  AMF_SURFACE_FORMAT format; ///< AMF surface format
61 
62  AVBufferRef *hw_device_ctx; ///< pointer to HW accelerator (decoder)
63  AVBufferRef *hw_frames_ctx; ///< pointer to HW accelerator (frame allocator)
64 
67 
68  // helpers to handle async calls
70  AMFSurface *delayed_surface;
72 
73  // shift dts back by max_b_frames in timing
75  int64_t dts_delay;
76 
77  // common encoder option options
78 
80 
81  // Static options, have to be set before Init() call
82  int usage;
83  int profile;
84  int level;
86  int quality;
89 
90  // Dynamic options, can be set after Init() call
91 
97  int qp_i;
98  int qp_p;
99  int qp_b;
107  int aud;
108 
109  // HEVC - specific options
110 
113  int min_qp_i;
114  int max_qp_i;
115  int min_qp_p;
116  int max_qp_p;
117  int tier;
118 } AmfContext;
119 
120 /**
121 * Common encoder initization function
122 */
124 /**
125 * Common encoder termination function
126 */
128 
129 /**
130 * Ecoding one frame - common function for all AMF encoders
131 */
132 
135 
136 /**
137 * Supported formats
138 */
139 extern const enum AVPixelFormat ff_amf_pix_fmts[];
140 
141 /**
142 * Error handling helper
143 */
144 #define AMF_RETURN_IF_FALSE(avctx, exp, ret_value, /*message,*/ ...) \
145  if (!(exp)) { \
146  av_log(avctx, AV_LOG_ERROR, __VA_ARGS__); \
147  return ret_value; \
148  }
149 
150 #endif //AVCODEC_AMFENC_H
AMFContext * context
AMF context.
Definition: amfenc.h:56
int hwsurfaces_in_queue
Definition: amfenc.h:65
int usage
Definition: amfenc.h:82
This structure describes decoded (raw) audio or video data.
Definition: frame.h:295
int skip_frame
Definition: amfenc.h:96
int ff_amf_encode_init(AVCodecContext *avctx)
Common encoder initization function.
Definition: amfenc.c:506
AVBufferRef * hw_device_ctx
pointer to HW accelerator (decoder)
Definition: amfenc.h:62
int b_frame_ref
Definition: amfenc.h:102
int hwsurfaces_in_queue_max
Definition: amfenc.h:66
int me_half_pel
Definition: amfenc.h:105
int level
Definition: amfenc.h:84
int gops_per_idr
Definition: amfenc.h:111
int coding_mode
Definition: amfenc.h:104
AMF_SURFACE_FORMAT format
AMF surface format.
Definition: amfenc.h:60
int b_frame_delta_qp
Definition: amfenc.h:87
int enforce_hrd
Definition: amfenc.h:93
AVFrame * delayed_frame
Definition: amfenc.h:71
int me_quarter_pel
Definition: amfenc.h:106
int delayed_drain
Definition: amfenc.h:69
int ff_amf_receive_packet(AVCodecContext *avctx, AVPacket *avpkt)
Definition: amfenc.c:717
int qp_b
Definition: amfenc.h:99
AMF trace writer callback class Used to capture all AMF logging.
Definition: amfenc.h:37
int max_au_size
Definition: amfenc.h:100
int rate_control_mode
Definition: amfenc.h:92
int quality
Definition: amfenc.h:86
int filler_data
Definition: amfenc.h:94
int qp_p
Definition: amfenc.h:98
int ff_amf_send_frame(AVCodecContext *avctx, const AVFrame *frame)
Ecoding one frame - common function for all AMF encoders.
Definition: amfenc.c:591
enum AVPixelFormat ff_amf_pix_fmts[]
Supported formats.
Definition: amfenc.c:52
AVCodecContext * avctx
Definition: amfenc.h:39
int max_qp_i
Definition: amfenc.h:114
these buffered frames must be flushed immediately if a new input produces new the filter must not call request_frame to get more It must just process the frame or queue it The task of requesting more frames is left to the filter s request_frame method or the application If a filter has several the filter must be ready for frames arriving randomly on any input any filter with several inputs will most likely require some kind of queuing mechanism It is perfectly acceptable to have a limited queue and to drop frames when the inputs are too unbalanced request_frame For filters that do not use the this method is called when a frame is wanted on an output For a it should directly call filter_frame on the corresponding output For a if there are queued frames already one of these frames should be pushed If the filter should request a frame on one of its repeatedly until at least one frame has been pushed Return or at least make progress towards producing a frame
int tier
Definition: amfenc.h:117
AMFFactory * factory
pointer to AMF factory
Definition: amfenc.h:50
AVBufferRef * hw_frames_ctx
pointer to HW accelerator (frame allocator)
Definition: amfenc.h:63
int min_qp_i
Definition: amfenc.h:113
AMFTraceWriterVtbl * vtbl
Definition: amfenc.h:38
amf_handle library
handle to DLL library
Definition: amfenc.h:49
int preanalysis
Definition: amfenc.h:85
AMFComponent * encoder
AMF encoder object.
Definition: amfenc.h:58
int ref_b_frame_delta_qp
Definition: amfenc.h:88
Libavcodec external API header.
int aud
Definition: amfenc.h:107
int intra_refresh_mb
Definition: amfenc.h:103
AMFDebug * debug
pointer to AMF debug interface
Definition: amfenc.h:51
int64_t dts_delay
Definition: amfenc.h:75
int enable_vbaq
Definition: amfenc.h:95
int qp_i
Definition: amfenc.h:97
AVFifoBuffer * timestamp_list
Definition: amfenc.h:74
main external API structure.
Definition: avcodec.h:1568
int profile
Definition: amfenc.h:83
amf_bool eof
flag indicating EOF happened
Definition: amfenc.h:59
a very simple circular buffer FIFO implementation
Describe the class of an AVClass context structure.
Definition: log.h:67
int ff_amf_encode_close(AVCodecContext *avctx)
Common encoder termination function.
Definition: amfenc.c:369
amf_uint64 version
version of AMF runtime
Definition: amfenc.h:54
AMF encoder context.
Definition: amfenc.h:46
int header_insertion_mode
Definition: amfenc.h:112
A reference to a data buffer.
Definition: buffer.h:81
AmfTraceWriter tracer
AMF writer registered with AMF.
Definition: amfenc.h:55
AVClass * avclass
Definition: amfenc.h:47
int min_qp_p
Definition: amfenc.h:115
int max_qp_p
Definition: amfenc.h:116
int log_to_dbg
Definition: amfenc.h:79
AMFSurface * delayed_surface
Definition: amfenc.h:70
AMFTrace * trace
pointer to AMF trace interface
Definition: amfenc.h:52
AVPixelFormat
Pixel format.
Definition: pixfmt.h:64
This structure stores compressed data.
Definition: avcodec.h:1457
int header_spacing
Definition: amfenc.h:101