]> git.sesse.net Git - ffmpeg/blob - libavcodec/amfenc.h
avformat/argo_brp: allow v1.1 ASF streams to have a non-22050 sample rate in certain...
[ffmpeg] / libavcodec / amfenc.h
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;
39     AVCodecContext     *avctx;
40 } AmfTraceWriter;
41
42 /**
43 * AMF encoder context
44 */
45
46 typedef struct AmfContext {
47     AVClass            *avclass;
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
65     int                 hwsurfaces_in_queue;
66     int                 hwsurfaces_in_queue_max;
67
68     // helpers to handle async calls
69     int                 delayed_drain;
70     AMFSurface         *delayed_surface;
71     AVFrame            *delayed_frame;
72
73     // shift dts back by max_b_frames in timing
74     AVFifoBuffer       *timestamp_list;
75     int64_t             dts_delay;
76
77     // common encoder option options
78
79     int                 log_to_dbg;
80
81     // Static options, have to be set before Init() call
82     int                 usage;
83     int                 profile;
84     int                 level;
85     int                 preanalysis;
86     int                 quality;
87     int                 b_frame_delta_qp;
88     int                 ref_b_frame_delta_qp;
89
90     // Dynamic options, can be set after Init() call
91
92     int                 rate_control_mode;
93     int                 enforce_hrd;
94     int                 filler_data;
95     int                 enable_vbaq;
96     int                 skip_frame;
97     int                 qp_i;
98     int                 qp_p;
99     int                 qp_b;
100     int                 max_au_size;
101     int                 header_spacing;
102     int                 b_frame_ref;
103     int                 intra_refresh_mb;
104     int                 coding_mode;
105     int                 me_half_pel;
106     int                 me_quarter_pel;
107     int                 aud;
108
109     // HEVC - specific options
110
111     int                 gops_per_idr;
112     int                 header_insertion_mode;
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 */
123 int ff_amf_encode_init(AVCodecContext *avctx);
124 /**
125 * Common encoder termination function
126 */
127 int ff_amf_encode_close(AVCodecContext *avctx);
128
129 /**
130 * Ecoding one frame - common function for all AMF encoders
131 */
132 int ff_amf_receive_packet(AVCodecContext *avctx, AVPacket *avpkt);
133
134 /**
135 * Supported formats
136 */
137 extern const enum AVPixelFormat ff_amf_pix_fmts[];
138
139 /**
140 * Error handling helper
141 */
142 #define AMF_RETURN_IF_FALSE(avctx, exp, ret_value, /*message,*/ ...) \
143     if (!(exp)) { \
144         av_log(avctx, AV_LOG_ERROR, __VA_ARGS__); \
145         return ret_value; \
146     }
147
148 #endif //AVCODEC_AMFENC_H