FFmpeg
utils.c
Go to the documentation of this file.
1 /*
2  * utils for libavcodec
3  * Copyright (c) 2001 Fabrice Bellard
4  * Copyright (c) 2002-2004 Michael Niedermayer <michaelni@gmx.at>
5  *
6  * This file is part of FFmpeg.
7  *
8  * FFmpeg is free software; you can redistribute it and/or
9  * modify it under the terms of the GNU Lesser General Public
10  * License as published by the Free Software Foundation; either
11  * version 2.1 of the License, or (at your option) any later version.
12  *
13  * FFmpeg is distributed in the hope that it will be useful,
14  * but WITHOUT ANY WARRANTY; without even the implied warranty of
15  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
16  * Lesser General Public License for more details.
17  *
18  * You should have received a copy of the GNU Lesser General Public
19  * License along with FFmpeg; if not, write to the Free Software
20  * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
21  */
22 
23 /**
24  * @file
25  * utils.
26  */
27 
28 #include "config.h"
29 #include "libavutil/avassert.h"
30 #include "libavutil/avstring.h"
31 #include "libavutil/intreadwrite.h"
32 #include "libavutil/mem_internal.h"
33 #include "libavutil/pixdesc.h"
34 #include "libavutil/imgutils.h"
35 #include "libavutil/pixfmt.h"
36 #include "avcodec.h"
37 #include "codec.h"
38 #include "hwconfig.h"
39 #include "thread.h"
40 #include "internal.h"
41 #include "put_bits.h"
42 #include "raw.h"
43 #include "version.h"
44 #include <stdlib.h>
45 #include <stdarg.h>
46 #include <stdatomic.h>
47 #include <limits.h>
48 #include <float.h>
49 
50 void av_fast_padded_malloc(void *ptr, unsigned int *size, size_t min_size)
51 {
52  uint8_t **p = ptr;
53  if (min_size > SIZE_MAX - AV_INPUT_BUFFER_PADDING_SIZE) {
54  av_freep(p);
55  *size = 0;
56  return;
57  }
58  if (!ff_fast_malloc(p, size, min_size + AV_INPUT_BUFFER_PADDING_SIZE, 1))
59  memset(*p + min_size, 0, AV_INPUT_BUFFER_PADDING_SIZE);
60 }
61 
62 void av_fast_padded_mallocz(void *ptr, unsigned int *size, size_t min_size)
63 {
64  uint8_t **p = ptr;
65  if (min_size > SIZE_MAX - AV_INPUT_BUFFER_PADDING_SIZE) {
66  av_freep(p);
67  *size = 0;
68  return;
69  }
70  if (!ff_fast_malloc(p, size, min_size + AV_INPUT_BUFFER_PADDING_SIZE, 1))
71  memset(*p, 0, min_size + AV_INPUT_BUFFER_PADDING_SIZE);
72 }
73 
74 int av_codec_is_encoder(const AVCodec *codec)
75 {
76  return codec && (codec->encode_sub || codec->encode2 || codec->receive_packet);
77 }
78 
79 int av_codec_is_decoder(const AVCodec *codec)
80 {
81  return codec && (codec->decode || codec->receive_frame);
82 }
83 
85 {
86  int ret = av_image_check_size2(width, height, s->max_pixels, AV_PIX_FMT_NONE, 0, s);
87 
88  if (ret < 0)
89  width = height = 0;
90 
91  s->coded_width = width;
92  s->coded_height = height;
93  s->width = AV_CEIL_RSHIFT(width, s->lowres);
94  s->height = AV_CEIL_RSHIFT(height, s->lowres);
95 
96  return ret;
97 }
98 
100 {
101  int ret = av_image_check_sar(avctx->width, avctx->height, sar);
102 
103  if (ret < 0) {
104  av_log(avctx, AV_LOG_WARNING, "ignoring invalid SAR: %d/%d\n",
105  sar.num, sar.den);
106  avctx->sample_aspect_ratio = (AVRational){ 0, 1 };
107  return ret;
108  } else {
109  avctx->sample_aspect_ratio = sar;
110  }
111  return 0;
112 }
113 
115  enum AVMatrixEncoding matrix_encoding)
116 {
117  AVFrameSideData *side_data;
118  enum AVMatrixEncoding *data;
119 
121  if (!side_data)
123  sizeof(enum AVMatrixEncoding));
124 
125  if (!side_data)
126  return AVERROR(ENOMEM);
127 
128  data = (enum AVMatrixEncoding*)side_data->data;
129  *data = matrix_encoding;
130 
131  return 0;
132 }
133 
135  int linesize_align[AV_NUM_DATA_POINTERS])
136 {
137  int i;
138  int w_align = 1;
139  int h_align = 1;
141 
142  if (desc) {
143  w_align = 1 << desc->log2_chroma_w;
144  h_align = 1 << desc->log2_chroma_h;
145  }
146 
147  switch (s->pix_fmt) {
148  case AV_PIX_FMT_YUV420P:
149  case AV_PIX_FMT_YUYV422:
150  case AV_PIX_FMT_YVYU422:
151  case AV_PIX_FMT_UYVY422:
152  case AV_PIX_FMT_YUV422P:
153  case AV_PIX_FMT_YUV440P:
154  case AV_PIX_FMT_YUV444P:
155  case AV_PIX_FMT_GBRP:
156  case AV_PIX_FMT_GBRAP:
157  case AV_PIX_FMT_GRAY8:
158  case AV_PIX_FMT_GRAY16BE:
159  case AV_PIX_FMT_GRAY16LE:
160  case AV_PIX_FMT_YUVJ420P:
161  case AV_PIX_FMT_YUVJ422P:
162  case AV_PIX_FMT_YUVJ440P:
163  case AV_PIX_FMT_YUVJ444P:
164  case AV_PIX_FMT_YUVA420P:
165  case AV_PIX_FMT_YUVA422P:
166  case AV_PIX_FMT_YUVA444P:
223  case AV_PIX_FMT_GBRP9LE:
224  case AV_PIX_FMT_GBRP9BE:
225  case AV_PIX_FMT_GBRP10LE:
226  case AV_PIX_FMT_GBRP10BE:
227  case AV_PIX_FMT_GBRP12LE:
228  case AV_PIX_FMT_GBRP12BE:
229  case AV_PIX_FMT_GBRP14LE:
230  case AV_PIX_FMT_GBRP14BE:
231  case AV_PIX_FMT_GBRP16LE:
232  case AV_PIX_FMT_GBRP16BE:
237  w_align = 16; //FIXME assume 16 pixel per macroblock
238  h_align = 16 * 2; // interlaced needs 2 macroblocks height
239  break;
240  case AV_PIX_FMT_YUV411P:
241  case AV_PIX_FMT_YUVJ411P:
243  w_align = 32;
244  h_align = 16 * 2;
245  break;
246  case AV_PIX_FMT_YUV410P:
247  if (s->codec_id == AV_CODEC_ID_SVQ1) {
248  w_align = 64;
249  h_align = 64;
250  }
251  break;
252  case AV_PIX_FMT_RGB555:
253  if (s->codec_id == AV_CODEC_ID_RPZA) {
254  w_align = 4;
255  h_align = 4;
256  }
258  w_align = 8;
259  h_align = 8;
260  }
261  break;
262  case AV_PIX_FMT_PAL8:
263  case AV_PIX_FMT_BGR8:
264  case AV_PIX_FMT_RGB8:
265  if (s->codec_id == AV_CODEC_ID_SMC ||
267  w_align = 4;
268  h_align = 4;
269  }
270  if (s->codec_id == AV_CODEC_ID_JV ||
272  w_align = 8;
273  h_align = 8;
274  }
275  break;
276  case AV_PIX_FMT_BGR24:
277  if ((s->codec_id == AV_CODEC_ID_MSZH) ||
278  (s->codec_id == AV_CODEC_ID_ZLIB)) {
279  w_align = 4;
280  h_align = 4;
281  }
282  break;
283  case AV_PIX_FMT_RGB24:
284  if (s->codec_id == AV_CODEC_ID_CINEPAK) {
285  w_align = 4;
286  h_align = 4;
287  }
288  break;
289  default:
290  break;
291  }
292 
293  if (s->codec_id == AV_CODEC_ID_IFF_ILBM) {
294  w_align = FFMAX(w_align, 8);
295  }
296 
297  *width = FFALIGN(*width, w_align);
298  *height = FFALIGN(*height, h_align);
299  if (s->codec_id == AV_CODEC_ID_H264 || s->lowres ||
302  ) {
303  // some of the optimized chroma MC reads one line too much
304  // which is also done in mpeg decoders with lowres > 0
305  *height += 2;
306 
307  // H.264 uses edge emulation for out of frame motion vectors, for this
308  // it requires a temporary area large enough to hold a 21x21 block,
309  // increasing witdth ensure that the temporary area is large enough,
310  // the next rounded up width is 32
311  *width = FFMAX(*width, 32);
312  }
313 
314  for (i = 0; i < 4; i++)
315  linesize_align[i] = STRIDE_ALIGN;
316 }
317 
319 {
321  int chroma_shift = desc->log2_chroma_w;
322  int linesize_align[AV_NUM_DATA_POINTERS];
323  int align;
324 
325  avcodec_align_dimensions2(s, width, height, linesize_align);
326  align = FFMAX(linesize_align[0], linesize_align[3]);
327  linesize_align[1] <<= chroma_shift;
328  linesize_align[2] <<= chroma_shift;
329  align = FFMAX3(align, linesize_align[1], linesize_align[2]);
330  *width = FFALIGN(*width, align);
331 }
332 
333 int avcodec_enum_to_chroma_pos(int *xpos, int *ypos, enum AVChromaLocation pos)
334 {
335  if (pos <= AVCHROMA_LOC_UNSPECIFIED || pos >= AVCHROMA_LOC_NB)
336  return AVERROR(EINVAL);
337  pos--;
338 
339  *xpos = (pos&1) * 128;
340  *ypos = ((pos>>1)^(pos<4)) * 128;
341 
342  return 0;
343 }
344 
346 {
347  int pos, xout, yout;
348 
349  for (pos = AVCHROMA_LOC_UNSPECIFIED + 1; pos < AVCHROMA_LOC_NB; pos++) {
350  if (avcodec_enum_to_chroma_pos(&xout, &yout, pos) == 0 && xout == xpos && yout == ypos)
351  return pos;
352  }
354 }
355 
357  enum AVSampleFormat sample_fmt, const uint8_t *buf,
358  int buf_size, int align)
359 {
360  int ch, planar, needed_size, ret = 0;
361 
362  needed_size = av_samples_get_buffer_size(NULL, nb_channels,
363  frame->nb_samples, sample_fmt,
364  align);
365  if (buf_size < needed_size)
366  return AVERROR(EINVAL);
367 
368  planar = av_sample_fmt_is_planar(sample_fmt);
369  if (planar && nb_channels > AV_NUM_DATA_POINTERS) {
370  if (!(frame->extended_data = av_mallocz_array(nb_channels,
371  sizeof(*frame->extended_data))))
372  return AVERROR(ENOMEM);
373  } else {
374  frame->extended_data = frame->data;
375  }
376 
377  if ((ret = av_samples_fill_arrays(frame->extended_data, &frame->linesize[0],
378  (uint8_t *)(intptr_t)buf, nb_channels, frame->nb_samples,
379  sample_fmt, align)) < 0) {
380  if (frame->extended_data != frame->data)
381  av_freep(&frame->extended_data);
382  return ret;
383  }
384  if (frame->extended_data != frame->data) {
385  for (ch = 0; ch < AV_NUM_DATA_POINTERS; ch++)
386  frame->data[ch] = frame->extended_data[ch];
387  }
388 
389  return ret;
390 }
391 
392 void ff_color_frame(AVFrame *frame, const int c[4])
393 {
395  int p, y;
396 
398 
399  for (p = 0; p<desc->nb_components; p++) {
400  uint8_t *dst = frame->data[p];
401  int is_chroma = p == 1 || p == 2;
402  int bytes = is_chroma ? AV_CEIL_RSHIFT(frame->width, desc->log2_chroma_w) : frame->width;
403  int height = is_chroma ? AV_CEIL_RSHIFT(frame->height, desc->log2_chroma_h) : frame->height;
404  if (desc->comp[0].depth >= 9) {
405  ((uint16_t*)dst)[0] = c[p];
406  av_memcpy_backptr(dst + 2, 2, bytes - 2);
407  dst += frame->linesize[p];
408  for (y = 1; y < height; y++) {
409  memcpy(dst, frame->data[p], 2*bytes);
410  dst += frame->linesize[p];
411  }
412  } else {
413  for (y = 0; y < height; y++) {
414  memset(dst, c[p], bytes);
415  dst += frame->linesize[p];
416  }
417  }
418  }
419 }
420 
422  unsigned int fourcc)
423 {
424  while (tags->pix_fmt >= 0) {
425  if (tags->fourcc == fourcc)
426  return tags->pix_fmt;
427  tags++;
428  }
429  return AV_PIX_FMT_NONE;
430 }
431 
432 #if FF_API_CODEC_GET_SET
433 MAKE_ACCESSORS(AVCodecContext, codec, AVRational, pkt_timebase)
434 MAKE_ACCESSORS(AVCodecContext, codec, const AVCodecDescriptor *, codec_descriptor)
436 MAKE_ACCESSORS(AVCodecContext, codec, int, seek_preroll)
437 MAKE_ACCESSORS(AVCodecContext, codec, uint16_t*, chroma_intra_matrix)
438 
440 {
441  return codec->properties;
442 }
443 
445 {
446  return codec->max_lowres;
447 }
448 #endif
449 
452 }
453 
454 const char *avcodec_get_name(enum AVCodecID id)
455 {
456  const AVCodecDescriptor *cd;
457  const AVCodec *codec;
458 
459  if (id == AV_CODEC_ID_NONE)
460  return "none";
461  cd = avcodec_descriptor_get(id);
462  if (cd)
463  return cd->name;
464  av_log(NULL, AV_LOG_WARNING, "Codec 0x%x is not in the full list.\n", id);
465  codec = avcodec_find_decoder(id);
466  if (codec)
467  return codec->name;
468  codec = avcodec_find_encoder(id);
469  if (codec)
470  return codec->name;
471  return "unknown_codec";
472 }
473 
474 #if FF_API_TAG_STRING
475 size_t av_get_codec_tag_string(char *buf, size_t buf_size, unsigned int codec_tag)
476 {
477  int i, len, ret = 0;
478 
479 #define TAG_PRINT(x) \
480  (((x) >= '0' && (x) <= '9') || \
481  ((x) >= 'a' && (x) <= 'z') || ((x) >= 'A' && (x) <= 'Z') || \
482  ((x) == '.' || (x) == ' ' || (x) == '-' || (x) == '_'))
483 
484  for (i = 0; i < 4; i++) {
485  len = snprintf(buf, buf_size,
486  TAG_PRINT(codec_tag & 0xFF) ? "%c" : "[%d]", codec_tag & 0xFF);
487  buf += len;
488  buf_size = buf_size > len ? buf_size - len : 0;
489  ret += len;
490  codec_tag >>= 8;
491  }
492  return ret;
493 }
494 #endif
495 
496 const char *av_get_profile_name(const AVCodec *codec, int profile)
497 {
498  const AVProfile *p;
499  if (profile == FF_PROFILE_UNKNOWN || !codec->profiles)
500  return NULL;
501 
502  for (p = codec->profiles; p->profile != FF_PROFILE_UNKNOWN; p++)
503  if (p->profile == profile)
504  return p->name;
505 
506  return NULL;
507 }
508 
510 {
511  const AVCodecDescriptor *desc = avcodec_descriptor_get(codec_id);
512  const AVProfile *p;
513 
514  if (profile == FF_PROFILE_UNKNOWN || !desc || !desc->profiles)
515  return NULL;
516 
517  for (p = desc->profiles; p->profile != FF_PROFILE_UNKNOWN; p++)
518  if (p->profile == profile)
519  return p->name;
520 
521  return NULL;
522 }
523 
525 {
526  switch (codec_id) {
542  return 4;
550  case AV_CODEC_ID_PCM_S8:
552  case AV_CODEC_ID_PCM_SGA:
553  case AV_CODEC_ID_PCM_U8:
556  return 8;
563  return 16;
570  return 24;
580  return 32;
585  return 64;
586  default:
587  return 0;
588  }
589 }
590 
592 {
593  static const enum AVCodecID map[][2] = {
599  [AV_SAMPLE_FMT_U8P ] = { AV_CODEC_ID_PCM_U8, AV_CODEC_ID_PCM_U8 },
600  [AV_SAMPLE_FMT_S16P] = { AV_CODEC_ID_PCM_S16LE, AV_CODEC_ID_PCM_S16BE },
601  [AV_SAMPLE_FMT_S32P] = { AV_CODEC_ID_PCM_S32LE, AV_CODEC_ID_PCM_S32BE },
603  [AV_SAMPLE_FMT_FLTP] = { AV_CODEC_ID_PCM_F32LE, AV_CODEC_ID_PCM_F32BE },
604  [AV_SAMPLE_FMT_DBLP] = { AV_CODEC_ID_PCM_F64LE, AV_CODEC_ID_PCM_F64BE },
605  };
606  if (fmt < 0 || fmt >= FF_ARRAY_ELEMS(map))
607  return AV_CODEC_ID_NONE;
608  if (be < 0 || be > 1)
609  be = AV_NE(1, 0);
610  return map[fmt][be];
611 }
612 
614 {
615  switch (codec_id) {
617  return 2;
619  return 3;
625  return 4;
626  default:
627  return av_get_exact_bits_per_sample(codec_id);
628  }
629 }
630 
631 static int get_audio_frame_duration(enum AVCodecID id, int sr, int ch, int ba,
632  uint32_t tag, int bits_per_coded_sample, int64_t bitrate,
633  uint8_t * extradata, int frame_size, int frame_bytes)
634 {
636  int framecount = (ba > 0 && frame_bytes / ba > 0) ? frame_bytes / ba : 1;
637 
638  /* codecs with an exact constant bits per sample */
639  if (bps > 0 && ch > 0 && frame_bytes > 0 && ch < 32768 && bps < 32768)
640  return (frame_bytes * 8LL) / (bps * ch);
641  bps = bits_per_coded_sample;
642 
643  /* codecs with a fixed packet duration */
644  switch (id) {
645  case AV_CODEC_ID_ADPCM_ADX: return 32;
646  case AV_CODEC_ID_ADPCM_IMA_QT: return 64;
647  case AV_CODEC_ID_ADPCM_EA_XAS: return 128;
648  case AV_CODEC_ID_AMR_NB:
649  case AV_CODEC_ID_EVRC:
650  case AV_CODEC_ID_GSM:
651  case AV_CODEC_ID_QCELP:
652  case AV_CODEC_ID_RA_288: return 160;
653  case AV_CODEC_ID_AMR_WB:
654  case AV_CODEC_ID_GSM_MS: return 320;
655  case AV_CODEC_ID_MP1: return 384;
656  case AV_CODEC_ID_ATRAC1: return 512;
657  case AV_CODEC_ID_ATRAC9:
658  case AV_CODEC_ID_ATRAC3:
659  if (framecount > INT_MAX/1024)
660  return 0;
661  return 1024 * framecount;
662  case AV_CODEC_ID_ATRAC3P: return 2048;
663  case AV_CODEC_ID_MP2:
664  case AV_CODEC_ID_MUSEPACK7: return 1152;
665  case AV_CODEC_ID_AC3: return 1536;
666  }
667 
668  if (sr > 0) {
669  /* calc from sample rate */
670  if (id == AV_CODEC_ID_TTA)
671  return 256 * sr / 245;
672  else if (id == AV_CODEC_ID_DST)
673  return 588 * sr / 44100;
674  else if (id == AV_CODEC_ID_BINKAUDIO_DCT) {
675  if (sr / 22050 > 22)
676  return 0;
677  return (480 << (sr / 22050));
678  }
679 
680  if (id == AV_CODEC_ID_MP3)
681  return sr <= 24000 ? 576 : 1152;
682  }
683 
684  if (ba > 0) {
685  /* calc from block_align */
686  if (id == AV_CODEC_ID_SIPR) {
687  switch (ba) {
688  case 20: return 160;
689  case 19: return 144;
690  case 29: return 288;
691  case 37: return 480;
692  }
693  } else if (id == AV_CODEC_ID_ILBC) {
694  switch (ba) {
695  case 38: return 160;
696  case 50: return 240;
697  }
698  }
699  }
700 
701  if (frame_bytes > 0) {
702  /* calc from frame_bytes only */
703  if (id == AV_CODEC_ID_TRUESPEECH)
704  return 240 * (frame_bytes / 32);
705  if (id == AV_CODEC_ID_NELLYMOSER)
706  return 256 * (frame_bytes / 64);
707  if (id == AV_CODEC_ID_RA_144)
708  return 160 * (frame_bytes / 20);
709 
710  if (bps > 0) {
711  /* calc from frame_bytes and bits_per_coded_sample */
713  return frame_bytes * 8 / bps;
714  }
715 
716  if (ch > 0 && ch < INT_MAX/16) {
717  /* calc from frame_bytes and channels */
718  switch (id) {
720  return frame_bytes / (40 * ch) * 256;
722  return (frame_bytes - 4 * ch) / (128 * ch) * 256;
724  return frame_bytes / (9 * ch) * 16;
727  frame_bytes /= 16 * ch;
728  if (frame_bytes > INT_MAX / 28)
729  return 0;
730  return frame_bytes * 28;
734  return (frame_bytes - 4 * ch) * 2 / ch;
736  return (frame_bytes - 4) * 2 / ch;
738  return (frame_bytes - 8) * 2;
741  if (extradata)
742  return frame_bytes * 14 / (8 * ch);
743  break;
745  return (frame_bytes / 128) * 224 / ch;
747  return (frame_bytes - 6 - ch) / ch;
749  return (frame_bytes - 8) / ch;
751  return (frame_bytes - 2 * ch) / ch;
752  case AV_CODEC_ID_MACE3:
753  return 3 * frame_bytes / ch;
754  case AV_CODEC_ID_MACE6:
755  return 6 * frame_bytes / ch;
756  case AV_CODEC_ID_PCM_LXF:
757  return 2 * (frame_bytes / (5 * ch));
758  case AV_CODEC_ID_IAC:
759  case AV_CODEC_ID_IMC:
760  return 4 * frame_bytes / ch;
761  }
762 
763  if (tag) {
764  /* calc from frame_bytes, channels, and codec_tag */
765  if (id == AV_CODEC_ID_SOL_DPCM) {
766  if (tag == 3)
767  return frame_bytes / ch;
768  else
769  return frame_bytes * 2 / ch;
770  }
771  }
772 
773  if (ba > 0) {
774  /* calc from frame_bytes, channels, and block_align */
775  int blocks = frame_bytes / ba;
776  switch (id) {
778  if (bps < 2 || bps > 5)
779  return 0;
780  return blocks * (1 + (ba - 4 * ch) / (bps * ch) * 8);
782  return blocks * (((ba - 16) * 2 / 3 * 4) / ch);
784  return blocks * (1 + (ba - 4 * ch) * 2 / ch);
786  return blocks * ((ba - 4 * ch) * 2 / ch);
788  return blocks * (2 + (ba - 7 * ch) * 2LL / ch);
790  return blocks * (ba - 16) * 2 / ch;
791  }
792  }
793 
794  if (bps > 0) {
795  /* calc from frame_bytes, channels, and bits_per_coded_sample */
796  switch (id) {
797  case AV_CODEC_ID_PCM_DVD:
798  if(bps<4 || frame_bytes<3)
799  return 0;
800  return 2 * ((frame_bytes - 3) / ((bps * 2 / 8) * ch));
802  if(bps<4 || frame_bytes<4)
803  return 0;
804  return (frame_bytes - 4) / ((FFALIGN(ch, 2) * bps) / 8);
805  case AV_CODEC_ID_S302M:
806  return 2 * (frame_bytes / ((bps + 4) / 4)) / ch;
807  }
808  }
809  }
810  }
811 
812  /* Fall back on using frame_size */
813  if (frame_size > 1 && frame_bytes)
814  return frame_size;
815 
816  //For WMA we currently have no other means to calculate duration thus we
817  //do it here by assuming CBR, which is true for all known cases.
818  if (bitrate > 0 && frame_bytes > 0 && sr > 0 && ba > 1) {
819  if (id == AV_CODEC_ID_WMAV1 || id == AV_CODEC_ID_WMAV2)
820  return (frame_bytes * 8LL * sr) / bitrate;
821  }
822 
823  return 0;
824 }
825 
826 int av_get_audio_frame_duration(AVCodecContext *avctx, int frame_bytes)
827 {
828  return get_audio_frame_duration(avctx->codec_id, avctx->sample_rate,
829  avctx->channels, avctx->block_align,
830  avctx->codec_tag, avctx->bits_per_coded_sample,
831  avctx->bit_rate, avctx->extradata, avctx->frame_size,
832  frame_bytes);
833 }
834 
836 {
838  par->channels, par->block_align,
839  par->codec_tag, par->bits_per_coded_sample,
840  par->bit_rate, par->extradata, par->frame_size,
841  frame_bytes);
842 }
843 
844 #if !HAVE_THREADS
846 {
847  return -1;
848 }
849 
850 #endif
851 
852 unsigned int av_xiphlacing(unsigned char *s, unsigned int v)
853 {
854  unsigned int n = 0;
855 
856  while (v >= 0xff) {
857  *s++ = 0xff;
858  v -= 0xff;
859  n++;
860  }
861  *s = v;
862  n++;
863  return n;
864 }
865 
866 int ff_match_2uint16(const uint16_t(*tab)[2], int size, int a, int b)
867 {
868  int i;
869  for (i = 0; i < size && !(tab[i][0] == a && tab[i][1] == b); i++) ;
870  return i;
871 }
872 
874 {
875  int i;
876  if (!codec->hw_configs || index < 0)
877  return NULL;
878  for (i = 0; i <= index; i++)
879  if (!codec->hw_configs[i])
880  return NULL;
881  return &codec->hw_configs[index]->public;
882 }
883 
884 #if FF_API_USER_VISIBLE_AVHWACCEL
886 {
887  return NULL;
888 }
889 
891 {
892 }
893 #endif
894 
895 unsigned int avpriv_toupper4(unsigned int x)
896 {
897  return av_toupper(x & 0xFF) +
898  (av_toupper((x >> 8) & 0xFF) << 8) +
899  (av_toupper((x >> 16) & 0xFF) << 16) +
900 ((unsigned)av_toupper((x >> 24) & 0xFF) << 24);
901 }
902 
904 {
905  int ret;
906 
907  dst->owner[0] = src->owner[0];
908  dst->owner[1] = src->owner[1];
909 
910  ret = av_frame_ref(dst->f, src->f);
911  if (ret < 0)
912  return ret;
913 
914  av_assert0(!dst->progress);
915 
916  if (src->progress &&
917  !(dst->progress = av_buffer_ref(src->progress))) {
918  ff_thread_release_buffer(dst->owner[0], dst);
919  return AVERROR(ENOMEM);
920  }
921 
922  return 0;
923 }
924 
925 #if !HAVE_THREADS
926 
928 {
929  return ff_get_format(avctx, fmt);
930 }
931 
933 {
934  f->owner[0] = f->owner[1] = avctx;
935  return ff_get_buffer(avctx, f->f, flags);
936 }
937 
939 {
940  if (f->f)
941  av_frame_unref(f->f);
942 }
943 
945 {
946 }
947 
948 void ff_thread_report_progress(ThreadFrame *f, int progress, int field)
949 {
950 }
951 
952 void ff_thread_await_progress(ThreadFrame *f, int progress, int field)
953 {
954 }
955 
957 {
958  return 1;
959 }
960 
962 {
963  return 0;
964 }
965 
967 {
968 }
969 
970 void ff_thread_await_progress2(AVCodecContext *avctx, int field, int thread, int shift)
971 {
972 }
973 
974 void ff_thread_report_progress2(AVCodecContext *avctx, int field, int thread, int n)
975 {
976 }
977 
978 #endif
979 
980 const uint8_t *avpriv_find_start_code(const uint8_t *av_restrict p,
981  const uint8_t *end,
982  uint32_t *av_restrict state)
983 {
984  int i;
985 
986  av_assert0(p <= end);
987  if (p >= end)
988  return end;
989 
990  for (i = 0; i < 3; i++) {
991  uint32_t tmp = *state << 8;
992  *state = tmp + *(p++);
993  if (tmp == 0x100 || p == end)
994  return p;
995  }
996 
997  while (p < end) {
998  if (p[-1] > 1 ) p += 3;
999  else if (p[-2] ) p += 2;
1000  else if (p[-3]|(p[-1]-1)) p++;
1001  else {
1002  p++;
1003  break;
1004  }
1005  }
1006 
1007  p = FFMIN(p, end) - 4;
1008  *state = AV_RB32(p);
1009 
1010  return p + 4;
1011 }
1012 
1014 {
1015  AVCPBProperties *props = av_mallocz(sizeof(AVCPBProperties));
1016  if (!props)
1017  return NULL;
1018 
1019  if (size)
1020  *size = sizeof(*props);
1021 
1022  props->vbv_delay = UINT64_MAX;
1023 
1024  return props;
1025 }
1026 
1028 {
1030  AVCPBProperties *props;
1031  size_t size;
1032  int i;
1033 
1034  for (i = 0; i < avctx->nb_coded_side_data; i++)
1036  return (AVCPBProperties *)avctx->coded_side_data[i].data;
1037 
1038  props = av_cpb_properties_alloc(&size);
1039  if (!props)
1040  return NULL;
1041 
1042  tmp = av_realloc_array(avctx->coded_side_data, avctx->nb_coded_side_data + 1, sizeof(*tmp));
1043  if (!tmp) {
1044  av_freep(&props);
1045  return NULL;
1046  }
1047 
1048  avctx->coded_side_data = tmp;
1049  avctx->nb_coded_side_data++;
1050 
1052  avctx->coded_side_data[avctx->nb_coded_side_data - 1].data = (uint8_t*)props;
1053  avctx->coded_side_data[avctx->nb_coded_side_data - 1].size = size;
1054 
1055  return props;
1056 }
1057 
1058 static unsigned bcd2uint(uint8_t bcd)
1059 {
1060  unsigned low = bcd & 0xf;
1061  unsigned high = bcd >> 4;
1062  if (low > 9 || high > 9)
1063  return 0;
1064  return low + 10*high;
1065 }
1066 
1067 int ff_alloc_timecode_sei(const AVFrame *frame, AVRational rate, size_t prefix_len,
1068  void **data, size_t *sei_size)
1069 {
1070  AVFrameSideData *sd = NULL;
1071  uint8_t *sei_data;
1072  PutBitContext pb;
1073  uint32_t *tc;
1074  int m;
1075 
1076  if (frame)
1078 
1079  if (!sd) {
1080  *data = NULL;
1081  return 0;
1082  }
1083  tc = (uint32_t*)sd->data;
1084  m = tc[0] & 3;
1085 
1086  *sei_size = sizeof(uint32_t) * 4;
1087  *data = av_mallocz(*sei_size + prefix_len);
1088  if (!*data)
1089  return AVERROR(ENOMEM);
1090  sei_data = (uint8_t*)*data + prefix_len;
1091 
1092  init_put_bits(&pb, sei_data, *sei_size);
1093  put_bits(&pb, 2, m); // num_clock_ts
1094 
1095  for (int j = 1; j <= m; j++) {
1096  uint32_t tcsmpte = tc[j];
1097  unsigned hh = bcd2uint(tcsmpte & 0x3f); // 6-bit hours
1098  unsigned mm = bcd2uint(tcsmpte>>8 & 0x7f); // 7-bit minutes
1099  unsigned ss = bcd2uint(tcsmpte>>16 & 0x7f); // 7-bit seconds
1100  unsigned ff = bcd2uint(tcsmpte>>24 & 0x3f); // 6-bit frames
1101  unsigned drop = tcsmpte & 1<<30 && !0; // 1-bit drop if not arbitrary bit
1102 
1103  /* Calculate frame number of HEVC by SMPTE ST 12-1:2014 Sec 12.2 if rate > 30FPS */
1104  if (av_cmp_q(rate, (AVRational) {30, 1}) == 1) {
1105  unsigned pc;
1106  ff *= 2;
1107  if (av_cmp_q(rate, (AVRational) {50, 1}) == 0)
1108  pc = !!(tcsmpte & 1 << 7);
1109  else
1110  pc = !!(tcsmpte & 1 << 23);
1111  ff = (ff + pc) & 0x7f;
1112  }
1113 
1114  put_bits(&pb, 1, 1); // clock_timestamp_flag
1115  put_bits(&pb, 1, 1); // units_field_based_flag
1116  put_bits(&pb, 5, 0); // counting_type
1117  put_bits(&pb, 1, 1); // full_timestamp_flag
1118  put_bits(&pb, 1, 0); // discontinuity_flag
1119  put_bits(&pb, 1, drop);
1120  put_bits(&pb, 9, ff);
1121  put_bits(&pb, 6, ss);
1122  put_bits(&pb, 6, mm);
1123  put_bits(&pb, 5, hh);
1124  put_bits(&pb, 5, 0);
1125  }
1126  flush_put_bits(&pb);
1127 
1128  return 0;
1129 }
1130 
1132 {
1133  AVRational framerate = avctx->framerate;
1134  int bits_per_coded_sample = avctx->bits_per_coded_sample;
1135  int64_t bitrate;
1136 
1137  if (!(framerate.num && framerate.den))
1138  framerate = av_inv_q(avctx->time_base);
1139  if (!(framerate.num && framerate.den))
1140  return 0;
1141 
1142  if (!bits_per_coded_sample) {
1144  bits_per_coded_sample = av_get_bits_per_pixel(desc);
1145  }
1146  bitrate = (int64_t)bits_per_coded_sample * avctx->width * avctx->height *
1147  framerate.num / framerate.den;
1148 
1149  return bitrate;
1150 }
1151 
1152 int ff_int_from_list_or_default(void *ctx, const char * val_name, int val,
1153  const int * array_valid_values, int default_value)
1154 {
1155  int i = 0, ref_val;
1156 
1157  while (1) {
1158  ref_val = array_valid_values[i];
1159  if (ref_val == INT_MAX)
1160  break;
1161  if (val == ref_val)
1162  return val;
1163  i++;
1164  }
1165  /* val is not a valid value */
1166  av_log(ctx, AV_LOG_DEBUG,
1167  "%s %d are not supported. Set to default value : %d\n", val_name, val, default_value);
1168  return default_value;
1169 }
int64_t ff_guess_coded_bitrate(AVCodecContext *avctx)
Get an estimated video bitrate based on frame size, frame rate and coded bits per pixel...
Definition: utils.c:1131
packed YUV 4:2:2, 16bpp, Cb Y0 Cr Y1
Definition: pixfmt.h:81
AVCodecHWConfig public
This is the structure which will be returned to the user by avcodec_get_hw_config().
Definition: hwconfig.h:34
float, planar
Definition: samplefmt.h:69
#define NULL
Definition: coverity.c:32
int ff_get_format(AVCodecContext *avctx, const enum AVPixelFormat *fmt)
Select the (possibly hardware accelerated) pixel format.
Definition: decode.c:1317
planar YUV 4:2:2, 18bpp, (1 Cr & Cb sample per 2x1 Y samples), big-endian
Definition: pixfmt.h:166
AVRational framerate
Definition: avcodec.h:2071
planar YUV 4:4:0,20bpp, (1 Cr & Cb sample per 1x2 Y samples), little-endian
Definition: pixfmt.h:275
planar YUV 4:4:4,42bpp, (1 Cr & Cb sample per 1x1 Y samples), big-endian
Definition: pixfmt.h:252
int(* receive_packet)(struct AVCodecContext *avctx, struct AVPacket *avpkt)
Encode API with decoupled frame/packet dataflow.
Definition: codec.h:311
#define AV_NUM_DATA_POINTERS
Definition: frame.h:319
static int shift(int a, int b)
Definition: sonic.c:82
planar YUV 4:2:0,21bpp, (1 Cr & Cb sample per 2x2 Y samples), little-endian
Definition: pixfmt.h:245
unsigned int fourcc
Definition: raw.h:36
const AVPixFmtDescriptor * av_pix_fmt_desc_get(enum AVPixelFormat pix_fmt)
Definition: pixdesc.c:2573
This structure describes decoded (raw) audio or video data.
Definition: frame.h:318
int av_codec_is_encoder(const AVCodec *codec)
Definition: utils.c:74
ptrdiff_t const GLvoid * data
Definition: opengl_enc.c:100
planar YUV 4:2:2,28bpp, (1 Cr & Cb sample per 2x1 Y samples), little-endian
Definition: pixfmt.h:249
planar YUV 4:2:0, 15bpp, (1 Cr & Cb sample per 2x2 Y samples), little-endian
Definition: pixfmt.h:159
int coded_width
Bitstream width / height, may be different from width/height e.g.
Definition: avcodec.h:724
const char * desc
Definition: libsvtav1.c:79
planar YUV 4:4:4, 24bpp, (1 Cr & Cb sample per 1x1 Y samples)
Definition: pixfmt.h:71
misc image utilities
static void put_bits(Jpeg2000EncoderContext *s, int val, int n)
put n times val bit
Definition: j2kenc.c:218
#define AV_LOG_WARNING
Something somehow does not look correct.
Definition: log.h:200
AVFrame * f
Definition: thread.h:35
int64_t bit_rate
the average bitrate
Definition: avcodec.h:586
planar YUV 4:4:4,36bpp, (1 Cr & Cb sample per 1x1 Y samples), 12b alpha, little-endian ...
Definition: pixfmt.h:346
packed RGB 8:8:8, 24bpp, RGBRGB...
Definition: pixfmt.h:68
uint8_t pi<< 24) CONV_FUNC(AV_SAMPLE_FMT_S64, int64_t, AV_SAMPLE_FMT_U8,(uint64_t)((*(const uint8_t *) pi-0x80U))<< 56) CONV_FUNC(AV_SAMPLE_FMT_FLT, float, AV_SAMPLE_FMT_U8,(*(const uint8_t *) pi-0x80)*(1.0f/(1<< 7))) CONV_FUNC(AV_SAMPLE_FMT_DBL, double, AV_SAMPLE_FMT_U8,(*(const uint8_t *) pi-0x80)*(1.0/(1<< 7))) CONV_FUNC(AV_SAMPLE_FMT_U8, uint8_t, AV_SAMPLE_FMT_S16,(*(const int16_t *) pi >>8)+0x80) CONV_FUNC(AV_SAMPLE_FMT_S32, int32_t, AV_SAMPLE_FMT_S16,*(const int16_t *) pi *(1<< 16)) CONV_FUNC(AV_SAMPLE_FMT_S64, int64_t, AV_SAMPLE_FMT_S16,(uint64_t)(*(const int16_t *) pi)<< 48) CONV_FUNC(AV_SAMPLE_FMT_FLT, float, AV_SAMPLE_FMT_S16,*(const int16_t *) pi *(1.0f/(1<< 15))) CONV_FUNC(AV_SAMPLE_FMT_DBL, double, AV_SAMPLE_FMT_S16,*(const int16_t *) pi *(1.0/(1<< 15))) CONV_FUNC(AV_SAMPLE_FMT_U8, uint8_t, AV_SAMPLE_FMT_S32,(*(const int32_t *) pi >>24)+0x80) CONV_FUNC(AV_SAMPLE_FMT_S64, int64_t, AV_SAMPLE_FMT_S32,(uint64_t)(*(const int32_t *) pi)<< 32) CONV_FUNC(AV_SAMPLE_FMT_FLT, float, AV_SAMPLE_FMT_S32,*(const int32_t *) pi *(1.0f/(1U<< 31))) CONV_FUNC(AV_SAMPLE_FMT_DBL, double, AV_SAMPLE_FMT_S32,*(const int32_t *) pi *(1.0/(1U<< 31))) CONV_FUNC(AV_SAMPLE_FMT_U8, uint8_t, AV_SAMPLE_FMT_S64,(*(const int64_t *) pi >>56)+0x80) CONV_FUNC(AV_SAMPLE_FMT_FLT, float, AV_SAMPLE_FMT_S64,*(const int64_t *) pi *(1.0f/(UINT64_C(1)<< 63))) CONV_FUNC(AV_SAMPLE_FMT_DBL, double, AV_SAMPLE_FMT_S64,*(const int64_t *) pi *(1.0/(UINT64_C(1)<< 63))) CONV_FUNC(AV_SAMPLE_FMT_U8, uint8_t, AV_SAMPLE_FMT_FLT, av_clip_uint8(lrintf(*(const float *) pi *(1<< 7))+0x80)) CONV_FUNC(AV_SAMPLE_FMT_S16, int16_t, AV_SAMPLE_FMT_FLT, av_clip_int16(lrintf(*(const float *) pi *(1<< 15)))) CONV_FUNC(AV_SAMPLE_FMT_S32, int32_t, AV_SAMPLE_FMT_FLT, av_clipl_int32(llrintf(*(const float *) pi *(1U<< 31)))) CONV_FUNC(AV_SAMPLE_FMT_S64, int64_t, AV_SAMPLE_FMT_FLT, llrintf(*(const float *) pi *(UINT64_C(1)<< 63))) CONV_FUNC(AV_SAMPLE_FMT_U8, uint8_t, AV_SAMPLE_FMT_DBL, av_clip_uint8(lrint(*(const double *) pi *(1<< 7))+0x80)) CONV_FUNC(AV_SAMPLE_FMT_S16, int16_t, AV_SAMPLE_FMT_DBL, av_clip_int16(lrint(*(const double *) pi *(1<< 15)))) CONV_FUNC(AV_SAMPLE_FMT_S32, int32_t, AV_SAMPLE_FMT_DBL, av_clipl_int32(llrint(*(const double *) pi *(1U<< 31)))) CONV_FUNC(AV_SAMPLE_FMT_S64, int64_t, AV_SAMPLE_FMT_DBL, llrint(*(const double *) pi *(UINT64_C(1)<< 63)))#define FMT_PAIR_FUNC(out, in) static conv_func_type *const fmt_pair_to_conv_functions[AV_SAMPLE_FMT_NB *AV_SAMPLE_FMT_NB]={FMT_PAIR_FUNC(AV_SAMPLE_FMT_U8, AV_SAMPLE_FMT_U8), FMT_PAIR_FUNC(AV_SAMPLE_FMT_S16, AV_SAMPLE_FMT_U8), FMT_PAIR_FUNC(AV_SAMPLE_FMT_S32, AV_SAMPLE_FMT_U8), FMT_PAIR_FUNC(AV_SAMPLE_FMT_FLT, AV_SAMPLE_FMT_U8), FMT_PAIR_FUNC(AV_SAMPLE_FMT_DBL, AV_SAMPLE_FMT_U8), FMT_PAIR_FUNC(AV_SAMPLE_FMT_S64, AV_SAMPLE_FMT_U8), FMT_PAIR_FUNC(AV_SAMPLE_FMT_U8, AV_SAMPLE_FMT_S16), FMT_PAIR_FUNC(AV_SAMPLE_FMT_S16, AV_SAMPLE_FMT_S16), FMT_PAIR_FUNC(AV_SAMPLE_FMT_S32, AV_SAMPLE_FMT_S16), FMT_PAIR_FUNC(AV_SAMPLE_FMT_FLT, AV_SAMPLE_FMT_S16), FMT_PAIR_FUNC(AV_SAMPLE_FMT_DBL, AV_SAMPLE_FMT_S16), FMT_PAIR_FUNC(AV_SAMPLE_FMT_S64, AV_SAMPLE_FMT_S16), FMT_PAIR_FUNC(AV_SAMPLE_FMT_U8, AV_SAMPLE_FMT_S32), FMT_PAIR_FUNC(AV_SAMPLE_FMT_S16, AV_SAMPLE_FMT_S32), FMT_PAIR_FUNC(AV_SAMPLE_FMT_S32, AV_SAMPLE_FMT_S32), FMT_PAIR_FUNC(AV_SAMPLE_FMT_FLT, AV_SAMPLE_FMT_S32), FMT_PAIR_FUNC(AV_SAMPLE_FMT_DBL, AV_SAMPLE_FMT_S32), FMT_PAIR_FUNC(AV_SAMPLE_FMT_S64, AV_SAMPLE_FMT_S32), FMT_PAIR_FUNC(AV_SAMPLE_FMT_U8, AV_SAMPLE_FMT_FLT), FMT_PAIR_FUNC(AV_SAMPLE_FMT_S16, AV_SAMPLE_FMT_FLT), FMT_PAIR_FUNC(AV_SAMPLE_FMT_S32, AV_SAMPLE_FMT_FLT), FMT_PAIR_FUNC(AV_SAMPLE_FMT_FLT, AV_SAMPLE_FMT_FLT), FMT_PAIR_FUNC(AV_SAMPLE_FMT_DBL, AV_SAMPLE_FMT_FLT), FMT_PAIR_FUNC(AV_SAMPLE_FMT_S64, AV_SAMPLE_FMT_FLT), FMT_PAIR_FUNC(AV_SAMPLE_FMT_U8, AV_SAMPLE_FMT_DBL), FMT_PAIR_FUNC(AV_SAMPLE_FMT_S16, AV_SAMPLE_FMT_DBL), FMT_PAIR_FUNC(AV_SAMPLE_FMT_S32, AV_SAMPLE_FMT_DBL), FMT_PAIR_FUNC(AV_SAMPLE_FMT_FLT, AV_SAMPLE_FMT_DBL), FMT_PAIR_FUNC(AV_SAMPLE_FMT_DBL, AV_SAMPLE_FMT_DBL), FMT_PAIR_FUNC(AV_SAMPLE_FMT_S64, AV_SAMPLE_FMT_DBL), FMT_PAIR_FUNC(AV_SAMPLE_FMT_U8, AV_SAMPLE_FMT_S64), FMT_PAIR_FUNC(AV_SAMPLE_FMT_S16, AV_SAMPLE_FMT_S64), FMT_PAIR_FUNC(AV_SAMPLE_FMT_S32, AV_SAMPLE_FMT_S64), FMT_PAIR_FUNC(AV_SAMPLE_FMT_FLT, AV_SAMPLE_FMT_S64), FMT_PAIR_FUNC(AV_SAMPLE_FMT_DBL, AV_SAMPLE_FMT_S64), FMT_PAIR_FUNC(AV_SAMPLE_FMT_S64, AV_SAMPLE_FMT_S64),};static void cpy1(uint8_t **dst, const uint8_t **src, int len){memcpy(*dst,*src, len);}static void cpy2(uint8_t **dst, const uint8_t **src, int len){memcpy(*dst,*src, 2 *len);}static void cpy4(uint8_t **dst, const uint8_t **src, int len){memcpy(*dst,*src, 4 *len);}static void cpy8(uint8_t **dst, const uint8_t **src, int len){memcpy(*dst,*src, 8 *len);}AudioConvert *swri_audio_convert_alloc(enum AVSampleFormat out_fmt, enum AVSampleFormat in_fmt, int channels, const int *ch_map, int flags){AudioConvert *ctx;conv_func_type *f=fmt_pair_to_conv_functions[av_get_packed_sample_fmt(out_fmt)+AV_SAMPLE_FMT_NB *av_get_packed_sample_fmt(in_fmt)];if(!f) return NULL;ctx=av_mallocz(sizeof(*ctx));if(!ctx) return NULL;if(channels==1){in_fmt=av_get_planar_sample_fmt(in_fmt);out_fmt=av_get_planar_sample_fmt(out_fmt);}ctx->channels=channels;ctx->conv_f=f;ctx->ch_map=ch_map;if(in_fmt==AV_SAMPLE_FMT_U8||in_fmt==AV_SAMPLE_FMT_U8P) memset(ctx->silence, 0x80, sizeof(ctx->silence));if(out_fmt==in_fmt &&!ch_map){switch(av_get_bytes_per_sample(in_fmt)){case 1:ctx->simd_f=cpy1;break;case 2:ctx->simd_f=cpy2;break;case 4:ctx->simd_f=cpy4;break;case 8:ctx->simd_f=cpy8;break;}}if(HAVE_X86ASM &&1) swri_audio_convert_init_x86(ctx, out_fmt, in_fmt, channels);if(ARCH_ARM) swri_audio_convert_init_arm(ctx, out_fmt, in_fmt, channels);if(ARCH_AARCH64) swri_audio_convert_init_aarch64(ctx, out_fmt, in_fmt, channels);return ctx;}void swri_audio_convert_free(AudioConvert **ctx){av_freep(ctx);}int swri_audio_convert(AudioConvert *ctx, AudioData *out, AudioData *in, int len){int ch;int off=0;const int os=(out->planar?1:out->ch_count)*out->bps;unsigned misaligned=0;av_assert0(ctx->channels==out->ch_count);if(ctx->in_simd_align_mask){int planes=in->planar?in->ch_count:1;unsigned m=0;for(ch=0;ch< planes;ch++) m|=(intptr_t) in->ch[ch];misaligned|=m &ctx->in_simd_align_mask;}if(ctx->out_simd_align_mask){int planes=out->planar?out->ch_count:1;unsigned m=0;for(ch=0;ch< planes;ch++) m|=(intptr_t) out->ch[ch];misaligned|=m &ctx->out_simd_align_mask;}if(ctx->simd_f &&!ctx->ch_map &&!misaligned){off=len &~15;av_assert1(off >=0);av_assert1(off<=len);av_assert2(ctx->channels==SWR_CH_MAX||!in->ch[ctx->channels]);if(off >0){if(out->planar==in->planar){int planes=out->planar?out->ch_count:1;for(ch=0;ch< planes;ch++){ctx->simd_f(out->ch+ch,(const uint8_t **) in->ch+ch, off *(out-> planar
Definition: audioconvert.c:56
planar YUV 4:4:4, 27bpp, (1 Cr & Cb sample per 1x1 Y samples), big-endian
Definition: pixfmt.h:162
int av_get_bits_per_pixel(const AVPixFmtDescriptor *pixdesc)
Return the number of bits per pixel used by the pixel format described by pixdesc.
Definition: pixdesc.c:2525
int(* receive_frame)(struct AVCodecContext *avctx, struct AVFrame *frame)
Decode API with decoupled packet/frame dataflow.
Definition: codec.h:318
planar YUV 4:4:4,36bpp, (1 Cr & Cb sample per 1x1 Y samples), big-endian
Definition: pixfmt.h:250
uint32_t fourcc
Definition: vaapi_decode.c:239
enum AVCodecID codec_id
Specific type of the encoded data (the codec used).
Definition: codec_par.h:60
planar GBR 4:4:4 24bpp
Definition: pixfmt.h:168
int num
Numerator.
Definition: rational.h:59
Timecode which conforms to SMPTE ST 12-1.
Definition: frame.h:168
int av_codec_is_decoder(const AVCodec *codec)
Definition: utils.c:79
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:915
planar YUV 4:4:4 40bpp, (1 Cr & Cb sample per 1x1 Y & A samples, little-endian)
Definition: pixfmt.h:189
double, planar
Definition: samplefmt.h:70
The reader does not expect b to be semantically here and if the code is changed by maybe adding a a division or other the signedness will almost certainly be mistaken To avoid this confusion a new type was SUINT is the C unsigned type but it holds a signed int to use the same example SUINT a
Definition: undefined.txt:36
enum AVPixelFormat pix_fmt
Pixel format, see AV_PIX_FMT_xxx.
Definition: avcodec.h:746
#define tc
Definition: regdef.h:69
enum AVPixelFormat pix_fmt
Definition: raw.h:35
int avpriv_codec_get_cap_skip_frame_fill_param(const AVCodec *codec)
Definition: utils.c:450
void av_fast_padded_malloc(void *ptr, unsigned int *size, size_t min_size)
Same behaviour av_fast_malloc but the buffer has additional AV_INPUT_BUFFER_PADDING_SIZE at the end w...
Definition: utils.c:50
planar GBR 4:4:4 36bpp, little-endian
Definition: pixfmt.h:255
The following 12 formats have the disadvantage of needing 1 format for each bit depth.
Definition: pixfmt.h:156
#define FF_ARRAY_ELEMS(a)
void * av_mallocz(size_t size)
Allocate a memory block with alignment suitable for all memory accesses (including vectors if availab...
Definition: mem.c:237
enum AVPixelFormat ff_thread_get_format(AVCodecContext *avctx, const enum AVPixelFormat *fmt)
Wrapper around get_format() for frame-multithreaded codecs.
Definition: utils.c:927
int avcodec_enum_to_chroma_pos(int *xpos, int *ypos, enum AVChromaLocation pos)
Converts AVChromaLocation to swscale x/y chroma position.
Definition: utils.c:333
size_t size
Definition: packet.h:311
fg index
planar GBR 4:4:4 36bpp, big-endian
Definition: pixfmt.h:254
AVCodec.
Definition: codec.h:197
planar YUV 4:2:0, 24bpp, (1 Cr & Cb sample per 2x2 Y samples), little-endian
Definition: pixfmt.h:131
int framerate
Definition: h264_levels.c:65
int block_align
number of bytes per packet if constant and known or 0 Used by some WAV based audio codecs...
Definition: avcodec.h:1233
uint8_t log2_chroma_w
Amount to shift the luma width right to find the chroma width.
Definition: pixdesc.h:92
This struct describes the properties of an encoded stream.
Definition: codec_par.h:52
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:84
int frame_size
Audio only.
Definition: codec_par.h:181
AVRational time_base
This is the fundamental unit of time (in seconds) in terms of which frame timestamps are represented...
Definition: avcodec.h:659
AVFrameSideData * av_frame_get_side_data(const AVFrame *frame, enum AVFrameSideDataType type)
Definition: frame.c:739
void ff_thread_await_progress2(AVCodecContext *avctx, int field, int thread, int shift)
Definition: utils.c:970
int avcodec_fill_audio_frame(AVFrame *frame, int nb_channels, enum AVSampleFormat sample_fmt, const uint8_t *buf, int buf_size, int align)
Fill AVFrame audio data and linesize pointers.
Definition: utils.c:356
uint64_t vbv_delay
The delay between the time the packet this structure is associated with is received and the time when...
Definition: avcodec.h:495
planar YUV 4:2:0 22.5bpp, (1 Cr & Cb sample per 2x2 Y & A samples), little-endian ...
Definition: pixfmt.h:179
void avcodec_align_dimensions(AVCodecContext *s, int *width, int *height)
Modify width and height values so that they will result in a memory buffer that is acceptable for the...
Definition: utils.c:318
#define av_assert0(cond)
assert() equivalent, that is always enabled.
Definition: avassert.h:37
planar GBRA 4:4:4:4 64bpp, big-endian
Definition: pixfmt.h:216
planar YUV 4:2:0 40bpp, (1 Cr & Cb sample per 2x2 Y & A samples, big-endian)
Definition: pixfmt.h:190
planar YUV 4:2:0, 20bpp, (1 Cr & Cb sample per 2x2 Y & A samples)
Definition: pixfmt.h:101
planar YUV 4:2:2,24bpp, (1 Cr & Cb sample per 2x1 Y samples), 12b alpha, little-endian ...
Definition: pixfmt.h:344
AVComponentDescriptor comp[4]
Parameters that describe how pixels are packed.
Definition: pixdesc.h:117
uint8_t
AV_SAMPLE_FMT_U8
8 bits with AV_PIX_FMT_RGB32 palette
Definition: pixfmt.h:77
#define f(width, name)
Definition: cbs_vp9.c:255
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
int ff_side_data_update_matrix_encoding(AVFrame *frame, enum AVMatrixEncoding matrix_encoding)
Add or update AV_FRAME_DATA_MATRIXENCODING side data.
Definition: utils.c:114
Multithreading support functions.
#define AV_NE(be, le)
Definition: common.h:50
int av_frame_ref(AVFrame *dst, const AVFrame *src)
Set up a new reference to the data described by the source frame.
Definition: frame.c:444
planar YUV 4:4:4,36bpp, (1 Cr & Cb sample per 1x1 Y samples), little-endian
Definition: pixfmt.h:251
int(* encode2)(struct AVCodecContext *avctx, struct AVPacket *avpkt, const struct AVFrame *frame, int *got_packet_ptr)
Encode data to an AVPacket.
Definition: codec.h:289
uint8_t * extradata
some codecs need / can use extradata like Huffman tables.
Definition: avcodec.h:637
uint64_t_TMPL AV_WL64 unsigned int_TMPL AV_WL32 unsigned int_TMPL AV_WL24 unsigned int_TMPL AV_WL16 uint64_t_TMPL AV_WB64 unsigned int_TMPL AV_RB32
Definition: bytestream.h:91
planar YUV 4:2:0 40bpp, (1 Cr & Cb sample per 2x2 Y & A samples, little-endian)
Definition: pixfmt.h:191
AVCPBProperties * ff_add_cpb_side_data(AVCodecContext *avctx)
Add a CPB properties side data to an encoding context.
Definition: utils.c:1027
Structure to hold side data for an AVFrame.
Definition: frame.h:220
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:322
planar YUV 4:4:0,20bpp, (1 Cr & Cb sample per 1x2 Y samples), big-endian
Definition: pixfmt.h:276
planar GBR 4:4:4 48bpp, big-endian
Definition: pixfmt.h:174
planar YUV 4:4:0 full scale (JPEG), deprecated in favor of AV_PIX_FMT_YUV440P and setting color_range...
Definition: pixfmt.h:100
uint32_t tag
Definition: movenc.c:1600
planar YUV 4:2:2, 16bpp, full scale (JPEG), deprecated in favor of AV_PIX_FMT_YUV422P and setting col...
Definition: pixfmt.h:79
planar YUV 4:4:4 64bpp, (1 Cr & Cb sample per 1x1 Y & A samples, big-endian)
Definition: pixfmt.h:194
void av_memcpy_backptr(uint8_t *dst, int back, int cnt)
Overlapping memcpy() implementation.
Definition: mem.c:428
uint8_t * data
Definition: packet.h:307
static int get_audio_frame_duration(enum AVCodecID id, int sr, int ch, int ba, uint32_t tag, int bits_per_coded_sample, int64_t bitrate, uint8_t *extradata, int frame_size, int frame_bytes)
Definition: utils.c:631
int lowres
low resolution decoding, 1-> 1/2 size, 2->1/4 size
Definition: avcodec.h:1754
int av_codec_get_max_lowres(const AVCodec *codec)
Definition: utils.c:444
static unsigned bcd2uint(uint8_t bcd)
Definition: utils.c:1058
int ff_match_2uint16(const uint16_t(*tab)[2], int size, int a, int b)
Return the index into tab at which {a,b} match elements {[0],[1]} of tab.
Definition: utils.c:866
ptrdiff_t size
Definition: opengl_enc.c:100
int bits_per_coded_sample
bits per sample/pixel from the demuxer (needed for huffyuv).
Definition: avcodec.h:1740
planar YUV 4:4:0,24bpp, (1 Cr & Cb sample per 1x2 Y samples), big-endian
Definition: pixfmt.h:278
int ff_set_sar(AVCodecContext *avctx, AVRational sar)
Check that the provided sample aspect ratio is valid and set it on the codec context.
Definition: utils.c:99
signed 32 bits
Definition: samplefmt.h:62
static struct @321 state
void * av_realloc_array(void *ptr, size_t nmemb, size_t size)
Definition: mem.c:198
AVCPBProperties * av_cpb_properties_alloc(size_t *size)
Allocate a CPB properties structure and initialize its fields to default values.
Definition: utils.c:1013
#define FFALIGN(x, a)
Definition: macros.h:48
#define av_log(a,...)
int av_sample_fmt_is_planar(enum AVSampleFormat sample_fmt)
Check if the sample format is planar.
Definition: samplefmt.c:112
int64_t bit_rate
The average bitrate of the encoded data (in bits per second).
Definition: codec_par.h:89
void avcodec_align_dimensions2(AVCodecContext *s, int *width, int *height, int linesize_align[AV_NUM_DATA_POINTERS])
Modify width and height values so that they will result in a memory buffer that is acceptable for the...
Definition: utils.c:134
void av_register_hwaccel(AVHWAccel *hwaccel)
Register the hardware accelerator hwaccel.
Definition: utils.c:890
planar YUV 4:2:0, 13.5bpp, (1 Cr & Cb sample per 2x2 Y samples), little-endian
Definition: pixfmt.h:157
Libavcodec version macros.
#define src
Definition: vp8dsp.c:255
planar GBR 4:4:4 27bpp, big-endian
Definition: pixfmt.h:170
planar YUV 4:4:4, 30bpp, (1 Cr & Cb sample per 1x1 Y samples), little-endian
Definition: pixfmt.h:165
planar YUV 4:2:2 24bpp, (1 Cr & Cb sample per 2x1 Y & A samples)
Definition: pixfmt.h:176
AVCodecID
Identify the syntax and semantics of the bitstream.
Definition: codec_id.h:46
unsigned av_codec_get_codec_properties(const AVCodecContext *codec)
Definition: utils.c:439
int width
Definition: frame.h:376
int av_get_bits_per_sample(enum AVCodecID codec_id)
Return codec bits per sample.
Definition: utils.c:613
uint8_t log2_chroma_h
Amount to shift the luma height right to find the chroma height.
Definition: pixdesc.h:101
const struct AVCodecHWConfigInternal *const * hw_configs
Array of pointers to hardware configurations supported by the codec, or NULL if no hardware supported...
Definition: codec.h:343
int ff_int_from_list_or_default(void *ctx, const char *val_name, int val, const int *array_valid_values, int default_value)
Check if a value is in the list.
Definition: utils.c:1152
#define MAKE_ACCESSORS(str, name, type, field)
Definition: internal.h:90
planar YUV 4:4:4, 48bpp, (1 Cr & Cb sample per 1x1 Y samples), big-endian
Definition: pixfmt.h:136
unsigned int avpriv_toupper4(unsigned int x)
Definition: utils.c:895
it s the only field you need to keep assuming you have a context There is some magic you don t need to care about around this field
unsigned int pos
Definition: spdifenc.c:412
#define AV_LOG_DEBUG
Stuff which is only useful for libav* developers.
Definition: log.h:215
int ff_thread_init(AVCodecContext *s)
Definition: utils.c:845
preferred ID for decoding MPEG audio layer 1, 2 or 3
Definition: codec_id.h:425
planar YUV 4:4:4 36bpp, (1 Cr & Cb sample per 1x1 Y & A samples), big-endian
Definition: pixfmt.h:182
planar YUV 4:2:2, 20bpp, (1 Cr & Cb sample per 2x1 Y samples), little-endian
Definition: pixfmt.h:161
AVCodec * avcodec_find_encoder(enum AVCodecID id)
Find a registered encoder with a matching codec ID.
Definition: allcodecs.c:941
simple assert() macros that are a bit more flexible than ISO C assert().
planar YUV 4:2:2,28bpp, (1 Cr & Cb sample per 2x1 Y samples), big-endian
Definition: pixfmt.h:248
enum AVPacketSideDataType type
Definition: packet.h:313
const char * name
Name of the codec implementation.
Definition: codec.h:204
planar YUV 4:2:2, 32bpp, (1 Cr & Cb sample per 2x1 Y samples), big-endian
Definition: pixfmt.h:134
int64_t max_pixels
The number of pixels per image to maximally accept.
Definition: avcodec.h:2248
const struct AVProfile * profiles
If non-NULL, an array of profiles recognized for this codec.
Definition: codec_desc.h:65
int ff_alloc_timecode_sei(const AVFrame *frame, AVRational rate, size_t prefix_len, void **data, size_t *sei_size)
Check AVFrame for S12M timecode side data and allocate and fill TC SEI message with timecode info...
Definition: utils.c:1067
GLsizei count
Definition: opengl_enc.c:108
planar YUV 4:4:4 36bpp, (1 Cr & Cb sample per 1x1 Y & A samples), little-endian
Definition: pixfmt.h:183
#define FFMAX(a, b)
Definition: common.h:103
int av_get_audio_frame_duration2(AVCodecParameters *par, int frame_bytes)
This function is the same as av_get_audio_frame_duration(), except it works with AVCodecParameters in...
Definition: utils.c:835
planar YUV 4:2:0 25bpp, (1 Cr & Cb sample per 2x2 Y & A samples, big-endian)
Definition: pixfmt.h:184
planar YUV 4:2:2, 16bpp, (1 Cr & Cb sample per 2x1 Y samples)
Definition: pixfmt.h:70
uint64_t flags
Combination of AV_PIX_FMT_FLAG_...
Definition: pixdesc.h:106
planar GBR 4:4:4:4 48bpp, big-endian
Definition: pixfmt.h:287
int block_align
Audio only.
Definition: codec_par.h:177
#define ss(width, name, subs,...)
Definition: cbs_vp9.c:261
uint8_t nb_components
The number of components each pixel has, (1-4)
Definition: pixdesc.h:83
#define b
Definition: input.c:41
#define FFMIN(a, b)
Definition: common.h:105
AVPacketSideData * coded_side_data
Additional data associated with the entire coded stream.
Definition: avcodec.h:2193
Raw Video Codec.
signed 32 bits, planar
Definition: samplefmt.h:68
planar YUV 4:2:0, 12bpp, full scale (JPEG), deprecated in favor of AV_PIX_FMT_YUV420P and setting col...
Definition: pixfmt.h:78
int av_get_exact_bits_per_sample(enum AVCodecID codec_id)
Return codec bits per sample.
Definition: utils.c:524
void ff_thread_report_progress2(AVCodecContext *avctx, int field, int thread, int n)
Definition: utils.c:974
int width
picture width / height.
Definition: avcodec.h:709
#define FF_PROFILE_UNKNOWN
Definition: avcodec.h:1859
int profile
Definition: codec.h:184
AVFormatContext * ctx
Definition: movenc.c:48
planar YUV 4:4:4 40bpp, (1 Cr & Cb sample per 1x1 Y & A samples, big-endian)
Definition: pixfmt.h:188
packed YUV 4:2:2, 16bpp, Y0 Cr Y1 Cb
Definition: pixfmt.h:210
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
#define s(width, name)
Definition: cbs_vp9.c:257
void ff_thread_finish_setup(AVCodecContext *avctx)
If the codec defines update_thread_context(), call this when they are ready for the next thread to st...
Definition: utils.c:944
planar YUV 4:2:2 27bpp, (1 Cr & Cb sample per 2x1 Y & A samples), big-endian
Definition: pixfmt.h:180
const AVProfile * profiles
array of recognized profiles, or NULL if unknown, array is terminated by {FF_PROFILE_UNKNOWN} ...
Definition: codec.h:224
unsigned 8 bits, planar
Definition: samplefmt.h:66
packed RGB 8:8:8, 24bpp, BGRBGR...
Definition: pixfmt.h:69
planar YUV 4:2:0,18bpp, (1 Cr & Cb sample per 2x2 Y samples), little-endian
Definition: pixfmt.h:243
planar YUV 4:2:0, 15bpp, (1 Cr & Cb sample per 2x2 Y samples), big-endian
Definition: pixfmt.h:158
enum AVCodecID codec_id
Definition: vaapi_decode.c:369
enum AVPixelFormat avpriv_find_pix_fmt(const PixelFormatTag *tags, unsigned int fourcc)
Definition: utils.c:421
planar YUV 4:2:2, 18bpp, (1 Cr & Cb sample per 2x1 Y samples), little-endian
Definition: pixfmt.h:167
planar GBR 4:4:4:4 48bpp, little-endian
Definition: pixfmt.h:288
int(* decode)(struct AVCodecContext *avctx, void *outdata, int *got_frame_ptr, struct AVPacket *avpkt)
Decode picture or subtitle data.
Definition: codec.h:303
int format
format of the frame, -1 if unknown or unset Values correspond to enum AVPixelFormat for video frames...
Definition: frame.h:391
AVBufferRef * progress
Definition: thread.h:39
const char * av_get_profile_name(const AVCodec *codec, int profile)
Return a name for the specified profile, if available.
Definition: utils.c:496
int frame_size
Number of samples per channel in an audio frame.
Definition: avcodec.h:1216
This structure describes the bitrate properties of an encoded bitstream.
Definition: avcodec.h:453
packed RGB 3:3:2, 8bpp, (msb)2B 3G 3R(lsb)
Definition: pixfmt.h:83
static int width
Definition: utils.c:158
planar YUV 4:2:0, 24bpp, (1 Cr & Cb sample per 2x2 Y samples), big-endian
Definition: pixfmt.h:132
int frame_size
Definition: mxfenc.c:2206
AVHWAccel * av_hwaccel_next(const AVHWAccel *hwaccel)
If hwaccel is NULL, returns the first registered hardware accelerator, if hwaccel is non-NULL...
Definition: utils.c:885
Libavcodec external API header.
AVSampleFormat
Audio sample formats.
Definition: samplefmt.h:58
enum AVCodecID av_get_pcm_codec(enum AVSampleFormat fmt, int be)
Return the PCM codec associated with a sample format.
Definition: utils.c:591
enum AVCodecID codec_id
Definition: avcodec.h:546
int sample_rate
samples per second
Definition: avcodec.h:1196
int linesize[AV_NUM_DATA_POINTERS]
For video, size in bytes of each picture line.
Definition: frame.h:349
planar YUV 4:4:4 32bpp, (1 Cr & Cb sample per 1x1 Y & A samples)
Definition: pixfmt.h:177
Descriptor that unambiguously describes how the bits of a pixel are stored in the up to 4 data planes...
Definition: pixdesc.h:81
const AVCodecHWConfig * avcodec_get_hw_config(const AVCodec *codec, int index)
Retrieve supported hardware configurations for a codec.
Definition: utils.c:873
planar GBR 4:4:4 30bpp, big-endian
Definition: pixfmt.h:172
main external API structure.
Definition: avcodec.h:536
planar YUV 4:2:2 48bpp, (1 Cr & Cb sample per 2x1 Y & A samples, big-endian)
Definition: pixfmt.h:192
it s the only field you need to keep assuming you have a context There is some magic you don t need to care about around this just let it be(in the first position) for now.Options-------Then comes the options array.This is what will define the user accessible options.For example
unsigned int codec_tag
fourcc (LSB first, so "ABCD" -> (&#39;D&#39;<<24) + (&#39;C&#39;<<16) + (&#39;B&#39;<<8) + &#39;A&#39;).
Definition: avcodec.h:561
packed YUV 4:2:2, 16bpp, Y0 Cb Y1 Cr
Definition: pixfmt.h:67
int ff_get_buffer(AVCodecContext *avctx, AVFrame *frame, int flags)
Get a buffer for a frame.
Definition: decode.c:1893
uint8_t * data
Definition: frame.h:222
planar YUV 4:4:0,24bpp, (1 Cr & Cb sample per 1x2 Y samples), little-endian
Definition: pixfmt.h:277
planar GBR 4:4:4 42bpp, little-endian
Definition: pixfmt.h:257
unsigned int av_xiphlacing(unsigned char *s, unsigned int v)
Encode extradata length to a buffer.
Definition: utils.c:852
int nb_coded_side_data
Definition: avcodec.h:2194
planar YUV 4:1:0, 9bpp, (1 Cr & Cb sample per 4x4 Y samples)
Definition: pixfmt.h:72
planar YUV 4:2:2 48bpp, (1 Cr & Cb sample per 2x1 Y & A samples, little-endian)
Definition: pixfmt.h:193
AVCodecContext * owner[2]
Definition: thread.h:36
int coded_height
Definition: avcodec.h:724
planar YUV 4:4:4 64bpp, (1 Cr & Cb sample per 1x1 Y & A samples, little-endian)
Definition: pixfmt.h:195
AVFrameSideData * av_frame_new_side_data(AVFrame *frame, enum AVFrameSideDataType type, buffer_size_t size)
Add a new side data to a frame.
Definition: frame.c:727
static av_const int av_toupper(int c)
Locale-independent conversion of ASCII characters to uppercase.
Definition: avstring.h:236
Y , 16bpp, big-endian.
Definition: pixfmt.h:97
int av_samples_get_buffer_size(int *linesize, int nb_channels, int nb_samples, enum AVSampleFormat sample_fmt, int align)
Get the required buffer size for the given audio parameters.
Definition: samplefmt.c:119
Rational number (pair of numerator and denominator).
Definition: rational.h:58
void ff_thread_release_buffer(AVCodecContext *avctx, ThreadFrame *f)
Wrapper around release_buffer() frame-for multithreaded codecs.
Definition: utils.c:938
const char * name
short name for the profile
Definition: codec.h:185
planar YUV 4:2:0,21bpp, (1 Cr & Cb sample per 2x2 Y samples), big-endian
Definition: pixfmt.h:244
planar YUV 4:4:4,36bpp, (1 Cr & Cb sample per 1x1 Y samples), 12b alpha, big-endian ...
Definition: pixfmt.h:345
planar GBR 4:4:4 42bpp, big-endian
Definition: pixfmt.h:256
planar YUV 4:2:0 22.5bpp, (1 Cr & Cb sample per 2x2 Y & A samples), big-endian
Definition: pixfmt.h:178
const VDPAUPixFmtMap * map
#define STRIDE_ALIGN
Definition: internal.h:113
const char * name
Name of the codec described by this descriptor.
Definition: codec_desc.h:46
#define snprintf
Definition: snprintf.h:34
int av_get_audio_frame_duration(AVCodecContext *avctx, int frame_bytes)
Return audio frame duration.
Definition: utils.c:826
AVCodec * avcodec_find_decoder(enum AVCodecID id)
Find a registered decoder with a matching codec ID.
Definition: allcodecs.c:946
mfxU16 profile
Definition: qsvenc.c:45
This struct describes the properties of a single codec described by an AVCodecID. ...
Definition: codec_desc.h:38
void av_frame_unref(AVFrame *frame)
Unreference all the buffers referenced by frame and reset the frame fields.
Definition: frame.c:554
planar YUV 4:2:2 30bpp, (1 Cr & Cb sample per 2x1 Y & A samples, little-endian)
Definition: pixfmt.h:187
#define flags(name, subs,...)
Definition: cbs_av1.c:561
uint8_t * data[AV_NUM_DATA_POINTERS]
pointer to the picture/channel planes.
Definition: frame.h:332
planar YUV 4:4:4, 27bpp, (1 Cr & Cb sample per 1x1 Y samples), little-endian
Definition: pixfmt.h:163
planar YUV 4:4:4, 48bpp, (1 Cr & Cb sample per 1x1 Y samples), little-endian
Definition: pixfmt.h:135
void ff_color_frame(AVFrame *frame, const int c[4])
Definition: utils.c:392
static av_always_inline AVRational av_inv_q(AVRational q)
Invert a rational.
Definition: rational.h:159
int sample_rate
Audio only.
Definition: codec_par.h:170
uint8_t max_lowres
maximum value for lowres supported by the decoder
Definition: codec.h:222
int64_t bitrate
Definition: h264_levels.c:131
static int av_cmp_q(AVRational a, AVRational b)
Compare two rationals.
Definition: rational.h:89
planar YUV 4:2:0, 12bpp, (1 Cr & Cb sample per 2x2 Y samples)
Definition: pixfmt.h:66
planar YUV 4:2:2,24bpp, (1 Cr & Cb sample per 2x1 Y samples), little-endian
Definition: pixfmt.h:247
Y , 8bpp.
Definition: pixfmt.h:74
common internal api header.
enum AVChromaLocation avcodec_chroma_pos_to_enum(int xpos, int ypos)
Converts swscale x/y chroma position to AVChromaLocation.
Definition: utils.c:345
static void flush_put_bits(PutBitContext *s)
Pad the end of the output stream with zeros.
Definition: put_bits.h:147
#define FF_CODEC_CAP_SKIP_FRAME_FILL_PARAM
The decoder extracts and fills its parameters even if the frame is skipped due to the skip_frame sett...
Definition: internal.h:61
planar GBRA 4:4:4:4 32bpp
Definition: pixfmt.h:215
signed 16 bits
Definition: samplefmt.h:61
planar GBR 4:4:4 27bpp, little-endian
Definition: pixfmt.h:171
int(* encode_sub)(struct AVCodecContext *, uint8_t *buf, int buf_size, const struct AVSubtitle *sub)
Definition: codec.h:277
void av_fast_padded_mallocz(void *ptr, unsigned int *size, size_t min_size)
Same behaviour av_fast_padded_malloc except that buffer will always be 0-initialized after call...
Definition: utils.c:62
AVBufferRef * av_buffer_ref(AVBufferRef *buf)
Create a new reference to an AVBuffer.
Definition: buffer.c:93
AVProfile.
Definition: codec.h:183
planar YUV 4:2:2, 32bpp, (1 Cr & Cb sample per 2x1 Y samples), little-endian
Definition: pixfmt.h:133
planar YUV 4:4:4, 24bpp, full scale (JPEG), deprecated in favor of AV_PIX_FMT_YUV444P and setting col...
Definition: pixfmt.h:80
int ff_thread_can_start_frame(AVCodecContext *avctx)
Definition: utils.c:956
void ff_thread_report_progress(ThreadFrame *f, int progress, int field)
Notify later decoding threads when part of their reference picture is ready.
Definition: utils.c:948
packed RGB 3:3:2, 8bpp, (msb)2R 3G 3B(lsb)
Definition: pixfmt.h:86
#define AV_PIX_FMT_RGB555
Definition: pixfmt.h:387
planar YUV 4:1:1, 12bpp, (1 Cr & Cb sample per 4x1 Y samples)
Definition: pixfmt.h:73
int caps_internal
Internal codec capabilities.
Definition: codec.h:328
const char * avcodec_get_name(enum AVCodecID id)
Get the name of a codec.
Definition: utils.c:454
static void init_put_bits(PutBitContext *s, uint8_t *buffer, int buffer_size)
Initialize the PutBitContext s.
Definition: put_bits.h:66
int den
Denominator.
Definition: rational.h:60
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:288
unsigned bps
Definition: movenc.c:1601
planar YUV 4:2:0 25bpp, (1 Cr & Cb sample per 2x2 Y & A samples, little-endian)
Definition: pixfmt.h:185
#define AV_INPUT_BUFFER_PADDING_SIZE
Required number of additionally allocated bytes at the end of the input bitstream for decoding...
Definition: avcodec.h:215
static int lowres
Definition: ffplay.c:336
size_t av_get_codec_tag_string(char *buf, size_t buf_size, unsigned int codec_tag)
Put a string representing the codec tag codec_tag in buf.
Definition: utils.c:475
int av_samples_fill_arrays(uint8_t **audio_data, int *linesize, const uint8_t *buf, int nb_channels, int nb_samples, enum AVSampleFormat sample_fmt, int align)
Fill plane data pointers and linesize for samples with sample format sample_fmt.
Definition: samplefmt.c:151
pixel format definitions
int ff_thread_ref_frame(ThreadFrame *dst, const ThreadFrame *src)
Definition: utils.c:903
#define TAG_PRINT(x)
planar YUV 4:4:4,42bpp, (1 Cr & Cb sample per 1x1 Y samples), little-endian
Definition: pixfmt.h:253
as in Berlin toast format
Definition: codec_id.h:442
int len
int channels
number of audio channels
Definition: avcodec.h:1197
Y , 16bpp, little-endian.
Definition: pixfmt.h:98
This side data corresponds to the AVCPBProperties struct.
Definition: packet.h:145
planar YUV 4:1:1, 12bpp, (1 Cr & Cb sample per 4x1 Y samples) full scale (JPEG), deprecated in favor ...
Definition: pixfmt.h:258
Not part of ABI.
Definition: pixfmt.h:613
signed 64 bits, planar
Definition: samplefmt.h:72
const AVCodecDescriptor * avcodec_descriptor_get(enum AVCodecID id)
Definition: codec_desc.c:3501
int bits_per_coded_sample
The number of bits per sample in the codedwords.
Definition: codec_par.h:102
uint8_t * extradata
Extra binary data needed for initializing the decoder, codec-dependent.
Definition: codec_par.h:74
static const struct twinvq_data tab
int channels
Audio only.
Definition: codec_par.h:166
void ff_thread_await_progress(ThreadFrame *f, int progress, int field)
Wait for earlier decoding threads to finish reference pictures.
Definition: utils.c:952
planar YUV 4:2:2 30bpp, (1 Cr & Cb sample per 2x1 Y & A samples, big-endian)
Definition: pixfmt.h:186
static int height
Definition: utils.c:158
int height
Definition: frame.h:376
#define av_freep(p)
planar YUV 4:4:0 (1 Cr & Cb sample per 1x2 Y samples)
Definition: pixfmt.h:99
signed 16 bits, planar
Definition: samplefmt.h:67
AVChromaLocation
Location of chroma samples.
Definition: pixfmt.h:605
planar GBR 4:4:4 48bpp, little-endian
Definition: pixfmt.h:175
AVMatrixEncoding
int ff_thread_get_buffer(AVCodecContext *avctx, ThreadFrame *f, int flags)
Wrapper around get_buffer() for frame-multithreaded codecs.
Definition: utils.c:932
uint32_t codec_tag
Additional information about the codec (corresponds to the AVI FOURCC).
Definition: codec_par.h:64
int ff_alloc_entries(AVCodecContext *avctx, int count)
Definition: utils.c:961
int nb_channels
planar YUV 4:2:2 27bpp, (1 Cr & Cb sample per 2x1 Y & A samples), little-endian
Definition: pixfmt.h:181
const uint8_t * avpriv_find_start_code(const uint8_t *av_restrict p, const uint8_t *end, uint32_t *av_restrict state)
Definition: utils.c:980
void ff_reset_entries(AVCodecContext *avctx)
Definition: utils.c:966
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
int depth
Number of bits in the component.
Definition: pixdesc.h:58
uint8_t ** extended_data
pointers to the data planes/channels.
Definition: frame.h:365
planar GBRA 4:4:4:4 64bpp, little-endian
Definition: pixfmt.h:217
packed YUV 4:1:1, 12bpp, Cb Y0 Y1 Cr Y2 Y3
Definition: pixfmt.h:82
AVPixelFormat
Pixel format.
Definition: pixfmt.h:64
static double val(void *priv, double ch)
Definition: aeval.c:76
const char * avcodec_profile_name(enum AVCodecID codec_id, int profile)
Return a name for the specified profile, if available.
Definition: utils.c:509
static int ff_fast_malloc(void *ptr, unsigned int *size, size_t min_size, int zero_realloc)
Definition: mem_internal.h:139
int nb_samples
number of audio samples (per channel) described by this frame
Definition: frame.h:384
#define AV_PIX_FMT_FLAG_PLANAR
At least one pixel component is not in the first data plane.
Definition: pixdesc.h:144
planar YUV 4:2:0,18bpp, (1 Cr & Cb sample per 2x2 Y samples), big-endian
Definition: pixfmt.h:242
The data is the AVMatrixEncoding enum defined in libavutil/channel_layout.h.
Definition: frame.h:67
planar YUV 4:4:4, 30bpp, (1 Cr & Cb sample per 1x1 Y samples), big-endian
Definition: pixfmt.h:164
planar YUV 4:2:2,24bpp, (1 Cr & Cb sample per 2x1 Y samples), big-endian
Definition: pixfmt.h:246
int i
Definition: input.c:407
#define FFMAX3(a, b, c)
Definition: common.h:104
planar GBR 4:4:4 30bpp, little-endian
Definition: pixfmt.h:173
void * av_mallocz_array(size_t nmemb, size_t size)
Definition: mem.c:190
#define AV_CEIL_RSHIFT(a, b)
Definition: common.h:58
planar YUV 4:2:2,24bpp, (1 Cr & Cb sample per 2x1 Y samples), 12b alpha, big-endian ...
Definition: pixfmt.h:343
static uint8_t tmp[11]
Definition: aes_ctr.c:27
planar YUV 4:2:2, 20bpp, (1 Cr & Cb sample per 2x1 Y samples), big-endian
Definition: pixfmt.h:160
bitstream writer API