avcodec/cavs_parser: fix finding the end of a frame

Use the next I/P/B or start code as the end of current frame.

Before the patch, extension start code, user data start code,
sequence end code and so on are treated as the start of next
frame.

Signed-off-by: Zhao Zhili <zhilizhao@tencent.com>
This commit is contained in:
Zhao Zhili 2023-05-13 01:13:05 +08:00
parent 2838138975
commit 47430a3cb1
3 changed files with 70 additions and 6 deletions

View File

@ -59,12 +59,11 @@ static int cavs_find_frame_end(ParseContext *pc, const uint8_t *buf,
return 0;
for(; i<buf_size; i++){
state= (state<<8) | buf[i];
if((state&0xFFFFFF00) == 0x100){
if(state > SLICE_MAX_START_CODE){
pc->frame_start_found=0;
pc->state=-1;
return i-3;
}
if (state == PIC_I_START_CODE || state == PIC_PB_START_CODE ||
state == CAVS_START_CODE) {
pc->frame_start_found=0;
pc->state=-1;
return i-3;
}
}
}

View File

@ -29,6 +29,9 @@ fate-bcstm: CMD = crc -i $(TARGET_SAMPLES)/bfstm/loz-mm-mikau.bcstm -c:a copy
FATE_SAMPLES_DEMUX-$(CONFIG_BRSTM_DEMUXER) += fate-brstm
fate-brstm: CMD = crc -i $(TARGET_SAMPLES)/brstm/lozswd_partial.brstm -c:a copy
FATE_FFPROBE_DEMUX-$(call ALLYES, CAVSVIDEO_DEMUXER CAVSVIDEO_PARSER) += fate-cavs-demux
fate-cavs-demux: CMD = ffprobe_demux $(TARGET_SAMPLES)/cavs/bunny.cavs
FATE_SAMPLES_DEMUX-$(CONFIG_CDXL_DEMUXER) += fate-cdxl-demux
fate-cdxl-demux: CMD = framecrc -i $(TARGET_SAMPLES)/cdxl/mirage.cdxl -c:v copy -c:a copy

62
tests/ref/fate/cavs-demux Normal file
View File

@ -0,0 +1,62 @@
packet|codec_type=video|stream_index=0|pts=0|pts_time=0.000000|dts=0|dts_time=0.000000|duration=48000|duration_time=0.040000|size=14447|pos=0|flags=K__|data_hash=CRC32:83f257c0
packet|codec_type=video|stream_index=0|pts=48000|pts_time=0.040000|dts=48000|dts_time=0.040000|duration=48000|duration_time=0.040000|size=483|pos=14447|flags=K__|data_hash=CRC32:5abb82f8
packet|codec_type=video|stream_index=0|pts=96000|pts_time=0.080000|dts=96000|dts_time=0.080000|duration=48000|duration_time=0.040000|size=18|pos=14930|flags=K__|data_hash=CRC32:b8b123d8
packet|codec_type=video|stream_index=0|pts=144000|pts_time=0.120000|dts=144000|dts_time=0.120000|duration=48000|duration_time=0.040000|size=18|pos=14948|flags=K__|data_hash=CRC32:19180fa8
packet|codec_type=video|stream_index=0|pts=192000|pts_time=0.160000|dts=192000|dts_time=0.160000|duration=48000|duration_time=0.040000|size=18|pos=14966|flags=K__|data_hash=CRC32:cf501647
packet|codec_type=video|stream_index=0|pts=240000|pts_time=0.200000|dts=240000|dts_time=0.200000|duration=40000|duration_time=0.033333|size=1807|pos=14984|flags=K__|data_hash=CRC32:4267e1d5
packet|codec_type=video|stream_index=0|pts=280000|pts_time=0.233333|dts=280000|dts_time=0.233333|duration=40000|duration_time=0.033333|size=28|pos=16791|flags=K__|data_hash=CRC32:c223285a
packet|codec_type=video|stream_index=0|pts=320000|pts_time=0.266667|dts=320000|dts_time=0.266667|duration=40000|duration_time=0.033333|size=25|pos=16819|flags=K__|data_hash=CRC32:2565cc9e
packet|codec_type=video|stream_index=0|pts=360000|pts_time=0.300000|dts=360000|dts_time=0.300000|duration=40000|duration_time=0.033333|size=22|pos=16844|flags=K__|data_hash=CRC32:7fbf36ac
packet|codec_type=video|stream_index=0|pts=400000|pts_time=0.333333|dts=400000|dts_time=0.333333|duration=40000|duration_time=0.033333|size=23884|pos=16866|flags=K__|data_hash=CRC32:d61430fd
packet|codec_type=video|stream_index=0|pts=440000|pts_time=0.366667|dts=440000|dts_time=0.366667|duration=40000|duration_time=0.033333|size=265|pos=40750|flags=K__|data_hash=CRC32:d64145a0
packet|codec_type=video|stream_index=0|pts=480000|pts_time=0.400000|dts=480000|dts_time=0.400000|duration=40000|duration_time=0.033333|size=393|pos=41015|flags=K__|data_hash=CRC32:32c020e2
packet|codec_type=video|stream_index=0|pts=520000|pts_time=0.433333|dts=520000|dts_time=0.433333|duration=40000|duration_time=0.033333|size=656|pos=41408|flags=K__|data_hash=CRC32:965c7846
packet|codec_type=video|stream_index=0|pts=560000|pts_time=0.466667|dts=560000|dts_time=0.466667|duration=40000|duration_time=0.033333|size=3500|pos=42064|flags=K__|data_hash=CRC32:ddf731de
packet|codec_type=video|stream_index=0|pts=600000|pts_time=0.500000|dts=600000|dts_time=0.500000|duration=40000|duration_time=0.033333|size=68|pos=45564|flags=K__|data_hash=CRC32:f8c8ba07
packet|codec_type=video|stream_index=0|pts=640000|pts_time=0.533333|dts=640000|dts_time=0.533333|duration=40000|duration_time=0.033333|size=58|pos=45632|flags=K__|data_hash=CRC32:22adbb83
packet|codec_type=video|stream_index=0|pts=680000|pts_time=0.566667|dts=680000|dts_time=0.566667|duration=40000|duration_time=0.033333|size=43|pos=45690|flags=K__|data_hash=CRC32:53fb136c
packet|codec_type=video|stream_index=0|pts=720000|pts_time=0.600000|dts=720000|dts_time=0.600000|duration=40000|duration_time=0.033333|size=11757|pos=45733|flags=K__|data_hash=CRC32:551e491b
packet|codec_type=video|stream_index=0|pts=760000|pts_time=0.633333|dts=760000|dts_time=0.633333|duration=40000|duration_time=0.033333|size=98|pos=57490|flags=K__|data_hash=CRC32:4e718dd4
packet|codec_type=video|stream_index=0|pts=800000|pts_time=0.666667|dts=800000|dts_time=0.666667|duration=40000|duration_time=0.033333|size=79|pos=57588|flags=K__|data_hash=CRC32:4c5a32f5
packet|codec_type=video|stream_index=0|pts=840000|pts_time=0.700000|dts=840000|dts_time=0.700000|duration=40000|duration_time=0.033333|size=128|pos=57667|flags=K__|data_hash=CRC32:95b8cad1
packet|codec_type=video|stream_index=0|pts=880000|pts_time=0.733333|dts=880000|dts_time=0.733333|duration=40000|duration_time=0.033333|size=10487|pos=57795|flags=K__|data_hash=CRC32:8646f8f2
packet|codec_type=video|stream_index=0|pts=920000|pts_time=0.766667|dts=920000|dts_time=0.766667|duration=40000|duration_time=0.033333|size=65|pos=68282|flags=K__|data_hash=CRC32:73687d19
packet|codec_type=video|stream_index=0|pts=960000|pts_time=0.800000|dts=960000|dts_time=0.800000|duration=40000|duration_time=0.033333|size=46|pos=68347|flags=K__|data_hash=CRC32:ad381ca5
packet|codec_type=video|stream_index=0|pts=1000000|pts_time=0.833333|dts=1000000|dts_time=0.833333|duration=40000|duration_time=0.033333|size=67|pos=68393|flags=K__|data_hash=CRC32:89069152
packet|codec_type=video|stream_index=0|pts=1040000|pts_time=0.866667|dts=1040000|dts_time=0.866667|duration=40000|duration_time=0.033333|size=8403|pos=68460|flags=K__|data_hash=CRC32:a22913dd
packet|codec_type=video|stream_index=0|pts=1080000|pts_time=0.900000|dts=1080000|dts_time=0.900000|duration=40000|duration_time=0.033333|size=70|pos=76863|flags=K__|data_hash=CRC32:98772596
packet|codec_type=video|stream_index=0|pts=1120000|pts_time=0.933333|dts=1120000|dts_time=0.933333|duration=40000|duration_time=0.033333|size=63|pos=76933|flags=K__|data_hash=CRC32:cfd62cc4
packet|codec_type=video|stream_index=0|pts=1160000|pts_time=0.966667|dts=1160000|dts_time=0.966667|duration=40000|duration_time=0.033333|size=70|pos=76996|flags=K__|data_hash=CRC32:9b526357
packet|codec_type=video|stream_index=0|pts=1200000|pts_time=1.000000|dts=1200000|dts_time=1.000000|duration=40000|duration_time=0.033333|size=7945|pos=77066|flags=K__|data_hash=CRC32:d0f46769
packet|codec_type=video|stream_index=0|pts=1240000|pts_time=1.033333|dts=1240000|dts_time=1.033333|duration=40000|duration_time=0.033333|size=40558|pos=85011|flags=K__|data_hash=CRC32:4db0bd7d
packet|codec_type=video|stream_index=0|pts=1280000|pts_time=1.066667|dts=1280000|dts_time=1.066667|duration=40000|duration_time=0.033333|size=1260|pos=125569|flags=K__|data_hash=CRC32:3c4397d7
packet|codec_type=video|stream_index=0|pts=1320000|pts_time=1.100000|dts=1320000|dts_time=1.100000|duration=40000|duration_time=0.033333|size=27|pos=126829|flags=K__|data_hash=CRC32:5e233c77
packet|codec_type=video|stream_index=0|pts=1360000|pts_time=1.133333|dts=1360000|dts_time=1.133333|duration=40000|duration_time=0.033333|size=26|pos=126856|flags=K__|data_hash=CRC32:57985e7b
packet|codec_type=video|stream_index=0|pts=1400000|pts_time=1.166667|dts=1400000|dts_time=1.166667|duration=40000|duration_time=0.033333|size=18|pos=126882|flags=K__|data_hash=CRC32:f4eb01ba
packet|codec_type=video|stream_index=0|pts=1440000|pts_time=1.200000|dts=1440000|dts_time=1.200000|duration=40000|duration_time=0.033333|size=2931|pos=126900|flags=K__|data_hash=CRC32:ca20964f
packet|codec_type=video|stream_index=0|pts=1480000|pts_time=1.233333|dts=1480000|dts_time=1.233333|duration=40000|duration_time=0.033333|size=25|pos=129831|flags=K__|data_hash=CRC32:a82bd0b4
packet|codec_type=video|stream_index=0|pts=1520000|pts_time=1.266667|dts=1520000|dts_time=1.266667|duration=40000|duration_time=0.033333|size=19|pos=129856|flags=K__|data_hash=CRC32:bc5f709d
packet|codec_type=video|stream_index=0|pts=1560000|pts_time=1.300000|dts=1560000|dts_time=1.300000|duration=40000|duration_time=0.033333|size=30|pos=129875|flags=K__|data_hash=CRC32:c1f8a4c9
packet|codec_type=video|stream_index=0|pts=1600000|pts_time=1.333333|dts=1600000|dts_time=1.333333|duration=40000|duration_time=0.033333|size=5088|pos=129905|flags=K__|data_hash=CRC32:41ace145
packet|codec_type=video|stream_index=0|pts=1640000|pts_time=1.366667|dts=1640000|dts_time=1.366667|duration=40000|duration_time=0.033333|size=41|pos=134993|flags=K__|data_hash=CRC32:e169b3c7
packet|codec_type=video|stream_index=0|pts=1680000|pts_time=1.400000|dts=1680000|dts_time=1.400000|duration=40000|duration_time=0.033333|size=53|pos=135034|flags=K__|data_hash=CRC32:973c5fe3
packet|codec_type=video|stream_index=0|pts=1720000|pts_time=1.433333|dts=1720000|dts_time=1.433333|duration=40000|duration_time=0.033333|size=54|pos=135087|flags=K__|data_hash=CRC32:665639e6
packet|codec_type=video|stream_index=0|pts=1760000|pts_time=1.466667|dts=1760000|dts_time=1.466667|duration=40000|duration_time=0.033333|size=7150|pos=135141|flags=K__|data_hash=CRC32:cc910027
packet|codec_type=video|stream_index=0|pts=1800000|pts_time=1.500000|dts=1800000|dts_time=1.500000|duration=40000|duration_time=0.033333|size=48|pos=142291|flags=K__|data_hash=CRC32:45658f78
packet|codec_type=video|stream_index=0|pts=1840000|pts_time=1.533333|dts=1840000|dts_time=1.533333|duration=40000|duration_time=0.033333|size=48|pos=142339|flags=K__|data_hash=CRC32:94e359a2
packet|codec_type=video|stream_index=0|pts=1880000|pts_time=1.566667|dts=1880000|dts_time=1.566667|duration=40000|duration_time=0.033333|size=51|pos=142387|flags=K__|data_hash=CRC32:959ccdd9
packet|codec_type=video|stream_index=0|pts=1920000|pts_time=1.600000|dts=1920000|dts_time=1.600000|duration=40000|duration_time=0.033333|size=9379|pos=142438|flags=K__|data_hash=CRC32:a3318410
packet|codec_type=video|stream_index=0|pts=1960000|pts_time=1.633333|dts=1960000|dts_time=1.633333|duration=40000|duration_time=0.033333|size=58|pos=151817|flags=K__|data_hash=CRC32:44b24f03
packet|codec_type=video|stream_index=0|pts=2000000|pts_time=1.666667|dts=2000000|dts_time=1.666667|duration=40000|duration_time=0.033333|size=43|pos=151875|flags=K__|data_hash=CRC32:f4876e05
packet|codec_type=video|stream_index=0|pts=2040000|pts_time=1.700000|dts=2040000|dts_time=1.700000|duration=40000|duration_time=0.033333|size=62|pos=151918|flags=K__|data_hash=CRC32:34dce749
packet|codec_type=video|stream_index=0|pts=2080000|pts_time=1.733333|dts=2080000|dts_time=1.733333|duration=40000|duration_time=0.033333|size=10733|pos=151980|flags=K__|data_hash=CRC32:9012fdfb
packet|codec_type=video|stream_index=0|pts=2120000|pts_time=1.766667|dts=2120000|dts_time=1.766667|duration=40000|duration_time=0.033333|size=58|pos=162713|flags=K__|data_hash=CRC32:8a3c8760
packet|codec_type=video|stream_index=0|pts=2160000|pts_time=1.800000|dts=2160000|dts_time=1.800000|duration=40000|duration_time=0.033333|size=41|pos=162771|flags=K__|data_hash=CRC32:28da6bf4
packet|codec_type=video|stream_index=0|pts=2200000|pts_time=1.833333|dts=2200000|dts_time=1.833333|duration=40000|duration_time=0.033333|size=68|pos=162812|flags=K__|data_hash=CRC32:959dcc10
packet|codec_type=video|stream_index=0|pts=2240000|pts_time=1.866667|dts=2240000|dts_time=1.866667|duration=40000|duration_time=0.033333|size=9247|pos=162880|flags=K__|data_hash=CRC32:cf1e2a1a
packet|codec_type=video|stream_index=0|pts=2280000|pts_time=1.900000|dts=2280000|dts_time=1.900000|duration=40000|duration_time=0.033333|size=58|pos=172127|flags=K__|data_hash=CRC32:2efcb7ba
packet|codec_type=video|stream_index=0|pts=2320000|pts_time=1.933333|dts=2320000|dts_time=1.933333|duration=40000|duration_time=0.033333|size=67|pos=172185|flags=K__|data_hash=CRC32:42484449
packet|codec_type=video|stream_index=0|pts=2360000|pts_time=1.966667|dts=2360000|dts_time=1.966667|duration=40000|duration_time=0.033333|size=83|pos=172252|flags=K__|data_hash=CRC32:a941bdf0
packet|codec_type=video|stream_index=0|pts=2400000|pts_time=2.000000|dts=2400000|dts_time=2.000000|duration=40000|duration_time=0.033333|size=5417|pos=172335|flags=K__|data_hash=CRC32:9d0d503b
stream|index=0|codec_name=cavs|profile=unknown|codec_type=video|codec_tag_string=[0][0][0][0]|codec_tag=0x0000|width=1280|height=720|coded_width=1280|coded_height=720|closed_captions=0|film_grain=0|has_b_frames=0|sample_aspect_ratio=N/A|display_aspect_ratio=N/A|pix_fmt=yuv420p|level=-99|color_range=unknown|color_space=unknown|color_transfer=unknown|color_primaries=unknown|chroma_location=unspecified|field_order=unknown|refs=1|id=N/A|r_frame_rate=30/1|avg_frame_rate=25/1|time_base=1/1200000|start_pts=N/A|start_time=N/A|duration_ts=N/A|duration=N/A|bit_rate=N/A|max_bit_rate=N/A|bits_per_raw_sample=N/A|nb_frames=N/A|nb_read_frames=N/A|nb_read_packets=60|extradata_size=18|extradata_hash=CRC32:1255d52e|disposition:default=0|disposition:dub=0|disposition:original=0|disposition:comment=0|disposition:lyrics=0|disposition:karaoke=0|disposition:forced=0|disposition:hearing_impaired=0|disposition:visual_impaired=0|disposition:clean_effects=0|disposition:attached_pic=0|disposition:timed_thumbnails=0|disposition:captions=0|disposition:descriptions=0|disposition:metadata=0|disposition:dependent=0|disposition:still_image=0
format|filename=bunny.cavs|nb_streams=1|nb_programs=0|format_name=cavsvideo|start_time=N/A|duration=N/A|size=177752|bit_rate=N/A|probe_score=51