diff --git a/libavcodec/ac3dec.c b/libavcodec/ac3dec.c
index 4ac3ea5cf1305d5d0c7c192ae23f392b7709c857..2cd07c3534b4e013b59d34532ed5b790cd20088b 100644
--- a/libavcodec/ac3dec.c
+++ b/libavcodec/ac3dec.c
@@ -1433,6 +1433,8 @@ static int ac3_decode_frame(AVCodecContext * avctx, void *data,
         }
     }
 
+    s->frame.decode_error_flags = err ? FF_DECODE_ERROR_INVALID_BITSTREAM : 0;
+
     *got_frame_ptr   = 1;
     *(AVFrame *)data = s->frame;