[FFmpeg-devel] [PATCH] Move av_open_input_file probe loop to its own method

Michael Niedermayer michaelni
Fri Mar 5 12:44:46 CET 2010


On Thu, Mar 04, 2010 at 10:23:57PM -0500, Micah F. Galizia wrote:
> Greetings,
>
> In an effort to add a SHOUTcast demuxer (which needs to probe data offset 
> within a stream and restrict the probe buffer size) I have moved the probe 
> loop from av_open_input_file into its own method so that it can be reused.  
> Here are a few differences to the original way things were probed:
>
> - maximum probe buffer size can be specified as a parameter.
>
> - offset within the stream to probe from can be specified as a parameter.
>
> - instead of seeking back to the start each time a probe fails, stream data 
> is appenended to the reallocated buffer.  This lowers the amount of data 
> read from the stream (there is no repetition) and results in fewer closed 
> and reopened streams (when seeking fails).
>
> Thanks in advance, and I look forward to your scathing code reviews :)
[...]
> +        pd.buf_size += get_buffer(*pb, buf + buf_offset, probe_size - buf_offset);
> +        pd.buf = &buf[offset];
> +
> +        if ((int)pd.buf_size < 0) {
> +            av_free(buf);
> +            return pd.buf_size;
> +        }

previous_size + error code < 0 doesnt look good


[...]
> Index: libavformat/avformat.h
> ===================================================================
> --- libavformat/avformat.h	(revision 22211)
> +++ libavformat/avformat.h	(working copy)
> @@ -872,7 +872,23 @@
>   */
>  AVInputFormat *av_probe_input_format(AVProbeData *pd, int is_opened);
>  
> +
>  /**
> + * Probe a Bytestream to determine the input format.
> + *
> + * @param pb The bytestream to probe. It may be closed and opened again.
> + * @param fmt The input format is put here.
> + * @param filename The filename of the stream.
> + * @param logctx The log context
> + * @param offset The offset within the bytestream to probe from.
> + * @param max_probe_size The maximum probe buffer size.
> + * @return 0 if OK, AVERROR_xxx otherwise
> + */
> +int av_probe_input_buffer(ByteIOContext **pb, AVInputFormat **fmt,

do we need this as public function?
if not it should have a ff_ prefix and be in internal.h

[...]
-- 
Michael     GnuPG fingerprint: 9FF2128B147EF6730BADF133611EC787040B0FAB

When you are offended at any man's fault, turn to yourself and study your
own failings. Then you will forget your anger. -- Epictetus
-------------- next part --------------
A non-text attachment was scrubbed...
Name: not available
Type: application/pgp-signature
Size: 189 bytes
Desc: Digital signature
URL: <http://lists.mplayerhq.hu/pipermail/ffmpeg-devel/attachments/20100305/f6c1d2d2/attachment.pgp>



More information about the ffmpeg-devel mailing list