aboutsummaryrefslogtreecommitdiffstats
path: root/libavcodec
diff options
context:
space:
mode:
authorMatthew Einhorn <moiein2000@gmail.com>2011-08-21 13:18:30 -0400
committerMichael Niedermayer <michaelni@gmx.at>2011-08-21 20:33:02 +0200
commit27667d28a67c59e83c90722360c7b440762b90bb (patch)
treef64fddd534ad8ebbf986c939ce812d3390b176f6 /libavcodec
parent18de79692c1d8a5577fda16261a217f6d21dd867 (diff)
downloadffmpeg-27667d28a67c59e83c90722360c7b440762b90bb.tar.gz
Updates avcodec_get_pix_fmt_loss to return maximum loss for an invalid destination pixel format.
Signed-off-by: Matthew Einhorn <moiein2000@gmail.com> Signed-off-by: Michael Niedermayer <michaelni@gmx.at>
Diffstat (limited to 'libavcodec')
-rw-r--r--libavcodec/avcodec.h3
-rw-r--r--libavcodec/imgconvert.c3
2 files changed, 5 insertions, 1 deletions
diff --git a/libavcodec/avcodec.h b/libavcodec/avcodec.h
index b1773a340c..2617f65ccc 100644
--- a/libavcodec/avcodec.h
+++ b/libavcodec/avcodec.h
@@ -3484,7 +3484,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);
diff --git a/libavcodec/imgconvert.c b/libavcodec/imgconvert.c
index 071d3122c9..e411b797e0 100644
--- a/libavcodec/imgconvert.c
+++ b/libavcodec/imgconvert.c
@@ -359,6 +359,9 @@ static int get_pix_fmt_depth(int *min, int *max, enum PixelFormat pix_fmt)
int avcodec_get_pix_fmt_loss(enum PixelFormat dst_pix_fmt, enum PixelFormat src_pix_fmt,
int has_alpha)
{
+ if (dst_pix_fmt>=PIX_FMT_NB || dst_pix_fmt<=PIX_FMT_NONE)
+ return ~0;
+
const PixFmtInfo *pf, *ps;
const AVPixFmtDescriptor *src_desc = &av_pix_fmt_descriptors[src_pix_fmt];
const AVPixFmtDescriptor *dst_desc = &av_pix_fmt_descriptors[dst_pix_fmt];