Libav
avcodec.h
Go to the documentation of this file.
1 /*
2  * copyright (c) 2001 Fabrice Bellard
3  *
4  * This file is part of Libav.
5  *
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.
10  *
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.
15  *
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
19  */
20 
21 #ifndef AVCODEC_AVCODEC_H
22 #define AVCODEC_AVCODEC_H
23 
30 #include <errno.h>
31 #include "libavutil/samplefmt.h"
32 #include "libavutil/attributes.h"
33 #include "libavutil/avutil.h"
34 #include "libavutil/buffer.h"
35 #include "libavutil/cpu.h"
36 #include "libavutil/dict.h"
37 #include "libavutil/frame.h"
38 #include "libavutil/log.h"
39 #include "libavutil/pixfmt.h"
40 #include "libavutil/rational.h"
41 
42 #include "version.h"
43 
44 #if FF_API_FAST_MALLOC
45 // to provide fast_*alloc
46 #include "libavutil/mem.h"
47 #endif
48 
105 enum AVCodecID {
107 
108  /* video codecs */
111 #if FF_API_XVMC
112  AV_CODEC_ID_MPEG2VIDEO_XVMC,
113 #endif /* FF_API_XVMC */
287 
288  /* various PCM "codecs" */
320 
321  /* various ADPCM codecs */
352 
353  /* AMR */
356 
357  /* RealAudio codecs*/
360 
361  /* various DPCM codecs */
366 
367  /* audio codecs */
368  AV_CODEC_ID_MP2 = 0x15000,
398  AV_CODEC_ID_GSM_MS, /* as found in WAV */
400 #if FF_API_VOXWARE
402 #endif
435 
436  /* subtitle codecs */
447 
448  /* other specific kind of codecs (generally used for attachments) */
450  AV_CODEC_ID_TTF = 0x18000,
451 
452  AV_CODEC_ID_PROBE = 0x19000,
453 
459 };
460 
466 typedef struct AVCodecDescriptor {
467  enum AVCodecID id;
474  const char *name;
478  const char *long_name;
482  int props;
484 
489 #define AV_CODEC_PROP_INTRA_ONLY (1 << 0)
490 
495 #define AV_CODEC_PROP_LOSSY (1 << 1)
496 
499 #define AV_CODEC_PROP_LOSSLESS (1 << 2)
500 
509 #define FF_INPUT_BUFFER_PADDING_SIZE 8
510 
516 #define FF_MIN_BUFFER_SIZE 16384
517 
518 
524  ME_ZERO = 1,
533 };
534 
539  /* We leave some space between them for extensions (drop some
540  * keyframes for intra-only or drop just some bidir frames). */
547 };
548 
559 };
560 
577 };
578 
591 };
592 
598 };
599 
614 };
615 
627 };
628 
632 typedef struct RcOverride{
635  int qscale; // If this is 0 then quality_factor will be used instead.
637 } RcOverride;
638 
639 #if FF_API_MAX_BFRAMES
640 
643 #define FF_MAX_B_FRAMES 16
644 #endif
645 
646 /* encoding support
647  These flags can be passed in AVCodecContext.flags before initialization.
648  Note: Not everything is supported yet.
649 */
650 
655 #define CODEC_FLAG_UNALIGNED 0x0001
656 #define CODEC_FLAG_QSCALE 0x0002
657 #define CODEC_FLAG_4MV 0x0004
658 #define CODEC_FLAG_OUTPUT_CORRUPT 0x0008
659 #define CODEC_FLAG_QPEL 0x0010
660 #define CODEC_FLAG_GMC 0x0020
661 #define CODEC_FLAG_MV0 0x0040
662 
667 #define CODEC_FLAG_INPUT_PRESERVED 0x0100
668 #define CODEC_FLAG_PASS1 0x0200
669 #define CODEC_FLAG_PASS2 0x0400
670 #define CODEC_FLAG_GRAY 0x2000
671 #if FF_API_EMU_EDGE
672 
676 #define CODEC_FLAG_EMU_EDGE 0x4000
677 #endif
678 #define CODEC_FLAG_PSNR 0x8000
679 #define CODEC_FLAG_TRUNCATED 0x00010000
681 #define CODEC_FLAG_NORMALIZE_AQP 0x00020000
682 #define CODEC_FLAG_INTERLACED_DCT 0x00040000
683 #define CODEC_FLAG_LOW_DELAY 0x00080000
684 #define CODEC_FLAG_GLOBAL_HEADER 0x00400000
685 #define CODEC_FLAG_BITEXACT 0x00800000
686 /* Fx : Flag for h263+ extra options */
687 #define CODEC_FLAG_AC_PRED 0x01000000
688 #define CODEC_FLAG_LOOP_FILTER 0x00000800
689 #define CODEC_FLAG_INTERLACED_ME 0x20000000
690 #define CODEC_FLAG_CLOSED_GOP 0x80000000
691 #define CODEC_FLAG2_FAST 0x00000001
692 #define CODEC_FLAG2_NO_OUTPUT 0x00000004
693 #define CODEC_FLAG2_LOCAL_HEADER 0x00000008
694 #define CODEC_FLAG2_IGNORE_CROP 0x00010000
696 #define CODEC_FLAG2_CHUNKS 0x00008000
697 
698 /* Unsupported options :
699  * Syntax Arithmetic coding (SAC)
700  * Reference Picture Selection
701  * Independent Segment Decoding */
702 /* /Fx */
703 /* codec capabilities */
705 #define CODEC_CAP_DRAW_HORIZ_BAND 0x0001
706 
711 #define CODEC_CAP_DR1 0x0002
712 #define CODEC_CAP_TRUNCATED 0x0008
713 #if FF_API_XVMC
714 /* Codec can export data for HW decoding (XvMC). */
715 #define CODEC_CAP_HWACCEL 0x0010
716 #endif /* FF_API_XVMC */
717 
740 #define CODEC_CAP_DELAY 0x0020
741 
745 #define CODEC_CAP_SMALL_LAST_FRAME 0x0040
746 #if FF_API_CAP_VDPAU
747 
750 #define CODEC_CAP_HWACCEL_VDPAU 0x0080
751 #endif
752 
763 #define CODEC_CAP_SUBFRAMES 0x0100
764 
768 #define CODEC_CAP_EXPERIMENTAL 0x0200
769 
772 #define CODEC_CAP_CHANNEL_CONF 0x0400
773 #if FF_API_NEG_LINESIZES
774 
777 #define CODEC_CAP_NEG_LINESIZES 0x0800
778 #endif
779 
782 #define CODEC_CAP_FRAME_THREADS 0x1000
783 
786 #define CODEC_CAP_SLICE_THREADS 0x2000
787 
790 #define CODEC_CAP_PARAM_CHANGE 0x4000
791 
794 #define CODEC_CAP_AUTO_THREADS 0x8000
795 
798 #define CODEC_CAP_VARIABLE_FRAME_SIZE 0x10000
799 
800 #if FF_API_MB_TYPE
801 //The following defines may change, don't expect compatibility if you use them.
802 #define MB_TYPE_INTRA4x4 0x0001
803 #define MB_TYPE_INTRA16x16 0x0002 //FIXME H.264-specific
804 #define MB_TYPE_INTRA_PCM 0x0004 //FIXME H.264-specific
805 #define MB_TYPE_16x16 0x0008
806 #define MB_TYPE_16x8 0x0010
807 #define MB_TYPE_8x16 0x0020
808 #define MB_TYPE_8x8 0x0040
809 #define MB_TYPE_INTERLACED 0x0080
810 #define MB_TYPE_DIRECT2 0x0100 //FIXME
811 #define MB_TYPE_ACPRED 0x0200
812 #define MB_TYPE_GMC 0x0400
813 #define MB_TYPE_SKIP 0x0800
814 #define MB_TYPE_P0L0 0x1000
815 #define MB_TYPE_P1L0 0x2000
816 #define MB_TYPE_P0L1 0x4000
817 #define MB_TYPE_P1L1 0x8000
818 #define MB_TYPE_L0 (MB_TYPE_P0L0 | MB_TYPE_P1L0)
819 #define MB_TYPE_L1 (MB_TYPE_P0L1 | MB_TYPE_P1L1)
820 #define MB_TYPE_L0L1 (MB_TYPE_L0 | MB_TYPE_L1)
821 #define MB_TYPE_QUANT 0x00010000
822 #define MB_TYPE_CBP 0x00020000
823 //Note bits 24-31 are reserved for codec specific use (h264 ref0, mpeg1 0mv, ...)
824 #endif
825 
831 typedef struct AVPanScan{
837  int id;
838 
844  int width;
845  int height;
846 
852  int16_t position[3][2];
853 }AVPanScan;
854 
855 #if FF_API_QSCALE_TYPE
856 #define FF_QSCALE_TYPE_MPEG1 0
857 #define FF_QSCALE_TYPE_MPEG2 1
858 #define FF_QSCALE_TYPE_H264 2
859 #define FF_QSCALE_TYPE_VP56 3
860 #endif
861 
862 #if FF_API_GET_BUFFER
863 #define FF_BUFFER_TYPE_INTERNAL 1
864 #define FF_BUFFER_TYPE_USER 2
865 #define FF_BUFFER_TYPE_SHARED 4
866 #define FF_BUFFER_TYPE_COPY 8
868 #define FF_BUFFER_HINTS_VALID 0x01 // Buffer hints value is meaningful (if 0 ignore).
869 #define FF_BUFFER_HINTS_READABLE 0x02 // Codec will read from buffer.
870 #define FF_BUFFER_HINTS_PRESERVE 0x04 // User must not alter buffer content.
871 #define FF_BUFFER_HINTS_REUSABLE 0x08 // Codec will reuse the buffer (update).
872 #endif
873 
877 #define AV_GET_BUFFER_FLAG_REF (1 << 0)
878 
888 
905 
926 };
927 
950 typedef struct AVPacket {
956  AVBufferRef *buf;
966  int64_t pts;
972  int64_t dts;
974  int size;
975  int stream_index;
979  int flags;
984  struct {
985  uint8_t *data;
986  int size;
989  int side_data_elems;
990 
995  int duration;
996 #if FF_API_DESTRUCT_PACKET
998  void (*destruct)(struct AVPacket *);
1000  void *priv;
1001 #endif
1002  int64_t pos;
1003 
1021  int64_t convergence_duration;
1023 #define AV_PKT_FLAG_KEY 0x0001
1024 #define AV_PKT_FLAG_CORRUPT 0x0002
1031 };
1036 struct AVCodecInternal;
1041  AV_FIELD_TT, //< Top coded_first, top displayed first
1042  AV_FIELD_BB, //< Bottom coded first, bottom displayed first
1043  AV_FIELD_TB, //< Top coded first, bottom displayed first
1044  AV_FIELD_BT, //< Bottom coded first, top displayed first
1045 };
1046 
1054 typedef struct AVCodecContext {
1060  int log_level_offset;
1062  enum AVMediaType codec_type; /* see AVMEDIA_TYPE_xxx */
1063  const struct AVCodec *codec;
1064  char codec_name[32];
1065  enum AVCodecID codec_id; /* see AV_CODEC_ID_xxx */
1066 
1080  unsigned int codec_tag;
1081 
1088  unsigned int stream_codec_tag;
1090  void *priv_data;
1091 
1098  struct AVCodecInternal *internal;
1099 
1105  void *opaque;
1106 
1112  int bit_rate;
1113 
1120  int bit_rate_tolerance;
1121 
1128  int global_quality;
1129 
1135 #define FF_COMPRESSION_DEFAULT -1
1136 
1142  int flags;
1143 
1149  int flags2;
1150 
1163  int extradata_size;
1164 
1174 
1182  int ticks_per_frame;
1183 
1205  int delay;
1206 
1207 
1208  /* video only */
1217  int width, height;
1218 
1228 
1229 #if FF_API_ASPECT_EXTENDED
1230 #define FF_ASPECT_EXTENDED 15
1231 #endif
1232 
1238  int gop_size;
1239 
1247  enum AVPixelFormat pix_fmt;
1248 
1256  int me_method;
1257 
1281  void (*draw_horiz_band)(struct AVCodecContext *s,
1282  const AVFrame *src, int offset[AV_NUM_DATA_POINTERS],
1283  int y, int type, int height);
1284 
1294  enum AVPixelFormat (*get_format)(struct AVCodecContext *s, const enum AVPixelFormat * fmt);
1295 
1302  int max_b_frames;
1303 
1311  float b_quant_factor;
1312 
1315 #define FF_RC_STRATEGY_XVID 1
1317  int b_frame_strategy;
1318 
1324  float b_quant_offset;
1325 
1332  int has_b_frames;
1333 
1339  int mpeg_quant;
1340 
1348  float i_quant_factor;
1349 
1355  float i_quant_offset;
1356 
1362  float lumi_masking;
1363 
1369  float temporal_cplx_masking;
1370 
1376  float spatial_cplx_masking;
1377 
1383  float p_masking;
1384 
1390  float dark_masking;
1391 
1397  int slice_count;
1404 #define FF_PRED_LEFT 0
1405 #define FF_PRED_PLANE 1
1406 #define FF_PRED_MEDIAN 2
1407 
1413  int *slice_offset;
1414 
1423 
1429  int me_cmp;
1435  int me_sub_cmp;
1441  int mb_cmp;
1448 #define FF_CMP_SAD 0
1449 #define FF_CMP_SSE 1
1450 #define FF_CMP_SATD 2
1451 #define FF_CMP_DCT 3
1452 #define FF_CMP_PSNR 4
1453 #define FF_CMP_BIT 5
1454 #define FF_CMP_RD 6
1455 #define FF_CMP_ZERO 7
1456 #define FF_CMP_VSAD 8
1457 #define FF_CMP_VSSE 9
1458 #define FF_CMP_NSSE 10
1459 #define FF_CMP_DCTMAX 13
1460 #define FF_CMP_DCT264 14
1461 #define FF_CMP_CHROMA 256
1462 
1468  int dia_size;
1469 
1476 
1482  int pre_me;
1483 
1489  int me_pre_cmp;
1490 
1496  int pre_dia_size;
1497 
1503  int me_subpel_quality;
1504 
1514 #define FF_DTG_AFD_SAME 8
1515 #define FF_DTG_AFD_4_3 9
1516 #define FF_DTG_AFD_16_9 10
1517 #define FF_DTG_AFD_14_9 11
1518 #define FF_DTG_AFD_4_3_SP_14_9 13
1519 #define FF_DTG_AFD_16_9_SP_14_9 14
1520 #define FF_DTG_AFD_SP_4_3 15
1521 
1529  int me_range;
1530 
1537 #define FF_DEFAULT_QUANT_BIAS 999999
1538 
1544  int inter_quant_bias;
1545 
1552 #define SLICE_FLAG_CODED_ORDER 0x0001
1553 #define SLICE_FLAG_ALLOW_FIELD 0x0002
1554 #define SLICE_FLAG_ALLOW_PLANE 0x0004
1555 
1556 #if FF_API_XVMC
1557 
1563  attribute_deprecated int xvmc_acceleration;
1564 #endif /* FF_API_XVMC */
1565 
1572 #define FF_MB_DECISION_SIMPLE 0
1573 #define FF_MB_DECISION_BITS 1
1574 #define FF_MB_DECISION_RD 2
1575 
1576 
1581  uint16_t *intra_matrix;
1582 
1588  uint16_t *inter_matrix;
1589 
1597 
1603  int noise_reduction;
1604 
1612  int me_threshold;
1613 
1619  int mb_threshold;
1620 
1626  int intra_dc_precision;
1627 
1633  int skip_top;
1634 
1640  int skip_bottom;
1641 
1648  float border_masking;
1649 
1655  int mb_lmin;
1656 
1662  int mb_lmax;
1663 
1670 
1676  int bidir_refine;
1677 
1683  int brd_scale;
1684 
1690  int keyint_min;
1691 
1697  int refs;
1698 
1704  int chromaoffset;
1705 
1711  int scenechange_factor;
1712 
1719  int mv0_threshold;
1720 
1726  int b_sensitivity;
1727 
1734 
1741 
1747  enum AVColorSpace colorspace;
1748 
1755 
1762 
1770  int slices;
1771 
1777 
1778  /* audio only */
1780  int channels;
1781 
1787  enum AVSampleFormat sample_fmt;
1788 
1789  /* The following data should not be initialized. */
1799  int frame_size;
1800 
1810  int frame_number;
1811 
1816  int block_align;
1817 
1823  int cutoff;
1824 
1825 #if FF_API_REQUEST_CHANNELS
1826 
1833 #endif
1834 
1840  uint64_t channel_layout;
1841 
1847  uint64_t request_channel_layout;
1848 
1855 
1862 
1863 #if FF_API_GET_BUFFER
1864 
1927  int (*get_buffer)(struct AVCodecContext *c, AVFrame *pic);
1928 
1941  void (*release_buffer)(struct AVCodecContext *c, AVFrame *pic);
1942 
1956  int (*reget_buffer)(struct AVCodecContext *c, AVFrame *pic);
1957 #endif
1958 
2037  int (*get_buffer2)(struct AVCodecContext *s, AVFrame *frame, int flags);
2038 
2050  int refcounted_frames;
2051 
2052  /* - encoding parameters */
2053  float qcompress;
2054  float qblur;
2055 
2061  int qmin;
2062 
2068  int qmax;
2069 
2075  int max_qdiff;
2076 
2083  float rc_qsquish;
2086  int rc_qmod_freq;
2087 
2093  int rc_buffer_size;
2094 
2102 
2108  const char *rc_eq;
2109 
2115  int rc_max_rate;
2116 
2122  int rc_min_rate;
2124  float rc_buffer_aggressivity;
2125 
2131  float rc_initial_cplx;
2132 
2139 
2146 
2154 #define FF_CODER_TYPE_VLC 0
2155 #define FF_CODER_TYPE_AC 1
2156 #define FF_CODER_TYPE_RAW 2
2157 #define FF_CODER_TYPE_RLE 3
2158 #define FF_CODER_TYPE_DEFLATE 4
2159 
2164  int coder_type;
2165 
2171  int context_model;
2172 
2178  int lmin;
2179 
2185  int lmax;
2186 
2193 
2199  int frame_skip_factor;
2200 
2206  int frame_skip_exp;
2207 
2213  int frame_skip_cmp;
2214 
2220  int trellis;
2221 
2227 
2233 
2239  int64_t timecode_frame_start;
2240 
2241  /* The RTP callback: This function is called */
2242  /* every time the encoder has a packet to send. */
2243  /* It depends on the encoder if the data starts */
2244  /* with a Start Code (it should). H.263 does. */
2245  /* mb_nb contains the number of macroblocks */
2246  /* encoded in the RTP payload. */
2247  void (*rtp_callback)(struct AVCodecContext *avctx, void *data, int size, int mb_nb);
2249  int rtp_payload_size; /* The size of the RTP payload: the coder will */
2250  /* do its best to deliver a chunk with size */
2251  /* below rtp_payload_size, the chunk will start */
2252  /* with a start code on some codecs like H.263. */
2253  /* This doesn't take account of any particular */
2254  /* headers inside the transmitted RTP payload. */
2255 
2256  /* statistics, used for 2-pass encoding */
2257  int mv_bits;
2261  int i_count;
2262  int p_count;
2264  int misc_bits;
2265 
2271  int frame_bits;
2272 
2278  char *stats_out;
2279 
2286  char *stats_in;
2287 
2294 #define FF_BUG_AUTODETECT 1
2295 #if FF_API_OLD_MSMPEG4
2296 #define FF_BUG_OLD_MSMPEG4 2
2297 #endif
2298 #define FF_BUG_XVID_ILACE 4
2299 #define FF_BUG_UMP4 8
2300 #define FF_BUG_NO_PADDING 16
2301 #define FF_BUG_AMV 32
2302 #if FF_API_AC_VLC
2303 #define FF_BUG_AC_VLC 0
2304 #endif
2305 #define FF_BUG_QPEL_CHROMA 64
2306 #define FF_BUG_STD_QPEL 128
2307 #define FF_BUG_QPEL_CHROMA2 256
2308 #define FF_BUG_DIRECT_BLOCKSIZE 512
2309 #define FF_BUG_EDGE 1024
2310 #define FF_BUG_HPEL_CHROMA 2048
2311 #define FF_BUG_DC_CLIP 4096
2312 #define FF_BUG_MS 8192
2313 #define FF_BUG_TRUNCATED 16384
2314 
2328 #define FF_COMPLIANCE_VERY_STRICT 2
2329 #define FF_COMPLIANCE_STRICT 1
2330 #define FF_COMPLIANCE_NORMAL 0
2331 #define FF_COMPLIANCE_UNOFFICIAL -1
2332 #define FF_COMPLIANCE_EXPERIMENTAL -2
2333 
2334 
2340 #define FF_EC_GUESS_MVS 1
2341 #define FF_EC_DEBLOCK 2
2342 
2348  int debug;
2349 #define FF_DEBUG_PICT_INFO 1
2350 #define FF_DEBUG_RC 2
2351 #define FF_DEBUG_BITSTREAM 4
2352 #define FF_DEBUG_MB_TYPE 8
2353 #define FF_DEBUG_QP 16
2354 #if FF_API_DEBUG_MV
2355 
2358 #define FF_DEBUG_MV 32
2359 #endif
2360 #define FF_DEBUG_DCT_COEFF 0x00000040
2361 #define FF_DEBUG_SKIP 0x00000080
2362 #define FF_DEBUG_STARTCODE 0x00000100
2363 #define FF_DEBUG_PTS 0x00000200
2364 #define FF_DEBUG_ER 0x00000400
2365 #define FF_DEBUG_MMCO 0x00000800
2366 #define FF_DEBUG_BUGS 0x00001000
2367 #if FF_API_DEBUG_MV
2368 #define FF_DEBUG_VIS_QP 0x00002000
2369 #define FF_DEBUG_VIS_MB_TYPE 0x00004000
2370 #endif
2371 #define FF_DEBUG_BUFFERS 0x00008000
2372 #define FF_DEBUG_THREADS 0x00010000
2373 
2374 #if FF_API_DEBUG_MV
2375 
2380 #define FF_DEBUG_VIS_MV_P_FOR 0x00000001 //visualize forward predicted MVs of P frames
2381 #define FF_DEBUG_VIS_MV_B_FOR 0x00000002 //visualize forward predicted MVs of B frames
2382 #define FF_DEBUG_VIS_MV_B_BACK 0x00000004 //visualize backward predicted MVs of B frames
2383 #endif
2384 
2390  int err_recognition;
2391 
2398 #define AV_EF_CRCCHECK (1<<0)
2399 #define AV_EF_BITSTREAM (1<<1)
2400 #define AV_EF_BUFFER (1<<2)
2401 #define AV_EF_EXPLODE (1<<3)
2402 
2410  int64_t reordered_opaque;
2411 
2417  struct AVHWAccel *hwaccel;
2418 
2429  void *hwaccel_context;
2430 
2436  uint64_t error[AV_NUM_DATA_POINTERS];
2437 
2444 #define FF_DCT_AUTO 0
2445 #define FF_DCT_FASTINT 1
2446 #define FF_DCT_INT 2
2447 #define FF_DCT_MMX 3
2448 #define FF_DCT_ALTIVEC 5
2449 #define FF_DCT_FAAN 6
2450 
2457 #define FF_IDCT_AUTO 0
2458 #define FF_IDCT_INT 1
2459 #define FF_IDCT_SIMPLE 2
2460 #define FF_IDCT_SIMPLEMMX 3
2461 #define FF_IDCT_ARM 7
2462 #define FF_IDCT_ALTIVEC 8
2463 #define FF_IDCT_SH4 9
2464 #define FF_IDCT_SIMPLEARM 10
2465 #define FF_IDCT_IPP 13
2466 #define FF_IDCT_XVIDMMX 14
2467 #define FF_IDCT_SIMPLEARMV5TE 16
2468 #define FF_IDCT_SIMPLEARMV6 17
2469 #define FF_IDCT_SIMPLEVIS 18
2470 #define FF_IDCT_FAAN 20
2471 #define FF_IDCT_SIMPLENEON 22
2472 #if FF_API_ARCH_ALPHA
2473 #define FF_IDCT_SIMPLEALPHA 23
2474 #endif
2475 
2482 
2488  int bits_per_raw_sample;
2489 
2490 #if FF_API_LOWRES
2491 
2499 #endif
2500 
2507 
2514  int thread_count;
2515 
2525 #define FF_THREAD_FRAME 1
2526 #define FF_THREAD_SLICE 2
2527 
2528 
2533  int active_thread_type;
2534 
2544 
2554  int (*execute)(struct AVCodecContext *c, int (*func)(struct AVCodecContext *c2, void *arg), void *arg2, int *ret, int count, int size);
2555 
2574  int (*execute2)(struct AVCodecContext *c, int (*func)(struct AVCodecContext *c2, void *arg, int jobnr, int threadnr), void *arg2, int *ret, int count);
2575 
2576 #if FF_API_THREAD_OPAQUE
2577 
2581  void *thread_opaque;
2582 #endif
2583 
2589  int nsse_weight;
2590 
2596  int profile;
2597 #define FF_PROFILE_UNKNOWN -99
2598 #define FF_PROFILE_RESERVED -100
2600 #define FF_PROFILE_AAC_MAIN 0
2601 #define FF_PROFILE_AAC_LOW 1
2602 #define FF_PROFILE_AAC_SSR 2
2603 #define FF_PROFILE_AAC_LTP 3
2604 #define FF_PROFILE_AAC_HE 4
2605 #define FF_PROFILE_AAC_HE_V2 28
2606 #define FF_PROFILE_AAC_LD 22
2607 #define FF_PROFILE_AAC_ELD 38
2608 #define FF_PROFILE_MPEG2_AAC_LOW 128
2609 #define FF_PROFILE_MPEG2_AAC_HE 131
2611 #define FF_PROFILE_DTS 20
2612 #define FF_PROFILE_DTS_ES 30
2613 #define FF_PROFILE_DTS_96_24 40
2614 #define FF_PROFILE_DTS_HD_HRA 50
2615 #define FF_PROFILE_DTS_HD_MA 60
2617 #define FF_PROFILE_MPEG2_422 0
2618 #define FF_PROFILE_MPEG2_HIGH 1
2619 #define FF_PROFILE_MPEG2_SS 2
2620 #define FF_PROFILE_MPEG2_SNR_SCALABLE 3
2621 #define FF_PROFILE_MPEG2_MAIN 4
2622 #define FF_PROFILE_MPEG2_SIMPLE 5
2624 #define FF_PROFILE_H264_CONSTRAINED (1<<9) // 8+1; constraint_set1_flag
2625 #define FF_PROFILE_H264_INTRA (1<<11) // 8+3; constraint_set3_flag
2627 #define FF_PROFILE_H264_BASELINE 66
2628 #define FF_PROFILE_H264_CONSTRAINED_BASELINE (66|FF_PROFILE_H264_CONSTRAINED)
2629 #define FF_PROFILE_H264_MAIN 77
2630 #define FF_PROFILE_H264_EXTENDED 88
2631 #define FF_PROFILE_H264_HIGH 100
2632 #define FF_PROFILE_H264_HIGH_10 110
2633 #define FF_PROFILE_H264_HIGH_10_INTRA (110|FF_PROFILE_H264_INTRA)
2634 #define FF_PROFILE_H264_HIGH_422 122
2635 #define FF_PROFILE_H264_HIGH_422_INTRA (122|FF_PROFILE_H264_INTRA)
2636 #define FF_PROFILE_H264_HIGH_444 144
2637 #define FF_PROFILE_H264_HIGH_444_PREDICTIVE 244
2638 #define FF_PROFILE_H264_HIGH_444_INTRA (244|FF_PROFILE_H264_INTRA)
2639 #define FF_PROFILE_H264_CAVLC_444 44
2641 #define FF_PROFILE_VC1_SIMPLE 0
2642 #define FF_PROFILE_VC1_MAIN 1
2643 #define FF_PROFILE_VC1_COMPLEX 2
2644 #define FF_PROFILE_VC1_ADVANCED 3
2646 #define FF_PROFILE_MPEG4_SIMPLE 0
2647 #define FF_PROFILE_MPEG4_SIMPLE_SCALABLE 1
2648 #define FF_PROFILE_MPEG4_CORE 2
2649 #define FF_PROFILE_MPEG4_MAIN 3
2650 #define FF_PROFILE_MPEG4_N_BIT 4
2651 #define FF_PROFILE_MPEG4_SCALABLE_TEXTURE 5
2652 #define FF_PROFILE_MPEG4_SIMPLE_FACE_ANIMATION 6
2653 #define FF_PROFILE_MPEG4_BASIC_ANIMATED_TEXTURE 7
2654 #define FF_PROFILE_MPEG4_HYBRID 8
2655 #define FF_PROFILE_MPEG4_ADVANCED_REAL_TIME 9
2656 #define FF_PROFILE_MPEG4_CORE_SCALABLE 10
2657 #define FF_PROFILE_MPEG4_ADVANCED_CODING 11
2658 #define FF_PROFILE_MPEG4_ADVANCED_CORE 12
2659 #define FF_PROFILE_MPEG4_ADVANCED_SCALABLE_TEXTURE 13
2660 #define FF_PROFILE_MPEG4_SIMPLE_STUDIO 14
2661 #define FF_PROFILE_MPEG4_ADVANCED_SIMPLE 15
2663 #define FF_PROFILE_JPEG2000_CSTREAM_RESTRICTION_0 0
2664 #define FF_PROFILE_JPEG2000_CSTREAM_RESTRICTION_1 1
2665 #define FF_PROFILE_JPEG2000_CSTREAM_NO_RESTRICTION 2
2666 #define FF_PROFILE_JPEG2000_DCINEMA_2K 3
2667 #define FF_PROFILE_JPEG2000_DCINEMA_4K 4
2668 
2670 #define FF_PROFILE_HEVC_MAIN 1
2671 #define FF_PROFILE_HEVC_MAIN_10 2
2672 #define FF_PROFILE_HEVC_MAIN_STILL_PICTURE 3
2673 
2679  int level;
2680 #define FF_LEVEL_UNKNOWN -99
2681 
2688 
2694  enum AVDiscard skip_idct;
2695 
2701  enum AVDiscard skip_frame;
2702 
2713 
2714 #if FF_API_ERROR_RATE
2715 
2720  int error_rate;
2721 #endif
2722 
2723 #if FF_API_CODEC_PKT
2724 
2728  AVPacket *pkt;
2729 #endif
2730 
2737  uint64_t vbv_delay;
2738 } AVCodecContext;
2739 
2743 typedef struct AVProfile {
2744  int profile;
2745  const char *name;
2746 } AVProfile;
2747 
2748 typedef struct AVCodecDefault AVCodecDefault;
2749 
2750 struct AVSubtitle;
2751 
2755 typedef struct AVCodec {
2762  const char *name;
2767  const char *long_name;
2769  enum AVCodecID id;
2776  const enum AVPixelFormat *pix_fmts;
2779  const uint64_t *channel_layouts;
2780 #if FF_API_LOWRES
2782 #endif
2784  const AVProfile *profiles;
2785 
2786  /*****************************************************************
2787  * No fields below this line are part of the public API. They
2788  * may not be used outside of libavcodec and can be changed and
2789  * removed at will.
2790  * New public fields should be added right above.
2791  *****************************************************************
2792  */
2794  struct AVCodec *next;
2804  int (*init_thread_copy)(AVCodecContext *);
2812  int (*update_thread_context)(AVCodecContext *dst, const AVCodecContext *src);
2818  const AVCodecDefault *defaults;
2819 
2823  void (*init_static_data)(struct AVCodec *codec);
2826  int (*encode_sub)(AVCodecContext *, uint8_t *buf, int buf_size,
2827  const struct AVSubtitle *sub);
2838  int (*encode2)(AVCodecContext *avctx, AVPacket *avpkt, const AVFrame *frame,
2839  int *got_packet_ptr);
2840  int (*decode)(AVCodecContext *, void *outdata, int *outdata_size, AVPacket *avpkt);
2841  int (*close)(AVCodecContext *);
2846  void (*flush)(AVCodecContext *);
2847 } AVCodec;
2848 
2852 typedef struct AVHWAccel {
2858  const char *name;
2859 
2865  enum AVMediaType type;
2866 
2872  enum AVCodecID id;
2873 
2879  enum AVPixelFormat pix_fmt;
2880 
2885  int capabilities;
2887  struct AVHWAccel *next;
2888 
2903  int (*start_frame)(AVCodecContext *avctx, const uint8_t *buf, uint32_t buf_size);
2904 
2916  int (*decode_slice)(AVCodecContext *avctx, const uint8_t *buf, uint32_t buf_size);
2917 
2927  int (*end_frame)(AVCodecContext *avctx);
2928 
2936  int priv_data_size;
2937 } AVHWAccel;
2938 
2950 typedef struct AVPicture {
2953 } AVPicture;
2954 
2959 #define AVPALETTE_SIZE 1024
2960 #define AVPALETTE_COUNT 256
2963  SUBTITLE_NONE,
2965  SUBTITLE_BITMAP,
2966 
2971  SUBTITLE_TEXT,
2972 
2977  SUBTITLE_ASS,
2978 };
2980 #define AV_SUBTITLE_FLAG_FORCED 0x00000001
2982 typedef struct AVSubtitleRect {
2983  int x;
2984  int y;
2985  int w;
2986  int h;
2987  int nb_colors;
2988 
2994  enum AVSubtitleType type;
2996  char *text;
2997 
3003  char *ass;
3004  int flags;
3005 } AVSubtitleRect;
3007 typedef struct AVSubtitle {
3008  uint16_t format; /* 0 = graphics */
3009  uint32_t start_display_time; /* relative to packet pts, in ms */
3010  uint32_t end_display_time; /* relative to packet pts, in ms */
3011  unsigned num_rects;
3013  int64_t pts;
3014 } AVSubtitle;
3015 
3021 AVCodec *av_codec_next(const AVCodec *c);
3022 
3026 unsigned avcodec_version(void);
3027 
3031 const char *avcodec_configuration(void);
3032 
3036 const char *avcodec_license(void);
3037 
3046 void avcodec_register(AVCodec *codec);
3047 
3058 void avcodec_register_all(void);
3059 
3076 
3087 
3094 const AVClass *avcodec_get_class(void);
3095 
3107 int avcodec_copy_context(AVCodecContext *dest, const AVCodecContext *src);
3108 
3109 #if FF_API_AVFRAME_LAVC
3110 
3114 AVFrame *avcodec_alloc_frame(void);
3115 
3124 void avcodec_get_frame_defaults(AVFrame *frame);
3125 
3139 void avcodec_free_frame(AVFrame **frame);
3140 #endif
3141 
3178 int avcodec_open2(AVCodecContext *avctx, const AVCodec *codec, AVDictionary **options);
3179 
3189 int avcodec_close(AVCodecContext *avctx);
3190 
3196 void avsubtitle_free(AVSubtitle *sub);
3197 
3207 #if FF_API_DESTRUCT_PACKET
3208 
3213 void av_destruct_packet(AVPacket *pkt);
3214 #endif
3215 
3224 void av_init_packet(AVPacket *pkt);
3225 
3234 int av_new_packet(AVPacket *pkt, int size);
3235 
3242 void av_shrink_packet(AVPacket *pkt, int size);
3243 
3250 int av_grow_packet(AVPacket *pkt, int grow_by);
3251 
3265 int av_packet_from_data(AVPacket *pkt, uint8_t *data, int size);
3266 
3271 int av_dup_packet(AVPacket *pkt);
3272 
3278 void av_free_packet(AVPacket *pkt);
3279 
3289  int size);
3290 
3300  int size);
3301 
3311  int *size);
3312 
3320 
3337 int av_packet_ref(AVPacket *dst, AVPacket *src);
3338 
3347 void av_packet_unref(AVPacket *pkt);
3348 
3357 void av_packet_move_ref(AVPacket *dst, AVPacket *src);
3358 
3371 int av_packet_copy_props(AVPacket *dst, const AVPacket *src);
3372 
3389 
3397 
3398 #if FF_API_GET_BUFFER
3402 #endif
3403 
3410 
3411 #if FF_API_EMU_EDGE
3412 
3423 unsigned avcodec_get_edge_width(void);
3424 #endif
3425 
3434 
3443  int linesize_align[AV_NUM_DATA_POINTERS]);
3444 
3493 int avcodec_decode_audio4(AVCodecContext *avctx, AVFrame *frame,
3494  int *got_frame_ptr, AVPacket *avpkt);
3495 
3537  int *got_picture_ptr,
3538  AVPacket *avpkt);
3539 
3557  int *got_sub_ptr,
3558  AVPacket *avpkt);
3559 
3567  AV_PICTURE_STRUCTURE_TOP_FIELD, //< coded as top field
3568  AV_PICTURE_STRUCTURE_BOTTOM_FIELD, //< coded as bottom field
3569  AV_PICTURE_STRUCTURE_FRAME, //< coded as frame
3570 };
3572 typedef struct AVCodecParserContext {
3573  void *priv_data;
3575  int64_t frame_offset; /* offset of the current frame */
3576  int64_t cur_offset; /* current offset
3577  (incremented by each av_parser_parse()) */
3578  int64_t next_frame_offset; /* offset of the next frame */
3579  /* video info */
3580  int pict_type; /* XXX: Put it back in AVCodecContext. */
3590  int repeat_pict; /* XXX: Put it back in AVCodecContext. */
3591  int64_t pts; /* pts of the current frame */
3592  int64_t dts; /* dts of the current frame */
3593 
3594  /* private data */
3595  int64_t last_pts;
3596  int64_t last_dts;
3597  int fetch_timestamp;
3599 #define AV_PARSER_PTS_NB 4
3605  int flags;
3606 #define PARSER_FLAG_COMPLETE_FRAMES 0x0001
3607 #define PARSER_FLAG_ONCE 0x0002
3609 #define PARSER_FLAG_FETCHED_OFFSET 0x0004
3611  int64_t offset;
3613 
3620  int key_frame;
3621 
3639  int64_t convergence_duration;
3640 
3641  // Timestamp generation support:
3651  int dts_sync_point;
3652 
3666  int dts_ref_dts_delta;
3667 
3680  int pts_dts_delta;
3681 
3688 
3692  int64_t pos;
3693 
3697  int64_t last_pos;
3698 
3704  int duration;
3707 
3717 
3727 typedef struct AVCodecParser {
3728  int codec_ids[5]; /* several codec IDs are permitted */
3732  AVCodecContext *avctx,
3733  const uint8_t **poutbuf, int *poutbuf_size,
3734  const uint8_t *buf, int buf_size);
3736  int (*split)(AVCodecContext *avctx, const uint8_t *buf, int buf_size);
3737  struct AVCodecParser *next;
3738 } AVCodecParser;
3739 
3741 
3744 
3774  AVCodecContext *avctx,
3775  uint8_t **poutbuf, int *poutbuf_size,
3776  const uint8_t *buf, int buf_size,
3777  int64_t pts, int64_t dts,
3778  int64_t pos);
3779 
3785  AVCodecContext *avctx,
3786  uint8_t **poutbuf, int *poutbuf_size,
3787  const uint8_t *buf, int buf_size, int keyframe);
3789 
3807 
3815 
3854 int avcodec_encode_audio2(AVCodecContext *avctx, AVPacket *avpkt,
3855  const AVFrame *frame, int *got_packet_ptr);
3856 
3891 int avcodec_encode_video2(AVCodecContext *avctx, AVPacket *avpkt,
3892  const AVFrame *frame, int *got_packet_ptr);
3893 
3894 int avcodec_encode_subtitle(AVCodecContext *avctx, uint8_t *buf, int buf_size,
3895  const AVSubtitle *sub);
3896 
3897 
3919 
3928 
3950  enum AVPixelFormat pix_fmt, int width, int height);
3951 
3967 int avpicture_layout(const AVPicture* src, enum AVPixelFormat pix_fmt,
3968  int width, int height,
3969  unsigned char *dest, int dest_size);
3970 
3984 
3985 #if FF_API_DEINTERLACE
3986 
3992 int avpicture_deinterlace(AVPicture *dst, const AVPicture *src,
3993  enum AVPixelFormat pix_fmt, int width, int height);
3994 #endif
3995 
3998 void av_picture_copy(AVPicture *dst, const AVPicture *src,
3999  enum AVPixelFormat pix_fmt, int width, int height);
4000 
4004 int av_picture_crop(AVPicture *dst, const AVPicture *src,
4005  enum AVPixelFormat pix_fmt, int top_band, int left_band);
4006 
4010 int av_picture_pad(AVPicture *dst, const AVPicture *src, int height, int width, enum AVPixelFormat pix_fmt,
4011  int padtop, int padbottom, int padleft, int padright, int *color);
4012 
4037 void attribute_deprecated avcodec_get_chroma_sub_sample(enum AVPixelFormat pix_fmt, int *h_shift, int *v_shift);
4038 
4046 #define FF_LOSS_RESOLUTION 0x0001
4047 #define FF_LOSS_DEPTH 0x0002
4048 #define FF_LOSS_COLORSPACE 0x0004
4049 #define FF_LOSS_ALPHA 0x0008
4050 #define FF_LOSS_COLORQUANT 0x0010
4051 #define FF_LOSS_CHROMA 0x0020
4070 int avcodec_get_pix_fmt_loss(enum AVPixelFormat dst_pix_fmt, enum AVPixelFormat src_pix_fmt,
4071  int has_alpha);
4072 
4091  enum AVPixelFormat src_pix_fmt,
4092  int has_alpha, int *loss_ptr);
4093 
4094 enum AVPixelFormat avcodec_default_get_format(struct AVCodecContext *s, const enum AVPixelFormat * fmt);
4095 
4100 #if FF_API_SET_DIMENSIONS
4101 
4106 #endif
4107 
4117 size_t av_get_codec_tag_string(char *buf, size_t buf_size, unsigned int codec_tag);
4118 
4119 void avcodec_string(char *buf, int buf_size, AVCodecContext *enc, int encode);
4120 
4128 const char *av_get_profile_name(const AVCodec *codec, int profile);
4129 
4130 int avcodec_default_execute(AVCodecContext *c, int (*func)(AVCodecContext *c2, void *arg2),void *arg, int *ret, int count, int size);
4131 int avcodec_default_execute2(AVCodecContext *c, int (*func)(AVCodecContext *c2, void *arg2, int, int),void *arg, int *ret, int count);
4132 //FIXME func typedef
4133 
4151  enum AVSampleFormat sample_fmt, const uint8_t *buf,
4152  int buf_size, int align);
4153 
4164 
4172 
4182 
4191 int av_get_audio_frame_duration(AVCodecContext *avctx, int frame_bytes);
4192 
4195  void *priv_data;
4200 
4202 typedef struct AVBitStreamFilter {
4203  const char *name;
4205  int (*filter)(AVBitStreamFilterContext *bsfc,
4206  AVCodecContext *avctx, const char *args,
4207  uint8_t **poutbuf, int *poutbuf_size,
4208  const uint8_t *buf, int buf_size, int keyframe);
4210  struct AVBitStreamFilter *next;
4212 
4216  AVCodecContext *avctx, const char *args,
4217  uint8_t **poutbuf, int *poutbuf_size,
4218  const uint8_t *buf, int buf_size, int keyframe);
4220 
4222 
4223 /* memory */
4224 
4232 void av_fast_padded_malloc(void *ptr, unsigned int *size, size_t min_size);
4233 
4241 unsigned int av_xiphlacing(unsigned char *s, unsigned int v);
4242 
4243 #if FF_API_MISSING_SAMPLE
4244 
4258 void av_log_missing_feature(void *avc, const char *feature, int want_sample);
4259 
4270 void av_log_ask_for_sample(void *avc, const char *msg, ...) av_printf_format(2, 3);
4271 #endif /* FF_API_MISSING_SAMPLE */
4272 
4276 void av_register_hwaccel(AVHWAccel *hwaccel);
4277 
4284 
4285 
4289 enum AVLockOp {
4293  AV_LOCK_DESTROY,
4294 };
4295 
4309 int av_lockmgr_register(int (*cb)(void **mutex, enum AVLockOp op));
4310 
4315 
4321 
4325 int av_codec_is_encoder(const AVCodec *codec);
4326 
4330 int av_codec_is_decoder(const AVCodec *codec);
4331 
4336 
4345 
4351 
4356 #endif /* AVCODEC_AVCODEC_H */