Newer
Older
Michael Niedermayer
committed
struct AVResampleContext;
typedef struct ReSampleContext ReSampleContext;
#if FF_API_AUDIO_OLD
/**
* @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
/**
* Initialize audio resampling context
3019
3020
3021
3022
3023
3024
3025
3026
3027
3028
3029
3030
3031
3032
3033
3034
3035
3036
3037
3038
3039
*
* @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);
int audio_resample(ReSampleContext *s, short *output, short *input, int nb_samples);
void audio_resample_close(ReSampleContext *s);
/**
* Note, if either rate is not an integer then simply scale both rates up so they are.
Michael Niedermayer
committed
* @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);
/**
* Resample an array of samples using a previously configured context.
* @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
*/
Michael Niedermayer
committed
int av_resample(struct AVResampleContext *c, short *dst, short *src, int *consumed, int src_size, int dst_size, int update_ctx);
/**
* Compensate 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
*/
void av_resample_compensate(struct AVResampleContext *c, int sample_delta, int compensation_distance);
William Juwono
committed
void av_resample_close(struct AVResampleContext *c);
Michael Niedermayer
committed
/**
* Allocate memory for a picture. Call avpicture_free to free it.
*
* @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
int avpicture_alloc(AVPicture *picture, enum PixelFormat pix_fmt, int width, int height);
/**
* Free a picture previously allocated by avpicture_alloc().
*
Panagiotis Issaris
committed
/**
Panagiotis Issaris
committed
* 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.
Panagiotis Issaris
committed
*
* @param picture AVPicture whose fields are to be filled in
Panagiotis Issaris
committed
* @param ptr Buffer which will contain or contains the actual image data
* @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
Panagiotis Issaris
committed
*/
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);
Panagiotis Issaris
committed
/**
* 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.
Panagiotis Issaris
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).
Panagiotis Issaris
committed
*/
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);
#if LIBAVCODEC_VERSION_MAJOR < 53
/**
* Return the pixel format corresponding to the name name.
* If there is no pixel format with name name, then look for a
* pixel format with the name corresponding to the native endian
* format of name.
* For example in a little-endian system, first look for "gray16",
* then for "gray16le".
*
* Finally if no pixel format has been found, return PIX_FMT_NONE.
*
* @deprecated Deprecated in favor of av_get_pix_fmt().
*/
attribute_deprecated enum PixelFormat avcodec_get_pix_fmt(const char* name);
#endif
* Return a value representing the fourCC code associated to the
* pixel format pix_fmt, or 0 if no associated fourCC code can be
* found.
*/
unsigned int avcodec_pix_fmt_to_codec_tag(enum PixelFormat pix_fmt);
* Put a string representing the codec tag codec_tag in buf.
*
* @param buf_size size in bytes of buf
* @return the length of the string that would have been generated if
* enough space had been available, excluding the trailing null
*/
size_t av_get_codec_tag_string(char *buf, size_t buf_size, unsigned int codec_tag);
Panagiotis Issaris
committed
#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) */
Fabrice Bellard
committed
Panagiotis Issaris
committed
/**
* Compute what kind of losses will occur when converting from one specific
Panagiotis Issaris
committed
* 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.
* avcodec_get_fix_fmt_loss() informs you about the various types of losses
* which will occur when converting from one pixel format to another.
Panagiotis Issaris
committed
*
* @param[in] dst_pix_fmt destination pixel format
* @param[in] src_pix_fmt source pixel format
Panagiotis Issaris
committed
* @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.
Panagiotis Issaris
committed
*/
int avcodec_get_pix_fmt_loss(enum PixelFormat dst_pix_fmt, enum PixelFormat src_pix_fmt,
Fabrice Bellard
committed
int has_alpha);
Panagiotis Issaris
committed
/**
* Find the best pixel format to convert to given a certain source pixel
Panagiotis Issaris
committed
* 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
* 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
* pix_fmt_mask parameter.
Panagiotis Issaris
committed
*
* @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
*
* @param[in] pix_fmt_mask bitmask determining which pixel format to choose from
* @param[in] src_pix_fmt source pixel format
Panagiotis Issaris
committed
* @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.
Panagiotis Issaris
committed
*/
enum PixelFormat avcodec_find_best_pix_fmt(int64_t pix_fmt_mask, enum PixelFormat src_pix_fmt,
Fabrice Bellard
committed
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, enum PixelFormat pix_fmt);
#define FF_ALPHA_TRANSP 0x0001 /* image has some totally transparent pixels */
#define FF_ALPHA_SEMI_TRANSP 0x0002 /* image has some transparent pixels */
Panagiotis Issaris
committed
/**
* 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,
enum PixelFormat pix_fmt, int width, int height);
/* deinterlace a picture */
Panagiotis Issaris
committed
/* deinterlace - if not supported return -1 */
int avpicture_deinterlace(AVPicture *dst, const AVPicture *src,
enum PixelFormat pix_fmt, int width, int height);
/**
* If c is NULL, returns the first registered codec,
* if c is non-NULL, returns the next registered codec after c,
AVCodec *av_codec_next(AVCodec *c);
* Return the LIBAVCODEC_VERSION_INT constant.
unsigned avcodec_version(void);
* Return the libavcodec build-time configuration.
const char *avcodec_configuration(void);
/**
const char *avcodec_license(void);
* @warning This function must be called before any other libavcodec
#if LIBAVCODEC_VERSION_MAJOR < 53
/**
* @deprecated Deprecated in favor of avcodec_register().
*/
attribute_deprecated void register_avcodec(AVCodec *codec);
#endif
* Register the codec codec and initialize libavcodec.
void avcodec_register(AVCodec *codec);
* Find a registered encoder with a matching codec ID.
* @return An encoder if one was found, NULL otherwise.
*/
* Find a registered encoder with the specified name.
* @return An encoder if one was found, NULL otherwise.
*/
AVCodec *avcodec_find_encoder_by_name(const char *name);
* Find a registered decoder with a matching codec ID.
* @return A decoder if one was found, NULL otherwise.
*/
* Find a registered decoder with the specified name.
* @return A decoder if one was found, NULL otherwise.
*/
AVCodec *avcodec_find_decoder_by_name(const char *name);
void avcodec_string(char *buf, int buf_size, AVCodecContext *enc, int encode);
* Set 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
committed
/** 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 AVMediaType);
Michael Niedermayer
committed
Michael Niedermayer
committed
/** THIS FUNCTION IS NOT YET PART OF THE PUBLIC API!
* we WILL change its arguments and name a few times! */
int avcodec_get_context_defaults3(AVCodecContext *s, AVCodec *codec);
* Allocate an AVCodecContext and set 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
*/
Michael Niedermayer
committed
/** 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 AVMediaType);
Michael Niedermayer
committed
Michael Niedermayer
committed
/** THIS FUNCTION IS NOT YET PART OF THE PUBLIC API!
* we WILL change its arguments and name a few times! */
AVCodecContext *avcodec_alloc_context3(AVCodec *codec);
/**
* Copy the settings of the source AVCodecContext into the destination
* AVCodecContext. The resulting destination codec context will be
* unopened, i.e. you are required to call avcodec_open() before you
* can use this AVCodecContext to decode/encode video/audio data.
*
* @param dest target codec context, should be initialized with
* avcodec_alloc_context(), but otherwise uninitialized
* @param src source codec context
* @return AVERROR() on error (e.g. memory allocation error), 0 on success
*/
int avcodec_copy_context(AVCodecContext *dest, const AVCodecContext *src);
* Set the fields of the given AVFrame to default values.
*
* @param pic The AVFrame of which the fields should be set to default values.
*/
* Allocate an AVFrame and set 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
*/
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);
* Return the amount of padding in pixels which the get_buffer callback must
* provide around the edge of the image for codecs which do not have the
* CODEC_FLAG_EMU_EDGE flag.
*
* @return Required padding in pixels.
*/
unsigned avcodec_get_edge_width(void);
Reimar Döffinger
committed
/**
* Modify width and height values so that they will result in a memory
Reimar Döffinger
committed
* buffer that is acceptable for the codec if you do not use any horizontal
* padding.
*
* May only be used if a codec with CODEC_CAP_DR1 has been opened.
* If CODEC_FLAG_EMU_EDGE is not set, the dimensions must have been increased
* according to avcodec_get_edge_width() before.
Reimar Döffinger
committed
*/
void avcodec_align_dimensions(AVCodecContext *s, int *width, int *height);
Reimar Döffinger
committed
/**
* Modify width and height values so that they will result in a memory
Reimar Döffinger
committed
* buffer that is acceptable for the codec if you also ensure that all
* line sizes are a multiple of the respective linesize_align[i].
*
* May only be used if a codec with CODEC_CAP_DR1 has been opened.
* If CODEC_FLAG_EMU_EDGE is not set, the dimensions must have been increased
* according to avcodec_get_edge_width() before.
Reimar Döffinger
committed
*/
void avcodec_align_dimensions2(AVCodecContext *s, int *width, int *height,
int linesize_align[4]);
#if LIBAVCODEC_VERSION_MAJOR < 53
* @deprecated Deprecated in favor of av_check_image_size().
attribute_deprecated
int avcodec_check_dimensions(void *av_log_ctx, unsigned int w, unsigned int h);
#endif
enum PixelFormat avcodec_default_get_format(struct AVCodecContext *s, const enum PixelFormat * fmt);
int avcodec_thread_init(AVCodecContext *s, int thread_count);
void avcodec_thread_free(AVCodecContext *s);
Roman Shaposhnik
committed
int avcodec_default_execute(AVCodecContext *c, int (*func)(AVCodecContext *c2, void *arg2),void *arg, int *ret, int count, int size);
Reimar Döffinger
committed
int avcodec_default_execute2(AVCodecContext *c, int (*func)(AVCodecContext *c2, void *arg2, int, int),void *arg, int *ret, int count);
* Initialize 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.
*
* 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
*
* @param avctx The context which will be set up to use the given codec.
* @param codec The codec to use within the context.
* @return zero on success, a negative value on error
* @see avcodec_alloc_context, avcodec_find_decoder, avcodec_find_encoder
int avcodec_open(AVCodecContext *avctx, AVCodec *codec);
#if FF_API_AUDIO_OLD
Luca Barbato
committed
/**
* Decode an audio frame from buf into samples.
* Wrapper function which calls avcodec_decode_audio3.
*
Thilo Borgmann
committed
* @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.
Thilo Borgmann
committed
*/
attribute_deprecated int avcodec_decode_audio2(AVCodecContext *avctx, int16_t *samples,
int *frame_size_ptr,
const uint8_t *buf, int buf_size);
#endif
/**
* Decode the audio frame of size avpkt->size from avpkt->data into samples.
* Some decoders may support multiple frames in a single AVPacket, such
* decoders would then just decode the first frame. In this case,
* avcodec_decode_audio3 has to be called again with an AVPacket that contains
* the remaining data in order to decode the second frame etc.
* If no frame
* could be outputted, frame_size_ptr is zero. Otherwise, it is the
* decompressed frame size in bytes.
* @warning You must set frame_size_ptr to the allocated size of the
Thilo Borgmann
committed
* output buffer before calling avcodec_decode_audio3().
* @warning The input buffer must be 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 avpkt->data should be set to 0 to ensure that
* no overreading happens for damaged MPEG streams.
Luca Barbato
committed
*
* @note You might have to align the input buffer avpkt->data and output buffer
* 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, avpkt->data should have 4 byte alignment at minimum and
* samples should be 16 byte aligned unless the CPU doesn't need it
* (AltiVec and SSE do).
* @param[out] samples the output buffer, sample type in avctx->sample_fmt
* @param[in,out] frame_size_ptr the output buffer size in bytes
Thilo Borgmann
committed
* @param[in] avpkt The input AVPacket containing the input buffer.
* You can create such packet with av_init_packet() and by then setting
* data and size, some decoders might in addition need other fields.
* All decoders are designed to use the least fields possible though.
* @return On error a negative value is returned, otherwise the number of bytes
* used or zero if no frame data was decompressed (used) from the input AVPacket.
Luca Barbato
committed
*/
Thilo Borgmann
committed
int avcodec_decode_audio3(AVCodecContext *avctx, int16_t *samples,
Thilo Borgmann
committed
AVPacket *avpkt);
#if FF_API_VIDEO_OLD
* Decode a video frame from buf into picture.
* Wrapper function which calls avcodec_decode_video2.
*
Thilo Borgmann
committed
* @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.
Thilo Borgmann
committed
*/
attribute_deprecated int avcodec_decode_video(AVCodecContext *avctx, AVFrame *picture,
int *got_picture_ptr,
const uint8_t *buf, int buf_size);
#endif
/**
* Decode the video frame of size avpkt->size from avpkt->data into picture.
* Some decoders may support multiple frames in a single AVPacket, such
* decoders would then just decode the first frame.
* @warning The input buffer must be 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 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 avpkt->data.
* 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, avpkt->data should have 4 byte alignment at minimum.
Michael Niedermayer
committed
* @note Some codecs have a delay between input and output, these need to be
* fed with avpkt->data=NULL, avpkt->size=0 at the end to return the remaining frames.
Michael Niedermayer
committed
*
* @param[out] picture The AVFrame in which the decoded video frame will be stored.
* Use avcodec_alloc_frame to get an AVFrame, the codec will
* allocate memory for the actual bitmap.
* with default get/release_buffer(), the decoder frees/reuses the bitmap as it sees fit.
Michael Niedermayer
committed
* with overridden get/release_buffer() (needs CODEC_CAP_DR1) the user decides into what buffer the decoder
* decodes and the decoder tells the user once it does not need the data anymore,
* the user app can at this point free/reuse/keep the memory as it sees fit.
*
Thilo Borgmann
committed
* @param[in] avpkt The input AVpacket containing the input buffer.
* You can create such packet with av_init_packet() and by then setting
* data and size, some decoders might in addition need other fields like
* flags&AV_PKT_FLAG_KEY. All decoders are designed to use the least
* fields possible.
* @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.
*/
Thilo Borgmann
committed
int avcodec_decode_video2(AVCodecContext *avctx, AVFrame *picture,
Thilo Borgmann
committed
AVPacket *avpkt);
Panagiotis Issaris
committed
Aurelien Jacobs
committed
#if FF_API_SUBTITLE_OLD
/* 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. */
Thilo Borgmann
committed
attribute_deprecated int avcodec_decode_subtitle(AVCodecContext *avctx, AVSubtitle *sub,
int *got_sub_ptr,
const uint8_t *buf, int buf_size);
Thilo Borgmann
committed
#endif
/**
* Return a negative value on 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.
* Note that CODEC_CAP_DR1 is not available for subtitle codecs. This is for
* simplicity, because the performance difference is expect to be negligible
* and reusing a get_buffer written for video codecs would probably perform badly
* due to a potentially very different allocation pattern.
Thilo Borgmann
committed
*
* @param avctx the codec context
* @param[out] sub The AVSubtitle in which the decoded subtitle will be stored, must be
freed with avsubtitle_free if *got_sub_ptr is set.
Thilo Borgmann
committed
* @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);
/**
* Frees all allocated data in the given subtitle struct.
*
* @param sub AVSubtitle to free.
*/
void avsubtitle_free(AVSubtitle *sub);
int avcodec_parse_frame(AVCodecContext *avctx, uint8_t **pdata,
Fabrice Bellard
committed
int *data_size_ptr,
* Encode an audio frame from samples into buf.
* @note The output buffer should be at least 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 buf_size as described
* below. In that case a lower value can be used.
* @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 avctx.
* For PCM audio the number of samples read from samples is equal to
* buf_size * input_sample_size / output_sample_size.
* @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,
* Encode a video frame from pict into buf.
Michael Niedermayer
committed
* The input picture should be
* stored using a specific format, namely avctx.pix_fmt.
* @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,
int avcodec_encode_subtitle(AVCodecContext *avctx, uint8_t *buf, int buf_size,
/**
* 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 avcodec_register
* @see av_register_codec_parser
* @see av_register_bitstream_filter
*/
Panagiotis Issaris
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);
* Return a single letter to describe the given picture type pict_type.
*
* @return A single character representing the picture type.
*
* @return Number of bits per sample or zero if unknown for the given codec.
*/
int av_get_bits_per_sample(enum CodecID codec_id);
* Return 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 */
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.
*/
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;
#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
Alex Converse
committed
#define PARSER_FLAG_ONCE 0x0002
/// Set if the parser has a valid file offset
#define PARSER_FLAG_FETCHED_OFFSET 0x0004
int64_t offset; ///< byte offset from starting packet start
Michael Niedermayer
committed
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.
* This field has no meaning if the packet does not have AV_PKT_FLAG_KEY
* set.
*
* 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;
3791
3792
3793
3794
3795
3796
3797
3798
3799
3800
3801
3802
3803
3804
3805
3806
3807
3808
3809
3810
3811
3812
3813
3814
3815
3816
3817
3818
3819
3820
3821
3822
3823
3824
3825
3826
3827
3828
3829
3830
3831
// 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 {
int codec_ids[5]; /* several codec IDs are permitted */
int priv_data_size;
int (*parser_init)(AVCodecParserContext *s);
int (*parser_parse)(AVCodecParserContext *s,
const uint8_t **poutbuf, int *poutbuf_size,
const uint8_t *buf, int buf_size);
void (*parser_close)(AVCodecParserContext *s);
Michael Niedermayer
committed
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
int av_parser_parse(AVCodecParserContext *s,
uint8_t **poutbuf, int *poutbuf_size,
const uint8_t *buf, int buf_size,
int64_t pts, int64_t dts);
#endif
3877
3878
3879
3880
3881
3882
3883
3884
3885
3886
3887
3888
3889
3890
3891
3892
3893
3894
3895
3896
3897
3898
3899
3900
3901
3902
3903
3904
3905
3906
3907
3908
3909
3910
3911
3912
/**
* 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);
Michael Niedermayer
committed
int av_parser_change(AVCodecParserContext *s,
AVCodecContext *avctx,
uint8_t **poutbuf, int *poutbuf_size,
Michael Niedermayer
committed
const uint8_t *buf, int buf_size, int keyframe);
void av_parser_close(AVCodecParserContext *s);
Michael Niedermayer
committed
typedef struct AVBitStreamFilterContext {
Michael Niedermayer
committed
struct AVBitStreamFilter *filter;
AVCodecParserContext *parser;
struct AVBitStreamFilterContext *next;
} AVBitStreamFilterContext;
typedef struct AVBitStreamFilter {
const char *name;
Michael Niedermayer
committed
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);
Michael Niedermayer
committed
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);
Michael Niedermayer
committed
Panagiotis Issaris
committed
/**
* Reallocate the given block if it is not large enough, otherwise do nothing.
*
* @see av_realloc
Panagiotis Issaris
committed
*/
void *av_fast_realloc(void *ptr, unsigned int *size, unsigned int min_size);
Panagiotis Issaris
committed
Reimar Döffinger
committed
/**
* Allocate a buffer, reusing the given one if large enough.
Reimar Döffinger
committed
*
* 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);
#if LIBAVCODEC_VERSION_MAJOR < 53
Panagiotis Issaris
committed
/**
* @deprecated Deprecated in favor of av_image_copy().
S.N. Hemanth Meenakshisundaram
committed
*/
attribute_deprecated
S.N. Hemanth Meenakshisundaram
committed
void av_picture_data_copy(uint8_t *dst_data[4], int dst_linesize[4],
uint8_t *src_data[4], int src_linesize[4],
enum PixelFormat pix_fmt, int width, int height);
S.N. Hemanth Meenakshisundaram
committed
/**
* Copy image src to dst. Wraps av_picture_data_copy() above.
Panagiotis Issaris
committed
*/
Panagiotis Issaris
committed
void av_picture_copy(AVPicture *dst, const AVPicture *src,
enum PixelFormat pix_fmt, int width, int height);
Panagiotis Issaris
committed
/**
Panagiotis Issaris
committed
*/
Panagiotis Issaris
committed
int av_picture_crop(AVPicture *dst, const AVPicture *src,
enum PixelFormat pix_fmt, int top_band, int left_band);
Panagiotis Issaris
committed
/**
Panagiotis Issaris
committed
*/
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);