Other tools don't. Typically encoder input is primed, so there is no reason to drop decoded data.
Unified · Split
| @@ -111,19 +111,19 @@ audio_file *open_audio_file(char *infile, int samplerate, int channels, · 110 unmodified lines | ||
| 111 | 111 | return aufile; |
| 112 | 112 | } |
| 113 | 113 | |
| 114 | −int write_audio_file(audio_file *aufile, void *sample_buffer, int samples, int offset) | |
| 114 | +int write_audio_file(audio_file *aufile, void *sample_buffer, int samples) | |
| 115 | 115 | { |
| 116 | 116 | char *buf = (char *)sample_buffer; |
| 117 | 117 | switch (aufile->outputFormat) |
| 118 | 118 | { |
| 119 | 119 | case FAAD_FMT_16BIT: |
| 120 | − return write_audio_16bit(aufile, buf + offset*2, samples); | |
| 120 | + return write_audio_16bit(aufile, buf, samples); | |
| 121 | 121 | case FAAD_FMT_24BIT: |
| 122 | − return write_audio_24bit(aufile, buf + offset*4, samples); | |
| 122 | + return write_audio_24bit(aufile, buf, samples); | |
| 123 | 123 | case FAAD_FMT_32BIT: |
| 124 | − return write_audio_32bit(aufile, buf + offset*4, samples); | |
| 124 | + return write_audio_32bit(aufile, buf, samples); | |
| 125 | 125 | case FAAD_FMT_FLOAT: |
| 126 | − return write_audio_float(aufile, buf + offset*4, samples); | |
| 126 | + return write_audio_float(aufile, buf, samples); | |
| 127 | 127 | default: |
| 128 | 128 | return 0; |
| 129 | 129 | } |
| @@ -55,7 +55,7 @@ typedef struct · 54 unmodified lines | ||
| 55 | 55 | |
| 56 | 56 | audio_file *open_audio_file(char *infile, int samplerate, int channels, |
| 57 | 57 | int outputFormat, int fileType, long channelMask); |
| 58 | −int write_audio_file(audio_file *aufile, void *sample_buffer, int samples, int offset); | |
| 58 | +int write_audio_file(audio_file *aufile, void *sample_buffer, int samples); | |
| 59 | 59 | void close_audio_file(audio_file *aufile); |
| 60 | 60 | |
| 61 | 61 | #ifdef __cplusplus |
| @@ -666,6 +666,9 @@ static int decodeAACfile(char *aacfile, char *sndfile, char *adts_fn, int to_std · 665 unmodified lines | ||
| 666 | 666 | break; |
| 667 | 667 | } |
| 668 | 668 | |
| 669 | + // Override the logic of skipping 0-th output frame. | |
| 670 | + NeAACDecPostSeekReset(hDecoder, 1); | |
| 671 | + | |
| 669 | 672 | if (infoOnly) |
| 670 | 673 | { |
| 671 | 674 | NeAACDecClose(hDecoder); |
| @@ -754,7 +757,7 @@ static int decodeAACfile(char *aacfile, char *sndfile, char *adts_fn, int to_std · 82 unmodified lines | ||
| 754 | 757 | |
| 755 | 758 | if ((frameInfo.error == 0) && (frameInfo.samples > 0) && (!adts_out)) |
| 756 | 759 | { |
| 757 | − if (write_audio_file(aufile, sample_buffer, frameInfo.samples, 0) == 0) | |
| 760 | + if (write_audio_file(aufile, sample_buffer, frameInfo.samples) == 0) | |
| 758 | 761 | break; |
| 759 | 762 | } |
| 760 | 763 | |
| @@ -907,7 +910,6 @@ static int decodeMP4file(char *mp4file, char *sndfile, char *adts_fn, int to_std · 146 unmodified lines | ||
| 907 | 910 | /*int rc;*/ |
| 908 | 911 | long dur; |
| 909 | 912 | unsigned int sample_count; |
| 910 | − unsigned int delay = 0; | |
| 911 | 913 | |
| 912 | 914 | if (mp4read_frame()) |
| 913 | 915 | break; |
| @@ -997,7 +999,7 @@ static int decodeMP4file(char *mp4file, char *sndfile, char *adts_fn, int to_std · 83 unmodified lines | ||
| 997 | 999 | |
| 998 | 1000 | if ((frameInfo.error == 0) && (sample_count > 0) && (!adts_out)) |
| 999 | 1001 | { |
| 1000 | − if (write_audio_file(aufile, sample_buffer, sample_count, delay) == 0) | |
| 1002 | + if (write_audio_file(aufile, sample_buffer, sample_count) == 0) | |
| 1001 | 1003 | break; |
| 1002 | 1004 | } |
| 1003 | 1005 | |
| @@ -1154,6 +1156,8 @@ static int faad_main(int argc, char *argv[]) · 150 unmodified lines | ||
| 1154 | 1156 | outputFormat = atoi(dr); |
| 1155 | 1157 | if ((outputFormat < 1) || (outputFormat > 5)) |
| 1156 | 1158 | showHelp = 1; |
| 1159 | + if (outputFormat == 5) // Not yet unsupported by "audio". | |
| 1160 | + showHelp = 1; | |
| 1157 | 1161 | } |
| 1158 | 1162 | } |
| 1159 | 1163 | break; |