X-Git-Url: https://git.sesse.net/?a=blobdiff_plain;f=libavcodec%2Favcodec.h;h=7128a831484cb541a793c52508c23e7fa786839e;hb=62acb4937e06a3802735106a9d9fa48db87d0d36;hp=0455b7b03abeb47666bf440c41225434fda87111;hpb=96e9b96fcd394dcaeebf7da3f94b0b7de663ecec;p=ffmpeg diff --git a/libavcodec/avcodec.h b/libavcodec/avcodec.h index 0455b7b03ab..7128a831484 100644 --- a/libavcodec/avcodec.h +++ b/libavcodec/avcodec.h @@ -183,9 +183,6 @@ enum CodecID { CODEC_ID_TIERTEXSEQVIDEO, CODEC_ID_TIFF, CODEC_ID_GIF, -#if LIBAVCODEC_VERSION_MAJOR == 53 - CODEC_ID_FFH264, -#endif CODEC_ID_DXA, CODEC_ID_DNXHD, CODEC_ID_THP, @@ -203,10 +200,6 @@ enum CodecID { CODEC_ID_INDEO5, CODEC_ID_MIMIC, CODEC_ID_RL2, -#if LIBAVCODEC_VERSION_MAJOR == 53 - CODEC_ID_8SVX_EXP, - CODEC_ID_8SVX_FIB, -#endif CODEC_ID_ESCAPE124, CODEC_ID_DIRAC, CODEC_ID_BFI, @@ -245,16 +238,13 @@ enum CodecID { CODEC_ID_DFA, CODEC_ID_WMV3IMAGE, CODEC_ID_VC1IMAGE, -#if LIBAVCODEC_VERSION_MAJOR == 53 - CODEC_ID_G723_1, - CODEC_ID_G729, -#endif CODEC_ID_UTVIDEO, CODEC_ID_BMV_VIDEO, CODEC_ID_VBLE, CODEC_ID_DXTORY, CODEC_ID_V410, CODEC_ID_XWD, + CODEC_ID_CDXL, /* various PCM "codecs" */ CODEC_ID_FIRST_AUDIO = 0x10000, ///< A dummy id pointing at the start of audio codecs @@ -346,10 +336,6 @@ enum CodecID { CODEC_ID_MACE3, CODEC_ID_MACE6, CODEC_ID_VMDAUDIO, -#if LIBAVCODEC_VERSION_MAJOR == 53 - CODEC_ID_SONIC, - CODEC_ID_SONIC_LS, -#endif CODEC_ID_FLAC, CODEC_ID_MP3ADU, CODEC_ID_MP3ON4, @@ -391,12 +377,10 @@ enum CodecID { CODEC_ID_AAC_LATM, CODEC_ID_QDMC, CODEC_ID_CELT, -#if LIBAVCODEC_VERSION_MAJOR > 53 CODEC_ID_G723_1, CODEC_ID_G729, CODEC_ID_8SVX_EXP, CODEC_ID_8SVX_FIB, -#endif CODEC_ID_BMV_AUDIO, /* subtitle codecs */ @@ -588,17 +572,6 @@ typedef struct RcOverride{ #define CODEC_FLAG2_LOCAL_HEADER 0x00000008 ///< Place global headers at every keyframe instead of in extradata. #define CODEC_FLAG2_SKIP_RD 0x00004000 ///< RD optimal MB level residual skipping #define CODEC_FLAG2_CHUNKS 0x00008000 ///< Input bitstream might be truncated at a packet boundaries instead of only at frame boundaries. -/** - * @defgroup deprecated_flags Deprecated codec flags - * Use corresponding private codec options instead. - * @{ - */ -#if FF_API_MJPEG_GLOBAL_OPTS -#define CODEC_FLAG_EXTERN_HUFF 0x1000 ///< Use external Huffman table (for MJPEG). -#endif -/** - * @} - */ /* Unsupported options : * Syntax Arithmetic coding (SAC) @@ -614,10 +587,6 @@ typedef struct RcOverride{ * assume the buffer was allocated by avcodec_default_get_buffer. */ #define CODEC_CAP_DR1 0x0002 -#if FF_API_PARSE_FRAME -/* If 'parse_only' field is true, then avcodec_parse_frame() can be used. */ -#define CODEC_CAP_PARSE_ONLY 0x0004 -#endif #define CODEC_CAP_TRUNCATED 0x0008 /* Codec can export data for HW decoding (XvMC). */ #define CODEC_CAP_HWACCEL 0x0010 @@ -869,11 +838,7 @@ enum AVSideDataParamChangeFlags { * sizeof(AVFrame) must not be used outside libav*. */ typedef struct AVFrame { -#if FF_API_DATA_POINTERS -#define AV_NUM_DATA_POINTERS 4 -#else #define AV_NUM_DATA_POINTERS 8 -#endif /** * pointer to the picture/channel planes. * This might be different from the first allocated byte @@ -888,7 +853,7 @@ typedef struct AVFrame { * For audio, only linesize[0] may be set. For planar audio, each channel * plane must be the same size. * - * - encoding: Set by user (video only) + * - encoding: Set by user * - decoding: set by AVCodecContext.get_buffer() */ int linesize[AV_NUM_DATA_POINTERS]; @@ -942,13 +907,6 @@ typedef struct AVFrame { */ int quality; -#if FF_API_AVFRAME_AGE - /** - * @deprecated unused - */ - attribute_deprecated int age; -#endif - /** * is this picture used as reference * The values for this are the same as the MpegEncContext.picture_structure @@ -1145,7 +1103,7 @@ typedef struct AVFrame { /** * number of audio samples (per channel) described by this frame - * - encoding: unused + * - encoding: Set by user * - decoding: Set by libavcodec */ int nb_samples; @@ -1497,7 +1455,6 @@ typedef struct AVCodecContext { #define FF_BUG_DC_CLIP 4096 #define FF_BUG_MS 8192 ///< Work around various bugs in Microsoft's broken decoders. #define FF_BUG_TRUNCATED 16384 -//#define FF_BUG_FAKE_SCALABILITY 16 //Autodetection should work 100%. /** * luma single coefficient elimination threshold @@ -1621,16 +1578,6 @@ typedef struct AVCodecContext { */ int block_align; -#if FF_API_PARSE_FRAME - /** - * If true, only parsing is done. The frame data is returned. - * Only MPEG audio decoders support this now. - * - encoding: unused - * - decoding: Set by user - */ - attribute_deprecated int parse_only; -#endif - /** * 0-> h263 quant 1-> mpeg quant * - encoding: Set by user. @@ -1734,7 +1681,6 @@ typedef struct AVCodecContext { #define FF_DCT_FASTINT 1 #define FF_DCT_INT 2 #define FF_DCT_MMX 3 -#define FF_DCT_MLIB 4 #define FF_DCT_ALTIVEC 5 #define FF_DCT_FAAN 6 @@ -1784,8 +1730,7 @@ typedef struct AVCodecContext { #define FF_IDCT_SIMPLE 2 #define FF_IDCT_SIMPLEMMX 3 #define FF_IDCT_LIBMPEG2MMX 4 -#define FF_IDCT_PS2 5 -#define FF_IDCT_MLIB 6 +#define FF_IDCT_MMI 5 #define FF_IDCT_ARM 7 #define FF_IDCT_ALTIVEC 8 #define FF_IDCT_SH4 9 @@ -2054,22 +1999,6 @@ typedef struct AVCodecContext { */ int color_table_id; -#if FF_API_INTERNAL_CONTEXT - /** - * internal_buffer count - * Don't touch, used by libavcodec default_get_buffer(). - * @deprecated this field was moved to an internal context - */ - attribute_deprecated int internal_buffer_count; - - /** - * internal_buffers - * Don't touch, used by libavcodec default_get_buffer(). - * @deprecated this field was moved to an internal context - */ - attribute_deprecated void *internal_buffer; -#endif - /** * Global quality for codecs which cannot change it per frame. * This should be proportional to MPEG-1/2/4 qscale. @@ -2096,14 +2025,6 @@ typedef struct AVCodecContext { * - decoding: unused */ int context_model; -#if 0 - /** - * - * - encoding: unused - * - decoding: Set by user. - */ - uint8_t * (*realloc)(struct AVCodecContext *s, uint8_t *buf, int buf_size); -#endif /** * slice flags @@ -2734,19 +2655,6 @@ typedef struct AVCodecContext { */ AVPacket *pkt; -#if FF_API_INTERNAL_CONTEXT - /** - * Whether this is a copy of the context which had init() called on it. - * This is used by multithreading - shared tables and picture pointers - * should be freed from the original context only. - * - encoding: Set by libavcodec. - * - decoding: Set by libavcodec. - * - * @deprecated this field has been moved to an internal context - */ - attribute_deprecated int is_copy; -#endif - /** * Which multithreading methods to use. * Use of FF_THREAD_FRAME will increase decoding delay by one frame per thread, @@ -2845,31 +2753,20 @@ typedef struct AVCodec { * This is the primary way to find a codec from the user perspective. */ const char *name; + /** + * Descriptive name for the codec, meant to be more human readable than name. + * You should use the NULL_IF_CONFIG_SMALL() macro to define it. + */ + const char *long_name; enum AVMediaType type; enum CodecID id; - int priv_data_size; - int (*init)(AVCodecContext *); - int (*encode)(AVCodecContext *, uint8_t *buf, int buf_size, void *data); - int (*close)(AVCodecContext *); - int (*decode)(AVCodecContext *, void *outdata, int *outdata_size, AVPacket *avpkt); /** * Codec capabilities. * see CODEC_CAP_* */ int capabilities; - struct AVCodec *next; - /** - * Flush buffers. - * Will be called when seeking - */ - void (*flush)(AVCodecContext *); const AVRational *supported_framerates; ///< array of supported framerates, or NULL if any, array is terminated by {0,0} const enum PixelFormat *pix_fmts; ///< array of supported pixel formats, or NULL if unknown, array is terminated by -1 - /** - * Descriptive name for the codec, meant to be more human readable than name. - * You should use the NULL_IF_CONFIG_SMALL() macro to define it. - */ - const char *long_name; const int *supported_samplerates; ///< array of supported audio samplerates, or NULL if unknown, array is terminated by 0 const enum AVSampleFormat *sample_fmts; ///< array of supported sample formats, or NULL if unknown, array is terminated by -1 const uint64_t *channel_layouts; ///< array of support channel layouts, or NULL if unknown. array is terminated by 0 @@ -2877,6 +2774,15 @@ typedef struct AVCodec { const AVClass *priv_class; ///< AVClass for the private context const AVProfile *profiles; ///< array of recognized profiles, or NULL if unknown, array is terminated by {FF_PROFILE_UNKNOWN} + /***************************************************************** + * No fields below this line are part of the public API. They + * may not be used outside of libavcodec and can be changed and + * removed at will. + * New public fields should be added right above. + ***************************************************************** + */ + int priv_data_size; + struct AVCodec *next; /** * @name Frame-level threading support functions * @{ @@ -2907,6 +2813,8 @@ typedef struct AVCodec { */ void (*init_static_data)(struct AVCodec *codec); + int (*init)(AVCodecContext *); + int (*encode)(AVCodecContext *, uint8_t *buf, int buf_size, void *data); /** * Encode data to an AVPacket. * @@ -2919,6 +2827,13 @@ typedef struct AVCodec { */ int (*encode2)(AVCodecContext *avctx, AVPacket *avpkt, const AVFrame *frame, int *got_packet_ptr); + int (*decode)(AVCodecContext *, void *outdata, int *outdata_size, AVPacket *avpkt); + int (*close)(AVCodecContext *); + /** + * Flush buffers. + * Will be called when seeking + */ + void (*flush)(AVCodecContext *); } AVCodec; /** @@ -3381,19 +3296,6 @@ int avcodec_get_pix_fmt_loss(enum PixelFormat dst_pix_fmt, enum PixelFormat src_ enum PixelFormat avcodec_find_best_pix_fmt(int64_t pix_fmt_mask, enum PixelFormat src_pix_fmt, int has_alpha, int *loss_ptr); -#if FF_API_GET_ALPHA_INFO -#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 - */ -attribute_deprecated -int img_get_alpha_info(const AVPicture *src, - enum PixelFormat pix_fmt, int width, int height); -#endif - /* deinterlace a picture */ /* deinterlace - if not supported return -1 */ int avpicture_deinterlace(AVPicture *dst, const AVPicture *src, @@ -3488,11 +3390,15 @@ 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(). + * resulting struct can be deallocated by calling avcodec_close() on it followed + * by av_free(). * * @param codec if non-NULL, allocate private data and initialize defaults * for the given codec. It is illegal to then call avcodec_open2() * with a different codec. + * If NULL, then the codec-specific defaults won't be initialized, + * which may result in suboptimal default settings (this is + * important mainly for encoders, e.g. libx264). * * @return An AVCodecContext filled with default values or NULL on failure. * @see avcodec_get_context_defaults @@ -3592,6 +3498,11 @@ int avcodec_default_execute2(AVCodecContext *c, int (*func)(AVCodecContext *c2, * @endcode * * @param avctx The context to initialize. + * @param codec The codec to open this context for. If a non-NULL codec has been + * previously passed to avcodec_alloc_context3() or + * avcodec_get_context_defaults3() for this context, then this + * parameter MUST be either NULL or equal to the previously passed + * codec. * @param options A dictionary filled with AVCodecContext and codec-private options. * On return this object will be filled with options that were not found. * @@ -3860,7 +3771,10 @@ int avcodec_fill_audio_frame(AVFrame *frame, int nb_channels, enum AVSampleFormat sample_fmt, const uint8_t *buf, int buf_size, int align); +#if FF_API_OLD_ENCODE_VIDEO /** + * @deprecated use avcodec_encode_video2() instead. + * * Encode a video frame from pict into buf. * The input picture should be * stored using a specific format, namely avctx.pix_fmt. @@ -3872,11 +3786,56 @@ int avcodec_fill_audio_frame(AVFrame *frame, int nb_channels, * @return On error a negative value is returned, on success zero or the number * of bytes used from the output buffer. */ +attribute_deprecated int avcodec_encode_video(AVCodecContext *avctx, uint8_t *buf, int buf_size, const AVFrame *pict); +#endif + +/** + * Encode a frame of video. + * + * Takes input raw video data from frame and writes the next output packet, if + * available, to avpkt. The output packet does not necessarily contain data for + * the most recent frame, as encoders can delay and reorder input frames + * internally as needed. + * + * @param avctx codec context + * @param avpkt output AVPacket. + * The user can supply an output buffer by setting + * avpkt->data and avpkt->size prior to calling the + * function, but if the size of the user-provided data is not + * large enough, encoding will fail. All other AVPacket fields + * will be reset by the encoder using av_init_packet(). If + * avpkt->data is NULL, the encoder will allocate it. + * The encoder will set avpkt->size to the size of the + * output packet. The returned data (if any) belongs to the + * caller, he is responsible for freeing it. + * @param[in] frame AVFrame containing the raw video data to be encoded. + * May be NULL when flushing an encoder that has the + * CODEC_CAP_DELAY capability set. + * @param[out] got_packet_ptr This field is set to 1 by libavcodec if the + * output packet is non-empty, and to 0 if it is + * empty. If the function returns an error, the + * packet can be assumed to be invalid, and the + * value of got_packet_ptr is undefined and should + * not be used. + * @return 0 on success, negative error code on failure + */ +int avcodec_encode_video2(AVCodecContext *avctx, AVPacket *avpkt, + const AVFrame *frame, int *got_packet_ptr); + int avcodec_encode_subtitle(AVCodecContext *avctx, uint8_t *buf, int buf_size, const AVSubtitle *sub); +/** + * Close a given AVCodecContext and free all the data associated with it + * (but not the AVCodecContext itself). + * + * Calling this function on an AVCodecContext that hasn't been opened will free + * the codec-specific data allocated in avcodec_alloc_context3() / + * avcodec_get_context_defaults3() with a non-NULL codec. Subsequent calls will + * do nothing. + */ int avcodec_close(AVCodecContext *avctx); /** @@ -4035,6 +3994,13 @@ typedef struct AVCodecParserContext { * Previous frame byte position. */ int64_t last_pos; + + /** + * Duration of the current frame. + * For audio, this is in units of 1 / AVCodecContext.sample_rate. + * For all other types, this is in units of AVCodecContext.time_base. + */ + int duration; } AVCodecParserContext; typedef struct AVCodecParser { @@ -4149,6 +4115,15 @@ void *av_fast_realloc(void *ptr, unsigned int *size, size_t min_size); */ void av_fast_malloc(void *ptr, unsigned int *size, size_t min_size); +/** + * Allocate a buffer with padding, reusing the given one if large enough. + * + * Same behaviour av_fast_malloc but the buffer has additional + * FF_INPUT_PADDING_SIZE at the end which will always memset to 0. + * + */ +void av_fast_padded_malloc(void *ptr, unsigned int *size, size_t min_size); + /** * Copy image src to dst. Wraps av_picture_data_copy() above. */ @@ -4251,4 +4226,10 @@ enum AVMediaType avcodec_get_type(enum CodecID codec_id); */ const AVClass *avcodec_get_class(void); +/** + * @return a positive value if s is open (i.e. avcodec_open2() was called on it + * with no corresponding avcodec_close()), 0 otherwise. + */ +int avcodec_is_open(AVCodecContext *s); + #endif /* AVCODEC_AVCODEC_H */