Skip to content
Snippets Groups Projects
avcodec.h 93.8 KiB
Newer Older
  • Learn to ignore specific revisions
  • 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.
    
    Robert Swain's avatar
    Robert Swain committed
         * - decoding: unused
         */
        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 */
    
    Diego Biurrun's avatar
    Diego Biurrun committed
         * direct MV prediction mode - 0 (none), 1 (spatial), 2 (temporal)
         * - 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
    
    
        /**
         * Decoder should decode to this many channels if it can (0 for default)
         * - encoding: unused
         * - decoding: Set by user.
         */
        int request_channels;
    
    
        /**
         * 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;
    
    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 *);
    
    Michael Niedermayer's avatar
    Michael Niedermayer committed
        int (*decode)(AVCodecContext *, void *outdata, int *outdata_size,
    
                      const uint8_t *buf, int buf_size);
    
        /**
         * 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 \p name.
         * You \e should use the NULL_IF_CONFIG_SMALL() macro to define it.
         */
        const char *long_name;
    
        const int *supported_samplerates;       ///< array of supported audio samplerates, or NULL if unknown, array is terminated by 0
    
    Fabrice Bellard's avatar
    Fabrice Bellard committed
    } AVCodec;
    
    
     * 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;
    
    
    /**
     * AVPaletteControl
     * This structure defines a method for communicating palette changes
     * between and demuxer and a decoder.
    
     *
     * @deprecated Use AVPacket to send palette changes instead.
     * This is totally broken.
    
    #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];
    
    typedef struct AVSubtitleRect {
    
        uint16_t x;
        uint16_t y;
        uint16_t w;
        uint16_t h;
        uint16_t nb_colors;
        int linesize;
        uint32_t *rgba_palette;
        uint8_t *bitmap;
    
    } 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 */
        uint32_t num_rects;
        AVSubtitleRect *rects;
    
    Fabrice Bellard's avatar
    Fabrice Bellard committed
    /* resample.c */
    
    struct ReSampleContext;
    
    Fabrice Bellard's avatar
    Fabrice Bellard committed
    
    typedef struct ReSampleContext ReSampleContext;
    
    
    ReSampleContext *audio_resample_init(int output_channels, int input_channels,
    
    Fabrice Bellard's avatar
    Fabrice Bellard committed
                                         int output_rate, int input_rate);
    int audio_resample(ReSampleContext *s, short *output, short *input, int nb_samples);
    void audio_resample_close(ReSampleContext *s);
    
    
    struct AVResampleContext *av_resample_init(int out_rate, int in_rate, int filter_length, int log2_phase_count, int linear, double cutoff);
    
    int av_resample(struct AVResampleContext *c, short *dst, short *src, int *consumed, int src_size, int dst_size, int update_ctx);
    
    Michael Niedermayer's avatar
    Michael Niedermayer committed
    void av_resample_compensate(struct AVResampleContext *c, int sample_delta, int compensation_distance);
    
    #if LIBAVCODEC_VERSION_INT < ((52<<16)+(0<<8)+0)
    
    Fabrice Bellard's avatar
    Fabrice Bellard committed
    /* YUV420 format is assumed ! */
    
    
    /**
     * @deprecated Use the software scaler (swscale) instead.
     */
    
    typedef struct ImgReSampleContext ImgReSampleContext attribute_deprecated;
    
    Fabrice Bellard's avatar
    Fabrice Bellard committed
    
    
    /**
     * @deprecated Use the software scaler (swscale) instead.
     */
    
    attribute_deprecated ImgReSampleContext *img_resample_init(int output_width, int output_height,
    
    Fabrice Bellard's avatar
    Fabrice Bellard committed
                                          int input_width, int input_height);
    
    /**
     * @deprecated Use the software scaler (swscale) instead.
     */
    
    attribute_deprecated ImgReSampleContext *img_resample_full_init(int owidth, int oheight,
    
                                          int iwidth, int iheight,
                                          int topBand, int bottomBand,
    
                                          int leftBand, int rightBand,
                                          int padtop, int padbottom,
                                          int padleft, int padright);
    
    
    /**
     * @deprecated Use the software scaler (swscale) instead.
     */
    
    attribute_deprecated void img_resample(struct ImgReSampleContext *s,
    
                      AVPicture *output, const AVPicture *input);
    
    Fabrice Bellard's avatar
    Fabrice Bellard committed
    
    
    /**
     * @deprecated Use the software scaler (swscale) instead.
     */
    
    attribute_deprecated void img_resample_close(struct ImgReSampleContext *s);
    
    Fabrice Bellard's avatar
    Fabrice Bellard committed
    
    
    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, int pix_fmt, int width, int height);
    
    
    /**
     * 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.
     *
    
    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,
    
                       int pix_fmt, int width, int height);
    
    int avpicture_layout(const AVPicture* src, int 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.
     *
    
    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
    
    int avpicture_get_size(int pix_fmt, int width, int height);
    
    void avcodec_get_chroma_sub_sample(int pix_fmt, int *h_shift, int *v_shift);
    const char *avcodec_get_pix_fmt_name(int pix_fmt);
    
    void avcodec_set_dimensions(AVCodecContext *s, int width, int height);
    
    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(int dst_pix_fmt, int src_pix_fmt,
                                 int has_alpha);
    
     * Finds the best pixel format to convert to given a certain source pixel
     * format.  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. avcodec_find_best_pix_fmt() searches which of
    
    Diego Biurrun's avatar
    Diego Biurrun committed
     * the given pixel formats should be used to suffer the least amount of loss.
     * The pixel formats from which it chooses one, are determined by the
    
     * \p pix_fmt_mask parameter.
     *
     * @code
     * src_pix_fmt = PIX_FMT_YUV420P;
     * pix_fmt_mask = (1 << PIX_FMT_YUV422P) || (1 << PIX_FMT_RGB24);
     * dst_pix_fmt = avcodec_find_best_pix_fmt(pix_fmt_mask, src_pix_fmt, alpha, &loss);
     * @endcode
     *
    
    Diego Biurrun's avatar
    Diego Biurrun committed
     * @param[in] pix_fmt_mask bitmask determining which pixel format to choose from
     * @param[in] src_pix_fmt source pixel format
    
     * @param[in] has_alpha Whether the source pixel format alpha channel is used.
     * @param[out] loss_ptr Combination of flags informing you what kind of losses will occur.
     * @return The best pixel format to convert to or -1 if none was found.
    
    int avcodec_find_best_pix_fmt(int pix_fmt_mask, int src_pix_fmt,
                                  int has_alpha, int *loss_ptr);
    
    
    
    /**
     * Print in buf the string corresponding to the pixel format with
     * number pix_fmt, or an header if pix_fmt is negative.
     *
    
     * @param[in] buf the buffer where to write the string
     * @param[in] buf_size the size of buf
     * @param[in] pix_fmt the number of the pixel format to print the corresponding info string, or
    
     * a negative value to print the corresponding header.
     * Meaningful values for obtaining a pixel format info vary from 0 to PIX_FMT_NB -1.
     */
    void avcodec_pix_fmt_string (char *buf, int buf_size, int pix_fmt);
    
    
    #define FF_ALPHA_TRANSP       0x0001 /* image has some totally transparent pixels */
    #define FF_ALPHA_SEMI_TRANSP  0x0002 /* image has some transparent pixels */
    
    
    /**
     * Tell if an image really has transparent alpha values.
     * @return ored mask of FF_ALPHA_xxx constants
     */
    
    int img_get_alpha_info(const AVPicture *src,
    
                           int pix_fmt, int width, int height);
    
    #if LIBAVCODEC_VERSION_INT < ((52<<16)+(0<<8)+0)
    
    /**
     * convert among pixel formats
     * @deprecated Use the software scaler (swscale) instead.
     */
    
    attribute_deprecated int img_convert(AVPicture *dst, int dst_pix_fmt,
    
                    const AVPicture *src, int pix_fmt,
    
                    int width, int height);
    
    
    /* deinterlace a picture */
    
    /* deinterlace - if not supported return -1 */
    
    int avpicture_deinterlace(AVPicture *dst, const AVPicture *src,
    
    Fabrice Bellard's avatar
    Fabrice Bellard committed
                              int pix_fmt, int width, int height);
    
    /* external high level API */
    
    
    #if LIBAVCODEC_VERSION_INT < ((52<<16)+(0<<8)+0)
    
    Fabrice Bellard's avatar
    Fabrice Bellard committed
    extern AVCodec *first_avcodec;
    
    #endif
    AVCodec *av_codec_next(AVCodec *c);
    
    Fabrice Bellard's avatar
    Fabrice Bellard committed
    
    
    Nick Kurshev's avatar
    Nick Kurshev committed
    /* returns LIBAVCODEC_VERSION_INT constant */
    
    unsigned avcodec_version(void);
    
    #if LIBAVCODEC_VERSION_INT < ((52<<16)+(0<<8)+0)
    
    Nick Kurshev's avatar
    Nick Kurshev committed
    /* returns LIBAVCODEC_BUILD constant */
    
    attribute_deprecated unsigned avcodec_build(void);
    #endif
    
    
    /**
     * Initializes libavcodec.
     *
     * @warning This function \e must be called before any other libavcodec
     * function.
     */
    
    Fabrice Bellard's avatar
    Fabrice Bellard committed
    void avcodec_init(void);
    
    void register_avcodec(AVCodec *format);
    
     * Finds a registered encoder with a matching codec ID.
    
    Diego Biurrun's avatar
    Diego Biurrun committed
     * @param id CodecID of the requested encoder
    
     * @return An encoder if one was found, NULL otherwise.
     */
    
    Fabrice Bellard's avatar
    Fabrice Bellard committed
    AVCodec *avcodec_find_encoder(enum CodecID id);
    
     * Finds a registered encoder with the specified name.
    
    Diego Biurrun's avatar
    Diego Biurrun committed
     * @param name name of the requested encoder
    
     * @return An encoder if one was found, NULL otherwise.
     */
    
    AVCodec *avcodec_find_encoder_by_name(const char *name);
    
     * Finds a registered decoder with a matching codec ID.
    
    Diego Biurrun's avatar
    Diego Biurrun committed
     * @param id CodecID of the requested decoder
    
     * @return A decoder if one was found, NULL otherwise.
     */
    
    Fabrice Bellard's avatar
    Fabrice Bellard committed
    AVCodec *avcodec_find_decoder(enum CodecID id);
    
     * Finds a registered decoder with the specified name.
    
    Diego Biurrun's avatar
    Diego Biurrun committed
     * @param name name of the requested decoder
    
     * @return A decoder if one was found, NULL otherwise.
     */
    
    Fabrice Bellard's avatar
    Fabrice Bellard committed
    AVCodec *avcodec_find_decoder_by_name(const char *name);
    void avcodec_string(char *buf, int buf_size, AVCodecContext *enc, int encode);
    
    
    /**
     * Sets the fields of the given AVCodecContext to default values.
     *
     * @param s The AVCodecContext of which the fields should be set to default values.
     */
    
    Michael Niedermayer's avatar
    Michael Niedermayer committed
    void avcodec_get_context_defaults(AVCodecContext *s);
    
    /** THIS FUNCTION IS NOT YET PART OF THE PUBLIC API!
     *  we WILL change its arguments and name a few times! */
    void avcodec_get_context_defaults2(AVCodecContext *s, enum CodecType);
    
    
    /**
     * Allocates an AVCodecContext and sets its fields to default values.  The
     * resulting struct can be deallocated by simply calling av_free().
     *
     * @return An AVCodecContext filled with default values or NULL on failure.
     * @see avcodec_get_context_defaults
     */
    
    Falk Hüffner's avatar
    Falk Hüffner committed
    AVCodecContext *avcodec_alloc_context(void);
    
    /** THIS FUNCTION IS NOT YET PART OF THE PUBLIC API!
     *  we WILL change its arguments and name a few times! */
    AVCodecContext *avcodec_alloc_context2(enum CodecType);
    
    
    /**
     * Sets the fields of the given AVFrame to default values.
     *
     * @param pic The AVFrame of which the fields should be set to default values.
     */
    
    Falk Hüffner's avatar
    Falk Hüffner committed
    void avcodec_get_frame_defaults(AVFrame *pic);
    
    
    /**
     * Allocates an AVFrame and sets its fields to default values.  The resulting
     * struct can be deallocated by simply calling av_free().
     *
     * @return An AVFrame filled with default values or NULL on failure.
     * @see avcodec_get_frame_defaults
     */
    
    AVFrame *avcodec_alloc_frame(void);
    
    Michael Niedermayer's avatar
    Michael Niedermayer committed
    
    
    int avcodec_default_get_buffer(AVCodecContext *s, AVFrame *pic);
    void avcodec_default_release_buffer(AVCodecContext *s, AVFrame *pic);
    
    int avcodec_default_reget_buffer(AVCodecContext *s, AVFrame *pic);
    void avcodec_align_dimensions(AVCodecContext *s, int *width, int *height);
    
    
    /**
     * Checks if the given dimension of a picture is valid, meaning that all
     * bytes of the picture can be addressed with a signed int.
     *
     * @param[in] w Width of the picture.
     * @param[in] h Height of the picture.
     * @return Zero if valid, a negative value if invalid.
     */
    
    int avcodec_check_dimensions(void *av_log_ctx, unsigned int w, unsigned int h);
    
    enum PixelFormat avcodec_default_get_format(struct AVCodecContext *s, const enum PixelFormat * fmt);
    
    Michael Niedermayer's avatar
    Michael Niedermayer committed
    
    
    Michael Niedermayer's avatar
    1l  
    Michael Niedermayer committed
    int avcodec_thread_init(AVCodecContext *s, int thread_count);
    void avcodec_thread_free(AVCodecContext *s);
    int avcodec_thread_execute(AVCodecContext *s, int (*func)(AVCodecContext *c2, void *arg2),void **arg, int *ret, int count);
    
    int avcodec_default_execute(AVCodecContext *c, int (*func)(AVCodecContext *c2, void *arg2),void **arg, int *ret, int count);
    
    //FIXME func typedef
    
    
    Michael Niedermayer's avatar
    Michael Niedermayer committed
    /**
    
     * Initializes the AVCodecContext to use the given AVCodec. Prior to using this
     * function the context has to be allocated.
     *
     * The functions avcodec_find_decoder_by_name(), avcodec_find_encoder_by_name(),
     * avcodec_find_decoder() and avcodec_find_encoder() provide an easy way for
     * retrieving a codec.
     *
    
    Diego Biurrun's avatar
    Diego Biurrun committed
     * @warning This function is not thread safe!
    
     * avcodec_register_all();
    
     * codec = avcodec_find_decoder(CODEC_ID_H264);
     * if (!codec)
     *     exit(1);
     *
     * context = avcodec_alloc_context();
     *
     * if (avcodec_open(context, codec) < 0)
     *     exit(1);
     * @endcode
     *
    
    Diego Biurrun's avatar
    Diego Biurrun committed
     * @param avctx The context which will be set up to use the given codec.
    
     * @param codec The codec to use within the context.
    
    Diego Biurrun's avatar
    Diego Biurrun committed
     * @return zero on success, a negative value on error
    
     * @see avcodec_alloc_context, avcodec_find_decoder, avcodec_find_encoder
    
    Michael Niedermayer's avatar
    Michael Niedermayer committed
     */
    
    Fabrice Bellard's avatar
    Fabrice Bellard committed
    int avcodec_open(AVCodecContext *avctx, AVCodec *codec);
    
    /**
     * @deprecated Use avcodec_decode_audio2() instead.
     */
    
    attribute_deprecated int avcodec_decode_audio(AVCodecContext *avctx, int16_t *samples,
                             int *frame_size_ptr,
    
                             const uint8_t *buf, int buf_size);
    
     * Decodes an audio frame from \p buf into \p samples.
    
    Diego Biurrun's avatar
    Diego Biurrun committed
     * The avcodec_decode_audio2() function decodes an audio frame from the input
    
     * buffer \p buf of size \p buf_size. To decode it, it makes use of the
    
    Diego Biurrun's avatar
    Diego Biurrun committed
     * audio codec which was coupled with \p avctx using avcodec_open(). The
    
     * resulting decoded frame is stored in output buffer \p samples.  If no frame
     * could be decompressed, \p frame_size_ptr is zero. Otherwise, it is the
     * decompressed frame size in \e bytes.
     *
     * @warning You \e must set \p frame_size_ptr to the allocated size of the
     * output buffer before calling avcodec_decode_audio2().
     *
     * @warning The input buffer must be \c FF_INPUT_BUFFER_PADDING_SIZE larger than
     * the actual read bytes because some optimized bitstream readers read 32 or 64
     * bits at once and could read over the end.
     *
     * @warning The end of the input buffer \p buf should be set to 0 to ensure that
     * no overreading happens for damaged MPEG streams.
    
     * @note You might have to align the input buffer \p buf and output buffer \p
    
    Diego Biurrun's avatar
    Diego Biurrun committed
     * samples. The alignment requirements depend on the CPU: On some CPUs it isn't
    
     * necessary at all, on others it won't work at all if not aligned and on others
     * it will work but it will have an impact on performance. In practice, the
     * bitstream should have 4 byte alignment at minimum and all sample data should
     * be 16 byte aligned unless the CPU doesn't need it (AltiVec and SSE do). If
     * the linesize is not a multiple of 16 then there's no sense in aligning the
     * start of the buffer to 16.
     *
    
    Diego Biurrun's avatar
    Diego Biurrun committed
     * @param avctx the codec context
     * @param[out] samples the output buffer
     * @param[in,out] frame_size_ptr the output buffer size in bytes
     * @param[in] buf the input buffer
     * @param[in] buf_size the input buffer size in bytes
    
     * @return On error a negative value is returned, otherwise the number of bytes
     * used or zero if no frame could be decompressed.
    
    int avcodec_decode_audio2(AVCodecContext *avctx, int16_t *samples,
    
    Fabrice Bellard's avatar
    Fabrice Bellard committed
                             int *frame_size_ptr,
    
                             const uint8_t *buf, int buf_size);
    
    
    /**
     * Decodes a video frame from \p buf into \p picture.
    
    Diego Biurrun's avatar
    Diego Biurrun committed
     * The avcodec_decode_video() function decodes a video frame from the input
    
     * buffer \p buf of size \p buf_size. To decode it, it makes use of the
    
    Diego Biurrun's avatar
    Diego Biurrun committed
     * video codec which was coupled with \p avctx using avcodec_open(). The
    
     * resulting decoded frame is stored in \p picture.
     *
     * @warning The input buffer must be \c FF_INPUT_BUFFER_PADDING_SIZE larger than
     * the actual read bytes because some optimized bitstream readers read 32 or 64
     * bits at once and could read over the end.
     *
     * @warning The end of the input buffer \p buf should be set to 0 to ensure that
     * no overreading happens for damaged MPEG streams.
     *
     * @note You might have to align the input buffer \p buf and output buffer \p
     * samples. The alignment requirements depend on the CPU: on some CPUs it isn't
     * necessary at all, on others it won't work at all if not aligned and on others
     * it will work but it will have an impact on performance. In practice, the
     * bitstream should have 4 byte alignment at minimum and all sample data should
     * be 16 byte aligned unless the CPU doesn't need it (AltiVec and SSE do). If
     * the linesize is not a multiple of 16 then there's no sense in aligning the
     * start of the buffer to 16.
     *
    
    Diego Biurrun's avatar
    Diego Biurrun committed
     * @param avctx the codec context
    
     * @param[out] picture The AVFrame in which the decoded video frame will be stored.
    
    Diego Biurrun's avatar
    Diego Biurrun committed
     * @param[in] buf the input buffer
     * @param[in] buf_size the size of the input buffer in bytes
     * @param[in,out] got_picture_ptr Zero if no frame could be decompressed, otherwise, it is nonzero.
    
     * @return On error a negative value is returned, otherwise the number of bytes
     * used or zero if no frame could be decompressed.
     */
    
    int avcodec_decode_video(AVCodecContext *avctx, AVFrame *picture,
    
    Fabrice Bellard's avatar
    Fabrice Bellard committed
                             int *got_picture_ptr,
    
                             const uint8_t *buf, int buf_size);
    
    Diego Biurrun's avatar
    Diego Biurrun committed
    /* Decode a subtitle message. Return -1 if error, otherwise return the
     * number of bytes used. If no subtitle could be decompressed,
     * got_sub_ptr is zero. Otherwise, the subtitle is stored in *sub. */
    
    int avcodec_decode_subtitle(AVCodecContext *avctx, AVSubtitle *sub,
                                int *got_sub_ptr,
                                const uint8_t *buf, int buf_size);
    
    int avcodec_parse_frame(AVCodecContext *avctx, uint8_t **pdata,
    
                            uint8_t *buf, int buf_size);
    
    
    /**
     * Encodes an audio frame from \p samples into \p buf.
    
    Diego Biurrun's avatar
    Diego Biurrun committed
     * The avcodec_encode_audio() function encodes an audio frame from the input
     * buffer \p samples. To encode it, it makes use of the audio codec which was
    
     * coupled with \p avctx using avcodec_open(). The resulting encoded frame is
     * stored in output buffer \p buf.
     *
     * @note The output buffer should be at least \c FF_MIN_BUFFER_SIZE bytes large.
     *
    
    Diego Biurrun's avatar
    Diego Biurrun committed
     * @param avctx the codec context
     * @param[out] buf the output buffer
     * @param[in] buf_size the output buffer size
     * @param[in] samples the input buffer containing the samples
    
     * The number of samples read from this buffer is frame_size*channels,
     * both of which are defined in \p avctx.
    
     * For PCM audio the number of samples read from \p samples is equal to
     * \p buf_size * input_sample_size / output_sample_size.
    
    Diego Biurrun's avatar
    Diego Biurrun committed
     * @return On error a negative value is returned, on success zero or the number
    
     * of bytes used to encode the data read from the input buffer.
    
    int avcodec_encode_audio(AVCodecContext *avctx, uint8_t *buf, int buf_size,
    
    Fabrice Bellard's avatar
    Fabrice Bellard committed
                             const short *samples);
    
    
    /**
     * Encodes a video frame from \p pict into \p buf.
    
    Diego Biurrun's avatar
    Diego Biurrun committed
     * The avcodec_encode_video() function encodes a video frame from the input
     * \p pict. To encode it, it makes use of the video codec which was coupled with
    
     * \p avctx using avcodec_open(). The resulting encoded bytes representing the
     * frame are stored in the output buffer \p buf. The input picture should be
     * stored using a specific format, namely \c avctx.pix_fmt.
     *
    
    Diego Biurrun's avatar
    Diego Biurrun committed
     * @param avctx the codec context
     * @param[out] buf the output buffer for the bitstream of encoded frame
     * @param[in] buf_size the size of the output buffer in bytes
     * @param[in] pict the input picture to encode
    
     * @return On error a negative value is returned, on success zero or the number
     * of bytes used from the input buffer.
     */
    
    int avcodec_encode_video(AVCodecContext *avctx, uint8_t *buf, int buf_size,
    
                             const AVFrame *pict);
    
    int avcodec_encode_subtitle(AVCodecContext *avctx, uint8_t *buf, int buf_size,
    
                                const AVSubtitle *sub);
    
    Fabrice Bellard's avatar
    Fabrice Bellard committed
    
    int avcodec_close(AVCodecContext *avctx);
    
    void avcodec_register_all(void);
    
    Fabrice Bellard's avatar
    Fabrice Bellard committed
    
    
    /**
     * Flush buffers, should be called when seeking or when switching to a different stream.
     */
    
    void avcodec_flush_buffers(AVCodecContext *avctx);
    
    
    void avcodec_default_free_buffers(AVCodecContext *s);
    
    
    Panagiotis Issaris's avatar
    Panagiotis Issaris committed
    /* misc useful functions */
    
    Michael Niedermayer's avatar
    Michael Niedermayer committed
    
    /**
    
     * Returns a single letter to describe the given picture type \p pict_type.
     *
    
    Diego Biurrun's avatar
    Diego Biurrun committed
     * @param[in] pict_type the picture type
    
     * @return A single character representing the picture type.
    
    Michael Niedermayer's avatar
    Michael Niedermayer committed
     */
    char av_get_pict_type_char(int pict_type);
    
    
    Diego Biurrun's avatar
    Diego Biurrun committed
     * @param[in] codec_id the codec
    
     * @return Number of bits per sample or zero if unknown for the given codec.
    
     */
    int av_get_bits_per_sample(enum CodecID codec_id);
    
    /**
     * Returns sample format bits per sample.
     *
     * @param[in] sample_fmt the sample format
     * @return Number of bits per sample or zero if unknown for the given sample format.
     */
    int av_get_bits_per_sample_format(enum SampleFormat sample_fmt);
    
    
    /* frame parsing */
    typedef struct AVCodecParserContext {
        void *priv_data;
        struct AVCodecParser *parser;
        int64_t frame_offset; /* offset of the current frame */
    
        int64_t cur_offset; /* current offset
    
                               (incremented by each av_parser_parse()) */
    
        int64_t next_frame_offset; /* offset of the next frame */
    
        /* video info */
    
    Diego Biurrun's avatar
    Diego Biurrun committed
        int pict_type; /* XXX: Put it back in AVCodecContext. */
        int repeat_pict; /* XXX: Put it back in AVCodecContext. */
    
        int64_t pts;     /* pts of the current frame */
        int64_t dts;     /* dts of the current frame */
    
        /* private data */
        int64_t last_pts;
        int64_t last_dts;
    
        int fetch_timestamp;
    
    
    #define AV_PARSER_PTS_NB 4
        int cur_frame_start_index;
        int64_t cur_frame_offset[AV_PARSER_PTS_NB];
        int64_t cur_frame_pts[AV_PARSER_PTS_NB];
        int64_t cur_frame_dts[AV_PARSER_PTS_NB];
    
        int flags;
    #define PARSER_FLAG_COMPLETE_FRAMES           0x0001
    
    
        int64_t offset;      ///< byte offset from starting packet start
    
        int64_t cur_frame_end[AV_PARSER_PTS_NB];
    
    } AVCodecParserContext;
    
    typedef struct AVCodecParser {
    
    Michael Niedermayer's avatar
    Michael Niedermayer committed
        int codec_ids[5]; /* several codec IDs are permitted */
    
        int priv_data_size;
        int (*parser_init)(AVCodecParserContext *s);
    
        int (*parser_parse)(AVCodecParserContext *s,
    
                            AVCodecContext *avctx,
    
                            const uint8_t **poutbuf, int *poutbuf_size,
    
                            const uint8_t *buf, int buf_size);
        void (*parser_close)(AVCodecParserContext *s);
    
        int (*split)(AVCodecContext *avctx, const uint8_t *buf, int buf_size);
    
        struct AVCodecParser *next;
    } AVCodecParser;
    
    
    #if LIBAVCODEC_VERSION_INT < ((52<<16)+(0<<8)+0)
    
    extern AVCodecParser *av_first_parser;
    
    #endif
    AVCodecParser *av_parser_next(AVCodecParser *c);
    
    
    void av_register_codec_parser(AVCodecParser *parser);
    AVCodecParserContext *av_parser_init(int codec_id);
    
    int av_parser_parse(AVCodecParserContext *s,
    
                        AVCodecContext *avctx,
    
                        uint8_t **poutbuf, int *poutbuf_size,
    
                        const uint8_t *buf, int buf_size,
                        int64_t pts, int64_t dts);
    
    int av_parser_change(AVCodecParserContext *s,
                         AVCodecContext *avctx,
    
                         uint8_t **poutbuf, int *poutbuf_size,
    
                         const uint8_t *buf, int buf_size, int keyframe);
    
    void av_parser_close(AVCodecParserContext *s);
    
    
        void *priv_data;
    
        struct AVBitStreamFilter *filter;
        AVCodecParserContext *parser;
        struct AVBitStreamFilterContext *next;
    } AVBitStreamFilterContext;
    
    
    typedef struct AVBitStreamFilter {
        const char *name;
    
        int priv_data_size;
    
        int (*filter)(AVBitStreamFilterContext *bsfc,
                      AVCodecContext *avctx, const char *args,
                      uint8_t **poutbuf, int *poutbuf_size,
                      const uint8_t *buf, int buf_size, int keyframe);
    
        void (*close)(AVBitStreamFilterContext *bsfc);
    
        struct AVBitStreamFilter *next;
    } AVBitStreamFilter;
    
    void av_register_bitstream_filter(AVBitStreamFilter *bsf);
    AVBitStreamFilterContext *av_bitstream_filter_init(const char *name);
    int av_bitstream_filter_filter(AVBitStreamFilterContext *bsfc,
                                   AVCodecContext *avctx, const char *args,
                                   uint8_t **poutbuf, int *poutbuf_size,
                                   const uint8_t *buf, int buf_size, int keyframe);
    void av_bitstream_filter_close(AVBitStreamFilterContext *bsf);
    
    
    AVBitStreamFilter *av_bitstream_filter_next(AVBitStreamFilter *f);
    
    /* memory */
    
     * Reallocates the given block if it is not large enough, otherwise it
     * does nothing.
     *
     * @see av_realloc
    
    void *av_fast_realloc(void *ptr, unsigned int *size, unsigned int min_size);
    
    void av_picture_copy(AVPicture *dst, const AVPicture *src,
    
                  int pix_fmt, int width, int height);
    
    
    Diego Biurrun's avatar
    Diego Biurrun committed
     * Crop image top and left side.
    
    int av_picture_crop(AVPicture *dst, const AVPicture *src,
    
                 int pix_fmt, int top_band, int left_band);
    
    
    Diego Biurrun's avatar
    Diego Biurrun committed
     * Pad image.
    
    int av_picture_pad(AVPicture *dst, const AVPicture *src, int height, int width, int pix_fmt,
    
                int padtop, int padbottom, int padleft, int padright, int *color);
    
    
    #if LIBAVCODEC_VERSION_INT < ((52<<16)+(0<<8)+0)
    
    /**
     * @deprecated Use the software scaler (swscale) instead.
     */
    
    attribute_deprecated void img_copy(AVPicture *dst, const AVPicture *src,
                  int pix_fmt, int width, int height);
    
    
    /**
     * @deprecated Use the software scaler (swscale) instead.
     */
    
    attribute_deprecated int img_crop(AVPicture *dst, const AVPicture *src,
                 int pix_fmt, int top_band, int left_band);
    
    
    /**
     * @deprecated Use the software scaler (swscale) instead.
     */
    
    attribute_deprecated int img_pad(AVPicture *dst, const AVPicture *src, int height, int width, int pix_fmt,
                int padtop, int padbottom, int padleft, int padright, int *color);
    #endif
    
    
    extern unsigned int av_xiphlacing(unsigned char *s, unsigned int v);
    
    
    /**
     * Parses \p str and put in \p width_ptr and \p height_ptr the detected values.
     *
    
    Diego Biurrun's avatar
    Diego Biurrun committed
     * @return 0 in case of a successful parsing, a negative value otherwise
    
     * @param[in] str the string to parse: it has to be a string in the format
     * <width>x<height> or a valid video frame size abbreviation.
     * @param[in,out] width_ptr pointer to the variable which will contain the detected
     * frame width value
     * @param[in,out] height_ptr pointer to the variable which will contain the detected
     * frame height value
     */
    int av_parse_video_frame_size(int *width_ptr, int *height_ptr, const char *str);
    
    /**
     * Parses \p str and put in \p frame_rate the detected values.
     *
    
    Diego Biurrun's avatar
    Diego Biurrun committed
     * @return 0 in case of a successful parsing, a negative value otherwise
    
     * @param[in] str the string to parse: it has to be a string in the format
     * <frame_rate_nom>/<frame_rate_den>, a float number or a valid video rate abbreviation