Quoting Alexandra Hájková (2015-03-03 20:18:17)
> From: alexandra <alexandra@sai>
>
> The old one is result of reverse engeneering and guesswork.
> The new one had been written following the now-available specification.
>
> This work is part of Outreach Program for Women Summer 2014 activities.
>
> The fate references had to be changed because the old demuxer cuts
> the last frame in some cases and this new one hadles them properly.
> For the pcm files, the reference have to be changed separetly for
> this patch to pass fate as pcm references are not the part of git.
> The seek-test reference was changed because seeking works diferently
> in the new demuxer. When seeking, the packet is not read from the stream
> directly, but rather constructed from the demuxer. That's why pos is -1 now
> in the reference.
> ---
> doc/demuxers.texi | 2 +-
> libavformat/asf.h | 21 -
> libavformat/asfdec.c | 2511
> ++++++++++++++++++++++-------------------
> libavformat/asfenc.c | 21 +
> tests/ref/fate/lossless-wma | 2 +-
> tests/ref/fate/wmv8-drm-nodec | 1 -
> tests/ref/seek/lavf-asf | 54 +-
> 7 files changed, 1376 insertions(+), 1236 deletions(-)
>
> diff --git a/doc/demuxers.texi b/doc/demuxers.texi
> index 2f2f464..beef99c 100644
> --- a/doc/demuxers.texi
> +++ b/doc/demuxers.texi
> @@ -107,7 +107,7 @@ This demuxer is used to demux ASF files and MMS network
> streams.
>
> @table @option
> @item -no_resync_search @var{bool}
> -Do not try to resynchronize by looking for a certain optional start code.
> +This option does nothing and will be removed
> @end table
>
> @c man end INPUT DEVICES
> diff --git a/libavformat/asf.h b/libavformat/asf.h
> index 2f6722a..7ac28db 100644
> --- a/libavformat/asf.h
> +++ b/libavformat/asf.h
> @@ -28,27 +28,6 @@
>
> #define PACKET_SIZE 3200
>
> -typedef struct ASFStream {
> - int num;
> - unsigned char seq;
> - /* use for reading */
> - AVPacket pkt;
> - int frag_offset;
> - int timestamp;
> - int64_t duration;
> -
> - int ds_span; /* descrambling */
> - int ds_packet_size;
> - int ds_chunk_size;
> -
> - int64_t packet_pos;
> -
> - uint16_t stream_language_index;
> -
> - int palette_changed;
> - uint32_t palette[256];
> -} ASFStream;
> -
> typedef struct ASFMainHeader {
> ff_asf_guid guid; ///< generated by client computer
> uint64_t file_size; /**< in bytes
> diff --git a/libavformat/asfdec.c b/libavformat/asfdec.c
> index fac5806..4138edd 100644
> --- a/libavformat/asfdec.c
> +++ b/libavformat/asfdec.c
> @@ -1,6 +1,6 @@
> /*
> - * ASF compatible demuxer
> - * Copyright (c) 2000, 2001 Fabrice Bellard
> + * Microsoft Advanced Streaming Format demuxer
> + * Copyright (c) 2014 Alexandra Hájková
> *
> * This file is part of Libav.
> *
> @@ -19,8 +19,6 @@
> * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301
> USA
> */
>
> -#include <inttypes.h>
> -
> #include "libavutil/attributes.h"
> #include "libavutil/avassert.h"
> #include "libavutil/avstring.h"
> @@ -30,6 +28,8 @@
> #include "libavutil/internal.h"
> #include "libavutil/mathematics.h"
> #include "libavutil/opt.h"
> +#include "libavutil/time_internal.h"
> +
> #include "avformat.h"
> #include "avio_internal.h"
> #include "avlanguage.h"
> @@ -39,153 +39,294 @@
> #include "asf.h"
> #include "asfcrypt.h"
>
> +#define ASF_BOOL 0x2
> +#define ASF_WORD 0x5
> +#define ASF_GUID 0x6
> +#define ASF_DWORD 0x3
> +#define ASF_QWORD 0x4
> +#define ASF_UNICODE 0x0
> +#define IS_BROADCAST 1
> +#define ASF_BYTE_ARRAY 0x1
> +#define ASF_TYPE_AUDIO 0x2
> +#define ASF_TYPE_VIDEO 0x1
> +#define ASF_STREAM_NUM 0x7F
> +#define ASF_MAX_STREAMS 128
> +#define BMP_HEADER_SIZE 40
> +#define ASF_NUM_OF_PAYLOADS 0x3F
> +#define ASF_ERROR_CORRECTION_LENGTH_TYPE 0x60
> +#define ASF_PACKET_ERROR_CORRECTION_DATA_SIZE 0x2
> +
> +typedef struct GUIDParseTable {
> + const char *name;
> + ff_asf_guid guid;
> + int (*read_object)(AVFormatContext *, const struct GUIDParseTable *);
> + int is_subobject;
> +} GUIDParseTable;
> +
> +typedef struct ASFPacket {
> + AVPacket *avpkt;
> + int64_t dts;
> + uint32_t frame_num; // ASF payloads with the same number are parts of
> the same frame
> + int flags;
> + int data_size;
> + int duration;
> + int size_left;
> + uint8_t stream_index;
> +} ASFPacket;
> +
> +typedef struct ASFStream2 {
> + uint8_t stream_index; //from packet header
> + int index; // stream index in AVFormatContext, set in
> asf_read_stream_properties
> + int type;
> + int indexed; // added index entries from the Simple Index Object or not
> + int8_t span; // for deinterleaving
> + uint16_t virtual_pkt_len;
> + uint16_t virtual_chunk_len;
> + int16_t idx_type; // index type in the Index Parameters Object
> + int16_t lang_idx;
> + char lang[100];
> + ASFPacket *pkt;
> +} ASFStream2;
> +
> typedef struct ASFContext {
> - const AVClass *class;
> - int asfid2avid[128]; ///< conversion table from asf ID 2
> AVStream ID
> - ASFStream streams[128]; ///< it's max number and it's not
> that big
> - uint32_t stream_bitrates[128]; ///< max number of streams, bitrate
> for each (for streaming)
> - AVRational dar[128];
> - char stream_languages[128][6]; ///< max number of streams,
> language for each (RFC1766, e.g. en-US)
> - /* non streamed additonnal info */
> - /* packet filling */
> - int packet_size_left;
> - /* only for reading */
> - uint64_t data_offset; ///< beginning of the first data
> packet
> - uint64_t data_object_offset; ///< data object offset (excl. GUID
> & size)
> - uint64_t data_object_size; ///< size of the data object
> - int index_read;
> -
> - ASFMainHeader hdr;
> -
> - int packet_flags;
> - int packet_property;
> - int packet_timestamp;
> - int packet_segsizetype;
> - int packet_segments;
> - int packet_seq;
> - int packet_replic_size;
> - int packet_key_frame;
> - int packet_padsize;
> - unsigned int packet_frag_offset;
> - unsigned int packet_frag_size;
> - int64_t packet_frag_timestamp;
> - int packet_multi_size;
> - int packet_obj_size;
> - int packet_time_delta;
> - int packet_time_start;
> - int64_t packet_pos;
> -
> - int stream_index;
> -
> - ASFStream *asf_st; ///< currently decoded stream
> -
> - int no_resync_search;
> - int export_xmp;
> + int data_reached;
> + int is_simple_index; // is simple index present or not 1/0
> + int is_header;
> +
> + uint64_t preroll;
> + uint64_t nb_packets; // ASF packets
> + uint32_t packet_size;
> + int64_t send_time;
> + int duration;
> +
> + uint32_t b_flags; // flags with broadcast flag
> + uint32_t prop_flags; // file properties object flags
> +
> + uint64_t data_size; // data object size
> + int64_t header_obj_size;
> + int64_t unknown_size; // size of the unknown object
> +
> + // presentation time offset, equal for all streams, should be equal to
> send time, !100-nanosecond units
> + uint64_t time_offset;
> + int64_t offset; // offset of the current object
> + int64_t data_offset;
> + int64_t first_packet_offset; // packet offset
> + int64_t unknown_offset; // for top level header objects or subobjects
> without specified behavior
> +
> + // ASF file must not contain more than 128 streams according to the
> specification
> + ASFStream2 *asf_st[ASF_MAX_STREAMS];
> + int nb_streams;
> + int stream_index; //from packet header, for the subpayload case
> + char langs[ASF_MAX_STREAMS][100];
> +
> + // packet parametres
> + uint64_t sub_header_offset; // offset of subplayload header
> + int64_t sub_dts;
> + uint8_t dts_delta; // for subpayloads
> + uint32_t packet_size_internal; // packet size stored inside ASFPacket,
> can be 0
> + int64_t dts;
> + int64_t packet_offset; // offset of the current packet inside Data Object
> + uint32_t pad_len; // padding after payload
> + uint32_t rep_data_len;
> +
> + // packet state
> + uint64_t sub_left; // subpayloads left or not
> + int nb_sub; // number of subpayloads read so far from the current ASF
> packet
> + uint16_t mult_sub_len; // total length of subpayloads array inside
> multiple payload
> + uint64_t nb_mult_left; // multiple payloads left
> + int return_subpayload;
> + enum {
> + PARSE_PACKET_HEADER,
> + READ_SINGLE,
> + READ_MULTI,
> + READ_MULTI_SUB
> + } state;
> } ASFContext;
>
> -static const AVOption options[] = {
> - { "no_resync_search", "Don't try to resynchronize by looking for a
> certain optional start code", offsetof(ASFContext, no_resync_search),
> AV_OPT_TYPE_INT, { .i64 = 0 }, 0, 1, AV_OPT_FLAG_DECODING_PARAM },
> - { "export_xmp", "Export full XMP metadata", offsetof(ASFContext,
> export_xmp), AV_OPT_TYPE_INT, { .i64 = 0 }, 0, 1, AV_OPT_FLAG_DECODING_PARAM
> },
> - { NULL },
> -};
> +static int detect_unknown_subobject(AVFormatContext *s, int64_t offset,
> int64_t size);
> +static const GUIDParseTable *find_guid(ff_asf_guid guid);
> +>>>>>>> lavf: Replace the ASF demuxer
This does not compile.
--
Anton Khirnov
_______________________________________________
libav-devel mailing list
[email protected]
https://lists.libav.org/mailman/listinfo/libav-devel