FFmpeg
 All Data Structures Files Functions Variables Typedefs Enumerations Enumerator Macros Groups Pages
avcodec.h
Go to the documentation of this file.
1 /*
2  * copyright (c) 2001 Fabrice Bellard
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 #ifndef AVCODEC_AVCODEC_H
22 #define AVCODEC_AVCODEC_H
23 
24 /**
25  * @file
26  * external API header
27  */
28 
29 #include <errno.h>
30 #include "libavutil/samplefmt.h"
31 #include "libavutil/avutil.h"
32 #include "libavutil/cpu.h"
34 #include "libavutil/dict.h"
35 #include "libavutil/log.h"
36 #include "libavutil/pixfmt.h"
37 #include "libavutil/rational.h"
38 
39 #include "libavcodec/version.h"
40 /**
41  * @defgroup libavc Encoding/Decoding Library
42  * @{
43  *
44  * @defgroup lavc_decoding Decoding
45  * @{
46  * @}
47  *
48  * @defgroup lavc_encoding Encoding
49  * @{
50  * @}
51  *
52  * @defgroup lavc_codec Codecs
53  * @{
54  * @defgroup lavc_codec_native Native Codecs
55  * @{
56  * @}
57  * @defgroup lavc_codec_wrappers External library wrappers
58  * @{
59  * @}
60  * @defgroup lavc_codec_hwaccel Hardware Accelerators bridge
61  * @{
62  * @}
63  * @}
64  * @defgroup lavc_internal Internal
65  * @{
66  * @}
67  * @}
68  *
69  */
70 
71 /**
72  * @defgroup lavc_core Core functions/structures.
73  * @ingroup libavc
74  *
75  * Basic definitions, functions for querying libavcodec capabilities,
76  * allocating core structures, etc.
77  * @{
78  */
79 
80 
81 /**
82  * Identify the syntax and semantics of the bitstream.
83  * The principle is roughly:
84  * Two decoders with the same ID can decode the same streams.
85  * Two encoders with the same ID can encode compatible streams.
86  * There may be slight deviations from the principle due to implementation
87  * details.
88  *
89  * If you add a codec ID to this list, add it so that
90  * 1. no value of a existing codec ID changes (that would break ABI),
91  * 2. Give it a value which when taken as ASCII is recognized uniquely by a human as this specific codec.
92  * This ensures that 2 forks can independently add AVCodecIDs without producing conflicts.
93  *
94  * After adding new codec IDs, do not forget to add an entry to the codec
95  * descriptor list and bump libavcodec minor version.
96  */
97 enum AVCodecID {
99 
100  /* video codecs */
102  AV_CODEC_ID_MPEG2VIDEO, ///< preferred ID for MPEG-1/2 video decoding
270  AV_CODEC_ID_BRENDER_PIX= MKBETAG('B','P','I','X'),
271  AV_CODEC_ID_Y41P = MKBETAG('Y','4','1','P'),
272  AV_CODEC_ID_ESCAPE130 = MKBETAG('E','1','3','0'),
273  AV_CODEC_ID_EXR = MKBETAG('0','E','X','R'),
274  AV_CODEC_ID_AVRP = MKBETAG('A','V','R','P'),
275 
276  AV_CODEC_ID_012V = MKBETAG('0','1','2','V'),
277  AV_CODEC_ID_G2M = MKBETAG( 0 ,'G','2','M'),
278  AV_CODEC_ID_AVUI = MKBETAG('A','V','U','I'),
279  AV_CODEC_ID_AYUV = MKBETAG('A','Y','U','V'),
280  AV_CODEC_ID_TARGA_Y216 = MKBETAG('T','2','1','6'),
281  AV_CODEC_ID_V308 = MKBETAG('V','3','0','8'),
282  AV_CODEC_ID_V408 = MKBETAG('V','4','0','8'),
283  AV_CODEC_ID_YUV4 = MKBETAG('Y','U','V','4'),
284  AV_CODEC_ID_SANM = MKBETAG('S','A','N','M'),
285  AV_CODEC_ID_PAF_VIDEO = MKBETAG('P','A','F','V'),
286  AV_CODEC_ID_AVRN = MKBETAG('A','V','R','n'),
287  AV_CODEC_ID_CPIA = MKBETAG('C','P','I','A'),
288  AV_CODEC_ID_XFACE = MKBETAG('X','F','A','C'),
289  AV_CODEC_ID_SGIRLE = MKBETAG('S','G','I','R'),
290  AV_CODEC_ID_MVC1 = MKBETAG('M','V','C','1'),
291  AV_CODEC_ID_MVC2 = MKBETAG('M','V','C','2'),
292 
293  /* various PCM "codecs" */
294  AV_CODEC_ID_FIRST_AUDIO = 0x10000, ///< A dummy id pointing at the start of audio codecs
326 
327  /* various ADPCM codecs */
358  AV_CODEC_ID_VIMA = MKBETAG('V','I','M','A'),
359  AV_CODEC_ID_ADPCM_AFC = MKBETAG('A','F','C',' '),
360  AV_CODEC_ID_ADPCM_IMA_OKI = MKBETAG('O','K','I',' '),
361 
362  /* AMR */
365 
366  /* RealAudio codecs*/
369 
370  /* various DPCM codecs */
375 
376  /* audio codecs */
377  AV_CODEC_ID_MP2 = 0x15000,
378  AV_CODEC_ID_MP3, ///< preferred ID for decoding MPEG audio layer 1, 2 or 3
395  AV_CODEC_ID_GSM, ///< as in Berlin toast format
407  AV_CODEC_ID_GSM_MS, /* as found in WAV */
441  AV_CODEC_ID_FFWAVESYNTH = MKBETAG('F','F','W','S'),
442 #if LIBAVCODEC_VERSION_MAJOR <= 54
443  AV_CODEC_ID_8SVX_RAW = MKBETAG('8','S','V','X'),
444 #endif
445  AV_CODEC_ID_SONIC = MKBETAG('S','O','N','C'),
446  AV_CODEC_ID_SONIC_LS = MKBETAG('S','O','N','L'),
447  AV_CODEC_ID_PAF_AUDIO = MKBETAG('P','A','F','A'),
448  AV_CODEC_ID_OPUS = MKBETAG('O','P','U','S'),
449  AV_CODEC_ID_TAK = MKBETAG('t','B','a','K'),
450 
451  /* subtitle codecs */
452  AV_CODEC_ID_FIRST_SUBTITLE = 0x17000, ///< A dummy ID pointing at the start of subtitle codecs.
455  AV_CODEC_ID_TEXT, ///< raw UTF-8 text
462  AV_CODEC_ID_MICRODVD = MKBETAG('m','D','V','D'),
463  AV_CODEC_ID_EIA_608 = MKBETAG('c','6','0','8'),
464  AV_CODEC_ID_JACOSUB = MKBETAG('J','S','U','B'),
465  AV_CODEC_ID_SAMI = MKBETAG('S','A','M','I'),
466  AV_CODEC_ID_REALTEXT = MKBETAG('R','T','X','T'),
467  AV_CODEC_ID_SUBVIEWER1 = MKBETAG('S','b','V','1'),
468  AV_CODEC_ID_SUBVIEWER = MKBETAG('S','u','b','V'),
469  AV_CODEC_ID_SUBRIP = MKBETAG('S','R','i','p'),
470  AV_CODEC_ID_WEBVTT = MKBETAG('W','V','T','T'),
471  AV_CODEC_ID_MPL2 = MKBETAG('M','P','L','2'),
472  AV_CODEC_ID_VPLAYER = MKBETAG('V','P','l','r'),
473  AV_CODEC_ID_PJS = MKBETAG('P','h','J','S'),
474 
475  /* other specific kind of codecs (generally used for attachments) */
476  AV_CODEC_ID_FIRST_UNKNOWN = 0x18000, ///< A dummy ID pointing at the start of various fake codecs.
477  AV_CODEC_ID_TTF = 0x18000,
478  AV_CODEC_ID_BINTEXT = MKBETAG('B','T','X','T'),
479  AV_CODEC_ID_XBIN = MKBETAG('X','B','I','N'),
480  AV_CODEC_ID_IDF = MKBETAG( 0 ,'I','D','F'),
481  AV_CODEC_ID_OTF = MKBETAG( 0 ,'O','T','F'),
482  AV_CODEC_ID_SMPTE_KLV = MKBETAG('K','L','V','A'),
483 
484  AV_CODEC_ID_PROBE = 0x19000, ///< codec_id is not known (like AV_CODEC_ID_NONE) but lavf should attempt to identify it
485 
486  AV_CODEC_ID_MPEG2TS = 0x20000, /**< _FAKE_ codec to indicate a raw MPEG-2 TS
487  * stream (only used by libavformat) */
488  AV_CODEC_ID_MPEG4SYSTEMS = 0x20001, /**< _FAKE_ codec to indicate a MPEG-4 Systems
489  * stream (only used by libavformat) */
490  AV_CODEC_ID_FFMETADATA = 0x21000, ///< Dummy codec for streams containing only metadata information.
491 
492 #if FF_API_CODEC_ID
493 #include "old_codec_ids.h"
494 #endif
495 };
496 
497 #if FF_API_CODEC_ID
498 #define CodecID AVCodecID
499 #endif
500 
501 /**
502  * This struct describes the properties of a single codec described by an
503  * AVCodecID.
504  * @see avcodec_get_descriptor()
505  */
506 typedef struct AVCodecDescriptor {
507  enum AVCodecID id;
509  /**
510  * Name of the codec described by this descriptor. It is non-empty and
511  * unique for each codec descriptor. It should contain alphanumeric
512  * characters and '_' only.
513  */
514  const char *name;
515  /**
516  * A more descriptive name for this codec. May be NULL.
517  */
518  const char *long_name;
519  /**
520  * Codec properties, a combination of AV_CODEC_PROP_* flags.
521  */
522  int props;
524 
525 /**
526  * Codec uses only intra compression.
527  * Video codecs only.
528  */
529 #define AV_CODEC_PROP_INTRA_ONLY (1 << 0)
530 /**
531  * Codec supports lossy compression. Audio and video codecs only.
532  * @note a codec may support both lossy and lossless
533  * compression modes
534  */
535 #define AV_CODEC_PROP_LOSSY (1 << 1)
536 /**
537  * Codec supports lossless compression. Audio and video codecs only.
538  */
539 #define AV_CODEC_PROP_LOSSLESS (1 << 2)
540 
541 #if FF_API_OLD_DECODE_AUDIO
542 /* in bytes */
543 #define AVCODEC_MAX_AUDIO_FRAME_SIZE 192000 // 1 second of 48khz 32bit audio
544 #endif
545 
546 /**
547  * @ingroup lavc_decoding
548  * Required number of additionally allocated bytes at the end of the input bitstream for decoding.
549  * This is mainly needed because some optimized bitstream readers read
550  * 32 or 64 bit at once and could read over the end.<br>
551  * Note: If the first 23 bits of the additional bytes are not 0, then damaged
552  * MPEG bitstreams could cause overread and segfault.
553  */
554 #define FF_INPUT_BUFFER_PADDING_SIZE 16
555 
556 /**
557  * @ingroup lavc_encoding
558  * minimum encoding buffer size
559  * Used to avoid some checks during header writing.
560  */
561 #define FF_MIN_BUFFER_SIZE 16384
562 
563 
564 /**
565  * @ingroup lavc_encoding
566  * motion estimation type.
567  */
569  ME_ZERO = 1, ///< no search, that is use 0,0 vector whenever one is needed
573  ME_EPZS, ///< enhanced predictive zonal search
574  ME_X1, ///< reserved for experiments
575  ME_HEX, ///< hexagon based search
576  ME_UMH, ///< uneven multi-hexagon search
577  ME_ITER, ///< iterative search
578  ME_TESA, ///< transformed exhaustive search algorithm
579 };
580 
581 /**
582  * @ingroup lavc_decoding
583  */
585  /* We leave some space between them for extensions (drop some
586  * keyframes for intra-only or drop just some bidir frames). */
587  AVDISCARD_NONE =-16, ///< discard nothing
588  AVDISCARD_DEFAULT = 0, ///< discard useless packets like 0 size packets in avi
589  AVDISCARD_NONREF = 8, ///< discard all non reference
590  AVDISCARD_BIDIR = 16, ///< discard all bidirectional frames
591  AVDISCARD_NONKEY = 32, ///< discard all frames except keyframes
592  AVDISCARD_ALL = 48, ///< discard all
593 };
594 
596  AVCOL_PRI_BT709 = 1, ///< also ITU-R BT1361 / IEC 61966-2-4 / SMPTE RP177 Annex B
599  AVCOL_PRI_BT470BG = 5, ///< also ITU-R BT601-6 625 / ITU-R BT1358 625 / ITU-R BT1700 625 PAL & SECAM
600  AVCOL_PRI_SMPTE170M = 6, ///< also ITU-R BT601-6 525 / ITU-R BT1358 525 / ITU-R BT1700 NTSC
601  AVCOL_PRI_SMPTE240M = 7, ///< functionally identical to above
603  AVCOL_PRI_NB , ///< Not part of ABI
604 };
605 
607  AVCOL_TRC_BT709 = 1, ///< also ITU-R BT1361
609  AVCOL_TRC_GAMMA22 = 4, ///< also ITU-R BT470M / ITU-R BT1700 625 PAL & SECAM
610  AVCOL_TRC_GAMMA28 = 5, ///< also ITU-R BT470BG
612  AVCOL_TRC_NB , ///< Not part of ABI
613 };
614 
617  AVCOL_SPC_BT709 = 1, ///< also ITU-R BT1361 / IEC 61966-2-4 xvYCC709 / SMPTE RP177 Annex B
620  AVCOL_SPC_BT470BG = 5, ///< also ITU-R BT601-6 625 / ITU-R BT1358 625 / ITU-R BT1700 625 PAL & SECAM / IEC 61966-2-4 xvYCC601
621  AVCOL_SPC_SMPTE170M = 6, ///< also ITU-R BT601-6 525 / ITU-R BT1358 525 / ITU-R BT1700 NTSC / functionally identical to above
623  AVCOL_SPC_YCOCG = 8, ///< Used by Dirac / VC-2 and H.264 FRext, see ITU-T SG16
624  AVCOL_SPC_NB , ///< Not part of ABI
625 };
626 #define AVCOL_SPC_YCGCO AVCOL_SPC_YCOCG
627 
630  AVCOL_RANGE_MPEG = 1, ///< the normal 219*2^(n-8) "MPEG" YUV ranges
631  AVCOL_RANGE_JPEG = 2, ///< the normal 2^n-1 "JPEG" YUV ranges
632  AVCOL_RANGE_NB , ///< Not part of ABI
633 };
634 
635 /**
636  * X X 3 4 X X are luma samples,
637  * 1 2 1-6 are possible chroma positions
638  * X X 5 6 X 0 is undefined/unknown position
639  */
642  AVCHROMA_LOC_LEFT = 1, ///< mpeg2/4, h264 default
643  AVCHROMA_LOC_CENTER = 2, ///< mpeg1, jpeg, h263
644  AVCHROMA_LOC_TOPLEFT = 3, ///< DV
648  AVCHROMA_LOC_NB , ///< Not part of ABI
649 };
650 
661  AV_AUDIO_SERVICE_TYPE_NB , ///< Not part of ABI
662 };
663 
664 /**
665  * @ingroup lavc_encoding
666  */
667 typedef struct RcOverride{
670  int qscale; // If this is 0 then quality_factor will be used instead.
672 } RcOverride;
673 
674 #define FF_MAX_B_FRAMES 16
675 
676 /* encoding support
677  These flags can be passed in AVCodecContext.flags before initialization.
678  Note: Not everything is supported yet.
679 */
680 
681 #define CODEC_FLAG_QSCALE 0x0002 ///< Use fixed qscale.
682 #define CODEC_FLAG_4MV 0x0004 ///< 4 MV per MB allowed / advanced prediction for H.263.
683 #define CODEC_FLAG_QPEL 0x0010 ///< Use qpel MC.
684 #define CODEC_FLAG_GMC 0x0020 ///< Use GMC.
685 #define CODEC_FLAG_MV0 0x0040 ///< Always try a MB with MV=<0,0>.
686 /**
687  * The parent program guarantees that the input for B-frames containing
688  * streams is not written to for at least s->max_b_frames+1 frames, if
689  * this is not set the input will be copied.
690  */
691 #define CODEC_FLAG_INPUT_PRESERVED 0x0100
692 #define CODEC_FLAG_PASS1 0x0200 ///< Use internal 2pass ratecontrol in first pass mode.
693 #define CODEC_FLAG_PASS2 0x0400 ///< Use internal 2pass ratecontrol in second pass mode.
694 #define CODEC_FLAG_GRAY 0x2000 ///< Only decode/encode grayscale.
695 #define CODEC_FLAG_EMU_EDGE 0x4000 ///< Don't draw edges.
696 #define CODEC_FLAG_PSNR 0x8000 ///< error[?] variables will be set during encoding.
697 #define CODEC_FLAG_TRUNCATED 0x00010000 /** Input bitstream might be truncated at a random
698  location instead of only at frame boundaries. */
699 #define CODEC_FLAG_NORMALIZE_AQP 0x00020000 ///< Normalize adaptive quantization.
700 #define CODEC_FLAG_INTERLACED_DCT 0x00040000 ///< Use interlaced DCT.
701 #define CODEC_FLAG_LOW_DELAY 0x00080000 ///< Force low delay.
702 #define CODEC_FLAG_GLOBAL_HEADER 0x00400000 ///< Place global headers in extradata instead of every keyframe.
703 #define CODEC_FLAG_BITEXACT 0x00800000 ///< Use only bitexact stuff (except (I)DCT).
704 /* Fx : Flag for h263+ extra options */
705 #define CODEC_FLAG_AC_PRED 0x01000000 ///< H.263 advanced intra coding / MPEG-4 AC prediction
706 #define CODEC_FLAG_LOOP_FILTER 0x00000800 ///< loop filter
707 #define CODEC_FLAG_INTERLACED_ME 0x20000000 ///< interlaced motion estimation
708 #define CODEC_FLAG_CLOSED_GOP 0x80000000
709 #define CODEC_FLAG2_FAST 0x00000001 ///< Allow non spec compliant speedup tricks.
710 #define CODEC_FLAG2_NO_OUTPUT 0x00000004 ///< Skip bitstream encoding.
711 #define CODEC_FLAG2_LOCAL_HEADER 0x00000008 ///< Place global headers at every keyframe instead of in extradata.
712 #define CODEC_FLAG2_DROP_FRAME_TIMECODE 0x00002000 ///< timecode is in drop frame format. DEPRECATED!!!!
713 #if FF_API_MPV_GLOBAL_OPTS
714 #define CODEC_FLAG_CBP_RD 0x04000000 ///< Use rate distortion optimization for cbp.
715 #define CODEC_FLAG_QP_RD 0x08000000 ///< Use rate distortion optimization for qp selectioon.
716 #define CODEC_FLAG2_STRICT_GOP 0x00000002 ///< Strictly enforce GOP size.
717 #define CODEC_FLAG2_SKIP_RD 0x00004000 ///< RD optimal MB level residual skipping
718 #endif
719 #define CODEC_FLAG2_CHUNKS 0x00008000 ///< Input bitstream might be truncated at a packet boundaries instead of only at frame boundaries.
720 #define CODEC_FLAG2_SHOW_ALL 0x00400000 ///< Show all frames before the first keyframe
721 
722 /* Unsupported options :
723  * Syntax Arithmetic coding (SAC)
724  * Reference Picture Selection
725  * Independent Segment Decoding */
726 /* /Fx */
727 /* codec capabilities */
729 #define CODEC_CAP_DRAW_HORIZ_BAND 0x0001 ///< Decoder can use draw_horiz_band callback.
730 /**
731  * Codec uses get_buffer() for allocating buffers and supports custom allocators.
732  * If not set, it might not use get_buffer() at all or use operations that
733  * assume the buffer was allocated by avcodec_default_get_buffer.
734  */
735 #define CODEC_CAP_DR1 0x0002
736 #define CODEC_CAP_TRUNCATED 0x0008
737 /* Codec can export data for HW decoding (XvMC). */
738 #define CODEC_CAP_HWACCEL 0x0010
739 /**
740  * Encoder or decoder requires flushing with NULL input at the end in order to
741  * give the complete and correct output.
742  *
743  * NOTE: If this flag is not set, the codec is guaranteed to never be fed with
744  * with NULL data. The user can still send NULL data to the public encode
745  * or decode function, but libavcodec will not pass it along to the codec
746  * unless this flag is set.
747  *
748  * Decoders:
749  * The decoder has a non-zero delay and needs to be fed with avpkt->data=NULL,
750  * avpkt->size=0 at the end to get the delayed data until the decoder no longer
751  * returns frames.
752  *
753  * Encoders:
754  * The encoder needs to be fed with NULL data at the end of encoding until the
755  * encoder no longer returns data.
756  *
757  * NOTE: For encoders implementing the AVCodec.encode2() function, setting this
758  * flag also means that the encoder must set the pts and duration for
759  * each output packet. If this flag is not set, the pts and duration will
760  * be determined by libavcodec from the input frame.
761  */
762 #define CODEC_CAP_DELAY 0x0020
763 /**
764  * Codec can be fed a final frame with a smaller size.
765  * This can be used to prevent truncation of the last audio samples.
766  */
767 #define CODEC_CAP_SMALL_LAST_FRAME 0x0040
768 /**
769  * Codec can export data for HW decoding (VDPAU).
770  */
771 #define CODEC_CAP_HWACCEL_VDPAU 0x0080
772 /**
773  * Codec can output multiple frames per AVPacket
774  * Normally demuxers return one frame at a time, demuxers which do not do
775  * are connected to a parser to split what they return into proper frames.
776  * This flag is reserved to the very rare category of codecs which have a
777  * bitstream that cannot be split into frames without timeconsuming
778  * operations like full decoding. Demuxers carring such bitstreams thus
779  * may return multiple frames in a packet. This has many disadvantages like
780  * prohibiting stream copy in many cases thus it should only be considered
781  * as a last resort.
782  */
783 #define CODEC_CAP_SUBFRAMES 0x0100
784 /**
785  * Codec is experimental and is thus avoided in favor of non experimental
786  * encoders
787  */
788 #define CODEC_CAP_EXPERIMENTAL 0x0200
789 /**
790  * Codec should fill in channel configuration and samplerate instead of container
791  */
792 #define CODEC_CAP_CHANNEL_CONF 0x0400
793 
794 /**
795  * Codec is able to deal with negative linesizes
796  */
797 #define CODEC_CAP_NEG_LINESIZES 0x0800
798 
799 /**
800  * Codec supports frame-level multithreading.
801  */
802 #define CODEC_CAP_FRAME_THREADS 0x1000
803 /**
804  * Codec supports slice-based (or partition-based) multithreading.
805  */
806 #define CODEC_CAP_SLICE_THREADS 0x2000
807 /**
808  * Codec supports changed parameters at any point.
809  */
810 #define CODEC_CAP_PARAM_CHANGE 0x4000
811 /**
812  * Codec supports avctx->thread_count == 0 (auto).
813  */
814 #define CODEC_CAP_AUTO_THREADS 0x8000
815 /**
816  * Audio encoder supports receiving a different number of samples in each call.
817  */
818 #define CODEC_CAP_VARIABLE_FRAME_SIZE 0x10000
819 /**
820  * Codec is intra only.
821  */
822 #define CODEC_CAP_INTRA_ONLY 0x40000000
823 /**
824  * Codec is lossless.
825  */
826 #define CODEC_CAP_LOSSLESS 0x80000000
827 
828 //The following defines may change, don't expect compatibility if you use them.
829 #define MB_TYPE_INTRA4x4 0x0001
830 #define MB_TYPE_INTRA16x16 0x0002 //FIXME H.264-specific
831 #define MB_TYPE_INTRA_PCM 0x0004 //FIXME H.264-specific
832 #define MB_TYPE_16x16 0x0008
833 #define MB_TYPE_16x8 0x0010
834 #define MB_TYPE_8x16 0x0020
835 #define MB_TYPE_8x8 0x0040
836 #define MB_TYPE_INTERLACED 0x0080
837 #define MB_TYPE_DIRECT2 0x0100 //FIXME
838 #define MB_TYPE_ACPRED 0x0200
839 #define MB_TYPE_GMC 0x0400
840 #define MB_TYPE_SKIP 0x0800
841 #define MB_TYPE_P0L0 0x1000
842 #define MB_TYPE_P1L0 0x2000
843 #define MB_TYPE_P0L1 0x4000
844 #define MB_TYPE_P1L1 0x8000
845 #define MB_TYPE_L0 (MB_TYPE_P0L0 | MB_TYPE_P1L0)
846 #define MB_TYPE_L1 (MB_TYPE_P0L1 | MB_TYPE_P1L1)
847 #define MB_TYPE_L0L1 (MB_TYPE_L0 | MB_TYPE_L1)
848 #define MB_TYPE_QUANT 0x00010000
849 #define MB_TYPE_CBP 0x00020000
850 //Note bits 24-31 are reserved for codec specific use (h264 ref0, mpeg1 0mv, ...)
851 
852 /**
853  * Pan Scan area.
854  * This specifies the area which should be displayed.
855  * Note there may be multiple such areas for one frame.
856  */
857 typedef struct AVPanScan{
858  /**
859  * id
860  * - encoding: Set by user.
861  * - decoding: Set by libavcodec.
862  */
863  int id;
864 
865  /**
866  * width and height in 1/16 pel
867  * - encoding: Set by user.
868  * - decoding: Set by libavcodec.
869  */
870  int width;
871  int height;
872 
873  /**
874  * position of the top left corner in 1/16 pel for up to 3 fields/frames
875  * - encoding: Set by user.
876  * - decoding: Set by libavcodec.
877  */
878  int16_t position[3][2];
879 }AVPanScan;
881 #define FF_QSCALE_TYPE_MPEG1 0
882 #define FF_QSCALE_TYPE_MPEG2 1
883 #define FF_QSCALE_TYPE_H264 2
884 #define FF_QSCALE_TYPE_VP56 3
886 #define FF_BUFFER_TYPE_INTERNAL 1
887 #define FF_BUFFER_TYPE_USER 2 ///< direct rendering buffers (image is (de)allocated by user)
888 #define FF_BUFFER_TYPE_SHARED 4 ///< Buffer from somewhere else; don't deallocate image (data/base), all other tables are not shared.
889 #define FF_BUFFER_TYPE_COPY 8 ///< Just a (modified) copy of some other buffer, don't deallocate anything.
891 #define FF_BUFFER_HINTS_VALID 0x01 // Buffer hints value is meaningful (if 0 ignore).
892 #define FF_BUFFER_HINTS_READABLE 0x02 // Codec will read from buffer.
893 #define FF_BUFFER_HINTS_PRESERVE 0x04 // User must not alter buffer content.
894 #define FF_BUFFER_HINTS_REUSABLE 0x08 // Codec will reuse the buffer (update).
895 
896 /**
897  * @defgroup lavc_packet AVPacket
898  *
899  * Types and functions for working with AVPacket.
900  * @{
901  */
905 
906  /**
907  * An AV_PKT_DATA_PARAM_CHANGE side data packet is laid out as follows:
908  * @code
909  * u32le param_flags
910  * if (param_flags & AV_SIDE_DATA_PARAM_CHANGE_CHANNEL_COUNT)
911  * s32le channel_count
912  * if (param_flags & AV_SIDE_DATA_PARAM_CHANGE_CHANNEL_LAYOUT)
913  * u64le channel_layout
914  * if (param_flags & AV_SIDE_DATA_PARAM_CHANGE_SAMPLE_RATE)
915  * s32le sample_rate
916  * if (param_flags & AV_SIDE_DATA_PARAM_CHANGE_DIMENSIONS)
917  * s32le width
918  * s32le height
919  * @endcode
920  */
922 
923  /**
924  * An AV_PKT_DATA_H263_MB_INFO side data packet contains a number of
925  * structures with info about macroblocks relevant to splitting the
926  * packet into smaller packets on macroblock edges (e.g. as for RFC 2190).
927  * That is, it does not necessarily contain info about all macroblocks,
928  * as long as the distance between macroblocks in the info is smaller
929  * than the target payload size.
930  * Each MB info structure is 12 bytes, and is laid out as follows:
931  * @code
932  * u32le bit offset from the start of the packet
933  * u8 current quantizer at the start of the macroblock
934  * u8 GOB number
935  * u16le macroblock address within the GOB
936  * u8 horizontal MV predictor
937  * u8 vertical MV predictor
938  * u8 horizontal MV predictor for block number 3
939  * u8 vertical MV predictor for block number 3
940  * @endcode
941  */
943 
944  /**
945  * Recommmends skipping the specified number of samples
946  * @code
947  * u32le number of samples to skip from start of this packet
948  * u32le number of samples to skip from end of this packet
949  * u8 reason for start skip
950  * u8 reason for end skip (0=padding silence, 1=convergence)
951  * @endcode
952  */
954 
955  /**
956  * An AV_PKT_DATA_JP_DUALMONO side data packet indicates that
957  * the packet may contain "dual mono" audio specific to Japanese DTV
958  * and if it is true, recommends only the selected channel to be used.
959  * @code
960  * u8 selected channels (0=mail/left, 1=sub/right, 2=both)
961  * @endcode
962  */
964 
965  /**
966  * A list of zero terminated key/value strings. There is no end marker for
967  * the list, so it is required to rely on the side data size to stop.
968  */
970 
971  /**
972  * Subtitle event position
973  * @code
974  * u32le x1
975  * u32le y1
976  * u32le x2
977  * u32le y2
978  * @endcode
979  */
981 };
982 
983 /**
984  * This structure stores compressed data. It is typically exported by demuxers
985  * and then passed as input to decoders, or received as output from encoders and
986  * then passed to muxers.
987  *
988  * For video, it should typically contain one compressed frame. For audio it may
989  * contain several compressed frames.
990  *
991  * AVPacket is one of the few structs in FFmpeg, whose size is a part of public
992  * ABI. Thus it may be allocated on stack and no new fields can be added to it
993  * without libavcodec and libavformat major bump.
994  *
995  * The semantics of data ownership depends on the destruct field.
996  * If it is set, the packet data is dynamically allocated and is valid
997  * indefinitely until av_free_packet() is called (which in turn calls the
998  * destruct callback to free the data). If destruct is not set, the packet data
999  * is typically backed by some static buffer somewhere and is only valid for a
1000  * limited time (e.g. until the next read call when demuxing).
1001  *
1002  * The side data is always allocated with av_malloc() and is freed in
1003  * av_free_packet().
1004  */
1005 typedef struct AVPacket {
1006  /**
1007  * Presentation timestamp in AVStream->time_base units; the time at which
1008  * the decompressed packet will be presented to the user.
1009  * Can be AV_NOPTS_VALUE if it is not stored in the file.
1010  * pts MUST be larger or equal to dts as presentation cannot happen before
1011  * decompression, unless one wants to view hex dumps. Some formats misuse
1012  * the terms dts and pts/cts to mean something different. Such timestamps
1013  * must be converted to true pts/dts before they are stored in AVPacket.
1014  */
1015  int64_t pts;
1016  /**
1017  * Decompression timestamp in AVStream->time_base units; the time at which
1018  * the packet is decompressed.
1019  * Can be AV_NOPTS_VALUE if it is not stored in the file.
1020  */
1021  int64_t dts;
1023  int size;
1024  int stream_index;
1025  /**
1026  * A combination of AV_PKT_FLAG values
1027  */
1028  int flags;
1029  /**
1030  * Additional packet data that can be provided by the container.
1031  * Packet can contain several types of side information.
1032  */
1033  struct {
1034  uint8_t *data;
1035  int size;
1038  int side_data_elems;
1039 
1040  /**
1041  * Duration of this packet in AVStream->time_base units, 0 if unknown.
1042  * Equals next_pts - this_pts in presentation order.
1043  */
1045  void (*destruct)(struct AVPacket *);
1046  void *priv;
1047  int64_t pos; ///< byte position in stream, -1 if unknown
1048 
1049  /**
1050  * Time difference in AVStream->time_base units from the pts of this
1051  * packet to the point at which the output from the decoder has converged
1052  * independent from the availability of previous frames. That is, the
1053  * frames are virtually identical no matter if decoding started from
1054  * the very first frame or from this keyframe.
1055  * Is AV_NOPTS_VALUE if unknown.
1056  * This field is not the display duration of the current packet.
1057  * This field has no meaning if the packet does not have AV_PKT_FLAG_KEY
1058  * set.
1059  *
1060  * The purpose of this field is to allow seeking in streams that have no
1061  * keyframes in the conventional sense. It corresponds to the
1062  * recovery point SEI in H.264 and match_time_delta in NUT. It is also
1063  * essential for some types of subtitle streams to ensure that all
1064  * subtitles are correctly displayed after seeking.
1065  */
1066  int64_t convergence_duration;
1068 #define AV_PKT_FLAG_KEY 0x0001 ///< The packet contains a keyframe
1069 #define AV_PKT_FLAG_CORRUPT 0x0002 ///< The packet content is corrupted
1076 };
1077 /**
1078  * @}
1079  */
1080 
1081 /**
1082  * This structure describes decoded (raw) audio or video data.
1083  *
1084  * AVFrame must be allocated using avcodec_alloc_frame() and freed with
1085  * avcodec_free_frame(). Note that this allocates only the AVFrame itself. The
1086  * buffers for the data must be managed through other means.
1087  *
1088  * AVFrame is typically allocated once and then reused multiple times to hold
1089  * different data (e.g. a single AVFrame to hold frames received from a
1090  * decoder). In such a case, avcodec_get_frame_defaults() should be used to
1091  * reset the frame to its original clean state before it is reused again.
1092  *
1093  * sizeof(AVFrame) is not a part of the public ABI, so new fields may be added
1094  * to the end with a minor bump.
1095  * Similarly fields that are marked as to be only accessed by
1096  * av_opt_ptr() can be reordered. This allows 2 forks to add fields
1097  * without breaking compatibility with each other.
1098  */
1099 typedef struct AVFrame {
1100 #define AV_NUM_DATA_POINTERS 8
1101  /**
1102  * pointer to the picture/channel planes.
1103  * This might be different from the first allocated byte
1104  * - encoding: Set by user
1105  * - decoding: set by AVCodecContext.get_buffer()
1106  */
1108 
1109  /**
1110  * Size, in bytes, of the data for each picture/channel plane.
1111  *
1112  * For audio, only linesize[0] may be set. For planar audio, each channel
1113  * plane must be the same size.
1114  *
1115  * - encoding: Set by user
1116  * - decoding: set by AVCodecContext.get_buffer()
1117  */
1119 
1120  /**
1121  * pointers to the data planes/channels.
1122  *
1123  * For video, this should simply point to data[].
1124  *
1125  * For planar audio, each channel has a separate data pointer, and
1126  * linesize[0] contains the size of each channel buffer.
1127  * For packed audio, there is just one data pointer, and linesize[0]
1128  * contains the total size of the buffer for all channels.
1129  *
1130  * Note: Both data and extended_data will always be set by get_buffer(),
1131  * but for planar audio with more channels that can fit in data,
1132  * extended_data must be used by the decoder in order to access all
1133  * channels.
1134  *
1135  * encoding: set by user
1136  * decoding: set by AVCodecContext.get_buffer()
1137  */
1139 
1140  /**
1141  * width and height of the video frame
1142  * - encoding: unused
1143  * - decoding: Read by user.
1144  */
1145  int width, height;
1146 
1147  /**
1148  * number of audio samples (per channel) described by this frame
1149  * - encoding: Set by user
1150  * - decoding: Set by libavcodec
1151  */
1152  int nb_samples;
1153 
1154  /**
1155  * format of the frame, -1 if unknown or unset
1156  * Values correspond to enum AVPixelFormat for video frames,
1157  * enum AVSampleFormat for audio)
1158  * - encoding: unused
1159  * - decoding: Read by user.
1160  */
1161  int format;
1162 
1163  /**
1164  * 1 -> keyframe, 0-> not
1165  * - encoding: Set by libavcodec.
1166  * - decoding: Set by libavcodec.
1167  */
1168  int key_frame;
1169 
1170  /**
1171  * Picture type of the frame, see ?_TYPE below.
1172  * - encoding: Set by libavcodec. for coded_picture (and set by user for input).
1173  * - decoding: Set by libavcodec.
1174  */
1175  enum AVPictureType pict_type;
1176 
1177  /**
1178  * pointer to the first allocated byte of the picture. Can be used in get_buffer/release_buffer.
1179  * This isn't used by libavcodec unless the default get/release_buffer() is used.
1180  * - encoding:
1181  * - decoding:
1182  */
1184 
1185  /**
1186  * sample aspect ratio for the video frame, 0/1 if unknown/unspecified
1187  * - encoding: unused
1188  * - decoding: Read by user.
1189  */
1191 
1192  /**
1193  * presentation timestamp in time_base units (time when frame should be shown to user)
1194  * If AV_NOPTS_VALUE then frame_rate = 1/time_base will be assumed.
1195  * - encoding: MUST be set by user.
1196  * - decoding: Set by libavcodec.
1197  */
1198  int64_t pts;
1199 
1200  /**
1201  * pts copied from the AVPacket that was decoded to produce this frame
1202  * - encoding: unused
1203  * - decoding: Read by user.
1204  */
1205  int64_t pkt_pts;
1206 
1207  /**
1208  * dts copied from the AVPacket that triggered returning this frame
1209  * - encoding: unused
1210  * - decoding: Read by user.
1211  */
1212  int64_t pkt_dts;
1213 
1214  /**
1215  * picture number in bitstream order
1216  * - encoding: set by
1217  * - decoding: Set by libavcodec.
1218  */
1220  /**
1221  * picture number in display order
1222  * - encoding: set by
1223  * - decoding: Set by libavcodec.
1224  */
1226 
1227  /**
1228  * quality (between 1 (good) and FF_LAMBDA_MAX (bad))
1229  * - encoding: Set by libavcodec. for coded_picture (and set by user for input).
1230  * - decoding: Set by libavcodec.
1231  */
1232  int quality;
1233 
1234  /**
1235  * is this picture used as reference
1236  * The values for this are the same as the MpegEncContext.picture_structure
1237  * variable, that is 1->top field, 2->bottom field, 3->frame/both fields.
1238  * Set to 4 for delayed, non-reference frames.
1239  * - encoding: unused
1240  * - decoding: Set by libavcodec. (before get_buffer() call)).
1241  */
1242  int reference;
1243 
1244  /**
1245  * QP table
1246  * - encoding: unused
1247  * - decoding: Set by libavcodec.
1248  */
1249  int8_t *qscale_table;
1250  /**
1251  * QP store stride
1252  * - encoding: unused
1253  * - decoding: Set by libavcodec.
1254  */
1255  int qstride;
1256 
1257  /**
1258  *
1259  */
1260  int qscale_type;
1261 
1262  /**
1263  * mbskip_table[mb]>=1 if MB didn't change
1264  * stride= mb_width = (width+15)>>4
1265  * - encoding: unused
1266  * - decoding: Set by libavcodec.
1267  */
1269 
1270  /**
1271  * motion vector table
1272  * @code
1273  * example:
1274  * int mv_sample_log2= 4 - motion_subsample_log2;
1275  * int mb_width= (width+15)>>4;
1276  * int mv_stride= (mb_width << mv_sample_log2) + 1;
1277  * motion_val[direction][x + y*mv_stride][0->mv_x, 1->mv_y];
1278  * @endcode
1279  * - encoding: Set by user.
1280  * - decoding: Set by libavcodec.
1281  */
1282  int16_t (*motion_val[2])[2];
1283 
1284  /**
1285  * macroblock type table
1286  * mb_type_base + mb_width + 2
1287  * - encoding: Set by user.
1288  * - decoding: Set by libavcodec.
1289  */
1290  uint32_t *mb_type;
1291 
1292  /**
1293  * DCT coefficients
1294  * - encoding: unused
1295  * - decoding: Set by libavcodec.
1296  */
1297  short *dct_coeff;
1298 
1299  /**
1300  * motion reference frame index
1301  * the order in which these are stored can depend on the codec.
1302  * - encoding: Set by user.
1303  * - decoding: Set by libavcodec.
1304  */
1305  int8_t *ref_index[2];
1306 
1307  /**
1308  * for some private data of the user
1309  * - encoding: unused
1310  * - decoding: Set by user.
1311  */
1312  void *opaque;
1313 
1314  /**
1315  * error
1316  * - encoding: Set by libavcodec. if flags&CODEC_FLAG_PSNR.
1317  * - decoding: unused
1318  */
1319  uint64_t error[AV_NUM_DATA_POINTERS];
1320 
1321  /**
1322  * type of the buffer (to keep track of who has to deallocate data[*])
1323  * - encoding: Set by the one who allocates it.
1324  * - decoding: Set by the one who allocates it.
1325  * Note: User allocated (direct rendering) & internal buffers cannot coexist currently.
1326  */
1327  int type;
1328 
1329  /**
1330  * When decoding, this signals how much the picture must be delayed.
1331  * extra_delay = repeat_pict / (2*fps)
1332  * - encoding: unused
1333  * - decoding: Set by libavcodec.
1334  */
1335  int repeat_pict;
1336 
1337  /**
1338  * The content of the picture is interlaced.
1339  * - encoding: Set by user.
1340  * - decoding: Set by libavcodec. (default 0)
1341  */
1342  int interlaced_frame;
1343 
1344  /**
1345  * If the content is interlaced, is top field displayed first.
1346  * - encoding: Set by user.
1347  * - decoding: Set by libavcodec.
1348  */
1349  int top_field_first;
1350 
1351  /**
1352  * Tell user application that palette has changed from previous frame.
1353  * - encoding: ??? (no palette-enabled encoder yet)
1354  * - decoding: Set by libavcodec. (default 0).
1355  */
1356  int palette_has_changed;
1357 
1358  /**
1359  * codec suggestion on buffer type if != 0
1360  * - encoding: unused
1361  * - decoding: Set by libavcodec. (before get_buffer() call)).
1362  */
1363  int buffer_hints;
1364 
1365  /**
1366  * Pan scan.
1367  * - encoding: Set by user.
1368  * - decoding: Set by libavcodec.
1369  */
1371 
1372  /**
1373  * reordered opaque 64bit (generally an integer or a double precision float
1374  * PTS but can be anything).
1375  * The user sets AVCodecContext.reordered_opaque to represent the input at
1376  * that time,
1377  * the decoder reorders values as needed and sets AVFrame.reordered_opaque
1378  * to exactly one of the values provided by the user through AVCodecContext.reordered_opaque
1379  * @deprecated in favor of pkt_pts
1380  * - encoding: unused
1381  * - decoding: Read by user.
1382  */
1383  int64_t reordered_opaque;
1384 
1385  /**
1386  * hardware accelerator private data (FFmpeg-allocated)
1387  * - encoding: unused
1388  * - decoding: Set by libavcodec
1389  */
1391 
1392  /**
1393  * the AVCodecContext which ff_thread_get_buffer() was last called on
1394  * - encoding: Set by libavcodec.
1395  * - decoding: Set by libavcodec.
1396  */
1397  struct AVCodecContext *owner;
1398 
1399  /**
1400  * used by multithreading to store frame-specific info
1401  * - encoding: Set by libavcodec.
1402  * - decoding: Set by libavcodec.
1403  */
1404  void *thread_opaque;
1405 
1406  /**
1407  * log2 of the size of the block which a single vector in motion_val represents:
1408  * (4->16x16, 3->8x8, 2-> 4x4, 1-> 2x2)
1409  * - encoding: unused
1410  * - decoding: Set by libavcodec.
1411  */
1413 
1414  /**
1415  * Sample rate of the audio data.
1416  *
1417  * - encoding: unused
1418  * - decoding: read by user
1419  */
1420  int sample_rate;
1421 
1422  /**
1423  * Channel layout of the audio data.
1424  *
1425  * - encoding: unused
1426  * - decoding: read by user.
1427  */
1428  uint64_t channel_layout;
1429 
1430  /**
1431  * frame timestamp estimated using various heuristics, in stream time base
1432  * Code outside libavcodec should access this field using:
1433  * av_frame_get_best_effort_timestamp(frame)
1434  * - encoding: unused
1435  * - decoding: set by libavcodec, read by user.
1436  */
1437  int64_t best_effort_timestamp;
1438 
1439  /**
1440  * reordered pos from the last AVPacket that has been input into the decoder
1441  * Code outside libavcodec should access this field using:
1442  * av_frame_get_pkt_pos(frame)
1443  * - encoding: unused
1444  * - decoding: Read by user.
1445  */
1446  int64_t pkt_pos;
1447 
1448  /**
1449  * duration of the corresponding packet, expressed in
1450  * AVStream->time_base units, 0 if unknown.
1451  * Code outside libavcodec should access this field using:
1452  * av_frame_get_pkt_duration(frame)
1453  * - encoding: unused
1454  * - decoding: Read by user.
1455  */
1456  int64_t pkt_duration;
1457 
1458  /**
1459  * metadata.
1460  * Code outside libavcodec should access this field using:
1461  * av_frame_get_metadata(frame)
1462  * - encoding: Set by user.
1463  * - decoding: Set by libavcodec.
1464  */
1466 
1467  /**
1468  * decode error flags of the frame, set to a combination of
1469  * FF_DECODE_ERROR_xxx flags if the decoder produced a frame, but there
1470  * were errors during the decoding.
1471  * Code outside libavcodec should access this field using:
1472  * av_frame_get_decode_error_flags(frame)
1473  * - encoding: unused
1474  * - decoding: set by libavcodec, read by user.
1475  */
1477 #define FF_DECODE_ERROR_INVALID_BITSTREAM 1
1478 #define FF_DECODE_ERROR_MISSING_REFERENCE 2
1479 
1480  /**
1481  * number of audio channels, only used for audio.
1482  * Code outside libavcodec should access this field using:
1483  * av_frame_get_channels(frame)
1484  * - encoding: unused
1485  * - decoding: Read by user.
1486  */
1487  int64_t channels;
1488 
1489  /**
1490  * size of the corresponding packet containing the compressed
1491  * frame. It must be accessed using av_frame_get_pkt_size() and
1492  * av_frame_set_pkt_size().
1493  * It is set to a negative value if unknown.
1494  * - encoding: unused
1495  * - decoding: set by libavcodec, read by user.
1496  */
1497  int pkt_size;
1498 } AVFrame;
1499 
1500 /**
1501  * Accessors for some AVFrame fields.
1502  * The position of these field in the structure is not part of the ABI,
1503  * they should not be accessed directly outside libavcodec.
1504  */
1507 int64_t av_frame_get_pkt_duration (const AVFrame *frame);
1508 void av_frame_set_pkt_duration (AVFrame *frame, int64_t val);
1509 int64_t av_frame_get_pkt_pos (const AVFrame *frame);
1510 void av_frame_set_pkt_pos (AVFrame *frame, int64_t val);
1511 int64_t av_frame_get_channel_layout (const AVFrame *frame);
1512 void av_frame_set_channel_layout (AVFrame *frame, int64_t val);
1513 int av_frame_get_channels (const AVFrame *frame);
1514 void av_frame_set_channels (AVFrame *frame, int val);
1516 void av_frame_set_sample_rate (AVFrame *frame, int val);
1521 int av_frame_get_pkt_size(const AVFrame *frame);
1522 void av_frame_set_pkt_size(AVFrame *frame, int val);
1523 
1524 struct AVCodecInternal;
1529  AV_FIELD_TT, //< Top coded_first, top displayed first
1530  AV_FIELD_BB, //< Bottom coded first, bottom displayed first
1531  AV_FIELD_TB, //< Top coded first, bottom displayed first
1532  AV_FIELD_BT, //< Bottom coded first, top displayed first
1533 };
1534 
1535 /**
1536  * main external API structure.
1537  * New fields can be added to the end with minor version bumps.
1538  * Removal, reordering and changes to existing fields require a major
1539  * version bump.
1540  * Please use AVOptions (av_opt* / av_set/get*()) to access these fields from user
1541  * applications.
1542  * sizeof(AVCodecContext) must not be used outside libav*.
1543  */
1544 typedef struct AVCodecContext {
1545  /**
1546  * information on struct for av_log
1547  * - set by avcodec_alloc_context3
1548  */
1550  int log_level_offset;
1552  enum AVMediaType codec_type; /* see AVMEDIA_TYPE_xxx */
1553  const struct AVCodec *codec;
1554  char codec_name[32];
1555  enum AVCodecID codec_id; /* see AV_CODEC_ID_xxx */
1556 
1557  /**
1558  * fourcc (LSB first, so "ABCD" -> ('D'<<24) + ('C'<<16) + ('B'<<8) + 'A').
1559  * This is used to work around some encoder bugs.
1560  * A demuxer should set this to what is stored in the field used to identify the codec.
1561  * If there are multiple such fields in a container then the demuxer should choose the one
1562  * which maximizes the information about the used codec.
1563  * If the codec tag field in a container is larger than 32 bits then the demuxer should
1564  * remap the longer ID to 32 bits with a table or other structure. Alternatively a new
1565  * extra_codec_tag + size could be added but for this a clear advantage must be demonstrated
1566  * first.
1567  * - encoding: Set by user, if not then the default based on codec_id will be used.
1568  * - decoding: Set by user, will be converted to uppercase by libavcodec during init.
1569  */
1570  unsigned int codec_tag;
1571 
1572  /**
1573  * fourcc from the AVI stream header (LSB first, so "ABCD" -> ('D'<<24) + ('C'<<16) + ('B'<<8) + 'A').
1574  * This is used to work around some encoder bugs.
1575  * - encoding: unused
1576  * - decoding: Set by user, will be converted to uppercase by libavcodec during init.
1577  */
1578  unsigned int stream_codec_tag;
1579 
1580 #if FF_API_SUB_ID
1581  /**
1582  * @deprecated this field is unused
1583  */
1584  attribute_deprecated int sub_id;
1585 #endif
1587  void *priv_data;
1588 
1589  /**
1590  * Private context used for internal data.
1591  *
1592  * Unlike priv_data, this is not codec-specific. It is used in general
1593  * libavcodec functions.
1594  */
1595  struct AVCodecInternal *internal;
1596 
1597  /**
1598  * Private data of the user, can be used to carry app specific stuff.
1599  * - encoding: Set by user.
1600  * - decoding: Set by user.
1601  */
1602  void *opaque;
1603 
1604  /**
1605  * the average bitrate
1606  * - encoding: Set by user; unused for constant quantizer encoding.
1607  * - decoding: Set by libavcodec. 0 or some bitrate if this info is available in the stream.
1608  */
1609  int bit_rate;
1610 
1611  /**
1612  * number of bits the bitstream is allowed to diverge from the reference.
1613  * the reference can be CBR (for CBR pass1) or VBR (for pass2)
1614  * - encoding: Set by user; unused for constant quantizer encoding.
1615  * - decoding: unused
1616  */
1617  int bit_rate_tolerance;
1618 
1619  /**
1620  * Global quality for codecs which cannot change it per frame.
1621  * This should be proportional to MPEG-1/2/4 qscale.
1622  * - encoding: Set by user.
1623  * - decoding: unused
1624  */
1625  int global_quality;
1626 
1627  /**
1628  * - encoding: Set by user.
1629  * - decoding: unused
1630  */
1632 #define FF_COMPRESSION_DEFAULT -1
1633 
1634  /**
1635  * CODEC_FLAG_*.
1636  * - encoding: Set by user.
1637  * - decoding: Set by user.
1638  */
1639  int flags;
1640 
1641  /**
1642  * CODEC_FLAG2_*
1643  * - encoding: Set by user.
1644  * - decoding: Set by user.
1645  */
1646  int flags2;
1647 
1648  /**
1649  * some codecs need / can use extradata like Huffman tables.
1650  * mjpeg: Huffman tables
1651  * rv10: additional flags
1652  * mpeg4: global headers (they can be in the bitstream or here)
1653  * The allocated memory should be FF_INPUT_BUFFER_PADDING_SIZE bytes larger
1654  * than extradata_size to avoid prolems if it is read with the bitstream reader.
1655  * The bytewise contents of extradata must not depend on the architecture or CPU endianness.
1656  * - encoding: Set/allocated/freed by libavcodec.
1657  * - decoding: Set/allocated/freed by user.
1658  */
1660  int extradata_size;
1661 
1662  /**
1663  * This is the fundamental unit of time (in seconds) in terms
1664  * of which frame timestamps are represented. For fixed-fps content,
1665  * timebase should be 1/framerate and timestamp increments should be
1666  * identically 1.
1667  * - encoding: MUST be set by user.
1668  * - decoding: Set by libavcodec.
1669  */
1671 
1672  /**
1673  * For some codecs, the time base is closer to the field rate than the frame rate.
1674  * Most notably, H.264 and MPEG-2 specify time_base as half of frame duration
1675  * if no telecine is used ...
1676  *
1677  * Set to time_base ticks per frame. Default 1, e.g., H.264/MPEG-2 set it to 2.
1678  */
1679  int ticks_per_frame;
1680 
1681  /**
1682  * Codec delay.
1683  *
1684  * Encoding: Number of frames delay there will be from the encoder input to
1685  * the decoder output. (we assume the decoder matches the spec)
1686  * Decoding: Number of frames delay in addition to what a standard decoder
1687  * as specified in the spec would produce.
1688  *
1689  * Video:
1690  * Number of frames the decoded output will be delayed relative to the
1691  * encoded input.
1692  *
1693  * Audio:
1694  * For encoding, this is the number of "priming" samples added to the
1695  * beginning of the stream. The decoded output will be delayed by this
1696  * many samples relative to the input to the encoder. Note that this
1697  * field is purely informational and does not directly affect the pts
1698  * output by the encoder, which should always be based on the actual
1699  * presentation time, including any delay.
1700  * For decoding, this is the number of samples the decoder needs to
1701  * output before the decoder's output is valid. When seeking, you should
1702  * start decoding this many samples prior to your desired seek point.
1703  *
1704  * - encoding: Set by libavcodec.
1705  * - decoding: Set by libavcodec.
1706  */
1707  int delay;
1708 
1709 
1710  /* video only */
1711  /**
1712  * picture width / height.
1713  * - encoding: MUST be set by user.
1714  * - decoding: Set by libavcodec.
1715  * Note: For compatibility it is possible to set this instead of
1716  * coded_width/height before decoding.
1717  */
1718  int width, height;
1719 
1720  /**
1721  * Bitstream width / height, may be different from width/height if lowres enabled.
1722  * - encoding: unused
1723  * - decoding: Set by user before init if known. Codec should override / dynamically change if needed.
1724  */
1727 #define FF_ASPECT_EXTENDED 15
1728 
1729  /**
1730  * the number of pictures in a group of pictures, or 0 for intra_only
1731  * - encoding: Set by user.
1732  * - decoding: unused
1733  */
1734  int gop_size;
1735 
1736  /**
1737  * Pixel format, see AV_PIX_FMT_xxx.
1738  * May be set by the demuxer if known from headers.
1739  * May be overridden by the decoder if it knows better.
1740  * - encoding: Set by user.
1741  * - decoding: Set by user if known, overridden by libavcodec if known
1742  */
1743  enum AVPixelFormat pix_fmt;
1744 
1745  /**
1746  * Motion estimation algorithm used for video coding.
1747  * 1 (zero), 2 (full), 3 (log), 4 (phods), 5 (epzs), 6 (x1), 7 (hex),
1748  * 8 (umh), 9 (iter), 10 (tesa) [7, 8, 10 are x264 specific, 9 is snow specific]
1749  * - encoding: MUST be set by user.
1750  * - decoding: unused
1751  */
1752  int me_method;
1753 
1754  /**
1755  * If non NULL, 'draw_horiz_band' is called by the libavcodec
1756  * decoder to draw a horizontal band. It improves cache usage. Not
1757  * all codecs can do that. You must check the codec capabilities
1758  * beforehand.
1759  * When multithreading is used, it may be called from multiple threads
1760  * at the same time; threads might draw different parts of the same AVFrame,
1761  * or multiple AVFrames, and there is no guarantee that slices will be drawn
1762  * in order.
1763  * The function is also used by hardware acceleration APIs.
1764  * It is called at least once during frame decoding to pass
1765  * the data needed for hardware render.
1766  * In that mode instead of pixel data, AVFrame points to
1767  * a structure specific to the acceleration API. The application
1768  * reads the structure and can change some fields to indicate progress
1769  * or mark state.
1770  * - encoding: unused
1771  * - decoding: Set by user.
1772  * @param height the height of the slice
1773  * @param y the y position of the slice
1774  * @param type 1->top field, 2->bottom field, 3->frame
1775  * @param offset offset into the AVFrame.data from which the slice should be read
1776  */
1777  void (*draw_horiz_band)(struct AVCodecContext *s,
1778  const AVFrame *src, int offset[AV_NUM_DATA_POINTERS],
1779  int y, int type, int height);
1780 
1781  /**
1782  * callback to negotiate the pixelFormat
1783  * @param fmt is the list of formats which are supported by the codec,
1784  * it is terminated by -1 as 0 is a valid format, the formats are ordered by quality.
1785  * The first is always the native one.
1786  * @return the chosen format
1787  * - encoding: unused
1788  * - decoding: Set by user, if not set the native format will be chosen.
1789  */
1790  enum AVPixelFormat (*get_format)(struct AVCodecContext *s, const enum AVPixelFormat * fmt);
1791 
1792  /**
1793  * maximum number of B-frames between non-B-frames
1794  * Note: The output will be delayed by max_b_frames+1 relative to the input.
1795  * - encoding: Set by user.
1796  * - decoding: unused
1797  */
1798  int max_b_frames;
1799 
1800  /**
1801  * qscale factor between IP and B-frames
1802  * If > 0 then the last P-frame quantizer will be used (q= lastp_q*factor+offset).
1803  * If < 0 then normal ratecontrol will be done (q= -normal_q*factor+offset).
1804  * - encoding: Set by user.
1805  * - decoding: unused
1806  */
1807  float b_quant_factor;
1808 
1809  /** obsolete FIXME remove */
1811 #define FF_RC_STRATEGY_XVID 1
1813  int b_frame_strategy;
1814 
1815 #if FF_API_MPV_GLOBAL_OPTS
1816  /**
1817  * luma single coefficient elimination threshold
1818  * - encoding: Set by user.
1819  * - decoding: unused
1820  */
1821  attribute_deprecated int luma_elim_threshold;
1822 
1823  /**
1824  * chroma single coeff elimination threshold
1825  * - encoding: Set by user.
1826  * - decoding: unused
1827  */
1828  attribute_deprecated int chroma_elim_threshold;
1829 #endif
1830 
1831  /**
1832  * qscale offset between IP and B-frames
1833  * - encoding: Set by user.
1834  * - decoding: unused
1835  */
1836  float b_quant_offset;
1837 
1838  /**
1839  * Size of the frame reordering buffer in the decoder.
1840  * For MPEG-2 it is 1 IPB or 0 low delay IP.
1841  * - encoding: Set by libavcodec.
1842  * - decoding: Set by libavcodec.
1843  */
1844  int has_b_frames;
1845 
1846  /**
1847  * 0-> h263 quant 1-> mpeg quant
1848  * - encoding: Set by user.
1849  * - decoding: unused
1850  */
1851  int mpeg_quant;
1852 
1853  /**
1854  * qscale factor between P and I-frames
1855  * If > 0 then the last p frame quantizer will be used (q= lastp_q*factor+offset).
1856  * If < 0 then normal ratecontrol will be done (q= -normal_q*factor+offset).
1857  * - encoding: Set by user.
1858  * - decoding: unused
1859  */
1860  float i_quant_factor;
1861 
1862  /**
1863  * qscale offset between P and I-frames
1864  * - encoding: Set by user.
1865  * - decoding: unused
1866  */
1867  float i_quant_offset;
1868 
1869  /**
1870  * luminance masking (0-> disabled)
1871  * - encoding: Set by user.
1872  * - decoding: unused
1873  */
1874  float lumi_masking;
1875 
1876  /**
1877  * temporary complexity masking (0-> disabled)
1878  * - encoding: Set by user.
1879  * - decoding: unused
1880  */
1881  float temporal_cplx_masking;
1882 
1883  /**
1884  * spatial complexity masking (0-> disabled)
1885  * - encoding: Set by user.
1886  * - decoding: unused
1887  */
1888  float spatial_cplx_masking;
1889 
1890  /**
1891  * p block masking (0-> disabled)
1892  * - encoding: Set by user.
1893  * - decoding: unused
1894  */
1895  float p_masking;
1896 
1897  /**
1898  * darkness masking (0-> disabled)
1899  * - encoding: Set by user.
1900  * - decoding: unused
1901  */
1902  float dark_masking;
1903 
1904  /**
1905  * slice count
1906  * - encoding: Set by libavcodec.
1907  * - decoding: Set by user (or 0).
1908  */
1909  int slice_count;
1910  /**
1911  * prediction method (needed for huffyuv)
1912  * - encoding: Set by user.
1913  * - decoding: unused
1914  */
1916 #define FF_PRED_LEFT 0
1917 #define FF_PRED_PLANE 1
1918 #define FF_PRED_MEDIAN 2
1919 
1920  /**
1921  * slice offsets in the frame in bytes
1922  * - encoding: Set/allocated by libavcodec.
1923  * - decoding: Set/allocated by user (or NULL).
1924  */
1925  int *slice_offset;
1926 
1927  /**
1928  * sample aspect ratio (0 if unknown)
1929  * That is the width of a pixel divided by the height of the pixel.
1930  * Numerator and denominator must be relatively prime and smaller than 256 for some video standards.
1931  * - encoding: Set by user.
1932  * - decoding: Set by libavcodec.
1933  */
1935 
1936  /**
1937  * motion estimation comparison function
1938  * - encoding: Set by user.
1939  * - decoding: unused
1940  */
1941  int me_cmp;
1942  /**
1943  * subpixel motion estimation comparison function
1944  * - encoding: Set by user.
1945  * - decoding: unused
1946  */
1947  int me_sub_cmp;
1948  /**
1949  * macroblock comparison function (not supported yet)
1950  * - encoding: Set by user.
1951  * - decoding: unused
1952  */
1953  int mb_cmp;
1954  /**
1955  * interlaced DCT comparison function
1956  * - encoding: Set by user.
1957  * - decoding: unused
1958  */
1960 #define FF_CMP_SAD 0
1961 #define FF_CMP_SSE 1
1962 #define FF_CMP_SATD 2
1963 #define FF_CMP_DCT 3
1964 #define FF_CMP_PSNR 4
1965 #define FF_CMP_BIT 5
1966 #define FF_CMP_RD 6
1967 #define FF_CMP_ZERO 7
1968 #define FF_CMP_VSAD 8
1969 #define FF_CMP_VSSE 9
1970 #define FF_CMP_NSSE 10
1971 #define FF_CMP_W53 11
1972 #define FF_CMP_W97 12
1973 #define FF_CMP_DCTMAX 13
1974 #define FF_CMP_DCT264 14
1975 #define FF_CMP_CHROMA 256
1976 
1977  /**
1978  * ME diamond size & shape
1979  * - encoding: Set by user.
1980  * - decoding: unused
1981  */
1982  int dia_size;
1983 
1984  /**
1985  * amount of previous MV predictors (2a+1 x 2a+1 square)
1986  * - encoding: Set by user.
1987  * - decoding: unused
1988  */
1990 
1991  /**
1992  * prepass for motion estimation
1993  * - encoding: Set by user.
1994  * - decoding: unused
1995  */
1996  int pre_me;
1997 
1998  /**
1999  * motion estimation prepass comparison function
2000  * - encoding: Set by user.
2001  * - decoding: unused
2002  */
2003  int me_pre_cmp;
2004 
2005  /**
2006  * ME prepass diamond size & shape
2007  * - encoding: Set by user.
2008  * - decoding: unused
2009  */
2010  int pre_dia_size;
2011 
2012  /**
2013  * subpel ME quality
2014  * - encoding: Set by user.
2015  * - decoding: unused
2016  */
2017  int me_subpel_quality;
2018 
2019  /**
2020  * DTG active format information (additional aspect ratio
2021  * information only used in DVB MPEG-2 transport streams)
2022  * 0 if not set.
2023  *
2024  * - encoding: unused
2025  * - decoding: Set by decoder.
2026  */
2028 #define FF_DTG_AFD_SAME 8
2029 #define FF_DTG_AFD_4_3 9
2030 #define FF_DTG_AFD_16_9 10
2031 #define FF_DTG_AFD_14_9 11
2032 #define FF_DTG_AFD_4_3_SP_14_9 13
2033 #define FF_DTG_AFD_16_9_SP_14_9 14
2034 #define FF_DTG_AFD_SP_4_3 15
2035 
2036  /**
2037  * maximum motion estimation search range in subpel units
2038  * If 0 then no limit.
2039  *
2040  * - encoding: Set by user.
2041  * - decoding: unused
2042  */
2043  int me_range;
2044 
2045  /**
2046  * intra quantizer bias
2047  * - encoding: Set by user.
2048  * - decoding: unused
2049  */
2051 #define FF_DEFAULT_QUANT_BIAS 999999
2052 
2053  /**
2054  * inter quantizer bias
2055  * - encoding: Set by user.
2056  * - decoding: unused
2057  */
2058  int inter_quant_bias;
2059 
2060 #if FF_API_COLOR_TABLE_ID
2061  /**
2062  * color table ID
2063  * - encoding: unused
2064  * - decoding: Which clrtable should be used for 8bit RGB images.
2065  * Tables have to be stored somewhere. FIXME
2066  */
2067  attribute_deprecated int color_table_id;
2068 #endif
2069 
2070  /**
2071  * slice flags
2072  * - encoding: unused
2073  * - decoding: Set by user.
2074  */
2076 #define SLICE_FLAG_CODED_ORDER 0x0001 ///< draw_horiz_band() is called in coded order instead of display
2077 #define SLICE_FLAG_ALLOW_FIELD 0x0002 ///< allow draw_horiz_band() with field slices (MPEG2 field pics)
2078 #define SLICE_FLAG_ALLOW_PLANE 0x0004 ///< allow draw_horiz_band() with 1 component at a time (SVQ1)
2079 
2080  /**
2081  * XVideo Motion Acceleration
2082  * - encoding: forbidden
2083  * - decoding: set by decoder
2084  */
2085  int xvmc_acceleration;
2086 
2087  /**
2088  * macroblock decision mode
2089  * - encoding: Set by user.
2090  * - decoding: unused
2091  */
2093 #define FF_MB_DECISION_SIMPLE 0 ///< uses mb_cmp
2094 #define FF_MB_DECISION_BITS 1 ///< chooses the one which needs the fewest bits
2095 #define FF_MB_DECISION_RD 2 ///< rate distortion
2096 
2097  /**
2098  * custom intra quantization matrix
2099  * - encoding: Set by user, can be NULL.
2100  * - decoding: Set by libavcodec.
2101  */
2102  uint16_t *intra_matrix;
2103 
2104  /**
2105  * custom inter quantization matrix
2106  * - encoding: Set by user, can be NULL.
2107  * - decoding: Set by libavcodec.
2108  */
2109  uint16_t *inter_matrix;
2110 
2111  /**
2112  * scene change detection threshold
2113  * 0 is default, larger means fewer detected scene changes.
2114  * - encoding: Set by user.
2115  * - decoding: unused
2116  */
2118 
2119  /**
2120  * noise reduction strength
2121  * - encoding: Set by user.
2122  * - decoding: unused
2123  */
2124  int noise_reduction;
2125 
2126 #if FF_API_INTER_THRESHOLD
2127  /**
2128  * @deprecated this field is unused
2129  */
2130  attribute_deprecated int inter_threshold;
2131 #endif
2132 
2133 #if FF_API_MPV_GLOBAL_OPTS
2134  /**
2135  * @deprecated use mpegvideo private options instead
2136  */
2137  attribute_deprecated int quantizer_noise_shaping;
2138 #endif
2139 
2140  /**
2141  * Motion estimation threshold below which no motion estimation is
2142  * performed, but instead the user specified motion vectors are used.
2143  *
2144  * - encoding: Set by user.
2145  * - decoding: unused
2146  */
2147  int me_threshold;
2148 
2149  /**
2150  * Macroblock threshold below which the user specified macroblock types will be used.
2151  * - encoding: Set by user.
2152  * - decoding: unused
2153  */
2154  int mb_threshold;
2155 
2156  /**
2157  * precision of the intra DC coefficient - 8
2158  * - encoding: Set by user.
2159  * - decoding: unused
2160  */
2161  int intra_dc_precision;
2162 
2163  /**
2164  * Number of macroblock rows at the top which are skipped.
2165  * - encoding: unused
2166  * - decoding: Set by user.
2167  */
2168  int skip_top;
2169 
2170  /**
2171  * Number of macroblock rows at the bottom which are skipped.
2172  * - encoding: unused
2173  * - decoding: Set by user.
2174  */
2175  int skip_bottom;
2176 
2177  /**
2178  * Border processing masking, raises the quantizer for mbs on the borders
2179  * of the picture.
2180  * - encoding: Set by user.
2181  * - decoding: unused
2182  */
2183  float border_masking;
2184 
2185  /**
2186  * minimum MB lagrange multipler
2187  * - encoding: Set by user.
2188  * - decoding: unused
2189  */
2190  int mb_lmin;
2191 
2192  /**
2193  * maximum MB lagrange multipler
2194  * - encoding: Set by user.
2195  * - decoding: unused
2196  */
2197  int mb_lmax;
2198 
2199  /**
2200  *
2201  * - encoding: Set by user.
2202  * - decoding: unused
2203  */
2205 
2206  /**
2207  *
2208  * - encoding: Set by user.
2209  * - decoding: unused
2210  */
2211  int bidir_refine;
2212 
2213  /**
2214  *
2215  * - encoding: Set by user.
2216  * - decoding: unused
2217  */
2218  int brd_scale;
2219 
2220  /**
2221  * minimum GOP size
2222  * - encoding: Set by user.
2223  * - decoding: unused
2224  */
2225  int keyint_min;
2226 
2227  /**
2228  * number of reference frames
2229  * - encoding: Set by user.
2230  * - decoding: Set by lavc.
2231  */
2232  int refs;
2233 
2234  /**
2235  * chroma qp offset from luma
2236  * - encoding: Set by user.
2237  * - decoding: unused
2238  */
2239  int chromaoffset;
2240 
2241  /**
2242  * Multiplied by qscale for each frame and added to scene_change_score.
2243  * - encoding: Set by user.
2244  * - decoding: unused
2245  */
2246  int scenechange_factor;
2247 
2248  /**
2249  *
2250  * Note: Value depends upon the compare function used for fullpel ME.
2251  * - encoding: Set by user.
2252  * - decoding: unused
2253  */
2254  int mv0_threshold;
2255 
2256  /**
2257  * Adjust sensitivity of b_frame_strategy 1.
2258  * - encoding: Set by user.
2259  * - decoding: unused
2260  */
2261  int b_sensitivity;
2262 
2263  /**
2264  * Chromaticity coordinates of the source primaries.
2265  * - encoding: Set by user
2266  * - decoding: Set by libavcodec
2267  */
2269 
2270  /**
2271  * Color Transfer Characteristic.
2272  * - encoding: Set by user
2273  * - decoding: Set by libavcodec
2274  */
2276 
2277  /**
2278  * YUV colorspace type.
2279  * - encoding: Set by user
2280  * - decoding: Set by libavcodec
2281  */
2282  enum AVColorSpace colorspace;
2283 
2284  /**
2285  * MPEG vs JPEG YUV range.
2286  * - encoding: Set by user
2287  * - decoding: Set by libavcodec
2288  */
2290 
2291  /**
2292  * This defines the location of chroma samples.
2293  * - encoding: Set by user
2294  * - decoding: Set by libavcodec
2295  */
2297 
2298  /**
2299  * Number of slices.
2300  * Indicates number of picture subdivisions. Used for parallelized
2301  * decoding.
2302  * - encoding: Set by user
2303  * - decoding: unused
2304  */
2305  int slices;
2306 
2307  /** Field order
2308  * - encoding: set by libavcodec
2309  * - decoding: Set by user.
2310  */
2312 
2313  /* audio only */
2314  int sample_rate; ///< samples per second
2315  int channels; ///< number of audio channels
2316 
2317  /**
2318  * audio sample format
2319  * - encoding: Set by user.
2320  * - decoding: Set by libavcodec.
2321  */
2322  enum AVSampleFormat sample_fmt; ///< sample format
2323 
2324  /* The following data should not be initialized. */
2325  /**
2326  * Number of samples per channel in an audio frame.
2327  *
2328  * - encoding: set by libavcodec in avcodec_open2(). Each submitted frame
2329  * except the last must contain exactly frame_size samples per channel.
2330  * May be 0 when the codec has CODEC_CAP_VARIABLE_FRAME_SIZE set, then the
2331  * frame size is not restricted.
2332  * - decoding: may be set by some decoders to indicate constant frame size
2333  */
2334  int frame_size;
2335 
2336  /**
2337  * Frame counter, set by libavcodec.
2338  *
2339  * - decoding: total number of frames returned from the decoder so far.
2340  * - encoding: total number of frames passed to the encoder so far.
2341  *
2342  * @note the counter is not incremented if encoding/decoding resulted in
2343  * an error.
2344  */
2345  int frame_number;
2346 
2347  /**
2348  * number of bytes per packet if constant and known or 0
2349  * Used by some WAV based audio codecs.
2350  */
2351  int block_align;
2352 
2353  /**
2354  * Audio cutoff bandwidth (0 means "automatic")
2355  * - encoding: Set by user.
2356  * - decoding: unused
2357  */
2358  int cutoff;
2359 
2360 #if FF_API_REQUEST_CHANNELS
2361  /**
2362  * Decoder should decode to this many channels if it can (0 for default)
2363  * - encoding: unused
2364  * - decoding: Set by user.
2365  * @deprecated Deprecated in favor of request_channel_layout.
2366  */
2367  int request_channels;
2368 #endif
2369 
2370  /**
2371  * Audio channel layout.
2372  * - encoding: set by user.
2373  * - decoding: set by user, may be overwritten by libavcodec.
2374  */
2375  uint64_t channel_layout;
2376 
2377  /**
2378  * Request decoder to use this channel layout if it can (0 for default)
2379  * - encoding: unused
2380  * - decoding: Set by user.
2381  */
2382  uint64_t request_channel_layout;
2383 
2384  /**
2385  * Type of service that the audio stream conveys.
2386  * - encoding: Set by user.
2387  * - decoding: Set by libavcodec.
2388  */
2390 
2391  /**
2392  * desired sample format
2393  * - encoding: Not used.
2394  * - decoding: Set by user.
2395  * Decoder will decode to this format if it can.
2396  */
2398 
2399  /**
2400  * Called at the beginning of each frame to get a buffer for it.
2401  *
2402  * The function will set AVFrame.data[], AVFrame.linesize[].
2403  * AVFrame.extended_data[] must also be set, but it should be the same as
2404  * AVFrame.data[] except for planar audio with more channels than can fit
2405  * in AVFrame.data[]. In that case, AVFrame.data[] shall still contain as
2406  * many data pointers as it can hold.
2407  *
2408  * if CODEC_CAP_DR1 is not set then get_buffer() must call
2409  * avcodec_default_get_buffer() instead of providing buffers allocated by
2410  * some other means.
2411  *
2412  * AVFrame.data[] should be 32- or 16-byte-aligned unless the CPU doesn't
2413  * need it. avcodec_default_get_buffer() aligns the output buffer properly,
2414  * but if get_buffer() is overridden then alignment considerations should
2415  * be taken into account.
2416  *
2417  * @see avcodec_default_get_buffer()
2418  *
2419  * Video:
2420  *
2421  * If pic.reference is set then the frame will be read later by libavcodec.
2422  * avcodec_align_dimensions2() should be used to find the required width and
2423  * height, as they normally need to be rounded up to the next multiple of 16.
2424  *
2425  * If frame multithreading is used and thread_safe_callbacks is set,
2426  * it may be called from a different thread, but not from more than one at
2427  * once. Does not need to be reentrant.
2428  *
2429  * @see release_buffer(), reget_buffer()
2430  * @see avcodec_align_dimensions2()
2431  *
2432  * Audio:
2433  *
2434  * Decoders request a buffer of a particular size by setting
2435  * AVFrame.nb_samples prior to calling get_buffer(). The decoder may,
2436  * however, utilize only part of the buffer by setting AVFrame.nb_samples
2437  * to a smaller value in the output frame.
2438  *
2439  * Decoders cannot use the buffer after returning from
2440  * avcodec_decode_audio4(), so they will not call release_buffer(), as it
2441  * is assumed to be released immediately upon return. In some rare cases,
2442  * a decoder may need to call get_buffer() more than once in a single
2443  * call to avcodec_decode_audio4(). In that case, when get_buffer() is
2444  * called again after it has already been called once, the previously
2445  * acquired buffer is assumed to be released at that time and may not be
2446  * reused by the decoder.
2447  *
2448  * As a convenience, av_samples_get_buffer_size() and
2449  * av_samples_fill_arrays() in libavutil may be used by custom get_buffer()
2450  * functions to find the required data size and to fill data pointers and
2451  * linesize. In AVFrame.linesize, only linesize[0] may be set for audio
2452  * since all planes must be the same size.
2453  *
2454  * @see av_samples_get_buffer_size(), av_samples_fill_arrays()
2455  *
2456  * - encoding: unused
2457  * - decoding: Set by libavcodec, user can override.
2458  */
2459  int (*get_buffer)(struct AVCodecContext *c, AVFrame *pic);
2460 
2461  /**
2462  * Called to release buffers which were allocated with get_buffer.
2463  * A released buffer can be reused in get_buffer().
2464  * pic.data[*] must be set to NULL.
2465  * May be called from a different thread if frame multithreading is used,
2466  * but not by more than one thread at once, so does not need to be reentrant.
2467  * - encoding: unused
2468  * - decoding: Set by libavcodec, user can override.
2469  */
2470  void (*release_buffer)(struct AVCodecContext *c, AVFrame *pic);
2471 
2472  /**
2473  * Called at the beginning of a frame to get cr buffer for it.
2474  * Buffer type (size, hints) must be the same. libavcodec won't check it.
2475  * libavcodec will pass previous buffer in pic, function should return
2476  * same buffer or new buffer with old frame "painted" into it.
2477  * If pic.data[0] == NULL must behave like get_buffer().
2478  * if CODEC_CAP_DR1 is not set then reget_buffer() must call
2479  * avcodec_default_reget_buffer() instead of providing buffers allocated by
2480  * some other means.
2481  * - encoding: unused
2482  * - decoding: Set by libavcodec, user can override.
2483  */
2484  int (*reget_buffer)(struct AVCodecContext *c, AVFrame *pic);
2485 
2486 
2487  /* - encoding parameters */
2488  float qcompress; ///< amount of qscale change between easy & hard scenes (0.0-1.0)
2489  float qblur; ///< amount of qscale smoothing over time (0.0-1.0)
2490 
2491  /**
2492  * minimum quantizer
2493  * - encoding: Set by user.
2494  * - decoding: unused
2495  */
2496  int qmin;
2497 
2498  /**
2499  * maximum quantizer
2500  * - encoding: Set by user.
2501  * - decoding: unused
2502  */
2503  int qmax;
2504 
2505  /**
2506  * maximum quantizer difference between frames
2507  * - encoding: Set by user.
2508  * - decoding: unused
2509  */
2510  int max_qdiff;
2511 
2512  /**
2513  * ratecontrol qmin qmax limiting method
2514  * 0-> clipping, 1-> use a nice continuous function to limit qscale wthin qmin/qmax.
2515  * - encoding: Set by user.
2516  * - decoding: unused
2517  */
2518  float rc_qsquish;
2521  int rc_qmod_freq;
2522 
2523  /**
2524  * decoder bitstream buffer size
2525  * - encoding: Set by user.
2526  * - decoding: unused
2527  */
2528  int rc_buffer_size;
2529 
2530  /**
2531  * ratecontrol override, see RcOverride
2532  * - encoding: Allocated/set/freed by user.
2533  * - decoding: unused
2534  */
2537 
2538  /**
2539  * rate control equation
2540  * - encoding: Set by user
2541  * - decoding: unused
2542  */
2543  const char *rc_eq;
2544 
2545  /**
2546  * maximum bitrate
2547  * - encoding: Set by user.
2548  * - decoding: unused
2549  */
2550  int rc_max_rate;
2551 
2552  /**
2553  * minimum bitrate
2554  * - encoding: Set by user.
2555  * - decoding: unused
2556  */
2557  int rc_min_rate;
2559  float rc_buffer_aggressivity;
2560 
2561  /**
2562  * initial complexity for pass1 ratecontrol
2563  * - encoding: Set by user.
2564  * - decoding: unused
2565  */
2566  float rc_initial_cplx;
2567 
2568  /**
2569  * Ratecontrol attempt to use, at maximum, <value> of what can be used without an underflow.
2570  * - encoding: Set by user.
2571  * - decoding: unused.
2572  */
2574 
2575  /**
2576  * Ratecontrol attempt to use, at least, <value> times the amount needed to prevent a vbv overflow.
2577  * - encoding: Set by user.
2578  * - decoding: unused.
2579  */
2581 
2582  /**
2583  * Number of bits which should be loaded into the rc buffer before decoding starts.
2584  * - encoding: Set by user.
2585  * - decoding: unused
2586  */
2589 #define FF_CODER_TYPE_VLC 0
2590 #define FF_CODER_TYPE_AC 1
2591 #define FF_CODER_TYPE_RAW 2
2592 #define FF_CODER_TYPE_RLE 3
2593 #define FF_CODER_TYPE_DEFLATE 4
2594  /**
2595  * coder type
2596  * - encoding: Set by user.
2597  * - decoding: unused
2598  */
2599  int coder_type;
2600 
2601  /**
2602  * context model
2603  * - encoding: Set by user.
2604  * - decoding: unused
2605  */
2606  int context_model;
2607 
2608  /**
2609  * minimum Lagrange multipler
2610  * - encoding: Set by user.
2611  * - decoding: unused
2612  */
2613  int lmin;
2614 
2615  /**
2616  * maximum Lagrange multipler
2617  * - encoding: Set by user.
2618  * - decoding: unused
2619  */
2620  int lmax;
2621 
2622  /**
2623  * frame skip threshold
2624  * - encoding: Set by user.
2625  * - decoding: unused
2626  */
2628 
2629  /**
2630  * frame skip factor
2631  * - encoding: Set by user.
2632  * - decoding: unused
2633  */
2634  int frame_skip_factor;
2635 
2636  /**
2637  * frame skip exponent
2638  * - encoding: Set by user.
2639  * - decoding: unused
2640  */
2641  int frame_skip_exp;
2642 
2643  /**
2644  * frame skip comparison function
2645  * - encoding: Set by user.
2646  * - decoding: unused
2647  */
2648  int frame_skip_cmp;
2649 
2650  /**
2651  * trellis RD quantization
2652  * - encoding: Set by user.
2653  * - decoding: unused
2654  */
2655  int trellis;
2656 
2657  /**
2658  * - encoding: Set by user.
2659  * - decoding: unused
2660  */
2662 
2663  /**
2664  * - encoding: Set by user.
2665  * - decoding: unused
2666  */
2668 
2669  /**
2670  * GOP timecode frame start number
2671  * - encoding: Set by user, in non drop frame format
2672  * - decoding: Set by libavcodec (timecode in the 25 bits format, -1 if unset)
2673  */
2674  int64_t timecode_frame_start;
2675 
2676  /* The RTP callback: This function is called */
2677  /* every time the encoder has a packet to send. */
2678  /* It depends on the encoder if the data starts */
2679  /* with a Start Code (it should). H.263 does. */
2680  /* mb_nb contains the number of macroblocks */
2681  /* encoded in the RTP payload. */
2682  void (*rtp_callback)(struct AVCodecContext *avctx, void *data, int size, int mb_nb);
2684  int rtp_payload_size; /* The size of the RTP payload: the coder will */
2685  /* do its best to deliver a chunk with size */
2686  /* below rtp_payload_size, the chunk will start */
2687  /* with a start code on some codecs like H.263. */
2688  /* This doesn't take account of any particular */
2689  /* headers inside the transmitted RTP payload. */
2690 
2691  /* statistics, used for 2-pass encoding */
2692  int mv_bits;
2696  int i_count;
2697  int p_count;
2699  int misc_bits;
2700 
2701  /**
2702  * number of bits used for the previously encoded frame
2703  * - encoding: Set by libavcodec.
2704  * - decoding: unused
2705  */
2706  int frame_bits;
2707 
2708  /**
2709  * pass1 encoding statistics output buffer
2710  * - encoding: Set by libavcodec.
2711  * - decoding: unused
2712  */
2713  char *stats_out;
2714 
2715  /**
2716  * pass2 encoding statistics input buffer
2717  * Concatenated stuff from stats_out of pass1 should be placed here.
2718  * - encoding: Allocated/set/freed by user.
2719  * - decoding: unused
2720  */
2721  char *stats_in;
2722 
2723  /**
2724  * Work around bugs in encoders which sometimes cannot be detected automatically.
2725  * - encoding: Set by user
2726  * - decoding: Set by user
2727  */
2729 #define FF_BUG_AUTODETECT 1 ///< autodetection
2730 #define FF_BUG_OLD_MSMPEG4 2
2731 #define FF_BUG_XVID_ILACE 4
2732 #define FF_BUG_UMP4 8
2733 #define FF_BUG_NO_PADDING 16
2734 #define FF_BUG_AMV 32
2735 #define FF_BUG_AC_VLC 0 ///< Will be removed, libavcodec can now handle these non-compliant files by default.
2736 #define FF_BUG_QPEL_CHROMA 64
2737 #define FF_BUG_STD_QPEL 128
2738 #define FF_BUG_QPEL_CHROMA2 256
2739 #define FF_BUG_DIRECT_BLOCKSIZE 512
2740 #define FF_BUG_EDGE 1024
2741 #define FF_BUG_HPEL_CHROMA 2048
2742 #define FF_BUG_DC_CLIP 4096
2743 #define FF_BUG_MS 8192 ///< Work around various bugs in Microsoft's broken decoders.
2744 #define FF_BUG_TRUNCATED 16384
2745 
2746  /**
2747  * strictly follow the standard (MPEG4, ...).
2748  * - encoding: Set by user.
2749  * - decoding: Set by user.
2750  * Setting this to STRICT or higher means the encoder and decoder will
2751  * generally do stupid things, whereas setting it to unofficial or lower
2752  * will mean the encoder might produce output that is not supported by all
2753  * spec-compliant decoders. Decoders don't differentiate between normal,
2754  * unofficial and experimental (that is, they always try to decode things
2755  * when they can) unless they are explicitly asked to behave stupidly
2756  * (=strictly conform to the specs)
2757  */
2759 #define FF_COMPLIANCE_VERY_STRICT 2 ///< Strictly conform to an older more strict version of the spec or reference software.
2760 #define FF_COMPLIANCE_STRICT 1 ///< Strictly conform to all the things in the spec no matter what consequences.
2761 #define FF_COMPLIANCE_NORMAL 0
2762 #define FF_COMPLIANCE_UNOFFICIAL -1 ///< Allow unofficial extensions
2763 #define FF_COMPLIANCE_EXPERIMENTAL -2 ///< Allow nonstandardized experimental things.
2764 
2765  /**
2766  * error concealment flags
2767  * - encoding: unused
2768  * - decoding: Set by user.
2769  */
2771 #define FF_EC_GUESS_MVS 1
2772 #define FF_EC_DEBLOCK 2
2773 
2774  /**
2775  * debug
2776  * - encoding: Set by user.
2777  * - decoding: Set by user.
2778  */
2779  int debug;
2780 #define FF_DEBUG_PICT_INFO 1
2781 #define FF_DEBUG_RC 2
2782 #define FF_DEBUG_BITSTREAM 4
2783 #define FF_DEBUG_MB_TYPE 8
2784 #define FF_DEBUG_QP 16
2785 #define FF_DEBUG_MV 32
2786 #define FF_DEBUG_DCT_COEFF 0x00000040
2787 #define FF_DEBUG_SKIP 0x00000080
2788 #define FF_DEBUG_STARTCODE 0x00000100
2789 #define FF_DEBUG_PTS 0x00000200
2790 #define FF_DEBUG_ER 0x00000400
2791 #define FF_DEBUG_MMCO 0x00000800
2792 #define FF_DEBUG_BUGS 0x00001000
2793 #define FF_DEBUG_VIS_QP 0x00002000
2794 #define FF_DEBUG_VIS_MB_TYPE 0x00004000
2795 #define FF_DEBUG_BUFFERS 0x00008000
2796 #define FF_DEBUG_THREADS 0x00010000
2797 
2798  /**
2799  * debug
2800  * - encoding: Set by user.
2801  * - decoding: Set by user.
2802  */
2804 #define FF_DEBUG_VIS_MV_P_FOR 0x00000001 //visualize forward predicted MVs of P frames
2805 #define FF_DEBUG_VIS_MV_B_FOR 0x00000002 //visualize forward predicted MVs of B frames
2806 #define FF_DEBUG_VIS_MV_B_BACK 0x00000004 //visualize backward predicted MVs of B frames
2807 
2808  /**
2809  * Error recognition; may misdetect some more or less valid parts as errors.
2810  * - encoding: unused
2811  * - decoding: Set by user.
2812  */
2814 #define AV_EF_CRCCHECK (1<<0)
2815 #define AV_EF_BITSTREAM (1<<1)
2816 #define AV_EF_BUFFER (1<<2)
2817 #define AV_EF_EXPLODE (1<<3)
2819 #define AV_EF_CAREFUL (1<<16)
2820 #define AV_EF_COMPLIANT (1<<17)
2821 #define AV_EF_AGGRESSIVE (1<<18)
2822 
2823 
2824  /**
2825  * opaque 64bit number (generally a PTS) that will be reordered and
2826  * output in AVFrame.reordered_opaque
2827  * @deprecated in favor of pkt_pts
2828  * - encoding: unused
2829  * - decoding: Set by user.
2830  */
2831  int64_t reordered_opaque;
2832 
2833  /**
2834  * Hardware accelerator in use
2835  * - encoding: unused.
2836  * - decoding: Set by libavcodec
2837  */
2838  struct AVHWAccel *hwaccel;
2839 
2840  /**
2841  * Hardware accelerator context.
2842  * For some hardware accelerators, a global context needs to be
2843  * provided by the user. In that case, this holds display-dependent
2844  * data FFmpeg cannot instantiate itself. Please refer to the
2845  * FFmpeg HW accelerator documentation to know how to fill this
2846  * is. e.g. for VA API, this is a struct vaapi_context.
2847  * - encoding: unused
2848  * - decoding: Set by user
2849  */
2850  void *hwaccel_context;
2851 
2852  /**
2853  * error
2854  * - encoding: Set by libavcodec if flags&CODEC_FLAG_PSNR.
2855  * - decoding: unused
2856  */
2857  uint64_t error[AV_NUM_DATA_POINTERS];
2858 
2859  /**
2860  * DCT algorithm, see FF_DCT_* below
2861  * - encoding: Set by user.
2862  * - decoding: unused
2863  */
2865 #define FF_DCT_AUTO 0
2866 #define FF_DCT_FASTINT 1
2867 #define FF_DCT_INT 2
2868 #define FF_DCT_MMX 3
2869 #define FF_DCT_ALTIVEC 5
2870 #define FF_DCT_FAAN 6
2871 
2872  /**
2873  * IDCT algorithm, see FF_IDCT_* below.
2874  * - encoding: Set by user.
2875  * - decoding: Set by user.
2876  */
2878 #define FF_IDCT_AUTO 0
2879 #define FF_IDCT_INT 1
2880 #define FF_IDCT_SIMPLE 2
2881 #define FF_IDCT_SIMPLEMMX 3
2882 #define FF_IDCT_LIBMPEG2MMX 4
2883 #if FF_API_MMI
2884 #define FF_IDCT_MMI 5
2885 #endif
2886 #define FF_IDCT_ARM 7
2887 #define FF_IDCT_ALTIVEC 8
2888 #define FF_IDCT_SH4 9
2889 #define FF_IDCT_SIMPLEARM 10
2890 #define FF_IDCT_H264 11
2891 #define FF_IDCT_VP3 12
2892 #define FF_IDCT_IPP 13
2893 #define FF_IDCT_XVIDMMX 14
2894 #define FF_IDCT_CAVS 15
2895 #define FF_IDCT_SIMPLEARMV5TE 16
2896 #define FF_IDCT_SIMPLEARMV6 17
2897 #define FF_IDCT_SIMPLEVIS 18
2898 #define FF_IDCT_WMV2 19
2899 #define FF_IDCT_FAAN 20
2900 #define FF_IDCT_EA 21
2901 #define FF_IDCT_SIMPLENEON 22
2902 #define FF_IDCT_SIMPLEALPHA 23
2903 #define FF_IDCT_BINK 24
2904 
2905 #if FF_API_DSP_MASK
2906  /**
2907  * Unused.
2908  * @deprecated use av_set_cpu_flags_mask() instead.
2909  */
2910  attribute_deprecated unsigned dsp_mask;
2911 #endif
2912 
2913  /**
2914  * bits per sample/pixel from the demuxer (needed for huffyuv).
2915  * - encoding: Set by libavcodec.
2916  * - decoding: Set by user.
2917  */
2919 
2920  /**
2921  * Bits per sample/pixel of internal libavcodec pixel/sample format.
2922  * - encoding: set by user.
2923  * - decoding: set by libavcodec.
2924  */
2925  int bits_per_raw_sample;
2926 
2927  /**
2928  * low resolution decoding, 1-> 1/2 size, 2->1/4 size
2929  * - encoding: unused
2930  * - decoding: Set by user.
2931  */
2932  int lowres;
2933 
2934  /**
2935  * the picture in the bitstream
2936  * - encoding: Set by libavcodec.
2937  * - decoding: Set by libavcodec.
2938  */
2940 
2941  /**
2942  * thread count
2943  * is used to decide how many independent tasks should be passed to execute()
2944  * - encoding: Set by user.
2945  * - decoding: Set by user.
2946  */
2947  int thread_count;
2948 
2949  /**
2950  * Which multithreading methods to use.
2951  * Use of FF_THREAD_FRAME will increase decoding delay by one frame per thread,
2952  * so clients which cannot provide future frames should not use it.
2953  *
2954  * - encoding: Set by user, otherwise the default is used.
2955  * - decoding: Set by user, otherwise the default is used.
2956  */
2958 #define FF_THREAD_FRAME 1 ///< Decode more than one frame at once
2959 #define FF_THREAD_SLICE 2 ///< Decode more than one part of a single frame at once
2960 
2961  /**
2962  * Which multithreading methods are in use by the codec.
2963  * - encoding: Set by libavcodec.
2964  * - decoding: Set by libavcodec.
2965  */
2966  int active_thread_type;
2967 
2968  /**
2969  * Set by the client if its custom get_buffer() callback can be called
2970  * synchronously from another thread, which allows faster multithreaded decoding.
2971  * draw_horiz_band() will be called from other threads regardless of this setting.
2972  * Ignored if the default get_buffer() is used.
2973  * - encoding: Set by user.
2974  * - decoding: Set by user.
2975  */
2977 
2978  /**
2979  * The codec may call this to execute several independent things.
2980  * It will return only after finishing all tasks.
2981  * The user may replace this with some multithreaded implementation,
2982  * the default implementation will execute the parts serially.
2983  * @param count the number of things to execute
2984  * - encoding: Set by libavcodec, user can override.
2985  * - decoding: Set by libavcodec, user can override.
2986  */
2987  int (*execute)(struct AVCodecContext *c, int (*func)(struct AVCodecContext *c2, void *arg), void *arg2, int *ret, int count, int size);
2988 
2989  /**
2990  * The codec may call this to execute several independent things.
2991  * It will return only after finishing all tasks.
2992  * The user may replace this with some multithreaded implementation,
2993  * the default implementation will execute the parts serially.
2994  * Also see avcodec_thread_init and e.g. the --enable-pthread configure option.
2995  * @param c context passed also to func
2996  * @param count the number of things to execute
2997  * @param arg2 argument passed unchanged to func
2998  * @param ret return values of executed functions, must have space for "count" values. May be NULL.
2999  * @param func function that will be called count times, with jobnr from 0 to count-1.
3000  * threadnr will be in the range 0 to c->thread_count-1 < MAX_THREADS and so that no
3001  * two instances of func executing at the same time will have the same threadnr.
3002  * @return always 0 currently, but code should handle a future improvement where when any call to func
3003  * returns < 0 no further calls to func may be done and < 0 is returned.
3004  * - encoding: Set by libavcodec, user can override.
3005  * - decoding: Set by libavcodec, user can override.
3006  */
3007  int (*execute2)(struct AVCodecContext *c, int (*func)(struct AVCodecContext *c2, void *arg, int jobnr, int threadnr), void *arg2, int *ret, int count);
3008 
3009  /**
3010  * thread opaque
3011  * Can be used by execute() to store some per AVCodecContext stuff.
3012  * - encoding: set by execute()
3013  * - decoding: set by execute()
3014  */
3015  void *thread_opaque;
3016 
3017  /**
3018  * noise vs. sse weight for the nsse comparsion function
3019  * - encoding: Set by user.
3020  * - decoding: unused
3021  */
3022  int nsse_weight;
3023 
3024  /**
3025  * profile
3026  * - encoding: Set by user.
3027  * - decoding: Set by libavcodec.
3028  */
3029  int profile;
3030 #define FF_PROFILE_UNKNOWN -99
3031 #define FF_PROFILE_RESERVED -100
3033 #define FF_PROFILE_AAC_MAIN 0
3034 #define FF_PROFILE_AAC_LOW 1
3035 #define FF_PROFILE_AAC_SSR 2
3036 #define FF_PROFILE_AAC_LTP 3
3037 #define FF_PROFILE_AAC_HE 4
3038 #define FF_PROFILE_AAC_HE_V2 28
3039 #define FF_PROFILE_AAC_LD 22
3040 #define FF_PROFILE_AAC_ELD 38
3042 #define FF_PROFILE_DTS 20
3043 #define FF_PROFILE_DTS_ES 30
3044 #define FF_PROFILE_DTS_96_24 40
3045 #define FF_PROFILE_DTS_HD_HRA 50
3046 #define FF_PROFILE_DTS_HD_MA 60
3048 #define FF_PROFILE_MPEG2_422 0
3049 #define FF_PROFILE_MPEG2_HIGH 1
3050 #define FF_PROFILE_MPEG2_SS 2
3051 #define FF_PROFILE_MPEG2_SNR_SCALABLE 3
3052 #define FF_PROFILE_MPEG2_MAIN 4
3053 #define FF_PROFILE_MPEG2_SIMPLE 5
3055 #define FF_PROFILE_H264_CONSTRAINED (1<<9) // 8+1; constraint_set1_flag
3056 #define FF_PROFILE_H264_INTRA (1<<11) // 8+3; constraint_set3_flag
3058 #define FF_PROFILE_H264_BASELINE 66
3059 #define FF_PROFILE_H264_CONSTRAINED_BASELINE (66|FF_PROFILE_H264_CONSTRAINED)
3060 #define FF_PROFILE_H264_MAIN 77
3061 #define FF_PROFILE_H264_EXTENDED 88
3062 #define FF_PROFILE_H264_HIGH 100
3063 #define FF_PROFILE_H264_HIGH_10 110
3064 #define FF_PROFILE_H264_HIGH_10_INTRA (110|FF_PROFILE_H264_INTRA)
3065 #define FF_PROFILE_H264_HIGH_422 122
3066 #define FF_PROFILE_H264_HIGH_422_INTRA (122|FF_PROFILE_H264_INTRA)
3067 #define FF_PROFILE_H264_HIGH_444 144
3068 #define FF_PROFILE_H264_HIGH_444_PREDICTIVE 244
3069 #define FF_PROFILE_H264_HIGH_444_INTRA (244|FF_PROFILE_H264_INTRA)
3070 #define FF_PROFILE_H264_CAVLC_444 44
3072 #define FF_PROFILE_VC1_SIMPLE 0
3073 #define FF_PROFILE_VC1_MAIN 1
3074 #define FF_PROFILE_VC1_COMPLEX 2
3075 #define FF_PROFILE_VC1_ADVANCED 3
3077 #define FF_PROFILE_MPEG4_SIMPLE 0
3078 #define FF_PROFILE_MPEG4_SIMPLE_SCALABLE 1
3079 #define FF_PROFILE_MPEG4_CORE 2
3080 #define FF_PROFILE_MPEG4_MAIN 3
3081 #define FF_PROFILE_MPEG4_N_BIT 4
3082 #define FF_PROFILE_MPEG4_SCALABLE_TEXTURE 5
3083 #define FF_PROFILE_MPEG4_SIMPLE_FACE_ANIMATION 6
3084 #define FF_PROFILE_MPEG4_BASIC_ANIMATED_TEXTURE 7
3085 #define FF_PROFILE_MPEG4_HYBRID 8
3086 #define FF_PROFILE_MPEG4_ADVANCED_REAL_TIME 9
3087 #define FF_PROFILE_MPEG4_CORE_SCALABLE 10
3088 #define FF_PROFILE_MPEG4_ADVANCED_CODING 11
3089 #define FF_PROFILE_MPEG4_ADVANCED_CORE 12
3090 #define FF_PROFILE_MPEG4_ADVANCED_SCALABLE_TEXTURE 13
3091 #define FF_PROFILE_MPEG4_SIMPLE_STUDIO 14
3092 #define FF_PROFILE_MPEG4_ADVANCED_SIMPLE 15
3093 
3094  /**
3095  * level
3096  * - encoding: Set by user.
3097  * - decoding: Set by libavcodec.
3098  */
3099  int level;
3100 #define FF_LEVEL_UNKNOWN -99
3101 
3102  /**
3103  *
3104  * - encoding: unused
3105  * - decoding: Set by user.
3106  */
3108 
3109  /**
3110  *
3111  * - encoding: unused
3112  * - decoding: Set by user.
3113  */
3114  enum AVDiscard skip_idct;
3115 
3116  /**
3117  *
3118  * - encoding: unused
3119  * - decoding: Set by user.
3120  */
3121  enum AVDiscard skip_frame;
3122 
3123  /**
3124  * Header containing style information for text subtitles.
3125  * For SUBTITLE_ASS subtitle type, it should contain the whole ASS
3126  * [Script Info] and [V4+ Styles] section, plus the [Events] line and
3127  * the Format line following. It shouldn't include any Dialogue line.
3128  * - encoding: Set/allocated/freed by user (before avcodec_open2())
3129  * - decoding: Set/allocated/freed by libavcodec (by avcodec_open2())
3130  */
3133 
3134  /**
3135  * Simulates errors in the bitstream to test error concealment.
3136  * - encoding: Set by user.
3137  * - decoding: unused
3138  */
3139  int error_rate;
3140 
3141  /**
3142  * Current packet as passed into the decoder, to avoid having
3143  * to pass the packet into every function. Currently only valid
3144  * inside lavc and get/release_buffer callbacks.
3145  * - decoding: set by avcodec_decode_*, read by get_buffer() for setting pkt_pts
3146  * - encoding: unused
3147  */
3148  AVPacket *pkt;
3149 
3150  /**
3151  * VBV delay coded in the last frame (in periods of a 27 MHz clock).
3152  * Used for compliant TS muxing.
3153  * - encoding: Set by libavcodec.
3154  * - decoding: unused.
3155  */
3156  uint64_t vbv_delay;
3157 
3158  /**
3159  * Timebase in which pkt_dts/pts and AVPacket.dts/pts are.
3160  * Code outside libavcodec should access this field using:
3161  * avcodec_set_pkt_timebase(avctx)
3162  * - encoding unused.
3163  * - decodimg set by user
3164  */
3166 
3167  /**
3168  * AVCodecDescriptor
3169  * Code outside libavcodec should access this field using:
3170  * avcodec_get_codec_descriptior(avctx)
3171  * - encoding: unused.
3172  * - decoding: set by libavcodec.
3173  */
3175 
3176  /**
3177  * Current statistics for PTS correction.
3178  * - decoding: maintained and used by libavcodec, not intended to be used by user apps
3179  * - encoding: unused
3180  */
3181  int64_t pts_correction_num_faulty_pts; /// Number of incorrect PTS values so far
3182  int64_t pts_correction_num_faulty_dts; /// Number of incorrect DTS values so far
3183  int64_t pts_correction_last_pts; /// PTS of the last frame
3184  int64_t pts_correction_last_dts; /// DTS of the last frame
3185 
3186  /**
3187  * Current frame metadata.
3188  * - decoding: maintained and used by libavcodec, not intended to be used by user apps
3189  * - encoding: unused
3190  */
3192 } AVCodecContext;
3193 
3196 
3199 
3200 /**
3201  * AVProfile.
3202  */
3203 typedef struct AVProfile {
3204  int profile;
3205  const char *name; ///< short name for the profile
3206 } AVProfile;
3207 
3208 typedef struct AVCodecDefault AVCodecDefault;
3209 
3210 struct AVSubtitle;
3211 
3212 /**
3213  * AVCodec.
3214  */
3215 typedef struct AVCodec {
3216  /**
3217  * Name of the codec implementation.
3218  * The name is globally unique among encoders and among decoders (but an
3219  * encoder and a decoder can share the same name).
3220  * This is the primary way to find a codec from the user perspective.
3221  */
3222  const char *name;
3223  /**
3224  * Descriptive name for the codec, meant to be more human readable than name.
3225  * You should use the NULL_IF_CONFIG_SMALL() macro to define it.
3226  */
3227  const char *long_name;
3229  enum AVCodecID id;
3230  /**
3231  * Codec capabilities.
3232  * see CODEC_CAP_*
3233  */
3235  const AVRational *supported_framerates; ///< array of supported framerates, or NULL if any, array is terminated by {0,0}
3236  const enum AVPixelFormat *pix_fmts; ///< array of supported pixel formats, or NULL if unknown, array is terminated by -1
3237  const int *supported_samplerates; ///< array of supported audio samplerates, or NULL if unknown, array is terminated by 0
3238  const enum AVSampleFormat *sample_fmts; ///< array of supported sample formats, or NULL if unknown, array is terminated by -1
3239  const uint64_t *channel_layouts; ///< array of support channel layouts, or NULL if unknown. array is terminated by 0
3240  uint8_t max_lowres; ///< maximum value for lowres supported by the decoder
3241  const AVClass *priv_class; ///< AVClass for the private context
3242  const AVProfile *profiles; ///< array of recognized profiles, or NULL if unknown, array is terminated by {FF_PROFILE_UNKNOWN}
3243 
3244  /*****************************************************************
3245  * No fields below this line are part of the public API. They
3246  * may not be used outside of libavcodec and can be changed and
3247  * removed at will.
3248  * New public fields should be added right above.
3249  *****************************************************************
3250  */
3252  struct AVCodec *next;
3253  /**
3254  * @name Frame-level threading support functions
3255  * @{
3256  */
3257  /**
3258  * If defined, called on thread contexts when they are created.
3259  * If the codec allocates writable tables in init(), re-allocate them here.
3260  * priv_data will be set to a copy of the original.
3261  */
3262  int (*init_thread_copy)(AVCodecContext *);
3263  /**
3264  * Copy necessary context variables from a previous thread context to the current one.
3265  * If not defined, the next thread will start automatically; otherwise, the codec
3266  * must call ff_thread_finish_setup().
3267  *
3268  * dst and src will (rarely) point to the same context, in which case memcpy should be skipped.
3269  */
3271  /** @} */
3272 
3273  /**
3274  * Private codec-specific defaults.
3275  */
3276  const AVCodecDefault *defaults;
3277 
3278  /**
3279  * Initialize codec static data, called from avcodec_register().
3280  */
3281  void (*init_static_data)(struct AVCodec *codec);
3284  int (*encode_sub)(AVCodecContext *, uint8_t *buf, int buf_size,
3285  const struct AVSubtitle *sub);
3286  /**
3287  * Encode data to an AVPacket.
3288  *
3289  * @param avctx codec context
3290  * @param avpkt output AVPacket (may contain a user-provided buffer)
3291  * @param[in] frame AVFrame containing the raw data to be encoded
3292  * @param[out] got_packet_ptr encoder sets to 0 or 1 to indicate that a
3293  * non-empty packet was returned in avpkt.
3294  * @return 0 on success, negative error code on failure
3295  */
3296  int (*encode2)(AVCodecContext *avctx, AVPacket *avpkt, const AVFrame *frame,
3297  int *got_packet_ptr);
3298  int (*decode)(AVCodecContext *, void *outdata, int *outdata_size, AVPacket *avpkt);
3299  int (*close)(AVCodecContext *);
3300  /**
3301  * Flush buffers.
3302  * Will be called when seeking
3303  */
3304  void (*flush)(AVCodecContext *);
3305 } AVCodec;
3306 
3307 /**
3308  * AVHWAccel.
3309  */
3310 typedef struct AVHWAccel {
3311  /**
3312  * Name of the hardware accelerated codec.
3313  * The name is globally unique among encoders and among decoders (but an
3314  * encoder and a decoder can share the same name).
3315  */
3316  const char *name;
3317 
3318  /**
3319  * Type of codec implemented by the hardware accelerator.
3320  *
3321  * See AVMEDIA_TYPE_xxx
3322  */
3323  enum AVMediaType type;
3324 
3325  /**
3326  * Codec implemented by the hardware accelerator.
3327  *
3328  * See AV_CODEC_ID_xxx
3329  */
3330  enum AVCodecID id;
3331 
3332  /**
3333  * Supported pixel format.
3334  *
3335  * Only hardware accelerated formats are supported here.
3336  */
3337  enum AVPixelFormat pix_fmt;
3338 
3339  /**
3340  * Hardware accelerated codec capabilities.
3341  * see FF_HWACCEL_CODEC_CAP_*
3342  */
3343  int capabilities;
3345  struct AVHWAccel *next;
3346 
3347  /**
3348  * Called at the beginning of each frame or field picture.
3349  *
3350  * Meaningful frame information (codec specific) is guaranteed to
3351  * be parsed at this point. This function is mandatory.
3352  *
3353  * Note that buf can be NULL along with buf_size set to 0.
3354  * Otherwise, this means the whole frame is available at this point.
3355  *
3356  * @param avctx the codec context
3357  * @param buf the frame data buffer base
3358  * @param buf_size the size of the frame in bytes
3359  * @return zero if successful, a negative value otherwise
3360  */
3361  int (*start_frame)(AVCodecContext *avctx, const uint8_t *buf, uint32_t buf_size);
3362 
3363  /**
3364  * Callback for each slice.
3365  *
3366  * Meaningful slice information (codec specific) is guaranteed to
3367  * be parsed at this point. This function is mandatory.
3368  *
3369  * @param avctx the codec context
3370  * @param buf the slice data buffer base
3371  * @param buf_size the size of the slice in bytes
3372  * @return zero if successful, a negative value otherwise
3373  */
3374  int (*decode_slice)(AVCodecContext *avctx, const uint8_t *buf, uint32_t buf_size);
3375 
3376  /**
3377  * Called at the end of each frame or field picture.
3378  *
3379  * The whole picture is parsed at this point and can now be sent
3380  * to the hardware accelerator. This function is mandatory.
3381  *
3382  * @param avctx the codec context
3383  * @return zero if successful, a negative value otherwise
3384  */
3385  int (*end_frame)(AVCodecContext *avctx);
3386 
3387  /**
3388  * Size of HW accelerator private data.
3389  *
3390  * Private data is allocated with av_mallocz() before
3391  * AVCodecContext.get_buffer() and deallocated after
3392  * AVCodecContext.release_buffer().
3393  */
3394  int priv_data_size;
3395 } AVHWAccel;
3396 
3397 /**
3398  * @defgroup lavc_picture AVPicture
3399  *
3400  * Functions for working with AVPicture
3401  * @{
3402  */
3403 
3404 /**
3405  * four components are given, that's all.
3406  * the last component is alpha
3407  */
3408 typedef struct AVPicture {
3410  int linesize[AV_NUM_DATA_POINTERS]; ///< number of bytes per line
3411 } AVPicture;
3412 
3413 /**
3414  * @}
3415  */
3418  SUBTITLE_NONE,
3420  SUBTITLE_BITMAP, ///< A bitmap, pict will be set
3421 
3422  /**
3423  * Plain text, the text field must be set by the decoder and is
3424  * authoritative. ass and pict fields may contain approximations.
3425  */
3426  SUBTITLE_TEXT,
3427 
3428  /**
3429  * Formatted text, the ass field must be set by the decoder and is
3430  * authoritative. pict and text fields may contain approximations.
3431  */
3432  SUBTITLE_ASS,
3433 };
3435 #define AV_SUBTITLE_FLAG_FORCED 0x00000001
3437 typedef struct AVSubtitleRect {
3438  int x; ///< top left corner of pict, undefined when pict is not set
3439  int y; ///< top left corner of pict, undefined when pict is not set
3440  int w; ///< width of pict, undefined when pict is not set
3441  int h; ///< height of pict, undefined when pict is not set
3442  int nb_colors; ///< number of colors in pict, undefined when pict is not set
3443 
3444  /**
3445  * data+linesize for the bitmap of this subtitle.
3446  * can be set for text/ass as well once they where rendered
3447  */
3449  enum AVSubtitleType type;
3451  char *text; ///< 0 terminated plain UTF-8 text
3452 
3453  /**
3454  * 0 terminated ASS/SSA compatible event line.
3455  * The presentation of this is unaffected by the other values in this
3456  * struct.
3457  */
3458  char *ass;
3460  int flags;
3461 } AVSubtitleRect;
3463 typedef struct AVSubtitle {
3464  uint16_t format; /* 0 = graphics */
3465  uint32_t start_display_time; /* relative to packet pts, in ms */
3466  uint32_t end_display_time; /* relative to packet pts, in ms */
3467  unsigned num_rects;
3469  int64_t pts; ///< Same as packet pts, in AV_TIME_BASE
3470 } AVSubtitle;
3471 
3472 /**
3473  * If c is NULL, returns the first registered codec,
3474  * if c is non-NULL, returns the next registered codec after c,
3475  * or NULL if c is the last one.
3476  */
3477 AVCodec *av_codec_next(const AVCodec *c);
3478 
3479 /**
3480  * Return the LIBAVCODEC_VERSION_INT constant.
3481  */
3482 unsigned avcodec_version(void);
3483 
3484 /**
3485  * Return the libavcodec build-time configuration.
3486  */
3487 const char *avcodec_configuration(void);
3488 
3489 /**
3490  * Return the libavcodec license.
3491  */
3492 const char *avcodec_license(void);
3493 
3494 /**
3495  * Register the codec codec and initialize libavcodec.
3496  *
3497  * @warning either this function or avcodec_register_all() must be called
3498  * before any other libavcodec functions.
3499  *
3500  * @see avcodec_register_all()
3501  */
3502 void avcodec_register(AVCodec *codec);
3503 
3504 /**
3505  * Register all the codecs, parsers and bitstream filters which were enabled at
3506  * configuration time. If you do not call this function you can select exactly
3507  * which formats you want to support, by using the individual registration
3508  * functions.
3509  *
3510  * @see avcodec_register
3511  * @see av_register_codec_parser
3512  * @see av_register_bitstream_filter
3513  */
3514 void avcodec_register_all(void);
3515 
3516 
3517 #if FF_API_ALLOC_CONTEXT
3518 /**
3519  * Allocate an AVCodecContext and set its fields to default values. The
3520  * resulting struct can be deallocated by simply calling av_free().
3521  *
3522  * @return An AVCodecContext filled with default values or NULL on failure.
3523  * @see avcodec_get_context_defaults
3524  *
3525  * @deprecated use avcodec_alloc_context3()
3526  */
3528 AVCodecContext *avcodec_alloc_context(void);
3529 
3530 /** THIS FUNCTION IS NOT YET PART OF THE PUBLIC API!
3531  * we WILL change its arguments and name a few times! */
3533 AVCodecContext *avcodec_alloc_context2(enum AVMediaType);
3534 
3535 /**
3536  * Set the fields of the given AVCodecContext to default values.
3537  *
3538  * @param s The AVCodecContext of which the fields should be set to default values.
3539  * @deprecated use avcodec_get_context_defaults3
3540  */
3542 void avcodec_get_context_defaults(AVCodecContext *s);
3543 
3544 /** THIS FUNCTION IS NOT YET PART OF THE PUBLIC API!
3545  * we WILL change its arguments and name a few times! */
3547 void avcodec_get_context_defaults2(AVCodecContext *s, enum AVMediaType);
3548 #endif
3549 
3550 /**
3551  * Allocate an AVCodecContext and set its fields to default values. The
3552  * resulting struct can be deallocated by calling avcodec_close() on it followed
3553  * by av_free().
3554  *
3555  * @param codec if non-NULL, allocate private data and initialize defaults
3556  * for the given codec. It is illegal to then call avcodec_open2()
3557  * with a different codec.
3558  * If NULL, then the codec-specific defaults won't be initialized,
3559  * which may result in suboptimal default settings (this is
3560  * important mainly for encoders, e.g. libx264).
3561  *
3562  * @return An AVCodecContext filled with default values or NULL on failure.
3563  * @see avcodec_get_context_defaults
3564  */
3566 
3567 /**
3568  * Set the fields of the given AVCodecContext to default values corresponding
3569  * to the given codec (defaults may be codec-dependent).
3570  *
3571  * Do not call this function if a non-NULL codec has been passed
3572  * to avcodec_alloc_context3() that allocated this AVCodecContext.
3573  * If codec is non-NULL, it is illegal to call avcodec_open2() with a
3574  * different codec on this AVCodecContext.
3575  */
3577 
3578 /**
3579  * Get the AVClass for AVCodecContext. It can be used in combination with
3580  * AV_OPT_SEARCH_FAKE_OBJ for examining options.
3581  *
3582  * @see av_opt_find().
3583  */
3584 const AVClass *avcodec_get_class(void);
3585 
3586 /**
3587  * Get the AVClass for AVFrame. It can be used in combination with
3588  * AV_OPT_SEARCH_FAKE_OBJ for examining options.
3589  *
3590  * @see av_opt_find().
3591  */
3592 const AVClass *avcodec_get_frame_class(void);
3593 
3594 /**
3595  * Get the AVClass for AVSubtitleRect. It can be used in combination with
3596  * AV_OPT_SEARCH_FAKE_OBJ for examining options.
3597  *
3598  * @see av_opt_find().
3599  */
3601 
3602 /**
3603  * Copy the settings of the source AVCodecContext into the destination
3604  * AVCodecContext. The resulting destination codec context will be
3605  * unopened, i.e. you are required to call avcodec_open2() before you
3606  * can use this AVCodecContext to decode/encode video/audio data.
3607  *
3608  * @param dest target codec context, should be initialized with
3609  * avcodec_alloc_context3(), but otherwise uninitialized
3610  * @param src source codec context
3611  * @return AVERROR() on error (e.g. memory allocation error), 0 on success
3612  */
3613 int avcodec_copy_context(AVCodecContext *dest, const AVCodecContext *src);
3614 
3615 /**
3616  * Allocate an AVFrame and set its fields to default values. The resulting
3617  * struct must be freed using avcodec_free_frame().
3618  *
3619  * @return An AVFrame filled with default values or NULL on failure.
3620  * @see avcodec_get_frame_defaults
3621  */
3623 
3624 /**
3625  * Set the fields of the given AVFrame to default values.
3626  *
3627  * @param frame The AVFrame of which the fields should be set to default values.
3628  */
3630 
3631 /**
3632  * Free the frame and any dynamically allocated objects in it,
3633  * e.g. extended_data.
3634  *
3635  * @param frame frame to be freed. The pointer will be set to NULL.
3636  *
3637  * @warning this function does NOT free the data buffers themselves
3638  * (it does not know how, since they might have been allocated with
3639  * a custom get_buffer()).
3640  */
3642 
3643 #if FF_API_AVCODEC_OPEN
3644 /**
3645  * Initialize the AVCodecContext to use the given AVCodec. Prior to using this
3646  * function the context has to be allocated.
3647  *
3648  * The functions avcodec_find_decoder_by_name(), avcodec_find_encoder_by_name(),
3649  * avcodec_find_decoder() and avcodec_find_encoder() provide an easy way for
3650  * retrieving a codec.
3651  *
3652  * @warning This function is not thread safe!
3653  *
3654  * @code
3655  * avcodec_register_all();
3656  * codec = avcodec_find_decoder(AV_CODEC_ID_H264);
3657  * if (!codec)
3658  * exit(1);
3659  *
3660  * context = avcodec_alloc_context3(codec);
3661  *
3662  * if (avcodec_open(context, codec) < 0)
3663  * exit(1);
3664  * @endcode
3665  *
3666  * @param avctx The context which will be set up to use the given codec.
3667  * @param codec The codec to use within the context.
3668  * @return zero on success, a negative value on error
3669  * @see avcodec_alloc_context3, avcodec_find_decoder, avcodec_find_encoder, avcodec_close
3670  *
3671  * @deprecated use avcodec_open2
3672  */
3674 int avcodec_open(AVCodecContext *avctx, AVCodec *codec);
3675 #endif
3676 
3677 /**
3678  * Initialize the AVCodecContext to use the given AVCodec. Prior to using this
3679  * function the context has to be allocated with avcodec_alloc_context3().
3680  *
3681  * The functions avcodec_find_decoder_by_name(), avcodec_find_encoder_by_name(),
3682  * avcodec_find_decoder() and avcodec_find_encoder() provide an easy way for
3683  * retrieving a codec.
3684  *
3685  * @warning This function is not thread safe!
3686  *
3687  * @code
3688  * avcodec_register_all();
3689  * av_dict_set(&opts, "b", "2.5M", 0);
3690  * codec = avcodec_find_decoder(AV_CODEC_ID_H264);
3691  * if (!codec)
3692  * exit(1);
3693  *
3694  * context = avcodec_alloc_context3(codec);
3695  *
3696  * if (avcodec_open2(context, codec, opts) < 0)
3697  * exit(1);
3698  * @endcode
3699  *
3700  * @param avctx The context to initialize.
3701  * @param codec The codec to open this context for. If a non-NULL codec has been
3702  * previously passed to avcodec_alloc_context3() or
3703  * avcodec_get_context_defaults3() for this context, then this
3704  * parameter MUST be either NULL or equal to the previously passed
3705  * codec.
3706  * @param options A dictionary filled with AVCodecContext and codec-private options.
3707  * On return this object will be filled with options that were not found.
3708  *
3709  * @return zero on success, a negative value on error
3710  * @see avcodec_alloc_context3(), avcodec_find_decoder(), avcodec_find_encoder(),
3711  * av_dict_set(), av_opt_find().
3712  */
3713 int avcodec_open2(AVCodecContext *avctx, const AVCodec *codec, AVDictionary **options);
3714 
3715 /**
3716  * Close a given AVCodecContext and free all the data associated with it
3717  * (but not the AVCodecContext itself).
3718  *
3719  * Calling this function on an AVCodecContext that hasn't been opened will free
3720  * the codec-specific data allocated in avcodec_alloc_context3() /
3721  * avcodec_get_context_defaults3() with a non-NULL codec. Subsequent calls will
3722  * do nothing.
3723  */
3724 int avcodec_close(AVCodecContext *avctx);
3725 
3726 /**
3727  * Free all allocated data in the given subtitle struct.
3728  *
3729  * @param sub AVSubtitle to free.
3730  */
3731 void avsubtitle_free(AVSubtitle *sub);
3732 
3733 /**
3734  * @}
3735  */
3736 
3737 /**
3738  * @addtogroup lavc_packet
3739  * @{
3740  */
3741 
3742 /**
3743  * Default packet destructor.
3744  */
3746 
3747 /**
3748  * Initialize optional fields of a packet with default values.
3749  *
3750  * Note, this does not touch the data and size members, which have to be
3751  * initialized separately.
3752  *
3753  * @param pkt packet
3754  */
3755 void av_init_packet(AVPacket *pkt);
3756 
3757 /**
3758  * Allocate the payload of a packet and initialize its fields with
3759  * default values.
3760  *
3761  * @param pkt packet
3762  * @param size wanted payload size
3763  * @return 0 if OK, AVERROR_xxx otherwise
3764  */
3765 int av_new_packet(AVPacket *pkt, int size);
3766 
3767 /**
3768  * Reduce packet size, correctly zeroing padding
3769  *
3770  * @param pkt packet
3771  * @param size new size
3772  */
3773 void av_shrink_packet(AVPacket *pkt, int size);
3774 
3775 /**
3776  * Increase packet size, correctly zeroing padding
3777  *
3778  * @param pkt packet
3779  * @param grow_by number of bytes by which to increase the size of the packet
3780  */
3781 int av_grow_packet(AVPacket *pkt, int grow_by);
3782 
3783 /**
3784  * @warning This is a hack - the packet memory allocation stuff is broken. The
3785  * packet is allocated if it was not really allocated.
3786  */
3787 int av_dup_packet(AVPacket *pkt);
3788 
3789 /**
3790  * Copy packet, including contents
3791  *
3792  * @return 0 on success, negative AVERROR on fail
3793  */
3794 int av_copy_packet(AVPacket *dst, AVPacket *src);
3795 
3796 /**
3797  * Free a packet.
3798  *
3799  * @param pkt packet to free
3800  */
3801 void av_free_packet(AVPacket *pkt);
3802 
3803 /**
3804  * Allocate new information of a packet.
3805  *
3806  * @param pkt packet
3807  * @param type side information type
3808  * @param size side information size
3809  * @return pointer to fresh allocated data or NULL otherwise
3810  */
3812  int size);
3813 
3814 /**
3815  * Shrink the already allocated side data buffer
3816  *
3817  * @param pkt packet
3818  * @param type side information type
3819  * @param size new side information size
3820  * @return 0 on success, < 0 on failure
3821  */
3823  int size);
3824 
3825 /**
3826  * Get side information from packet.
3827  *
3828  * @param pkt packet
3829  * @param type desired side information type
3830  * @param size pointer for side information size to store (optional)
3831  * @return pointer to data if present or NULL otherwise
3832  */
3834  int *size);
3835 
3837 
3839 
3840 
3841 /**
3842  * @}
3843  */
3844 
3845 /**
3846  * @addtogroup lavc_decoding
3847  * @{
3848  */
3849 
3850 /**
3851  * Find a registered decoder with a matching codec ID.
3852  *
3853  * @param id AVCodecID of the requested decoder
3854  * @return A decoder if one was found, NULL otherwise.
3855  */
3857 
3858 /**
3859  * Find a registered decoder with the specified name.
3860  *
3861  * @param name name of the requested decoder
3862  * @return A decoder if one was found, NULL otherwise.
3863  */
3865 
3869 
3870 /**
3871  * Return the amount of padding in pixels which the get_buffer callback must
3872  * provide around the edge of the image for codecs which do not have the
3873  * CODEC_FLAG_EMU_EDGE flag.
3874  *
3875  * @return Required padding in pixels.
3876  */
3877 unsigned avcodec_get_edge_width(void);
3878 
3879 /**
3880  * Modify width and height values so that they will result in a memory
3881  * buffer that is acceptable for the codec if you do not use any horizontal
3882  * padding.
3883  *
3884  * May only be used if a codec with CODEC_CAP_DR1 has been opened.
3885  * If CODEC_FLAG_EMU_EDGE is not set, the dimensions must have been increased
3886  * according to avcodec_get_edge_width() before.
3887  */
3889 
3890 /**
3891  * Modify width and height values so that they will result in a memory
3892  * buffer that is acceptable for the codec if you also ensure that all
3893  * line sizes are a multiple of the respective linesize_align[i].
3894  *
3895  * May only be used if a codec with CODEC_CAP_DR1 has been opened.
3896  * If CODEC_FLAG_EMU_EDGE is not set, the dimensions must have been increased
3897  * according to avcodec_get_edge_width() before.
3898  */
3900  int linesize_align[AV_NUM_DATA_POINTERS]);
3901 
3902 #if FF_API_OLD_DECODE_AUDIO
3903 /**
3904  * Wrapper function which calls avcodec_decode_audio4.
3905  *
3906  * @deprecated Use avcodec_decode_audio4 instead.
3907  *
3908  * Decode the audio frame of size avpkt->size from avpkt->data into samples.
3909  * Some decoders may support multiple frames in a single AVPacket, such
3910  * decoders would then just decode the first frame. In this case,
3911  * avcodec_decode_audio3 has to be called again with an AVPacket that contains
3912  * the remaining data in order to decode the second frame etc.
3913  * If no frame
3914  * could be outputted, frame_size_ptr is zero. Otherwise, it is the
3915  * decompressed frame size in bytes.
3916  *
3917  * @warning You must set frame_size_ptr to the allocated size of the
3918  * output buffer before calling avcodec_decode_audio3().
3919  *
3920  * @warning The input buffer must be FF_INPUT_BUFFER_PADDING_SIZE larger than
3921  * the actual read bytes because some optimized bitstream readers read 32 or 64
3922  * bits at once and could read over the end.
3923  *
3924  * @warning The end of the input buffer avpkt->data should be set to 0 to ensure that
3925  * no overreading happens for damaged MPEG streams.
3926  *
3927  * @warning You must not provide a custom get_buffer() when using
3928  * avcodec_decode_audio3(). Doing so will override it with
3929  * avcodec_default_get_buffer. Use avcodec_decode_audio4() instead,
3930  * which does allow the application to provide a custom get_buffer().
3931  *
3932  * @note You might have to align the input buffer avpkt->data and output buffer
3933  * samples. The alignment requirements depend on the CPU: On some CPUs it isn't
3934  * necessary at all, on others it won't work at all if not aligned and on others
3935  * it will work but it will have an impact on performance.
3936  *
3937  * In practice, avpkt->data should have 4 byte alignment at minimum and
3938  * samples should be 16 byte aligned unless the CPU doesn't need it
3939  * (AltiVec and SSE do).
3940  *
3941  * @note Codecs which have the CODEC_CAP_DELAY capability set have a delay
3942  * between input and output, these need to be fed with avpkt->data=NULL,
3943  * avpkt->size=0 at the end to return the remaining frames.
3944  *
3945  * @param avctx the codec context
3946  * @param[out] samples the output buffer, sample type in avctx->sample_fmt
3947  * If the sample format is planar, each channel plane will
3948  * be the same size, with no padding between channels.
3949  * @param[in,out] frame_size_ptr the output buffer size in bytes
3950  * @param[in] avpkt The input AVPacket containing the input buffer.
3951  * You can create such packet with av_init_packet() and by then setting
3952  * data and size, some decoders might in addition need other fields.
3953  * All decoders are designed to use the least fields possible though.
3954  * @return On error a negative value is returned, otherwise the number of bytes
3955  * used or zero if no frame data was decompressed (used) from the input AVPacket.
3956  */
3957 attribute_deprecated int avcodec_decode_audio3(AVCodecContext *avctx, int16_t *samples,
3958  int *frame_size_ptr,
3959  AVPacket *avpkt);
3960 #endif
3961 
3962 /**
3963  * Decode the audio frame of size avpkt->size from avpkt->data into frame.
3964  *
3965  * Some decoders may support multiple frames in a single AVPacket. Such
3966  * decoders would then just decode the first frame. In this case,
3967  * avcodec_decode_audio4 has to be called again with an AVPacket containing
3968  * the remaining data in order to decode the second frame, etc...
3969  * Even if no frames are returned, the packet needs to be fed to the decoder
3970  * with remaining data until it is completely consumed or an error occurs.
3971  *
3972  * @warning The input buffer, avpkt->data must be FF_INPUT_BUFFER_PADDING_SIZE
3973  * larger than the actual read bytes because some optimized bitstream
3974  * readers read 32 or 64 bits at once and could read over the end.
3975  *
3976  * @note You might have to align the input buffer. The alignment requirements
3977  * depend on the CPU and the decoder.
3978  *
3979  * @param avctx the codec context
3980  * @param[out] frame The AVFrame in which to store decoded audio samples.
3981  * Decoders request a buffer of a particular size by setting
3982  * AVFrame.nb_samples prior to calling get_buffer(). The
3983  * decoder may, however, only utilize part of the buffer by
3984  * setting AVFrame.nb_samples to a smaller value in the
3985  * output frame.
3986  * @param[out] got_frame_ptr Zero if no frame could be decoded, otherwise it is
3987  * non-zero.
3988  * @param[in] avpkt The input AVPacket containing the input buffer.
3989  * At least avpkt->data and avpkt->size should be set. Some
3990  * decoders might also require additional fields to be set.
3991  * @return A negative error code is returned if an error occurred during
3992  * decoding, otherwise the number of bytes consumed from the input
3993  * AVPacket is returned.
3994  */
3996  int *got_frame_ptr, const AVPacket *avpkt);
3997 
3998 /**
3999  * Decode the video frame of size avpkt->size from avpkt->data into picture.
4000  * Some decoders may support multiple frames in a single AVPacket, such
4001  * decoders would then just decode the first frame.
4002  *
4003  * @warning The input buffer must be FF_INPUT_BUFFER_PADDING_SIZE larger than
4004  * the actual read bytes because some optimized bitstream readers read 32 or 64
4005  * bits at once and could read over the end.
4006  *
4007  * @warning The end of the input buffer buf should be set to 0 to ensure that
4008  * no overreading happens for damaged MPEG streams.
4009  *
4010  * @note You might have to align the input buffer avpkt->data.
4011  * The alignment requirements depend on the CPU: on some CPUs it isn't
4012  * necessary at all, on others it won't work at all if not aligned and on others
4013  * it will work but it will have an impact on performance.
4014  *
4015  * In practice, avpkt->data should have 4 byte alignment at minimum.
4016  *
4017  * @note Codecs which have the CODEC_CAP_DELAY capability set have a delay
4018  * between input and output, these need to be fed with avpkt->data=NULL,
4019  * avpkt->size=0 at the end to return the remaining frames.
4020  *
4021  * @param avctx the codec context
4022  * @param[out] picture The AVFrame in which the decoded video frame will be stored.
4023  * Use avcodec_alloc_frame to get an AVFrame, the codec will
4024  * allocate memory for the actual bitmap.
4025  * with default get/release_buffer(), the decoder frees/reuses the bitmap as it sees fit.
4026  * with overridden get/release_buffer() (needs CODEC_CAP_DR1) the user decides into what buffer the decoder
4027  * decodes and the decoder tells the user once it does not need the data anymore,
4028  * the user app can at this point free/reuse/keep the memory as it sees fit.
4029  *
4030  * @param[in] avpkt The input AVpacket containing the input buffer.
4031  * You can create such packet with av_init_packet() and by then setting
4032  * data and size, some decoders might in addition need other fields like
4033  * flags&AV_PKT_FLAG_KEY. All decoders are designed to use the least
4034  * fields possible.
4035  * @param[in,out] got_picture_ptr Zero if no frame could be decompressed, otherwise, it is nonzero.
4036  * @return On error a negative value is returned, otherwise the number of bytes
4037  * used or zero if no frame could be decompressed.
4038  */
4039 int avcodec_decode_video2(AVCodecContext *avctx, AVFrame *picture,
4040  int *got_picture_ptr,
4041  const AVPacket *avpkt);
4042 
4043 /**
4044  * Decode a subtitle message.
4045  * Return a negative value on error, otherwise return the number of bytes used.
4046  * If no subtitle could be decompressed, got_sub_ptr is zero.
4047  * Otherwise, the subtitle is stored in *sub.
4048  * Note that CODEC_CAP_DR1 is not available for subtitle codecs. This is for
4049  * simplicity, because the performance difference is expect to be negligible
4050  * and reusing a get_buffer written for video codecs would probably perform badly
4051  * due to a potentially very different allocation pattern.
4052  *
4053  * @param avctx the codec context
4054  * @param[out] sub The AVSubtitle in which the decoded subtitle will be stored, must be
4055  freed with avsubtitle_free if *got_sub_ptr is set.
4056  * @param[in,out] got_sub_ptr Zero if no subtitle could be decompressed, otherwise, it is nonzero.
4057  * @param[in] avpkt The input AVPacket containing the input buffer.
4058  */
4060  int *got_sub_ptr,
4061  AVPacket *avpkt);
4062 
4063 /**
4064  * @defgroup lavc_parsing Frame parsing
4065  * @{
4066  */
4068 typedef struct AVCodecParserContext {
4069  void *priv_data;
4071  int64_t frame_offset; /* offset of the current frame */
4072  int64_t cur_offset; /* current offset
4073  (incremented by each av_parser_parse()) */
4074  int64_t next_frame_offset; /* offset of the next frame */
4075  /* video info */
4076  int pict_type; /* XXX: Put it back in AVCodecContext. */
4077  /**
4078  * This field is used for proper frame duration computation in lavf.
4079  * It signals, how much longer the frame duration of the current frame
4080  * is compared to normal frame duration.
4081  *
4082  * frame_duration = (1 + repeat_pict) * time_base
4083  *
4084  * It is used by codecs like H.264 to display telecined material.
4085  */
4086  int repeat_pict; /* XXX: Put it back in AVCodecContext. */
4087  int64_t pts; /* pts of the current frame */
4088  int64_t dts; /* dts of the current frame */
4089 
4090  /* private data */
4091  int64_t last_pts;
4092  int64_t last_dts;
4093  int fetch_timestamp;
4095 #define AV_PARSER_PTS_NB 4
4101  int flags;
4102 #define PARSER_FLAG_COMPLETE_FRAMES 0x0001
4103 #define PARSER_FLAG_ONCE 0x0002
4104 /// Set if the parser has a valid file offset
4105 #define PARSER_FLAG_FETCHED_OFFSET 0x0004
4106 #define PARSER_FLAG_USE_CODEC_TS 0x1000
4108  int64_t offset; ///< byte offset from starting packet start
4110 
4111  /**
4112  * Set by parser to 1 for key frames and 0 for non-key frames.
4113  * It is initialized to -1, so if the parser doesn't set this flag,
4114  * old-style fallback using AV_PICTURE_TYPE_I picture type as key frames
4115  * will be used.
4116  */
4117  int key_frame;
4118 
4119  /**
4120  * Time difference in stream time base units from the pts of this
4121  * packet to the point at which the output from the decoder has converged
4122  * independent from the availability of previous frames. That is, the
4123  * frames are virtually identical no matter if decoding started from
4124  * the very first frame or from this keyframe.
4125  * Is AV_NOPTS_VALUE if unknown.
4126  * This field is not the display duration of the current frame.
4127  * This field has no meaning if the packet does not have AV_PKT_FLAG_KEY
4128  * set.
4129  *
4130  * The purpose of this field is to allow seeking in streams that have no
4131  * keyframes in the conventional sense. It corresponds to the
4132  * recovery point SEI in H.264 and match_time_delta in NUT. It is also
4133  * essential for some types of subtitle streams to ensure that all
4134  * subtitles are correctly displayed after seeking.
4135  */
4136  int64_t convergence_duration;
4137 
4138  // Timestamp generation support:
4139  /**
4140  * Synchronization point for start of timestamp generation.
4141  *
4142  * Set to >0 for sync point, 0 for no sync point and <0 for undefined
4143  * (default).
4144  *
4145  * For example, this corresponds to presence of H.264 buffering period
4146  * SEI message.
4147  */
4148  int dts_sync_point;
4149 
4150  /**
4151  * Offset of the current timestamp against last timestamp sync point in
4152  * units of AVCodecContext.time_base.
4153  *
4154  * Set to INT_MIN when dts_sync_point unused. Otherwise, it must
4155  * contain a valid timestamp offset.
4156  *
4157  * Note that the timestamp of sync point has usually a nonzero
4158  * dts_ref_dts_delta, which refers to the previous sync point. Offset of
4159  * the next frame after timestamp sync point will be usually 1.
4160  *
4161  * For example, this corresponds to H.264 cpb_removal_delay.
4162  */
4163  int dts_ref_dts_delta;
4164 
4165  /**
4166  * Presentation delay of current frame in units of AVCodecContext.time_base.
4167  *
4168  * Set to INT_MIN when dts_sync_point unused. Otherwise, it must
4169  * contain valid non-negative timestamp delta (presentation time of a frame
4170  * must not lie in the past).
4171  *
4172  * This delay represents the difference between decoding and presentation
4173  * time of the frame.
4174  *
4175  * For example, this corresponds to H.264 dpb_output_delay.
4176  */
4177  int pts_dts_delta;
4178 
4179  /**
4180  * Position of the packet in file.
4181  *
4182  * Analogous to cur_frame_pts/dts
4183  */
4185 
4186  /**
4187  * Byte position of currently parsed frame in stream.
4188  */
4189  int64_t pos;
4190 
4191  /**
4192  * Previous frame byte position.
4193  */
4194  int64_t last_pos;
4195 
4196  /**
4197  * Duration of the current frame.
4198  * For audio, this is in units of 1 / AVCodecContext.sample_rate.
4199  * For all other types, this is in units of AVCodecContext.time_base.
4200  */
4201  int duration;
4204 typedef struct AVCodecParser {
4205  int codec_ids[5]; /* several codec IDs are permitted */
4209  AVCodecContext *avctx,
4210  const uint8_t **poutbuf, int *poutbuf_size,
4211  const uint8_t *buf, int buf_size);
4213  int (*split)(AVCodecContext *avctx, const uint8_t *buf, int buf_size);
4214  struct AVCodecParser *next;
4215 } AVCodecParser;
4216 
4218 
4221 
4222 /**
4223  * Parse a packet.
4224  *
4225  * @param s parser context.
4226  * @param avctx codec context.
4227  * @param poutbuf set to pointer to parsed buffer or NULL if not yet finished.
4228  * @param poutbuf_size set to size of parsed buffer or zero if not yet finished.
4229  * @param buf input buffer.
4230  * @param buf_size input length, to signal EOF, this should be 0 (so that the last frame can be output).
4231  * @param pts input presentation timestamp.
4232  * @param dts input decoding timestamp.
4233  * @param pos input byte position in stream.
4234  * @return the number of bytes of the input bitstream used.
4235  *
4236  * Example:
4237  * @code
4238  * while(in_len){
4239  * len = av_parser_parse2(myparser, AVCodecContext, &data, &size,
4240  * in_data, in_len,
4241  * pts, dts, pos);
4242  * in_data += len;
4243  * in_len -= len;
4244  *
4245  * if(size)
4246  * decode_frame(data, size);
4247  * }
4248  * @endcode
4249  */
4251  AVCodecContext *avctx,
4252  uint8_t **poutbuf, int *poutbuf_size,
4253  const uint8_t *buf, int buf_size,
4254  int64_t pts, int64_t dts,
4255  int64_t pos);
4256 
4257 /**
4258  * @return 0 if the output buffer is a subset of the input, 1 if it is allocated and must be freed
4259  * @deprecated use AVBitstreamFilter
4260  */
4262  AVCodecContext *avctx,
4263  uint8_t **poutbuf, int *poutbuf_size,
4264  const uint8_t *buf, int buf_size, int keyframe);
4266 
4267 /**
4268  * @}
4269  * @}
4270  */
4271 
4272 /**
4273  * @addtogroup lavc_encoding
4274  * @{
4275  */
4276 
4277 /**
4278  * Find a registered encoder with a matching codec ID.
4279  *
4280  * @param id AVCodecID of the requested encoder
4281  * @return An encoder if one was found, NULL otherwise.
4282  */
4284 
4285 /**
4286  * Find a registered encoder with the specified name.
4287  *
4288  * @param name name of the requested encoder
4289  * @return An encoder if one was found, NULL otherwise.
4290  */
4292 
4293 #if FF_API_OLD_ENCODE_AUDIO
4294 /**
4295  * Encode an audio frame from samples into buf.
4296  *
4297  * @deprecated Use avcodec_encode_audio2 instead.
4298  *
4299  * @note The output buffer should be at least FF_MIN_BUFFER_SIZE bytes large.
4300  * However, for codecs with avctx->frame_size equal to 0 (e.g. PCM) the user
4301  * will know how much space is needed because it depends on the value passed
4302  * in buf_size as described below. In that case a lower value can be used.
4303  *
4304  * @param avctx the codec context
4305  * @param[out] buf the output buffer
4306  * @param[in] buf_size the output buffer size
4307  * @param[in] samples the input buffer containing the samples
4308  * The number of samples read from this buffer is frame_size*channels,
4309  * both of which are defined in avctx.
4310  * For codecs which have avctx->frame_size equal to 0 (e.g. PCM) the number of
4311  * samples read from samples is equal to:
4312  * buf_size * 8 / (avctx->channels * av_get_bits_per_sample(avctx->codec_id))
4313  * This also implies that av_get_bits_per_sample() must not return 0 for these
4314  * codecs.
4315  * @return On error a negative value is returned, on success zero or the number
4316  * of bytes used to encode the data read from the input buffer.
4317  */
4318 int attribute_deprecated avcodec_encode_audio(AVCodecContext *avctx,
4319  uint8_t *buf, int buf_size,
4320  const short *samples);
4321 #endif
4322 
4323 /**
4324  * Encode a frame of audio.
4325  *
4326  * Takes input samples from frame and writes the next output packet, if
4327  * available, to avpkt. The output packet does not necessarily contain data for
4328  * the most recent frame, as encoders can delay, split, and combine input frames
4329  * internally as needed.
4330  *
4331  * @param avctx codec context
4332  * @param avpkt output AVPacket.
4333  * The user can supply an output buffer by setting
4334  * avpkt->data and avpkt->size prior to calling the
4335  * function, but if the size of the user-provided data is not
4336  * large enough, encoding will fail. If avpkt->data and
4337  * avpkt->size are set, avpkt->destruct must also be set. All
4338  * other AVPacket fields will be reset by the encoder using
4339  * av_init_packet(). If avpkt->data is NULL, the encoder will
4340  * allocate it. The encoder will set avpkt->size to the size
4341  * of the output packet.
4342  *
4343  * If this function fails or produces no output, avpkt will be
4344  * freed using av_free_packet() (i.e. avpkt->destruct will be
4345  * called to free the user supplied buffer).
4346  * @param[in] frame AVFrame containing the raw audio data to be encoded.
4347  * May be NULL when flushing an encoder that has the
4348  * CODEC_CAP_DELAY capability set.
4349  * If CODEC_CAP_VARIABLE_FRAME_SIZE is set, then each frame
4350  * can have any number of samples.
4351  * If it is not set, frame->nb_samples must be equal to
4352  * avctx->frame_size for all frames except the last.
4353  * The final frame may be smaller than avctx->frame_size.
4354  * @param[out] got_packet_ptr This field is set to 1 by libavcodec if the
4355  * output packet is non-empty, and to 0 if it is
4356  * empty. If the function returns an error, the
4357  * packet can be assumed to be invalid, and the
4358  * value of got_packet_ptr is undefined and should
4359  * not be used.
4360  * @return 0 on success, negative error code on failure
4361  */
4362 int avcodec_encode_audio2(AVCodecContext *avctx, AVPacket *avpkt,
4363  const AVFrame *frame, int *got_packet_ptr);
4364 
4365 #if FF_API_OLD_ENCODE_VIDEO
4366 /**
4367  * @deprecated use avcodec_encode_video2() instead.
4368  *
4369  * Encode a video frame from pict into buf.
4370  * The input picture should be
4371  * stored using a specific format, namely avctx.pix_fmt.
4372  *
4373  * @param avctx the codec context
4374  * @param[out] buf the output buffer for the bitstream of encoded frame
4375  * @param[in] buf_size the size of the output buffer in bytes
4376  * @param[in] pict the input picture to encode
4377  * @return On error a negative value is returned, on success zero or the number
4378  * of bytes used from the output buffer.
4379  */
4381 int avcodec_encode_video(AVCodecContext *avctx, uint8_t *buf, int buf_size,
4382  const AVFrame *pict);
4383 #endif
4384 
4385 /**
4386  * Encode a frame of video.
4387  *
4388  * Takes input raw video data from frame and writes the next output packet, if
4389  * available, to avpkt. The output packet does not necessarily contain data for
4390  * the most recent frame, as encoders can delay and reorder input frames
4391  * internally as needed.
4392  *
4393  * @param avctx codec context
4394  * @param avpkt output AVPacket.
4395  * The user can supply an output buffer by setting
4396  * avpkt->data and avpkt->size prior to calling the
4397  * function, but if the size of the user-provided data is not
4398  * large enough, encoding will fail. All other AVPacket fields
4399  * will be reset by the encoder using av_init_packet(). If
4400  * avpkt->data is NULL, the encoder will allocate it.
4401  * The encoder will set avpkt->size to the size of the
4402  * output packet. The returned data (if any) belongs to the
4403  * caller, he is responsible for freeing it.
4404  *
4405  * If this function fails or produces no output, avpkt will be
4406  * freed using av_free_packet() (i.e. avpkt->destruct will be
4407  * called to free the user supplied buffer).
4408  * @param[in] frame AVFrame containing the raw video data to be encoded.
4409  * May be NULL when flushing an encoder that has the
4410  * CODEC_CAP_DELAY capability set.
4411  * @param[out] got_packet_ptr This field is set to 1 by libavcodec if the
4412  * output packet is non-empty, and to 0 if it is
4413  * empty. If the function returns an error, the
4414  * packet can be assumed to be invalid, and the
4415  * value of got_packet_ptr is undefined and should
4416  * not be used.
4417  * @return 0 on success, negative error code on failure
4418  */
4419 int avcodec_encode_video2(AVCodecContext *avctx, AVPacket *avpkt,
4420  const AVFrame *frame, int *got_packet_ptr);
4421 
4422 int avcodec_encode_subtitle(AVCodecContext *avctx, uint8_t *buf, int buf_size,
4423  const AVSubtitle *sub);
4424 
4425 
4426 /**
4427  * @}
4428  */
4429 
4430 #if FF_API_AVCODEC_RESAMPLE
4431 /**
4432  * @defgroup lavc_resample Audio resampling
4433  * @ingroup libavc
4434  * @deprecated use libswresample instead
4435  *
4436  * @{
4437  */
4438 struct ReSampleContext;
4439 struct AVResampleContext;
4440 
4441 typedef struct ReSampleContext ReSampleContext;
4442 
4443 /**
4444  * Initialize audio resampling context.
4445  *
4446  * @param output_channels number of output channels
4447  * @param input_channels number of input channels
4448  * @param output_rate output sample rate
4449  * @param input_rate input sample rate
4450  * @param sample_fmt_out requested output sample format
4451  * @param sample_fmt_in input sample format
4452  * @param filter_length length of each FIR filter in the filterbank relative to the cutoff frequency
4453  * @param log2_phase_count log2 of the number of entries in the polyphase filterbank
4454  * @param linear if 1 then the used FIR filter will be linearly interpolated
4455  between the 2 closest, if 0 the closest will be used
4456  * @param cutoff cutoff frequency, 1.0 corresponds to half the output sampling rate
4457  * @return allocated ReSampleContext, NULL if error occurred
4458  */
4460 ReSampleContext *av_audio_resample_init(int output_channels, int input_channels,
4461  int output_rate, int input_rate,
4462  enum AVSampleFormat sample_fmt_out,
4463  enum AVSampleFormat sample_fmt_in,
4464  int filter_length, int log2_phase_count,
4465  int linear, double cutoff);
4466 
4468 int audio_resample(ReSampleContext *s, short *output, short *input, int nb_samples);
4469 
4470 /**
4471  * Free resample context.
4472  *
4473  * @param s a non-NULL pointer to a resample context previously
4474  * created with av_audio_resample_init()
4475  */
4477 void audio_resample_close(ReSampleContext *s);
4478 
4479 
4480 /**
4481  * Initialize an audio resampler.
4482  * Note, if either rate is not an integer then simply scale both rates up so they are.
4483  * @param filter_length length of each FIR filter in the filterbank relative to the cutoff freq
4484  * @param log2_phase_count log2 of the number of entries in the polyphase filterbank
4485  * @param linear If 1 then the used FIR filter will be linearly interpolated
4486  between the 2 closest, if 0 the closest will be used
4487  * @param cutoff cutoff frequency, 1.0 corresponds to half the output sampling rate
4488  */
4490 struct AVResampleContext *av_resample_init(int out_rate, int in_rate, int filter_length, int log2_phase_count, int linear, double cutoff);
4491 
4492 /**
4493  * Resample an array of samples using a previously configured context.
4494  * @param src an array of unconsumed samples
4495  * @param consumed the number of samples of src which have been consumed are returned here
4496  * @param src_size the number of unconsumed samples available
4497  * @param dst_size the amount of space in samples available in dst
4498  * @param update_ctx If this is 0 then the context will not be modified, that way several channels can be resampled with the same context.
4499  * @return the number of samples written in dst or -1 if an error occurred
4500  */
4502 int av_resample(struct AVResampleContext *c, short *dst, short *src, int *consumed, int src_size, int dst_size, int update_ctx);
4503 
4504 
4505 /**
4506  * Compensate samplerate/timestamp drift. The compensation is done by changing
4507  * the resampler parameters, so no audible clicks or similar distortions occur
4508  * @param compensation_distance distance in output samples over which the compensation should be performed
4509  * @param sample_delta number of output samples which should be output less
4510  *
4511  * example: av_resample_compensate(c, 10, 500)
4512  * here instead of 510 samples only 500 samples would be output
4513  *
4514  * note, due to rounding the actual compensation might be slightly different,
4515  * especially if the compensation_distance is large and the in_rate used during init is small
4516  */
4518 void av_resample_compensate(struct AVResampleContext *c, int sample_delta, int compensation_distance);
4520 void av_resample_close(struct AVResampleContext *c);
4521 
4522 /**
4523  * @}
4524  */
4525 #endif
4526 
4527 /**
4528  * @addtogroup lavc_picture
4529  * @{
4530  */
4531 
4532 /**
4533  * Allocate memory for a picture. Call avpicture_free() to free it.
4534  *
4535  * @see avpicture_fill()
4536  *
4537  * @param picture the picture to be filled in
4538  * @param pix_fmt the format of the picture
4539  * @param width the width of the picture
4540  * @param height the height of the picture
4541  * @return zero if successful, a negative value if not
4542  */
4543 int avpicture_alloc(AVPicture *picture, enum AVPixelFormat pix_fmt, int width, int height);
4544 
4545 /**
4546  * Free a picture previously allocated by avpicture_alloc().
4547  * The data buffer used by the AVPicture is freed, but the AVPicture structure
4548  * itself is not.
4549  *
4550  * @param picture the AVPicture to be freed
4551  */
4552 void avpicture_free(AVPicture *picture);
4553 
4554 /**
4555  * Fill in the AVPicture fields, always assume a linesize alignment of
4556  * 1.
4557  *
4558  * @see av_image_fill_arrays()
4559  */
4560 int avpicture_fill(AVPicture *picture, const uint8_t *ptr,
4561  enum AVPixelFormat pix_fmt, int width, int height);
4562 
4563 /**
4564  * Copy pixel data from an AVPicture into a buffer, always assume a
4565  * linesize alignment of 1.
4566  *
4567  * @see av_image_copy_to_buffer()
4568  */
4569 int avpicture_layout(const AVPicture* src, enum AVPixelFormat pix_fmt,
4570  int width, int height,
4571  unsigned char *dest, int dest_size);
4572 
4573 /**
4574  * Calculate the size in bytes that a picture of the given width and height
4575  * would occupy if stored in the given picture format.
4576  * Always assume a linesize alignment of 1.
4577  *
4578  * @see av_image_get_buffer_size().
4579  */
4581 
4582 /**
4583  * deinterlace - if not supported return -1
4584  */
4585 int avpicture_deinterlace(AVPicture *dst, const AVPicture *src,
4586  enum AVPixelFormat pix_fmt, int width, int height);
4587 /**
4588  * Copy image src to dst. Wraps av_image_copy().
4589  */
4590 void av_picture_copy(AVPicture *dst, const AVPicture *src,
4591  enum AVPixelFormat pix_fmt, int width, int height);
4592 
4593 /**
4594  * Crop image top and left side.
4595  */
4596 int av_picture_crop(AVPicture *dst, const AVPicture *src,
4597  enum AVPixelFormat pix_fmt, int top_band, int left_band);
4598 
4599 /**
4600  * Pad image.
4601  */
4602 int av_picture_pad(AVPicture *dst, const AVPicture *src, int height, int width, enum AVPixelFormat pix_fmt,
4603  int padtop, int padbottom, int padleft, int padright, int *color);
4604 
4605 /**
4606  * @}
4607  */
4608 
4609 /**
4610  * @defgroup lavc_misc Utility functions
4611  * @ingroup libavc
4612  *
4613  * Miscellaneous utility functions related to both encoding and decoding
4614  * (or neither).
4615  * @{
4616  */
4617 
4618 /**
4619  * @defgroup lavc_misc_pixfmt Pixel formats
4620  *
4621  * Functions for working with pixel formats.
4622  * @{
4623  */
4624 
4625 /**
4626  * Utility function to access log2_chroma_w log2_chroma_h from
4627  * the pixel format AVPixFmtDescriptor.
4628  *
4629  * This function asserts that pix_fmt is valid. See av_pix_fmt_get_chroma_sub_sample
4630  * for one that returns a failure code and continues in case of invalid
4631  * pix_fmts.
4632  *
4633  * @param[in] pix_fmt the pixel format
4634  * @param[out] h_shift store log2_chroma_h
4635  * @param[out] v_shift store log2_chroma_w
4636  *
4637  * @see av_pix_fmt_get_chroma_sub_sample
4638  */
4639 
4640 void avcodec_get_chroma_sub_sample(enum AVPixelFormat pix_fmt, int *h_shift, int *v_shift);
4641 
4642 /**
4643  * Return a value representing the fourCC code associated to the
4644  * pixel format pix_fmt, or 0 if no associated fourCC code can be
4645  * found.
4646  */
4649 #define FF_LOSS_RESOLUTION 0x0001 /**< loss due to resolution change */
4650 #define FF_LOSS_DEPTH 0x0002 /**< loss due to color depth change */
4651 #define FF_LOSS_COLORSPACE 0x0004 /**< loss due to color space conversion */
4652 #define FF_LOSS_ALPHA 0x0008 /**< loss of alpha bits */
4653 #define FF_LOSS_COLORQUANT 0x0010 /**< loss due to color quantization */
4654 #define FF_LOSS_CHROMA 0x0020 /**< loss of chroma (e.g. RGB to gray conversion) */
4655 
4656 /**
4657  * Compute what kind of losses will occur when converting from one specific
4658  * pixel format to another.
4659  * When converting from one pixel format to another, information loss may occur.
4660  * For example, when converting from RGB24 to GRAY, the color information will
4661  * be lost. Similarly, other losses occur when converting from some formats to
4662  * other formats. These losses can involve loss of chroma, but also loss of
4663  * resolution, loss of color depth, loss due to the color space conversion, loss
4664  * of the alpha bits or loss due to color quantization.
4665  * avcodec_get_fix_fmt_loss() informs you about the various types of losses
4666  * which will occur when converting from one pixel format to another.
4667  *
4668  * @param[in] dst_pix_fmt destination pixel format
4669  * @param[in] src_pix_fmt source pixel format
4670  * @param[in] has_alpha Whether the source pixel format alpha channel is used.
4671  * @return Combination of flags informing you what kind of losses will occur
4672  * (maximum loss for an invalid dst_pix_fmt).
4673  */
4674 int avcodec_get_pix_fmt_loss(enum AVPixelFormat dst_pix_fmt, enum AVPixelFormat src_pix_fmt,
4675  int has_alpha);
4676 
4677 #if FF_API_FIND_BEST_PIX_FMT
4678 /**
4679  * @deprecated use avcodec_find_best_pix_fmt_of_2() instead.
4680  *
4681  * Find the best pixel format to convert to given a certain source pixel
4682  * format. When converting from one pixel format to another, information loss
4683  * may occur. For example, when converting from RGB24 to GRAY, the color
4684  * information will be lost. Similarly, other losses occur when converting from
4685  * some formats to other formats. avcodec_find_best_pix_fmt() searches which of
4686  * the given pixel formats should be used to suffer the least amount of loss.
4687  * The pixel formats from which it chooses one, are determined by the
4688  * pix_fmt_mask parameter.
4689  *
4690  * Note, only the first 64 pixel formats will fit in pix_fmt_mask.
4691  *
4692  * @code
4693  * src_pix_fmt = AV_PIX_FMT_YUV420P;
4694  * pix_fmt_mask = (1 << AV_PIX_FMT_YUV422P) | (1 << AV_PIX_FMT_RGB24);
4695  * dst_pix_fmt = avcodec_find_best_pix_fmt(pix_fmt_mask, src_pix_fmt, alpha, &loss);
4696  * @endcode
4697  *
4698  * @param[in] pix_fmt_mask bitmask determining which pixel format to choose from
4699  * @param[in] src_pix_fmt source pixel format
4700  * @param[in] has_alpha Whether the source pixel format alpha channel is used.
4701  * @param[out] loss_ptr Combination of flags informing you what kind of losses will occur.
4702  * @return The best pixel format to convert to or -1 if none was found.
4703  */
4705 enum AVPixelFormat avcodec_find_best_pix_fmt(int64_t pix_fmt_mask, enum AVPixelFormat src_pix_fmt,
4706  int has_alpha, int *loss_ptr);
4707 #endif /* FF_API_FIND_BEST_PIX_FMT */
4708 
4709 /**
4710  * Find the best pixel format to convert to given a certain source pixel
4711  * format. When converting from one pixel format to another, information loss
4712  * may occur. For example, when converting from RGB24 to GRAY, the color
4713  * information will be lost. Similarly, other losses occur when converting from
4714  * some formats to other formats. avcodec_find_best_pix_fmt_of_2() searches which of
4715  * the given pixel formats should be used to suffer the least amount of loss.
4716  * The pixel formats from which it chooses one, are determined by the
4717  * pix_fmt_list parameter.
4718  *
4719  *
4720  * @param[in] pix_fmt_list AV_PIX_FMT_NONE terminated array of pixel formats to choose from
4721  * @param[in] src_pix_fmt source pixel format
4722  * @param[in] has_alpha Whether the source pixel format alpha channel is used.
4723  * @param[out] loss_ptr Combination of flags informing you what kind of losses will occur.
4724  * @return The best pixel format to convert to or -1 if none was found.
4725  */
4727  enum AVPixelFormat src_pix_fmt,
4728  int has_alpha, int *loss_ptr);
4729 
4730 /**
4731  * Find the best pixel format to convert to given a certain source pixel
4732  * format and a selection of two destination pixel formats. When converting from
4733  * one pixel format to another, information loss may occur. For example, when converting
4734  * from RGB24 to GRAY, the color information will be lost. Similarly, other losses occur when
4735  * converting from some formats to other formats. avcodec_find_best_pix_fmt_of_2() selects which of
4736  * the given pixel formats should be used to suffer the least amount of loss.
4737  *
4738  * If one of the destination formats is AV_PIX_FMT_NONE the other pixel format (if valid) will be
4739  * returned.
4740  *
4741  * @code
4742  * src_pix_fmt = AV_PIX_FMT_YUV420P;
4743  * dst_pix_fmt1= AV_PIX_FMT_RGB24;
4744  * dst_pix_fmt2= AV_PIX_FMT_GRAY8;
4745  * dst_pix_fmt3= AV_PIX_FMT_RGB8;
4746  * loss= FF_LOSS_CHROMA; // don't care about chroma loss, so chroma loss will be ignored.
4747  * dst_pix_fmt = avcodec_find_best_pix_fmt_of_2(dst_pix_fmt1, dst_pix_fmt2, src_pix_fmt, alpha, &loss);
4748  * dst_pix_fmt = avcodec_find_best_pix_fmt_of_2(dst_pix_fmt, dst_pix_fmt3, src_pix_fmt, alpha, &loss);
4749  * @endcode
4750  *
4751  * @param[in] dst_pix_fmt1 One of the two destination pixel formats to choose from
4752  * @param[in] dst_pix_fmt2 The other of the two destination pixel formats to choose from
4753  * @param[in] src_pix_fmt Source pixel format
4754  * @param[in] has_alpha Whether the source pixel format alpha channel is used.
4755  * @param[in, out] loss_ptr Combination of loss flags. In: selects which of the losses to ignore, i.e.
4756  * NULL or value of zero means we care about all losses. Out: the loss
4757  * that occurs when converting from src to selected dst pixel format.
4758  * @return The best pixel format to convert to or -1 if none was found.
4759  */
4760 enum AVPixelFormat avcodec_find_best_pix_fmt_of_2(enum AVPixelFormat dst_pix_fmt1, enum AVPixelFormat dst_pix_fmt2,
4761  enum AVPixelFormat src_pix_fmt, int has_alpha, int *loss_ptr);
4762 
4764 #if AV_HAVE_INCOMPATIBLE_FORK_ABI
4766  enum AVPixelFormat src_pix_fmt,
4767  int has_alpha, int *loss_ptr);
4768 #else
4769 enum AVPixelFormat avcodec_find_best_pix_fmt2(enum AVPixelFormat dst_pix_fmt1, enum AVPixelFormat dst_pix_fmt2,
4770  enum AVPixelFormat src_pix_fmt, int has_alpha, int *loss_ptr);
4771 #endif
4772 
4773 
4775 
4776 /**
4777  * @}
4778  */
4779 
4781 
4782 /**
4783  * Put a string representing the codec tag codec_tag in buf.
4784  *
4785  * @param buf_size size in bytes of buf
4786  * @return the length of the string that would have been generated if
4787  * enough space had been available, excluding the trailing null
4788  */
4789 size_t av_get_codec_tag_string(char *buf, size_t buf_size, unsigned int codec_tag);
4790 
4791 void avcodec_string(char *buf, int buf_size, AVCodecContext *enc, int encode);
4792 
4793 /**
4794  * Return a name for the specified profile, if available.
4795  *
4796  * @param codec the codec that is searched for the given profile
4797  * @param profile the profile value for which a name is requested
4798  * @return A name for the profile if found, NULL otherwise.
4799  */
4800 const char *av_get_profile_name(const AVCodec *codec, int profile);
4801 
4802 int avcodec_default_execute(AVCodecContext *c, int (*func)(AVCodecContext *c2, void *arg2),void *arg, int *ret, int count, int size);
4803 int avcodec_default_execute2(AVCodecContext *c, int (*func)(AVCodecContext *c2, void *arg2, int, int),void *arg, int *ret, int count);
4804 //FIXME func typedef
4805 
4806 /**
4807  * Fill AVFrame audio data and linesize pointers.
4808  *
4809  * The buffer buf must be a preallocated buffer with a size big enough
4810  * to contain the specified samples amount. The filled AVFrame data
4811  * pointers will point to this buffer.
4812  *
4813  * AVFrame extended_data channel pointers are allocated if necessary for
4814  * planar audio.
4815  *
4816  * @param frame the AVFrame
4817  * frame->nb_samples must be set prior to calling the
4818  * function. This function fills in frame->data,
4819  * frame->extended_data, frame->linesize[0].
4820  * @param nb_channels channel count
4821  * @param sample_fmt sample format
4822  * @param buf buffer to use for frame data
4823  * @param buf_size size of buffer
4824  * @param align plane size sample alignment (0 = default)
4825  * @return >=0 on success, negative error code on failure
4826  * @todo return the size in bytes required to store the samples in
4827  * case of success, at the next libavutil bump
4828  */
4830  enum AVSampleFormat sample_fmt, const uint8_t *buf,
4831  int buf_size, int align);
4832 
4833 /**
4834  * Flush buffers, should be called when seeking or when switching to a different stream.
4835  */
4837 
4839 
4840 /**
4841  * Return codec bits per sample.
4842  *
4843  * @param[in] codec_id the codec
4844  * @return Number of bits per sample or zero if unknown for the given codec.
4845  */
4847 
4848 /**
4849  * Return the PCM codec associated with a sample format.
4850  * @param be endianness, 0 for little, 1 for big,
4851  * -1 (or anything else) for native
4852  * @return AV_CODEC_ID_PCM_* or AV_CODEC_ID_NONE
4853  */
4854 enum AVCodecID av_get_pcm_codec(enum AVSampleFormat fmt, int be);
4855 
4856 /**
4857  * Return codec bits per sample.
4858  * Only return non-zero if the bits per sample is exactly correct, not an
4859  * approximation.
4860  *
4861  * @param[in] codec_id the codec
4862  * @return Number of bits per sample or zero if unknown for the given codec.
4863  */
4865 
4866 /**
4867  * Return audio frame duration.
4868  *
4869  * @param avctx codec context
4870  * @param frame_bytes size of the frame, or 0 if unknown
4871  * @return frame duration, in samples, if known. 0 if not able to
4872  * determine.
4873  */
4874 int av_get_audio_frame_duration(AVCodecContext *avctx, int frame_bytes);
4875 
4878  void *priv_data;
4883 
4885 typedef struct AVBitStreamFilter {
4886  const char *name;
4888  int (*filter)(AVBitStreamFilterContext *bsfc,
4889  AVCodecContext *avctx, const char *args,
4890  uint8_t **poutbuf, int *poutbuf_size,
4891  const uint8_t *buf, int buf_size, int keyframe);
4893  struct AVBitStreamFilter *next;
4895 
4899  AVCodecContext *avctx, const char *args,
4900  uint8_t **poutbuf, int *poutbuf_size,
4901  const uint8_t *buf, int buf_size, int keyframe);
4903 
4905 
4906 /* memory */
4907 
4908 /**
4909  * Reallocate the given block if it is not large enough, otherwise do nothing.
4910  *
4911  * @see av_realloc
4912  */
4913 void *av_fast_realloc(void *ptr, unsigned int *size, size_t min_size);
4914 
4915 /**
4916  * Allocate a buffer, reusing the given one if large enough.
4917  *
4918  * Contrary to av_fast_realloc the current buffer contents might not be
4919  * preserved and on error the old buffer is freed, thus no special
4920  * handling to avoid memleaks is necessary.
4921  *
4922  * @param ptr pointer to pointer to already allocated buffer, overwritten with pointer to new buffer
4923  * @param size size of the buffer *ptr points to
4924  * @param min_size minimum size of *ptr buffer after returning, *ptr will be NULL and
4925  * *size 0 if an error occurred.
4926  */
4927 void av_fast_malloc(void *ptr, unsigned int *size, size_t min_size);
4928 
4929 /**
4930  * Same behaviour av_fast_malloc but the buffer has additional
4931  * FF_INPUT_BUFFER_PADDING_SIZE at the end which will will always be 0.
4932  *
4933  * In addition the whole buffer will initially and after resizes
4934  * be 0-initialized so that no uninitialized data will ever appear.
4935  */
4936 void av_fast_padded_malloc(void *ptr, unsigned int *size, size_t min_size);
4937 
4938 /**
4939  * Same behaviour av_fast_padded_malloc except that buffer will always
4940  * be 0-initialized after call.
4941  */
4942 void av_fast_padded_mallocz(void *ptr, unsigned int *size, size_t min_size);
4943 
4944 /**
4945  * Encode extradata length to a buffer. Used by xiph codecs.
4946  *
4947  * @param s buffer to write to; must be at least (v/255+1) bytes long
4948  * @param v size of extradata in bytes
4949  * @return number of bytes written to the buffer.
4950  */
4951 unsigned int av_xiphlacing(unsigned char *s, unsigned int v);
4952 
4953 /**
4954  * Log a generic warning message about a missing feature. This function is
4955  * intended to be used internally by FFmpeg (libavcodec, libavformat, etc.)
4956  * only, and would normally not be used by applications.
4957  * @param[in] avc a pointer to an arbitrary struct of which the first field is
4958  * a pointer to an AVClass struct
4959  * @param[in] feature string containing the name of the missing feature
4960  * @param[in] want_sample indicates if samples are wanted which exhibit this feature.
4961  * If want_sample is non-zero, additional verbage will be added to the log
4962  * message which tells the user how to report samples to the development
4963  * mailing list.
4964  */
4965 void av_log_missing_feature(void *avc, const char *feature, int want_sample);
4966 
4967 /**
4968  * Log a generic warning message asking for a sample. This function is
4969  * intended to be used internally by FFmpeg (libavcodec, libavformat, etc.)
4970  * only, and would normally not be used by applications.
4971  * @param[in] avc a pointer to an arbitrary struct of which the first field is
4972  * a pointer to an AVClass struct
4973  * @param[in] msg string containing an optional message, or NULL if no message
4974  */
4975 void av_log_ask_for_sample(void *avc, const char *msg, ...) av_printf_format(2, 3);
4976 
4977 /**
4978  * Register the hardware accelerator hwaccel.
4979  */
4980 void av_register_hwaccel(AVHWAccel *hwaccel);
4981 
4982 /**
4983  * If hwaccel is NULL, returns the first registered hardware accelerator,
4984  * if hwaccel is non-NULL, returns the next registered hardware accelerator
4985  * after hwaccel, or NULL if hwaccel is the last one.
4986  */
4988 
4989 
4990 /**
4991  * Lock operation used by lockmgr
4992  */
4993 enum AVLockOp {
4994  AV_LOCK_CREATE, ///< Create a mutex
4995  AV_LOCK_OBTAIN, ///< Lock the mutex
4996  AV_LOCK_RELEASE, ///< Unlock the mutex
4997  AV_LOCK_DESTROY, ///< Free mutex resources
4998 };
4999 
5000 /**
5001  * Register a user provided lock manager supporting the operations
5002  * specified by AVLockOp. mutex points to a (void *) where the
5003  * lockmgr should store/get a pointer to a user allocated mutex. It's
5004  * NULL upon AV_LOCK_CREATE and != NULL for all other ops.
5005  *
5006  * @param cb User defined callback. Note: FFmpeg may invoke calls to this
5007  * callback during the call to av_lockmgr_register().
5008  * Thus, the application must be prepared to handle that.
5009  * If cb is set to NULL the lockmgr will be unregistered.
5010  * Also note that during unregistration the previously registered
5011  * lockmgr callback may also be invoked.
5012  */
5013 int av_lockmgr_register(int (*cb)(void **mutex, enum AVLockOp op));
5014 
5015 /**
5016  * Get the type of the given codec.
5017  */
5019 
5020 /**
5021  * Get the name of a codec.
5022  * @return a static string identifying the codec; never NULL
5023  */
5024 const char *avcodec_get_name(enum AVCodecID id);
5025 
5026 /**
5027  * @return a positive value if s is open (i.e. avcodec_open2() was called on it
5028  * with no corresponding avcodec_close()), 0 otherwise.
5029  */
5031 
5032 /**
5033  * @return a non-zero number if codec is an encoder, zero otherwise
5034  */
5035 int av_codec_is_encoder(const AVCodec *codec);
5036 
5037 /**
5038  * @return a non-zero number if codec is a decoder, zero otherwise
5039  */
5040 int av_codec_is_decoder(const AVCodec *codec);
5041 
5042 /**
5043  * @return descriptor for given codec ID or NULL if no descriptor exists.
5044  */
5046 
5047 /**
5048  * Iterate over all codec descriptors known to libavcodec.
5049  *
5050  * @param prev previous descriptor. NULL to get the first descriptor.
5051  *
5052  * @return next descriptor or NULL after the last descriptor
5053  */
5055 
5056 /**
5057  * @return codec descriptor with the given name or NULL if no such descriptor
5058  * exists.
5059  */
5061 
5062 /**
5063  * @}
5064  */
5065 
5066 #endif /* AVCODEC_AVCODEC_H */