[FFmpeg-devel] [PATCH] Document that the MPEG12 "fast" functions can read out of bounds.

Reimar Döffinger Reimar.Doeffinger at gmx.de
Sat Sep 15 18:23:38 CEST 2012


This is intentional (and a reason why fast usually should not be used),
but a few people sent patches to "fix" this recently so it would be
better to document this.

Signed-off-by: Reimar Döffinger <Reimar.Doeffinger at gmx.de>
---
 libavcodec/mpeg12.c |   15 +++++++++++++++
 1 file changed, 15 insertions(+)

diff --git a/libavcodec/mpeg12.c b/libavcodec/mpeg12.c
index 1bf857e..1e7ff9c 100644
--- a/libavcodec/mpeg12.c
+++ b/libavcodec/mpeg12.c
@@ -232,6 +232,11 @@ end:
     return 0;
 }
 
+/**
+ * Note: this function can read out of range and crash for corrupt streams.
+ * Changing this would eat up any speed benefits it has.
+ * Do not use "fast" flag if you need the code to be robust.
+ */
 static inline int mpeg1_fast_decode_block_inter(MpegEncContext *s, DCTELEM *block, int n)
 {
     int level, i, j, run;
@@ -383,6 +388,11 @@ end:
     return 0;
 }
 
+/**
+ * Note: this function can read out of range and crash for corrupt streams.
+ * Changing this would eat up any speed benefits it has.
+ * Do not use "fast" flag if you need the code to be robust.
+ */
 static inline int mpeg2_fast_decode_block_non_intra(MpegEncContext *s,
                                                     DCTELEM *block, int n)
 {
@@ -523,6 +533,11 @@ static inline int mpeg2_decode_block_intra(MpegEncContext *s, DCTELEM *block, in
     return 0;
 }
 
+/**
+ * Note: this function can read out of range and crash for corrupt streams.
+ * Changing this would eat up any speed benefits it has.
+ * Do not use "fast" flag if you need the code to be robust.
+ */
 static inline int mpeg2_fast_decode_block_intra(MpegEncContext *s, DCTELEM *block, int n)
 {
     int level, dc, diff, j, run;
-- 
1.7.10.4



More information about the ffmpeg-devel mailing list