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"
33 * AMF trace writer callback class
34 * Used to capture all AMF logging
37 typedef struct AmfTraceWriter {
38 AMFTraceWriterVtbl *vtbl;
39 AVCodecContext *avctx;
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
54 amf_uint64 version; ///< version of AMF runtime
55 AmfTraceWriter tracer; ///< AMF writer registered with AMF
56 AMFContext *context; ///< AMF context
58 AMFComponent *encoder; ///< AMF encoder object
59 amf_bool eof; ///< flag indicating EOF happened
60 AMF_SURFACE_FORMAT format; ///< AMF surface format
62 AVBufferRef *hw_device_ctx; ///< pointer to HW accelerator (decoder)
63 AVBufferRef *hw_frames_ctx; ///< pointer to HW accelerator (frame allocator)
65 int hwsurfaces_in_queue;
66 int hwsurfaces_in_queue_max;
68 // helpers to handle async calls
70 AMFSurface *delayed_surface;
71 AVFrame *delayed_frame;
73 // shift dts back by max_b_frames in timing
74 AVFifoBuffer *timestamp_list;
77 // common encoder option options
81 // Static options, have to be set before Init() call
88 int ref_b_frame_delta_qp;
90 // Dynamic options, can be set after Init() call
92 int rate_control_mode;
103 int intra_refresh_mb;
109 // HEVC - specific options
112 int header_insertion_mode;
121 * Common encoder initization function
123 int ff_amf_encode_init(AVCodecContext *avctx);
125 * Common encoder termination function
127 int ff_amf_encode_close(AVCodecContext *avctx);
130 * Ecoding one frame - common function for all AMF encoders
133 int ff_amf_send_frame(AVCodecContext *avctx, const AVFrame *frame);
134 int ff_amf_receive_packet(AVCodecContext *avctx, AVPacket *avpkt);
139 extern const enum AVPixelFormat ff_amf_pix_fmts[];
142 * Error handling helper
144 #define AMF_RETURN_IF_FALSE(avctx, exp, ret_value, /*message,*/ ...) \
146 av_log(avctx, AV_LOG_ERROR, __VA_ARGS__); \
150 #endif //AVCODEC_AMFENC_H