Opened 11 years ago

Closed 11 years ago

#2552 closed defect (fixed)

FLAC with wrong but valid 'header' makes decoder misbehave

Reported by: Martijn van Beurden Owned by:
Priority: important Component: avcodec
Version: git-master Keywords: flac regression
Cc: Blocked By:
Blocking: Reproduced by developer: yes
Analyzed by developer: no

Description

Summary of the bug: I found a file where libavcodec thinks the file is 8kHz, 3 channel while the file is 44.1kHz and stereo. With ghex I found out this is probably because there is a valid header (CRC checks out) somewhere halfway a block. While this is only one header versus 11 valid ones, libavcodec thinks this one is valid and the rest is garbage.

How to reproduce:

  1. Get flac-file-with-valid-header-in-last-block.flac from upload.ffmpeg.org/incoming
  2. Try 'ffmpeg -i flac-file-with-valid-header-in-last-block.flac test.wav' and see that the resulting file is 8kHz, 3-channel

Output:

ffmpeg -loglevel 99 -i flac-file-with-valid-header-in-last-block.flac -f null /dev/null
ffmpeg version N-52792-g7c23922 Copyright (c) 2000-2013 the FFmpeg developers
  built on May  5 2013 22:10:53 with gcc 4.7 (Ubuntu/Linaro 4.7.2-2ubuntu1)
  configuration: --enable-libx264 --enable-libtheora --enable-libvorbis --enable-libmp3lame --enable-gpl
  libavutil      52. 29.100 / 52. 29.100
  libavcodec     55.  7.100 / 55.  7.100
  libavformat    55.  4.101 / 55.  4.101
  libavdevice    55.  0.100 / 55.  0.100
  libavfilter     3. 63.101 /  3. 63.101
  libswscale      2.  2.100 /  2.  2.100
  libswresample   0. 17.102 /  0. 17.102
  libpostproc    52.  3.100 / 52.  3.100
Splitting the commandline.
Reading option '-loglevel' ... matched as option 'loglevel' (set logging level) with argument '99'.                                                                                                           
Reading option '-i' ... matched as input file with argument 'flac-file-with-valid-header-in-last-block.flac'.                                                                                                 
Reading option '-f' ... matched as option 'f' (force format) with argument 'null'.                                                                                                                            
Reading option '/dev/null' ... matched as output file.                                                                                                                                                        
Finished splitting the commandline.                                                                                                                                                                           
Parsing a group of options: global .                                                                                                                                                                          
Applying option loglevel (set logging level) with argument 99.                                                                                                                                                
Successfully parsed a group of options.                                                                                                                                                                       
Parsing a group of options: input file flac-file-with-valid-header-in-last-block.flac.                                                                                                                        
Successfully parsed a group of options.                                                                                                                                                                       
Opening an input file: flac-file-with-valid-header-in-last-block.flac.                                                                                                                                        
[flac @ 0x1e997c0] Format flac probed with size=2048 and score=50                                                                                                                                             
[flac @ 0x1e997c0] File position before avformat_find_stream_info() is 8304                                                                                                                                   
[flac @ 0x1e9a1e0] sample rate change detected in adjacent frames                                                                                                                                             
[flac @ 0x1e9a1e0] bits per sample change detected in adjacent frames                                                                                                                                         
[flac @ 0x1e9a1e0] number of channels change detected in adjacent frames                                                                                                                                      
[flac @ 0x1e9a1e0] sample/frame number mismatch in adjacent frames                                                                                                                                            
[flac @ 0x1e9a1e0] crc check failed from offset 518995 (frame 8) to 567270 (frame 65)                                                                                                                         
[flac @ 0x1e9a1e0] sample rate change detected in adjacent frames                                                                                                                                             
[flac @ 0x1e9a1e0] bits per sample change detected in adjacent frames                                                                                                                                         
[flac @ 0x1e9a1e0] number of channels change detected in adjacent frames                                                                                                                                      
[flac @ 0x1e9a1e0] sample/frame number mismatch in adjacent frames                                                                                                                                            
[flac @ 0x1e9a1e0] crc check failed from offset 443570 (frame 7) to 567270 (frame 65)                                                                                                                         
[flac @ 0x1e9a1e0] sample/frame number mismatch in adjacent frames                                                                                                                                            
[flac @ 0x1e9a1e0] sample rate change detected in adjacent frames                                                                                                                                             
[flac @ 0x1e9a1e0] bits per sample change detected in adjacent frames                                                                                                                                         
[flac @ 0x1e9a1e0] number of channels change detected in adjacent frames                                                                                                                                      
[flac @ 0x1e9a1e0] sample/frame number mismatch in adjacent frames                                                                                                                                            
[flac @ 0x1e9a1e0] crc check failed from offset 371506 (frame 6) to 567270 (frame 65)                                                                                                                         
[flac @ 0x1e9a1e0] sample/frame number mismatch in adjacent frames                                                                                                                                            
    Last message repeated 11 times
[flac @ 0x1e9a1e0] Junk frame till offset 48275
[flac @ 0x1e997c0] max_analyze_duration 5000000 reached at 5062721 microseconds
[flac @ 0x1e997c0] File position after avformat_find_stream_info() is 579223
Input #0, flac, from 'flac-file-with-valid-header-in-last-block.flac':
  Duration: 00:00:07.40, bitrate: 626 kb/s
    Stream #0:0, 8, 1/44100: Audio: flac, 8000 Hz, 3.0, s16
Successfully opened the file.
Parsing a group of options: output file /dev/null.                                                                                                                                                            
Applying option f (force format) with argument null.                                                                                                                                                          
Successfully parsed a group of options.
Opening an output file: /dev/null.
Successfully opened the file.
[graph 0 input from stream 0:0 @ 0x1e9a6e0] Setting 'time_base' to value '1/8000'
[graph 0 input from stream 0:0 @ 0x1e9a6e0] Setting 'sample_rate' to value '8000'
[graph 0 input from stream 0:0 @ 0x1e9a6e0] Setting 'sample_fmt' to value 's16'
[graph 0 input from stream 0:0 @ 0x1e9a6e0] Setting 'channel_layout' to value '0x7'
[graph 0 input from stream 0:0 @ 0x1e9a6e0] tb:1/8000 samplefmt:s16 samplerate:8000 chlayout:0x7
[audio format for output stream 0:0 @ 0x1e9e300] Setting 'sample_fmts' to value 's16'
[AVFilterGraph @ 0x1e9b1a0] query_formats: 4 queried, 9 merged, 0 already done, 0 delayed
Output #0, null, to '/dev/null':
  Metadata:
    encoder         : Lavf55.4.101
    Stream #0:0, 0, 1/90000: Audio: pcm_s16le, 8000 Hz, 3.0, s16, 384 kb/s
Stream mapping:
  Stream #0:0 -> #0:0 (flac -> pcm_s16le)
Press [q] to stop, [?] for help
Input stream #0:0 frame changed from rate:8000 fmt:s16 ch:3 chl:3.0 to rate:44100 fmt:s16 ch:2 chl:stereo
[graph 0 input from stream 0:0 @ 0x1e9e280] Setting 'time_base' to value '1/44100'
[graph 0 input from stream 0:0 @ 0x1e9e280] Setting 'sample_rate' to value '44100'
[graph 0 input from stream 0:0 @ 0x1e9e280] Setting 'sample_fmt' to value 's16'
[graph 0 input from stream 0:0 @ 0x1e9e280] Setting 'channel_layout' to value '0x3'
[graph 0 input from stream 0:0 @ 0x1e9e280] tb:1/44100 samplefmt:s16 samplerate:44100 chlayout:0x3
[audio format for output stream 0:0 @ 0x1e9f140] Setting 'sample_fmts' to value 's16'
[audio format for output stream 0:0 @ 0x1e9f140] Setting 'sample_rates' to value '8000'
[audio format for output stream 0:0 @ 0x1e9f140] Setting 'channel_layouts' to value '0x7'
[audio format for output stream 0:0 @ 0x1e9f140] auto-inserting filter 'auto-inserted resampler 0' between the filter 'Parsed_anull_0' and the filter 'audio format for output stream 0:0'
[AVFilterGraph @ 0x1e9df60] query_formats: 4 queried, 9 merged, 3 already done, 0 delayed
1.000000 0.000000 
0.000000 1.000000 
0.000000 0.000000 
[auto-inserted resampler 0 @ 0x1ea1960] ch:2 chl:stereo fmt:s16 r:44100Hz -> ch:3 chl:3.0 fmt:s16 r:8000Hz
[flac @ 0x1e9a1e0] CRC error at PTS -9223372036854775808
[flac @ 0x1e9a1e0] overread: 1
Error while decoding stream #0:0: Invalid data found when processing input
[flac @ 0x1e9a1e0] switching bps mid-stream is not supported
[flac @ 0x1e9a1e0] decode_frame() failed
Error while decoding stream #0:0: Operation not permitted
[output stream 0:0 @ 0x1e9de80] EOF on sink link output stream 0:0:default.
No more output streams to write to, finishing.
size=N/A time=00:00:07.40 bitrate=N/A    
video:0kB audio:347kB subtitle:0 global headers:0kB muxing overhead -100.006195%
9 frames successfully decoded, 2 decoding errors
[AVIOContext @ 0x1ea1ee0] Statistics: 579223 bytes read, 0 seeks

Attachments (1)

flac-file-with-valid-header-in-last-block.flac (565.6 KB ) - added by Carl Eugen Hoyos 11 years ago.

Download all attachments as: .zip

Change History (4)

by Carl Eugen Hoyos, 11 years ago

comment:1 by Carl Eugen Hoyos, 11 years ago

Keywords: regression added
Priority: normalimportant
Reproduced by developer: set
Status: newopen

Regression since f095391 / 27c7ca9

comment:2 by Carl Eugen Hoyos, 11 years ago

Fixed by Michael Chinen.

comment:3 by Carl Eugen Hoyos, 11 years ago

Resolution: fixed
Status: openclosed
Note: See TracTickets for help on using tickets.