summaryrefslogtreecommitdiff
path: root/libavcodec/apiexample.c
diff options
context:
space:
mode:
authorMichael Niedermayer <michaelni@gmx.at>2003-08-01 11:01:05 +0000
committerMichael Niedermayer <michaelni@gmx.at>2003-08-01 11:01:05 +0000
commit6a686d58b4e2ea0ec0e92cdd34afe766022d2f27 (patch)
treebbe5317eb7b95f781fe345b5ae00a1f6329cf9f0 /libavcodec/apiexample.c
parentffba1dc02b3c808dcf023351a0ed5dcca3fc1513 (diff)
FF_INPUT_BUFFER_PADDING_SIZE
Originally committed as revision 2100 to svn://svn.ffmpeg.org/ffmpeg/trunk
Diffstat (limited to 'libavcodec/apiexample.c')
-rw-r--r--libavcodec/apiexample.c10
1 files changed, 8 insertions, 2 deletions
diff --git a/libavcodec/apiexample.c b/libavcodec/apiexample.c
index 94ec222cf3..10afd42686 100644
--- a/libavcodec/apiexample.c
+++ b/libavcodec/apiexample.c
@@ -98,9 +98,12 @@ void audio_decode_example(const char *outfilename, const char *filename)
int out_size, size, len;
FILE *f, *outfile;
uint8_t *outbuf;
- uint8_t inbuf[INBUF_SIZE], *inbuf_ptr;
+ uint8_t inbuf[INBUF_SIZE + FF_INPUT_BUFFER_PADDING_SIZE], *inbuf_ptr;
printf("Audio decoding\n");
+
+ /* set end of buffer to 0 (this ensures that no overreading happens for damaged mpeg streams) */
+ memset(inbuf + INBUF_SIZE, 0, FF_INPUT_BUFFER_PADDING_SIZE);
/* find the mpeg audio decoder */
codec = avcodec_find_decoder(CODEC_ID_MP2);
@@ -297,9 +300,12 @@ void video_decode_example(const char *outfilename, const char *filename)
int frame, size, got_picture, len;
FILE *f;
AVFrame *picture;
- uint8_t inbuf[INBUF_SIZE], *inbuf_ptr;
+ uint8_t inbuf[INBUF_SIZE + FF_INPUT_BUFFER_PADDING_SIZE], *inbuf_ptr;
char buf[1024];
+ /* set end of buffer to 0 (this ensures that no overreading happens for damaged mpeg streams) */
+ memset(inbuf + INBUF_SIZE, 0, FF_INPUT_BUFFER_PADDING_SIZE);
+
printf("Video decoding\n");
/* find the mpeg1 video decoder */