[FFmpeg-devel] [PATCH]Accept 0 as codec_tag in ffmpeg.c if it matches the codec_id
Michael Niedermayer
michaelni at gmx.at
Thu Jan 17 16:32:16 CET 2013
On Tue, Dec 11, 2012 at 12:19:14PM +0100, Carl Eugen Hoyos wrote:
> On Tuesday 11 December 2012 12:47:12 am Michael Niedermayer wrote:
> > On Sun, Dec 09, 2012 at 02:47:34PM +0100, Carl Eugen Hoyos wrote:
> > > On Saturday 08 December 2012 03:02:39 am Michael Niedermayer wrote:
> > > > On Fri, Dec 07, 2012 at 01:15:21PM +0100, Carl Eugen Hoyos wrote:
> > > > > Hi!
> > > > >
> > > > > Attached patch fixes ticket #1953 for me.
> > > > >
> > > > > I suspect the actual problem is that av_codec_get_tag() returns 0
> > > > > both in case of failure and success, but that seems difficult to fix
> > > > > without breaking API.
> > > >
> > > > i think we should add a new function that is free of this ambiguity
> > >
> > > New patch attached.
> > >
> > > Please review, Carl Eugen
> >
> > breaks fate also some of the changes from the old tp the new function
> > look wrong. I dont think all the == 0 checks meant failure some
> > actually meant the 0 tag
>
> New patch attached that fixes both fate failures (that had different reasons).
>
> Please review, Carl Eugen
> ffmpeg.c | 3 ++-
> libavformat/avformat.h | 16 +++++++++++++++-
> libavformat/mux.c | 12 ++++++++----
> libavformat/segment.c | 3 ++-
> libavformat/utils.c | 22 +++++++++++++++++++---
> libavformat/version.h | 4 ++--
these changes are unrelated
addition of the function (without attribute_deprecated so as not to
generate warnings as long as it still used) and switching
other places (1 per patch) should be seperate.
> 6 files changed, 48 insertions(+), 12 deletions(-)
> 8ae0b0a807b302ce3d3d7218f9f289eaf47a36b6 patchgetcodectag3.diff
> diff --git a/ffmpeg.c b/ffmpeg.c
> index 4b278a2..c966a8a 100644
> --- a/ffmpeg.c
> +++ b/ffmpeg.c
> @@ -2033,9 +2033,10 @@ static int transcode_init(void)
> codec->codec_type = icodec->codec_type;
>
> if (!codec->codec_tag) {
> + unsigned int codec_tag;
> if (!oc->oformat->codec_tag ||
> av_codec_get_id (oc->oformat->codec_tag, icodec->codec_tag) == codec->codec_id ||
> - av_codec_get_tag(oc->oformat->codec_tag, icodec->codec_id) <= 0)
> + !av_codec_get_tag2(oc->oformat->codec_tag, icodec->codec_id, &codec_tag))
> codec->codec_tag = icodec->codec_tag;
> }
>
> diff --git a/libavformat/avformat.h b/libavformat/avformat.h
> index 7500881..f476056 100644
> --- a/libavformat/avformat.h
> +++ b/libavformat/avformat.h
> @@ -1893,8 +1893,22 @@ enum AVCodecID av_codec_get_id(const struct AVCodecTag * const *tags, unsigned i
> *
> * @param tags list of supported codec_id-codec_tag pairs, as stored
> * in AVInputFormat.codec_tag and AVOutputFormat.codec_tag
> + *
> + * @deprecated deprecated in favor of av_codec_get_tag2
> + */
> +attribute_deprecated unsigned int av_codec_get_tag(const struct AVCodecTag * const *tags, enum AVCodecID id);
> +
> +/**
> + * Get the codec tag for the given codec id.
> + *
> + * @param tags list of supported codec_id - codec_tag pairs, as stored
> + * in AVInputFormat.codec_tag and AVOutputFormat.codec_tag
> + * @param id codec id that should be searched for in the list
> + * @param tag A pointer to the found tag
> + * @return 0 if id was not found in tags, != 0 if it was found
errors are <0 non errors are >= 0
[...]
--
Michael GnuPG fingerprint: 9FF2128B147EF6730BADF133611EC787040B0FAB
Breaking DRM is a little like attempting to break through a door even
though the window is wide open and the only thing in the house is a bunch
of things you dont want and which you would get tomorrow for free anyway
-------------- next part --------------
A non-text attachment was scrubbed...
Name: not available
Type: application/pgp-signature
Size: 198 bytes
Desc: Digital signature
URL: <http://ffmpeg.org/pipermail/ffmpeg-devel/attachments/20130117/3368c488/attachment.asc>
More information about the ffmpeg-devel
mailing list