FFmpeg
Loading...
Searching...
No Matches
avcodec.c
Go to the documentation of this file.
1/*
2 * AVCodecContext functions for libavcodec
3 *
4 * This file is part of FFmpeg.
5 *
6 * FFmpeg is free software; you can redistribute it and/or
7 * modify it under the terms of the GNU Lesser General Public
8 * License as published by the Free Software Foundation; either
9 * version 2.1 of the License, or (at your option) any later version.
10 *
11 * FFmpeg is distributed in the hope that it will be useful,
12 * but WITHOUT ANY WARRANTY; without even the implied warranty of
13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
14 * Lesser General Public License for more details.
15 *
16 * You should have received a copy of the GNU Lesser General Public
17 * License along with FFmpeg; if not, write to the Free Software
18 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
19 */
20
21/**
22 * @file
23 * AVCodecContext functions for libavcodec
24 */
25
26#include <assert.h>
27
28#include "config.h"
29#include "libavutil/avassert.h"
30#include "libavutil/avstring.h"
31#include "libavutil/bprint.h"
33#include "libavutil/common.h"
34#include "libavutil/emms.h"
35#include "libavutil/imgutils.h"
36#include "libavutil/mem.h"
37#include "libavutil/opt.h"
38#include "libavutil/thread.h"
39#include "avcodec.h"
40#include "avcodec_internal.h"
41#include "bsf.h"
42#include "codec_desc.h"
43#include "codec_internal.h"
44#include "decode.h"
46#include "hwconfig.h"
47#include "internal.h"
48#include "libavutil/refstruct.h"
49
50/**
51 * Maximum size in bytes of extradata.
52 * This value was chosen such that every bit of the buffer is
53 * addressable by a 32-bit signed integer as used by get_bits.
54 */
55#define FF_MAX_EXTRADATA_SIZE ((1 << 28) - AV_INPUT_BUFFER_PADDING_SIZE)
56
72
73
74int avcodec_default_execute(AVCodecContext *c, int (*func)(AVCodecContext *c2, void *arg2), void *arg, int *ret, int count, int size)
75{
76 size_t i;
77
78 for (i = 0; i < count; i++) {
79 size_t offset = i * size;
80 int r = func(c, FF_PTR_ADD((char *)arg, offset));
81 if (ret)
82 ret[i] = r;
83 }
84 emms_c();
85 return 0;
86}
87
88int avcodec_default_execute2(AVCodecContext *c, int (*func)(AVCodecContext *c2, void *arg2, int jobnr, int threadnr), void *arg, int *ret, int count)
89{
90 int i;
91
92 for (i = 0; i < count; i++) {
93 int r = func(c, arg, i, 0);
94 if (ret)
95 ret[i] = r;
96 }
97 emms_c();
98 return 0;
99}
100
102
103static void lock_avcodec(const FFCodec *codec)
104{
107}
108
109static void unlock_avcodec(const FFCodec *codec)
110{
113}
114
116{
117 int64_t bit_rate;
118 int bits_per_sample;
119
120 switch (ctx->codec_type) {
125 bit_rate = ctx->bit_rate;
126 break;
128 bits_per_sample = av_get_bits_per_sample(ctx->codec_id);
129 if (bits_per_sample) {
130 bit_rate = ctx->sample_rate * (int64_t)ctx->ch_layout.nb_channels;
131 if (bit_rate > INT64_MAX / bits_per_sample) {
132 bit_rate = 0;
133 } else
134 bit_rate *= bits_per_sample;
135 } else
136 bit_rate = ctx->bit_rate;
137 break;
138 default:
139 bit_rate = 0;
140 break;
141 }
142 return bit_rate;
143}
144
146{
147 int ret = 0;
148 AVCodecInternal *avci;
149 const FFCodec *codec2;
150 const AVDictionaryEntry *e;
151
152 if (avcodec_is_open(avctx))
153 return 0;
154
155 if (!codec && !avctx->codec) {
156 av_log(avctx, AV_LOG_ERROR, "No codec provided to avcodec_open2()\n");
157 return AVERROR(EINVAL);
158 }
159 if (codec && avctx->codec && codec != avctx->codec) {
160 av_log(avctx, AV_LOG_ERROR, "This AVCodecContext was allocated for %s, "
161 "but %s passed to avcodec_open2()\n", avctx->codec->name, codec->name);
162 return AVERROR(EINVAL);
163 }
164 if (!codec)
165 codec = avctx->codec;
166 codec2 = ffcodec(codec);
167
168 if ((avctx->codec_type != AVMEDIA_TYPE_UNKNOWN && avctx->codec_type != codec->type) ||
169 (avctx->codec_id != AV_CODEC_ID_NONE && avctx->codec_id != codec->id)) {
170 av_log(avctx, AV_LOG_ERROR, "Codec type or id mismatches\n");
171 return AVERROR(EINVAL);
172 }
173
174 avctx->codec_type = codec->type;
175 avctx->codec_id = codec->id;
176 avctx->codec = codec;
177
178 if (avctx->extradata_size < 0 || avctx->extradata_size >= FF_MAX_EXTRADATA_SIZE)
179 return AVERROR(EINVAL);
180
181 // set the whitelist from provided options dict,
182 // so we can check it immediately
183 e = options ? av_dict_get(*options, "codec_whitelist", NULL, 0) : NULL;
184 if (e) {
185 ret = av_opt_set(avctx, e->key, e->value, 0);
186 if (ret < 0)
187 return ret;
188 }
189
190 if (avctx->codec_whitelist && av_match_list(codec->name, avctx->codec_whitelist, ',') <= 0) {
191 av_log(avctx, AV_LOG_ERROR, "Codec (%s) not on whitelist \'%s\'\n", codec->name, avctx->codec_whitelist);
192 return AVERROR(EINVAL);
193 }
194
195 avci = ff_codec_is_decoder(codec) ?
198 if (!avci) {
199 ret = AVERROR(ENOMEM);
200 goto end;
201 }
202 avctx->internal = avci;
203
205 avci->buffer_pkt = av_packet_alloc();
206 if (!avci->buffer_frame || !avci->buffer_pkt) {
207 ret = AVERROR(ENOMEM);
208 goto free_and_end;
209 }
210
211 if (codec2->priv_data_size > 0) {
212 if (!avctx->priv_data) {
213 avctx->priv_data = av_mallocz(codec2->priv_data_size);
214 if (!avctx->priv_data) {
215 ret = AVERROR(ENOMEM);
216 goto free_and_end;
217 }
218 if (codec->priv_class) {
219 *(const AVClass **)avctx->priv_data = codec->priv_class;
221 }
222 }
223 } else {
224 avctx->priv_data = NULL;
225 }
226
228 if (ret < 0)
229 goto free_and_end;
230
231 // only call ff_set_dimensions() for non H.264/VP6F/DXV codecs so as not to overwrite previously setup dimensions
232 if (!(avctx->coded_width && avctx->coded_height && avctx->width && avctx->height &&
233 (avctx->codec_id == AV_CODEC_ID_H264 || avctx->codec_id == AV_CODEC_ID_VP6F || avctx->codec_id == AV_CODEC_ID_DXV))) {
234 if (avctx->coded_width && avctx->coded_height)
235 ret = ff_set_dimensions(avctx, avctx->coded_width, avctx->coded_height);
236 else if (avctx->width && avctx->height)
237 ret = ff_set_dimensions(avctx, avctx->width, avctx->height);
238 if (ret < 0)
239 goto free_and_end;
240 }
241
242 if ((avctx->coded_width || avctx->coded_height || avctx->width || avctx->height)
243 && ( av_image_check_size2(avctx->coded_width, avctx->coded_height, avctx->max_pixels, AV_PIX_FMT_NONE, 0, avctx) < 0
244 || av_image_check_size2(avctx->width, avctx->height, avctx->max_pixels, AV_PIX_FMT_NONE, 0, avctx) < 0)) {
245 av_log(avctx, AV_LOG_WARNING, "Ignoring invalid width/height values\n");
246 ff_set_dimensions(avctx, 0, 0);
247 }
248
249 if (avctx->width > 0 && avctx->height > 0) {
250 if (av_image_check_sar(avctx->width, avctx->height,
251 avctx->sample_aspect_ratio) < 0) {
252 av_log(avctx, AV_LOG_WARNING, "ignoring invalid SAR: %u/%u\n",
254 avctx->sample_aspect_ratio.den);
255 avctx->sample_aspect_ratio = (AVRational){ 0, 1 };
256 }
257 }
258
259 /* AV_CODEC_CAP_CHANNEL_CONF is a decoder-only flag; so the code below
260 * in particular checks that sample_rate is set for all audio encoders. */
261 if (avctx->sample_rate < 0 ||
262 avctx->sample_rate == 0 && avctx->codec_type == AVMEDIA_TYPE_AUDIO &&
264 av_log(avctx, AV_LOG_ERROR, "Invalid sample rate: %d\n", avctx->sample_rate);
265 ret = AVERROR(EINVAL);
266 goto free_and_end;
267 }
268 if (avctx->block_align < 0) {
269 av_log(avctx, AV_LOG_ERROR, "Invalid block align: %d\n", avctx->block_align);
270 ret = AVERROR(EINVAL);
271 goto free_and_end;
272 }
273
274 /* AV_CODEC_CAP_CHANNEL_CONF is a decoder-only flag; so the code below
275 * in particular checks that nb_channels is set for all audio encoders. */
276 if (avctx->codec_type == AVMEDIA_TYPE_AUDIO && !avctx->ch_layout.nb_channels
278 av_log(avctx, AV_LOG_ERROR, "%s requires channel layout to be set\n",
279 ff_codec_is_decoder(codec) ? "Decoder" : "Encoder");
280 ret = AVERROR(EINVAL);
281 goto free_and_end;
282 }
283 if (avctx->ch_layout.nb_channels && !av_channel_layout_check(&avctx->ch_layout)) {
284 av_log(avctx, AV_LOG_ERROR, "Invalid channel layout\n");
285 ret = AVERROR(EINVAL);
286 goto free_and_end;
287 }
289 av_log(avctx, AV_LOG_ERROR, "Too many channels: %d\n", avctx->ch_layout.nb_channels);
290 ret = AVERROR(EINVAL);
291 goto free_and_end;
292 }
293
294 avctx->frame_num = 0;
296
299 const char *codec_string = ff_codec_is_encoder(codec) ? "encoder" : "decoder";
300 const AVCodec *codec2;
301 av_log(avctx, AV_LOG_ERROR,
302 "The %s '%s' is experimental but experimental codecs are not enabled, "
303 "add '-strict %d' if you want to use it.\n",
305 codec2 = ff_codec_is_encoder(codec) ? avcodec_find_encoder(codec->id) : avcodec_find_decoder(codec->id);
307 av_log(avctx, AV_LOG_ERROR, "Alternatively use the non experimental %s '%s'.\n",
308 codec_string, codec2->name);
310 goto free_and_end;
311 }
312
313 if (avctx->codec_type == AVMEDIA_TYPE_AUDIO &&
314 (!avctx->time_base.num || !avctx->time_base.den)) {
315 avctx->time_base.num = 1;
316 avctx->time_base.den = avctx->sample_rate;
317 }
318
319 if (ff_codec_is_encoder(avctx->codec))
320 ret = ff_encode_preinit(avctx);
321 else
322 ret = ff_decode_preinit(avctx);
323 if (ret < 0)
324 goto free_and_end;
325
326 if (HAVE_THREADS && !avci->frame_thread_encoder) {
327 /* Frame-threaded decoders call FFCodec.init for their child contexts. */
328 lock_avcodec(codec2);
329 ret = ff_thread_init(avctx);
330 unlock_avcodec(codec2);
331 if (ret < 0) {
332 goto free_and_end;
333 }
334 }
335 if (!HAVE_THREADS && !(codec2->caps_internal & FF_CODEC_CAP_AUTO_THREADS))
336 avctx->thread_count = 1;
337
338 if (!(avctx->active_thread_type & FF_THREAD_FRAME) ||
339 avci->frame_thread_encoder) {
340 if (codec2->init) {
341 lock_avcodec(codec2);
342 ret = codec2->init(avctx);
343 unlock_avcodec(codec2);
344 if (ret < 0) {
346 goto free_and_end;
347 }
348 }
349 avci->needs_close = 1;
350 }
351
352 ret=0;
353
354 if (ff_codec_is_decoder(avctx->codec)) {
355 if (!avctx->bit_rate)
356 avctx->bit_rate = get_bit_rate(avctx);
357
358
359 if (avctx->codec_type == AVMEDIA_TYPE_AUDIO &&
360 !avctx->frame_size && (avctx->flags2 & AV_CODEC_FLAG2_FIXED_FRAME_SIZE)) {
361 av_log(avctx, AV_LOG_ERROR, "Fixed frame size requested but no frame_size value set\n");
362 ret = AVERROR(EINVAL);
363 goto free_and_end;
364 }
365
366 avci->skip_samples = avctx->delay;
367
368 /* validate channel layout from the decoder */
369 if ((avctx->ch_layout.nb_channels && !av_channel_layout_check(&avctx->ch_layout)) ||
371 ret = AVERROR(EINVAL);
372 goto free_and_end;
373 }
374 if (avctx->bits_per_coded_sample < 0) {
375 ret = AVERROR(EINVAL);
376 goto free_and_end;
377 }
378 }
379 if (codec->priv_class)
380 av_assert0(*(const AVClass **)avctx->priv_data == codec->priv_class);
381
382end:
383
384 return ret;
385free_and_end:
386 ff_codec_close(avctx);
387 goto end;
388}
389
391{
392 AVCodecInternal *avci = avctx->internal;
393
394 if (av_codec_is_encoder(avctx->codec)) {
395 int caps = avctx->codec->capabilities;
396
397 if (!(caps & AV_CODEC_CAP_ENCODER_FLUSH)) {
398 // Only encoders that explicitly declare support for it can be
399 // flushed. Otherwise, this is a no-op.
400 av_log(avctx, AV_LOG_WARNING, "Ignoring attempt to flush encoder "
401 "that doesn't support it\n");
402 return;
403 }
405 } else
407
408 avci->draining = 0;
409 avci->draining_done = 0;
410 if (avci->buffer_frame)
412 if (avci->buffer_pkt)
414
415 if (HAVE_THREADS && avctx->active_thread_type & FF_THREAD_FRAME &&
416 !avci->is_frame_mt)
417 ff_thread_flush(avctx);
418 else if (ffcodec(avctx->codec)->flush)
419 ffcodec(avctx->codec)->flush(avctx);
420}
421
423{
424 int i;
425
426 for (i = 0; i < sub->num_rects; i++) {
427 AVSubtitleRect *const rect = sub->rects[i];
428
429 av_freep(&rect->data[0]);
430 av_freep(&rect->data[1]);
431 av_freep(&rect->data[2]);
432 av_freep(&rect->data[3]);
433 av_freep(&rect->text);
434 av_freep(&rect->ass);
435
436 av_freep(&sub->rects[i]);
437 }
438
439 av_freep(&sub->rects);
440
441 memset(sub, 0, sizeof(*sub));
442}
443
445{
446 int i;
447
448 if (avcodec_is_open(avctx)) {
449 AVCodecInternal *avci = avctx->internal;
450
451#if CONFIG_FRAME_THREAD_ENCODER
452 if (avci->frame_thread_encoder && avctx->thread_count > 1) {
454 }
455#endif
456 if (HAVE_THREADS && avci->thread_ctx)
457 ff_thread_free(avctx);
458 if (avci->needs_close && ffcodec(avctx->codec)->close)
459 ffcodec(avctx->codec)->close(avctx);
460 avci->byte_buffer_size = 0;
461 av_freep(&avci->byte_buffer);
465
466 av_packet_free(&avci->in_pkt);
467 av_frame_free(&avci->in_frame);
469
470 av_refstruct_unref(&avci->pool);
472 if (av_codec_is_decoder(avctx->codec))
474
475 ff_hwaccel_uninit(avctx);
476
477 av_bsf_free(&avci->bsf);
478
479#if CONFIG_LCMS2
480 ff_icc_context_uninit(&avci->icc);
481#endif
482
483 av_freep(&avctx->internal);
484 }
485
486 for (i = 0; i < avctx->nb_coded_side_data; i++)
487 av_freep(&avctx->coded_side_data[i].data);
488 av_freep(&avctx->coded_side_data);
489 avctx->nb_coded_side_data = 0;
491 &avctx->nb_decoded_side_data);
492
495
496 if (avctx->priv_data && avctx->codec && avctx->codec->priv_class)
497 av_opt_free(avctx->priv_data);
498 av_opt_free(avctx);
499 av_freep(&avctx->priv_data);
500 if (av_codec_is_encoder(avctx->codec)) {
501 av_freep(&avctx->extradata);
502 avctx->extradata_size = 0;
503 } else if (av_codec_is_decoder(avctx->codec))
504 av_freep(&avctx->subtitle_header);
505
506 avctx->codec = NULL;
507 avctx->active_thread_type = 0;
508}
509
510static const char *unknown_if_null(const char *str)
511{
512 return str ? str : "unknown";
513}
514
515void avcodec_string(char *buf, int buf_size, AVCodecContext *enc, int encode)
516{
517 const char *codec_type;
518 const char *codec_name;
519 const char *profile = NULL;
520 AVBPrint bprint;
522 int new_line = 0;
523 AVRational display_aspect_ratio;
524 const char *separator = enc->dump_separator ? (const char *)enc->dump_separator : ", ";
525 const char *str;
526
527 if (!buf || buf_size <= 0)
528 return;
529 av_bprint_init_for_buffer(&bprint, buf, buf_size);
531 codec_name = avcodec_get_name(enc->codec_id);
533
534 av_bprintf(&bprint, "%s: %s", codec_type ? codec_type : "unknown",
535 codec_name);
536 buf[0] ^= 'a' ^ 'A'; /* first letter in uppercase */
537
538 if (enc->codec && strcmp(enc->codec->name, codec_name))
539 av_bprintf(&bprint, " (%s)", enc->codec->name);
540
541 if (profile)
542 av_bprintf(&bprint, " (%s)", profile);
543 if ( enc->codec_type == AVMEDIA_TYPE_VIDEO
545 && enc->refs)
546 av_bprintf(&bprint, ", %d reference frame%s",
547 enc->refs, enc->refs > 1 ? "s" : "");
548
549 if (enc->codec_tag)
550 av_bprintf(&bprint, " (%s / 0x%04X)",
551 av_fourcc2str(enc->codec_tag), enc->codec_tag);
552
553 switch (enc->codec_type) {
555 {
556 unsigned len;
557
558 av_bprintf(&bprint, "%s%s", separator,
559 enc->pix_fmt == AV_PIX_FMT_NONE ? "none" :
561
562 av_bprint_chars(&bprint, '(', 1);
563 len = bprint.len;
564
565 /* The following check ensures that '(' has been written
566 * and therefore allows us to erase it if it turns out
567 * to be unnecessary. */
568 if (!av_bprint_is_complete(&bprint))
569 return;
570
571 if (enc->bits_per_raw_sample && enc->pix_fmt != AV_PIX_FMT_NONE &&
572 enc->bits_per_raw_sample < av_pix_fmt_desc_get(enc->pix_fmt)->comp[0].depth)
573 av_bprintf(&bprint, "%d bpc, ", enc->bits_per_raw_sample);
575 (str = av_color_range_name(enc->color_range)))
576 av_bprintf(&bprint, "%s, ", str);
577
578 if (enc->colorspace != AVCOL_SPC_UNSPECIFIED ||
581 const char *col = unknown_if_null(av_color_space_name(enc->colorspace));
583 const char *trc = unknown_if_null(av_color_transfer_name(enc->color_trc));
584 if (strcmp(col, pri) || strcmp(col, trc)) {
585 new_line = 1;
586 av_bprintf(&bprint, "%s/%s/%s, ", col, pri, trc);
587 } else
588 av_bprintf(&bprint, "%s, ", col);
589 }
590
591 if (enc->field_order != AV_FIELD_UNKNOWN) {
592 const char *field_order = "progressive";
593 if (enc->field_order == AV_FIELD_TT)
594 field_order = "top first";
595 else if (enc->field_order == AV_FIELD_BB)
596 field_order = "bottom first";
597 else if (enc->field_order == AV_FIELD_TB)
598 field_order = "top coded first (swapped)";
599 else if (enc->field_order == AV_FIELD_BT)
600 field_order = "bottom coded first (swapped)";
601
602 av_bprintf(&bprint, "%s, ", field_order);
603 }
604
608 av_bprintf(&bprint, "%s, ", str);
609
610 if (len == bprint.len) {
611 bprint.str[len - 1] = '\0';
612 bprint.len--;
613 } else {
614 if (bprint.len - 2 < bprint.size) {
615 /* Erase the last ", " */
616 bprint.len -= 2;
617 bprint.str[bprint.len] = '\0';
618 }
619 av_bprint_chars(&bprint, ')', 1);
620 }
621 }
622
623 if (enc->width) {
624 av_bprintf(&bprint, "%s%dx%d", new_line ? separator : ", ",
625 enc->width, enc->height);
626
628 enc->coded_width && enc->coded_height &&
629 (enc->width != enc->coded_width ||
630 enc->height != enc->coded_height))
631 av_bprintf(&bprint, " (%dx%d)",
632 enc->coded_width, enc->coded_height);
633
634 if (enc->sample_aspect_ratio.num) {
635 av_reduce(&display_aspect_ratio.num, &display_aspect_ratio.den,
638 1024 * 1024);
639 av_bprintf(&bprint, " [SAR %d:%d DAR %d:%d]",
641 display_aspect_ratio.num, display_aspect_ratio.den);
642 }
644 int g = av_gcd(enc->time_base.num, enc->time_base.den);
645 av_bprintf(&bprint, ", %d/%d",
646 enc->time_base.num / g, enc->time_base.den / g);
647 }
648 }
649 if (encode) {
650 av_bprintf(&bprint, ", q=%d-%d", enc->qmin, enc->qmax);
651 }
652 break;
654 av_bprintf(&bprint, "%s", separator);
655
656 if (enc->sample_rate) {
657 av_bprintf(&bprint, "%d Hz, ", enc->sample_rate);
658 }
660 if (enc->sample_fmt != AV_SAMPLE_FMT_NONE &&
661 (str = av_get_sample_fmt_name(enc->sample_fmt))) {
662 av_bprintf(&bprint, ", %s", str);
663 }
664 if ( enc->bits_per_raw_sample > 0
666 av_bprintf(&bprint, " (%d bit)", enc->bits_per_raw_sample);
668 if (enc->initial_padding)
669 av_bprintf(&bprint, ", delay %d", enc->initial_padding);
670 if (enc->trailing_padding)
671 av_bprintf(&bprint, ", padding %d", enc->trailing_padding);
672 }
673 break;
676 int g = av_gcd(enc->time_base.num, enc->time_base.den);
677 if (g)
678 av_bprintf(&bprint, ", %d/%d",
679 enc->time_base.num / g, enc->time_base.den / g);
680 }
681 break;
683 if (enc->width)
684 av_bprintf(&bprint, ", %dx%d", enc->width, enc->height);
685 break;
686 default:
687 return;
688 }
689 if (encode) {
690 if (enc->flags & AV_CODEC_FLAG_PASS1)
691 av_bprintf(&bprint, ", pass 1");
692 if (enc->flags & AV_CODEC_FLAG_PASS2)
693 av_bprintf(&bprint, ", pass 2");
694 }
695 bitrate = get_bit_rate(enc);
696 if (bitrate != 0) {
697 av_bprintf(&bprint, ", %"PRId64" kb/s", bitrate / 1000);
698 } else if (enc->rc_max_rate > 0) {
699 av_bprintf(&bprint, ", max. %"PRId64" kb/s", enc->rc_max_rate / 1000);
700 }
701}
702
704{
705 return !!s->internal;
706}
707
709 AVFrame *frame, unsigned flags)
710{
712
713 if (!avcodec_is_open(avctx) || !avctx->codec)
714 return AVERROR(EINVAL);
715
716 if (ff_codec_is_decoder(avctx->codec))
717 return ff_decode_receive_frame(avctx, frame, flags);
718 return ff_encode_receive_frame(avctx, frame);
719}
720
725
726#define WRAP_CONFIG(allowed_type, field, var, field_type, sentinel_check) \
727 do { \
728 if (codec->type != (allowed_type)) \
729 return AVERROR(EINVAL); \
730 const field_type *ptr = codec2->field; \
731 *out_configs = ptr; \
732 if (ptr) { \
733 for (int i = 0;; i++) { \
734 const field_type var = ptr[i]; \
735 if (sentinel_check) { \
736 *out_num_configs = i; \
737 break; \
738 } \
739 } \
740 } else \
741 *out_num_configs = 0; \
742 return 0; \
743 } while (0)
744
749
754
755static_assert((int)AVCOL_RANGE_MPEG == (int)AVALPHA_MODE_PREMULTIPLIED, "unexpected enum values");
756static_assert((int)AVCOL_RANGE_JPEG == (int)AVALPHA_MODE_STRAIGHT, "unexpected enum values");
757static_assert(AVCOL_RANGE_UNSPECIFIED == 0 && AVALPHA_MODE_UNSPECIFIED == 0, "unexpected enum values");
758static_assert(AVCOL_RANGE_NB == 3 && AVALPHA_MODE_NB == 3, "unexpected enum values");
759
760static const uint8_t offset_tab[] = {
761 [AVCOL_RANGE_MPEG] = 3,
762 [AVCOL_RANGE_JPEG] = 1,
764};
765
767 const AVCodec *codec,
768 enum AVCodecConfig config,
769 unsigned flags,
770 const void **out_configs,
771 int *out_num_configs)
772{
773 const FFCodec *codec2 = ffcodec(codec);
774
775 switch (config) {
779 WRAP_CONFIG(AVMEDIA_TYPE_VIDEO, supported_framerates, framerate, AVRational, framerate.num == 0);
781 WRAP_CONFIG(AVMEDIA_TYPE_AUDIO, supported_samplerates, samplerate, int, samplerate == 0);
785 WRAP_CONFIG(AVMEDIA_TYPE_AUDIO, ch_layouts, ch_layout, AVChannelLayout, ch_layout.nb_channels == 0);
786
788 if (codec->type != AVMEDIA_TYPE_VIDEO)
789 return AVERROR(EINVAL);
790 unsigned color_ranges = codec2->color_ranges;
791 if (color_ranges)
792 *out_configs = color_range_tab + offset_tab[color_ranges];
793 else
794 *out_configs = NULL;
795 *out_num_configs = av_popcount(color_ranges);
796 return 0;
797
799 *out_configs = NULL;
800 *out_num_configs = 0;
801 return 0;
802
804 if (codec->type != AVMEDIA_TYPE_VIDEO)
805 return AVERROR(EINVAL);
806 unsigned alpha_modes = codec2->alpha_modes;
807 if (alpha_modes)
808 *out_configs = alpha_mode_tab + offset_tab[alpha_modes];
809 else
810 *out_configs = NULL;
811 *out_num_configs = av_popcount(alpha_modes);
812 return 0;
813
815 WRAP_CONFIG(AVMEDIA_TYPE_VIDEO, chroma_locations, loc,
817
818 default:
819 return AVERROR(EINVAL);
820 }
821}
822
824 enum AVCodecConfig config, unsigned flags,
825 const void **out, int *out_num)
826{
827 const FFCodec *codec2;
828 int dummy_num = 0;
829 if (!codec)
830 codec = avctx->codec;
831 if (!out_num)
832 out_num = &dummy_num;
833
834 codec2 = ffcodec(codec);
835 if (codec2->get_supported_config) {
836 return codec2->get_supported_config(avctx, codec, config, flags, out, out_num);
837 } else {
838 return ff_default_get_supported_config(avctx, codec, config, flags, out, out_num);
839 }
840}
841
843 const AVFrameSideData *src, unsigned int flags)
844{
846
847 for (unsigned j = 0; ff_sd_global_map[j].packet < AV_PKT_DATA_NB; j++) {
848 if (ff_sd_global_map[j].frame != src->type)
849 continue;
850
851 sd = av_packet_side_data_new(psd, pnb_sd, ff_sd_global_map[j].packet,
852 src->size, 0);
853
854 if (!sd)
855 return AVERROR(ENOMEM);
856
857 memcpy(sd->data, src->data, src->size);
858 break;
859 }
860
861 if (!sd)
862 return AVERROR(EINVAL);
863
864 return 0;
865}
866
868 const AVPacketSideData *src, unsigned int flags)
869{
870 AVFrameSideData *sd = NULL;
871
872 for (unsigned j = 0; ff_sd_global_map[j].packet < AV_PKT_DATA_NB; j++) {
873 if (ff_sd_global_map[j].packet != src->type)
874 continue;
875
876 sd = av_frame_side_data_new(psd, pnb_sd, ff_sd_global_map[j].frame,
877 src->size, flags);
878
879 if (!sd)
880 return AVERROR(ENOMEM);
881
882 memcpy(sd->data, src->data, src->size);
883 break;
884 }
885
886 if (!sd)
887 return AVERROR(EINVAL);
888
889 return 0;
890}
static enum AVSampleFormat sample_fmts[]
Definition adpcmenc.c:933
static FILE * out
static AVFormatContext * ctx
simple assert() macros that are a bit more flexible than ISO C assert().
#define av_assert0(cond)
assert() equivalent, that is always enabled.
Definition avassert.h:42
#define FF_MAX_EXTRADATA_SIZE
Maximum size in bytes of extradata.
Definition avcodec.c:55
static const uint8_t offset_tab[]
Definition avcodec.c:760
int ff_default_get_supported_config(const AVCodecContext *avctx, const AVCodec *codec, enum AVCodecConfig config, unsigned flags, const void **out_configs, int *out_num_configs)
Definition avcodec.c:766
static void lock_avcodec(const FFCodec *codec)
Definition avcodec.c:103
static enum AVColorRange color_range_tab[]
Definition avcodec.c:745
av_cold void ff_codec_close(AVCodecContext *avctx)
Definition avcodec.c:444
static AVMutex codec_mutex
Definition avcodec.c:101
const SideDataMap ff_sd_global_map[]
A map between packet and frame side data types.
Definition avcodec.c:57
static const char * unknown_if_null(const char *str)
Definition avcodec.c:510
static enum AVAlphaMode alpha_mode_tab[]
Definition avcodec.c:750
static void unlock_avcodec(const FFCodec *codec)
Definition avcodec.c:109
int av_packet_side_data_from_frame(AVPacketSideData **psd, int *pnb_sd, const AVFrameSideData *src, unsigned int flags)
Definition avcodec.c:842
#define WRAP_CONFIG(allowed_type, field, var, field_type, sentinel_check)
Definition avcodec.c:726
static int64_t get_bit_rate(AVCodecContext *ctx)
Definition avcodec.c:115
Libavcodec external API header.
#define FF_THREAD_FRAME
Decode more than one frame at once.
Definition avcodec.h:1595
void ff_thread_free(struct AVCodecContext *s)
Definition pthread.c:84
int ff_encode_receive_frame(struct AVCodecContext *avctx, struct AVFrame *frame)
avcodec_receive_frame() implementation for encoders.
Definition encode.c:1011
void ff_thread_flush(struct AVCodecContext *avctx)
Wait for decoding threads to finish and reset internal state.
int ff_decode_preinit(struct AVCodecContext *avctx)
Perform decoder initialization and validation.
Definition decode.c:2033
void ff_encode_flush_buffers(struct AVCodecContext *avctx)
Definition encode.c:1024
void ff_decode_flush_buffers(struct AVCodecContext *avctx)
Definition decode.c:2371
void ff_decode_internal_uninit(struct AVCodecContext *avctx)
Definition decode.c:2412
int ff_encode_preinit(struct AVCodecContext *avctx)
Definition encode.c:898
int ff_decode_receive_frame(struct AVCodecContext *avctx, struct AVFrame *frame, unsigned flags)
avcodec_receive_frame() implementation for decoders.
Definition decode.c:821
int ff_thread_init(struct AVCodecContext *s)
Definition pthread.c:72
struct AVCodecInternal * ff_decode_internal_alloc(void)
Definition decode.c:2391
struct AVCodecInternal * ff_encode_internal_alloc(void)
Definition encode.c:1034
void av_bprintf(AVBPrint *buf, const char *fmt,...)
Definition bprint.c:121
AVBPrint public header.
#define flags(name, subs,...)
Definition cbs_h264.c:74
#define i(width, name, range_min, range_max)
Definition cbs_h264.c:63
#define s(width, name)
Definition cbs_vp9.c:198
Public libavutil channel layout APIs header.
#define FF_CODEC_CAP_NOT_INIT_THREADSAFE
The codec is not known to be init-threadsafe (i.e.
static av_always_inline const FFCodec * ffcodec(const AVCodec *codec)
#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.
static int ff_codec_is_decoder(const AVCodec *avcodec)
Internal version of av_codec_is_decoder().
static int ff_codec_is_encoder(const AVCodec *avcodec)
Internal version of av_codec_is_encoder().
common internal and external API header
#define av_popcount
Definition common.h:154
#define NULL
Definition coverity.c:32
long long int64_t
Definition coverity.c:34
void ff_hwaccel_uninit(AVCodecContext *avctx)
Definition decode.c:1221
int ff_set_dimensions(AVCodecContext *s, int width, int height)
Definition utils.c:91
#define FF_COMPLIANCE_EXPERIMENTAL
Allow nonstandardized experimental things.
Definition defs.h:62
@ AV_FIELD_TT
Top coded_first, top displayed first.
Definition defs.h:228
@ AV_FIELD_BB
Bottom coded first, bottom displayed first.
Definition defs.h:229
@ AV_FIELD_UNKNOWN
Definition defs.h:226
@ AV_FIELD_BT
Bottom coded first, top displayed first.
Definition defs.h:231
@ AV_FIELD_TB
Top coded first, bottom displayed first.
Definition defs.h:230
static enum AVPixelFormat pix_fmt
static AVFrame * frame
#define emms_c()
Definition emms.h:88
static void encode(AVCodecContext *ctx, AVFrame *frame, AVPacket *pkt, FILE *output)
static char separator(CheckasmFormat format)
Definition checkasm.c:149
static const char * unknown_if_null(const char *str)
av_cold void ff_frame_thread_encoder_free(AVCodecContext *avctx)
void av_bsf_free(AVBSFContext **pctx)
Free a bitstream filter context and everything associated with it; write NULL into the supplied point...
Definition bsf.c:47
int av_get_bits_per_sample(enum AVCodecID codec_id)
Return codec bits per sample.
Definition utils.c:557
const AVCodecDescriptor * avcodec_descriptor_get(enum AVCodecID id)
int attribute_align_arg avcodec_open2(AVCodecContext *avctx, const AVCodec *codec, AVDictionary **options)
Initialize the AVCodecContext to use the given AVCodec.
Definition avcodec.c:145
#define AV_CODEC_CAP_ENCODER_FLUSH
This encoder can be flushed using avcodec_flush_buffers().
Definition codec.h:154
#define AV_CODEC_FLAG_PASS2
Use internal 2pass ratecontrol in second pass mode.
Definition avcodec.h:294
int av_codec_is_encoder(const AVCodec *codec)
Definition utils.c:79
const char * avcodec_profile_name(enum AVCodecID codec_id, int profile)
Return a name for the specified profile, if available.
Definition utils.c:446
int av_codec_is_decoder(const AVCodec *codec)
Definition utils.c:85
#define AV_CODEC_FLAG_PASS1
Use internal 2pass ratecontrol in first pass mode.
Definition avcodec.h:290
#define AV_CODEC_FLAG2_FIXED_FRAME_SIZE
Force audio encoders to use a fixed frame size.
Definition avcodec.h:359
const AVCodec * avcodec_find_decoder(enum AVCodecID id)
Find a registered decoder with a matching codec ID.
Definition allcodecs.c:997
const AVCodec * avcodec_find_encoder(enum AVCodecID id)
Find a registered encoder with a matching codec ID.
Definition allcodecs.c:992
void avsubtitle_free(AVSubtitle *sub)
Free all allocated data in the given subtitle struct.
Definition avcodec.c:422
const char * avcodec_get_name(enum AVCodecID id)
Get the name of a codec.
Definition utils.c:421
#define AV_CODEC_CAP_CHANNEL_CONF
Codec should fill in channel configuration and samplerate instead of container.
Definition codec.h:94
#define AV_CODEC_CAP_EXPERIMENTAL
Codec is experimental and is thus avoided in favor of non experimental encoders.
Definition codec.h:90
@ AV_CODEC_ID_VP6F
Definition codec_id.h:142
@ AV_CODEC_ID_H264
Definition codec_id.h:77
@ AV_CODEC_ID_NONE
Definition codec_id.h:48
@ AV_CODEC_ID_DXV
Definition codec_id.h:240
int avcodec_receive_frame(AVCodecContext *avctx, AVFrame *frame)
Alias for avcodec_receive_frame_flags(avctx, frame, 0).
Definition avcodec.c:721
int attribute_align_arg avcodec_receive_frame_flags(AVCodecContext *avctx, AVFrame *frame, unsigned flags)
Return decoded output data from a decoder or encoder (when the AV_CODEC_FLAG_RECON_FRAME flag is used...
Definition avcodec.c:708
AVCodecConfig
Definition avcodec.h:2587
int avcodec_get_supported_config(const AVCodecContext *avctx, const AVCodec *codec, enum AVCodecConfig config, unsigned flags, const void **out, int *out_num)
Retrieve a list of all supported values for a given configuration type.
Definition avcodec.c:823
@ AV_CODEC_CONFIG_PIX_FORMAT
AVPixelFormat, terminated by AV_PIX_FMT_NONE.
Definition avcodec.h:2588
@ AV_CODEC_CONFIG_SAMPLE_FORMAT
AVSampleFormat, terminated by AV_SAMPLE_FMT_NONE.
Definition avcodec.h:2591
@ AV_CODEC_CONFIG_ALPHA_MODE
AVAlphaMode, terminated by AVALPHA_MODE_UNSPECIFIED.
Definition avcodec.h:2595
@ AV_CODEC_CONFIG_FRAME_RATE
AVRational, terminated by {0, 0}.
Definition avcodec.h:2589
@ AV_CODEC_CONFIG_COLOR_SPACE
AVColorSpace, terminated by AVCOL_SPC_UNSPECIFIED.
Definition avcodec.h:2594
@ AV_CODEC_CONFIG_CHROMA_LOCATION
AVChromaLocation, terminated by AVCHROMA_LOC_UNSPECIFIED.
Definition avcodec.h:2596
@ AV_CODEC_CONFIG_COLOR_RANGE
AVColorRange, terminated by AVCOL_RANGE_UNSPECIFIED.
Definition avcodec.h:2593
@ AV_CODEC_CONFIG_SAMPLE_RATE
int, terminated by 0
Definition avcodec.h:2590
@ AV_CODEC_CONFIG_CHANNEL_LAYOUT
AVChannelLayout, terminated by {0}.
Definition avcodec.h:2592
int avcodec_default_execute2(AVCodecContext *c, int(*func)(AVCodecContext *c2, void *arg2, int jobnr, int threadnr), void *arg, int *ret, int count)
Definition avcodec.c:88
void avcodec_string(char *buf, int buf_size, AVCodecContext *enc, int encode)
Definition avcodec.c:515
int avcodec_is_open(AVCodecContext *s)
Definition avcodec.c:703
int avcodec_default_execute(AVCodecContext *c, int(*func)(AVCodecContext *c2, void *arg2), void *arg, int *ret, int count, int size)
Definition avcodec.c:74
void avcodec_flush_buffers(AVCodecContext *avctx)
Reset the internal codec state / flush internal buffers.
Definition avcodec.c:390
AVPacketSideData * av_packet_side_data_new(AVPacketSideData **psd, int *pnb_sd, enum AVPacketSideDataType type, size_t size, int flags)
Allocate a new packet side data.
Definition packet.c:621
int av_packet_side_data_to_frame(AVFrameSideData ***psd, int *pnb_sd, const AVPacketSideData *src, unsigned int flags)
Add a new frame side data entry to an array based on existing packet side data, if a matching type ex...
Definition avcodec.c:867
@ AV_PKT_DATA_AMBIENT_VIEWING_ENVIRONMENT
Ambient viewing environment metadata, as defined by H.274.
Definition packet.h:327
@ AV_PKT_DATA_3D_REFERENCE_DISPLAYS
This side data contains information about the reference display width(s) and reference viewing distan...
Definition packet.h:357
@ AV_PKT_DATA_GAIN_MAP_PARAMS
Parameters describing how to combine this gain map with its base image to form an alternate rendition...
Definition packet.h:391
@ AV_PKT_DATA_ICC_PROFILE
ICC profile data consisting of an opaque octet buffer following the format described by ISO 15076-1.
Definition packet.h:271
@ AV_PKT_DATA_MASTERING_DISPLAY_METADATA
Mastering display metadata (based on SMPTE-2086:2014).
Definition packet.h:219
@ AV_PKT_DATA_AUDIO_SERVICE_TYPE
This side data should be associated with an audio stream and corresponds to enum AVAudioServiceType.
Definition packet.h:117
@ AV_PKT_DATA_SPHERICAL
This side data should be associated with a video stream and corresponds to the AVSphericalMapping str...
Definition packet.h:225
@ AV_PKT_DATA_DISPLAYMATRIX
This side data contains a 3x3 transformation matrix describing an affine transformation that needs to...
Definition packet.h:105
@ AV_PKT_DATA_EXIF
Extensible image file format metadata.
Definition packet.h:369
@ AV_PKT_DATA_NB
The number of side data types.
Definition packet.h:401
@ AV_PKT_DATA_STEREO3D
This side data should be associated with a video stream and contains Stereoscopic 3D information in f...
Definition packet.h:111
@ AV_PKT_DATA_CONTENT_LIGHT_LEVEL
Content light level (based on CTA-861.3).
Definition packet.h:232
@ AV_PKT_DATA_REPLAYGAIN
This side data should be associated with an audio stream and contains ReplayGain information in form ...
Definition packet.h:96
void av_packet_free(AVPacket **pkt)
Free the packet, if the packet is reference counted, it will be unreferenced first.
Definition packet.c:74
void av_packet_unref(AVPacket *pkt)
Wipe the packet.
Definition packet.c:435
AVPacket * av_packet_alloc(void)
Allocate an AVPacket and set its fields to default values.
Definition packet.c:63
int av_channel_layout_describe_bprint(const AVChannelLayout *channel_layout, AVBPrint *bp)
bprint variant of av_channel_layout_describe().
int av_channel_layout_check(const AVChannelLayout *channel_layout)
Check whether a channel layout is valid, i.e.
static int av_bprint_is_complete(const AVBPrint *buf)
Test if the print buffer is complete (not truncated).
Definition bprint.h:218
void av_bprint_chars(AVBPrint *buf, char c, unsigned n)
Append char c n times to a print buffer.
Definition bprint.c:129
void av_bprint_init_for_buffer(AVBPrint *buf, char *buffer, unsigned size)
Init a print buffer using a pre-existing buffer.
Definition bprint.c:84
void av_buffer_unref(AVBufferRef **buf)
Free a given reference and automatically free the buffer if there are no more references to it.
Definition buffer.c:140
AVDictionaryEntry * av_dict_get(const AVDictionary *m, const char *key, const AVDictionaryEntry *prev, int flags)
Get a dictionary entry with matching key.
Definition dict.c:61
#define AVERROR_EXPERIMENTAL
Requested feature is flagged experimental. Set strict_std_compliance if you really want to use it.
Definition error.h:74
#define AVERROR(e)
Definition error.h:45
void av_frame_unref(AVFrame *frame)
Unreference all the buffers referenced by frame and reset the frame fields.
Definition frame.c:496
AVFrameSideData * av_frame_side_data_new(AVFrameSideData ***sd, int *nb_sd, enum AVFrameSideDataType type, size_t size, unsigned int flags)
Add new side data entry to an array.
Definition side_data.c:205
void av_frame_side_data_free(AVFrameSideData ***sd, int *nb_sd)
Free all side data entries and their contents, then zeroes out the values which the pointers are poin...
Definition side_data.c:140
void av_frame_free(AVFrame **frame)
Free the frame and any dynamically allocated objects in it, e.g.
Definition frame.c:64
AVFrame * av_frame_alloc(void)
Allocate an AVFrame and set its fields to default values.
Definition frame.c:52
@ AV_FRAME_DATA_EXIF
Exchangeable image file format metadata.
Definition frame.h:263
@ AV_FRAME_DATA_SPHERICAL
The data represents the AVSphericalMapping structure defined in libavutil/spherical....
Definition frame.h:131
@ AV_FRAME_DATA_CONTENT_LIGHT_LEVEL
Content light level (based on CTA-861.3).
Definition frame.h:137
@ AV_FRAME_DATA_AMBIENT_VIEWING_ENVIRONMENT
Ambient viewing environment metadata, as defined by H.274.
Definition frame.h:220
@ AV_FRAME_DATA_DISPLAYMATRIX
This side data contains a 3x3 transformation matrix describing an affine transformation that needs to...
Definition frame.h:85
@ AV_FRAME_DATA_AUDIO_SERVICE_TYPE
This side data must be associated with an audio frame and corresponds to enum AVAudioServiceType defi...
Definition frame.h:114
@ AV_FRAME_DATA_REPLAYGAIN
ReplayGain information in the form of the AVReplayGain struct.
Definition frame.h:77
@ AV_FRAME_DATA_MASTERING_DISPLAY_METADATA
Mastering display metadata associated with a video frame.
Definition frame.h:120
@ AV_FRAME_DATA_3D_REFERENCE_DISPLAYS
This side data contains information about the reference display width(s) and reference viewing distan...
Definition frame.h:256
@ AV_FRAME_DATA_ICC_PROFILE
The data contains an ICC profile as an opaque octet buffer following the format described by ISO 1507...
Definition frame.h:144
@ AV_FRAME_DATA_STEREO3D
Stereoscopic 3d metadata.
Definition frame.h:64
@ AV_FRAME_DATA_GAIN_MAP_PARAMS
Parameters describing how to combine this gain map with its base image to form an alternate rendition...
Definition frame.h:314
#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
int av_log_get_level(void)
Get the current log level.
Definition log.c:471
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
int64_t av_gcd(int64_t a, int64_t b)
Compute the greatest common divisor of two integer operands.
Definition mathematics.c:37
const char * av_get_media_type_string(enum AVMediaType media_type)
Return a string describing the media_type enum, NULL if media_type is unknown.
Definition utils.c:28
#define av_fourcc2str(fourcc)
Definition avutil.h:323
@ AVMEDIA_TYPE_ATTACHMENT
Opaque data information usually sparse.
Definition avutil.h:204
@ AVMEDIA_TYPE_AUDIO
Definition avutil.h:201
@ AVMEDIA_TYPE_SUBTITLE
Definition avutil.h:203
@ AVMEDIA_TYPE_VIDEO
Definition avutil.h:200
@ AVMEDIA_TYPE_DATA
Opaque data information usually continuous.
Definition avutil.h:202
@ AVMEDIA_TYPE_UNKNOWN
Usually treated as AVMEDIA_TYPE_DATA.
Definition avutil.h:199
int av_image_check_size2(unsigned int w, unsigned int h, int64_t max_pixels, enum AVPixelFormat pix_fmt, int log_offset, void *log_ctx)
Check if the given dimension of an image is valid, meaning that all bytes of a plane of an image with...
Definition imgutils.c:289
int av_image_check_sar(unsigned int w, unsigned int h, AVRational sar)
Check if the given sample aspect ratio of an image is valid.
Definition imgutils.c:323
int av_get_bytes_per_sample(enum AVSampleFormat sample_fmt)
Return number of bytes per sample.
Definition samplefmt.c:109
const char * av_get_sample_fmt_name(enum AVSampleFormat sample_fmt)
Return the name of sample_fmt, or NULL if sample_fmt is not recognized.
Definition samplefmt.c:52
AVSampleFormat
Audio sample formats.
Definition samplefmt.h:55
@ AV_SAMPLE_FMT_NONE
Definition samplefmt.h:56
int av_match_list(const char *name, const char *list, char separator)
Check if a name is in a list.
Definition avstring.c:443
#define AV_OPT_SEARCH_CHILDREN
Search in possible children of the given object first.
Definition opt.h:604
void av_opt_free(void *obj)
Free all allocated objects in obj.
Definition opt.c:2029
void av_opt_set_defaults(void *s)
Set the values of all AVOption fields to their default values.
Definition opt.c:1758
int av_opt_set(void *obj, const char *name, const char *val, int search_flags)
Definition opt.c:891
int av_opt_set_dict2(void *obj, AVDictionary **options, int search_flags)
Set all the options from a given dictionary on an object.
Definition opt.c:2042
misc image utilities
#define r
Definition input.c:42
unsigned offset
Definition libaomenc.c:763
void ff_icc_context_uninit(FFIccContext *s)
Definition fflcms2.c:42
common internal api header.
#define FF_SANE_NB_CHANNELS
Definition internal.h:37
int(* func)(AVBPrint *dst, const char *in, const char *arg)
Definition jacosubdec.c:66
const char * arg
Definition jacosubdec.c:65
#define av_cold
Definition attributes.h:117
#define FF_PTR_ADD(ptr, off)
Definition internal.h:83
#define attribute_align_arg
Definition internal.h:51
#define AV_MUTEX_INITIALIZER
Definition thread.h:185
static int ff_mutex_unlock(AVMutex *mutex)
Definition thread.h:189
static int ff_mutex_lock(AVMutex *mutex)
Definition thread.h:188
#define AVMutex
Definition thread.h:184
static enum AVPixelFormat pix_fmts[]
Definition libkvazaar.c:296
Memory handling functions.
static const uint64_t c2
Definition murmur3.c:53
int profile
Definition mxfenc.c:2299
AVOptions.
const char * av_color_space_name(enum AVColorSpace space)
Definition pixdesc.c:3884
const char * av_color_range_name(enum AVColorRange range)
Definition pixdesc.c:3800
const char * av_get_pix_fmt_name(enum AVPixelFormat pix_fmt)
Return the short name for a pixel format, NULL in case pix_fmt is unknown.
Definition pixdesc.c:3404
const char * av_chroma_location_name(enum AVChromaLocation location)
Definition pixdesc.c:3905
const char * av_color_transfer_name(enum AVColorTransferCharacteristic transfer)
Definition pixdesc.c:3851
const char * av_color_primaries_name(enum AVColorPrimaries primaries)
Definition pixdesc.c:3818
const AVPixFmtDescriptor * av_pix_fmt_desc_get(enum AVPixelFormat pix_fmt)
Definition pixdesc.c:3484
AVChromaLocation
Location of chroma samples.
Definition pixfmt.h:807
@ AVCHROMA_LOC_UNSPECIFIED
Definition pixfmt.h:808
AVColorRange
Visual content value range.
Definition pixfmt.h:753
@ AVCOL_RANGE_MPEG
Narrow or limited range content.
Definition pixfmt.h:771
@ AVCOL_RANGE_UNSPECIFIED
Definition pixfmt.h:754
@ AVCOL_RANGE_NB
Not part of ABI.
Definition pixfmt.h:789
@ AVCOL_RANGE_JPEG
Full range content.
Definition pixfmt.h:788
AVAlphaMode
Correlation between the alpha channel and color values.
Definition pixfmt.h:821
@ AVALPHA_MODE_NB
Not part of ABI.
Definition pixfmt.h:825
@ AVALPHA_MODE_STRAIGHT
Alpha channel is independent of color values.
Definition pixfmt.h:824
@ AVALPHA_MODE_UNSPECIFIED
Unknown alpha handling, or no alpha channel.
Definition pixfmt.h:822
@ AVALPHA_MODE_PREMULTIPLIED
Alpha channel is multiplied into color values.
Definition pixfmt.h:823
AVPixelFormat
Pixel format.
Definition pixfmt.h:71
@ AV_PIX_FMT_NONE
Definition pixfmt.h:72
@ AVCOL_PRI_UNSPECIFIED
Definition pixfmt.h:650
@ AVCOL_TRC_UNSPECIFIED
Definition pixfmt.h:680
@ AVCOL_SPC_UNSPECIFIED
Definition pixfmt.h:714
void av_refstruct_unref(void *objp)
Decrement the reference count of the underlying object and automatically free the object if there are...
Definition refstruct.c:121
static void av_refstruct_pool_uninit(AVRefStructPool **poolp)
Mark the pool as being available for freeing.
Definition refstruct.h:292
enum AVMediaType codec_type
Definition rtp.c:37
An AVChannelLayout holds information about the channel layout of audio data.
int nb_channels
Number of channels in this layout.
Describe the class of an AVClass context structure.
Definition log.h:76
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
AVPacketSideData * coded_side_data
Additional data associated with the entire coded stream.
Definition avcodec.h:1773
const struct AVCodecDescriptor * codec_descriptor
AVCodecDescriptor.
Definition avcodec.h:1714
AVChannelLayout ch_layout
Audio channel layout.
Definition avcodec.h:1055
int flags2
AV_CODEC_FLAG2_*.
Definition avcodec.h:507
enum AVSampleFormat sample_fmt
audio sample format
Definition avcodec.h:1047
int64_t max_pixels
The number of pixels per image to maximally accept.
Definition avcodec.h:1792
enum AVColorRange color_range
MPEG vs JPEG YUV range.
Definition avcodec.h:681
unsigned int codec_tag
fourcc (LSB first, so "ABCD" -> ('D'<<24) + ('C'<<16) + ('B'<<8) + 'A').
Definition avcodec.h:468
int strict_std_compliance
strictly follow the standard (MPEG-4, ...).
Definition avcodec.h:1376
int nb_coded_side_data
Definition avcodec.h:1774
enum AVColorPrimaries color_primaries
Chromaticity coordinates of the source primaries.
Definition avcodec.h:657
AVBufferRef * hw_frames_ctx
A reference to the AVHWFramesContext describing the input (for encoding) or output (decoding) frames.
Definition avcodec.h:1472
int qmin
minimum quantizer
Definition avcodec.h:1252
enum AVMediaType codec_type
Definition avcodec.h:451
int64_t frame_num
Frame counter, set by libavcodec.
Definition avcodec.h:1888
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
int bits_per_coded_sample
bits per sample/pixel from the demuxer (needed for huffyuv).
Definition avcodec.h:1569
uint8_t * dump_separator
dump format separator.
Definition avcodec.h:1757
enum AVFieldOrder field_order
Field order.
Definition avcodec.h:694
int active_thread_type
Which multithreading methods are in use by the codec.
Definition avcodec.h:1603
char * codec_whitelist
',' separated list of allowed decoders.
Definition avcodec.h:1765
int64_t bit_rate
the average bitrate
Definition avcodec.h:493
const struct AVCodec * codec
Definition avcodec.h:452
int profile
profile
Definition avcodec.h:1641
int nb_decoded_side_data
Definition avcodec.h:1935
int bits_per_raw_sample
Bits per sample/pixel of internal libavcodec pixel/sample format.
Definition avcodec.h:1576
enum AVColorSpace colorspace
YUV colorspace type.
Definition avcodec.h:671
int initial_padding
Audio only.
Definition avcodec.h:1114
int sample_rate
samples per second
Definition avcodec.h:1040
int delay
Codec delay.
Definition avcodec.h:587
int refs
number of reference frames
Definition avcodec.h:701
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:1584
int qmax
maximum quantizer
Definition avcodec.h:1259
enum AVColorTransferCharacteristic color_trc
Color Transfer Characteristic.
Definition avcodec.h:664
uint8_t * subtitle_header
Definition avcodec.h:1749
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
AVFrameSideData ** decoded_side_data
Array containing static side data, such as HDR10 CLL / MDCV structures.
Definition avcodec.h:1934
uint8_t * extradata
Out-of-band global headers that may be used by some codecs.
Definition avcodec.h:526
int trailing_padding
Audio only.
Definition avcodec.h:1125
enum AVChromaLocation chroma_sample_location
This defines the location of chroma samples.
Definition avcodec.h:688
AVBufferRef * hw_device_ctx
A reference to the AVHWDeviceContext describing the device which will be used by a hardware encoder/d...
Definition avcodec.h:1494
enum AVCodecID codec_id
Definition avcodec.h:453
int extradata_size
Definition avcodec.h:527
int coded_width
Bitstream width / height, may be different from width/height e.g.
Definition avcodec.h:619
int block_align
number of bytes per packet if constant and known or 0 Used by some WAV based audio codecs.
Definition avcodec.h:1075
int frame_size
Number of samples per channel in an audio frame.
Definition avcodec.h:1068
struct AVCodecInternal * internal
Private context used for internal data.
Definition avcodec.h:478
void * priv_data
Definition avcodec.h:470
AVPacket * in_pkt
This packet is used to hold the packet given to decoders implementing the .decode API; it is unused b...
Definition internal.h:83
AVFrame * recon_frame
When the AV_CODEC_FLAG_RECON_FRAME flag is used.
Definition internal.h:114
void * thread_ctx
Definition internal.h:73
AVPacket * last_pkt_props
Properties (timestamps+side data) extracted from the last packet passed for decoding.
Definition internal.h:90
int needs_close
If this is set, then FFCodec->close (if existing) needs to be called for the parent AVCodecContext.
Definition internal.h:120
int is_frame_mt
This field is set to 1 when frame threading is being used and the parent AVCodecContext of this AVCod...
Definition internal.h:61
struct FramePool * pool
Definition internal.h:69
unsigned int byte_buffer_size
Definition internal.h:96
uint8_t * byte_buffer
temporary buffer used for encoders to store their bitstream
Definition internal.h:95
AVFrame * buffer_frame
Definition internal.h:145
AVPacket * buffer_pkt
Temporary buffers for newly received or not yet output packets/frames.
Definition internal.h:144
AVFrame * in_frame
The input frame is stored here for encoders implementing the simple encode API.
Definition internal.h:106
int draining
decoding: AVERROR_EOF has been returned from ff_decode_get_packet(); must not be used by decoders tha...
Definition internal.h:139
struct AVRefStructPool * progress_frame_pool
Definition internal.h:71
void * frame_thread_encoder
Definition internal.h:98
int skip_samples
Number of audio samples to skip at the start of the next decoded frame.
Definition internal.h:125
struct AVBSFContext * bsf
Definition internal.h:84
AVCodec.
Definition codec.h:175
enum AVCodecID id
Definition codec.h:189
const AVClass * priv_class
AVClass for the private context.
Definition codec.h:197
enum AVMediaType type
Definition codec.h:188
const char * name
Name of the codec implementation.
Definition codec.h:182
int capabilities
Codec capabilities.
Definition codec.h:194
char * key
Definition dict.h:91
char * value
Definition dict.h:92
Structure to hold side data for an AVFrame.
Definition frame.h:334
uint8_t * data
Definition frame.h:336
This structure describes decoded (raw) audio or video data.
Definition frame.h:479
This structure stores auxiliary information for decoding, presenting, or otherwise processing the cod...
Definition packet.h:431
uint8_t * data
Definition packet.h:432
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
unsigned num_rects
Definition avcodec.h:2106
AVSubtitleRect ** rects
Definition avcodec.h:2107
int priv_data_size
int(* init)(struct AVCodecContext *)
void(* flush)(struct AVCodecContext *)
Flush buffers.
unsigned alpha_modes
This field determines the alpha modes supported by an encoder.
unsigned caps_internal
Internal codec capabilities FF_CODEC_CAP_*.
int(* close)(struct AVCodecContext *)
int(* get_supported_config)(const struct AVCodecContext *avctx, const AVCodec *codec, enum AVCodecConfig config, unsigned flags, const void **out_configs, int *out_num_configs)
Custom callback for avcodec_get_supported_config().
unsigned color_ranges
This field determines the video color ranges supported by an encoder.
#define av_mallocz(s)
#define av_freep(p)
#define av_log(a,...)
float framerate
Definition av1_levels.c:29
int64_t bitrate
Definition av1_levels.c:47
#define src
Definition vp8dsp.c:248
int size
const char * g
Definition vf_curves.c:128
int len
static double c[64]