FFmpeg
Loading...
Searching...
No Matches
libopenh264enc.c
Go to the documentation of this file.
1/*
2 * OpenH264 video encoder
3 * Copyright (C) 2014 Martin Storsjo
4 *
5 * This file is part of FFmpeg.
6 *
7 * FFmpeg is free software; you can redistribute it and/or
8 * modify it under the terms of the GNU Lesser General Public
9 * License as published by the Free Software Foundation; either
10 * version 2.1 of the License, or (at your option) any later version.
11 *
12 * FFmpeg is distributed in the hope that it will be useful,
13 * but WITHOUT ANY WARRANTY; without even the implied warranty of
14 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
15 * Lesser General Public License for more details.
16 *
17 * You should have received a copy of the GNU Lesser General Public
18 * License along with FFmpeg; if not, write to the Free Software
19 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
20 */
21
22#include <wels/codec_api.h>
23#include <wels/codec_ver.h>
24
26#include "libavutil/common.h"
27#include "libavutil/mem.h"
28#include "libavutil/opt.h"
29#include "libavutil/internal.h"
32
33#include "avcodec.h"
34#include "codec_internal.h"
35#include "encode.h"
36#include "libopenh264.h"
37
38#if !OPENH264_VER_AT_LEAST(1, 6)
39#define SM_SIZELIMITED_SLICE SM_DYN_SLICE
40#endif
41
42#define TARGET_BITRATE_DEFAULT 2*1000*1000
43
44typedef struct SVCContext {
46 ISVCEncoder *encoder;
53 int coder;
54
55 // rate control mode
58
59#define OFFSET(x) offsetof(SVCContext, x)
60#define VE AV_OPT_FLAG_VIDEO_PARAM | AV_OPT_FLAG_ENCODING_PARAM
61#define DEPRECATED AV_OPT_FLAG_DEPRECATED
62static const AVOption options[] = {
63 { "loopfilter", "enable loop filter", OFFSET(loopfilter), AV_OPT_TYPE_INT, { .i64 = 1 }, 0, 1, VE },
64 { "profile", "set profile restrictions", OFFSET(profile), AV_OPT_TYPE_INT, { .i64 = AV_PROFILE_UNKNOWN }, AV_PROFILE_UNKNOWN, 0xffff, VE, .unit = "profile" },
65#define PROFILE(name, value) name, NULL, 0, AV_OPT_TYPE_CONST, { .i64 = value }, 0, 0, VE, .unit = "profile"
66 { PROFILE("constrained_baseline", AV_PROFILE_H264_CONSTRAINED_BASELINE) },
67 { PROFILE("main", AV_PROFILE_H264_MAIN) },
68 { PROFILE("high", AV_PROFILE_H264_HIGH) },
69#undef PROFILE
70 { "max_nal_size", "set maximum NAL size in bytes", OFFSET(max_nal_size), AV_OPT_TYPE_INT, { .i64 = 0 }, 0, INT_MAX, VE },
71 { "allow_skip_frames", "allow skipping frames to hit the target bitrate", OFFSET(skip_frames), AV_OPT_TYPE_BOOL, { .i64 = 0 }, 0, 1, VE },
72 { "coder", "Coder type", OFFSET(coder), AV_OPT_TYPE_INT, { .i64 = -1 }, -1, 1, VE, .unit = "coder" },
73 { "default", NULL, 0, AV_OPT_TYPE_CONST, { .i64 = -1 }, INT_MIN, INT_MAX, VE, .unit = "coder" },
74 { "cavlc", NULL, 0, AV_OPT_TYPE_CONST, { .i64 = 0 }, INT_MIN, INT_MAX, VE, .unit = "coder" },
75 { "cabac", NULL, 0, AV_OPT_TYPE_CONST, { .i64 = 1 }, INT_MIN, INT_MAX, VE, .unit = "coder" },
76 { "vlc", NULL, 0, AV_OPT_TYPE_CONST, { .i64 = 0 }, INT_MIN, INT_MAX, VE, .unit = "coder" },
77 { "ac", NULL, 0, AV_OPT_TYPE_CONST, { .i64 = 1 }, INT_MIN, INT_MAX, VE, .unit = "coder" },
78
79 { "rc_mode", "Select rate control mode", OFFSET(rc_mode), AV_OPT_TYPE_INT, { .i64 = RC_QUALITY_MODE }, RC_OFF_MODE, RC_TIMESTAMP_MODE, VE, .unit = "rc_mode" },
80 { "off", "bit rate control off", 0, AV_OPT_TYPE_CONST, { .i64 = RC_OFF_MODE }, 0, 0, VE, .unit = "rc_mode" },
81 { "quality", "quality mode", 0, AV_OPT_TYPE_CONST, { .i64 = RC_QUALITY_MODE }, 0, 0, VE, .unit = "rc_mode" },
82 { "bitrate", "bitrate mode", 0, AV_OPT_TYPE_CONST, { .i64 = RC_BITRATE_MODE }, 0, 0, VE, .unit = "rc_mode" },
83 { "buffer", "using buffer status to adjust the video quality (no bitrate control)", 0, AV_OPT_TYPE_CONST, { .i64 = RC_BUFFERBASED_MODE }, 0, 0, VE, .unit = "rc_mode" },
84#if OPENH264_VER_AT_LEAST(1, 4)
85 { "timestamp", "bit rate control based on timestamp", 0, AV_OPT_TYPE_CONST, { .i64 = RC_TIMESTAMP_MODE }, 0, 0, VE, .unit = "rc_mode" },
86#endif
87
88 { NULL }
89};
90
91static const AVClass class = {
92 .class_name = "libopenh264enc",
94 .option = options,
96};
97
99{
100 SVCContext *s = avctx->priv_data;
101
102 if (s->encoder)
103 WelsDestroySVCEncoder(s->encoder);
104 if (s->skipped > 0)
105 av_log(avctx, AV_LOG_WARNING, "%d frames skipped\n", s->skipped);
106 return 0;
107}
108
110{
111 SVCContext *s = avctx->priv_data;
112 SEncParamExt param = { 0 };
113 int log_level;
114 WelsTraceCallback callback_function;
115 AVCPBProperties *props;
116
117 if (WelsCreateSVCEncoder(&s->encoder)) {
118 av_log(avctx, AV_LOG_ERROR, "Unable to create encoder\n");
119 return AVERROR_UNKNOWN;
120 }
121
122 // Pass all libopenh264 messages to our callback, to allow ourselves to filter them.
123 log_level = WELS_LOG_DETAIL;
124 (*s->encoder)->SetOption(s->encoder, ENCODER_OPTION_TRACE_LEVEL, &log_level);
125
126 // Set the logging callback function to one that uses av_log() (see implementation above).
127 callback_function = (WelsTraceCallback) ff_libopenh264_trace_callback;
128 (*s->encoder)->SetOption(s->encoder, ENCODER_OPTION_TRACE_CALLBACK, &callback_function);
129
130 // Set the AVCodecContext as the libopenh264 callback context so that it can be passed to av_log().
131 (*s->encoder)->SetOption(s->encoder, ENCODER_OPTION_TRACE_CALLBACK_CONTEXT, &avctx);
132
133 (*s->encoder)->GetDefaultParams(s->encoder, &param);
134
135 if (avctx->framerate.num > 0 && avctx->framerate.den > 0) {
136 param.fMaxFrameRate = av_q2d(avctx->framerate);
137 } else {
138 param.fMaxFrameRate = 1.0 / av_q2d(avctx->time_base);
139 }
140 param.iPicWidth = avctx->width;
141 param.iPicHeight = avctx->height;
142 param.iTargetBitrate = avctx->bit_rate > 0 ? avctx->bit_rate : TARGET_BITRATE_DEFAULT;
143 param.iMaxBitrate = FFMAX(avctx->rc_max_rate, avctx->bit_rate);
144 param.iRCMode = s->rc_mode;
145 if (avctx->qmax >= 0)
146 param.iMaxQp = av_clip(avctx->qmax, 1, 51);
147 if (avctx->qmin >= 0)
148 param.iMinQp = av_clip(avctx->qmin, 1, param.iMaxQp);
149 param.iTemporalLayerNum = 1;
150 param.iSpatialLayerNum = 1;
151 param.bEnableDenoise = 0;
152 param.bEnableBackgroundDetection = 1;
153 param.bEnableAdaptiveQuant = 1;
154 param.bEnableFrameSkip = s->skip_frames;
155 param.bEnableLongTermReference = 0;
156 param.iLtrMarkPeriod = 30;
157 if (avctx->gop_size >= 0)
158 param.uiIntraPeriod = avctx->gop_size;
159#if OPENH264_VER_AT_LEAST(1, 4)
160 param.eSpsPpsIdStrategy = CONSTANT_ID;
161#else
162 param.bEnableSpsPpsIdAddition = 0;
163#endif
164 param.bPrefixNalAddingCtrl = 0;
165 param.iLoopFilterDisableIdc = !s->loopfilter;
166 param.iEntropyCodingModeFlag = s->coder >= 0 ? s->coder : 1;
167 param.iMultipleThreadIdc = avctx->thread_count;
168
169 /* Allow specifying the libopenh264 profile through AVCodecContext. */
170 if (AV_PROFILE_UNKNOWN == s->profile &&
171 AV_PROFILE_UNKNOWN != avctx->profile)
172 switch (avctx->profile) {
176 s->profile = avctx->profile;
177 break;
178 default:
179 av_log(avctx, AV_LOG_WARNING,
180 "Unsupported avctx->profile: %d.\n", avctx->profile);
181 break;
182 }
183
184 if (s->profile == AV_PROFILE_UNKNOWN && s->coder >= 0)
185 s->profile = s->coder == 0 ? AV_PROFILE_H264_CONSTRAINED_BASELINE :
186#if OPENH264_VER_AT_LEAST(1, 8)
188#else
190#endif
191
192 switch (s->profile) {
194 av_log(avctx, AV_LOG_VERBOSE, "Using %s, "
195 "select EProfileIdc PRO_HIGH in libopenh264.\n",
196 param.iEntropyCodingModeFlag ? "CABAC" : "CAVLC");
197 break;
199 av_log(avctx, AV_LOG_VERBOSE, "Using %s, "
200 "select EProfileIdc PRO_MAIN in libopenh264.\n",
201 param.iEntropyCodingModeFlag ? "CABAC" : "CAVLC");
202 break;
206 param.iEntropyCodingModeFlag = 0;
207 av_log(avctx, AV_LOG_VERBOSE, "Using CAVLC, "
208 "select EProfileIdc PRO_BASELINE in libopenh264.\n");
209 break;
210 default:
212 param.iEntropyCodingModeFlag = 0;
213 av_log(avctx, AV_LOG_WARNING, "Unsupported profile, "
214 "select EProfileIdc PRO_BASELINE in libopenh264.\n");
215 break;
216 }
217
218 param.sSpatialLayers[0].iVideoWidth = param.iPicWidth;
219 param.sSpatialLayers[0].iVideoHeight = param.iPicHeight;
220 param.sSpatialLayers[0].fFrameRate = param.fMaxFrameRate;
221 param.sSpatialLayers[0].iSpatialBitrate = param.iTargetBitrate;
222 param.sSpatialLayers[0].iMaxSpatialBitrate = param.iMaxBitrate;
223 param.sSpatialLayers[0].uiProfileIdc = s->profile;
224
225#if OPENH264_VER_AT_LEAST(1, 7)
226 if (avctx->sample_aspect_ratio.num && avctx->sample_aspect_ratio.den) {
227 // Table E-1.
228 static const AVRational sar_idc[] = {
229 { 0, 0 }, // Unspecified (never written here).
230 { 1, 1 }, { 12, 11 }, { 10, 11 }, { 16, 11 },
231 { 40, 33 }, { 24, 11 }, { 20, 11 }, { 32, 11 },
232 { 80, 33 }, { 18, 11 }, { 15, 11 }, { 64, 33 },
233 { 160, 99 }, // Last 3 are unknown to openh264: { 4, 3 }, { 3, 2 }, { 2, 1 },
234 };
235 static const ESampleAspectRatio asp_idc[] = {
236 ASP_UNSPECIFIED,
237 ASP_1x1, ASP_12x11, ASP_10x11, ASP_16x11,
238 ASP_40x33, ASP_24x11, ASP_20x11, ASP_32x11,
239 ASP_80x33, ASP_18x11, ASP_15x11, ASP_64x33,
240 ASP_160x99,
241 };
242 int num, den, i;
243
244 av_reduce(&num, &den, avctx->sample_aspect_ratio.num,
245 avctx->sample_aspect_ratio.den, 65535);
246
247 for (i = 1; i < FF_ARRAY_ELEMS(sar_idc); i++) {
248 if (num == sar_idc[i].num &&
249 den == sar_idc[i].den)
250 break;
251 }
252 if (i == FF_ARRAY_ELEMS(sar_idc)) {
253 param.sSpatialLayers[0].eAspectRatio = ASP_EXT_SAR;
254 param.sSpatialLayers[0].sAspectRatioExtWidth = num;
255 param.sSpatialLayers[0].sAspectRatioExtHeight = den;
256 } else {
257 param.sSpatialLayers[0].eAspectRatio = asp_idc[i];
258 }
259 param.sSpatialLayers[0].bAspectRatioPresent = true;
260 } else {
261 param.sSpatialLayers[0].bAspectRatioPresent = false;
262 }
263#endif
264
265 if ((avctx->slices > 1) && (s->max_nal_size)) {
266 av_log(avctx, AV_LOG_ERROR,
267 "Invalid combination -slices %d and -max_nal_size %d.\n",
268 avctx->slices, s->max_nal_size);
269 return AVERROR(EINVAL);
270 }
271
272 if (avctx->slices > 1)
273 s->slice_mode = SM_FIXEDSLCNUM_SLICE;
274
275 if (s->max_nal_size)
276 s->slice_mode = SM_SIZELIMITED_SLICE;
277
278#if OPENH264_VER_AT_LEAST(1, 6)
279 param.sSpatialLayers[0].sSliceArgument.uiSliceMode = s->slice_mode;
280 param.sSpatialLayers[0].sSliceArgument.uiSliceNum = avctx->slices;
281#else
282 param.sSpatialLayers[0].sSliceCfg.uiSliceMode = s->slice_mode;
283 param.sSpatialLayers[0].sSliceCfg.sSliceArgument.uiSliceNum = avctx->slices;
284#endif
285 if (avctx->slices == 0 && s->slice_mode == SM_FIXEDSLCNUM_SLICE)
286 av_log(avctx, AV_LOG_WARNING, "Slice count will be set automatically\n");
287
288 if (s->slice_mode == SM_SIZELIMITED_SLICE) {
289 if (s->max_nal_size) {
290 param.uiMaxNalSize = s->max_nal_size;
291#if OPENH264_VER_AT_LEAST(1, 6)
292 param.sSpatialLayers[0].sSliceArgument.uiSliceSizeConstraint = s->max_nal_size;
293#else
294 param.sSpatialLayers[0].sSliceCfg.sSliceArgument.uiSliceSizeConstraint = s->max_nal_size;
295#endif
296 } else {
297 av_log(avctx, AV_LOG_ERROR, "Invalid -max_nal_size, "
298 "specify a valid max_nal_size to use -slice_mode dyn\n");
299 return AVERROR(EINVAL);
300 }
301 }
302
303#if OPENH264_VER_AT_LEAST(1, 6)
304 param.sSpatialLayers[0].uiVideoFormat = VF_UNDEF;
305
306 if (avctx->color_range != AVCOL_RANGE_UNSPECIFIED) {
307 param.sSpatialLayers[0].bFullRange = (avctx->color_range == AVCOL_RANGE_JPEG);
308 } else if (avctx->pix_fmt == AV_PIX_FMT_YUVJ420P)
309 param.sSpatialLayers[0].bFullRange = 1;
310
311 if (avctx->colorspace != AVCOL_SPC_UNSPECIFIED ||
314 param.sSpatialLayers[0].bColorDescriptionPresent = true;
315 }
316
317 if (avctx->colorspace != AVCOL_SPC_UNSPECIFIED)
318 param.sSpatialLayers[0].uiColorMatrix = avctx->colorspace;
320 param.sSpatialLayers[0].uiColorPrimaries = avctx->color_primaries;
321 if (avctx->color_trc != AVCOL_TRC_UNSPECIFIED)
322 param.sSpatialLayers[0].uiTransferCharacteristics = avctx->color_trc;
323
324 param.sSpatialLayers[0].bVideoSignalTypePresent =
325 (param.sSpatialLayers[0].bFullRange || param.sSpatialLayers[0].bColorDescriptionPresent);
326#endif
327
328 if ((*s->encoder)->InitializeExt(s->encoder, &param) != cmResultSuccess) {
329 av_log(avctx, AV_LOG_ERROR, "Initialize failed\n");
330 return AVERROR_UNKNOWN;
331 }
332
333 if (avctx->flags & AV_CODEC_FLAG_GLOBAL_HEADER) {
334 SFrameBSInfo fbi = { 0 };
335 int i, size = 0;
336 (*s->encoder)->EncodeParameterSets(s->encoder, &fbi);
337 for (i = 0; i < fbi.sLayerInfo[0].iNalCount; i++)
338 size += fbi.sLayerInfo[0].pNalLengthInByte[i];
340 if (!avctx->extradata)
341 return AVERROR(ENOMEM);
342 avctx->extradata_size = size;
343 memcpy(avctx->extradata, fbi.sLayerInfo[0].pBsBuf, size);
344 }
345
346 props = ff_encode_add_cpb_side_data(avctx);
347 if (!props)
348 return AVERROR(ENOMEM);
349 props->max_bitrate = param.iMaxBitrate;
350 props->avg_bitrate = param.iTargetBitrate;
351
352 return 0;
353}
354
355static int svc_encode_frame(AVCodecContext *avctx, AVPacket *avpkt,
356 const AVFrame *frame, int *got_packet)
357{
358 SVCContext *s = avctx->priv_data;
359 SFrameBSInfo fbi = { 0 };
360 int i, ret;
361 int encoded;
362 SSourcePicture sp = { 0 };
363 int size = 0, layer, first_layer = 0;
364 int layer_size[MAX_LAYER_NUM_OF_FRAME] = { 0 };
365
366 sp.iColorFormat = videoFormatI420;
367 for (i = 0; i < 3; i++) {
368 sp.iStride[i] = frame->linesize[i];
369 sp.pData[i] = frame->data[i];
370 }
371 sp.iPicWidth = avctx->width;
372 sp.iPicHeight = avctx->height;
373
374 if (frame->pict_type == AV_PICTURE_TYPE_I) {
375 (*s->encoder)->ForceIntraFrame(s->encoder, true);
376 }
377
378 encoded = (*s->encoder)->EncodeFrame(s->encoder, &sp, &fbi);
379 if (encoded != cmResultSuccess) {
380 av_log(avctx, AV_LOG_ERROR, "EncodeFrame failed\n");
381 return AVERROR_UNKNOWN;
382 }
383 if (fbi.eFrameType == videoFrameTypeSkip) {
384 s->skipped++;
385 av_log(avctx, AV_LOG_DEBUG, "frame skipped\n");
386 return 0;
387 }
388 first_layer = 0;
389 // Normal frames are returned with one single layer, while IDR
390 // frames have two layers, where the first layer contains the SPS/PPS.
391 // If using global headers, don't include the SPS/PPS in the returned
392 // packet - thus, only return one layer.
394 first_layer = fbi.iLayerNum - 1;
395
396 for (layer = first_layer; layer < fbi.iLayerNum; layer++) {
397 for (i = 0; i < fbi.sLayerInfo[layer].iNalCount; i++)
398 layer_size[layer] += fbi.sLayerInfo[layer].pNalLengthInByte[i];
399 size += layer_size[layer];
400 }
401 av_log(avctx, AV_LOG_DEBUG, "%d slices\n", fbi.sLayerInfo[fbi.iLayerNum - 1].iNalCount);
402
403 if ((ret = ff_get_encode_buffer(avctx, avpkt, size, 0)))
404 return ret;
405
406 size = 0;
407 for (layer = first_layer; layer < fbi.iLayerNum; layer++) {
408 memcpy(avpkt->data + size, fbi.sLayerInfo[layer].pBsBuf, layer_size[layer]);
409 size += layer_size[layer];
410 }
411 avpkt->pts = frame->pts;
412 if (fbi.eFrameType == videoFrameTypeIDR)
413 avpkt->flags |= AV_PKT_FLAG_KEY;
414 *got_packet = 1;
415 return 0;
416}
417
419 { "b", "0" },
420 { "g", "-1" },
421 { "qmin", "-1" },
422 { "qmax", "-1" },
423 { NULL },
424};
425
427 .p.name = "libopenh264",
428 CODEC_LONG_NAME("OpenH264 H.264 / AVC / MPEG-4 AVC / MPEG-4 part 10"),
429 .p.type = AVMEDIA_TYPE_VIDEO,
430 .p.id = AV_CODEC_ID_H264,
431 .p.capabilities = AV_CODEC_CAP_DR1 | AV_CODEC_CAP_OTHER_THREADS |
433 .priv_data_size = sizeof(SVCContext),
436 .close = svc_encode_close,
437 .caps_internal = FF_CODEC_CAP_INIT_CLEANUP |
440 .color_ranges = AVCOL_RANGE_MPEG | AVCOL_RANGE_JPEG,
441 .defaults = svc_enc_defaults,
442 .p.priv_class = &class,
443 .p.wrapper_name = "libopenh264",
444};
const FFCodec ff_libopenh264_encoder
#define VE
Definition amfenc_av1.c:30
Libavcodec external API header.
#define i(width, name, range_min, range_max)
Definition cbs_h264.c:63
#define s(width, name)
Definition cbs_vp9.c:198
#define CODEC_PIXFMTS(...)
#define FF_CODEC_ENCODE_CB(func)
#define CODEC_LONG_NAME(str)
#define FF_CODEC_CAP_INIT_CLEANUP
The codec allows calling the close function for deallocation even if the init function returned a fai...
#define FF_CODEC_CAP_AUTO_THREADS
Codec handles avctx->thread_count == 0 (auto) internally.
common internal and external API header
#define av_clip
Definition common.h:100
#define NULL
Definition coverity.c:32
#define AV_PROFILE_H264_MAIN
Definition defs.h:112
#define AV_PROFILE_UNKNOWN
Definition defs.h:65
#define AV_PROFILE_H264_HIGH
Definition defs.h:114
#define AV_PROFILE_H264_CONSTRAINED_BASELINE
Definition defs.h:111
static AVFrame * frame
int(* init)(AVBSFContext *ctx)
Definition dts2pts.c:608
int ff_get_encode_buffer(AVCodecContext *avctx, AVPacket *avpkt, int64_t size, int flags)
Get a buffer for a packet.
Definition encode.c:106
AVCPBProperties * ff_encode_add_cpb_side_data(AVCodecContext *avctx)
Add a CPB properties side data to an encoding context.
Definition encode.c:1039
@ AV_OPT_TYPE_CONST
Special option type for declaring named constants.
Definition opt.h:298
@ AV_OPT_TYPE_INT
Underlying C type is int.
Definition opt.h:258
@ AV_OPT_TYPE_BOOL
Underlying C type is int.
Definition opt.h:326
#define AV_CODEC_CAP_ENCODER_REORDERED_OPAQUE
This encoder can reorder user opaque values from input AVFrames and return them with corresponding ou...
Definition codec.h:147
#define AV_CODEC_CAP_OTHER_THREADS
Codec supports multithreading through a method other than slice- or frame-level multithreading.
Definition codec.h:112
#define AV_CODEC_CAP_DR1
Codec uses get_buffer() or get_encode_buffer() for allocating buffers and supports custom allocators.
Definition codec.h:49
#define AV_CODEC_FLAG_GLOBAL_HEADER
Place global headers in extradata instead of every keyframe.
Definition avcodec.h:318
@ AV_CODEC_ID_H264
Definition codec_id.h:77
#define AV_INPUT_BUFFER_PADDING_SIZE
Required number of additionally allocated bytes at the end of the input bitstream for decoding.
Definition defs.h:40
#define AV_PKT_FLAG_KEY
The packet contains a keyframe.
Definition packet.h:650
#define AVERROR_UNKNOWN
Unknown error, typically from an external library.
Definition error.h:73
#define AVERROR(e)
Definition error.h:45
#define AV_LOG_DEBUG
Stuff which is only useful for libav* developers.
Definition log.h:231
#define AV_LOG_WARNING
Something somehow does not look correct.
Definition log.h:216
#define AV_LOG_VERBOSE
Detailed information.
Definition log.h:226
#define AV_LOG_ERROR
Something went wrong and cannot losslessly be recovered.
Definition log.h:210
const char * av_default_item_name(void *ptr)
Return the context name.
Definition log.c:241
int av_reduce(int *dst_num, int *dst_den, int64_t num, int64_t den, int64_t max)
Reduce a fraction.
Definition rational.c:35
static double av_q2d(AVRational a)
Convert an AVRational to a double.
Definition rational.h:104
@ AVMEDIA_TYPE_VIDEO
Definition avutil.h:200
@ AV_PICTURE_TYPE_I
Intra.
Definition avutil.h:278
#define LIBAVUTIL_VERSION_INT
Definition version.h:85
Macro definitions for various function/variable attributes.
#define av_cold
Definition attributes.h:117
common internal API header
void ff_libopenh264_trace_callback(void *ctx, int level, const char *msg)
Definition libopenh264.c:42
static av_cold int svc_encode_close(AVCodecContext *avctx)
static av_cold int svc_encode_init(AVCodecContext *avctx)
#define SM_SIZELIMITED_SLICE
#define PROFILE(name, value)
static int svc_encode_frame(AVCodecContext *avctx, AVPacket *avpkt, const AVFrame *frame, int *got_packet)
#define TARGET_BITRATE_DEFAULT
#define OFFSET(x)
static const FFCodecDefault svc_enc_defaults[]
#define FFMAX(a, b)
Definition macros.h:47
Memory handling functions.
int profile
Definition mxfenc.c:2299
AVOptions.
@ AVCOL_RANGE_MPEG
Narrow or limited range content.
Definition pixfmt.h:766
@ AVCOL_RANGE_UNSPECIFIED
Definition pixfmt.h:749
@ AVCOL_RANGE_JPEG
Full range content.
Definition pixfmt.h:783
@ AV_PIX_FMT_YUV420P
planar YUV 4:2:0, 12bpp, (1 Cr & Cb sample per 2x2 Y samples)
Definition pixfmt.h:73
@ AV_PIX_FMT_YUVJ420P
planar YUV 4:2:0, 12bpp, full scale (JPEG), deprecated in favor of AV_PIX_FMT_YUV420P and setting col...
Definition pixfmt.h:85
@ AVCOL_PRI_UNSPECIFIED
Definition pixfmt.h:645
@ AVCOL_TRC_UNSPECIFIED
Definition pixfmt.h:675
@ AVCOL_SPC_UNSPECIFIED
Definition pixfmt.h:709
mfxU16 rc_mode
Definition qsvenc.c:141
#define FF_ARRAY_ELEMS(a)
This structure describes the bitrate properties of an encoded bitstream.
Definition defs.h:282
int64_t avg_bitrate
Average bitrate of the stream, in bits per second.
Definition defs.h:297
int64_t max_bitrate
Maximum bitrate of the stream, in bits per second.
Definition defs.h:287
Describe the class of an AVClass context structure.
Definition log.h:76
const char * class_name
The name of the class; usually it is the same name as the context structure type to which the AVClass...
Definition log.h:81
main external API structure.
Definition avcodec.h:443
enum AVPixelFormat pix_fmt
Pixel format, see AV_PIX_FMT_xxx.
Definition avcodec.h:643
int width
picture width / height.
Definition avcodec.h:604
enum AVColorRange color_range
MPEG vs JPEG YUV range.
Definition avcodec.h:681
enum AVColorPrimaries color_primaries
Chromaticity coordinates of the source primaries.
Definition avcodec.h:657
int qmin
minimum quantizer
Definition avcodec.h:1252
AVRational framerate
Definition avcodec.h:563
AVRational sample_aspect_ratio
sample aspect ratio (0 if unknown) That is the width of a pixel divided by the height of the pixel.
Definition avcodec.h:628
int64_t bit_rate
the average bitrate
Definition avcodec.h:493
int profile
profile
Definition avcodec.h:1636
enum AVColorSpace colorspace
YUV colorspace type.
Definition avcodec.h:671
int gop_size
the number of pictures in a group of pictures, or 0 for intra_only
Definition avcodec.h:1021
int64_t rc_max_rate
maximum bitrate
Definition avcodec.h:1288
int thread_count
thread count is used to decide how many independent tasks should be passed to execute()
Definition avcodec.h:1579
int qmax
maximum quantizer
Definition avcodec.h:1259
enum AVColorTransferCharacteristic color_trc
Color Transfer Characteristic.
Definition avcodec.h:664
AVRational time_base
This is the fundamental unit of time (in seconds) in terms of which frame timestamps are represented.
Definition avcodec.h:547
int flags
AV_CODEC_FLAG_*.
Definition avcodec.h:500
uint8_t * extradata
Out-of-band global headers that may be used by some codecs.
Definition avcodec.h:526
int extradata_size
Definition avcodec.h:527
void * priv_data
Definition avcodec.h:470
int slices
Number of slices.
Definition avcodec.h:1037
This structure describes decoded (raw) audio or video data.
Definition frame.h:472
AVOption.
Definition opt.h:428
This structure stores compressed data.
Definition packet.h:580
int flags
A combination of AV_PKT_FLAG values.
Definition packet.h:609
int64_t pts
Presentation timestamp in AVStream->time_base units; the time at which the decompressed packet will b...
Definition packet.h:596
uint8_t * data
Definition packet.h:603
Rational number (pair of numerator and denominator).
Definition rational.h:58
int num
Numerator.
Definition rational.h:59
int den
Denominator.
Definition rational.h:60
const AVClass * av_class
ISVCEncoder * encoder
#define av_mallocz(s)
#define av_log(a,...)
int size