[FFmpeg-devel] [PATCH] check sample_fmt in avcodec_open
Michael Niedermayer
michaelni
Sun Jan 2 04:40:48 CET 2011
On Sat, Jan 01, 2011 at 08:50:35PM +0100, Reimar D?ffinger wrote:
> Hello,
> this fixes an inconsistency (most codecs do not check the sample_fmt)
> and also allows to remove the check in flacenc.c.
> I am however not sure if such a check is correct: IIRC sample_fmt field
> was an API addition so this would actually break applications like
> mencoder that did not set this at all (they worked fone up to now for
> most codecs - the flac encoder was an exception).
> One possibility would be to detect avctx->sample_fmt ==
> AV_SAMPLE_FMT_NONE and override it to S16, at least until the next major
> bump.
> Either way, this one at least prints an error, flacenc just fails
> silently currently for that case.
> Index: libavcodec/utils.c
> ===================================================================
> --- libavcodec/utils.c (revision 26178)
> +++ libavcodec/utils.c (working copy)
> @@ -532,6 +532,16 @@
> avctx->codec->max_lowres);
> goto free_and_end;
> }
> + if (avctx->codec->sample_fmts) {
> + int i;
> + for (i = 0; avctx->codec->sample_fmts[i] != AV_SAMPLE_FMT_NONE; i++)
> + if (avctx->sample_fmt == avctx->codec->sample_fmts[i])
> + break;
> + if (avctx->codec->sample_fmts[i] == AV_SAMPLE_FMT_NONE) {
> + av_log(avctx, AV_LOG_ERROR, "Specified sample_fmt is not supported.\n");
> + goto free_and_end;
> + }
> + }
this seems missing a check for the codec being an encoder
[...]
--
Michael GnuPG fingerprint: 9FF2128B147EF6730BADF133611EC787040B0FAB
Those who are best at talking, realize last or never when they are wrong.
-------------- next part --------------
A non-text attachment was scrubbed...
Name: not available
Type: application/pgp-signature
Size: 198 bytes
Desc: Digital signature
URL: <http://lists.mplayerhq.hu/pipermail/ffmpeg-devel/attachments/20110102/9006a1a9/attachment.pgp>
More information about the ffmpeg-devel
mailing list