diff --git a/libavformat/dv.c b/libavformat/dv.c
index 0de099620b062e085bdc874a0b81187b794db4d0..bda7d94a9da1a2ee05b22a5842b13183507acde3 100644
--- a/libavformat/dv.c
+++ b/libavformat/dv.c
@@ -391,12 +391,16 @@ static void dv_format_frame(DVMuxContext *c, uint8_t* buf)
 
 static void dv_inject_audio(DVMuxContext *c, const uint8_t* pcm, uint8_t* frame_ptr)
 {
-    int i, j, d, of;
+    int i, j, d, of, size;
+    size = 4 * dv_audio_frame_size(c->sys, c->frames);
     for (i = 0; i < c->sys->difseg_size; i++) {
        frame_ptr += 6 * 80; /* skip DIF segment header */
        for (j = 0; j < 9; j++) {
           for (d = 8; d < 80; d+=2) {
 	     of = c->sys->audio_shuffle[i][j] + (d - 8)/2 * c->sys->audio_stride;
+	     if (of*2 >= size)
+	         continue;
+	     
 	     frame_ptr[d] = pcm[of*2+1]; // FIXME: may be we have to admit
 	     frame_ptr[d+1] = pcm[of*2]; //        that DV is a big endian PCM       
           }
diff --git a/tests/libav.regression.ref b/tests/libav.regression.ref
index 830df4e9b2312040cf8e3e1c9e37da2a34ed7650..3c6a6d6a8724a95da21b9953fcb2234e232bb52c 100644
--- a/tests/libav.regression.ref
+++ b/tests/libav.regression.ref
@@ -25,6 +25,9 @@ b57e3c4e0f27cbd0bf7b7fafb142fe7f *./data/b-libav.ffm
 fea20ced22451312dd463110e594eda6 *./data/b-libav.nut
 332415 ./data/b-libav.nut
 ./data/b-libav.nut CRC=001a3415
+b28918de1199e60a7ac235eefacb7d3b *./data/b-libav.dv
+3600000 ./data/b-libav.dv
+./data/b-libav.dv CRC=03701687
 9a9da315747599f7718cc9a9a09c21ff *./data/b-libav.pbm
 317075 ./data/b-libav.pbm
 ./data/b-libav.pbm CRC=a1057fd1
diff --git a/tests/regression.sh b/tests/regression.sh
index 8ad96dcc41d66ef3f1e0e4f7d9245b177435789e..ee42d282adb5d79c572ce8b2d2a71c6020f16722 100755
--- a/tests/regression.sh
+++ b/tests/regression.sh
@@ -516,9 +516,9 @@ do_ffmpeg $file -t 1 -y -qscale 10 -f pgmyuv -i $raw_src -f s16le -i $pcm_src -a
 do_ffmpeg_crc $file -i $file
 
 # dv
-#file=${outfile}libav.dv
-#do_ffmpeg $file -t 1 -y -qscale 10 -f pgmyuv -i $raw_src -f s16le -i $pcm_src -ar 48000 -r 25 -s pal -ac 2 $file
-#do_ffmpeg_crc $file -i $file
+file=${outfile}libav.dv
+do_ffmpeg $file -t 1 -y -qscale 10 -f pgmyuv -i $raw_src -f s16le -i $pcm_src -ar 48000 -r 25 -s pal -ac 2 $file
+do_ffmpeg_crc $file -i $file
 
 # XXX: need mpegts tests (add bitstreams or add output capability in ffmpeg)