[FFmpeg-devel] Chinese AVS file format demuxing

Pavel Modilaynen pmodilaynen
Fri Sep 5 14:28:47 CEST 2008


Stefan Gehrer wrote:
> Pavel Modilaynen wrote:
>   
>> Hi Stefan,
>>     
>>> the files stream0?.avs from avs.org.cn/fruits are
>>> AVS1-P1 format (abused MPEG2 part 1) and can be
>>> played back using
>>>
>>> 'ffplay stream01.avs'
>>> or
>>> 'mplayer -demuxer lavf stream01.avs'
>>>       
>> Unfortunately, I can't make them able to play by ffplay or mplayer.
>> May be *.avs files on avs.org.cn are changed since time you played them?
>>     
>
> Yes, they changed. There used to be 10 files of around 150MB each in
> AVS1-P1 format. One of them can still be found here 
> http://samples.mplayerhq.hu/AVS/
> Now there are three files of only a few kB and they are video elementary
> streams. When developing the decoder I had some way to play back these
> elementary streams but I can't remember how.
>
>   
Right, as I've recently found out, this is so called AVS P2 Video 
Elementary Stream.
With a little changes they can be demuxed by libavformat/raw.c :
Index: libavformat/raw.c
===================================================================
--- libavformat/raw.c (revision 15191)
+++ libavformat/raw.c (working copy)
@@ -336,6 +336,29 @@
}
#endif

+
+#define AVS_SEQUENCE_START_CODE 0x000001b0
+static int avs_probe(AVProbeData *probe_packet)
+{
+ uint32_t temp_buffer= -1;
+ int i;
+ int st_code = 0;
+
+ for(i=0; i<probe_packet->buf_size; i++){
+ temp_buffer = (temp_buffer<<8) + probe_packet->buf[i];
+ if ((temp_buffer & 0xffffff00) != 0x100)
+ continue;
+
+ if (temp_buffer == AVS_SEQUENCE_START_CODE)
+ st_code++;
+ }
+
+ if (st_code)
+ return AVPROBE_SCORE_MAX;
+ return 0;
+
+}
+
#ifdef CONFIG_M4V_DEMUXER
#define VISUAL_OBJECT_START_CODE 0x000001b5
#define VOP_START_CODE 0x000001b6
@@ -829,12 +852,12 @@
"m4v",
NULL_IF_CONFIG_SMALL("raw MPEG-4 video format"),
0,
- mpeg4video_probe, /** probing for MPEG-4 data */
+ avs_probe,
video_read_header,
raw_read_partial_packet,
.flags= AVFMT_GENERIC_INDEX,
- .extensions = "m4v", //FIXME remove after writing mpeg4_probe
- .value = CODEC_ID_MPEG4,
+ .extensions = "m4v,avs", //FIXME remove after writing mpeg4_probe
+ .value = CODEC_ID_CAVS,
};
#endif

The probing now works and ffplay gives out these errors:
Illegal intra prediction mode
Illegal intra prediction mode
Illegal intra prediction mode
Illegal intra prediction mode
[cavs @ 0x8837b40]position out of block bounds at pic 0 MB(1,0)
[cavs @ 0x8837b40]position out of block bounds at pic 0 MB(1,0)
Illegal intra prediction mode
Illegal intra prediction mode
...

So, now the decoder failes and it probably needs to be updated.
Of course, this modifications break the correct code - it's only
for investigations. The special AVInputFormat avsp2_demuxer
could be created instead.






More information about the ffmpeg-devel mailing list