Skip to content
Snippets Groups Projects
avcodec.h 116 KiB
Newer Older
  • Learn to ignore specific revisions
  • /**
     * 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 size);
    int avcodec_default_execute(AVCodecContext *c, int (*func)(AVCodecContext *c2, void *arg2),void *arg, int *ret, int count, int size);
    
    //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);
    
     * Decodes an audio frame from \p buf into \p samples.
    
     * Wrapper function which calls avcodec_decode_audio3.
     *
     * @deprecated Use avcodec_decode_audio3 instead.
     * @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.
     */
    attribute_deprecated int avcodec_decode_audio2(AVCodecContext *avctx, int16_t *samples,
                             int *frame_size_ptr,
                             const uint8_t *buf, int buf_size);
    #endif
    
    /**
     * Decodes an audio frame from \p avpkt->data into \p samples.
     * The avcodec_decode_audio3() function decodes an audio frame from the input
     * buffer \p avpkt->data of size \p avpkt->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_audio3().
    
     *
     * @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 avpkt->data 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 avpkt->data 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] avpkt The input AVPacket containing the input buffer.
    
     * @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_audio3(AVCodecContext *avctx, int16_t *samples,
    
    Fabrice Bellard's avatar
    Fabrice Bellard committed
                             int *frame_size_ptr,
    
    /**
     * Decodes a video frame from \p buf into \p picture.
    
     * Wrapper function which calls avcodec_decode_video2.
     *
     * @deprecated Use avcodec_decode_video2 instead.
     * @param avctx the codec context
     * @param[out] picture The AVFrame in which the decoded video frame will be stored.
     * @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.
     */
    attribute_deprecated int avcodec_decode_video(AVCodecContext *avctx, AVFrame *picture,
                             int *got_picture_ptr,
                             const uint8_t *buf, int buf_size);
    #endif
    
    /**
     * Decodes a video frame from \p avpkt->data into \p picture.
     * The avcodec_decode_video2() function decodes a video frame from the input
     * buffer \p avpkt->data of size \p avpkt->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 avpkt->data 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.
     *
    
     * @note Some codecs have a delay between input and output, these need to be
    
     * feeded with avpkt->data=NULL, avpkt->size=0 at the end to return the remaining frames.
    
    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.
    
     * @param[in] avpkt The input AVpacket containing the input buffer.
    
    Diego Biurrun's avatar
    Diego Biurrun committed
     * @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_video2(AVCodecContext *avctx, AVFrame *picture,
    
    Fabrice Bellard's avatar
    Fabrice Bellard committed
                             int *got_picture_ptr,
    
    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. */
    
    attribute_deprecated int avcodec_decode_subtitle(AVCodecContext *avctx, AVSubtitle *sub,
    
                                int *got_sub_ptr,
                                const uint8_t *buf, int buf_size);
    
    #endif
    
    /**
     * Decodes a subtitle message.
     * Returns -1 if error, otherwise returns the number of bytes used.
     * If no subtitle could be decompressed, \p got_sub_ptr is zero.
     * Otherwise, the subtitle is stored in \p *sub.
     *
     * @param avctx the codec context
     * @param[out] sub The AVSubtitle in which the decoded subtitle will be stored.
     * @param[in,out] got_sub_ptr Zero if no subtitle could be decompressed, otherwise, it is nonzero.
     * @param[in] avpkt The input AVPacket containing the input buffer.
     */
    int avcodec_decode_subtitle2(AVCodecContext *avctx, AVSubtitle *sub,
                                int *got_sub_ptr,
                                AVPacket *avpkt);
    
    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.
    
     * However, for PCM audio the user will know how much space is needed
     * because it depends on the value passed in \p buf_size as described
     * below. In that case a lower value can be used.
    
    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 output 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);
    
    
    /**
     * Register all the codecs, parsers and bitstream filters which were enabled at
     * configuration time. If you do not call this function you can select exactly
     * which formats you want to support, by using the individual registration
     * functions.
     *
    
     * @see av_register_codec_parser
     * @see av_register_bitstream_filter
     */
    
    Fabrice Bellard's avatar
    Fabrice Bellard committed
    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. */
    
        /**
         * This field is used for proper frame duration computation in lavf.
         * It signals, how much longer the frame duration of the current frame
         * is compared to normal frame duration.
         *
    
         * frame_duration = (1 + repeat_pict) * time_base
    
         *
         * It is used by codecs like H.264 to display telecined material.
         */
    
    Diego Biurrun's avatar
    Diego Biurrun committed
        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];
    
    
        /*!
         * Set by parser to 1 for key frames and 0 for non-key frames.
         * It is initialized to -1, so if the parser doesn't set this flag,
         * old-style fallback using FF_I_TYPE picture type as key frames
         * will be used.
         */
        int key_frame;
    
    
        /**
         * Time difference in stream time base units from the pts of this
         * packet to the point at which the output from the decoder has converged
         * independent from the availability of previous frames. That is, the
         * frames are virtually identical no matter if decoding started from
         * the very first frame or from this keyframe.
         * Is AV_NOPTS_VALUE if unknown.
         * This field is not the display duration of the current frame.
         *
         * The purpose of this field is to allow seeking in streams that have no
         * keyframes in the conventional sense. It corresponds to the
         * recovery point SEI in H.264 and match_time_delta in NUT. It is also
         * essential for some types of subtitle streams to ensure that all
         * subtitles are correctly displayed after seeking.
         */
        int64_t convergence_duration;
    
    
        // Timestamp generation support:
        /**
         * Synchronization point for start of timestamp generation.
         *
         * Set to >0 for sync point, 0 for no sync point and <0 for undefined
         * (default).
         *
         * For example, this corresponds to presence of H.264 buffering period
         * SEI message.
         */
        int dts_sync_point;
    
        /**
         * Offset of the current timestamp against last timestamp sync point in
         * units of AVCodecContext.time_base.
         *
         * Set to INT_MIN when dts_sync_point unused. Otherwise, it must
         * contain a valid timestamp offset.
         *
         * Note that the timestamp of sync point has usually a nonzero
         * dts_ref_dts_delta, which refers to the previous sync point. Offset of
         * the next frame after timestamp sync point will be usually 1.
         *
         * For example, this corresponds to H.264 cpb_removal_delay.
         */
        int dts_ref_dts_delta;
    
        /**
         * Presentation delay of current frame in units of AVCodecContext.time_base.
         *
         * Set to INT_MIN when dts_sync_point unused. Otherwise, it must
         * contain valid non-negative timestamp delta (presentation time of a frame
         * must not lie in the past).
         *
         * This delay represents the difference between decoding and presentation
         * time of the frame.
         *
         * For example, this corresponds to H.264 dpb_output_delay.
         */
        int pts_dts_delta;
    
    
        /**
         * Position of the packet in file.
         *
         * Analogous to cur_frame_pts/dts
         */
        int64_t cur_frame_pos[AV_PARSER_PTS_NB];
    
        /**
         * Byte position of currently parsed frame in stream.
         */
        int64_t pos;
    
        /**
         * Previous frame byte position.
         */
        int64_t last_pos;
    
    } 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;
    
    
    AVCodecParser *av_parser_next(AVCodecParser *c);
    
    
    void av_register_codec_parser(AVCodecParser *parser);
    AVCodecParserContext *av_parser_init(int codec_id);
    
    #if LIBAVCODEC_VERSION_MAJOR < 53
    
    attribute_deprecated
    
    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);
    
    
    /**
     * Parse a packet.
     *
     * @param s             parser context.
     * @param avctx         codec context.
     * @param poutbuf       set to pointer to parsed buffer or NULL if not yet finished.
     * @param poutbuf_size  set to size of parsed buffer or zero if not yet finished.
     * @param buf           input buffer.
     * @param buf_size      input length, to signal EOF, this should be 0 (so that the last frame can be output).
     * @param pts           input presentation timestamp.
     * @param dts           input decoding timestamp.
     * @param pos           input byte position in stream.
     * @return the number of bytes of the input bitstream used.
     *
     * Example:
     * @code
     *   while(in_len){
     *       len = av_parser_parse2(myparser, AVCodecContext, &data, &size,
     *                                        in_data, in_len,
     *                                        pts, dts, pos);
     *       in_data += len;
     *       in_len  -= len;
     *
     *       if(size)
     *          decode_frame(data, size);
     *   }
     * @endcode
     */
    int av_parser_parse2(AVCodecParserContext *s,
                         AVCodecContext *avctx,
                         uint8_t **poutbuf, int *poutbuf_size,
                         const uint8_t *buf, int buf_size,
                         int64_t pts, int64_t dts,
                         int64_t pos);
    
    
    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);
    
    /**
     * Allocates a buffer, reusing the given one if large enough.
     *
     * Contrary to av_fast_realloc the current buffer contents might not be
     * preserved and on error the old buffer is freed, thus no special
     * handling to avoid memleaks is necessary.
     *
     * @param ptr pointer to pointer to already allocated buffer, overwritten with pointer to new buffer
     * @param size size of the buffer *ptr points to
     * @param min_size minimum size of *ptr buffer after returning, *ptr will be NULL and
     *                 *size 0 if an error occurred.
     */
    void av_fast_malloc(void *ptr, unsigned int *size, unsigned int min_size);
    
    
    void av_picture_copy(AVPicture *dst, const AVPicture *src,
    
                         enum PixelFormat 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,
    
                        enum PixelFormat 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, enum PixelFormat pix_fmt,
    
                int padtop, int padbottom, int padleft, int padright, int *color);
    
    
    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_num>/<frame_rate_den>, a float number or a valid video rate abbreviation
    
     * @param[in,out] frame_rate pointer to the AVRational which will contain the detected
     * frame rate
     */
    int av_parse_video_frame_rate(AVRational *frame_rate, const char *str);
    
    
    Diego Biurrun's avatar
    Diego Biurrun committed
    #define AVERROR(e) (-(e)) /**< Returns a negative error code from a POSIX error code, to return from library functions. */
    #define AVUNERROR(e) (-(e)) /**< Returns a POSIX error code from a library function error return value. */
    
    Diego Biurrun's avatar
    Diego Biurrun committed
    /* Some platforms have E* and errno already negated. */
    
    #define AVERROR(e) (e)
    #define AVUNERROR(e) (e)
    #endif
    #define AVERROR_UNKNOWN     AVERROR(EINVAL)  /**< unknown error */
    
    Diego Biurrun's avatar
    Diego Biurrun committed
    #define AVERROR_IO          AVERROR(EIO)     /**< I/O error */
    #define AVERROR_NUMEXPECTED AVERROR(EDOM)    /**< Number syntax expected in filename. */
    
    #define AVERROR_INVALIDDATA AVERROR(EINVAL)  /**< invalid data found */
    #define AVERROR_NOMEM       AVERROR(ENOMEM)  /**< not enough memory */
    #define AVERROR_NOFMT       AVERROR(EILSEQ)  /**< unknown format */
    
    Diego Biurrun's avatar
    Diego Biurrun committed
    #define AVERROR_NOTSUPP     AVERROR(ENOSYS)  /**< Operation not supported. */
    
    Benoit Fouet's avatar
    Benoit Fouet committed
    #define AVERROR_NOENT       AVERROR(ENOENT)  /**< No such file or directory. */
    
    Peter Ross's avatar
    Peter Ross committed
    #define AVERROR_EOF         AVERROR(EPIPE)   /**< End of file. */
    
    #define AVERROR_PATCHWELCOME    -MKTAG('P','A','W','E') /**< Not yet implemented in FFmpeg. Patches welcome. */
    
    /**
     * Registers the hardware accelerator \p hwaccel.
     */
    void av_register_hwaccel(AVHWAccel *hwaccel);
    
    /**
     * If hwaccel is NULL, returns the first registered hardware accelerator,
     * if hwaccel is non-NULL, returns the next registered hardware accelerator
     * after hwaccel, or NULL if hwaccel is the last one.
     */
    AVHWAccel *av_hwaccel_next(AVHWAccel *hwaccel);
    
    
    #endif /* AVCODEC_AVCODEC_H */