diff -urN faad2-2.11.1-orig/frontend/main.c faad2-2.11.1/frontend/main.c
--- faad2-2.11.1-orig/frontend/main.c	2023-11-14 16:20:12 +0900
+++ faad2-2.11.1/frontend/main.c	2023-12-01 12:55:42 +0900
@@ -428,6 +428,7 @@
     faad_fprintf(stdout, " -d    Down matrix 5.1 to 2 channels\n");
     faad_fprintf(stdout, " -w    Write output to stdio instead of a file.\n");
     faad_fprintf(stdout, " -g    Disable gapless decoding.\n");
+    faad_fprintf(stdout, " -m    Mask decoding errors by repeating the previous block.\n");
     faad_fprintf(stdout, " -q    Quiet - suppresses status messages.\n");
     faad_fprintf(stdout, " -j X  Jump - start output X seconds into track (MP4 files only).\n");
     faad_fprintf(stdout, "Example:\n");
@@ -441,7 +442,7 @@
 
 static int decodeAACfile(char *aacfile, char *sndfile, char *adts_fn, int to_stdout,
                   int def_srate, unsigned char object_type, unsigned char outputFormat, int fileType,
-                  unsigned char downMatrix, int infoOnly, int adts_out, unsigned char old_format,
+                  unsigned char downMatrix, int maskErrors, int infoOnly, int adts_out, unsigned char old_format,
                   float *song_length)
 {
     int tagsize;
@@ -449,6 +450,9 @@
     unsigned char channels;
     void *sample_buffer;
 
+    void *saved_sample_buffer = NULL;
+    unsigned long saved_sample_buffer_len = 0;
+
     audio_file *aufile = NULL;
 
     FILE *adtsFile = NULL;
@@ -697,6 +701,46 @@
         {
             faad_fprintf(stderr, "Error: %s\n",
                 NeAACDecGetErrorMessage(frameInfo.error));
+            if (maskErrors)
+            {
+                int found = 0;
+                sample_buffer = saved_sample_buffer;
+                /* Look for the next frame header. */
+                if (frameInfo.bytesconsumed == 0) {
+                    advance_buffer(&b, 1);
+                }
+                while (!found) {
+                    long i;
+                    fill_buffer(&b);
+                    if (b.bytes_into_buffer < 2) {
+                        advance_buffer(&b, b.bytes_into_buffer);
+                        break;
+                    }
+                    for (i = 0; i < b.bytes_into_buffer - 1; i++) {
+                        if (b.buffer[i] == 0xFF && b.buffer[i+1] == 0xF8) {
+                            found = 1;
+                            break;
+                        }
+                    }
+                    advance_buffer(&b, i);
+                }
+            }
+        } else if (maskErrors) {
+            int bits_per_sample = (outputFormat == 1 ? 16 :
+                                   outputFormat == 2 ? 24 :
+                                   outputFormat == 5 ? 64 : 32);
+            unsigned long buffer_size = frameInfo.samples * bits_per_sample / 8;
+            if (saved_sample_buffer_len < frameInfo.samples)
+            {
+                free(saved_sample_buffer);
+                saved_sample_buffer = malloc(buffer_size);
+                if (saved_sample_buffer)
+                    saved_sample_buffer_len = frameInfo.samples;
+                else
+                    saved_sample_buffer_len = 0;
+            }
+            if (saved_sample_buffer)
+                memcpy(saved_sample_buffer, sample_buffer, buffer_size);
         }
 
         /* open the sound file now that the number of channels are known */
@@ -772,6 +816,9 @@
     if (b.buffer)
         free(b.buffer);
 
+    if (saved_sample_buffer)
+        free(saved_sample_buffer);
+
     return frameInfo.error;
 }
 
@@ -1032,6 +1079,7 @@
     int showHelp = 0;
     int mp4file = 0;
     int noGapless = 0;
+    int maskErrors = 0;
     char *fnp;
     char *aacFileName = NULL;
     char *audioFileName = NULL;
@@ -1074,10 +1122,11 @@
             { "stdio",      0, 0, 'g' },
             { "seek",       1, 0, 'j' },
             { "help",       0, 0, 'h' },
+            { "maskerrors", 0, 0, 'm' },
             { 0, 0, 0, 0 }
         };
 
-        c = getopt_long(argc, argv, "o:a:s:f:b:l:j:wgdhitq",
+        c = getopt_long(argc, argv, "o:a:s:f:b:l:j:wgdhitqm",
             long_options, &option_index);
 
         if (c == -1)
@@ -1190,6 +1239,9 @@
         case 'g':
             noGapless = 1;
             break;
+        case 'm':
+            maskErrors = 1;
+            break;
         case 'i':
             infoOnly = 1;
             break;
@@ -1331,8 +1383,8 @@
     }
 
         result = decodeAACfile(aacFileName, audioFileName, adtsFileName, writeToStdio,
-            def_srate, object_type, outputFormat, format, downMatrix, infoOnly, adts_out,
-            old_format, &length);
+            def_srate, object_type, outputFormat, format, downMatrix, maskErrors,
+            infoOnly, adts_out, old_format, &length);
     }
 
     if (audioFileName != NULL)
