2 * This file is part of FFmpeg.
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.
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.
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
19 #ifndef AVCODEC_AMFENC_H
20 #define AVCODEC_AMFENC_H
22 #include <AMF/core/Factory.h>
24 #include <AMF/components/VideoEncoderVCE.h>
25 #include <AMF/components/VideoEncoderHEVC.h>
27 #include "libavutil/fifo.h"
34 * AMF trace writer callback class
35 * Used to capture all AMF logging
38 typedef struct AmfTraceWriter {
39 AMFTraceWriterVtbl *vtbl;
40 AVCodecContext *avctx;
47 typedef struct AmfContext {
49 // access to AMF runtime
50 amf_handle library; ///< handle to DLL library
51 AMFFactory *factory; ///< pointer to AMF factory
52 AMFDebug *debug; ///< pointer to AMF debug interface
53 AMFTrace *trace; ///< pointer to AMF trace interface
55 amf_uint64 version; ///< version of AMF runtime
56 AmfTraceWriter tracer; ///< AMF writer registered with AMF
57 AMFContext *context; ///< AMF context
59 AMFComponent *encoder; ///< AMF encoder object
60 amf_bool eof; ///< flag indicating EOF happened
61 AMF_SURFACE_FORMAT format; ///< AMF surface format
63 AVBufferRef *hw_device_ctx; ///< pointer to HW accelerator (decoder)
64 AVBufferRef *hw_frames_ctx; ///< pointer to HW accelerator (frame allocator)
66 int hwsurfaces_in_queue;
67 int hwsurfaces_in_queue_max;
69 // helpers to handle async calls
71 AMFSurface *delayed_surface;
72 AVFrame *delayed_frame;
74 // shift dts back by max_b_frames in timing
75 AVFifoBuffer *timestamp_list;
78 // common encoder option options
82 // Static options, have to be set before Init() call
89 int ref_b_frame_delta_qp;
91 // Dynamic options, can be set after Init() call
93 int rate_control_mode;
104 int intra_refresh_mb;
110 // HEVC - specific options
113 int header_insertion_mode;
121 extern const AVCodecHWConfigInternal *const ff_amfenc_hw_configs[];
124 * Common encoder initization function
126 int ff_amf_encode_init(AVCodecContext *avctx);
128 * Common encoder termination function
130 int ff_amf_encode_close(AVCodecContext *avctx);
133 * Ecoding one frame - common function for all AMF encoders
135 int ff_amf_receive_packet(AVCodecContext *avctx, AVPacket *avpkt);
140 extern const enum AVPixelFormat ff_amf_pix_fmts[];
143 * Error handling helper
145 #define AMF_RETURN_IF_FALSE(avctx, exp, ret_value, /*message,*/ ...) \
147 av_log(avctx, AV_LOG_ERROR, __VA_ARGS__); \
151 #endif //AVCODEC_AMFENC_H