FFmpeg
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 "config.h"
27 #include "libavutil/avassert.h"
28 #include "libavutil/avstring.h"
29 #include "libavutil/bprint.h"
31 #include "libavutil/fifo.h"
32 #include "libavutil/imgutils.h"
33 #include "libavutil/mem.h"
34 #include "libavutil/opt.h"
35 #include "libavutil/thread.h"
36 #include "avcodec.h"
37 #include "bsf.h"
38 #include "codec_internal.h"
39 #include "decode.h"
40 #include "encode.h"
41 #include "frame_thread_encoder.h"
42 #include "internal.h"
43 #include "thread.h"
44 
45 int avcodec_default_execute(AVCodecContext *c, int (*func)(AVCodecContext *c2, void *arg2), void *arg, int *ret, int count, int size)
46 {
47  int i;
48 
49  for (i = 0; i < count; i++) {
50  int r = func(c, (char *)arg + i * size);
51  if (ret)
52  ret[i] = r;
53  }
54  emms_c();
55  return 0;
56 }
57 
58 int avcodec_default_execute2(AVCodecContext *c, int (*func)(AVCodecContext *c2, void *arg2, int jobnr, int threadnr), void *arg, int *ret, int count)
59 {
60  int i;
61 
62  for (i = 0; i < count; i++) {
63  int r = func(c, arg, i, 0);
64  if (ret)
65  ret[i] = r;
66  }
67  emms_c();
68  return 0;
69 }
70 
72 
73 static void lock_avcodec(const FFCodec *codec)
74 {
77 }
78 
79 static void unlock_avcodec(const FFCodec *codec)
80 {
83 }
84 
86 {
87  int64_t bit_rate;
88  int bits_per_sample;
89 
90  switch (ctx->codec_type) {
91  case AVMEDIA_TYPE_VIDEO:
92  case AVMEDIA_TYPE_DATA:
95  bit_rate = ctx->bit_rate;
96  break;
97  case AVMEDIA_TYPE_AUDIO:
98  bits_per_sample = av_get_bits_per_sample(ctx->codec_id);
99  if (bits_per_sample) {
100  bit_rate = ctx->sample_rate * (int64_t)ctx->ch_layout.nb_channels;
101  if (bit_rate > INT64_MAX / bits_per_sample) {
102  bit_rate = 0;
103  } else
104  bit_rate *= bits_per_sample;
105  } else
106  bit_rate = ctx->bit_rate;
107  break;
108  default:
109  bit_rate = 0;
110  break;
111  }
112  return bit_rate;
113 }
114 
115 int attribute_align_arg avcodec_open2(AVCodecContext *avctx, const AVCodec *codec, AVDictionary **options)
116 {
117  int ret = 0;
118  AVCodecInternal *avci;
119  const FFCodec *codec2;
120 
121  if (avcodec_is_open(avctx))
122  return 0;
123 
124  if (!codec && !avctx->codec) {
125  av_log(avctx, AV_LOG_ERROR, "No codec provided to avcodec_open2()\n");
126  return AVERROR(EINVAL);
127  }
128  if (codec && avctx->codec && codec != avctx->codec) {
129  av_log(avctx, AV_LOG_ERROR, "This AVCodecContext was allocated for %s, "
130  "but %s passed to avcodec_open2()\n", avctx->codec->name, codec->name);
131  return AVERROR(EINVAL);
132  }
133  if (!codec)
134  codec = avctx->codec;
135  codec2 = ffcodec(codec);
136 
137  if ((avctx->codec_type != AVMEDIA_TYPE_UNKNOWN && avctx->codec_type != codec->type) ||
138  (avctx->codec_id != AV_CODEC_ID_NONE && avctx->codec_id != codec->id)) {
139  av_log(avctx, AV_LOG_ERROR, "Codec type or id mismatches\n");
140  return AVERROR(EINVAL);
141  }
142 
143  avctx->codec_type = codec->type;
144  avctx->codec_id = codec->id;
145  avctx->codec = codec;
146 
147  if (avctx->extradata_size < 0 || avctx->extradata_size >= FF_MAX_EXTRADATA_SIZE)
148  return AVERROR(EINVAL);
149 
150  avci = av_mallocz(sizeof(*avci));
151  if (!avci) {
152  ret = AVERROR(ENOMEM);
153  goto end;
154  }
155  avctx->internal = avci;
156 
157  avci->buffer_frame = av_frame_alloc();
158  avci->buffer_pkt = av_packet_alloc();
159  if (!avci->buffer_frame || !avci->buffer_pkt) {
160  ret = AVERROR(ENOMEM);
161  goto free_and_end;
162  }
163 
164  if (codec2->priv_data_size > 0) {
165  if (!avctx->priv_data) {
166  avctx->priv_data = av_mallocz(codec2->priv_data_size);
167  if (!avctx->priv_data) {
168  ret = AVERROR(ENOMEM);
169  goto free_and_end;
170  }
171  if (codec->priv_class) {
172  *(const AVClass **)avctx->priv_data = codec->priv_class;
174  }
175  }
176  if (codec->priv_class && (ret = av_opt_set_dict(avctx->priv_data, options)) < 0)
177  goto free_and_end;
178  } else {
179  avctx->priv_data = NULL;
180  }
181  if ((ret = av_opt_set_dict(avctx, options)) < 0)
182  goto free_and_end;
183 
184  if (avctx->codec_whitelist && av_match_list(codec->name, avctx->codec_whitelist, ',') <= 0) {
185  av_log(avctx, AV_LOG_ERROR, "Codec (%s) not on whitelist \'%s\'\n", codec->name, avctx->codec_whitelist);
186  ret = AVERROR(EINVAL);
187  goto free_and_end;
188  }
189 
190  // only call ff_set_dimensions() for non H.264/VP6F/DXV codecs so as not to overwrite previously setup dimensions
191  if (!(avctx->coded_width && avctx->coded_height && avctx->width && avctx->height &&
192  (avctx->codec_id == AV_CODEC_ID_H264 || avctx->codec_id == AV_CODEC_ID_VP6F || avctx->codec_id == AV_CODEC_ID_DXV))) {
193  if (avctx->coded_width && avctx->coded_height)
194  ret = ff_set_dimensions(avctx, avctx->coded_width, avctx->coded_height);
195  else if (avctx->width && avctx->height)
196  ret = ff_set_dimensions(avctx, avctx->width, avctx->height);
197  if (ret < 0)
198  goto free_and_end;
199  }
200 
201  if ((avctx->coded_width || avctx->coded_height || avctx->width || avctx->height)
202  && ( av_image_check_size2(avctx->coded_width, avctx->coded_height, avctx->max_pixels, AV_PIX_FMT_NONE, 0, avctx) < 0
203  || av_image_check_size2(avctx->width, avctx->height, avctx->max_pixels, AV_PIX_FMT_NONE, 0, avctx) < 0)) {
204  av_log(avctx, AV_LOG_WARNING, "Ignoring invalid width/height values\n");
205  ff_set_dimensions(avctx, 0, 0);
206  }
207 
208  if (avctx->width > 0 && avctx->height > 0) {
209  if (av_image_check_sar(avctx->width, avctx->height,
210  avctx->sample_aspect_ratio) < 0) {
211  av_log(avctx, AV_LOG_WARNING, "ignoring invalid SAR: %u/%u\n",
212  avctx->sample_aspect_ratio.num,
213  avctx->sample_aspect_ratio.den);
214  avctx->sample_aspect_ratio = (AVRational){ 0, 1 };
215  }
216  }
217 
218  if (avctx->sample_rate < 0) {
219  av_log(avctx, AV_LOG_ERROR, "Invalid sample rate: %d\n", avctx->sample_rate);
220  ret = AVERROR(EINVAL);
221  goto free_and_end;
222  }
223  if (avctx->block_align < 0) {
224  av_log(avctx, AV_LOG_ERROR, "Invalid block align: %d\n", avctx->block_align);
225  ret = AVERROR(EINVAL);
226  goto free_and_end;
227  }
228 
229 #if FF_API_OLD_CHANNEL_LAYOUT
231  /* compat wrapper for old-style callers */
232  if (avctx->channel_layout && !avctx->channels)
233  avctx->channels = av_popcount64(avctx->channel_layout);
234 
235  if ((avctx->channels && avctx->ch_layout.nb_channels != avctx->channels) ||
236  (avctx->channel_layout && (avctx->ch_layout.order != AV_CHANNEL_ORDER_NATIVE ||
237  avctx->ch_layout.u.mask != avctx->channel_layout))) {
239  if (avctx->channel_layout) {
240  av_channel_layout_from_mask(&avctx->ch_layout, avctx->channel_layout);
241  } else {
243  }
244  avctx->ch_layout.nb_channels = avctx->channels;
245  }
247 #endif
248 
249  /* AV_CODEC_CAP_CHANNEL_CONF is a decoder-only flag; so the code below
250  * in particular checks that nb_channels is set for all audio encoders. */
251  if (avctx->codec_type == AVMEDIA_TYPE_AUDIO && !avctx->ch_layout.nb_channels
252  && !(codec->capabilities & AV_CODEC_CAP_CHANNEL_CONF)) {
253  av_log(avctx, AV_LOG_ERROR, "%s requires channel layout to be set\n",
254  av_codec_is_decoder(codec) ? "Decoder" : "Encoder");
255  ret = AVERROR(EINVAL);
256  goto free_and_end;
257  }
258  if (avctx->ch_layout.nb_channels && !av_channel_layout_check(&avctx->ch_layout)) {
259  av_log(avctx, AV_LOG_ERROR, "Invalid channel layout\n");
260  ret = AVERROR(EINVAL);
261  goto free_and_end;
262  }
264  av_log(avctx, AV_LOG_ERROR, "Too many channels: %d\n", avctx->ch_layout.nb_channels);
265  ret = AVERROR(EINVAL);
266  goto free_and_end;
267  }
268 
269  avctx->frame_number = 0;
271 
272  if ((avctx->codec->capabilities & AV_CODEC_CAP_EXPERIMENTAL) &&
274  const char *codec_string = av_codec_is_encoder(codec) ? "encoder" : "decoder";
275  const AVCodec *codec2;
276  av_log(avctx, AV_LOG_ERROR,
277  "The %s '%s' is experimental but experimental codecs are not enabled, "
278  "add '-strict %d' if you want to use it.\n",
280  codec2 = av_codec_is_encoder(codec) ? avcodec_find_encoder(codec->id) : avcodec_find_decoder(codec->id);
281  if (!(codec2->capabilities & AV_CODEC_CAP_EXPERIMENTAL))
282  av_log(avctx, AV_LOG_ERROR, "Alternatively use the non experimental %s '%s'.\n",
283  codec_string, codec2->name);
285  goto free_and_end;
286  }
287 
288  if (avctx->codec_type == AVMEDIA_TYPE_AUDIO &&
289  (!avctx->time_base.num || !avctx->time_base.den)) {
290  avctx->time_base.num = 1;
291  avctx->time_base.den = avctx->sample_rate;
292  }
293 
294  if (av_codec_is_encoder(avctx->codec))
295  ret = ff_encode_preinit(avctx);
296  else
297  ret = ff_decode_preinit(avctx);
298  if (ret < 0)
299  goto free_and_end;
300 
301  if (HAVE_THREADS && !avci->frame_thread_encoder) {
302  /* Frame-threaded decoders call FFCodec.init for their child contexts. */
303  lock_avcodec(codec2);
304  ret = ff_thread_init(avctx);
305  unlock_avcodec(codec2);
306  if (ret < 0) {
307  goto free_and_end;
308  }
309  }
310  if (!HAVE_THREADS && !(codec2->caps_internal & FF_CODEC_CAP_AUTO_THREADS))
311  avctx->thread_count = 1;
312 
313  if (!(avctx->active_thread_type & FF_THREAD_FRAME) ||
314  avci->frame_thread_encoder) {
315  if (codec2->init) {
316  lock_avcodec(codec2);
317  ret = codec2->init(avctx);
318  unlock_avcodec(codec2);
319  if (ret < 0) {
321  goto free_and_end;
322  }
323  }
324  avci->needs_close = 1;
325  }
326 
327  ret=0;
328 
329  if (av_codec_is_decoder(avctx->codec)) {
330  if (!avctx->bit_rate)
331  avctx->bit_rate = get_bit_rate(avctx);
332 
333 #if FF_API_OLD_CHANNEL_LAYOUT
335  /* update the deprecated fields for old-style callers */
336  avctx->channels = avctx->ch_layout.nb_channels;
337  avctx->channel_layout = avctx->ch_layout.order == AV_CHANNEL_ORDER_NATIVE ?
338  avctx->ch_layout.u.mask : 0;
340 #endif
341 
342  /* validate channel layout from the decoder */
343  if ((avctx->ch_layout.nb_channels && !av_channel_layout_check(&avctx->ch_layout)) ||
345  ret = AVERROR(EINVAL);
346  goto free_and_end;
347  }
348  if (avctx->bits_per_coded_sample < 0) {
349  ret = AVERROR(EINVAL);
350  goto free_and_end;
351  }
352 
353 #if FF_API_AVCTX_TIMEBASE
354  if (avctx->framerate.num > 0 && avctx->framerate.den > 0)
355  avctx->time_base = av_inv_q(av_mul_q(avctx->framerate, (AVRational){avctx->ticks_per_frame, 1}));
356 #endif
357  }
358  if (codec->priv_class)
359  av_assert0(*(const AVClass **)avctx->priv_data == codec->priv_class);
360 
361 end:
362 
363  return ret;
364 free_and_end:
365  avcodec_close(avctx);
366  goto end;
367 }
368 
370 {
371  AVCodecInternal *avci = avctx->internal;
372 
373  if (av_codec_is_encoder(avctx->codec)) {
374  int caps = avctx->codec->capabilities;
375 
376  if (!(caps & AV_CODEC_CAP_ENCODER_FLUSH)) {
377  // Only encoders that explicitly declare support for it can be
378  // flushed. Otherwise, this is a no-op.
379  av_log(avctx, AV_LOG_WARNING, "Ignoring attempt to flush encoder "
380  "that doesn't support it\n");
381  return;
382  }
383  if (avci->in_frame)
384  av_frame_unref(avci->in_frame);
385  if (avci->recon_frame)
387  } else {
389  while (av_fifo_read(avci->pkt_props, avci->last_pkt_props, 1) >= 0)
391 
392  av_packet_unref(avci->in_pkt);
393 
394  avctx->pts_correction_last_pts =
395  avctx->pts_correction_last_dts = INT64_MIN;
396 
397  av_bsf_flush(avci->bsf);
398  }
399 
400  avci->draining = 0;
401  avci->draining_done = 0;
402  avci->nb_draining_errors = 0;
405 
406  if (HAVE_THREADS && avctx->active_thread_type & FF_THREAD_FRAME)
407  ff_thread_flush(avctx);
408  else if (ffcodec(avctx->codec)->flush)
409  ffcodec(avctx->codec)->flush(avctx);
410 }
411 
413 {
414  int i;
415 
416  for (i = 0; i < sub->num_rects; i++) {
417  AVSubtitleRect *const rect = sub->rects[i];
418 
419  av_freep(&rect->data[0]);
420  av_freep(&rect->data[1]);
421  av_freep(&rect->data[2]);
422  av_freep(&rect->data[3]);
423  av_freep(&rect->text);
424  av_freep(&rect->ass);
425 
426  av_freep(&sub->rects[i]);
427  }
428 
429  av_freep(&sub->rects);
430 
431  memset(sub, 0, sizeof(*sub));
432 }
433 
435 {
436  int i;
437 
438  if (!avctx)
439  return 0;
440 
441  if (avcodec_is_open(avctx)) {
442  AVCodecInternal *avci = avctx->internal;
443 
444  if (CONFIG_FRAME_THREAD_ENCODER &&
445  avci->frame_thread_encoder && avctx->thread_count > 1) {
447  }
448  if (HAVE_THREADS && avci->thread_ctx)
449  ff_thread_free(avctx);
450  if (avci->needs_close && ffcodec(avctx->codec)->close)
451  ffcodec(avctx->codec)->close(avctx);
452  avci->byte_buffer_size = 0;
453  av_freep(&avci->byte_buffer);
454  av_frame_free(&avci->buffer_frame);
455  av_packet_free(&avci->buffer_pkt);
456  if (avci->pkt_props) {
457  while (av_fifo_can_read(avci->pkt_props)) {
459  av_fifo_read(avci->pkt_props, avci->last_pkt_props, 1);
460  }
461  av_fifo_freep2(&avci->pkt_props);
462  }
464 
465  av_packet_free(&avci->in_pkt);
466  av_frame_free(&avci->in_frame);
467  av_frame_free(&avci->recon_frame);
468 
469  av_buffer_unref(&avci->pool);
470 
471  if (avctx->hwaccel && avctx->hwaccel->uninit)
472  avctx->hwaccel->uninit(avctx);
473  av_freep(&avci->hwaccel_priv_data);
474 
475  av_bsf_free(&avci->bsf);
476 
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;
490 
493 
494  if (avctx->priv_data && avctx->codec && avctx->codec->priv_class)
495  av_opt_free(avctx->priv_data);
496  av_opt_free(avctx);
497  av_freep(&avctx->priv_data);
498  if (av_codec_is_encoder(avctx->codec)) {
499  av_freep(&avctx->extradata);
500  avctx->extradata_size = 0;
501  } else if (av_codec_is_decoder(avctx->codec))
502  av_freep(&avctx->subtitle_header);
503 
504  avctx->codec = NULL;
505  avctx->active_thread_type = 0;
506 
507  return 0;
508 }
509 
510 static const char *unknown_if_null(const char *str)
511 {
512  return str ? str : "unknown";
513 }
514 
515 void 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;
521  int64_t bitrate;
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) {
554  case AVMEDIA_TYPE_VIDEO:
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 &&
573  av_bprintf(&bprint, "%d bpc, ", enc->bits_per_raw_sample);
574  if (enc->color_range != AVCOL_RANGE_UNSPECIFIED &&
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 
605  if (av_log_get_level() >= AV_LOG_VERBOSE &&
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 
627  if (av_log_get_level() >= AV_LOG_VERBOSE &&
628  (enc->width != enc->coded_width ||
629  enc->height != enc->coded_height))
630  av_bprintf(&bprint, " (%dx%d)",
631  enc->coded_width, enc->coded_height);
632 
633  if (enc->sample_aspect_ratio.num) {
634  av_reduce(&display_aspect_ratio.num, &display_aspect_ratio.den,
635  enc->width * (int64_t)enc->sample_aspect_ratio.num,
636  enc->height * (int64_t)enc->sample_aspect_ratio.den,
637  1024 * 1024);
638  av_bprintf(&bprint, " [SAR %d:%d DAR %d:%d]",
640  display_aspect_ratio.num, display_aspect_ratio.den);
641  }
642  if (av_log_get_level() >= AV_LOG_DEBUG) {
643  int g = av_gcd(enc->time_base.num, enc->time_base.den);
644  av_bprintf(&bprint, ", %d/%d",
645  enc->time_base.num / g, enc->time_base.den / g);
646  }
647  }
648  if (encode) {
649  av_bprintf(&bprint, ", q=%d-%d", enc->qmin, enc->qmax);
650  } else {
652  av_bprintf(&bprint, ", Closed Captions");
654  av_bprintf(&bprint, ", Film Grain");
656  av_bprintf(&bprint, ", lossless");
657  }
658  break;
659  case AVMEDIA_TYPE_AUDIO:
660  av_bprintf(&bprint, "%s", separator);
661 
662  if (enc->sample_rate) {
663  av_bprintf(&bprint, "%d Hz, ", enc->sample_rate);
664  }
665  {
666  char buf[512];
667  int ret = av_channel_layout_describe(&enc->ch_layout, buf, sizeof(buf));
668  if (ret >= 0)
669  av_bprintf(&bprint, "%s", buf);
670  }
671  if (enc->sample_fmt != AV_SAMPLE_FMT_NONE &&
673  av_bprintf(&bprint, ", %s", str);
674  }
675  if ( enc->bits_per_raw_sample > 0
677  av_bprintf(&bprint, " (%d bit)", enc->bits_per_raw_sample);
678  if (av_log_get_level() >= AV_LOG_VERBOSE) {
679  if (enc->initial_padding)
680  av_bprintf(&bprint, ", delay %d", enc->initial_padding);
681  if (enc->trailing_padding)
682  av_bprintf(&bprint, ", padding %d", enc->trailing_padding);
683  }
684  break;
685  case AVMEDIA_TYPE_DATA:
686  if (av_log_get_level() >= AV_LOG_DEBUG) {
687  int g = av_gcd(enc->time_base.num, enc->time_base.den);
688  if (g)
689  av_bprintf(&bprint, ", %d/%d",
690  enc->time_base.num / g, enc->time_base.den / g);
691  }
692  break;
694  if (enc->width)
695  av_bprintf(&bprint, ", %dx%d", enc->width, enc->height);
696  break;
697  default:
698  return;
699  }
700  if (encode) {
701  if (enc->flags & AV_CODEC_FLAG_PASS1)
702  av_bprintf(&bprint, ", pass 1");
703  if (enc->flags & AV_CODEC_FLAG_PASS2)
704  av_bprintf(&bprint, ", pass 2");
705  }
706  bitrate = get_bit_rate(enc);
707  if (bitrate != 0) {
708  av_bprintf(&bprint, ", %"PRId64" kb/s", bitrate / 1000);
709  } else if (enc->rc_max_rate > 0) {
710  av_bprintf(&bprint, ", max. %"PRId64" kb/s", enc->rc_max_rate / 1000);
711  }
712 }
713 
715 {
716  return !!s->internal;
717 }
718 
719 int attribute_align_arg avcodec_receive_frame(AVCodecContext *avctx, AVFrame *frame)
720 {
722 
723  if (av_codec_is_decoder(avctx->codec))
724  return ff_decode_receive_frame(avctx, frame);
725  return ff_encode_receive_frame(avctx, frame);
726 }
AVSubtitle
Definition: avcodec.h:2308
avcodec_close
av_cold int avcodec_close(AVCodecContext *avctx)
Close a given AVCodecContext and free all the data associated with it (but not the AVCodecContext its...
Definition: avcodec.c:434
func
int(* func)(AVBPrint *dst, const char *in, const char *arg)
Definition: jacosubdec.c:68
av_packet_unref
void av_packet_unref(AVPacket *pkt)
Wipe the packet.
Definition: avpacket.c:422
AVCodecContext::hwaccel
const struct AVHWAccel * hwaccel
Hardware accelerator in use.
Definition: avcodec.h:1369
AVCodec
AVCodec.
Definition: codec.h:204
FF_ENABLE_DEPRECATION_WARNINGS
#define FF_ENABLE_DEPRECATION_WARNINGS
Definition: internal.h:82
AVMEDIA_TYPE_SUBTITLE
@ AVMEDIA_TYPE_SUBTITLE
Definition: avutil.h:204
AV_CODEC_ID_VP6F
@ AV_CODEC_ID_VP6F
Definition: codec_id.h:144
AV_LOG_WARNING
#define AV_LOG_WARNING
Something somehow does not look correct.
Definition: log.h:186
AVERROR_EXPERIMENTAL
#define AVERROR_EXPERIMENTAL
Requested feature is flagged experimental. Set strict_std_compliance if you really want to use it.
Definition: error.h:74
FF_CODEC_CAP_INIT_CLEANUP
#define FF_CODEC_CAP_INIT_CLEANUP
The codec allows calling the close function for deallocation even if the init function returned a fai...
Definition: codec_internal.h:42
av_bprint_is_complete
static int av_bprint_is_complete(const AVBPrint *buf)
Test if the print buffer is complete (not truncated).
Definition: bprint.h:215
r
const char * r
Definition: vf_curves.c:126
AVERROR
Filter the word “frame” indicates either a video frame or a group of audio as stored in an AVFrame structure Format for each input and each output the list of supported formats For video that means pixel format For audio that means channel sample they are references to shared objects When the negotiation mechanism computes the intersection of the formats supported at each end of a all references to both lists are replaced with a reference to the intersection And when a single format is eventually chosen for a link amongst the remaining all references to the list are updated That means that if a filter requires that its input and output have the same format amongst a supported all it has to do is use a reference to the same list of formats query_formats can leave some formats unset and return AVERROR(EAGAIN) to cause the negotiation mechanism toagain later. That can be used by filters with complex requirements to use the format negotiated on one link to set the formats supported on another. Frame references ownership and permissions
opt.h
AVCodecContext::colorspace
enum AVColorSpace colorspace
YUV colorspace type.
Definition: avcodec.h:975
av_opt_set_defaults
void av_opt_set_defaults(void *s)
Set the values of all AVOption fields to their default values.
Definition: opt.c:1459
AVCodecContext::sample_rate
int sample_rate
samples per second
Definition: avcodec.h:1007
AVCodec::priv_class
const AVClass * priv_class
AVClass for the private context.
Definition: codec.h:236
sub
static float sub(float src0, float src1)
Definition: dnn_backend_native_layer_mathbinary.c:31
av_popcount64
#define av_popcount64
Definition: common.h:152
thread.h
av_pix_fmt_desc_get
const AVPixFmtDescriptor * av_pix_fmt_desc_get(enum AVPixelFormat pix_fmt)
Definition: pixdesc.c:2858
ff_thread_flush
void ff_thread_flush(AVCodecContext *avctx)
Wait for decoding threads to finish and reset internal state.
Definition: pthread_frame.c:939
rect
Definition: f_ebur128.c:76
avcodec_string
void avcodec_string(char *buf, int buf_size, AVCodecContext *enc, int encode)
Definition: avcodec.c:515
AVCodecContext::coded_side_data
AVPacketSideData * coded_side_data
Additional data associated with the entire coded stream.
Definition: avcodec.h:1858
AVSubtitleRect
Definition: avcodec.h:2280
av_frame_free
void av_frame_free(AVFrame **frame)
Free the frame and any dynamically allocated objects in it, e.g.
Definition: frame.c:116
avcodec_find_encoder
const AVCodec * avcodec_find_encoder(enum AVCodecID id)
Find a registered encoder with a matching codec ID.
Definition: allcodecs.c:946
ff_encode_receive_frame
int ff_encode_receive_frame(AVCodecContext *avctx, AVFrame *frame)
avcodec_receive_frame() implementation for encoders.
Definition: encode.c:716
AVFrame
This structure describes decoded (raw) audio or video data.
Definition: frame.h:325
AVCodecContext::color_trc
enum AVColorTransferCharacteristic color_trc
Color Transfer Characteristic.
Definition: avcodec.h:968
AVCodec::capabilities
int capabilities
Codec capabilities.
Definition: codec.h:223
internal.h
AVComponentDescriptor::depth
int depth
Number of bits in the component.
Definition: pixdesc.h:57
AVCodecContext::field_order
enum AVFieldOrder field_order
Field order.
Definition: avcodec.h:1004
AVCodecInternal::frame_thread_encoder
void * frame_thread_encoder
Definition: internal.h:106
AVCodecInternal::in_frame
AVFrame * in_frame
The input frame is stored here for encoders implementing the simple encode API.
Definition: internal.h:114
encode.h
AVCOL_TRC_UNSPECIFIED
@ AVCOL_TRC_UNSPECIFIED
Definition: pixfmt.h:561
unknown_if_null
static const char * unknown_if_null(const char *str)
Definition: avcodec.c:510
FF_CODEC_CAP_NOT_INIT_THREADSAFE
#define FF_CODEC_CAP_NOT_INIT_THREADSAFE
The codec is not known to be init-threadsafe (i.e.
Definition: codec_internal.h:34
FFCodec
Definition: codec_internal.h:119
AVCodecContext::subtitle_header
uint8_t * subtitle_header
Header containing style information for text subtitles.
Definition: avcodec.h:1708
AV_LOG_VERBOSE
#define AV_LOG_VERBOSE
Detailed information.
Definition: log.h:196
FF_COMPLIANCE_EXPERIMENTAL
#define FF_COMPLIANCE_EXPERIMENTAL
Allow nonstandardized experimental things.
Definition: defs.h:62
AVDictionary
Definition: dict.c:32
AVChannelLayout::order
enum AVChannelOrder order
Channel order used in this layout.
Definition: channel_layout.h:306
avcodec_profile_name
const char * avcodec_profile_name(enum AVCodecID codec_id, int profile)
Return a name for the specified profile, if available.
Definition: utils.c:469
ff_thread_init
int ff_thread_init(AVCodecContext *avctx)
Definition: pthread.c:74
avcodec_is_open
int avcodec_is_open(AVCodecContext *s)
Definition: avcodec.c:714
AVChannelLayout::mask
uint64_t mask
This member must be used for AV_CHANNEL_ORDER_NATIVE, and may be used for AV_CHANNEL_ORDER_AMBISONIC ...
Definition: channel_layout.h:333
AVCodecContext::qmax
int qmax
maximum quantizer
Definition: avcodec.h:1194
AVChannelLayout::nb_channels
int nb_channels
Number of channels in this layout.
Definition: channel_layout.h:311
codec_type
enum AVMediaType codec_type
Definition: rtp.c:37
ff_set_dimensions
int ff_set_dimensions(AVCodecContext *s, int width, int height)
Check that the provided frame dimensions are valid and set them on the codec context.
Definition: utils.c:91
av_bsf_free
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:53
thread.h
av_packet_free
void av_packet_free(AVPacket **pkt)
Free the packet, if the packet is reference counted, it will be unreferenced first.
Definition: avpacket.c:73
av_chroma_location_name
const char * av_chroma_location_name(enum AVChromaLocation location)
Definition: pixdesc.c:3255
AVCodecInternal::pool
AVBufferRef * pool
Definition: internal.h:71
av_gcd
int64_t av_gcd(int64_t a, int64_t b)
Compute the greatest common divisor of two integer operands.
Definition: mathematics.c:37
ff_mutex_unlock
static int ff_mutex_unlock(AVMutex *mutex)
Definition: thread.h:178
FFCodec::priv_data_size
int priv_data_size
Definition: codec_internal.h:137
AVCodecContext::framerate
AVRational framerate
Definition: avcodec.h:1735
fifo.h
bsf.h
av_color_space_name
const char * av_color_space_name(enum AVColorSpace space)
Definition: pixdesc.c:3234
av_bprint_init_for_buffer
void av_bprint_init_for_buffer(AVBPrint *buf, char *buffer, unsigned size)
Init a print buffer using a pre-existing buffer.
Definition: bprint.c:85
AVCodecContext::codec
const struct AVCodec * codec
Definition: avcodec.h:407
AVCodecContext::ch_layout
AVChannelLayout ch_layout
Audio channel layout.
Definition: avcodec.h:2059
AVCodecContext::thread_count
int thread_count
thread count is used to decide how many independent tasks should be passed to execute()
Definition: avcodec.h:1466
get_bit_rate
static int64_t get_bit_rate(AVCodecContext *ctx)
Definition: avcodec.c:85
AVCodecContext::initial_padding
int initial_padding
Audio only.
Definition: avcodec.h:1726
AVCodecContext::refs
int refs
number of reference frames
Definition: avcodec.h:947
AVCodecContext::flags
int flags
AV_CODEC_FLAG_*.
Definition: avcodec.h:478
AV_FIELD_UNKNOWN
@ AV_FIELD_UNKNOWN
Definition: codec_par.h:39
AVCodecContext::coded_height
int coded_height
Definition: avcodec.h:586
AV_CODEC_CAP_ENCODER_FLUSH
#define AV_CODEC_CAP_ENCODER_FLUSH
This encoder can be flushed using avcodec_flush_buffers().
Definition: codec.h:183
av_reduce
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
AVRational::num
int num
Numerator.
Definition: rational.h:59
av_image_check_size2
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
avsubtitle_free
void avsubtitle_free(AVSubtitle *sub)
Free all allocated data in the given subtitle struct.
Definition: avcodec.c:412
av_frame_alloc
AVFrame * av_frame_alloc(void)
Allocate an AVFrame and set its fields to default values.
Definition: frame.c:104
AVFormatContext::bit_rate
int64_t bit_rate
Total stream bitrate in bit/s, 0 if not available.
Definition: avformat.h:1325
av_get_bits_per_sample
int av_get_bits_per_sample(enum AVCodecID codec_id)
Return codec bits per sample.
Definition: utils.c:575
avassert.h
AVCodecContext::color_primaries
enum AVColorPrimaries color_primaries
Chromaticity coordinates of the source primaries.
Definition: avcodec.h:961
AV_LOG_ERROR
#define AV_LOG_ERROR
Something went wrong and cannot losslessly be recovered.
Definition: log.h:180
frame_thread_encoder.h
AV_CODEC_CAP_EXPERIMENTAL
#define AV_CODEC_CAP_EXPERIMENTAL
Codec is experimental and is thus avoided in favor of non experimental encoders.
Definition: codec.h:105
av_cold
#define av_cold
Definition: attributes.h:90
ff_decode_receive_frame
int ff_decode_receive_frame(AVCodecContext *avctx, AVFrame *frame)
avcodec_receive_frame() implementation for decoders.
Definition: decode.c:700
FF_CODEC_PROPERTY_LOSSLESS
#define FF_CODEC_PROPERTY_LOSSLESS
Definition: avcodec.h:1848
av_fifo_read
int av_fifo_read(AVFifo *f, void *buf, size_t nb_elems)
Read data from a FIFO.
Definition: fifo.c:240
AVMutex
#define AVMutex
Definition: thread.h:173
av_channel_layout_describe
int av_channel_layout_describe(const AVChannelLayout *channel_layout, char *buf, size_t buf_size)
Get a human-readable string describing the channel layout properties.
Definition: channel_layout.c:778
av_opt_set_dict
int av_opt_set_dict(void *obj, AVDictionary **options)
Set all the options from a given dictionary on an object.
Definition: opt.c:1767
AVCodecContext::extradata_size
int extradata_size
Definition: avcodec.h:500
s
#define s(width, name)
Definition: cbs_vp9.c:256
AVCodecInternal::buffer_pkt
AVPacket * buffer_pkt
Temporary buffers for newly received or not yet output packets/frames.
Definition: internal.h:148
av_bsf_flush
void av_bsf_flush(AVBSFContext *ctx)
Reset the internal bitstream filter state.
Definition: bsf.c:191
AVHWAccel::uninit
int(* uninit)(AVCodecContext *avctx)
Uninitialize the hwaccel private data.
Definition: avcodec.h:2196
g
const char * g
Definition: vf_curves.c:127
AVMEDIA_TYPE_AUDIO
@ AVMEDIA_TYPE_AUDIO
Definition: avutil.h:202
AV_CHANNEL_ORDER_UNSPEC
@ AV_CHANNEL_ORDER_UNSPEC
Only the channel count is specified, without any further information about the channel order.
Definition: channel_layout.h:112
av_channel_layout_from_mask
FF_ENABLE_DEPRECATION_WARNINGS int av_channel_layout_from_mask(AVChannelLayout *channel_layout, uint64_t mask)
Initialize a native channel layout from a bitmask indicating which channels are present.
Definition: channel_layout.c:391
unlock_avcodec
static void unlock_avcodec(const FFCodec *codec)
Definition: avcodec.c:79
avcodec_receive_frame
int attribute_align_arg avcodec_receive_frame(AVCodecContext *avctx, AVFrame *frame)
Return decoded output data from a decoder or encoder (when the AV_CODEC_FLAG_RECON_FRAME flag is used...
Definition: avcodec.c:719
av_assert0
#define av_assert0(cond)
assert() equivalent, that is always enabled.
Definition: avassert.h:37
AVCodecContext::bits_per_raw_sample
int bits_per_raw_sample
Bits per sample/pixel of internal libavcodec pixel/sample format.
Definition: avcodec.h:1451
AV_LOG_DEBUG
#define AV_LOG_DEBUG
Stuff which is only useful for libav* developers.
Definition: log.h:201
AVPacketSideData::data
uint8_t * data
Definition: packet.h:316
ctx
AVFormatContext * ctx
Definition: movenc.c:48
FFCodec::flush
void(* flush)(struct AVCodecContext *)
Flush buffers.
Definition: codec_internal.h:238
decode.h
AVCodecContext::max_pixels
int64_t max_pixels
The number of pixels per image to maximally accept.
Definition: avcodec.h:1911
ff_icc_context_uninit
void ff_icc_context_uninit(FFIccContext *s)
Definition: fflcms2.c:43
AVCodecContext::rc_max_rate
int64_t rc_max_rate
maximum bitrate
Definition: avcodec.h:1223
av_get_sample_fmt_name
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:51
AVMEDIA_TYPE_DATA
@ AVMEDIA_TYPE_DATA
Opaque data information usually continuous.
Definition: avutil.h:203
AVCOL_PRI_UNSPECIFIED
@ AVCOL_PRI_UNSPECIFIED
Definition: pixfmt.h:536
AV_CODEC_ID_H264
@ AV_CODEC_ID_H264
Definition: codec_id.h:79
ff_thread_free
void ff_thread_free(AVCodecContext *avctx)
Definition: pthread.c:86
FFCodec::init
int(* init)(struct AVCodecContext *)
Definition: codec_internal.h:170
AVCodecContext::codec_id
enum AVCodecID codec_id
Definition: avcodec.h:408
AVChannelLayout::u
union AVChannelLayout::@313 u
Details about which channels are present in this layout.
FF_CODEC_PROPERTY_FILM_GRAIN
#define FF_CODEC_PROPERTY_FILM_GRAIN
Definition: avcodec.h:1850
arg
const char * arg
Definition: jacosubdec.c:67
if
if(ret)
Definition: filter_design.txt:179
av_color_range_name
const char * av_color_range_name(enum AVColorRange range)
Definition: pixdesc.c:3174
av_log_get_level
int av_log_get_level(void)
Get the current log level.
Definition: log.c:437
AVClass
Describe the class of an AVClass context structure.
Definition: log.h:66
NULL
#define NULL
Definition: coverity.c:32
av_match_list
int av_match_list(const char *name, const char *list, char separator)
Check if a name is in a list.
Definition: avstring.c:455
AVCodecContext::color_range
enum AVColorRange color_range
MPEG vs JPEG YUV range.
Definition: avcodec.h:982
av_buffer_unref
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:139
AVCodec::type
enum AVMediaType type
Definition: codec.h:217
AVRational
Rational number (pair of numerator and denominator).
Definition: rational.h:58
AVCodecContext::nb_coded_side_data
int nb_coded_side_data
Definition: avcodec.h:1859
AVCodecContext::internal
struct AVCodecInternal * internal
Private context used for internal data.
Definition: avcodec.h:433
AVCodecContext::bit_rate
int64_t bit_rate
the average bitrate
Definition: avcodec.h:448
av_fifo_can_read
size_t av_fifo_can_read(const AVFifo *f)
Definition: fifo.c:87
AVCodecContext::trailing_padding
int trailing_padding
Audio only.
Definition: avcodec.h:1903
av_color_primaries_name
const char * av_color_primaries_name(enum AVColorPrimaries primaries)
Definition: pixdesc.c:3192
av_opt_free
void av_opt_free(void *obj)
Free all allocated objects in obj.
Definition: opt.c:1719
avcodec_open2
int attribute_align_arg avcodec_open2(AVCodecContext *avctx, const AVCodec *codec, AVDictionary **options)
Initialize the AVCodecContext to use the given AVCodec.
Definition: avcodec.c:115
AVCodecInternal::draining_done
int draining_done
Definition: internal.h:150
AVCOL_RANGE_UNSPECIFIED
@ AVCOL_RANGE_UNSPECIFIED
Definition: pixfmt.h:627
c
Undefined Behavior In the C some operations are like signed integer dereferencing freed accessing outside allocated Undefined Behavior must not occur in a C it is not safe even if the output of undefined operations is unused The unsafety may seem nit picking but Optimizing compilers have in fact optimized code on the assumption that no undefined Behavior occurs Optimizing code based on wrong assumptions can and has in some cases lead to effects beyond the output of computations The signed integer overflow problem in speed critical code Code which is highly optimized and works with signed integers sometimes has the problem that often the output of the computation does not c
Definition: undefined.txt:32
AVCodecInternal::last_pkt_props
AVPacket * last_pkt_props
Properties (timestamps+side data) extracted from the last packet passed for decoding.
Definition: internal.h:90
avcodec_find_decoder
const AVCodec * avcodec_find_decoder(enum AVCodecID id)
Find a registered decoder with a matching codec ID.
Definition: allcodecs.c:951
AV_CODEC_CAP_CHANNEL_CONF
#define AV_CODEC_CAP_CHANNEL_CONF
Codec should fill in channel configuration and samplerate instead of container.
Definition: codec.h:109
AVCodecContext::time_base
AVRational time_base
This is the fundamental unit of time (in seconds) in terms of which frame timestamps are represented.
Definition: avcodec.h:521
av_codec_is_decoder
int av_codec_is_decoder(const AVCodec *codec)
Definition: utils.c:83
options
const OptionDef options[]
codec_internal.h
AVCodecInternal::hwaccel_priv_data
void * hwaccel_priv_data
hwaccel-specific private data
Definition: internal.h:138
AV_CODEC_ID_DXV
@ AV_CODEC_ID_DXV
Definition: codec_id.h:243
AVCodecInternal::bsf
struct AVBSFContext * bsf
Definition: internal.h:84
AVCodecContext::sample_fmt
enum AVSampleFormat sample_fmt
audio sample format
Definition: avcodec.h:1023
AV_SAMPLE_FMT_NONE
@ AV_SAMPLE_FMT_NONE
Definition: samplefmt.h:56
AV_MUTEX_INITIALIZER
#define AV_MUTEX_INITIALIZER
Definition: thread.h:174
size
int size
Definition: twinvq_data.h:10344
AVCodecInternal::byte_buffer
uint8_t * byte_buffer
temporary buffer used for encoders to store their bitstream
Definition: internal.h:96
ffcodec
static const av_always_inline FFCodec * ffcodec(const AVCodec *codec)
Definition: codec_internal.h:317
AVCHROMA_LOC_UNSPECIFIED
@ AVCHROMA_LOC_UNSPECIFIED
Definition: pixfmt.h:681
AVMEDIA_TYPE_UNKNOWN
@ AVMEDIA_TYPE_UNKNOWN
Usually treated as AVMEDIA_TYPE_DATA.
Definition: avutil.h:200
codec_mutex
static AVMutex codec_mutex
Definition: avcodec.c:71
AV_CODEC_FLAG_PASS2
#define AV_CODEC_FLAG_PASS2
Use internal 2pass ratecontrol in second pass mode.
Definition: avcodec.h:251
encode
static void encode(AVCodecContext *ctx, AVFrame *frame, AVPacket *pkt, FILE *output)
Definition: encode_audio.c:94
AVCodecContext::pts_correction_last_pts
int64_t pts_correction_last_pts
Number of incorrect DTS values so far.
Definition: avcodec.h:1765
AV_FIELD_TT
@ AV_FIELD_TT
Top coded_first, top displayed first.
Definition: codec_par.h:41
avcodec_default_execute
int avcodec_default_execute(AVCodecContext *c, int(*func)(AVCodecContext *c2, void *arg2), void *arg, int *ret, int count, int size)
Definition: avcodec.c:45
AV_CHANNEL_ORDER_NATIVE
@ AV_CHANNEL_ORDER_NATIVE
The native channel order, i.e.
Definition: channel_layout.h:118
ff_mutex_lock
static int ff_mutex_lock(AVMutex *mutex)
Definition: thread.h:177
av_packet_alloc
AVPacket * av_packet_alloc(void)
Allocate an AVPacket and set its fields to default values.
Definition: avpacket.c:62
AVCodecInternal
Definition: internal.h:52
AVCodecInternal::byte_buffer_size
unsigned int byte_buffer_size
Definition: internal.h:97
bitrate
int64_t bitrate
Definition: h264_levels.c:131
ff_encode_preinit
int ff_encode_preinit(AVCodecContext *avctx)
Definition: encode.c:627
AVCodecInternal::pkt_props
struct AVFifo * pkt_props
Definition: internal.h:91
FF_THREAD_FRAME
#define FF_THREAD_FRAME
Decode more than one frame at once.
Definition: avcodec.h:1477
AVCodec::id
enum AVCodecID id
Definition: codec.h:218
av_codec_is_encoder
int av_codec_is_encoder(const AVCodec *codec)
Definition: utils.c:75
avcodec_get_name
const char * avcodec_get_name(enum AVCodecID id)
Get the name of a codec.
Definition: utils.c:436
AVCodecContext::bits_per_coded_sample
int bits_per_coded_sample
bits per sample/pixel from the demuxer (needed for huffyuv).
Definition: avcodec.h:1444
FFCodec::caps_internal
unsigned caps_internal
Internal codec capabilities FF_CODEC_CAP_*.
Definition: codec_internal.h:128
bprint.h
avcodec_default_execute2
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:58
AV_CODEC_ID_NONE
@ AV_CODEC_ID_NONE
Definition: codec_id.h:50
i
#define i(width, name, range_min, range_max)
Definition: cbs_h2645.c:269
AVCodecContext::properties
unsigned properties
Properties of the stream that gets decoded.
Definition: avcodec.h:1847
av_get_bytes_per_sample
int av_get_bytes_per_sample(enum AVSampleFormat sample_fmt)
Return number of bytes per sample.
Definition: samplefmt.c:108
AVCodecContext::extradata
uint8_t * extradata
some codecs need / can use extradata like Huffman tables.
Definition: avcodec.h:499
AVCodecInternal::in_pkt
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
AVCodecContext::pts_correction_last_dts
int64_t pts_correction_last_dts
PTS of the last frame.
Definition: avcodec.h:1766
ff_decode_preinit
int ff_decode_preinit(AVCodecContext *avctx)
Perform decoder initialization and validation.
Definition: decode.c:1576
AVMEDIA_TYPE_ATTACHMENT
@ AVMEDIA_TYPE_ATTACHMENT
Opaque data information usually sparse.
Definition: avutil.h:205
AVCodecContext::dump_separator
uint8_t * dump_separator
dump format separator.
Definition: avcodec.h:1832
av_frame_unref
void av_frame_unref(AVFrame *frame)
Unreference all the buffers referenced by frame and reset the frame fields.
Definition: frame.c:487
av_mallocz
void * av_mallocz(size_t size)
Allocate a memory block with alignment suitable for all memory accesses (including vectors if availab...
Definition: mem.c:264
AVCodec::name
const char * name
Name of the codec implementation.
Definition: codec.h:211
av_inv_q
static av_always_inline AVRational av_inv_q(AVRational q)
Invert a rational.
Definition: rational.h:159
AVCodecContext::hw_device_ctx
AVBufferRef * hw_device_ctx
A reference to the AVHWDeviceContext describing the device which will be used by a hardware encoder/d...
Definition: avcodec.h:1933
AVCodecContext::chroma_sample_location
enum AVChromaLocation chroma_sample_location
This defines the location of chroma samples.
Definition: avcodec.h:989
len
int len
Definition: vorbis_enc_data.h:426
profile
int profile
Definition: mxfenc.c:2006
AVCOL_SPC_UNSPECIFIED
@ AVCOL_SPC_UNSPECIFIED
Definition: pixfmt.h:590
AVCodecContext::height
int height
Definition: avcodec.h:571
AVCodecContext::pix_fmt
enum AVPixelFormat pix_fmt
Pixel format, see AV_PIX_FMT_xxx.
Definition: avcodec.h:608
AVCodecInternal::nb_draining_errors
int nb_draining_errors
Definition: internal.h:155
AVCodecContext::hw_frames_ctx
AVBufferRef * hw_frames_ctx
A reference to the AVHWFramesContext describing the input (for encoding) or output (decoding) frames.
Definition: avcodec.h:1883
avcodec.h
ret
ret
Definition: filter_design.txt:187
AVCodecContext::block_align
int block_align
number of bytes per packet if constant and known or 0 Used by some WAV based audio codecs.
Definition: avcodec.h:1052
avcodec_flush_buffers
void avcodec_flush_buffers(AVCodecContext *avctx)
Reset the internal codec state / flush internal buffers.
Definition: avcodec.c:369
frame
these buffered frames must be flushed immediately if a new input produces new the filter must not call request_frame to get more It must just process the frame or queue it The task of requesting more frames is left to the filter s request_frame method or the application If a filter has several the filter must be ready for frames arriving randomly on any input any filter with several inputs will most likely require some kind of queuing mechanism It is perfectly acceptable to have a limited queue and to drop frames when the inputs are too unbalanced request_frame For filters that do not use the this method is called when a frame is wanted on an output For a it should directly call filter_frame on the corresponding output For a if there are queued frames already one of these frames should be pushed If the filter should request a frame on one of its repeatedly until at least one frame has been pushed Return or at least make progress towards producing a frame
Definition: filter_design.txt:264
AVCodecContext::strict_std_compliance
int strict_std_compliance
strictly follow the standard (MPEG-4, ...).
Definition: avcodec.h:1310
av_channel_layout_check
int av_channel_layout_check(const AVChannelLayout *channel_layout)
Check whether a channel layout is valid, i.e.
Definition: channel_layout.c:906
av_bprintf
void av_bprintf(AVBPrint *buf, const char *fmt,...)
Definition: bprint.c:94
AVCodecInternal::recon_frame
AVFrame * recon_frame
When the AV_CODEC_FLAG_RECON_FRAME flag is used.
Definition: internal.h:122
AVCodecInternal::needs_close
int needs_close
If this is set, then FFCodec->close (if existing) needs to be called for the parent AVCodecContext.
Definition: internal.h:128
av_get_media_type_string
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
AVCodecContext
main external API structure.
Definition: avcodec.h:398
AVCodecContext::active_thread_type
int active_thread_type
Which multithreading methods are in use by the codec.
Definition: avcodec.h:1485
AVCodecContext::codec_descriptor
const AVCodecDescriptor * codec_descriptor
AVCodecDescriptor.
Definition: avcodec.h:1756
c2
static const uint64_t c2
Definition: murmur3.c:52
channel_layout.h
AVCodecContext::qmin
int qmin
minimum quantizer
Definition: avcodec.h:1187
AVRational::den
int den
Denominator.
Definition: rational.h:60
AV_PIX_FMT_NONE
@ AV_PIX_FMT_NONE
Definition: pixfmt.h:65
AVCodecContext::profile
int profile
profile
Definition: avcodec.h:1550
av_channel_layout_uninit
void av_channel_layout_uninit(AVChannelLayout *channel_layout)
Free any allocated data in the channel layout and reset the channel count to 0.
Definition: channel_layout.c:632
AVPixFmtDescriptor::comp
AVComponentDescriptor comp[4]
Parameters that describe how pixels are packed.
Definition: pixdesc.h:105
FF_CODEC_PROPERTY_CLOSED_CAPTIONS
#define FF_CODEC_PROPERTY_CLOSED_CAPTIONS
Definition: avcodec.h:1849
av_mul_q
AVRational av_mul_q(AVRational b, AVRational c)
Multiply two rationals.
Definition: rational.c:80
FFCodec::close
int(* close)(struct AVCodecContext *)
Definition: codec_internal.h:232
ff_frame_thread_encoder_free
av_cold void ff_frame_thread_encoder_free(AVCodecContext *avctx)
Definition: frame_thread_encoder.c:261
AVCodecInternal::buffer_frame
AVFrame * buffer_frame
Definition: internal.h:149
AVCodecInternal::draining
int draining
checks API usage: after codec draining, flush is required to resume operation
Definition: internal.h:143
FF_DISABLE_DEPRECATION_WARNINGS
#define FF_DISABLE_DEPRECATION_WARNINGS
Definition: internal.h:81
AVCodecContext::coded_width
int coded_width
Bitstream width / height, may be different from width/height e.g.
Definition: avcodec.h:586
AVCodecContext::codec_type
enum AVMediaType codec_type
Definition: avcodec.h:406
AVMEDIA_TYPE_VIDEO
@ AVMEDIA_TYPE_VIDEO
Definition: avutil.h:201
mem.h
FF_CODEC_CAP_AUTO_THREADS
#define FF_CODEC_CAP_AUTO_THREADS
Codec handles avctx->thread_count == 0 (auto) internally.
Definition: codec_internal.h:73
AVCodecInternal::initial_ch_layout
AVChannelLayout initial_ch_layout
Definition: internal.h:162
AVCodecContext::frame_number
int frame_number
Frame counter, set by libavcodec.
Definition: avcodec.h:1046
AVCodecContext::codec_tag
unsigned int codec_tag
fourcc (LSB first, so "ABCD" -> ('D'<<24) + ('C'<<16) + ('B'<<8) + 'A').
Definition: avcodec.h:423
FF_MAX_EXTRADATA_SIZE
#define FF_MAX_EXTRADATA_SIZE
Maximum size in bytes of extradata.
Definition: internal.h:184
AVCodecContext::priv_data
void * priv_data
Definition: avcodec.h:425
av_freep
#define av_freep(p)
Definition: tableprint_vlc.h:34
AV_FIELD_TB
@ AV_FIELD_TB
Top coded first, bottom displayed first.
Definition: codec_par.h:43
codec_string
Definition: dashenc.c:206
AV_FIELD_BB
@ AV_FIELD_BB
Bottom coded first, bottom displayed first.
Definition: codec_par.h:42
AVCodecInternal::thread_ctx
void * thread_ctx
Definition: internal.h:73
AVCodecContext::width
int width
picture width / height.
Definition: avcodec.h:571
convert_header.str
string str
Definition: convert_header.py:20
imgutils.h
av_log
#define av_log(a,...)
Definition: tableprint_vlc.h:27
av_fifo_freep2
void av_fifo_freep2(AVFifo **f)
Free an AVFifo and reset pointer to NULL.
Definition: fifo.c:286
av_bprint_chars
void av_bprint_chars(AVBPrint *buf, char c, unsigned n)
Append char c n times to a print buffer.
Definition: bprint.c:140
avcodec_descriptor_get
const AVCodecDescriptor * avcodec_descriptor_get(enum AVCodecID id)
Definition: codec_desc.c:3617
av_image_check_sar
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
avstring.h
FF_SANE_NB_CHANNELS
#define FF_SANE_NB_CHANNELS
Definition: internal.h:40
AVCodecContext::codec_whitelist
char * codec_whitelist
',' separated list of allowed decoders.
Definition: avcodec.h:1840
lock_avcodec
static void lock_avcodec(const FFCodec *codec)
Definition: avcodec.c:73
AV_FIELD_BT
@ AV_FIELD_BT
Bottom coded first, top displayed first.
Definition: codec_par.h:44
av_color_transfer_name
const char * av_color_transfer_name(enum AVColorTransferCharacteristic transfer)
Definition: pixdesc.c:3213
AVCodecContext::sample_aspect_ratio
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:768
av_get_pix_fmt_name
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:2778
AV_CODEC_FLAG_PASS1
#define AV_CODEC_FLAG_PASS1
Use internal 2pass ratecontrol in first pass mode.
Definition: avcodec.h:247
av_fourcc2str
#define av_fourcc2str(fourcc)
Definition: avutil.h:354