Skip to content
Snippets Groups Projects
avcodec.h 123 KiB
Newer Older
  • Learn to ignore specific revisions
  •      */
        int inter_threshold;
    
        /**
    
    Diego Biurrun's avatar
    Diego Biurrun committed
         * CODEC_FLAG2_*
         * - encoding: Set by user.
         * - decoding: Set by user.
    
         */
        int flags2;
    
    Diego Biurrun's avatar
    Diego Biurrun committed
         * Simulates errors in the bitstream to test error concealment.
         * - encoding: Set by user.
         * - decoding: unused
    
         */
        int error_rate;
    
        /**
         * MP3 antialias algorithm, see FF_AA_* below.
         * - encoding: unused
    
    Diego Biurrun's avatar
    Diego Biurrun committed
         * - decoding: Set by user.
    
         */
        int antialias_algo;
    #define FF_AA_AUTO    0
    #define FF_AA_FASTINT 1 //not implemented yet
    #define FF_AA_INT     2
    #define FF_AA_FLOAT   3
    
    Diego Biurrun's avatar
    Diego Biurrun committed
         * quantizer noise shaping
         * - encoding: Set by user.
    
         * - decoding: unused
         */
        int quantizer_noise_shaping;
    
    Diego Biurrun's avatar
    Diego Biurrun committed
         * thread count
    
         * is used to decide how many independent tasks should be passed to execute()
    
    Diego Biurrun's avatar
    Diego Biurrun committed
         * - encoding: Set by user.
         * - decoding: Set by user.
    
         */
        int thread_count;
    
    Diego Biurrun's avatar
    Diego Biurrun committed
         * The codec may call this to execute several independent things.
         * It will return only after finishing all tasks.
         * The user may replace this with some multithreaded implementation,
         * the default implementation will execute the parts serially.
    
         * @param count the number of things to execute
    
    Diego Biurrun's avatar
    Diego Biurrun committed
         * - encoding: Set by libavcodec, user can override.
         * - decoding: Set by libavcodec, user can override.
    
        int (*execute)(struct AVCodecContext *c, int (*func)(struct AVCodecContext *c2, void *arg), void *arg2, int *ret, int count, int size);
    
    Diego Biurrun's avatar
    Diego Biurrun committed
         * thread opaque
         * Can be used by execute() to store some per AVCodecContext stuff.
    
         * - encoding: set by execute()
         * - decoding: set by execute()
         */
        void *thread_opaque;
    
    Diego Biurrun's avatar
    Diego Biurrun committed
         * Motion estimation threshold below which no motion estimation is
         * performed, but instead the user specified motion vectors are used.
    
    Diego Biurrun's avatar
    Diego Biurrun committed
         * - encoding: Set by user.
    
         int me_threshold;
    
    Diego Biurrun's avatar
    Diego Biurrun committed
         * Macroblock threshold below which the user specified macroblock types will be used.
         * - encoding: Set by user.
    
    Diego Biurrun's avatar
    Diego Biurrun committed
         * precision of the intra DC coefficient - 8
         * - encoding: Set by user.
    
         * - decoding: unused
         */
         int intra_dc_precision;
    
    Diego Biurrun's avatar
    Diego Biurrun committed
         * noise vs. sse weight for the nsse comparsion function
         * - encoding: Set by user.
    
    Michael Niedermayer's avatar
    Michael Niedermayer committed
         * - decoding: unused
         */
         int nsse_weight;
    
    Diego Biurrun's avatar
    Diego Biurrun committed
         * Number of macroblock rows at the top which are skipped.
    
         * - encoding: unused
    
    Diego Biurrun's avatar
    Diego Biurrun committed
         * - decoding: Set by user.
    
    Diego Biurrun's avatar
    Diego Biurrun committed
         * Number of macroblock rows at the bottom which are skipped.
    
         * - encoding: unused
    
    Diego Biurrun's avatar
    Diego Biurrun committed
         * - decoding: Set by user.
    
    Diego Biurrun's avatar
    Diego Biurrun committed
         * - encoding: Set by user.
         * - decoding: Set by libavcodec.
    
         */
         int profile;
    #define FF_PROFILE_UNKNOWN -99
    
    #define FF_PROFILE_AAC_MAIN 0
    
    Diego Biurrun's avatar
    Diego Biurrun committed
    #define FF_PROFILE_AAC_LOW  1
    #define FF_PROFILE_AAC_SSR  2
    #define FF_PROFILE_AAC_LTP  3
    
    Diego Biurrun's avatar
    Diego Biurrun committed
         * - encoding: Set by user.
         * - decoding: Set by libavcodec.
    
         */
         int level;
    #define FF_LEVEL_UNKNOWN -99
    
    Diego Biurrun's avatar
    Diego Biurrun committed
         * low resolution decoding, 1-> 1/2 size, 2->1/4 size
    
         * - encoding: unused
    
    Diego Biurrun's avatar
    Diego Biurrun committed
         * - decoding: Set by user.
    
         */
         int lowres;
    
    Diego Biurrun's avatar
    Diego Biurrun committed
         * Bitstream width / height, may be different from width/height if lowres
         * or other things are used.
    
         * - encoding: unused
    
    Diego Biurrun's avatar
    Diego Biurrun committed
         * - decoding: Set by user before init if known. Codec should override / dynamically change if needed.
    
         */
        int coded_width, coded_height;
    
    Michael Niedermayer's avatar
    Michael Niedermayer committed
    
        /**
         * frame skip threshold
    
    Diego Biurrun's avatar
    Diego Biurrun committed
         * - encoding: Set by user.
    
    Michael Niedermayer's avatar
    Michael Niedermayer committed
         * - decoding: unused
         */
        int frame_skip_threshold;
    
        /**
         * frame skip factor
    
    Diego Biurrun's avatar
    Diego Biurrun committed
         * - encoding: Set by user.
    
    Michael Niedermayer's avatar
    Michael Niedermayer committed
         * - decoding: unused
         */
        int frame_skip_factor;
    
    
        /**
         * frame skip exponent
    
    Diego Biurrun's avatar
    Diego Biurrun committed
         * - encoding: Set by user.
    
         * - decoding: unused
         */
        int frame_skip_exp;
    
        /**
    
    Diego Biurrun's avatar
    Diego Biurrun committed
         * frame skip comparison function
         * - encoding: Set by user.
    
         * - decoding: unused
         */
        int frame_skip_cmp;
    
    Diego Biurrun's avatar
    Diego Biurrun committed
         * Border processing masking, raises the quantizer for mbs on the borders
    
    Diego Biurrun's avatar
    Diego Biurrun committed
         * - encoding: Set by user.
    
    Diego Biurrun's avatar
    Diego Biurrun committed
         * minimum MB lagrange multipler
         * - encoding: Set by user.
    
    Diego Biurrun's avatar
    Diego Biurrun committed
         * maximum MB lagrange multipler
         * - encoding: Set by user.
    
    Diego Biurrun's avatar
    Diego Biurrun committed
         * - encoding: Set by user.
    
         * - decoding: unused
         */
        int me_penalty_compensation;
    
    Michael Niedermayer's avatar
    Michael Niedermayer committed
    
        /**
    
    Michael Niedermayer's avatar
    Michael Niedermayer committed
         * - encoding: unused
    
    Diego Biurrun's avatar
    Diego Biurrun committed
         * - decoding: Set by user.
    
    Michael Niedermayer's avatar
    Michael Niedermayer committed
         */
        enum AVDiscard skip_loop_filter;
    
        /**
    
    Michael Niedermayer's avatar
    Michael Niedermayer committed
         * - encoding: unused
    
    Diego Biurrun's avatar
    Diego Biurrun committed
         * - decoding: Set by user.
    
    Michael Niedermayer's avatar
    Michael Niedermayer committed
         */
        enum AVDiscard skip_idct;
    
        /**
    
    Michael Niedermayer's avatar
    Michael Niedermayer committed
         * - encoding: unused
    
    Diego Biurrun's avatar
    Diego Biurrun committed
         * - decoding: Set by user.
    
    Michael Niedermayer's avatar
    Michael Niedermayer committed
         */
        enum AVDiscard skip_frame;
    
    Diego Biurrun's avatar
    Diego Biurrun committed
         * - encoding: Set by user.
    
         * - decoding: unused
         */
        int bidir_refine;
    
    Diego Biurrun's avatar
    Diego Biurrun committed
         * - encoding: Set by user.
    
    Robert Swain's avatar
    Robert Swain committed
    
        /**
         * constant rate factor - quality-based VBR - values ~correspond to qps
    
    Diego Biurrun's avatar
    Diego Biurrun committed
         * - encoding: Set by user.
    
    Robert Swain's avatar
    Robert Swain committed
         * - decoding: unused
         */
    
        float crf;
    
    Robert Swain's avatar
    Robert Swain committed
    
        /**
         * constant quantization parameter rate control method
    
    Diego Biurrun's avatar
    Diego Biurrun committed
         * - encoding: Set by user.
    
    Robert Swain's avatar
    Robert Swain committed
         * - decoding: unused
         */
        int cqp;
    
        /**
    
    Diego Biurrun's avatar
    Diego Biurrun committed
         * minimum GOP size
         * - encoding: Set by user.
    
    Robert Swain's avatar
    Robert Swain committed
         * - decoding: unused
         */
        int keyint_min;
    
        /**
         * number of reference frames
    
    Diego Biurrun's avatar
    Diego Biurrun committed
         * - encoding: Set by user.
    
         * - decoding: Set by lavc.
    
    Robert Swain's avatar
    Robert Swain committed
         */
        int refs;
    
        /**
         * chroma qp offset from luma
    
    Diego Biurrun's avatar
    Diego Biurrun committed
         * - encoding: Set by user.
    
    Robert Swain's avatar
    Robert Swain committed
         * - decoding: unused
         */
        int chromaoffset;
    
        /**
    
    Diego Biurrun's avatar
    Diego Biurrun committed
         * Influences how often B-frames are used.
         * - encoding: Set by user.
    
    Robert Swain's avatar
    Robert Swain committed
         * - decoding: unused
         */
        int bframebias;
    
        /**
         * trellis RD quantization
    
    Diego Biurrun's avatar
    Diego Biurrun committed
         * - encoding: Set by user.
    
    Robert Swain's avatar
    Robert Swain committed
         * - decoding: unused
         */
        int trellis;
    
        /**
    
    Diego Biurrun's avatar
    Diego Biurrun committed
         * Reduce fluctuations in qp (before curve compression).
         * - encoding: Set by user.
    
    Robert Swain's avatar
    Robert Swain committed
         * - decoding: unused
         */
        float complexityblur;
    
        /**
         * in-loop deblocking filter alphac0 parameter
         * alpha is in the range -6...6
    
    Diego Biurrun's avatar
    Diego Biurrun committed
         * - encoding: Set by user.
    
    Robert Swain's avatar
    Robert Swain committed
         * - decoding: unused
         */
        int deblockalpha;
    
        /**
         * in-loop deblocking filter beta parameter
         * beta is in the range -6...6
    
    Diego Biurrun's avatar
    Diego Biurrun committed
         * - encoding: Set by user.
    
    Robert Swain's avatar
    Robert Swain committed
         * - decoding: unused
         */
        int deblockbeta;
    
        /**
         * macroblock subpartition sizes to consider - p8x8, p4x4, b8x8, i8x8, i4x4
    
    Diego Biurrun's avatar
    Diego Biurrun committed
         * - encoding: Set by user.
    
    Robert Swain's avatar
    Robert Swain committed
         * - decoding: unused
         */
        int partitions;
    
    #define X264_PART_I4X4 0x001  /* Analyze i4x4 */
    #define X264_PART_I8X8 0x002  /* Analyze i8x8 (requires 8x8 transform) */
    #define X264_PART_P8X8 0x010  /* Analyze p16x8, p8x16 and p8x8 */
    #define X264_PART_P4X4 0x020  /* Analyze p8x4, p4x8, p4x4 */
    #define X264_PART_B8X8 0x100  /* Analyze b16x8, b8x16 and b8x8 */
    
         * direct MV prediction mode - 0 (none), 1 (spatial), 2 (temporal), 3 (auto)
    
    Diego Biurrun's avatar
    Diego Biurrun committed
         * - encoding: Set by user.
    
    Robert Swain's avatar
    Robert Swain committed
         * - decoding: unused
         */
        int directpred;
    
         * Audio cutoff bandwidth (0 means "automatic")
    
    Diego Biurrun's avatar
    Diego Biurrun committed
         * - encoding: Set by user.
    
    Diego Biurrun's avatar
    Diego Biurrun committed
         * Multiplied by qscale for each frame and added to scene_change_score.
         * - encoding: Set by user.
    
         * - decoding: unused
         */
        int scenechange_factor;
    
    Diego Biurrun's avatar
    Diego Biurrun committed
         * Note: Value depends upon the compare function used for fullpel ME.
         * - encoding: Set by user.
    
         * - decoding: unused
         */
        int mv0_threshold;
    
    Diego Biurrun's avatar
    Diego Biurrun committed
         * Adjusts sensitivity of b_frame_strategy 1.
         * - encoding: Set by user.
    
         * - decoding: unused
         */
        int b_sensitivity;
    
    Diego Biurrun's avatar
    Diego Biurrun committed
         * - encoding: Set by user.
    
         * - decoding: unused
         */
        int compression_level;
    #define FF_COMPRESSION_DEFAULT -1
    
        /**
    
    Diego Biurrun's avatar
    Diego Biurrun committed
         * Sets whether to use LPC mode - used by FLAC encoder.
         * - encoding: Set by user.
         * - decoding: unused
    
         */
        int use_lpc;
    
        /**
         * LPC coefficient precision - used by FLAC encoder
    
    Diego Biurrun's avatar
    Diego Biurrun committed
         * - encoding: Set by user.
         * - decoding: unused
    
    Diego Biurrun's avatar
    Diego Biurrun committed
         * - encoding: Set by user.
         * - decoding: unused
    
    Diego Biurrun's avatar
    Diego Biurrun committed
         * - encoding: Set by user.
         * - decoding: unused
    
         */
        int max_prediction_order;
    
        /**
         * search method for selecting prediction order
    
    Diego Biurrun's avatar
    Diego Biurrun committed
         * - encoding: Set by user.
         * - decoding: unused
    
    Diego Biurrun's avatar
    Diego Biurrun committed
         * - encoding: Set by user.
         * - decoding: unused
    
    Diego Biurrun's avatar
    Diego Biurrun committed
         * - encoding: Set by user.
         * - decoding: unused
    
    
        /**
         * GOP timecode frame start number, in non drop frame format
    
    Diego Biurrun's avatar
    Diego Biurrun committed
         * - encoding: Set by user.
         * - decoding: unused
    
    #if LIBAVCODEC_VERSION_MAJOR < 53
    
         * Decoder should decode to this many channels if it can (0 for default)
         * - encoding: unused
         * - decoding: Set by user.
    
         * @deprecated Deprecated in favor of request_channel_layout.
    
    
        /**
         * Percentage of dynamic range compression to be applied by the decoder.
         * The default value is 1.0, corresponding to full compression.
         * - encoding: unused
         * - decoding: Set by user.
         */
        float drc_scale;
    
    
        /**
         * opaque 64bit number (generally a PTS) that will be reordered and
         * output in AVFrame.reordered_opaque
         * - encoding: unused
         * - decoding: Set by user.
         */
        int64_t reordered_opaque;
    
    
        /**
         * Bits per sample/pixel of internal libavcodec pixel/sample format.
         * This field is applicable only when sample_fmt is SAMPLE_FMT_S32.
         * - encoding: set by user.
         * - decoding: set by libavcodec.
         */
        int bits_per_raw_sample;
    
    
        /**
         * Audio channel layout.
         * - encoding: set by user.
         * - decoding: set by libavcodec.
         */
        int64_t channel_layout;
    
        /**
         * Request decoder to use this channel layout if it can (0 for default)
         * - encoding: unused
         * - decoding: Set by user.
         */
        int64_t request_channel_layout;
    
    
        /**
         * Ratecontrol attempt to use, at maximum, <value> of what can be used without an underflow.
         * - encoding: Set by user.
         * - decoding: unused.
         */
        float rc_max_available_vbv_use;
    
        /**
         * Ratecontrol attempt to use, at least, <value> times the amount needed to prevent a vbv overflow.
         * - encoding: Set by user.
         * - decoding: unused.
         */
        float rc_min_vbv_overflow_use;
    
    
        /**
         * Hardware accelerator in use
         * - encoding: unused.
         * - decoding: Set by libavcodec
         */
        struct AVHWAccel *hwaccel;
    
    
        /**
         * For some codecs, the time base is closer to the field rate than the frame rate.
         * Most notably, H.264 and MPEG-2 specify time_base as half of frame duration
         * if no telecine is used ...
         *
         * Set to time_base ticks per frame. Default 1, e.g., H.264/MPEG-2 set it to 2.
         */
        int ticks_per_frame;
    
    
        /**
         * Hardware accelerator context.
         * For some hardware accelerators, a global context needs to be
         * provided by the user. In that case, this holds display-dependent
         * data FFmpeg cannot instantiate itself. Please refer to the
         * FFmpeg HW accelerator documentation to know how to fill this
         * is. e.g. for VA API, this is a struct vaapi_context.
         * - encoding: unused
         * - decoding: Set by user
         */
        void *hwaccel_context;
    
    
        /**
         * Chromaticity coordinates of the source primaries.
         * - encoding: Set by user
         * - decoding: Set by libavcodec
         */
        enum AVColorPrimaries color_primaries;
    
        /**
         * Color Transfer Characteristic.
         * - encoding: Set by user
         * - decoding: Set by libavcodec
         */
        enum AVColorTransferCharacteristic color_trc;
    
        /**
         * YUV colorspace type.
         * - encoding: Set by user
         * - decoding: Set by libavcodec
         */
        enum AVColorSpace colorspace;
    
        /**
         * MPEG vs JPEG YUV range.
         * - encoding: Set by user
         * - decoding: Set by libavcodec
         */
        enum AVColorRange color_range;
    
    
        /**
         * This defines the location of chroma samples.
         * - encoding: Set by user
         * - decoding: Set by libavcodec
         */
    
        enum AVChromaLocation chroma_sample_location;
    
    
        /**
         * The codec may call this to execute several independent things.
         * It will return only after finishing all tasks.
         * The user may replace this with some multithreaded implementation,
         * the default implementation will execute the parts serially.
         * Also see avcodec_thread_init and e.g. the --enable-pthread configure option.
         * @param c context passed also to func
         * @param count the number of things to execute
         * @param arg2 argument passed unchanged to func
         * @param ret return values of executed functions, must have space for "count" values. May be NULL.
         * @param func function that will be called count times, with jobnr from 0 to count-1.
         *             threadnr will be in the range 0 to c->thread_count-1 < MAX_THREADS and so that no
         *             two instances of func executing at the same time will have the same threadnr.
         * @return always 0 currently, but code should handle a future improvement where when any call to func
         *         returns < 0 no further calls to func may be done and < 0 is returned.
         * - encoding: Set by libavcodec, user can override.
         * - decoding: Set by libavcodec, user can override.
         */
        int (*execute2)(struct AVCodecContext *c, int (*func)(struct AVCodecContext *c2, void *arg, int jobnr, int threadnr), void *arg2, int *ret, int count);
    
    Fabrice Bellard's avatar
    Fabrice Bellard committed
    } AVCodecContext;
    
    
    Fabrice Bellard's avatar
    Fabrice Bellard committed
    typedef struct AVCodec {
    
        /**
         * Name of the codec implementation.
         * The name is globally unique among encoders and among decoders (but an
         * encoder and a decoder can share the same name).
         * This is the primary way to find a codec from the user perspective.
         */
    
        const char *name;
    
    Zdenek Kabelac's avatar
    Zdenek Kabelac committed
        enum CodecType type;
    
    Michael Niedermayer's avatar
    Michael Niedermayer committed
        enum CodecID id;
    
    Fabrice Bellard's avatar
    Fabrice Bellard committed
        int priv_data_size;
        int (*init)(AVCodecContext *);
    
        int (*encode)(AVCodecContext *, uint8_t *buf, int buf_size, void *data);
    
    Fabrice Bellard's avatar
    Fabrice Bellard committed
        int (*close)(AVCodecContext *);
    
        int (*decode)(AVCodecContext *, void *outdata, int *outdata_size, AVPacket *avpkt);
    
        /**
         * Codec capabilities.
         * see CODEC_CAP_*
         */
    
        int capabilities;
    
    Fabrice Bellard's avatar
    Fabrice Bellard committed
        struct AVCodec *next;
    
        /**
         * Flush buffers.
         * Will be called when seeking
         */
    
    Michael Niedermayer's avatar
    Michael Niedermayer committed
        void (*flush)(AVCodecContext *);
    
        const AVRational *supported_framerates; ///< array of supported framerates, or NULL if any, array is terminated by {0,0}
    
    Benoit Fouet's avatar
    Benoit Fouet committed
        const enum PixelFormat *pix_fmts;       ///< array of supported pixel formats, or NULL if unknown, array is terminated by -1
    
         * Descriptive name for the codec, meant to be more human readable than name.
         * You should use the NULL_IF_CONFIG_SMALL() macro to define it.
    
        const int *supported_samplerates;       ///< array of supported audio samplerates, or NULL if unknown, array is terminated by 0
    
        const enum SampleFormat *sample_fmts;   ///< array of supported sample formats, or NULL if unknown, array is terminated by -1
    
        const int64_t *channel_layouts;         ///< array of support channel layouts, or NULL if unknown. array is terminated by 0
    
    Fabrice Bellard's avatar
    Fabrice Bellard committed
    } AVCodec;
    
    
    /**
     * AVHWAccel.
     */
    typedef struct AVHWAccel {
        /**
         * Name of the hardware accelerated codec.
         * The name is globally unique among encoders and among decoders (but an
         * encoder and a decoder can share the same name).
         */
        const char *name;
    
        /**
         * Type of codec implemented by the hardware accelerator.
         *
         * See CODEC_TYPE_xxx
         */
        enum CodecType type;
    
        /**
         * Codec implemented by the hardware accelerator.
         *
         * See CODEC_ID_xxx
         */
        enum CodecID id;
    
        /**
         * Supported pixel format.
         *
         * Only hardware accelerated formats are supported here.
         */
        enum PixelFormat pix_fmt;
    
        /**
         * Hardware accelerated codec capabilities.
         * see FF_HWACCEL_CODEC_CAP_*
         */
        int capabilities;
    
        struct AVHWAccel *next;
    
        /**
         * Called at the beginning of each frame or field picture.
         *
         * Meaningful frame information (codec specific) is guaranteed to
         * be parsed at this point. This function is mandatory.
         *
    
         * Note that buf can be NULL along with buf_size set to 0.
    
         * Otherwise, this means the whole frame is available at this point.
         *
         * @param avctx the codec context
         * @param buf the frame data buffer base
         * @param buf_size the size of the frame in bytes
         * @return zero if successful, a negative value otherwise
         */
        int (*start_frame)(AVCodecContext *avctx, const uint8_t *buf, uint32_t buf_size);
    
        /**
         * Callback for each slice.
         *
         * Meaningful slice information (codec specific) is guaranteed to
         * be parsed at this point. This function is mandatory.
         *
         * @param avctx the codec context
         * @param buf the slice data buffer base
         * @param buf_size the size of the slice in bytes
         * @return zero if successful, a negative value otherwise
         */
        int (*decode_slice)(AVCodecContext *avctx, const uint8_t *buf, uint32_t buf_size);
    
        /**
         * Called at the end of each frame or field picture.
         *
         * The whole picture is parsed at this point and can now be sent
         * to the hardware accelerator. This function is mandatory.
         *
         * @param avctx the codec context
         * @return zero if successful, a negative value otherwise
         */
        int (*end_frame)(AVCodecContext *avctx);
    
    
        /**
         * Size of HW accelerator private data.
         *
    
         * Private data is allocated with av_mallocz() before
         * AVCodecContext.get_buffer() and deallocated after
         * AVCodecContext.release_buffer().
    
     * four components are given, that's all.
     * the last component is alpha
     */
    
    Fabrice Bellard's avatar
    Fabrice Bellard committed
    typedef struct AVPicture {
    
        uint8_t *data[4];
    
    Michael Niedermayer's avatar
    Michael Niedermayer committed
        int linesize[4];       ///< number of bytes per line
    
    Fabrice Bellard's avatar
    Fabrice Bellard committed
    } AVPicture;
    
    
    #if LIBAVCODEC_VERSION_MAJOR < 53
    
     * AVPaletteControl
     * This structure defines a method for communicating palette changes
     * between and demuxer and a decoder.
     *
    
     * @deprecated Use AVPacket to send palette changes instead.
    
    #define AVPALETTE_SIZE 1024
    
    Michael Niedermayer's avatar
    Michael Niedermayer committed
    #define AVPALETTE_COUNT 256
    
    typedef struct AVPaletteControl {
    
    
    Diego Biurrun's avatar
    Diego Biurrun committed
        /* Demuxer sets this to 1 to indicate the palette has changed;
         * decoder resets to 0. */
    
        int palette_changed;
    
    
        /* 4-byte ARGB palette entries, stored in native byte order; note that
         * the individual palette components should be on a 8-bit scale; if
    
    Diego Biurrun's avatar
    Diego Biurrun committed
         * the palette data comes from an IBM VGA native format, the component
         * data is probably 6 bits in size and needs to be scaled. */
    
        unsigned int palette[AVPALETTE_COUNT];
    
    enum AVSubtitleType {
        SUBTITLE_NONE,
    
        SUBTITLE_BITMAP,                ///< A bitmap, pict will be set
    
        /**
         * Plain text, the text field must be set by the decoder and is
         * authoritative. ass and pict fields may contain approximations.
         */
        SUBTITLE_TEXT,
    
        /**
         * Formatted text, the ass field must be set by the decoder and is
         * authoritative. pict and text fields may contain approximations.
         */
        SUBTITLE_ASS,
    };
    
    
    typedef struct AVSubtitleRect {
    
        int x;         ///< top left corner  of pict, undefined when pict is not set
        int y;         ///< top left corner  of pict, undefined when pict is not set
        int w;         ///< width            of pict, undefined when pict is not set
        int h;         ///< height           of pict, undefined when pict is not set
        int nb_colors; ///< number of colors in pict, undefined when pict is not set
    
    
        /**
         * data+linesize for the bitmap of this subtitle.
         * can be set for text/ass as well once they where rendered
         */
        AVPicture pict;
    
        enum AVSubtitleType type;
    
        char *text;                     ///< 0 terminated plain UTF-8 text
    
        /**
         * 0 terminated ASS/SSA compatible event line.
         * The pressentation of this is unaffected by the other values in this
         * struct.
         */
        char *ass;
    
    } AVSubtitleRect;
    
    typedef struct AVSubtitle {
        uint16_t format; /* 0 = graphics */
        uint32_t start_display_time; /* relative to packet pts, in ms */
        uint32_t end_display_time; /* relative to packet pts, in ms */
    
        int64_t pts;    ///< Same as packet pts, in AV_TIME_BASE
    
    } AVSubtitle;
    
    
    /**
     * @deprecated use NULL instead
     */
    attribute_deprecated void av_destruct_packet_nofree(AVPacket *pkt);
    
    
    /**
     * Default packet destructor.
     */
    void av_destruct_packet(AVPacket *pkt);
    
    /**
     * Initialize optional fields of a packet with default values.
     *
     * @param pkt packet
     */
    void av_init_packet(AVPacket *pkt);
    
    /**
     * Allocate the payload of a packet and initialize its fields with
     * default values.
     *
     * @param pkt packet
     * @param size wanted payload size
     * @return 0 if OK, AVERROR_xxx otherwise
     */
    int av_new_packet(AVPacket *pkt, int size);
    
    
    /**
     * Reduce packet size, correctly zeroing padding
     *
     * @param pkt packet
     * @param size new size
     */
    void av_shrink_packet(AVPacket *pkt, int size);
    
    
    /**
     * @warning This is a hack - the packet memory allocation stuff is broken. The
     * packet is allocated if it was not really allocated.
     */
    int av_dup_packet(AVPacket *pkt);
    
    /**
     * Free a packet.
     *
     * @param pkt packet to free
     */
    
    Ramiro Polla's avatar
    Ramiro Polla committed
    void av_free_packet(AVPacket *pkt);
    
    Fabrice Bellard's avatar
    Fabrice Bellard committed
    /* resample.c */
    
    struct ReSampleContext;
    
    Fabrice Bellard's avatar
    Fabrice Bellard committed
    
    typedef struct ReSampleContext ReSampleContext;
    
    
    #if LIBAVCODEC_VERSION_MAJOR < 53
    /**
     * @deprecated Use av_audio_resample_init() instead.
     */
    attribute_deprecated ReSampleContext *audio_resample_init(int output_channels, int input_channels,
                                                              int output_rate, int input_rate);
    #endif
    /**
     *  Initializes audio resampling context
     *
     * @param output_channels  number of output channels
     * @param input_channels   number of input channels
     * @param output_rate      output sample rate
     * @param input_rate       input sample rate
     * @param sample_fmt_out   requested output sample format
     * @param sample_fmt_in    input sample format
     * @param filter_length    length of each FIR filter in the filterbank relative to the cutoff freq
     * @param log2_phase_count log2 of the number of entries in the polyphase filterbank
     * @param linear           If 1 then the used FIR filter will be linearly interpolated
                               between the 2 closest, if 0 the closest will be used
     * @param cutoff           cutoff frequency, 1.0 corresponds to half the output sampling rate
     * @return allocated ReSampleContext, NULL if error occured
     */
    ReSampleContext *av_audio_resample_init(int output_channels, int input_channels,
                                            int output_rate, int input_rate,
                                            enum SampleFormat sample_fmt_out,
                                            enum SampleFormat sample_fmt_in,
                                            int filter_length, int log2_phase_count,
                                            int linear, double cutoff);
    
    
    Fabrice Bellard's avatar
    Fabrice Bellard committed
    int audio_resample(ReSampleContext *s, short *output, short *input, int nb_samples);
    void audio_resample_close(ReSampleContext *s);
    
    
    
    /**
     * Initializes an audio resampler.
     * Note, if either rate is not an integer then simply scale both rates up so they are.
    
     * @param filter_length length of each FIR filter in the filterbank relative to the cutoff freq
     * @param log2_phase_count log2 of the number of entries in the polyphase filterbank
     * @param linear If 1 then the used FIR filter will be linearly interpolated
                     between the 2 closest, if 0 the closest will be used
     * @param cutoff cutoff frequency, 1.0 corresponds to half the output sampling rate
    
    struct AVResampleContext *av_resample_init(int out_rate, int in_rate, int filter_length, int log2_phase_count, int linear, double cutoff);
    
    
    /**
     * resamples.
     * @param src an array of unconsumed samples
     * @param consumed the number of samples of src which have been consumed are returned here
     * @param src_size the number of unconsumed samples available
     * @param dst_size the amount of space in samples available in dst
     * @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.
     * @return the number of samples written in dst or -1 if an error occurred
     */
    
    int av_resample(struct AVResampleContext *c, short *dst, short *src, int *consumed, int src_size, int dst_size, int update_ctx);
    
    
    
    /**
     * Compensates samplerate/timestamp drift. The compensation is done by changing
     * the resampler parameters, so no audible clicks or similar distortions occur
     * @param compensation_distance distance in output samples over which the compensation should be performed
     * @param sample_delta number of output samples which should be output less
     *
     * example: av_resample_compensate(c, 10, 500)
     * here instead of 510 samples only 500 samples would be output
     *
     * note, due to rounding the actual compensation might be slightly different,
     * especially if the compensation_distance is large and the in_rate used during init is small
     */
    
    Michael Niedermayer's avatar
    Michael Niedermayer committed
    void av_resample_compensate(struct AVResampleContext *c, int sample_delta, int compensation_distance);
    
    Drew Hess's avatar
    Drew Hess committed
    /**
     * Allocate memory for a picture.  Call avpicture_free to free it.
     *
    
    Diego Biurrun's avatar
    Diego Biurrun committed
     * @param picture the picture to be filled in
     * @param pix_fmt the format of the picture
     * @param width the width of the picture
     * @param height the height of the picture
     * @return zero if successful, a negative value if not
    
    Drew Hess's avatar
    Drew Hess committed
     */
    
    int avpicture_alloc(AVPicture *picture, enum PixelFormat pix_fmt, int width, int height);
    
    Drew Hess's avatar
    Drew Hess committed
    
    
    /**
     * Free a picture previously allocated by avpicture_alloc().
     *
    
    Diego Biurrun's avatar
    Diego Biurrun committed
     * @param picture the AVPicture to be freed
    
    Drew Hess's avatar
    Drew Hess committed
    void avpicture_free(AVPicture *picture);
    
    
    Diego Biurrun's avatar
    Diego Biurrun committed
     * Fill in the AVPicture fields.
    
     * The fields of the given AVPicture are filled in by using the 'ptr' address
     * which points to the image data buffer. Depending on the specified picture
     * format, one or multiple image data pointers and line sizes will be set.
     * If a planar format is specified, several pointers will be set pointing to
     * the different picture planes and the line sizes of the different planes
     * will be stored in the lines_sizes array.
    
     * Call with ptr == NULL to get the required size for the ptr buffer.
    
    Diego Biurrun's avatar
    Diego Biurrun committed
     * @param picture AVPicture whose fields are to be filled in
    
     * @param ptr Buffer which will contain or contains the actual image data
    
    Diego Biurrun's avatar
    Diego Biurrun committed
     * @param pix_fmt The format in which the picture data is stored.
     * @param width the width of the image in pixels
     * @param height the height of the image in pixels
     * @return size of the image data in bytes
    
    int avpicture_fill(AVPicture *picture, uint8_t *ptr,
    
                       enum PixelFormat pix_fmt, int width, int height);
    
    int avpicture_layout(const AVPicture* src, enum PixelFormat pix_fmt, int width, int height,
    
                         unsigned char *dest, int dest_size);
    
    
    /**
     * Calculate the size in bytes that a picture of the given width and height
     * would occupy if stored in the given picture format.
    
     * Note that this returns the size of a compact representation as generated
     * by avpicture_layout, which can be smaller than the size required for e.g.
     * avpicture_fill.
    
    Diego Biurrun's avatar
    Diego Biurrun committed
     * @param pix_fmt the given picture format
     * @param width the width of the image
     * @param height the height of the image
    
     * @return Image data size in bytes or -1 on error (e.g. too large dimensions).
    
    int avpicture_get_size(enum PixelFormat pix_fmt, int width, int height);
    void avcodec_get_chroma_sub_sample(enum PixelFormat pix_fmt, int *h_shift, int *v_shift);
    const char *avcodec_get_pix_fmt_name(enum PixelFormat pix_fmt);
    
    void avcodec_set_dimensions(AVCodecContext *s, int width, int height);
    
     * Returns the pixel format corresponding to the name name.
    
     * If there is no pixel format with name name, then looks for a
    
     * pixel format with the name corresponding to the native endian
    
     * For example in a little-endian system, first looks for "gray16",
     * then for "gray16le".
     *
    
     * Finally if no pixel format has been found, returns PIX_FMT_NONE.
    
    enum PixelFormat avcodec_get_pix_fmt(const char* name);
    
    unsigned int avcodec_pix_fmt_to_codec_tag(enum PixelFormat p);
    
    #define FF_LOSS_RESOLUTION  0x0001 /**< loss due to resolution change */
    #define FF_LOSS_DEPTH       0x0002 /**< loss due to color depth change */
    #define FF_LOSS_COLORSPACE  0x0004 /**< loss due to color space conversion */
    #define FF_LOSS_ALPHA       0x0008 /**< loss of alpha bits */
    #define FF_LOSS_COLORQUANT  0x0010 /**< loss due to color quantization */
    #define FF_LOSS_CHROMA      0x0020 /**< loss of chroma (e.g. RGB to gray conversion) */
    
     * Computes what kind of losses will occur when converting from one specific
     * pixel format to another.
     * When converting from one pixel format to another, information loss may occur.
     * For example, when converting from RGB24 to GRAY, the color information will
     * be lost. Similarly, other losses occur when converting from some formats to
     * other formats. These losses can involve loss of chroma, but also loss of
     * resolution, loss of color depth, loss due to the color space conversion, loss
     * of the alpha bits or loss due to color quantization.
    
    Diego Biurrun's avatar
    Diego Biurrun committed
     * avcodec_get_fix_fmt_loss() informs you about the various types of losses
     * which will occur when converting from one pixel format to another.
    
    Diego Biurrun's avatar
    Diego Biurrun committed
     * @param[in] dst_pix_fmt destination pixel format
     * @param[in] src_pix_fmt source pixel format
    
     * @param[in] has_alpha Whether the source pixel format alpha channel is used.
     * @return Combination of flags informing you what kind of losses will occur.
    
    int avcodec_get_pix_fmt_loss(enum PixelFormat dst_pix_fmt, enum PixelFormat src_pix_fmt,