From 52aa127d05b31ac99fd3b8fe5670d57a63779be7 Mon Sep 17 00:00:00 2001 From: k-m_schindler Date: Thu, 24 May 2012 09:09:01 +0000 Subject: add missing avformat_find_stream_info, av_find_best_stream, avformat_open_input and PPAVCodec git-svn-id: svn://svn.code.sf.net/p/ultrastardx/svn/trunk@2887 b956fd51-792f-4845-bead-9b4dfca2ff2c --- src/lib/ffmpeg-0.10/avcodec.pas | 1 + src/lib/ffmpeg-0.10/avformat.pas | 6 +-- src/lib/ffmpeg-0.7/avcodec.pas | 1 + src/lib/ffmpeg-0.7/avformat.pas | 80 ++++++++++++++++++++++++++++++++++++++++ src/lib/ffmpeg-0.8/avcodec.pas | 1 + src/lib/ffmpeg-0.8/avformat.pas | 78 +++++++++++++++++++++++++++++++++++++++ 6 files changed, 164 insertions(+), 3 deletions(-) diff --git a/src/lib/ffmpeg-0.10/avcodec.pas b/src/lib/ffmpeg-0.10/avcodec.pas index cf4e9e8b..d1c42f31 100644 --- a/src/lib/ffmpeg-0.10/avcodec.pas +++ b/src/lib/ffmpeg-0.10/avcodec.pas @@ -1736,6 +1736,7 @@ type PAVClass = ^TAVClass; + PPAVCodec = ^PAVCodec; PAVCodec = ^TAVCodec; PAVHWAccel = ^TAVHWAccel; diff --git a/src/lib/ffmpeg-0.10/avformat.pas b/src/lib/ffmpeg-0.10/avformat.pas index 31d0777d..e5b1f42a 100644 --- a/src/lib/ffmpeg-0.10/avformat.pas +++ b/src/lib/ffmpeg-0.10/avformat.pas @@ -1716,7 +1716,7 @@ function av_open_input_file(var ic_ptr: PAVFormatContext; filename: PAnsiChar; * * @note If you want to use custom IO, preallocate the format context and set its pb field. *) -function avformat_open_input(ps: {PPAVFormatContext} pointer; {const} filename: PAnsiChar; fmt: PAVInputFormat; options: {PPAVDictionary} pointer): cint; +function avformat_open_input(ps: PPAVFormatContext; {const} filename: PAnsiChar; fmt: PAVInputFormat; options: PPAVDictionary): cint; cdecl; external av__format; function av_demuxer_open(ic: PAVFormatContext; ap: TAVFormatParameters): cint; @@ -1761,7 +1761,7 @@ function av_find_stream_info(ic: PAVFormatContext): cint; {deprecated} * @todo Let the user decide somehow what information is needed so that * we do not waste time getting stuff the user does not need. *) -function avformat_find_stream_info(ic: PAVFormatContext; options: {PPAVDictionary} pointer): cint; +function avformat_find_stream_info(ic: PAVFormatContext; options: PPAVDictionary): cint; cdecl; external av__format; (** @@ -1805,7 +1805,7 @@ function av_find_best_stream(ic: PAVFormatContext; type_: TAVMediaType; wanted_stream_nb: cint; related_stream: cint; - decoder_ret: {PPAVCodec} pointer; + decoder_ret: PPAVCodec; flags: cint): cint; cdecl; external av__format; diff --git a/src/lib/ffmpeg-0.7/avcodec.pas b/src/lib/ffmpeg-0.7/avcodec.pas index 369a8e79..307c3ae2 100644 --- a/src/lib/ffmpeg-0.7/avcodec.pas +++ b/src/lib/ffmpeg-0.7/avcodec.pas @@ -1544,6 +1544,7 @@ type PAVClass = ^TAVClass; + PPAVCodec = ^PAVCodec; PAVCodec = ^TAVCodec; PAVHWAccel = ^TAVHWAccel; diff --git a/src/lib/ffmpeg-0.7/avformat.pas b/src/lib/ffmpeg-0.7/avformat.pas index eaa826e2..99af7410 100644 --- a/src/lib/ffmpeg-0.7/avformat.pas +++ b/src/lib/ffmpeg-0.7/avformat.pas @@ -1241,6 +1241,28 @@ function av_open_input_file(var ic_ptr: PAVFormatContext; filename: PAnsiChar; ap: PAVFormatParameters): cint; cdecl; external av__format; +(** + * Open an input stream and read the header. The codecs are not opened. + * The stream must be closed with av_close_input_file(). + * + * @param ps Pointer to user-supplied AVFormatContext (allocated by avformat_alloc_context). + * May be a pointer to NULL, in which case an AVFormatContext is allocated by this + * function and written into ps. + * Note that a user-supplied AVFormatContext will be freed on failure. + * @param filename Name of the stream to open. + * @param fmt If non-NULL, this parameter forces a specific input format. + * Otherwise the format is autodetected. + * @param options A dictionary filled with AVFormatContext and demuxer-private options. + * On return this parameter will be destroyed and replaced with a dict containing + * options that were not found. May be NULL. + * + * @return 0 on success, a negative AVERROR on failure. + * + * @note If you want to use custom IO, preallocate the format context and set its pb field. + *) +function avformat_open_input(ps: PPAVFormatContext; {const} filename: PAnsiChar; fmt: PAVInputFormat; options: PPAVDictionary): cint; + cdecl; external av__format; + (** * Allocate an AVFormatContext. * Can be freed with av_free() but do not forget to free everything you @@ -1271,6 +1293,64 @@ function av_alloc_format_context(): PAVFormatContext; function av_find_stream_info(ic: PAVFormatContext): cint; cdecl; external av__format; +{$IF LIBAVFORMAT_VERSION >= 52111000} // 52.111.0 +(** + * Read packets of a media file to get stream information. This + * is useful for file formats with no headers such as MPEG. This + * function also computes the real framerate in case of MPEG-2 repeat + * frame mode. + * The logical file position is not changed by this function; + * examined packets may be buffered for later processing. + * + * @param ic media file handle + * @param options If non-NULL, an ic.nb_streams long array of pointers to + * dictionaries, where i-th member contains options for + * codec corresponding to i-th stream. + * On return each dictionary will be filled with options that were not found. + * @return >=0 if OK, AVERROR_xxx on error + * + * @note this function isn't guaranteed to open all the codecs, so + * options being non-empty at return is a perfectly normal behavior. + * + * @todo Let the user decide somehow what information is needed so that + * we do not waste time getting stuff the user does not need. + *) +function avformat_find_stream_info(ic: PAVFormatContext; options: PPAVDictionary): cint; + cdecl; external av__format; +{$IFEND} + +(** + * Find the "best" stream in the file. + * The best stream is determined according to various heuristics as the most + * likely to be what the user expects. + * If the decoder parameter is non-NULL, av_find_best_stream will find the + * default decoder for the stream's codec; streams for which no decoder can + * be found are ignored. + * + * @param ic media file handle + * @param type stream type: video, audio, subtitles, etc. + * @param wanted_stream_nb user-requested stream number, + * or -1 for automatic selection + * @param related_stream try to find a stream related (eg. in the same + * program) to this one, or -1 if none + * @param decoder_ret if non-NULL, returns the decoder for the + * selected stream + * @param flags flags; none are currently defined + * @return the non-negative stream number in case of success, + * AVERROR_STREAM_NOT_FOUND if no stream with the requested type + * could be found, + * AVERROR_DECODER_NOT_FOUND if streams were found but no decoder + * @note If av_find_best_stream returns successfully and decoder_ret is not + * NULL, then *decoder_ret is guaranteed to be set to a valid AVCodec. + *) +function av_find_best_stream(ic: PAVFormatContext; + type_: TAVMediaType; + wanted_stream_nb: cint; + related_stream: cint; + decoder_ret: PPAVCodec; + flags: cint): cint; + cdecl; external av__format; + (** * Read a transport packet from a media file. * diff --git a/src/lib/ffmpeg-0.8/avcodec.pas b/src/lib/ffmpeg-0.8/avcodec.pas index a8bae81f..56c6afb8 100644 --- a/src/lib/ffmpeg-0.8/avcodec.pas +++ b/src/lib/ffmpeg-0.8/avcodec.pas @@ -1515,6 +1515,7 @@ type PAVClass = ^TAVClass; + PPAVCodec = ^PAVCodec; PAVCodec = ^TAVCodec; PAVHWAccel = ^TAVHWAccel; diff --git a/src/lib/ffmpeg-0.8/avformat.pas b/src/lib/ffmpeg-0.8/avformat.pas index 138ab20f..f119c784 100644 --- a/src/lib/ffmpeg-0.8/avformat.pas +++ b/src/lib/ffmpeg-0.8/avformat.pas @@ -1143,6 +1143,28 @@ function av_open_input_file(var ic_ptr: PAVFormatContext; filename: PAnsiChar; ap: PAVFormatParameters): cint; cdecl; external av__format; +(** + * Open an input stream and read the header. The codecs are not opened. + * The stream must be closed with av_close_input_file(). + * + * @param ps Pointer to user-supplied AVFormatContext (allocated by avformat_alloc_context). + * May be a pointer to NULL, in which case an AVFormatContext is allocated by this + * function and written into ps. + * Note that a user-supplied AVFormatContext will be freed on failure. + * @param filename Name of the stream to open. + * @param fmt If non-NULL, this parameter forces a specific input format. + * Otherwise the format is autodetected. + * @param options A dictionary filled with AVFormatContext and demuxer-private options. + * On return this parameter will be destroyed and replaced with a dict containing + * options that were not found. May be NULL. + * + * @return 0 on success, a negative AVERROR on failure. + * + * @note If you want to use custom IO, preallocate the format context and set its pb field. + *) +function avformat_open_input(ps: PPAVFormatContext; {const} filename: PAnsiChar; fmt: PAVInputFormat; options: PPAVDictionary): cint; + cdecl; external av__format; + (** * Allocate an AVFormatContext. * Can be freed with av_free() but do not forget to free everything you @@ -1167,6 +1189,62 @@ function avformat_alloc_context(): PAVFormatContext; function av_find_stream_info(ic: PAVFormatContext): cint; cdecl; external av__format; +(** + * Read packets of a media file to get stream information. This + * is useful for file formats with no headers such as MPEG. This + * function also computes the real framerate in case of MPEG-2 repeat + * frame mode. + * The logical file position is not changed by this function; + * examined packets may be buffered for later processing. + * + * @param ic media file handle + * @param options If non-NULL, an ic.nb_streams long array of pointers to + * dictionaries, where i-th member contains options for + * codec corresponding to i-th stream. + * On return each dictionary will be filled with options that were not found. + * @return >=0 if OK, AVERROR_xxx on error + * + * @note this function isn't guaranteed to open all the codecs, so + * options being non-empty at return is a perfectly normal behavior. + * + * @todo Let the user decide somehow what information is needed so that + * we do not waste time getting stuff the user does not need. + *) +function avformat_find_stream_info(ic: PAVFormatContext; options: PPAVDictionary): cint; + cdecl; external av__format; + +(** + * Find the "best" stream in the file. + * The best stream is determined according to various heuristics as the most + * likely to be what the user expects. + * If the decoder parameter is non-NULL, av_find_best_stream will find the + * default decoder for the stream's codec; streams for which no decoder can + * be found are ignored. + * + * @param ic media file handle + * @param type stream type: video, audio, subtitles, etc. + * @param wanted_stream_nb user-requested stream number, + * or -1 for automatic selection + * @param related_stream try to find a stream related (eg. in the same + * program) to this one, or -1 if none + * @param decoder_ret if non-NULL, returns the decoder for the + * selected stream + * @param flags flags; none are currently defined + * @return the non-negative stream number in case of success, + * AVERROR_STREAM_NOT_FOUND if no stream with the requested type + * could be found, + * AVERROR_DECODER_NOT_FOUND if streams were found but no decoder + * @note If av_find_best_stream returns successfully and decoder_ret is not + * NULL, then *decoder_ret is guaranteed to be set to a valid AVCodec. + *) +function av_find_best_stream(ic: PAVFormatContext; + type_: TAVMediaType; + wanted_stream_nb: cint; + related_stream: cint; + decoder_ret: PPAVCodec; + flags: cint): cint; + cdecl; external av__format; + (** * Read a transport packet from a media file. * -- cgit v1.2.3