[FFmpeg-cvslog] Updates avcodec_get_pix_fmt_loss to return maximum loss for an invalid destination pixel format .

Matthew Einhorn git at videolan.org
Sun Aug 21 20:43:15 CEST 2011


ffmpeg | branch: master | Matthew Einhorn <moiein2000 at gmail.com> | Sun Aug 21 13:18:30 2011 -0400| [27667d28a67c59e83c90722360c7b440762b90bb] | committer: Michael Niedermayer

Updates avcodec_get_pix_fmt_loss to return maximum loss for an invalid destination pixel format.

Signed-off-by: Matthew Einhorn <moiein2000 at gmail.com>
Signed-off-by: Michael Niedermayer <michaelni at gmx.at>

> http://git.videolan.org/gitweb.cgi/ffmpeg.git/?a=commit;h=27667d28a67c59e83c90722360c7b440762b90bb
---

 libavcodec/avcodec.h    |    3 ++-
 libavcodec/imgconvert.c |    3 +++
 2 files changed, 5 insertions(+), 1 deletions(-)

diff --git a/libavcodec/avcodec.h b/libavcodec/avcodec.h
index b1773a3..2617f65 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 071d312..e411b79 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];



More information about the ffmpeg-cvslog mailing list