2 * copyright (c) 2001 Fabrice Bellard
4 * This file is part of Libav.
6 * Libav 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.
11 * Libav 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.
16 * You should have received a copy of the GNU Lesser General Public
17 * License along with Libav; if not, write to the Free Software
18 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
21 #ifndef AVCODEC_AVCODEC_H
22 #define AVCODEC_AVCODEC_H
30 #include "libavutil/samplefmt.h"
31 #include "libavutil/avutil.h"
32 #include "libavutil/cpu.h"
33 #include "libavutil/dict.h"
34 #include "libavutil/log.h"
35 #include "libavutil/pixfmt.h"
36 #include "libavutil/rational.h"
38 #include "libavcodec/version.h"
40 * @defgroup libavc Encoding/Decoding Library
43 * @defgroup lavc_decoding Decoding
47 * @defgroup lavc_encoding Encoding
51 * @defgroup lavc_codec Codecs
53 * @defgroup lavc_codec_native Native Codecs
56 * @defgroup lavc_codec_wrappers External library wrappers
59 * @defgroup lavc_codec_hwaccel Hardware Accelerators bridge
63 * @defgroup lavc_internal Internal
72 * Identify the syntax and semantics of the bitstream.
73 * The principle is roughly:
74 * Two decoders with the same ID can decode the same streams.
75 * Two encoders with the same ID can encode compatible streams.
76 * There may be slight deviations from the principle due to implementation
79 * If you add a codec ID to this list, add it so that
80 * 1. no value of a existing codec ID changes (that would break ABI),
81 * 2. it is as close as possible to similar codecs.
88 CODEC_ID_MPEG2VIDEO, ///< preferred ID for MPEG-1/2 video decoding
89 CODEC_ID_MPEG2VIDEO_XVMC,
126 CODEC_ID_INTERPLAY_VIDEO,
138 CODEC_ID_TRUEMOTION1,
165 CODEC_ID_TRUEMOTION2,
182 CODEC_ID_DSICINVIDEO,
183 CODEC_ID_TIERTEXSEQVIDEO,
191 CODEC_ID_BETHSOFTVID,
207 CODEC_ID_MOTIONPIXELS,
225 CODEC_ID_IFF_BYTERUN1,
251 /* various PCM "codecs" */
252 CODEC_ID_FIRST_AUDIO = 0x10000, ///< A dummy id pointing at the start of audio codecs
253 CODEC_ID_PCM_S16LE = 0x10000,
269 CODEC_ID_PCM_S24DAUD,
271 CODEC_ID_PCM_S16LE_PLANAR,
280 CODEC_ID_PCM_S8_PLANAR,
282 /* various ADPCM codecs */
283 CODEC_ID_ADPCM_IMA_QT = 0x11000,
284 CODEC_ID_ADPCM_IMA_WAV,
285 CODEC_ID_ADPCM_IMA_DK3,
286 CODEC_ID_ADPCM_IMA_DK4,
287 CODEC_ID_ADPCM_IMA_WS,
288 CODEC_ID_ADPCM_IMA_SMJPEG,
297 CODEC_ID_ADPCM_YAMAHA,
298 CODEC_ID_ADPCM_SBPRO_4,
299 CODEC_ID_ADPCM_SBPRO_3,
300 CODEC_ID_ADPCM_SBPRO_2,
302 CODEC_ID_ADPCM_IMA_AMV,
303 CODEC_ID_ADPCM_EA_R1,
304 CODEC_ID_ADPCM_EA_R3,
305 CODEC_ID_ADPCM_EA_R2,
306 CODEC_ID_ADPCM_IMA_EA_SEAD,
307 CODEC_ID_ADPCM_IMA_EA_EACS,
308 CODEC_ID_ADPCM_EA_XAS,
309 CODEC_ID_ADPCM_EA_MAXIS_XA,
310 CODEC_ID_ADPCM_IMA_ISS,
312 CODEC_ID_ADPCM_IMA_APC,
315 CODEC_ID_AMR_NB = 0x12000,
318 /* RealAudio codecs*/
319 CODEC_ID_RA_144 = 0x13000,
322 /* various DPCM codecs */
323 CODEC_ID_ROQ_DPCM = 0x14000,
324 CODEC_ID_INTERPLAY_DPCM,
329 CODEC_ID_MP2 = 0x15000,
330 CODEC_ID_MP3, ///< preferred ID for decoding MPEG audio layer 1, 2 or 3
346 CODEC_ID_WESTWOOD_SND1,
347 CODEC_ID_GSM, ///< as in Berlin toast format
355 CODEC_ID_DSICINAUDIO,
359 CODEC_ID_GSM_MS, /* as found in WAV */
368 CODEC_ID_WMALOSSLESS,
377 CODEC_ID_BINKAUDIO_RDFT,
378 CODEC_ID_BINKAUDIO_DCT,
389 /* subtitle codecs */
390 CODEC_ID_FIRST_SUBTITLE = 0x17000, ///< A dummy ID pointing at the start of subtitle codecs.
391 CODEC_ID_DVD_SUBTITLE = 0x17000,
392 CODEC_ID_DVB_SUBTITLE,
393 CODEC_ID_TEXT, ///< raw UTF-8 text
397 CODEC_ID_HDMV_PGS_SUBTITLE,
398 CODEC_ID_DVB_TELETEXT,
401 /* other specific kind of codecs (generally used for attachments) */
402 CODEC_ID_FIRST_UNKNOWN = 0x18000, ///< A dummy ID pointing at the start of various fake codecs.
403 CODEC_ID_TTF = 0x18000,
405 CODEC_ID_PROBE = 0x19000, ///< codec_id is not known (like CODEC_ID_NONE) but lavf should attempt to identify it
407 CODEC_ID_MPEG2TS = 0x20000, /**< _FAKE_ codec to indicate a raw MPEG-2 TS
408 * stream (only used by libavformat) */
409 CODEC_ID_MPEG4SYSTEMS = 0x20001, /**< _FAKE_ codec to indicate a MPEG-4 Systems
410 * stream (only used by libavformat) */
411 CODEC_ID_FFMETADATA = 0x21000, ///< Dummy codec for streams containing only metadata information.
414 #if FF_API_OLD_DECODE_AUDIO
416 #define AVCODEC_MAX_AUDIO_FRAME_SIZE 192000 // 1 second of 48khz 32bit audio
420 * Required number of additionally allocated bytes at the end of the input bitstream for decoding.
421 * This is mainly needed because some optimized bitstream readers read
422 * 32 or 64 bit at once and could read over the end.<br>
423 * Note: If the first 23 bits of the additional bytes are not 0, then damaged
424 * MPEG bitstreams could cause overread and segfault.
426 #define FF_INPUT_BUFFER_PADDING_SIZE 8
429 * minimum encoding buffer size
430 * Used to avoid some checks during header writing.
432 #define FF_MIN_BUFFER_SIZE 16384
436 * motion estimation type.
439 ME_ZERO = 1, ///< no search, that is use 0,0 vector whenever one is needed
443 ME_EPZS, ///< enhanced predictive zonal search
444 ME_X1, ///< reserved for experiments
445 ME_HEX, ///< hexagon based search
446 ME_UMH, ///< uneven multi-hexagon search
447 ME_ITER, ///< iterative search
448 ME_TESA, ///< transformed exhaustive search algorithm
452 /* We leave some space between them for extensions (drop some
453 * keyframes for intra-only or drop just some bidir frames). */
454 AVDISCARD_NONE =-16, ///< discard nothing
455 AVDISCARD_DEFAULT= 0, ///< discard useless packets like 0 size packets in avi
456 AVDISCARD_NONREF = 8, ///< discard all non reference
457 AVDISCARD_BIDIR = 16, ///< discard all bidirectional frames
458 AVDISCARD_NONKEY = 32, ///< discard all frames except keyframes
459 AVDISCARD_ALL = 48, ///< discard all
462 enum AVColorPrimaries{
463 AVCOL_PRI_BT709 =1, ///< also ITU-R BT1361 / IEC 61966-2-4 / SMPTE RP177 Annex B
464 AVCOL_PRI_UNSPECIFIED=2,
466 AVCOL_PRI_BT470BG =5, ///< also ITU-R BT601-6 625 / ITU-R BT1358 625 / ITU-R BT1700 625 PAL & SECAM
467 AVCOL_PRI_SMPTE170M =6, ///< also ITU-R BT601-6 525 / ITU-R BT1358 525 / ITU-R BT1700 NTSC
468 AVCOL_PRI_SMPTE240M =7, ///< functionally identical to above
470 AVCOL_PRI_NB , ///< Not part of ABI
473 enum AVColorTransferCharacteristic{
474 AVCOL_TRC_BT709 =1, ///< also ITU-R BT1361
475 AVCOL_TRC_UNSPECIFIED=2,
476 AVCOL_TRC_GAMMA22 =4, ///< also ITU-R BT470M / ITU-R BT1700 625 PAL & SECAM
477 AVCOL_TRC_GAMMA28 =5, ///< also ITU-R BT470BG
478 AVCOL_TRC_NB , ///< Not part of ABI
483 AVCOL_SPC_BT709 =1, ///< also ITU-R BT1361 / IEC 61966-2-4 xvYCC709 / SMPTE RP177 Annex B
484 AVCOL_SPC_UNSPECIFIED=2,
486 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
487 AVCOL_SPC_SMPTE170M =6, ///< also ITU-R BT601-6 525 / ITU-R BT1358 525 / ITU-R BT1700 NTSC / functionally identical to above
488 AVCOL_SPC_SMPTE240M =7,
489 AVCOL_SPC_NB , ///< Not part of ABI
493 AVCOL_RANGE_UNSPECIFIED=0,
494 AVCOL_RANGE_MPEG =1, ///< the normal 219*2^(n-8) "MPEG" YUV ranges
495 AVCOL_RANGE_JPEG =2, ///< the normal 2^n-1 "JPEG" YUV ranges
496 AVCOL_RANGE_NB , ///< Not part of ABI
500 * X X 3 4 X X are luma samples,
501 * 1 2 1-6 are possible chroma positions
502 * X X 5 6 X 0 is undefined/unknown position
504 enum AVChromaLocation{
505 AVCHROMA_LOC_UNSPECIFIED=0,
506 AVCHROMA_LOC_LEFT =1, ///< mpeg2/4, h264 default
507 AVCHROMA_LOC_CENTER =2, ///< mpeg1, jpeg, h263
508 AVCHROMA_LOC_TOPLEFT =3, ///< DV
510 AVCHROMA_LOC_BOTTOMLEFT =5,
511 AVCHROMA_LOC_BOTTOM =6,
512 AVCHROMA_LOC_NB , ///< Not part of ABI
515 enum AVAudioServiceType {
516 AV_AUDIO_SERVICE_TYPE_MAIN = 0,
517 AV_AUDIO_SERVICE_TYPE_EFFECTS = 1,
518 AV_AUDIO_SERVICE_TYPE_VISUALLY_IMPAIRED = 2,
519 AV_AUDIO_SERVICE_TYPE_HEARING_IMPAIRED = 3,
520 AV_AUDIO_SERVICE_TYPE_DIALOGUE = 4,
521 AV_AUDIO_SERVICE_TYPE_COMMENTARY = 5,
522 AV_AUDIO_SERVICE_TYPE_EMERGENCY = 6,
523 AV_AUDIO_SERVICE_TYPE_VOICE_OVER = 7,
524 AV_AUDIO_SERVICE_TYPE_KARAOKE = 8,
525 AV_AUDIO_SERVICE_TYPE_NB , ///< Not part of ABI
528 typedef struct RcOverride{
531 int qscale; // If this is 0 then quality_factor will be used instead.
532 float quality_factor;
535 #define FF_MAX_B_FRAMES 16
538 These flags can be passed in AVCodecContext.flags before initialization.
539 Note: Not everything is supported yet.
542 #define CODEC_FLAG_QSCALE 0x0002 ///< Use fixed qscale.
543 #define CODEC_FLAG_4MV 0x0004 ///< 4 MV per MB allowed / advanced prediction for H.263.
544 #define CODEC_FLAG_QPEL 0x0010 ///< Use qpel MC.
545 #define CODEC_FLAG_GMC 0x0020 ///< Use GMC.
546 #define CODEC_FLAG_MV0 0x0040 ///< Always try a MB with MV=<0,0>.
548 * The parent program guarantees that the input for B-frames containing
549 * streams is not written to for at least s->max_b_frames+1 frames, if
550 * this is not set the input will be copied.
552 #define CODEC_FLAG_INPUT_PRESERVED 0x0100
553 #define CODEC_FLAG_PASS1 0x0200 ///< Use internal 2pass ratecontrol in first pass mode.
554 #define CODEC_FLAG_PASS2 0x0400 ///< Use internal 2pass ratecontrol in second pass mode.
555 #define CODEC_FLAG_GRAY 0x2000 ///< Only decode/encode grayscale.
556 #define CODEC_FLAG_EMU_EDGE 0x4000 ///< Don't draw edges.
557 #define CODEC_FLAG_PSNR 0x8000 ///< error[?] variables will be set during encoding.
558 #define CODEC_FLAG_TRUNCATED 0x00010000 /** Input bitstream might be truncated at a random
559 location instead of only at frame boundaries. */
560 #define CODEC_FLAG_NORMALIZE_AQP 0x00020000 ///< Normalize adaptive quantization.
561 #define CODEC_FLAG_INTERLACED_DCT 0x00040000 ///< Use interlaced DCT.
562 #define CODEC_FLAG_LOW_DELAY 0x00080000 ///< Force low delay.
563 #define CODEC_FLAG_GLOBAL_HEADER 0x00400000 ///< Place global headers in extradata instead of every keyframe.
564 #define CODEC_FLAG_BITEXACT 0x00800000 ///< Use only bitexact stuff (except (I)DCT).
565 /* Fx : Flag for h263+ extra options */
566 #define CODEC_FLAG_AC_PRED 0x01000000 ///< H.263 advanced intra coding / MPEG-4 AC prediction
567 #define CODEC_FLAG_LOOP_FILTER 0x00000800 ///< loop filter
568 #define CODEC_FLAG_INTERLACED_ME 0x20000000 ///< interlaced motion estimation
569 #define CODEC_FLAG_CLOSED_GOP 0x80000000
570 #define CODEC_FLAG2_FAST 0x00000001 ///< Allow non spec compliant speedup tricks.
571 #define CODEC_FLAG2_NO_OUTPUT 0x00000004 ///< Skip bitstream encoding.
572 #define CODEC_FLAG2_LOCAL_HEADER 0x00000008 ///< Place global headers at every keyframe instead of in extradata.
573 #if FF_API_MPV_GLOBAL_OPTS
574 #define CODEC_FLAG_CBP_RD 0x04000000 ///< Use rate distortion optimization for cbp.
575 #define CODEC_FLAG_QP_RD 0x08000000 ///< Use rate distortion optimization for qp selectioon.
576 #define CODEC_FLAG2_STRICT_GOP 0x00000002 ///< Strictly enforce GOP size.
577 #define CODEC_FLAG2_SKIP_RD 0x00004000 ///< RD optimal MB level residual skipping
579 #define CODEC_FLAG2_CHUNKS 0x00008000 ///< Input bitstream might be truncated at a packet boundaries instead of only at frame boundaries.
581 /* Unsupported options :
582 * Syntax Arithmetic coding (SAC)
583 * Reference Picture Selection
584 * Independent Segment Decoding */
586 /* codec capabilities */
588 #define CODEC_CAP_DRAW_HORIZ_BAND 0x0001 ///< Decoder can use draw_horiz_band callback.
590 * Codec uses get_buffer() for allocating buffers and supports custom allocators.
591 * If not set, it might not use get_buffer() at all or use operations that
592 * assume the buffer was allocated by avcodec_default_get_buffer.
594 #define CODEC_CAP_DR1 0x0002
595 #define CODEC_CAP_TRUNCATED 0x0008
596 /* Codec can export data for HW decoding (XvMC). */
597 #define CODEC_CAP_HWACCEL 0x0010
599 * Encoder or decoder requires flushing with NULL input at the end in order to
600 * give the complete and correct output.
602 * NOTE: If this flag is not set, the codec is guaranteed to never be fed with
603 * with NULL data. The user can still send NULL data to the public encode
604 * or decode function, but libavcodec will not pass it along to the codec
605 * unless this flag is set.
608 * The decoder has a non-zero delay and needs to be fed with avpkt->data=NULL,
609 * avpkt->size=0 at the end to get the delayed data until the decoder no longer
613 * The encoder needs to be fed with NULL data at the end of encoding until the
614 * encoder no longer returns data.
616 * NOTE: For encoders implementing the AVCodec.encode2() function, setting this
617 * flag also means that the encoder must set the pts and duration for
618 * each output packet. If this flag is not set, the pts and duration will
619 * be determined by libavcodec from the input frame.
621 #define CODEC_CAP_DELAY 0x0020
623 * Codec can be fed a final frame with a smaller size.
624 * This can be used to prevent truncation of the last audio samples.
626 #define CODEC_CAP_SMALL_LAST_FRAME 0x0040
628 * Codec can export data for HW decoding (VDPAU).
630 #define CODEC_CAP_HWACCEL_VDPAU 0x0080
632 * Codec can output multiple frames per AVPacket
633 * Normally demuxers return one frame at a time, demuxers which do not do
634 * are connected to a parser to split what they return into proper frames.
635 * This flag is reserved to the very rare category of codecs which have a
636 * bitstream that cannot be split into frames without timeconsuming
637 * operations like full decoding. Demuxers carring such bitstreams thus
638 * may return multiple frames in a packet. This has many disadvantages like
639 * prohibiting stream copy in many cases thus it should only be considered
642 #define CODEC_CAP_SUBFRAMES 0x0100
644 * Codec is experimental and is thus avoided in favor of non experimental
647 #define CODEC_CAP_EXPERIMENTAL 0x0200
649 * Codec should fill in channel configuration and samplerate instead of container
651 #define CODEC_CAP_CHANNEL_CONF 0x0400
653 * Codec is able to deal with negative linesizes
655 #define CODEC_CAP_NEG_LINESIZES 0x0800
657 * Codec supports frame-level multithreading.
659 #define CODEC_CAP_FRAME_THREADS 0x1000
661 * Codec supports slice-based (or partition-based) multithreading.
663 #define CODEC_CAP_SLICE_THREADS 0x2000
665 * Codec supports changed parameters at any point.
667 #define CODEC_CAP_PARAM_CHANGE 0x4000
669 * Codec supports avctx->thread_count == 0 (auto).
671 #define CODEC_CAP_AUTO_THREADS 0x8000
673 * Audio encoder supports receiving a different number of samples in each call.
675 #define CODEC_CAP_VARIABLE_FRAME_SIZE 0x10000
677 //The following defines may change, don't expect compatibility if you use them.
678 #define MB_TYPE_INTRA4x4 0x0001
679 #define MB_TYPE_INTRA16x16 0x0002 //FIXME H.264-specific
680 #define MB_TYPE_INTRA_PCM 0x0004 //FIXME H.264-specific
681 #define MB_TYPE_16x16 0x0008
682 #define MB_TYPE_16x8 0x0010
683 #define MB_TYPE_8x16 0x0020
684 #define MB_TYPE_8x8 0x0040
685 #define MB_TYPE_INTERLACED 0x0080
686 #define MB_TYPE_DIRECT2 0x0100 //FIXME
687 #define MB_TYPE_ACPRED 0x0200
688 #define MB_TYPE_GMC 0x0400
689 #define MB_TYPE_SKIP 0x0800
690 #define MB_TYPE_P0L0 0x1000
691 #define MB_TYPE_P1L0 0x2000
692 #define MB_TYPE_P0L1 0x4000
693 #define MB_TYPE_P1L1 0x8000
694 #define MB_TYPE_L0 (MB_TYPE_P0L0 | MB_TYPE_P1L0)
695 #define MB_TYPE_L1 (MB_TYPE_P0L1 | MB_TYPE_P1L1)
696 #define MB_TYPE_L0L1 (MB_TYPE_L0 | MB_TYPE_L1)
697 #define MB_TYPE_QUANT 0x00010000
698 #define MB_TYPE_CBP 0x00020000
699 //Note bits 24-31 are reserved for codec specific use (h264 ref0, mpeg1 0mv, ...)
703 * This specifies the area which should be displayed.
704 * Note there may be multiple such areas for one frame.
706 typedef struct AVPanScan{
709 * - encoding: Set by user.
710 * - decoding: Set by libavcodec.
715 * width and height in 1/16 pel
716 * - encoding: Set by user.
717 * - decoding: Set by libavcodec.
723 * position of the top left corner in 1/16 pel for up to 3 fields/frames
724 * - encoding: Set by user.
725 * - decoding: Set by libavcodec.
727 int16_t position[3][2];
730 #define FF_QSCALE_TYPE_MPEG1 0
731 #define FF_QSCALE_TYPE_MPEG2 1
732 #define FF_QSCALE_TYPE_H264 2
733 #define FF_QSCALE_TYPE_VP56 3
735 #define FF_BUFFER_TYPE_INTERNAL 1
736 #define FF_BUFFER_TYPE_USER 2 ///< direct rendering buffers (image is (de)allocated by user)
737 #define FF_BUFFER_TYPE_SHARED 4 ///< Buffer from somewhere else; don't deallocate image (data/base), all other tables are not shared.
738 #define FF_BUFFER_TYPE_COPY 8 ///< Just a (modified) copy of some other buffer, don't deallocate anything.
740 #define FF_BUFFER_HINTS_VALID 0x01 // Buffer hints value is meaningful (if 0 ignore).
741 #define FF_BUFFER_HINTS_READABLE 0x02 // Codec will read from buffer.
742 #define FF_BUFFER_HINTS_PRESERVE 0x04 // User must not alter buffer content.
743 #define FF_BUFFER_HINTS_REUSABLE 0x08 // Codec will reuse the buffer (update).
745 enum AVPacketSideDataType {
747 AV_PKT_DATA_NEW_EXTRADATA,
748 AV_PKT_DATA_PARAM_CHANGE,
749 AV_PKT_DATA_H263_MB_INFO,
752 typedef struct AVPacket {
754 * Presentation timestamp in AVStream->time_base units; the time at which
755 * the decompressed packet will be presented to the user.
756 * Can be AV_NOPTS_VALUE if it is not stored in the file.
757 * pts MUST be larger or equal to dts as presentation cannot happen before
758 * decompression, unless one wants to view hex dumps. Some formats misuse
759 * the terms dts and pts/cts to mean something different. Such timestamps
760 * must be converted to true pts/dts before they are stored in AVPacket.
764 * Decompression timestamp in AVStream->time_base units; the time at which
765 * the packet is decompressed.
766 * Can be AV_NOPTS_VALUE if it is not stored in the file.
773 * A combination of AV_PKT_FLAG values
777 * Additional packet data that can be provided by the container.
778 * Packet can contain several types of side information.
783 enum AVPacketSideDataType type;
788 * Duration of this packet in AVStream->time_base units, 0 if unknown.
789 * Equals next_pts - this_pts in presentation order.
792 void (*destruct)(struct AVPacket *);
794 int64_t pos; ///< byte position in stream, -1 if unknown
797 * Time difference in AVStream->time_base units from the pts of this
798 * packet to the point at which the output from the decoder has converged
799 * independent from the availability of previous frames. That is, the
800 * frames are virtually identical no matter if decoding started from
801 * the very first frame or from this keyframe.
802 * Is AV_NOPTS_VALUE if unknown.
803 * This field is not the display duration of the current packet.
804 * This field has no meaning if the packet does not have AV_PKT_FLAG_KEY
807 * The purpose of this field is to allow seeking in streams that have no
808 * keyframes in the conventional sense. It corresponds to the
809 * recovery point SEI in H.264 and match_time_delta in NUT. It is also
810 * essential for some types of subtitle streams to ensure that all
811 * subtitles are correctly displayed after seeking.
813 int64_t convergence_duration;
815 #define AV_PKT_FLAG_KEY 0x0001 ///< The packet contains a keyframe
816 #define AV_PKT_FLAG_CORRUPT 0x0002 ///< The packet content is corrupted
819 * An AV_PKT_DATA_PARAM_CHANGE side data packet is laid out as follows:
821 * if (param_flags & AV_SIDE_DATA_PARAM_CHANGE_CHANNEL_COUNT)
822 * s32le channel_count
823 * if (param_flags & AV_SIDE_DATA_PARAM_CHANGE_CHANNEL_LAYOUT)
824 * u64le channel_layout
825 * if (param_flags & AV_SIDE_DATA_PARAM_CHANGE_SAMPLE_RATE)
827 * if (param_flags & AV_SIDE_DATA_PARAM_CHANGE_DIMENSIONS)
833 * An AV_PKT_DATA_H263_MB_INFO side data packet contains a number of
834 * structures with info about macroblocks relevant to splitting the
835 * packet into smaller packets on macroblock edges (e.g. as for RFC 2190).
836 * That is, it does not necessarily contain info about all macroblocks,
837 * as long as the distance between macroblocks in the info is smaller
838 * than the target payload size.
839 * Each MB info structure is 12 bytes, and is laid out as follows:
840 * u32le bit offset from the start of the packet
841 * u8 current quantizer at the start of the macroblock
843 * u16le macroblock address within the GOB
844 * u8 horizontal MV predictor
845 * u8 vertical MV predictor
846 * u8 horizontal MV predictor for block number 3
847 * u8 vertical MV predictor for block number 3
850 enum AVSideDataParamChangeFlags {
851 AV_SIDE_DATA_PARAM_CHANGE_CHANNEL_COUNT = 0x0001,
852 AV_SIDE_DATA_PARAM_CHANGE_CHANNEL_LAYOUT = 0x0002,
853 AV_SIDE_DATA_PARAM_CHANGE_SAMPLE_RATE = 0x0004,
854 AV_SIDE_DATA_PARAM_CHANGE_DIMENSIONS = 0x0008,
859 * New fields can be added to the end of AVFRAME with minor version
860 * bumps. Removal, reordering and changes to existing fields require
861 * a major version bump.
862 * sizeof(AVFrame) must not be used outside libav*.
864 typedef struct AVFrame {
865 #define AV_NUM_DATA_POINTERS 8
867 * pointer to the picture/channel planes.
868 * This might be different from the first allocated byte
869 * - encoding: Set by user
870 * - decoding: set by AVCodecContext.get_buffer()
872 uint8_t *data[AV_NUM_DATA_POINTERS];
875 * Size, in bytes, of the data for each picture/channel plane.
877 * For audio, only linesize[0] may be set. For planar audio, each channel
878 * plane must be the same size.
880 * - encoding: Set by user
881 * - decoding: set by AVCodecContext.get_buffer()
883 int linesize[AV_NUM_DATA_POINTERS];
886 * pointers to the data planes/channels.
888 * For video, this should simply point to data[].
890 * For planar audio, each channel has a separate data pointer, and
891 * linesize[0] contains the size of each channel buffer.
892 * For packed audio, there is just one data pointer, and linesize[0]
893 * contains the total size of the buffer for all channels.
895 * Note: Both data and extended_data will always be set by get_buffer(),
896 * but for planar audio with more channels that can fit in data,
897 * extended_data must be used by the decoder in order to access all
901 * decoding: set by AVCodecContext.get_buffer()
903 uint8_t **extended_data;
906 * width and height of the video frame
908 * - decoding: Read by user.
913 * number of audio samples (per channel) described by this frame
914 * - encoding: Set by user
915 * - decoding: Set by libavcodec
920 * format of the frame, -1 if unknown or unset
921 * Values correspond to enum PixelFormat for video frames,
922 * enum AVSampleFormat for audio)
924 * - decoding: Read by user.
929 * 1 -> keyframe, 0-> not
930 * - encoding: Set by libavcodec.
931 * - decoding: Set by libavcodec.
936 * Picture type of the frame, see ?_TYPE below.
937 * - encoding: Set by libavcodec. for coded_picture (and set by user for input).
938 * - decoding: Set by libavcodec.
940 enum AVPictureType pict_type;
943 * pointer to the first allocated byte of the picture. Can be used in get_buffer/release_buffer.
944 * This isn't used by libavcodec unless the default get/release_buffer() is used.
948 uint8_t *base[AV_NUM_DATA_POINTERS];
951 * sample aspect ratio for the video frame, 0/1 if unknown\unspecified
953 * - decoding: Read by user.
955 AVRational sample_aspect_ratio;
958 * presentation timestamp in time_base units (time when frame should be shown to user)
959 * If AV_NOPTS_VALUE then frame_rate = 1/time_base will be assumed.
960 * - encoding: MUST be set by user.
961 * - decoding: Set by libavcodec.
966 * reordered pts from the last AVPacket that has been input into the decoder
968 * - decoding: Read by user.
973 * dts from the last AVPacket that has been input into the decoder
975 * - decoding: Read by user.
980 * picture number in bitstream order
982 * - decoding: Set by libavcodec.
984 int coded_picture_number;
986 * picture number in display order
988 * - decoding: Set by libavcodec.
990 int display_picture_number;
993 * quality (between 1 (good) and FF_LAMBDA_MAX (bad))
994 * - encoding: Set by libavcodec. for coded_picture (and set by user for input).
995 * - decoding: Set by libavcodec.
1000 * is this picture used as reference
1001 * The values for this are the same as the MpegEncContext.picture_structure
1002 * variable, that is 1->top field, 2->bottom field, 3->frame/both fields.
1003 * Set to 4 for delayed, non-reference frames.
1004 * - encoding: unused
1005 * - decoding: Set by libavcodec. (before get_buffer() call)).
1011 * - encoding: unused
1012 * - decoding: Set by libavcodec.
1014 int8_t *qscale_table;
1017 * - encoding: unused
1018 * - decoding: Set by libavcodec.
1028 * mbskip_table[mb]>=1 if MB didn't change
1029 * stride= mb_width = (width+15)>>4
1030 * - encoding: unused
1031 * - decoding: Set by libavcodec.
1033 uint8_t *mbskip_table;
1036 * motion vector table
1039 * int mv_sample_log2= 4 - motion_subsample_log2;
1040 * int mb_width= (width+15)>>4;
1041 * int mv_stride= (mb_width << mv_sample_log2) + 1;
1042 * motion_val[direction][x + y*mv_stride][0->mv_x, 1->mv_y];
1044 * - encoding: Set by user.
1045 * - decoding: Set by libavcodec.
1047 int16_t (*motion_val[2])[2];
1050 * macroblock type table
1051 * mb_type_base + mb_width + 2
1052 * - encoding: Set by user.
1053 * - decoding: Set by libavcodec.
1059 * - encoding: unused
1060 * - decoding: Set by libavcodec.
1065 * motion reference frame index
1066 * the order in which these are stored can depend on the codec.
1067 * - encoding: Set by user.
1068 * - decoding: Set by libavcodec.
1070 int8_t *ref_index[2];
1073 * for some private data of the user
1074 * - encoding: unused
1075 * - decoding: Set by user.
1081 * - encoding: Set by libavcodec. if flags&CODEC_FLAG_PSNR.
1082 * - decoding: unused
1084 uint64_t error[AV_NUM_DATA_POINTERS];
1087 * type of the buffer (to keep track of who has to deallocate data[*])
1088 * - encoding: Set by the one who allocates it.
1089 * - decoding: Set by the one who allocates it.
1090 * Note: User allocated (direct rendering) & internal buffers cannot coexist currently.
1095 * When decoding, this signals how much the picture must be delayed.
1096 * extra_delay = repeat_pict / (2*fps)
1097 * - encoding: unused
1098 * - decoding: Set by libavcodec.
1103 * The content of the picture is interlaced.
1104 * - encoding: Set by user.
1105 * - decoding: Set by libavcodec. (default 0)
1107 int interlaced_frame;
1110 * If the content is interlaced, is top field displayed first.
1111 * - encoding: Set by user.
1112 * - decoding: Set by libavcodec.
1114 int top_field_first;
1117 * Tell user application that palette has changed from previous frame.
1118 * - encoding: ??? (no palette-enabled encoder yet)
1119 * - decoding: Set by libavcodec. (default 0).
1121 int palette_has_changed;
1124 * codec suggestion on buffer type if != 0
1125 * - encoding: unused
1126 * - decoding: Set by libavcodec. (before get_buffer() call)).
1132 * - encoding: Set by user.
1133 * - decoding: Set by libavcodec.
1135 AVPanScan *pan_scan;
1138 * reordered opaque 64bit (generally an integer or a double precision float
1139 * PTS but can be anything).
1140 * The user sets AVCodecContext.reordered_opaque to represent the input at
1142 * the decoder reorders values as needed and sets AVFrame.reordered_opaque
1143 * to exactly one of the values provided by the user through AVCodecContext.reordered_opaque
1144 * @deprecated in favor of pkt_pts
1145 * - encoding: unused
1146 * - decoding: Read by user.
1148 int64_t reordered_opaque;
1151 * hardware accelerator private data (Libav-allocated)
1152 * - encoding: unused
1153 * - decoding: Set by libavcodec
1155 void *hwaccel_picture_private;
1158 * the AVCodecContext which ff_thread_get_buffer() was last called on
1159 * - encoding: Set by libavcodec.
1160 * - decoding: Set by libavcodec.
1162 struct AVCodecContext *owner;
1165 * used by multithreading to store frame-specific info
1166 * - encoding: Set by libavcodec.
1167 * - decoding: Set by libavcodec.
1169 void *thread_opaque;
1172 * log2 of the size of the block which a single vector in motion_val represents:
1173 * (4->16x16, 3->8x8, 2-> 4x4, 1-> 2x2)
1174 * - encoding: unused
1175 * - decoding: Set by libavcodec.
1177 uint8_t motion_subsample_log2;
1180 struct AVCodecInternal;
1184 AV_FIELD_PROGRESSIVE,
1185 AV_FIELD_TT, //< Top coded_first, top displayed first
1186 AV_FIELD_BB, //< Bottom coded first, bottom displayed first
1187 AV_FIELD_TB, //< Top coded first, bottom displayed first
1188 AV_FIELD_BT, //< Bottom coded first, top displayed first
1192 * main external API structure.
1193 * New fields can be added to the end with minor version bumps.
1194 * Removal, reordering and changes to existing fields require a major
1196 * sizeof(AVCodecContext) must not be used outside libav*.
1198 typedef struct AVCodecContext {
1200 * information on struct for av_log
1201 * - set by avcodec_alloc_context3
1203 const AVClass *av_class;
1204 int log_level_offset;
1206 enum AVMediaType codec_type; /* see AVMEDIA_TYPE_xxx */
1207 struct AVCodec *codec;
1208 char codec_name[32];
1209 enum CodecID codec_id; /* see CODEC_ID_xxx */
1212 * fourcc (LSB first, so "ABCD" -> ('D'<<24) + ('C'<<16) + ('B'<<8) + 'A').
1213 * This is used to work around some encoder bugs.
1214 * A demuxer should set this to what is stored in the field used to identify the codec.
1215 * If there are multiple such fields in a container then the demuxer should choose the one
1216 * which maximizes the information about the used codec.
1217 * If the codec tag field in a container is larger than 32 bits then the demuxer should
1218 * remap the longer ID to 32 bits with a table or other structure. Alternatively a new
1219 * extra_codec_tag + size could be added but for this a clear advantage must be demonstrated
1221 * - encoding: Set by user, if not then the default based on codec_id will be used.
1222 * - decoding: Set by user, will be converted to uppercase by libavcodec during init.
1224 unsigned int codec_tag;
1227 * fourcc from the AVI stream header (LSB first, so "ABCD" -> ('D'<<24) + ('C'<<16) + ('B'<<8) + 'A').
1228 * This is used to work around some encoder bugs.
1229 * - encoding: unused
1230 * - decoding: Set by user, will be converted to uppercase by libavcodec during init.
1232 unsigned int stream_codec_tag;
1236 * @deprecated this field is unused
1238 attribute_deprecated int sub_id;
1244 * Private context used for internal data.
1246 * Unlike priv_data, this is not codec-specific. It is used in general
1247 * libavcodec functions.
1249 struct AVCodecInternal *internal;
1252 * Private data of the user, can be used to carry app specific stuff.
1253 * - encoding: Set by user.
1254 * - decoding: Set by user.
1259 * the average bitrate
1260 * - encoding: Set by user; unused for constant quantizer encoding.
1261 * - decoding: Set by libavcodec. 0 or some bitrate if this info is available in the stream.
1266 * number of bits the bitstream is allowed to diverge from the reference.
1267 * the reference can be CBR (for CBR pass1) or VBR (for pass2)
1268 * - encoding: Set by user; unused for constant quantizer encoding.
1269 * - decoding: unused
1271 int bit_rate_tolerance;
1274 * Global quality for codecs which cannot change it per frame.
1275 * This should be proportional to MPEG-1/2/4 qscale.
1276 * - encoding: Set by user.
1277 * - decoding: unused
1282 * - encoding: Set by user.
1283 * - decoding: unused
1285 int compression_level;
1286 #define FF_COMPRESSION_DEFAULT -1
1290 * - encoding: Set by user.
1291 * - decoding: Set by user.
1297 * - encoding: Set by user.
1298 * - decoding: Set by user.
1303 * some codecs need / can use extradata like Huffman tables.
1304 * mjpeg: Huffman tables
1305 * rv10: additional flags
1306 * mpeg4: global headers (they can be in the bitstream or here)
1307 * The allocated memory should be FF_INPUT_BUFFER_PADDING_SIZE bytes larger
1308 * than extradata_size to avoid prolems if it is read with the bitstream reader.
1309 * The bytewise contents of extradata must not depend on the architecture or CPU endianness.
1310 * - encoding: Set/allocated/freed by libavcodec.
1311 * - decoding: Set/allocated/freed by user.
1317 * This is the fundamental unit of time (in seconds) in terms
1318 * of which frame timestamps are represented. For fixed-fps content,
1319 * timebase should be 1/framerate and timestamp increments should be
1321 * - encoding: MUST be set by user.
1322 * - decoding: Set by libavcodec.
1324 AVRational time_base;
1327 * For some codecs, the time base is closer to the field rate than the frame rate.
1328 * Most notably, H.264 and MPEG-2 specify time_base as half of frame duration
1329 * if no telecine is used ...
1331 * Set to time_base ticks per frame. Default 1, e.g., H.264/MPEG-2 set it to 2.
1333 int ticks_per_frame;
1339 * Number of frames the decoded output will be delayed relative to the
1343 * Number of "priming" samples added to the beginning of the stream
1344 * during encoding. The decoded output will be delayed by this many
1345 * samples relative to the input to the encoder. Note that this field is
1346 * purely informational and does not directly affect the pts output by
1347 * the encoder, which should always be based on the actual presentation
1348 * time, including any delay.
1350 * - encoding: Set by libavcodec.
1351 * - decoding: unused
1358 * picture width / height.
1359 * - encoding: MUST be set by user.
1360 * - decoding: Set by libavcodec.
1361 * Note: For compatibility it is possible to set this instead of
1362 * coded_width/height before decoding.
1367 * Bitstream width / height, may be different from width/height if lowres enabled.
1368 * - encoding: unused
1369 * - decoding: Set by user before init if known. Codec should override / dynamically change if needed.
1371 int coded_width, coded_height;
1373 #define FF_ASPECT_EXTENDED 15
1376 * the number of pictures in a group of pictures, or 0 for intra_only
1377 * - encoding: Set by user.
1378 * - decoding: unused
1383 * Pixel format, see PIX_FMT_xxx.
1384 * May be set by the demuxer if known from headers.
1385 * May be overriden by the decoder if it knows better.
1386 * - encoding: Set by user.
1387 * - decoding: Set by user if known, overridden by libavcodec if known
1389 enum PixelFormat pix_fmt;
1392 * Motion estimation algorithm used for video coding.
1393 * 1 (zero), 2 (full), 3 (log), 4 (phods), 5 (epzs), 6 (x1), 7 (hex),
1394 * 8 (umh), 9 (iter), 10 (tesa) [7, 8, 10 are x264 specific, 9 is snow specific]
1395 * - encoding: MUST be set by user.
1396 * - decoding: unused
1401 * If non NULL, 'draw_horiz_band' is called by the libavcodec
1402 * decoder to draw a horizontal band. It improves cache usage. Not
1403 * all codecs can do that. You must check the codec capabilities
1405 * When multithreading is used, it may be called from multiple threads
1406 * at the same time; threads might draw different parts of the same AVFrame,
1407 * or multiple AVFrames, and there is no guarantee that slices will be drawn
1409 * The function is also used by hardware acceleration APIs.
1410 * It is called at least once during frame decoding to pass
1411 * the data needed for hardware render.
1412 * In that mode instead of pixel data, AVFrame points to
1413 * a structure specific to the acceleration API. The application
1414 * reads the structure and can change some fields to indicate progress
1416 * - encoding: unused
1417 * - decoding: Set by user.
1418 * @param height the height of the slice
1419 * @param y the y position of the slice
1420 * @param type 1->top field, 2->bottom field, 3->frame
1421 * @param offset offset into the AVFrame.data from which the slice should be read
1423 void (*draw_horiz_band)(struct AVCodecContext *s,
1424 const AVFrame *src, int offset[AV_NUM_DATA_POINTERS],
1425 int y, int type, int height);
1428 * callback to negotiate the pixelFormat
1429 * @param fmt is the list of formats which are supported by the codec,
1430 * it is terminated by -1 as 0 is a valid format, the formats are ordered by quality.
1431 * The first is always the native one.
1432 * @return the chosen format
1433 * - encoding: unused
1434 * - decoding: Set by user, if not set the native format will be chosen.
1436 enum PixelFormat (*get_format)(struct AVCodecContext *s, const enum PixelFormat * fmt);
1439 * maximum number of B-frames between non-B-frames
1440 * Note: The output will be delayed by max_b_frames+1 relative to the input.
1441 * - encoding: Set by user.
1442 * - decoding: unused
1447 * qscale factor between IP and B-frames
1448 * If > 0 then the last P-frame quantizer will be used (q= lastp_q*factor+offset).
1449 * If < 0 then normal ratecontrol will be done (q= -normal_q*factor+offset).
1450 * - encoding: Set by user.
1451 * - decoding: unused
1453 float b_quant_factor;
1455 /** obsolete FIXME remove */
1457 #define FF_RC_STRATEGY_XVID 1
1459 int b_frame_strategy;
1461 #if FF_API_MPV_GLOBAL_OPTS
1463 * luma single coefficient elimination threshold
1464 * - encoding: Set by user.
1465 * - decoding: unused
1467 attribute_deprecated int luma_elim_threshold;
1470 * chroma single coeff elimination threshold
1471 * - encoding: Set by user.
1472 * - decoding: unused
1474 attribute_deprecated int chroma_elim_threshold;
1478 * qscale offset between IP and B-frames
1479 * - encoding: Set by user.
1480 * - decoding: unused
1482 float b_quant_offset;
1485 * Size of the frame reordering buffer in the decoder.
1486 * For MPEG-2 it is 1 IPB or 0 low delay IP.
1487 * - encoding: Set by libavcodec.
1488 * - decoding: Set by libavcodec.
1493 * 0-> h263 quant 1-> mpeg quant
1494 * - encoding: Set by user.
1495 * - decoding: unused
1500 * qscale factor between P and I-frames
1501 * If > 0 then the last p frame quantizer will be used (q= lastp_q*factor+offset).
1502 * If < 0 then normal ratecontrol will be done (q= -normal_q*factor+offset).
1503 * - encoding: Set by user.
1504 * - decoding: unused
1506 float i_quant_factor;
1509 * qscale offset between P and I-frames
1510 * - encoding: Set by user.
1511 * - decoding: unused
1513 float i_quant_offset;
1516 * luminance masking (0-> disabled)
1517 * - encoding: Set by user.
1518 * - decoding: unused
1523 * temporary complexity masking (0-> disabled)
1524 * - encoding: Set by user.
1525 * - decoding: unused
1527 float temporal_cplx_masking;
1530 * spatial complexity masking (0-> disabled)
1531 * - encoding: Set by user.
1532 * - decoding: unused
1534 float spatial_cplx_masking;
1537 * p block masking (0-> disabled)
1538 * - encoding: Set by user.
1539 * - decoding: unused
1544 * darkness masking (0-> disabled)
1545 * - encoding: Set by user.
1546 * - decoding: unused
1552 * - encoding: Set by libavcodec.
1553 * - decoding: Set by user (or 0).
1557 * prediction method (needed for huffyuv)
1558 * - encoding: Set by user.
1559 * - decoding: unused
1561 int prediction_method;
1562 #define FF_PRED_LEFT 0
1563 #define FF_PRED_PLANE 1
1564 #define FF_PRED_MEDIAN 2
1567 * slice offsets in the frame in bytes
1568 * - encoding: Set/allocated by libavcodec.
1569 * - decoding: Set/allocated by user (or NULL).
1574 * sample aspect ratio (0 if unknown)
1575 * That is the width of a pixel divided by the height of the pixel.
1576 * Numerator and denominator must be relatively prime and smaller than 256 for some video standards.
1577 * - encoding: Set by user.
1578 * - decoding: Set by libavcodec.
1580 AVRational sample_aspect_ratio;
1583 * motion estimation comparison function
1584 * - encoding: Set by user.
1585 * - decoding: unused
1589 * subpixel motion estimation comparison function
1590 * - encoding: Set by user.
1591 * - decoding: unused
1595 * macroblock comparison function (not supported yet)
1596 * - encoding: Set by user.
1597 * - decoding: unused
1601 * interlaced DCT comparison function
1602 * - encoding: Set by user.
1603 * - decoding: unused
1606 #define FF_CMP_SAD 0
1607 #define FF_CMP_SSE 1
1608 #define FF_CMP_SATD 2
1609 #define FF_CMP_DCT 3
1610 #define FF_CMP_PSNR 4
1611 #define FF_CMP_BIT 5
1613 #define FF_CMP_ZERO 7
1614 #define FF_CMP_VSAD 8
1615 #define FF_CMP_VSSE 9
1616 #define FF_CMP_NSSE 10
1617 #define FF_CMP_W53 11
1618 #define FF_CMP_W97 12
1619 #define FF_CMP_DCTMAX 13
1620 #define FF_CMP_DCT264 14
1621 #define FF_CMP_CHROMA 256
1624 * ME diamond size & shape
1625 * - encoding: Set by user.
1626 * - decoding: unused
1631 * amount of previous MV predictors (2a+1 x 2a+1 square)
1632 * - encoding: Set by user.
1633 * - decoding: unused
1635 int last_predictor_count;
1638 * prepass for motion estimation
1639 * - encoding: Set by user.
1640 * - decoding: unused
1645 * motion estimation prepass comparison function
1646 * - encoding: Set by user.
1647 * - decoding: unused
1652 * ME prepass diamond size & shape
1653 * - encoding: Set by user.
1654 * - decoding: unused
1660 * - encoding: Set by user.
1661 * - decoding: unused
1663 int me_subpel_quality;
1666 * DTG active format information (additional aspect ratio
1667 * information only used in DVB MPEG-2 transport streams)
1670 * - encoding: unused
1671 * - decoding: Set by decoder.
1673 int dtg_active_format;
1674 #define FF_DTG_AFD_SAME 8
1675 #define FF_DTG_AFD_4_3 9
1676 #define FF_DTG_AFD_16_9 10
1677 #define FF_DTG_AFD_14_9 11
1678 #define FF_DTG_AFD_4_3_SP_14_9 13
1679 #define FF_DTG_AFD_16_9_SP_14_9 14
1680 #define FF_DTG_AFD_SP_4_3 15
1683 * maximum motion estimation search range in subpel units
1684 * If 0 then no limit.
1686 * - encoding: Set by user.
1687 * - decoding: unused
1692 * intra quantizer bias
1693 * - encoding: Set by user.
1694 * - decoding: unused
1696 int intra_quant_bias;
1697 #define FF_DEFAULT_QUANT_BIAS 999999
1700 * inter quantizer bias
1701 * - encoding: Set by user.
1702 * - decoding: unused
1704 int inter_quant_bias;
1706 #if FF_API_COLOR_TABLE_ID
1709 * - encoding: unused
1710 * - decoding: Which clrtable should be used for 8bit RGB images.
1711 * Tables have to be stored somewhere. FIXME
1713 attribute_deprecated int color_table_id;
1718 * - encoding: unused
1719 * - decoding: Set by user.
1722 #define SLICE_FLAG_CODED_ORDER 0x0001 ///< draw_horiz_band() is called in coded order instead of display
1723 #define SLICE_FLAG_ALLOW_FIELD 0x0002 ///< allow draw_horiz_band() with field slices (MPEG2 field pics)
1724 #define SLICE_FLAG_ALLOW_PLANE 0x0004 ///< allow draw_horiz_band() with 1 component at a time (SVQ1)
1727 * XVideo Motion Acceleration
1728 * - encoding: forbidden
1729 * - decoding: set by decoder
1731 int xvmc_acceleration;
1734 * macroblock decision mode
1735 * - encoding: Set by user.
1736 * - decoding: unused
1739 #define FF_MB_DECISION_SIMPLE 0 ///< uses mb_cmp
1740 #define FF_MB_DECISION_BITS 1 ///< chooses the one which needs the fewest bits
1741 #define FF_MB_DECISION_RD 2 ///< rate distortion
1744 * custom intra quantization matrix
1745 * - encoding: Set by user, can be NULL.
1746 * - decoding: Set by libavcodec.
1748 uint16_t *intra_matrix;
1751 * custom inter quantization matrix
1752 * - encoding: Set by user, can be NULL.
1753 * - decoding: Set by libavcodec.
1755 uint16_t *inter_matrix;
1758 * scene change detection threshold
1759 * 0 is default, larger means fewer detected scene changes.
1760 * - encoding: Set by user.
1761 * - decoding: unused
1763 int scenechange_threshold;
1766 * noise reduction strength
1767 * - encoding: Set by user.
1768 * - decoding: unused
1770 int noise_reduction;
1772 #if FF_API_INTER_THRESHOLD
1774 * @deprecated this field is unused
1776 attribute_deprecated int inter_threshold;
1779 #if FF_API_MPV_GLOBAL_OPTS
1781 * @deprecated use mpegvideo private options instead
1783 attribute_deprecated int quantizer_noise_shaping;
1787 * Motion estimation threshold below which no motion estimation is
1788 * performed, but instead the user specified motion vectors are used.
1790 * - encoding: Set by user.
1791 * - decoding: unused
1796 * Macroblock threshold below which the user specified macroblock types will be used.
1797 * - encoding: Set by user.
1798 * - decoding: unused
1803 * precision of the intra DC coefficient - 8
1804 * - encoding: Set by user.
1805 * - decoding: unused
1807 int intra_dc_precision;
1810 * Number of macroblock rows at the top which are skipped.
1811 * - encoding: unused
1812 * - decoding: Set by user.
1817 * Number of macroblock rows at the bottom which are skipped.
1818 * - encoding: unused
1819 * - decoding: Set by user.
1824 * Border processing masking, raises the quantizer for mbs on the borders
1826 * - encoding: Set by user.
1827 * - decoding: unused
1829 float border_masking;
1832 * minimum MB lagrange multipler
1833 * - encoding: Set by user.
1834 * - decoding: unused
1839 * maximum MB lagrange multipler
1840 * - encoding: Set by user.
1841 * - decoding: unused
1847 * - encoding: Set by user.
1848 * - decoding: unused
1850 int me_penalty_compensation;
1854 * - encoding: Set by user.
1855 * - decoding: unused
1861 * - encoding: Set by user.
1862 * - decoding: unused
1868 * - encoding: Set by user.
1869 * - decoding: unused
1874 * number of reference frames
1875 * - encoding: Set by user.
1876 * - decoding: Set by lavc.
1881 * chroma qp offset from luma
1882 * - encoding: Set by user.
1883 * - decoding: unused
1888 * Multiplied by qscale for each frame and added to scene_change_score.
1889 * - encoding: Set by user.
1890 * - decoding: unused
1892 int scenechange_factor;
1896 * Note: Value depends upon the compare function used for fullpel ME.
1897 * - encoding: Set by user.
1898 * - decoding: unused
1903 * Adjust sensitivity of b_frame_strategy 1.
1904 * - encoding: Set by user.
1905 * - decoding: unused
1910 * Chromaticity coordinates of the source primaries.
1911 * - encoding: Set by user
1912 * - decoding: Set by libavcodec
1914 enum AVColorPrimaries color_primaries;
1917 * Color Transfer Characteristic.
1918 * - encoding: Set by user
1919 * - decoding: Set by libavcodec
1921 enum AVColorTransferCharacteristic color_trc;
1924 * YUV colorspace type.
1925 * - encoding: Set by user
1926 * - decoding: Set by libavcodec
1928 enum AVColorSpace colorspace;
1931 * MPEG vs JPEG YUV range.
1932 * - encoding: Set by user
1933 * - decoding: Set by libavcodec
1935 enum AVColorRange color_range;
1938 * This defines the location of chroma samples.
1939 * - encoding: Set by user
1940 * - decoding: Set by libavcodec
1942 enum AVChromaLocation chroma_sample_location;
1946 * Indicates number of picture subdivisions. Used for parallelized
1948 * - encoding: Set by user
1949 * - decoding: unused
1954 * - encoding: set by libavcodec
1955 * - decoding: Set by libavcodec
1957 enum AVFieldOrder field_order;
1960 int sample_rate; ///< samples per second
1961 int channels; ///< number of audio channels
1964 * audio sample format
1965 * - encoding: Set by user.
1966 * - decoding: Set by libavcodec.
1968 enum AVSampleFormat sample_fmt; ///< sample format
1970 /* The following data should not be initialized. */
1972 * Samples per packet, initialized when calling 'init'.
1977 * Frame counter, set by libavcodec.
1979 * - decoding: total number of frames returned from the decoder so far.
1980 * - encoding: total number of frames passed to the encoder so far.
1982 * @note the counter is not incremented if encoding/decoding resulted in
1988 * number of bytes per packet if constant and known or 0
1989 * Used by some WAV based audio codecs.
1994 * Audio cutoff bandwidth (0 means "automatic")
1995 * - encoding: Set by user.
1996 * - decoding: unused
2000 #if FF_API_REQUEST_CHANNELS
2002 * Decoder should decode to this many channels if it can (0 for default)
2003 * - encoding: unused
2004 * - decoding: Set by user.
2005 * @deprecated Deprecated in favor of request_channel_layout.
2007 int request_channels;
2011 * Audio channel layout.
2012 * - encoding: set by user.
2013 * - decoding: set by libavcodec.
2015 uint64_t channel_layout;
2018 * Request decoder to use this channel layout if it can (0 for default)
2019 * - encoding: unused
2020 * - decoding: Set by user.
2022 uint64_t request_channel_layout;
2025 * Type of service that the audio stream conveys.
2026 * - encoding: Set by user.
2027 * - decoding: Set by libavcodec.
2029 enum AVAudioServiceType audio_service_type;
2032 * Used to request a sample format from the decoder.
2033 * - encoding: unused.
2034 * - decoding: Set by user.
2036 enum AVSampleFormat request_sample_fmt;
2039 * Called at the beginning of each frame to get a buffer for it.
2041 * The function will set AVFrame.data[], AVFrame.linesize[].
2042 * AVFrame.extended_data[] must also be set, but it should be the same as
2043 * AVFrame.data[] except for planar audio with more channels than can fit
2044 * in AVFrame.data[]. In that case, AVFrame.data[] shall still contain as
2045 * many data pointers as it can hold.
2047 * if CODEC_CAP_DR1 is not set then get_buffer() must call
2048 * avcodec_default_get_buffer() instead of providing buffers allocated by
2051 * AVFrame.data[] should be 32- or 16-byte-aligned unless the CPU doesn't
2052 * need it. avcodec_default_get_buffer() aligns the output buffer properly,
2053 * but if get_buffer() is overridden then alignment considerations should
2054 * be taken into account.
2056 * @see avcodec_default_get_buffer()
2060 * If pic.reference is set then the frame will be read later by libavcodec.
2061 * avcodec_align_dimensions2() should be used to find the required width and
2062 * height, as they normally need to be rounded up to the next multiple of 16.
2064 * If frame multithreading is used and thread_safe_callbacks is set,
2065 * it may be called from a different thread, but not from more than one at
2066 * once. Does not need to be reentrant.
2068 * @see release_buffer(), reget_buffer()
2069 * @see avcodec_align_dimensions2()
2073 * Decoders request a buffer of a particular size by setting
2074 * AVFrame.nb_samples prior to calling get_buffer(). The decoder may,
2075 * however, utilize only part of the buffer by setting AVFrame.nb_samples
2076 * to a smaller value in the output frame.
2078 * Decoders cannot use the buffer after returning from
2079 * avcodec_decode_audio4(), so they will not call release_buffer(), as it
2080 * is assumed to be released immediately upon return.
2082 * As a convenience, av_samples_get_buffer_size() and
2083 * av_samples_fill_arrays() in libavutil may be used by custom get_buffer()
2084 * functions to find the required data size and to fill data pointers and
2085 * linesize. In AVFrame.linesize, only linesize[0] may be set for audio
2086 * since all planes must be the same size.
2088 * @see av_samples_get_buffer_size(), av_samples_fill_arrays()
2090 * - encoding: unused
2091 * - decoding: Set by libavcodec, user can override.
2093 int (*get_buffer)(struct AVCodecContext *c, AVFrame *pic);
2096 * Called to release buffers which were allocated with get_buffer.
2097 * A released buffer can be reused in get_buffer().
2098 * pic.data[*] must be set to NULL.
2099 * May be called from a different thread if frame multithreading is used,
2100 * but not by more than one thread at once, so does not need to be reentrant.
2101 * - encoding: unused
2102 * - decoding: Set by libavcodec, user can override.
2104 void (*release_buffer)(struct AVCodecContext *c, AVFrame *pic);
2107 * Called at the beginning of a frame to get cr buffer for it.
2108 * Buffer type (size, hints) must be the same. libavcodec won't check it.
2109 * libavcodec will pass previous buffer in pic, function should return
2110 * same buffer or new buffer with old frame "painted" into it.
2111 * If pic.data[0] == NULL must behave like get_buffer().
2112 * if CODEC_CAP_DR1 is not set then reget_buffer() must call
2113 * avcodec_default_reget_buffer() instead of providing buffers allocated by
2115 * - encoding: unused
2116 * - decoding: Set by libavcodec, user can override.
2118 int (*reget_buffer)(struct AVCodecContext *c, AVFrame *pic);
2121 /* - encoding parameters */
2122 float qcompress; ///< amount of qscale change between easy & hard scenes (0.0-1.0)
2123 float qblur; ///< amount of qscale smoothing over time (0.0-1.0)
2127 * - encoding: Set by user.
2128 * - decoding: unused
2134 * - encoding: Set by user.
2135 * - decoding: unused
2140 * maximum quantizer difference between frames
2141 * - encoding: Set by user.
2142 * - decoding: unused
2147 * ratecontrol qmin qmax limiting method
2148 * 0-> clipping, 1-> use a nice continous function to limit qscale wthin qmin/qmax.
2149 * - encoding: Set by user.
2150 * - decoding: unused
2158 * decoder bitstream buffer size
2159 * - encoding: Set by user.
2160 * - decoding: unused
2165 * ratecontrol override, see RcOverride
2166 * - encoding: Allocated/set/freed by user.
2167 * - decoding: unused
2169 int rc_override_count;
2170 RcOverride *rc_override;
2173 * rate control equation
2174 * - encoding: Set by user
2175 * - decoding: unused
2181 * - encoding: Set by user.
2182 * - decoding: unused
2188 * - encoding: Set by user.
2189 * - decoding: unused
2193 float rc_buffer_aggressivity;
2196 * initial complexity for pass1 ratecontrol
2197 * - encoding: Set by user.
2198 * - decoding: unused
2200 float rc_initial_cplx;
2203 * Ratecontrol attempt to use, at maximum, <value> of what can be used without an underflow.
2204 * - encoding: Set by user.
2205 * - decoding: unused.
2207 float rc_max_available_vbv_use;
2210 * Ratecontrol attempt to use, at least, <value> times the amount needed to prevent a vbv overflow.
2211 * - encoding: Set by user.
2212 * - decoding: unused.
2214 float rc_min_vbv_overflow_use;
2217 * Number of bits which should be loaded into the rc buffer before decoding starts.
2218 * - encoding: Set by user.
2219 * - decoding: unused
2221 int rc_initial_buffer_occupancy;
2223 #define FF_CODER_TYPE_VLC 0
2224 #define FF_CODER_TYPE_AC 1
2225 #define FF_CODER_TYPE_RAW 2
2226 #define FF_CODER_TYPE_RLE 3
2227 #define FF_CODER_TYPE_DEFLATE 4
2230 * - encoding: Set by user.
2231 * - decoding: unused
2237 * - encoding: Set by user.
2238 * - decoding: unused
2243 * minimum Lagrange multipler
2244 * - encoding: Set by user.
2245 * - decoding: unused
2250 * maximum Lagrange multipler
2251 * - encoding: Set by user.
2252 * - decoding: unused
2257 * frame skip threshold
2258 * - encoding: Set by user.
2259 * - decoding: unused
2261 int frame_skip_threshold;
2265 * - encoding: Set by user.
2266 * - decoding: unused
2268 int frame_skip_factor;
2271 * frame skip exponent
2272 * - encoding: Set by user.
2273 * - decoding: unused
2278 * frame skip comparison function
2279 * - encoding: Set by user.
2280 * - decoding: unused
2285 * trellis RD quantization
2286 * - encoding: Set by user.
2287 * - decoding: unused
2292 * - encoding: Set by user.
2293 * - decoding: unused
2295 int min_prediction_order;
2298 * - encoding: Set by user.
2299 * - decoding: unused
2301 int max_prediction_order;
2304 * GOP timecode frame start number, in non drop frame format
2305 * - encoding: Set by user.
2306 * - decoding: unused
2308 int64_t timecode_frame_start;
2310 /* The RTP callback: This function is called */
2311 /* every time the encoder has a packet to send. */
2312 /* It depends on the encoder if the data starts */
2313 /* with a Start Code (it should). H.263 does. */
2314 /* mb_nb contains the number of macroblocks */
2315 /* encoded in the RTP payload. */
2316 void (*rtp_callback)(struct AVCodecContext *avctx, void *data, int size, int mb_nb);
2318 int rtp_payload_size; /* The size of the RTP payload: the coder will */
2319 /* do its best to deliver a chunk with size */
2320 /* below rtp_payload_size, the chunk will start */
2321 /* with a start code on some codecs like H.263. */
2322 /* This doesn't take account of any particular */
2323 /* headers inside the transmitted RTP payload. */
2325 /* statistics, used for 2-pass encoding */
2336 * number of bits used for the previously encoded frame
2337 * - encoding: Set by libavcodec.
2338 * - decoding: unused
2343 * pass1 encoding statistics output buffer
2344 * - encoding: Set by libavcodec.
2345 * - decoding: unused
2350 * pass2 encoding statistics input buffer
2351 * Concatenated stuff from stats_out of pass1 should be placed here.
2352 * - encoding: Allocated/set/freed by user.
2353 * - decoding: unused
2358 * Work around bugs in encoders which sometimes cannot be detected automatically.
2359 * - encoding: Set by user
2360 * - decoding: Set by user
2362 int workaround_bugs;
2363 #define FF_BUG_AUTODETECT 1 ///< autodetection
2364 #define FF_BUG_OLD_MSMPEG4 2
2365 #define FF_BUG_XVID_ILACE 4
2366 #define FF_BUG_UMP4 8
2367 #define FF_BUG_NO_PADDING 16
2368 #define FF_BUG_AMV 32
2369 #define FF_BUG_AC_VLC 0 ///< Will be removed, libavcodec can now handle these non-compliant files by default.
2370 #define FF_BUG_QPEL_CHROMA 64
2371 #define FF_BUG_STD_QPEL 128
2372 #define FF_BUG_QPEL_CHROMA2 256
2373 #define FF_BUG_DIRECT_BLOCKSIZE 512
2374 #define FF_BUG_EDGE 1024
2375 #define FF_BUG_HPEL_CHROMA 2048
2376 #define FF_BUG_DC_CLIP 4096
2377 #define FF_BUG_MS 8192 ///< Work around various bugs in Microsoft's broken decoders.
2378 #define FF_BUG_TRUNCATED 16384
2381 * strictly follow the standard (MPEG4, ...).
2382 * - encoding: Set by user.
2383 * - decoding: Set by user.
2384 * Setting this to STRICT or higher means the encoder and decoder will
2385 * generally do stupid things, whereas setting it to unofficial or lower
2386 * will mean the encoder might produce output that is not supported by all
2387 * spec-compliant decoders. Decoders don't differentiate between normal,
2388 * unofficial and experimental (that is, they always try to decode things
2389 * when they can) unless they are explicitly asked to behave stupidly
2390 * (=strictly conform to the specs)
2392 int strict_std_compliance;
2393 #define FF_COMPLIANCE_VERY_STRICT 2 ///< Strictly conform to an older more strict version of the spec or reference software.
2394 #define FF_COMPLIANCE_STRICT 1 ///< Strictly conform to all the things in the spec no matter what consequences.
2395 #define FF_COMPLIANCE_NORMAL 0
2396 #define FF_COMPLIANCE_UNOFFICIAL -1 ///< Allow unofficial extensions
2397 #define FF_COMPLIANCE_EXPERIMENTAL -2 ///< Allow nonstandardized experimental things.
2400 * error concealment flags
2401 * - encoding: unused
2402 * - decoding: Set by user.
2404 int error_concealment;
2405 #define FF_EC_GUESS_MVS 1
2406 #define FF_EC_DEBLOCK 2
2410 * - encoding: Set by user.
2411 * - decoding: Set by user.
2414 #define FF_DEBUG_PICT_INFO 1
2415 #define FF_DEBUG_RC 2
2416 #define FF_DEBUG_BITSTREAM 4
2417 #define FF_DEBUG_MB_TYPE 8
2418 #define FF_DEBUG_QP 16
2419 #define FF_DEBUG_MV 32
2420 #define FF_DEBUG_DCT_COEFF 0x00000040
2421 #define FF_DEBUG_SKIP 0x00000080
2422 #define FF_DEBUG_STARTCODE 0x00000100
2423 #define FF_DEBUG_PTS 0x00000200
2424 #define FF_DEBUG_ER 0x00000400
2425 #define FF_DEBUG_MMCO 0x00000800
2426 #define FF_DEBUG_BUGS 0x00001000
2427 #define FF_DEBUG_VIS_QP 0x00002000
2428 #define FF_DEBUG_VIS_MB_TYPE 0x00004000
2429 #define FF_DEBUG_BUFFERS 0x00008000
2430 #define FF_DEBUG_THREADS 0x00010000
2434 * - encoding: Set by user.
2435 * - decoding: Set by user.
2438 #define FF_DEBUG_VIS_MV_P_FOR 0x00000001 //visualize forward predicted MVs of P frames
2439 #define FF_DEBUG_VIS_MV_B_FOR 0x00000002 //visualize forward predicted MVs of B frames
2440 #define FF_DEBUG_VIS_MV_B_BACK 0x00000004 //visualize backward predicted MVs of B frames
2443 * Error recognition; may misdetect some more or less valid parts as errors.
2444 * - encoding: unused
2445 * - decoding: Set by user.
2447 int err_recognition;
2448 #define AV_EF_CRCCHECK (1<<0)
2449 #define AV_EF_BITSTREAM (1<<1)
2450 #define AV_EF_BUFFER (1<<2)
2451 #define AV_EF_EXPLODE (1<<3)
2454 * opaque 64bit number (generally a PTS) that will be reordered and
2455 * output in AVFrame.reordered_opaque
2456 * @deprecated in favor of pkt_pts
2457 * - encoding: unused
2458 * - decoding: Set by user.
2460 int64_t reordered_opaque;
2463 * Hardware accelerator in use
2464 * - encoding: unused.
2465 * - decoding: Set by libavcodec
2467 struct AVHWAccel *hwaccel;
2470 * Hardware accelerator context.
2471 * For some hardware accelerators, a global context needs to be
2472 * provided by the user. In that case, this holds display-dependent
2473 * data Libav cannot instantiate itself. Please refer to the
2474 * Libav HW accelerator documentation to know how to fill this
2475 * is. e.g. for VA API, this is a struct vaapi_context.
2476 * - encoding: unused
2477 * - decoding: Set by user
2479 void *hwaccel_context;
2483 * - encoding: Set by libavcodec if flags&CODEC_FLAG_PSNR.
2484 * - decoding: unused
2486 uint64_t error[AV_NUM_DATA_POINTERS];
2489 * DCT algorithm, see FF_DCT_* below
2490 * - encoding: Set by user.
2491 * - decoding: unused
2494 #define FF_DCT_AUTO 0
2495 #define FF_DCT_FASTINT 1
2496 #define FF_DCT_INT 2
2497 #define FF_DCT_MMX 3
2498 #define FF_DCT_ALTIVEC 5
2499 #define FF_DCT_FAAN 6
2502 * IDCT algorithm, see FF_IDCT_* below.
2503 * - encoding: Set by user.
2504 * - decoding: Set by user.
2507 #define FF_IDCT_AUTO 0
2508 #define FF_IDCT_INT 1
2509 #define FF_IDCT_SIMPLE 2
2510 #define FF_IDCT_SIMPLEMMX 3
2511 #define FF_IDCT_LIBMPEG2MMX 4
2512 #define FF_IDCT_MMI 5
2513 #define FF_IDCT_ARM 7
2514 #define FF_IDCT_ALTIVEC 8
2515 #define FF_IDCT_SH4 9
2516 #define FF_IDCT_SIMPLEARM 10
2517 #define FF_IDCT_H264 11
2518 #define FF_IDCT_VP3 12
2519 #define FF_IDCT_IPP 13
2520 #define FF_IDCT_XVIDMMX 14
2521 #define FF_IDCT_CAVS 15
2522 #define FF_IDCT_SIMPLEARMV5TE 16
2523 #define FF_IDCT_SIMPLEARMV6 17
2524 #define FF_IDCT_SIMPLEVIS 18
2525 #define FF_IDCT_WMV2 19
2526 #define FF_IDCT_FAAN 20
2527 #define FF_IDCT_EA 21
2528 #define FF_IDCT_SIMPLENEON 22
2529 #define FF_IDCT_SIMPLEALPHA 23
2530 #define FF_IDCT_BINK 24
2533 * dsp_mask could be add used to disable unwanted CPU features
2534 * CPU features (i.e. MMX, SSE. ...)
2536 * With the FORCE flag you may instead enable given CPU features.
2537 * (Dangerous: Usable in case of misdetection, improper usage however will
2538 * result into program crash.)
2543 * bits per sample/pixel from the demuxer (needed for huffyuv).
2544 * - encoding: Set by libavcodec.
2545 * - decoding: Set by user.
2547 int bits_per_coded_sample;
2550 * Bits per sample/pixel of internal libavcodec pixel/sample format.
2551 * - encoding: set by user.
2552 * - decoding: set by libavcodec.
2554 int bits_per_raw_sample;
2557 * low resolution decoding, 1-> 1/2 size, 2->1/4 size
2558 * - encoding: unused
2559 * - decoding: Set by user.
2564 * the picture in the bitstream
2565 * - encoding: Set by libavcodec.
2566 * - decoding: Set by libavcodec.
2568 AVFrame *coded_frame;
2572 * is used to decide how many independent tasks should be passed to execute()
2573 * - encoding: Set by user.
2574 * - decoding: Set by user.
2579 * Which multithreading methods to use.
2580 * Use of FF_THREAD_FRAME will increase decoding delay by one frame per thread,
2581 * so clients which cannot provide future frames should not use it.
2583 * - encoding: Set by user, otherwise the default is used.
2584 * - decoding: Set by user, otherwise the default is used.
2587 #define FF_THREAD_FRAME 1 ///< Decode more than one frame at once
2588 #define FF_THREAD_SLICE 2 ///< Decode more than one part of a single frame at once
2591 * Which multithreading methods are in use by the codec.
2592 * - encoding: Set by libavcodec.
2593 * - decoding: Set by libavcodec.
2595 int active_thread_type;
2598 * Set by the client if its custom get_buffer() callback can be called
2599 * from another thread, which allows faster multithreaded decoding.
2600 * draw_horiz_band() will be called from other threads regardless of this setting.
2601 * Ignored if the default get_buffer() is used.
2602 * - encoding: Set by user.
2603 * - decoding: Set by user.
2605 int thread_safe_callbacks;
2608 * The codec may call this to execute several independent things.
2609 * It will return only after finishing all tasks.
2610 * The user may replace this with some multithreaded implementation,
2611 * the default implementation will execute the parts serially.
2612 * @param count the number of things to execute
2613 * - encoding: Set by libavcodec, user can override.
2614 * - decoding: Set by libavcodec, user can override.
2616 int (*execute)(struct AVCodecContext *c, int (*func)(struct AVCodecContext *c2, void *arg), void *arg2, int *ret, int count, int size);
2619 * The codec may call this to execute several independent things.
2620 * It will return only after finishing all tasks.
2621 * The user may replace this with some multithreaded implementation,
2622 * the default implementation will execute the parts serially.
2623 * Also see avcodec_thread_init and e.g. the --enable-pthread configure option.
2624 * @param c context passed also to func
2625 * @param count the number of things to execute
2626 * @param arg2 argument passed unchanged to func
2627 * @param ret return values of executed functions, must have space for "count" values. May be NULL.
2628 * @param func function that will be called count times, with jobnr from 0 to count-1.
2629 * threadnr will be in the range 0 to c->thread_count-1 < MAX_THREADS and so that no
2630 * two instances of func executing at the same time will have the same threadnr.
2631 * @return always 0 currently, but code should handle a future improvement where when any call to func
2632 * returns < 0 no further calls to func may be done and < 0 is returned.
2633 * - encoding: Set by libavcodec, user can override.
2634 * - decoding: Set by libavcodec, user can override.
2636 int (*execute2)(struct AVCodecContext *c, int (*func)(struct AVCodecContext *c2, void *arg, int jobnr, int threadnr), void *arg2, int *ret, int count);
2640 * Can be used by execute() to store some per AVCodecContext stuff.
2641 * - encoding: set by execute()
2642 * - decoding: set by execute()
2644 void *thread_opaque;
2647 * noise vs. sse weight for the nsse comparsion function
2648 * - encoding: Set by user.
2649 * - decoding: unused
2655 * - encoding: Set by user.
2656 * - decoding: Set by libavcodec.
2659 #define FF_PROFILE_UNKNOWN -99
2660 #define FF_PROFILE_RESERVED -100
2662 #define FF_PROFILE_AAC_MAIN 0
2663 #define FF_PROFILE_AAC_LOW 1
2664 #define FF_PROFILE_AAC_SSR 2
2665 #define FF_PROFILE_AAC_LTP 3
2667 #define FF_PROFILE_DTS 20
2668 #define FF_PROFILE_DTS_ES 30
2669 #define FF_PROFILE_DTS_96_24 40
2670 #define FF_PROFILE_DTS_HD_HRA 50
2671 #define FF_PROFILE_DTS_HD_MA 60
2673 #define FF_PROFILE_MPEG2_422 0
2674 #define FF_PROFILE_MPEG2_HIGH 1
2675 #define FF_PROFILE_MPEG2_SS 2
2676 #define FF_PROFILE_MPEG2_SNR_SCALABLE 3
2677 #define FF_PROFILE_MPEG2_MAIN 4
2678 #define FF_PROFILE_MPEG2_SIMPLE 5
2680 #define FF_PROFILE_H264_CONSTRAINED (1<<9) // 8+1; constraint_set1_flag
2681 #define FF_PROFILE_H264_INTRA (1<<11) // 8+3; constraint_set3_flag
2683 #define FF_PROFILE_H264_BASELINE 66
2684 #define FF_PROFILE_H264_CONSTRAINED_BASELINE (66|FF_PROFILE_H264_CONSTRAINED)
2685 #define FF_PROFILE_H264_MAIN 77
2686 #define FF_PROFILE_H264_EXTENDED 88
2687 #define FF_PROFILE_H264_HIGH 100
2688 #define FF_PROFILE_H264_HIGH_10 110
2689 #define FF_PROFILE_H264_HIGH_10_INTRA (110|FF_PROFILE_H264_INTRA)
2690 #define FF_PROFILE_H264_HIGH_422 122
2691 #define FF_PROFILE_H264_HIGH_422_INTRA (122|FF_PROFILE_H264_INTRA)
2692 #define FF_PROFILE_H264_HIGH_444 144
2693 #define FF_PROFILE_H264_HIGH_444_PREDICTIVE 244
2694 #define FF_PROFILE_H264_HIGH_444_INTRA (244|FF_PROFILE_H264_INTRA)
2695 #define FF_PROFILE_H264_CAVLC_444 44
2697 #define FF_PROFILE_VC1_SIMPLE 0
2698 #define FF_PROFILE_VC1_MAIN 1
2699 #define FF_PROFILE_VC1_COMPLEX 2
2700 #define FF_PROFILE_VC1_ADVANCED 3
2702 #define FF_PROFILE_MPEG4_SIMPLE 0
2703 #define FF_PROFILE_MPEG4_SIMPLE_SCALABLE 1
2704 #define FF_PROFILE_MPEG4_CORE 2
2705 #define FF_PROFILE_MPEG4_MAIN 3
2706 #define FF_PROFILE_MPEG4_N_BIT 4
2707 #define FF_PROFILE_MPEG4_SCALABLE_TEXTURE 5
2708 #define FF_PROFILE_MPEG4_SIMPLE_FACE_ANIMATION 6
2709 #define FF_PROFILE_MPEG4_BASIC_ANIMATED_TEXTURE 7
2710 #define FF_PROFILE_MPEG4_HYBRID 8
2711 #define FF_PROFILE_MPEG4_ADVANCED_REAL_TIME 9
2712 #define FF_PROFILE_MPEG4_CORE_SCALABLE 10
2713 #define FF_PROFILE_MPEG4_ADVANCED_CODING 11
2714 #define FF_PROFILE_MPEG4_ADVANCED_CORE 12
2715 #define FF_PROFILE_MPEG4_ADVANCED_SCALABLE_TEXTURE 13
2716 #define FF_PROFILE_MPEG4_SIMPLE_STUDIO 14
2717 #define FF_PROFILE_MPEG4_ADVANCED_SIMPLE 15
2721 * - encoding: Set by user.
2722 * - decoding: Set by libavcodec.
2725 #define FF_LEVEL_UNKNOWN -99
2729 * - encoding: unused
2730 * - decoding: Set by user.
2732 enum AVDiscard skip_loop_filter;
2736 * - encoding: unused
2737 * - decoding: Set by user.
2739 enum AVDiscard skip_idct;
2743 * - encoding: unused
2744 * - decoding: Set by user.
2746 enum AVDiscard skip_frame;
2749 * Header containing style information for text subtitles.
2750 * For SUBTITLE_ASS subtitle type, it should contain the whole ASS
2751 * [Script Info] and [V4+ Styles] section, plus the [Events] line and
2752 * the Format line following. It shouldn't include any Dialogue line.
2753 * - encoding: Set/allocated/freed by user (before avcodec_open2())
2754 * - decoding: Set/allocated/freed by libavcodec (by avcodec_open2())
2756 uint8_t *subtitle_header;
2757 int subtitle_header_size;
2760 * Simulates errors in the bitstream to test error concealment.
2761 * - encoding: Set by user.
2762 * - decoding: unused
2767 * Current packet as passed into the decoder, to avoid having
2768 * to pass the packet into every function. Currently only valid
2769 * inside lavc and get/release_buffer callbacks.
2770 * - decoding: set by avcodec_decode_*, read by get_buffer() for setting pkt_pts
2771 * - encoding: unused
2776 * VBV delay coded in the last frame (in periods of a 27 MHz clock).
2777 * Used for compliant TS muxing.
2778 * - encoding: Set by libavcodec.
2779 * - decoding: unused.
2787 typedef struct AVProfile {
2789 const char *name; ///< short name for the profile
2792 typedef struct AVCodecDefault AVCodecDefault;
2797 typedef struct AVCodec {
2799 * Name of the codec implementation.
2800 * The name is globally unique among encoders and among decoders (but an
2801 * encoder and a decoder can share the same name).
2802 * This is the primary way to find a codec from the user perspective.
2806 * Descriptive name for the codec, meant to be more human readable than name.
2807 * You should use the NULL_IF_CONFIG_SMALL() macro to define it.
2809 const char *long_name;
2810 enum AVMediaType type;
2813 * Codec capabilities.
2817 const AVRational *supported_framerates; ///< array of supported framerates, or NULL if any, array is terminated by {0,0}
2818 const enum PixelFormat *pix_fmts; ///< array of supported pixel formats, or NULL if unknown, array is terminated by -1
2819 const int *supported_samplerates; ///< array of supported audio samplerates, or NULL if unknown, array is terminated by 0
2820 const enum AVSampleFormat *sample_fmts; ///< array of supported sample formats, or NULL if unknown, array is terminated by -1
2821 const uint64_t *channel_layouts; ///< array of support channel layouts, or NULL if unknown. array is terminated by 0
2822 uint8_t max_lowres; ///< maximum value for lowres supported by the decoder
2823 const AVClass *priv_class; ///< AVClass for the private context
2824 const AVProfile *profiles; ///< array of recognized profiles, or NULL if unknown, array is terminated by {FF_PROFILE_UNKNOWN}
2826 /*****************************************************************
2827 * No fields below this line are part of the public API. They
2828 * may not be used outside of libavcodec and can be changed and
2830 * New public fields should be added right above.
2831 *****************************************************************
2834 struct AVCodec *next;
2836 * @name Frame-level threading support functions
2840 * If defined, called on thread contexts when they are created.
2841 * If the codec allocates writable tables in init(), re-allocate them here.
2842 * priv_data will be set to a copy of the original.
2844 int (*init_thread_copy)(AVCodecContext *);
2846 * Copy necessary context variables from a previous thread context to the current one.
2847 * If not defined, the next thread will start automatically; otherwise, the codec
2848 * must call ff_thread_finish_setup().
2850 * dst and src will (rarely) point to the same context, in which case memcpy should be skipped.
2852 int (*update_thread_context)(AVCodecContext *dst, const AVCodecContext *src);
2856 * Private codec-specific defaults.
2858 const AVCodecDefault *defaults;
2861 * Initialize codec static data, called from avcodec_register().
2863 void (*init_static_data)(struct AVCodec *codec);
2865 int (*init)(AVCodecContext *);
2866 int (*encode)(AVCodecContext *, uint8_t *buf, int buf_size, void *data);
2868 * Encode data to an AVPacket.
2870 * @param avctx codec context
2871 * @param avpkt output AVPacket (may contain a user-provided buffer)
2872 * @param[in] frame AVFrame containing the raw data to be encoded
2873 * @param[out] got_packet_ptr encoder sets to 0 or 1 to indicate that a
2874 * non-empty packet was returned in avpkt.
2875 * @return 0 on success, negative error code on failure
2877 int (*encode2)(AVCodecContext *avctx, AVPacket *avpkt, const AVFrame *frame,
2878 int *got_packet_ptr);
2879 int (*decode)(AVCodecContext *, void *outdata, int *outdata_size, AVPacket *avpkt);
2880 int (*close)(AVCodecContext *);
2883 * Will be called when seeking
2885 void (*flush)(AVCodecContext *);
2891 typedef struct AVHWAccel {
2893 * Name of the hardware accelerated codec.
2894 * The name is globally unique among encoders and among decoders (but an
2895 * encoder and a decoder can share the same name).
2900 * Type of codec implemented by the hardware accelerator.
2902 * See AVMEDIA_TYPE_xxx
2904 enum AVMediaType type;
2907 * Codec implemented by the hardware accelerator.
2914 * Supported pixel format.
2916 * Only hardware accelerated formats are supported here.
2918 enum PixelFormat pix_fmt;
2921 * Hardware accelerated codec capabilities.
2922 * see FF_HWACCEL_CODEC_CAP_*
2926 struct AVHWAccel *next;
2929 * Called at the beginning of each frame or field picture.
2931 * Meaningful frame information (codec specific) is guaranteed to
2932 * be parsed at this point. This function is mandatory.
2934 * Note that buf can be NULL along with buf_size set to 0.
2935 * Otherwise, this means the whole frame is available at this point.
2937 * @param avctx the codec context
2938 * @param buf the frame data buffer base
2939 * @param buf_size the size of the frame in bytes
2940 * @return zero if successful, a negative value otherwise
2942 int (*start_frame)(AVCodecContext *avctx, const uint8_t *buf, uint32_t buf_size);
2945 * Callback for each slice.
2947 * Meaningful slice information (codec specific) is guaranteed to
2948 * be parsed at this point. This function is mandatory.
2950 * @param avctx the codec context
2951 * @param buf the slice data buffer base
2952 * @param buf_size the size of the slice in bytes
2953 * @return zero if successful, a negative value otherwise
2955 int (*decode_slice)(AVCodecContext *avctx, const uint8_t *buf, uint32_t buf_size);
2958 * Called at the end of each frame or field picture.
2960 * The whole picture is parsed at this point and can now be sent
2961 * to the hardware accelerator. This function is mandatory.
2963 * @param avctx the codec context
2964 * @return zero if successful, a negative value otherwise
2966 int (*end_frame)(AVCodecContext *avctx);
2969 * Size of HW accelerator private data.
2971 * Private data is allocated with av_mallocz() before
2972 * AVCodecContext.get_buffer() and deallocated after
2973 * AVCodecContext.release_buffer().
2979 * four components are given, that's all.
2980 * the last component is alpha
2982 typedef struct AVPicture {
2983 uint8_t *data[AV_NUM_DATA_POINTERS];
2984 int linesize[AV_NUM_DATA_POINTERS]; ///< number of bytes per line
2987 #define AVPALETTE_SIZE 1024
2988 #define AVPALETTE_COUNT 256
2990 enum AVSubtitleType {
2993 SUBTITLE_BITMAP, ///< A bitmap, pict will be set
2996 * Plain text, the text field must be set by the decoder and is
2997 * authoritative. ass and pict fields may contain approximations.
3002 * Formatted text, the ass field must be set by the decoder and is
3003 * authoritative. pict and text fields may contain approximations.
3008 typedef struct AVSubtitleRect {
3009 int x; ///< top left corner of pict, undefined when pict is not set
3010 int y; ///< top left corner of pict, undefined when pict is not set
3011 int w; ///< width of pict, undefined when pict is not set
3012 int h; ///< height of pict, undefined when pict is not set
3013 int nb_colors; ///< number of colors in pict, undefined when pict is not set
3016 * data+linesize for the bitmap of this subtitle.
3017 * can be set for text/ass as well once they where rendered
3020 enum AVSubtitleType type;
3022 char *text; ///< 0 terminated plain UTF-8 text
3025 * 0 terminated ASS/SSA compatible event line.
3026 * The pressentation of this is unaffected by the other values in this
3032 typedef struct AVSubtitle {
3033 uint16_t format; /* 0 = graphics */
3034 uint32_t start_display_time; /* relative to packet pts, in ms */
3035 uint32_t end_display_time; /* relative to packet pts, in ms */
3037 AVSubtitleRect **rects;
3038 int64_t pts; ///< Same as packet pts, in AV_TIME_BASE
3041 /* packet functions */
3044 * @deprecated use NULL instead
3046 attribute_deprecated void av_destruct_packet_nofree(AVPacket *pkt);
3049 * Default packet destructor.
3051 void av_destruct_packet(AVPacket *pkt);
3054 * Initialize optional fields of a packet with default values.
3058 void av_init_packet(AVPacket *pkt);
3061 * Allocate the payload of a packet and initialize its fields with
3065 * @param size wanted payload size
3066 * @return 0 if OK, AVERROR_xxx otherwise
3068 int av_new_packet(AVPacket *pkt, int size);
3071 * Reduce packet size, correctly zeroing padding
3074 * @param size new size
3076 void av_shrink_packet(AVPacket *pkt, int size);
3079 * Increase packet size, correctly zeroing padding
3082 * @param grow_by number of bytes by which to increase the size of the packet
3084 int av_grow_packet(AVPacket *pkt, int grow_by);
3087 * @warning This is a hack - the packet memory allocation stuff is broken. The
3088 * packet is allocated if it was not really allocated.
3090 int av_dup_packet(AVPacket *pkt);
3095 * @param pkt packet to free
3097 void av_free_packet(AVPacket *pkt);
3100 * Allocate new information of a packet.
3103 * @param type side information type
3104 * @param size side information size
3105 * @return pointer to fresh allocated data or NULL otherwise
3107 uint8_t* av_packet_new_side_data(AVPacket *pkt, enum AVPacketSideDataType type,
3111 * Shrink the already allocated side data buffer
3114 * @param type side information type
3115 * @param size new side information size
3116 * @return 0 on success, < 0 on failure
3118 int av_packet_shrink_side_data(AVPacket *pkt, enum AVPacketSideDataType type,
3122 * Get side information from packet.
3125 * @param type desired side information type
3126 * @param size pointer for side information size to store (optional)
3127 * @return pointer to data if present or NULL otherwise
3129 uint8_t* av_packet_get_side_data(AVPacket *pkt, enum AVPacketSideDataType type,
3134 struct ReSampleContext;
3135 struct AVResampleContext;
3137 typedef struct ReSampleContext ReSampleContext;
3140 * Initialize audio resampling context.
3142 * @param output_channels number of output channels
3143 * @param input_channels number of input channels
3144 * @param output_rate output sample rate
3145 * @param input_rate input sample rate
3146 * @param sample_fmt_out requested output sample format
3147 * @param sample_fmt_in input sample format
3148 * @param filter_length length of each FIR filter in the filterbank relative to the cutoff frequency
3149 * @param log2_phase_count log2 of the number of entries in the polyphase filterbank
3150 * @param linear if 1 then the used FIR filter will be linearly interpolated
3151 between the 2 closest, if 0 the closest will be used
3152 * @param cutoff cutoff frequency, 1.0 corresponds to half the output sampling rate
3153 * @return allocated ReSampleContext, NULL if error occurred
3155 ReSampleContext *av_audio_resample_init(int output_channels, int input_channels,
3156 int output_rate, int input_rate,
3157 enum AVSampleFormat sample_fmt_out,
3158 enum AVSampleFormat sample_fmt_in,
3159 int filter_length, int log2_phase_count,
3160 int linear, double cutoff);
3162 int audio_resample(ReSampleContext *s, short *output, short *input, int nb_samples);
3165 * Free resample context.
3167 * @param s a non-NULL pointer to a resample context previously
3168 * created with av_audio_resample_init()
3170 void audio_resample_close(ReSampleContext *s);
3174 * Initialize an audio resampler.
3175 * Note, if either rate is not an integer then simply scale both rates up so they are.
3176 * @param filter_length length of each FIR filter in the filterbank relative to the cutoff freq
3177 * @param log2_phase_count log2 of the number of entries in the polyphase filterbank
3178 * @param linear If 1 then the used FIR filter will be linearly interpolated
3179 between the 2 closest, if 0 the closest will be used
3180 * @param cutoff cutoff frequency, 1.0 corresponds to half the output sampling rate
3182 struct AVResampleContext *av_resample_init(int out_rate, int in_rate, int filter_length, int log2_phase_count, int linear, double cutoff);
3185 * Resample an array of samples using a previously configured context.
3186 * @param src an array of unconsumed samples
3187 * @param consumed the number of samples of src which have been consumed are returned here
3188 * @param src_size the number of unconsumed samples available
3189 * @param dst_size the amount of space in samples available in dst
3190 * @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.
3191 * @return the number of samples written in dst or -1 if an error occurred
3193 int av_resample(struct AVResampleContext *c, short *dst, short *src, int *consumed, int src_size, int dst_size, int update_ctx);
3197 * Compensate samplerate/timestamp drift. The compensation is done by changing
3198 * the resampler parameters, so no audible clicks or similar distortions occur
3199 * @param compensation_distance distance in output samples over which the compensation should be performed
3200 * @param sample_delta number of output samples which should be output less
3202 * example: av_resample_compensate(c, 10, 500)
3203 * here instead of 510 samples only 500 samples would be output
3205 * note, due to rounding the actual compensation might be slightly different,
3206 * especially if the compensation_distance is large and the in_rate used during init is small
3208 void av_resample_compensate(struct AVResampleContext *c, int sample_delta, int compensation_distance);
3209 void av_resample_close(struct AVResampleContext *c);
3212 * Allocate memory for a picture. Call avpicture_free() to free it.
3214 * @see avpicture_fill()
3216 * @param picture the picture to be filled in
3217 * @param pix_fmt the format of the picture
3218 * @param width the width of the picture
3219 * @param height the height of the picture
3220 * @return zero if successful, a negative value if not
3222 int avpicture_alloc(AVPicture *picture, enum PixelFormat pix_fmt, int width, int height);
3225 * Free a picture previously allocated by avpicture_alloc().
3226 * The data buffer used by the AVPicture is freed, but the AVPicture structure
3229 * @param picture the AVPicture to be freed
3231 void avpicture_free(AVPicture *picture);
3234 * Fill in the AVPicture fields.
3235 * The fields of the given AVPicture are filled in by using the 'ptr' address
3236 * which points to the image data buffer. Depending on the specified picture
3237 * format, one or multiple image data pointers and line sizes will be set.
3238 * If a planar format is specified, several pointers will be set pointing to
3239 * the different picture planes and the line sizes of the different planes
3240 * will be stored in the lines_sizes array.
3241 * Call with ptr == NULL to get the required size for the ptr buffer.
3243 * To allocate the buffer and fill in the AVPicture fields in one call,
3244 * use avpicture_alloc().
3246 * @param picture AVPicture whose fields are to be filled in
3247 * @param ptr Buffer which will contain or contains the actual image data
3248 * @param pix_fmt The format in which the picture data is stored.
3249 * @param width the width of the image in pixels
3250 * @param height the height of the image in pixels
3251 * @return size of the image data in bytes
3253 int avpicture_fill(AVPicture *picture, uint8_t *ptr,
3254 enum PixelFormat pix_fmt, int width, int height);
3257 * Copy pixel data from an AVPicture into a buffer.
3258 * The data is stored compactly, without any gaps for alignment or padding
3259 * which may be applied by avpicture_fill().
3261 * @see avpicture_get_size()
3263 * @param[in] src AVPicture containing image data
3264 * @param[in] pix_fmt The format in which the picture data is stored.
3265 * @param[in] width the width of the image in pixels.
3266 * @param[in] height the height of the image in pixels.
3267 * @param[out] dest A buffer into which picture data will be copied.
3268 * @param[in] dest_size The size of 'dest'.
3269 * @return The number of bytes written to dest, or a negative value (error code) on error.
3271 int avpicture_layout(const AVPicture* src, enum PixelFormat pix_fmt, int width, int height,
3272 unsigned char *dest, int dest_size);
3275 * Calculate the size in bytes that a picture of the given width and height
3276 * would occupy if stored in the given picture format.
3277 * Note that this returns the size of a compact representation as generated
3278 * by avpicture_layout(), which can be smaller than the size required for e.g.
3281 * @param pix_fmt the given picture format
3282 * @param width the width of the image
3283 * @param height the height of the image
3284 * @return Image data size in bytes or -1 on error (e.g. too large dimensions).
3286 int avpicture_get_size(enum PixelFormat pix_fmt, int width, int height);
3287 void avcodec_get_chroma_sub_sample(enum PixelFormat pix_fmt, int *h_shift, int *v_shift);
3289 void avcodec_set_dimensions(AVCodecContext *s, int width, int height);
3292 * Return a value representing the fourCC code associated to the
3293 * pixel format pix_fmt, or 0 if no associated fourCC code can be
3296 unsigned int avcodec_pix_fmt_to_codec_tag(enum PixelFormat pix_fmt);
3299 * Put a string representing the codec tag codec_tag in buf.
3301 * @param buf_size size in bytes of buf
3302 * @return the length of the string that would have been generated if
3303 * enough space had been available, excluding the trailing null
3305 size_t av_get_codec_tag_string(char *buf, size_t buf_size, unsigned int codec_tag);
3307 #define FF_LOSS_RESOLUTION 0x0001 /**< loss due to resolution change */
3308 #define FF_LOSS_DEPTH 0x0002 /**< loss due to color depth change */
3309 #define FF_LOSS_COLORSPACE 0x0004 /**< loss due to color space conversion */
3310 #define FF_LOSS_ALPHA 0x0008 /**< loss of alpha bits */
3311 #define FF_LOSS_COLORQUANT 0x0010 /**< loss due to color quantization */
3312 #define FF_LOSS_CHROMA 0x0020 /**< loss of chroma (e.g. RGB to gray conversion) */
3315 * Compute what kind of losses will occur when converting from one specific
3316 * pixel format to another.
3317 * When converting from one pixel format to another, information loss may occur.
3318 * For example, when converting from RGB24 to GRAY, the color information will
3319 * be lost. Similarly, other losses occur when converting from some formats to
3320 * other formats. These losses can involve loss of chroma, but also loss of
3321 * resolution, loss of color depth, loss due to the color space conversion, loss
3322 * of the alpha bits or loss due to color quantization.
3323 * avcodec_get_fix_fmt_loss() informs you about the various types of losses
3324 * which will occur when converting from one pixel format to another.
3326 * @param[in] dst_pix_fmt destination pixel format
3327 * @param[in] src_pix_fmt source pixel format
3328 * @param[in] has_alpha Whether the source pixel format alpha channel is used.
3329 * @return Combination of flags informing you what kind of losses will occur.
3331 int avcodec_get_pix_fmt_loss(enum PixelFormat dst_pix_fmt, enum PixelFormat src_pix_fmt,
3335 * Find the best pixel format to convert to given a certain source pixel
3336 * format. When converting from one pixel format to another, information loss
3337 * may occur. For example, when converting from RGB24 to GRAY, the color
3338 * information will be lost. Similarly, other losses occur when converting from
3339 * some formats to other formats. avcodec_find_best_pix_fmt() searches which of
3340 * the given pixel formats should be used to suffer the least amount of loss.
3341 * The pixel formats from which it chooses one, are determined by the
3342 * pix_fmt_mask parameter.
3345 * src_pix_fmt = PIX_FMT_YUV420P;
3346 * pix_fmt_mask = (1 << PIX_FMT_YUV422P) || (1 << PIX_FMT_RGB24);
3347 * dst_pix_fmt = avcodec_find_best_pix_fmt(pix_fmt_mask, src_pix_fmt, alpha, &loss);
3350 * @param[in] pix_fmt_mask bitmask determining which pixel format to choose from
3351 * @param[in] src_pix_fmt source pixel format
3352 * @param[in] has_alpha Whether the source pixel format alpha channel is used.
3353 * @param[out] loss_ptr Combination of flags informing you what kind of losses will occur.
3354 * @return The best pixel format to convert to or -1 if none was found.
3356 enum PixelFormat avcodec_find_best_pix_fmt(int64_t pix_fmt_mask, enum PixelFormat src_pix_fmt,
3357 int has_alpha, int *loss_ptr);
3359 /* deinterlace a picture */
3360 /* deinterlace - if not supported return -1 */
3361 int avpicture_deinterlace(AVPicture *dst, const AVPicture *src,
3362 enum PixelFormat pix_fmt, int width, int height);
3364 /* external high level API */
3367 * If c is NULL, returns the first registered codec,
3368 * if c is non-NULL, returns the next registered codec after c,
3369 * or NULL if c is the last one.
3371 AVCodec *av_codec_next(AVCodec *c);
3374 * Return the LIBAVCODEC_VERSION_INT constant.
3376 unsigned avcodec_version(void);
3379 * Return the libavcodec build-time configuration.
3381 const char *avcodec_configuration(void);
3384 * Return the libavcodec license.
3386 const char *avcodec_license(void);
3389 * Register the codec codec and initialize libavcodec.
3391 * @warning either this function or avcodec_register_all() must be called
3392 * before any other libavcodec functions.
3394 * @see avcodec_register_all()
3396 void avcodec_register(AVCodec *codec);
3399 * Find a registered encoder with a matching codec ID.
3401 * @param id CodecID of the requested encoder
3402 * @return An encoder if one was found, NULL otherwise.
3404 AVCodec *avcodec_find_encoder(enum CodecID id);
3407 * Find a registered encoder with the specified name.
3409 * @param name name of the requested encoder
3410 * @return An encoder if one was found, NULL otherwise.
3412 AVCodec *avcodec_find_encoder_by_name(const char *name);
3415 * Find a registered decoder with a matching codec ID.
3417 * @param id CodecID of the requested decoder
3418 * @return A decoder if one was found, NULL otherwise.
3420 AVCodec *avcodec_find_decoder(enum CodecID id);
3423 * Find a registered decoder with the specified name.
3425 * @param name name of the requested decoder
3426 * @return A decoder if one was found, NULL otherwise.
3428 AVCodec *avcodec_find_decoder_by_name(const char *name);
3429 void avcodec_string(char *buf, int buf_size, AVCodecContext *enc, int encode);
3432 * Return a name for the specified profile, if available.
3434 * @param codec the codec that is searched for the given profile
3435 * @param profile the profile value for which a name is requested
3436 * @return A name for the profile if found, NULL otherwise.
3438 const char *av_get_profile_name(const AVCodec *codec, int profile);
3441 * Set the fields of the given AVCodecContext to default values corresponding
3442 * to the given codec (defaults may be codec-dependent).
3444 * Do not call this function if a non-NULL codec has been passed
3445 * to avcodec_alloc_context3() that allocated this AVCodecContext.
3446 * If codec is non-NULL, it is illegal to call avcodec_open2() with a
3447 * different codec on this AVCodecContext.
3449 int avcodec_get_context_defaults3(AVCodecContext *s, AVCodec *codec);
3452 * Allocate an AVCodecContext and set its fields to default values. The
3453 * resulting struct can be deallocated by calling avcodec_close() on it followed
3456 * @param codec if non-NULL, allocate private data and initialize defaults
3457 * for the given codec. It is illegal to then call avcodec_open2()
3458 * with a different codec.
3459 * If NULL, then the codec-specific defaults won't be initialized,
3460 * which may result in suboptimal default settings (this is
3461 * important mainly for encoders, e.g. libx264).
3463 * @return An AVCodecContext filled with default values or NULL on failure.
3464 * @see avcodec_get_context_defaults
3466 AVCodecContext *avcodec_alloc_context3(AVCodec *codec);
3469 * Copy the settings of the source AVCodecContext into the destination
3470 * AVCodecContext. The resulting destination codec context will be
3471 * unopened, i.e. you are required to call avcodec_open2() before you
3472 * can use this AVCodecContext to decode/encode video/audio data.
3474 * @param dest target codec context, should be initialized with
3475 * avcodec_alloc_context3(), but otherwise uninitialized
3476 * @param src source codec context
3477 * @return AVERROR() on error (e.g. memory allocation error), 0 on success
3479 int avcodec_copy_context(AVCodecContext *dest, const AVCodecContext *src);
3482 * Set the fields of the given AVFrame to default values.
3484 * @param pic The AVFrame of which the fields should be set to default values.
3486 void avcodec_get_frame_defaults(AVFrame *pic);
3489 * Allocate an AVFrame and set its fields to default values. The resulting
3490 * struct can be deallocated by simply calling av_free().
3492 * @return An AVFrame filled with default values or NULL on failure.
3493 * @see avcodec_get_frame_defaults
3495 AVFrame *avcodec_alloc_frame(void);
3497 int avcodec_default_get_buffer(AVCodecContext *s, AVFrame *pic);
3498 void avcodec_default_release_buffer(AVCodecContext *s, AVFrame *pic);
3499 int avcodec_default_reget_buffer(AVCodecContext *s, AVFrame *pic);
3502 * Return the amount of padding in pixels which the get_buffer callback must
3503 * provide around the edge of the image for codecs which do not have the
3504 * CODEC_FLAG_EMU_EDGE flag.
3506 * @return Required padding in pixels.
3508 unsigned avcodec_get_edge_width(void);
3510 * Modify width and height values so that they will result in a memory
3511 * buffer that is acceptable for the codec if you do not use any horizontal
3514 * May only be used if a codec with CODEC_CAP_DR1 has been opened.
3515 * If CODEC_FLAG_EMU_EDGE is not set, the dimensions must have been increased
3516 * according to avcodec_get_edge_width() before.
3518 void avcodec_align_dimensions(AVCodecContext *s, int *width, int *height);
3520 * Modify width and height values so that they will result in a memory
3521 * buffer that is acceptable for the codec if you also ensure that all
3522 * line sizes are a multiple of the respective linesize_align[i].
3524 * May only be used if a codec with CODEC_CAP_DR1 has been opened.
3525 * If CODEC_FLAG_EMU_EDGE is not set, the dimensions must have been increased
3526 * according to avcodec_get_edge_width() before.
3528 void avcodec_align_dimensions2(AVCodecContext *s, int *width, int *height,
3529 int linesize_align[AV_NUM_DATA_POINTERS]);
3531 enum PixelFormat avcodec_default_get_format(struct AVCodecContext *s, const enum PixelFormat * fmt);
3533 int avcodec_default_execute(AVCodecContext *c, int (*func)(AVCodecContext *c2, void *arg2),void *arg, int *ret, int count, int size);
3534 int avcodec_default_execute2(AVCodecContext *c, int (*func)(AVCodecContext *c2, void *arg2, int, int),void *arg, int *ret, int count);
3535 //FIXME func typedef
3538 * Initialize the AVCodecContext to use the given AVCodec. Prior to using this
3539 * function the context has to be allocated with avcodec_alloc_context3().
3541 * The functions avcodec_find_decoder_by_name(), avcodec_find_encoder_by_name(),
3542 * avcodec_find_decoder() and avcodec_find_encoder() provide an easy way for
3543 * retrieving a codec.
3545 * @warning This function is not thread safe!
3548 * avcodec_register_all();
3549 * av_dict_set(&opts, "b", "2.5M", 0);
3550 * codec = avcodec_find_decoder(CODEC_ID_H264);
3554 * context = avcodec_alloc_context3(codec);
3556 * if (avcodec_open2(context, codec, opts) < 0)
3560 * @param avctx The context to initialize.
3561 * @param codec The codec to open this context for. If a non-NULL codec has been
3562 * previously passed to avcodec_alloc_context3() or
3563 * avcodec_get_context_defaults3() for this context, then this
3564 * parameter MUST be either NULL or equal to the previously passed
3566 * @param options A dictionary filled with AVCodecContext and codec-private options.
3567 * On return this object will be filled with options that were not found.
3569 * @return zero on success, a negative value on error
3570 * @see avcodec_alloc_context3(), avcodec_find_decoder(), avcodec_find_encoder(),
3571 * av_dict_set(), av_opt_find().
3573 int avcodec_open2(AVCodecContext *avctx, AVCodec *codec, AVDictionary **options);
3575 #if FF_API_OLD_DECODE_AUDIO
3577 * Wrapper function which calls avcodec_decode_audio4.
3579 * @deprecated Use avcodec_decode_audio4 instead.
3581 * Decode the audio frame of size avpkt->size from avpkt->data into samples.
3582 * Some decoders may support multiple frames in a single AVPacket, such
3583 * decoders would then just decode the first frame. In this case,
3584 * avcodec_decode_audio3 has to be called again with an AVPacket that contains
3585 * the remaining data in order to decode the second frame etc.
3587 * could be outputted, frame_size_ptr is zero. Otherwise, it is the
3588 * decompressed frame size in bytes.
3590 * @warning You must set frame_size_ptr to the allocated size of the
3591 * output buffer before calling avcodec_decode_audio3().
3593 * @warning The input buffer must be FF_INPUT_BUFFER_PADDING_SIZE larger than
3594 * the actual read bytes because some optimized bitstream readers read 32 or 64
3595 * bits at once and could read over the end.
3597 * @warning The end of the input buffer avpkt->data should be set to 0 to ensure that
3598 * no overreading happens for damaged MPEG streams.
3600 * @warning You must not provide a custom get_buffer() when using
3601 * avcodec_decode_audio3(). Doing so will override it with
3602 * avcodec_default_get_buffer. Use avcodec_decode_audio4() instead,
3603 * which does allow the application to provide a custom get_buffer().
3605 * @note You might have to align the input buffer avpkt->data and output buffer
3606 * samples. The alignment requirements depend on the CPU: On some CPUs it isn't
3607 * necessary at all, on others it won't work at all if not aligned and on others
3608 * it will work but it will have an impact on performance.
3610 * In practice, avpkt->data should have 4 byte alignment at minimum and
3611 * samples should be 16 byte aligned unless the CPU doesn't need it
3612 * (AltiVec and SSE do).
3614 * @note Codecs which have the CODEC_CAP_DELAY capability set have a delay
3615 * between input and output, these need to be fed with avpkt->data=NULL,
3616 * avpkt->size=0 at the end to return the remaining frames.
3618 * @param avctx the codec context
3619 * @param[out] samples the output buffer, sample type in avctx->sample_fmt
3620 * If the sample format is planar, each channel plane will
3621 * be the same size, with no padding between channels.
3622 * @param[in,out] frame_size_ptr the output buffer size in bytes
3623 * @param[in] avpkt The input AVPacket containing the input buffer.
3624 * You can create such packet with av_init_packet() and by then setting
3625 * data and size, some decoders might in addition need other fields.
3626 * All decoders are designed to use the least fields possible though.
3627 * @return On error a negative value is returned, otherwise the number of bytes
3628 * used or zero if no frame data was decompressed (used) from the input AVPacket.
3630 attribute_deprecated int avcodec_decode_audio3(AVCodecContext *avctx, int16_t *samples,
3631 int *frame_size_ptr,
3636 * Decode the audio frame of size avpkt->size from avpkt->data into frame.
3638 * Some decoders may support multiple frames in a single AVPacket. Such
3639 * decoders would then just decode the first frame. In this case,
3640 * avcodec_decode_audio4 has to be called again with an AVPacket containing
3641 * the remaining data in order to decode the second frame, etc...
3642 * Even if no frames are returned, the packet needs to be fed to the decoder
3643 * with remaining data until it is completely consumed or an error occurs.
3645 * @warning The input buffer, avpkt->data must be FF_INPUT_BUFFER_PADDING_SIZE
3646 * larger than the actual read bytes because some optimized bitstream
3647 * readers read 32 or 64 bits at once and could read over the end.
3649 * @note You might have to align the input buffer. The alignment requirements
3650 * depend on the CPU and the decoder.
3652 * @param avctx the codec context
3653 * @param[out] frame The AVFrame in which to store decoded audio samples.
3654 * Decoders request a buffer of a particular size by setting
3655 * AVFrame.nb_samples prior to calling get_buffer(). The
3656 * decoder may, however, only utilize part of the buffer by
3657 * setting AVFrame.nb_samples to a smaller value in the
3659 * @param[out] got_frame_ptr Zero if no frame could be decoded, otherwise it is
3661 * @param[in] avpkt The input AVPacket containing the input buffer.
3662 * At least avpkt->data and avpkt->size should be set. Some
3663 * decoders might also require additional fields to be set.
3664 * @return A negative error code is returned if an error occurred during
3665 * decoding, otherwise the number of bytes consumed from the input
3666 * AVPacket is returned.
3668 int avcodec_decode_audio4(AVCodecContext *avctx, AVFrame *frame,
3669 int *got_frame_ptr, AVPacket *avpkt);
3672 * Decode the video frame of size avpkt->size from avpkt->data into picture.
3673 * Some decoders may support multiple frames in a single AVPacket, such
3674 * decoders would then just decode the first frame.
3676 * @warning The input buffer must be FF_INPUT_BUFFER_PADDING_SIZE larger than
3677 * the actual read bytes because some optimized bitstream readers read 32 or 64
3678 * bits at once and could read over the end.
3680 * @warning The end of the input buffer buf should be set to 0 to ensure that
3681 * no overreading happens for damaged MPEG streams.
3683 * @note You might have to align the input buffer avpkt->data.
3684 * The alignment requirements depend on the CPU: on some CPUs it isn't
3685 * necessary at all, on others it won't work at all if not aligned and on others
3686 * it will work but it will have an impact on performance.
3688 * In practice, avpkt->data should have 4 byte alignment at minimum.
3690 * @note Codecs which have the CODEC_CAP_DELAY capability set have a delay
3691 * between input and output, these need to be fed with avpkt->data=NULL,
3692 * avpkt->size=0 at the end to return the remaining frames.
3694 * @param avctx the codec context
3695 * @param[out] picture The AVFrame in which the decoded video frame will be stored.
3696 * Use avcodec_alloc_frame to get an AVFrame, the codec will
3697 * allocate memory for the actual bitmap.
3698 * with default get/release_buffer(), the decoder frees/reuses the bitmap as it sees fit.
3699 * with overridden get/release_buffer() (needs CODEC_CAP_DR1) the user decides into what buffer the decoder
3700 * decodes and the decoder tells the user once it does not need the data anymore,
3701 * the user app can at this point free/reuse/keep the memory as it sees fit.
3703 * @param[in] avpkt The input AVpacket containing the input buffer.
3704 * You can create such packet with av_init_packet() and by then setting
3705 * data and size, some decoders might in addition need other fields like
3706 * flags&AV_PKT_FLAG_KEY. All decoders are designed to use the least
3708 * @param[in,out] got_picture_ptr Zero if no frame could be decompressed, otherwise, it is nonzero.
3709 * @return On error a negative value is returned, otherwise the number of bytes
3710 * used or zero if no frame could be decompressed.
3712 int avcodec_decode_video2(AVCodecContext *avctx, AVFrame *picture,
3713 int *got_picture_ptr,
3717 * Decode a subtitle message.
3718 * Return a negative value on error, otherwise return the number of bytes used.
3719 * If no subtitle could be decompressed, got_sub_ptr is zero.
3720 * Otherwise, the subtitle is stored in *sub.
3721 * Note that CODEC_CAP_DR1 is not available for subtitle codecs. This is for
3722 * simplicity, because the performance difference is expect to be negligible
3723 * and reusing a get_buffer written for video codecs would probably perform badly
3724 * due to a potentially very different allocation pattern.
3726 * @param avctx the codec context
3727 * @param[out] sub The AVSubtitle in which the decoded subtitle will be stored, must be
3728 freed with avsubtitle_free if *got_sub_ptr is set.
3729 * @param[in,out] got_sub_ptr Zero if no subtitle could be decompressed, otherwise, it is nonzero.
3730 * @param[in] avpkt The input AVPacket containing the input buffer.
3732 int avcodec_decode_subtitle2(AVCodecContext *avctx, AVSubtitle *sub,
3737 * Free all allocated data in the given subtitle struct.
3739 * @param sub AVSubtitle to free.
3741 void avsubtitle_free(AVSubtitle *sub);
3743 #if FF_API_OLD_ENCODE_AUDIO
3745 * Encode an audio frame from samples into buf.
3747 * @deprecated Use avcodec_encode_audio2 instead.
3749 * @note The output buffer should be at least FF_MIN_BUFFER_SIZE bytes large.
3750 * However, for codecs with avctx->frame_size equal to 0 (e.g. PCM) the user
3751 * will know how much space is needed because it depends on the value passed
3752 * in buf_size as described below. In that case a lower value can be used.
3754 * @param avctx the codec context
3755 * @param[out] buf the output buffer
3756 * @param[in] buf_size the output buffer size
3757 * @param[in] samples the input buffer containing the samples
3758 * The number of samples read from this buffer is frame_size*channels,
3759 * both of which are defined in avctx.
3760 * For codecs which have avctx->frame_size equal to 0 (e.g. PCM) the number of
3761 * samples read from samples is equal to:
3762 * buf_size * 8 / (avctx->channels * av_get_bits_per_sample(avctx->codec_id))
3763 * This also implies that av_get_bits_per_sample() must not return 0 for these
3765 * @return On error a negative value is returned, on success zero or the number
3766 * of bytes used to encode the data read from the input buffer.
3768 int attribute_deprecated avcodec_encode_audio(AVCodecContext *avctx,
3769 uint8_t *buf, int buf_size,
3770 const short *samples);
3774 * Encode a frame of audio.
3776 * Takes input samples from frame and writes the next output packet, if
3777 * available, to avpkt. The output packet does not necessarily contain data for
3778 * the most recent frame, as encoders can delay, split, and combine input frames
3779 * internally as needed.
3781 * @param avctx codec context
3782 * @param avpkt output AVPacket.
3783 * The user can supply an output buffer by setting
3784 * avpkt->data and avpkt->size prior to calling the
3785 * function, but if the size of the user-provided data is not
3786 * large enough, encoding will fail. All other AVPacket fields
3787 * will be reset by the encoder using av_init_packet(). If
3788 * avpkt->data is NULL, the encoder will allocate it.
3789 * The encoder will set avpkt->size to the size of the
3792 * If this function fails or produces no output, avpkt will be
3793 * freed using av_free_packet() (i.e. avpkt->destruct will be
3794 * called to free the user supplied buffer).
3795 * @param[in] frame AVFrame containing the raw audio data to be encoded.
3796 * May be NULL when flushing an encoder that has the
3797 * CODEC_CAP_DELAY capability set.
3798 * There are 2 codec capabilities that affect the allowed
3799 * values of frame->nb_samples.
3800 * If CODEC_CAP_SMALL_LAST_FRAME is set, then only the final
3801 * frame may be smaller than avctx->frame_size, and all other
3802 * frames must be equal to avctx->frame_size.
3803 * If CODEC_CAP_VARIABLE_FRAME_SIZE is set, then each frame
3804 * can have any number of samples.
3805 * If neither is set, frame->nb_samples must be equal to
3806 * avctx->frame_size for all frames.
3807 * @param[out] got_packet_ptr This field is set to 1 by libavcodec if the
3808 * output packet is non-empty, and to 0 if it is
3809 * empty. If the function returns an error, the
3810 * packet can be assumed to be invalid, and the
3811 * value of got_packet_ptr is undefined and should
3813 * @return 0 on success, negative error code on failure
3815 int avcodec_encode_audio2(AVCodecContext *avctx, AVPacket *avpkt,
3816 const AVFrame *frame, int *got_packet_ptr);
3819 * Fill audio frame data and linesize.
3820 * AVFrame extended_data channel pointers are allocated if necessary for
3823 * @param frame the AVFrame
3824 * frame->nb_samples must be set prior to calling the
3825 * function. This function fills in frame->data,
3826 * frame->extended_data, frame->linesize[0].
3827 * @param nb_channels channel count
3828 * @param sample_fmt sample format
3829 * @param buf buffer to use for frame data
3830 * @param buf_size size of buffer
3831 * @param align plane size sample alignment (0 = default)
3832 * @return 0 on success, negative error code on failure
3834 int avcodec_fill_audio_frame(AVFrame *frame, int nb_channels,
3835 enum AVSampleFormat sample_fmt, const uint8_t *buf,
3836 int buf_size, int align);
3838 #if FF_API_OLD_ENCODE_VIDEO
3840 * @deprecated use avcodec_encode_video2() instead.
3842 * Encode a video frame from pict into buf.
3843 * The input picture should be
3844 * stored using a specific format, namely avctx.pix_fmt.
3846 * @param avctx the codec context
3847 * @param[out] buf the output buffer for the bitstream of encoded frame
3848 * @param[in] buf_size the size of the output buffer in bytes
3849 * @param[in] pict the input picture to encode
3850 * @return On error a negative value is returned, on success zero or the number
3851 * of bytes used from the output buffer.
3853 attribute_deprecated
3854 int avcodec_encode_video(AVCodecContext *avctx, uint8_t *buf, int buf_size,
3855 const AVFrame *pict);
3859 * Encode a frame of video.
3861 * Takes input raw video data from frame and writes the next output packet, if
3862 * available, to avpkt. The output packet does not necessarily contain data for
3863 * the most recent frame, as encoders can delay and reorder input frames
3864 * internally as needed.
3866 * @param avctx codec context
3867 * @param avpkt output AVPacket.
3868 * The user can supply an output buffer by setting
3869 * avpkt->data and avpkt->size prior to calling the
3870 * function, but if the size of the user-provided data is not
3871 * large enough, encoding will fail. All other AVPacket fields
3872 * will be reset by the encoder using av_init_packet(). If
3873 * avpkt->data is NULL, the encoder will allocate it.
3874 * The encoder will set avpkt->size to the size of the
3875 * output packet. The returned data (if any) belongs to the
3876 * caller, he is responsible for freeing it.
3878 * If this function fails or produces no output, avpkt will be
3879 * freed using av_free_packet() (i.e. avpkt->destruct will be
3880 * called to free the user supplied buffer).
3881 * @param[in] frame AVFrame containing the raw video data to be encoded.
3882 * May be NULL when flushing an encoder that has the
3883 * CODEC_CAP_DELAY capability set.
3884 * @param[out] got_packet_ptr This field is set to 1 by libavcodec if the
3885 * output packet is non-empty, and to 0 if it is
3886 * empty. If the function returns an error, the
3887 * packet can be assumed to be invalid, and the
3888 * value of got_packet_ptr is undefined and should
3890 * @return 0 on success, negative error code on failure
3892 int avcodec_encode_video2(AVCodecContext *avctx, AVPacket *avpkt,
3893 const AVFrame *frame, int *got_packet_ptr);
3895 int avcodec_encode_subtitle(AVCodecContext *avctx, uint8_t *buf, int buf_size,
3896 const AVSubtitle *sub);
3899 * Close a given AVCodecContext and free all the data associated with it
3900 * (but not the AVCodecContext itself).
3902 * Calling this function on an AVCodecContext that hasn't been opened will free
3903 * the codec-specific data allocated in avcodec_alloc_context3() /
3904 * avcodec_get_context_defaults3() with a non-NULL codec. Subsequent calls will
3907 int avcodec_close(AVCodecContext *avctx);
3910 * Register all the codecs, parsers and bitstream filters which were enabled at
3911 * configuration time. If you do not call this function you can select exactly
3912 * which formats you want to support, by using the individual registration
3915 * @see avcodec_register
3916 * @see av_register_codec_parser
3917 * @see av_register_bitstream_filter
3919 void avcodec_register_all(void);
3922 * Flush buffers, should be called when seeking or when switching to a different stream.
3924 void avcodec_flush_buffers(AVCodecContext *avctx);
3926 void avcodec_default_free_buffers(AVCodecContext *s);
3928 /* misc useful functions */
3931 * Return codec bits per sample.
3933 * @param[in] codec_id the codec
3934 * @return Number of bits per sample or zero if unknown for the given codec.
3936 int av_get_bits_per_sample(enum CodecID codec_id);
3939 * Return codec bits per sample.
3940 * Only return non-zero if the bits per sample is exactly correct, not an
3943 * @param[in] codec_id the codec
3944 * @return Number of bits per sample or zero if unknown for the given codec.
3946 int av_get_exact_bits_per_sample(enum CodecID codec_id);
3949 * Return audio frame duration.
3951 * @param avctx codec context
3952 * @param frame_bytes size of the frame, or 0 if unknown
3953 * @return frame duration, in samples, if known. 0 if not able to
3956 int av_get_audio_frame_duration(AVCodecContext *avctx, int frame_bytes);
3959 typedef struct AVCodecParserContext {
3961 struct AVCodecParser *parser;
3962 int64_t frame_offset; /* offset of the current frame */
3963 int64_t cur_offset; /* current offset
3964 (incremented by each av_parser_parse()) */
3965 int64_t next_frame_offset; /* offset of the next frame */
3967 int pict_type; /* XXX: Put it back in AVCodecContext. */
3969 * This field is used for proper frame duration computation in lavf.
3970 * It signals, how much longer the frame duration of the current frame
3971 * is compared to normal frame duration.
3973 * frame_duration = (1 + repeat_pict) * time_base
3975 * It is used by codecs like H.264 to display telecined material.
3977 int repeat_pict; /* XXX: Put it back in AVCodecContext. */
3978 int64_t pts; /* pts of the current frame */
3979 int64_t dts; /* dts of the current frame */
3984 int fetch_timestamp;
3986 #define AV_PARSER_PTS_NB 4
3987 int cur_frame_start_index;
3988 int64_t cur_frame_offset[AV_PARSER_PTS_NB];
3989 int64_t cur_frame_pts[AV_PARSER_PTS_NB];
3990 int64_t cur_frame_dts[AV_PARSER_PTS_NB];
3993 #define PARSER_FLAG_COMPLETE_FRAMES 0x0001
3994 #define PARSER_FLAG_ONCE 0x0002
3995 /// Set if the parser has a valid file offset
3996 #define PARSER_FLAG_FETCHED_OFFSET 0x0004
3998 int64_t offset; ///< byte offset from starting packet start
3999 int64_t cur_frame_end[AV_PARSER_PTS_NB];
4002 * Set by parser to 1 for key frames and 0 for non-key frames.
4003 * It is initialized to -1, so if the parser doesn't set this flag,
4004 * old-style fallback using AV_PICTURE_TYPE_I picture type as key frames
4010 * Time difference in stream time base units from the pts of this
4011 * packet to the point at which the output from the decoder has converged
4012 * independent from the availability of previous frames. That is, the
4013 * frames are virtually identical no matter if decoding started from
4014 * the very first frame or from this keyframe.
4015 * Is AV_NOPTS_VALUE if unknown.
4016 * This field is not the display duration of the current frame.
4017 * This field has no meaning if the packet does not have AV_PKT_FLAG_KEY
4020 * The purpose of this field is to allow seeking in streams that have no
4021 * keyframes in the conventional sense. It corresponds to the
4022 * recovery point SEI in H.264 and match_time_delta in NUT. It is also
4023 * essential for some types of subtitle streams to ensure that all
4024 * subtitles are correctly displayed after seeking.
4026 int64_t convergence_duration;
4028 // Timestamp generation support:
4030 * Synchronization point for start of timestamp generation.
4032 * Set to >0 for sync point, 0 for no sync point and <0 for undefined
4035 * For example, this corresponds to presence of H.264 buffering period
4041 * Offset of the current timestamp against last timestamp sync point in
4042 * units of AVCodecContext.time_base.
4044 * Set to INT_MIN when dts_sync_point unused. Otherwise, it must
4045 * contain a valid timestamp offset.
4047 * Note that the timestamp of sync point has usually a nonzero
4048 * dts_ref_dts_delta, which refers to the previous sync point. Offset of
4049 * the next frame after timestamp sync point will be usually 1.
4051 * For example, this corresponds to H.264 cpb_removal_delay.
4053 int dts_ref_dts_delta;
4056 * Presentation delay of current frame in units of AVCodecContext.time_base.
4058 * Set to INT_MIN when dts_sync_point unused. Otherwise, it must
4059 * contain valid non-negative timestamp delta (presentation time of a frame
4060 * must not lie in the past).
4062 * This delay represents the difference between decoding and presentation
4063 * time of the frame.
4065 * For example, this corresponds to H.264 dpb_output_delay.
4070 * Position of the packet in file.
4072 * Analogous to cur_frame_pts/dts
4074 int64_t cur_frame_pos[AV_PARSER_PTS_NB];
4077 * Byte position of currently parsed frame in stream.
4082 * Previous frame byte position.
4087 * Duration of the current frame.
4088 * For audio, this is in units of 1 / AVCodecContext.sample_rate.
4089 * For all other types, this is in units of AVCodecContext.time_base.
4092 } AVCodecParserContext;
4094 typedef struct AVCodecParser {
4095 int codec_ids[5]; /* several codec IDs are permitted */
4097 int (*parser_init)(AVCodecParserContext *s);
4098 int (*parser_parse)(AVCodecParserContext *s,
4099 AVCodecContext *avctx,
4100 const uint8_t **poutbuf, int *poutbuf_size,
4101 const uint8_t *buf, int buf_size);
4102 void (*parser_close)(AVCodecParserContext *s);
4103 int (*split)(AVCodecContext *avctx, const uint8_t *buf, int buf_size);
4104 struct AVCodecParser *next;
4107 AVCodecParser *av_parser_next(AVCodecParser *c);
4109 void av_register_codec_parser(AVCodecParser *parser);
4110 AVCodecParserContext *av_parser_init(int codec_id);
4115 * @param s parser context.
4116 * @param avctx codec context.
4117 * @param poutbuf set to pointer to parsed buffer or NULL if not yet finished.
4118 * @param poutbuf_size set to size of parsed buffer or zero if not yet finished.
4119 * @param buf input buffer.
4120 * @param buf_size input length, to signal EOF, this should be 0 (so that the last frame can be output).
4121 * @param pts input presentation timestamp.
4122 * @param dts input decoding timestamp.
4123 * @param pos input byte position in stream.
4124 * @return the number of bytes of the input bitstream used.
4129 * len = av_parser_parse2(myparser, AVCodecContext, &data, &size,
4136 * decode_frame(data, size);
4140 int av_parser_parse2(AVCodecParserContext *s,
4141 AVCodecContext *avctx,
4142 uint8_t **poutbuf, int *poutbuf_size,
4143 const uint8_t *buf, int buf_size,
4144 int64_t pts, int64_t dts,
4147 int av_parser_change(AVCodecParserContext *s,
4148 AVCodecContext *avctx,
4149 uint8_t **poutbuf, int *poutbuf_size,
4150 const uint8_t *buf, int buf_size, int keyframe);
4151 void av_parser_close(AVCodecParserContext *s);
4154 typedef struct AVBitStreamFilterContext {
4156 struct AVBitStreamFilter *filter;
4157 AVCodecParserContext *parser;
4158 struct AVBitStreamFilterContext *next;
4159 } AVBitStreamFilterContext;
4162 typedef struct AVBitStreamFilter {
4165 int (*filter)(AVBitStreamFilterContext *bsfc,
4166 AVCodecContext *avctx, const char *args,
4167 uint8_t **poutbuf, int *poutbuf_size,
4168 const uint8_t *buf, int buf_size, int keyframe);
4169 void (*close)(AVBitStreamFilterContext *bsfc);
4170 struct AVBitStreamFilter *next;
4171 } AVBitStreamFilter;
4173 void av_register_bitstream_filter(AVBitStreamFilter *bsf);
4174 AVBitStreamFilterContext *av_bitstream_filter_init(const char *name);
4175 int av_bitstream_filter_filter(AVBitStreamFilterContext *bsfc,
4176 AVCodecContext *avctx, const char *args,
4177 uint8_t **poutbuf, int *poutbuf_size,
4178 const uint8_t *buf, int buf_size, int keyframe);
4179 void av_bitstream_filter_close(AVBitStreamFilterContext *bsf);
4181 AVBitStreamFilter *av_bitstream_filter_next(AVBitStreamFilter *f);
4186 * Reallocate the given block if it is not large enough, otherwise do nothing.
4190 void *av_fast_realloc(void *ptr, unsigned int *size, size_t min_size);
4193 * Allocate a buffer, reusing the given one if large enough.
4195 * Contrary to av_fast_realloc the current buffer contents might not be
4196 * preserved and on error the old buffer is freed, thus no special
4197 * handling to avoid memleaks is necessary.
4199 * @param ptr pointer to pointer to already allocated buffer, overwritten with pointer to new buffer
4200 * @param size size of the buffer *ptr points to
4201 * @param min_size minimum size of *ptr buffer after returning, *ptr will be NULL and
4202 * *size 0 if an error occurred.
4204 void av_fast_malloc(void *ptr, unsigned int *size, size_t min_size);
4207 * Allocate a buffer with padding, reusing the given one if large enough.
4209 * Same behaviour av_fast_malloc but the buffer has additional
4210 * FF_INPUT_PADDING_SIZE at the end which will always memset to 0.
4213 void av_fast_padded_malloc(void *ptr, unsigned int *size, size_t min_size);
4216 * Copy image src to dst. Wraps av_picture_data_copy() above.
4218 void av_picture_copy(AVPicture *dst, const AVPicture *src,
4219 enum PixelFormat pix_fmt, int width, int height);
4222 * Crop image top and left side.
4224 int av_picture_crop(AVPicture *dst, const AVPicture *src,
4225 enum PixelFormat pix_fmt, int top_band, int left_band);
4230 int av_picture_pad(AVPicture *dst, const AVPicture *src, int height, int width, enum PixelFormat pix_fmt,
4231 int padtop, int padbottom, int padleft, int padright, int *color);
4234 * Encode extradata length to a buffer. Used by xiph codecs.
4236 * @param s buffer to write to; must be at least (v/255+1) bytes long
4237 * @param v size of extradata in bytes
4238 * @return number of bytes written to the buffer.
4240 unsigned int av_xiphlacing(unsigned char *s, unsigned int v);
4243 * Log a generic warning message about a missing feature. This function is
4244 * intended to be used internally by Libav (libavcodec, libavformat, etc.)
4245 * only, and would normally not be used by applications.
4246 * @param[in] avc a pointer to an arbitrary struct of which the first field is
4247 * a pointer to an AVClass struct
4248 * @param[in] feature string containing the name of the missing feature
4249 * @param[in] want_sample indicates if samples are wanted which exhibit this feature.
4250 * If want_sample is non-zero, additional verbage will be added to the log
4251 * message which tells the user how to report samples to the development
4254 void av_log_missing_feature(void *avc, const char *feature, int want_sample);
4257 * Log a generic warning message asking for a sample. This function is
4258 * intended to be used internally by Libav (libavcodec, libavformat, etc.)
4259 * only, and would normally not be used by applications.
4260 * @param[in] avc a pointer to an arbitrary struct of which the first field is
4261 * a pointer to an AVClass struct
4262 * @param[in] msg string containing an optional message, or NULL if no message
4264 void av_log_ask_for_sample(void *avc, const char *msg, ...) av_printf_format(2, 3);
4267 * Register the hardware accelerator hwaccel.
4269 void av_register_hwaccel(AVHWAccel *hwaccel);
4272 * If hwaccel is NULL, returns the first registered hardware accelerator,
4273 * if hwaccel is non-NULL, returns the next registered hardware accelerator
4274 * after hwaccel, or NULL if hwaccel is the last one.
4276 AVHWAccel *av_hwaccel_next(AVHWAccel *hwaccel);
4280 * Lock operation used by lockmgr
4283 AV_LOCK_CREATE, ///< Create a mutex
4284 AV_LOCK_OBTAIN, ///< Lock the mutex
4285 AV_LOCK_RELEASE, ///< Unlock the mutex
4286 AV_LOCK_DESTROY, ///< Free mutex resources
4290 * Register a user provided lock manager supporting the operations
4291 * specified by AVLockOp. mutex points to a (void *) where the
4292 * lockmgr should store/get a pointer to a user allocated mutex. It's
4293 * NULL upon AV_LOCK_CREATE and != NULL for all other ops.
4295 * @param cb User defined callback. Note: Libav may invoke calls to this
4296 * callback during the call to av_lockmgr_register().
4297 * Thus, the application must be prepared to handle that.
4298 * If cb is set to NULL the lockmgr will be unregistered.
4299 * Also note that during unregistration the previously registered
4300 * lockmgr callback may also be invoked.
4302 int av_lockmgr_register(int (*cb)(void **mutex, enum AVLockOp op));
4305 * Get the type of the given codec.
4307 enum AVMediaType avcodec_get_type(enum CodecID codec_id);
4310 * Get the AVClass for AVCodecContext. It can be used in combination with
4311 * AV_OPT_SEARCH_FAKE_OBJ for examining options.
4313 * @see av_opt_find().
4315 const AVClass *avcodec_get_class(void);
4318 * @return a positive value if s is open (i.e. avcodec_open2() was called on it
4319 * with no corresponding avcodec_close()), 0 otherwise.
4321 int avcodec_is_open(AVCodecContext *s);
4324 * @return a non-zero number if codec is an encoder, zero otherwise
4326 int av_codec_is_encoder(AVCodec *codec);
4329 * @return a non-zero number if codec is a decoder, zero otherwise
4331 int av_codec_is_decoder(AVCodec *codec);
4333 #endif /* AVCODEC_AVCODEC_H */