diff options
Diffstat (limited to 'libavcodec/avcodec.h')
-rw-r--r-- | libavcodec/avcodec.h | 184 |
1 files changed, 156 insertions, 28 deletions
diff --git a/libavcodec/avcodec.h b/libavcodec/avcodec.h index 43abcd82be..1381a3e018 100644 --- a/libavcodec/avcodec.h +++ b/libavcodec/avcodec.h @@ -1,20 +1,20 @@ /* * copyright (c) 2001 Fabrice Bellard * - * This file is part of Libav. + * This file is part of FFmpeg. * - * Libav is free software; you can redistribute it and/or + * FFmpeg is free software; you can redistribute it and/or * modify it under the terms of the GNU Lesser General Public * License as published by the Free Software Foundation; either * version 2.1 of the License, or (at your option) any later version. * - * Libav is distributed in the hope that it will be useful, + * FFmpeg is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU * Lesser General Public License for more details. * * You should have received a copy of the GNU Lesser General Public - * License along with Libav; if not, write to the Free Software + * License along with FFmpeg; if not, write to the Free Software * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA */ @@ -78,7 +78,8 @@ * * If you add a codec ID to this list, add it so that * 1. no value of a existing codec ID changes (that would break ABI), - * 2. it is as close as possible to similar codecs. + * 2. Give it a value which when taken as ASCII is recognized uniquely by a human as this specific codec. + * This ensures that 2 forks can independantly add CodecIDs without producing conflicts. */ enum CodecID { CODEC_ID_NONE, @@ -246,12 +247,15 @@ enum CodecID { CODEC_ID_WMV3IMAGE, CODEC_ID_VC1IMAGE, #if LIBAVCODEC_VERSION_MAJOR == 53 - CODEC_ID_G723_1, - CODEC_ID_G729, + CODEC_ID_G723_1_DEPRECATED, + CODEC_ID_G729_DEPRECATED, #endif - CODEC_ID_UTVIDEO, + CODEC_ID_UTVIDEO_DEPRECATED, CODEC_ID_BMV_VIDEO, CODEC_ID_VBLE, + CODEC_ID_UTVIDEO = 0x800, + + CODEC_ID_G2M = MKBETAG( 0 ,'G','2','M'), /* various PCM "codecs" */ CODEC_ID_FIRST_AUDIO = 0x10000, ///< A dummy id pointing at the start of audio codecs @@ -388,12 +392,15 @@ enum CodecID { CODEC_ID_QDMC, CODEC_ID_CELT, #if LIBAVCODEC_VERSION_MAJOR > 53 - CODEC_ID_G723_1, - CODEC_ID_G729, + CODEC_ID_G723_1_DEPRECATED, + CODEC_ID_G729_DEPRECATED, CODEC_ID_8SVX_EXP, CODEC_ID_8SVX_FIB, #endif CODEC_ID_BMV_AUDIO, + CODEC_ID_G729 = 0x15800, + CODEC_ID_G723_1= 0x15801, + CODEC_ID_8SVX_RAW = MKBETAG('8','S','V','X'), /* subtitle codecs */ CODEC_ID_FIRST_SUBTITLE = 0x17000, ///< A dummy ID pointing at the start of subtitle codecs. @@ -406,10 +413,14 @@ enum CodecID { CODEC_ID_HDMV_PGS_SUBTITLE, CODEC_ID_DVB_TELETEXT, CODEC_ID_SRT, + CODEC_ID_MICRODVD = MKBETAG('m','D','V','D'), /* other specific kind of codecs (generally used for attachments) */ CODEC_ID_FIRST_UNKNOWN = 0x18000, ///< A dummy ID pointing at the start of various fake codecs. CODEC_ID_TTF = 0x18000, + CODEC_ID_BINTEXT = MKBETAG('B','T','X','T'), + CODEC_ID_XBIN = MKBETAG('X','B','I','N'), + CODEC_ID_IDF = MKBETAG( 0 ,'I','D','F'), CODEC_ID_PROBE = 0x19000, ///< codec_id is not known (like CODEC_ID_NONE) but lavf should attempt to identify it @@ -490,7 +501,7 @@ enum CodecID { * Note: If the first 23 bits of the additional bytes are not 0, then damaged * MPEG bitstreams could cause overread and segfault. */ -#define FF_INPUT_BUFFER_PADDING_SIZE 8 +#define FF_INPUT_BUFFER_PADDING_SIZE 16 /** * minimum encoding buffer size @@ -542,6 +553,7 @@ enum AVColorTransferCharacteristic{ AVCOL_TRC_UNSPECIFIED=2, AVCOL_TRC_GAMMA22 =4, ///< also ITU-R BT470M / ITU-R BT1700 625 PAL & SECAM AVCOL_TRC_GAMMA28 =5, ///< also ITU-R BT470BG + AVCOL_TRC_SMPTE240M =7, AVCOL_TRC_NB , ///< Not part of ABI }; @@ -553,6 +565,7 @@ enum AVColorSpace{ AVCOL_SPC_BT470BG =5, ///< also ITU-R BT601-6 625 / ITU-R BT1358 625 / ITU-R BT1700 625 PAL & SECAM / IEC 61966-2-4 xvYCC601 AVCOL_SPC_SMPTE170M =6, ///< also ITU-R BT601-6 525 / ITU-R BT1358 525 / ITU-R BT1700 NTSC / functionally identical to above AVCOL_SPC_SMPTE240M =7, + AVCOL_SPC_YCGCO =8, AVCOL_SPC_NB , ///< Not part of ABI }; @@ -656,6 +669,7 @@ 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. +#define CODEC_FLAG2_SHOW_ALL 0x00400000 ///< Show all frames before the first keyframe /** * @defgroup deprecated_flags Deprecated codec flags * Use corresponding private codec options instead. @@ -757,10 +771,12 @@ typedef struct RcOverride{ * Codec should fill in channel configuration and samplerate instead of container */ #define CODEC_CAP_CHANNEL_CONF 0x0400 + /** * Codec is able to deal with negative linesizes */ #define CODEC_CAP_NEG_LINESIZES 0x0800 + /** * Codec supports frame-level multithreading. */ @@ -769,6 +785,10 @@ typedef struct RcOverride{ * Codec supports slice-based (or partition-based) multithreading. */ #define CODEC_CAP_SLICE_THREADS 0x2000 +/** + * Codec is lossless. + */ +#define CODEC_CAP_LOSSLESS 0x80000000 //The following defines may change, don't expect compatibility if you use them. #define MB_TYPE_INTRA4x4 0x0001 @@ -1152,7 +1172,7 @@ typedef struct AVFrame { int64_t reordered_opaque; /** - * hardware accelerator private data (Libav-allocated) + * hardware accelerator private data (FFmpeg-allocated) * - encoding: unused * - decoding: Set by libavcodec */ @@ -1185,6 +1205,44 @@ typedef struct AVFrame { * - decoding: Set by libavcodec. */ void *thread_opaque; + + /** + * frame timestamp estimated using various heuristics, in stream time base + * - encoding: unused + * - decoding: set by libavcodec, read by user. + */ + int64_t best_effort_timestamp; + + /** + * reordered pos from the last AVPacket that has been input into the decoder + * - encoding: unused + * - decoding: Read by user. + */ + int64_t pkt_pos; + + /** + * reordered sample aspect ratio for the video frame, 0/1 if unknown\unspecified + * - encoding: unused + * - decoding: Read by user. + */ + AVRational sample_aspect_ratio; + + /** + * width and height of the video frame + * - encoding: unused + * - decoding: Read by user. + */ + int width, height; + + /** + * format of the frame, -1 if unknown or unset + * It should be cast to the corresponding enum (enum PixelFormat + * for video, enum AVSampleFormat for audio) + * - encoding: unused + * - decoding: Read by user. + */ + int format; + } AVFrame; struct AVCodecInternal; @@ -1194,6 +1252,8 @@ struct AVCodecInternal; * New fields can be added to the end with minor version bumps. * Removal, reordering and changes to existing fields require a major * version bump. + * Please use AVOptions (av_opt* / av_set/get*()) to access these fields from user + * applications. * sizeof(AVCodecContext) must not be used outside libav*. */ typedef struct AVCodecContext { @@ -1341,10 +1401,12 @@ typedef struct AVCodecContext { int frame_number; ///< audio or video frame number /** - * Number of frames the decoded output will be delayed relative to - * the encoded input. + * Encoding: Number of frames delay there will be from the encoder input to + * the decoder output. (we assume the decoder matches the spec) + * Decoding: Number of frames delay in addition to what a standard decoder + * as specified in the spec would produce. * - encoding: Set by libavcodec. - * - decoding: unused + * - decoding: Set by libavcodec. */ int delay; @@ -2648,9 +2710,9 @@ typedef struct AVCodecContext { #endif /** - * GOP timecode frame start number, in non drop frame format - * - encoding: Set by user. - * - decoding: unused + * GOP timecode frame start number + * - encoding: Set by user, in non drop frame format + * - decoding: Set by libavcodec (timecode in the 25 bits format, -1 if unset) */ int64_t timecode_frame_start; @@ -2694,7 +2756,7 @@ typedef struct AVCodecContext { /** * Audio channel layout. * - encoding: set by user. - * - decoding: set by libavcodec. + * - decoding: set by user, may be overwritten by libavcodec. */ uint64_t channel_layout; @@ -2739,8 +2801,8 @@ typedef struct AVCodecContext { * Hardware accelerator context. * For some hardware accelerators, a global context needs to be * provided by the user. In that case, this holds display-dependent - * data Libav cannot instantiate itself. Please refer to the - * Libav HW accelerator documentation to know how to fill this + * data FFmpeg cannot instantiate itself. Please refer to the + * FFmpeg HW accelerator documentation to know how to fill this * is. e.g. for VA API, this is a struct vaapi_context. * - encoding: unused * - decoding: Set by user @@ -2970,9 +3032,10 @@ typedef struct AVCodecContext { enum AVAudioServiceType audio_service_type; /** - * Used to request a sample format from the decoder. - * - encoding: unused. + * desired sample format + * - encoding: Not used. * - decoding: Set by user. + * Decoder will decode to this format if it can. */ enum AVSampleFormat request_sample_fmt; @@ -2987,6 +3050,10 @@ typedef struct AVCodecContext { #define AV_EF_BUFFER (1<<2) #define AV_EF_EXPLODE (1<<3) +#define AV_EF_CAREFUL (1<<16) +#define AV_EF_COMPLIANT (1<<17) +#define AV_EF_AGGRESSIVE (1<<18) + /** * Private context used for internal data. * @@ -2994,6 +3061,17 @@ typedef struct AVCodecContext { * libavcodec functions. */ struct AVCodecInternal *internal; + + /** + * Current statistics for PTS correction. + * - decoding: maintained and used by libavcodec, not intended to be used by user apps + * - encoding: unused + */ + int64_t pts_correction_num_faulty_pts; /// Number of incorrect PTS values so far + int64_t pts_correction_num_faulty_dts; /// Number of incorrect DTS values so far + int64_t pts_correction_last_pts; /// PTS of the last frame + int64_t pts_correction_last_dts; /// DTS of the last frame + } AVCodecContext; /** @@ -3336,6 +3414,11 @@ uint8_t* av_packet_new_side_data(AVPacket *pkt, enum AVPacketSideDataType type, uint8_t* av_packet_get_side_data(AVPacket *pkt, enum AVPacketSideDataType type, int *size); +int av_packet_merge_side_data(AVPacket *pkt); + +int av_packet_split_side_data(AVPacket *pkt); + + /* resample.c */ struct ReSampleContext; @@ -3493,8 +3576,17 @@ int avpicture_layout(const AVPicture* src, enum PixelFormat pix_fmt, int width, 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); +/** + * Get the name of a codec. + * @return a static string identifying the codec; never NULL + */ +const char *avcodec_get_name(enum CodecID id); + #if FF_API_GET_PIX_FMT_NAME /** + * Return the short name for a pixel format. + * + * \see av_get_pix_fmt(), av_get_pix_fmt_string(). * @deprecated Deprecated in favor of av_get_pix_fmt_name(). */ attribute_deprecated @@ -3541,7 +3633,8 @@ size_t av_get_codec_tag_string(char *buf, size_t buf_size, unsigned int codec_ta * @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. + * @return Combination of flags informing you what kind of losses will occur + * (maximum loss for an invalid dst_pix_fmt). */ int avcodec_get_pix_fmt_loss(enum PixelFormat dst_pix_fmt, enum PixelFormat src_pix_fmt, int has_alpha); @@ -3556,9 +3649,11 @@ int avcodec_get_pix_fmt_loss(enum PixelFormat dst_pix_fmt, enum PixelFormat src_ * The pixel formats from which it chooses one, are determined by the * pix_fmt_mask parameter. * + * Note, only the first 64 pixel formats will fit in pix_fmt_mask. + * * @code * src_pix_fmt = PIX_FMT_YUV420P; - * pix_fmt_mask = (1 << PIX_FMT_YUV422P) || (1 << PIX_FMT_RGB24); + * 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 * @@ -3571,6 +3666,39 @@ 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); +/** + * Find the best pixel format to convert to given a certain source pixel + * format and a selection of two destination pixel formats. 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_fmt2() selects which of + * the given pixel formats should be used to suffer the least amount of loss. + * + * If one of the destination formats is PIX_FMT_NONE the other pixel format (if valid) will be + * returned. + * + * @code + * src_pix_fmt = PIX_FMT_YUV420P; + * dst_pix_fmt1= PIX_FMT_RGB24; + * dst_pix_fmt2= PIX_FMT_GRAY8; + * dst_pix_fmt3= PIX_FMT_RGB8; + * loss= FF_LOSS_CHROMA; // don't care about chroma loss, so chroma loss will be ignored. + * dst_pix_fmt = avcodec_find_best_pix_fmt2(dst_pix_fmt1, dst_pix_fmt2, src_pix_fmt, alpha, &loss); + * dst_pix_fmt = avcodec_find_best_pix_fmt2(dst_pix_fmt, dst_pix_fmt3, src_pix_fmt, alpha, &loss); + * @endcode + * + * @param[in] dst_pix_fmt1 One of the two destination pixel formats to choose from + * @param[in] dst_pix_fmt2 The other of the two destination pixel formats 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[in, out] loss_ptr Combination of loss flags. In: selects which of the losses to ignore, i.e. + * NULL or value of zero means we care about all losses. Out: the loss + * that occurs when converting from src to selected dst pixel format. + * @return The best pixel format to convert to or -1 if none was found. + */ +enum PixelFormat avcodec_find_best_pix_fmt2(enum PixelFormat dst_pix_fmt1, enum PixelFormat dst_pix_fmt2, + 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 */ @@ -4356,7 +4484,7 @@ unsigned int av_xiphlacing(unsigned char *s, unsigned int v); /** * Logs a generic warning message about a missing feature. This function is - * intended to be used internally by Libav (libavcodec, libavformat, etc.) + * intended to be used internally by FFmpeg (libavcodec, libavformat, etc.) * only, and would normally not be used by applications. * @param[in] avc a pointer to an arbitrary struct of which the first field is * a pointer to an AVClass struct @@ -4370,7 +4498,7 @@ void av_log_missing_feature(void *avc, const char *feature, int want_sample); /** * Log a generic warning message asking for a sample. This function is - * intended to be used internally by Libav (libavcodec, libavformat, etc.) + * intended to be used internally by FFmpeg (libavcodec, libavformat, etc.) * only, and would normally not be used by applications. * @param[in] avc a pointer to an arbitrary struct of which the first field is * a pointer to an AVClass struct @@ -4407,7 +4535,7 @@ enum AVLockOp { * lockmgr should store/get a pointer to a user allocated mutex. It's * NULL upon AV_LOCK_CREATE and != NULL for all other ops. * - * @param cb User defined callback. Note: Libav may invoke calls to this + * @param cb User defined callback. Note: FFmpeg may invoke calls to this * callback during the call to av_lockmgr_register(). * Thus, the application must be prepared to handle that. * If cb is set to NULL the lockmgr will be unregistered. |