1cabdff1aSopenharmony_ci/*
2cabdff1aSopenharmony_ci * Argonaut Games ASF (de)muxer
3cabdff1aSopenharmony_ci *
4cabdff1aSopenharmony_ci * Copyright (C) 2020 Zane van Iperen (zane@zanevaniperen.com)
5cabdff1aSopenharmony_ci *
6cabdff1aSopenharmony_ci * This file is part of FFmpeg.
7cabdff1aSopenharmony_ci *
8cabdff1aSopenharmony_ci * FFmpeg is free software; you can redistribute it and/or
9cabdff1aSopenharmony_ci * modify it under the terms of the GNU Lesser General Public
10cabdff1aSopenharmony_ci * License as published by the Free Software Foundation; either
11cabdff1aSopenharmony_ci * version 2.1 of the License, or (at your option) any later version.
12cabdff1aSopenharmony_ci *
13cabdff1aSopenharmony_ci * FFmpeg is distributed in the hope that it will be useful,
14cabdff1aSopenharmony_ci * but WITHOUT ANY WARRANTY; without even the implied warranty of
15cabdff1aSopenharmony_ci * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
16cabdff1aSopenharmony_ci * Lesser General Public License for more details.
17cabdff1aSopenharmony_ci *
18cabdff1aSopenharmony_ci * You should have received a copy of the GNU Lesser General Public
19cabdff1aSopenharmony_ci * License along with FFmpeg; if not, write to the Free Software
20cabdff1aSopenharmony_ci * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
21cabdff1aSopenharmony_ci */
22cabdff1aSopenharmony_ci
23cabdff1aSopenharmony_ci#ifndef AVFORMAT_ARGO_ASF_H
24cabdff1aSopenharmony_ci#define AVFORMAT_ARGO_ASF_H
25cabdff1aSopenharmony_ci
26cabdff1aSopenharmony_ci#include <stdint.h>
27cabdff1aSopenharmony_ci#include "libavutil/macros.h"
28cabdff1aSopenharmony_ci
29cabdff1aSopenharmony_ci#include "avformat.h"
30cabdff1aSopenharmony_ci
31cabdff1aSopenharmony_ci#define ASF_TAG                 MKTAG('A', 'S', 'F', '\0')
32cabdff1aSopenharmony_ci#define ASF_FILE_HEADER_SIZE    24
33cabdff1aSopenharmony_ci#define ASF_CHUNK_HEADER_SIZE   20
34cabdff1aSopenharmony_ci#define ASF_SAMPLE_COUNT        32
35cabdff1aSopenharmony_ci#define ASF_MIN_BUFFER_SIZE     FFMAX(ASF_FILE_HEADER_SIZE, ASF_CHUNK_HEADER_SIZE)
36cabdff1aSopenharmony_ci#define ASF_NAME_SIZE           8
37cabdff1aSopenharmony_ci
38cabdff1aSopenharmony_citypedef struct ArgoASFFileHeader {
39cabdff1aSopenharmony_ci    uint32_t    magic;          /*< Magic Number, {'A', 'S', 'F', '\0'} */
40cabdff1aSopenharmony_ci    uint16_t    version_major;  /*< File Major Version. */
41cabdff1aSopenharmony_ci    uint16_t    version_minor;  /*< File Minor Version. */
42cabdff1aSopenharmony_ci    uint32_t    num_chunks;     /*< No. chunks in the file. */
43cabdff1aSopenharmony_ci    uint32_t    chunk_offset;   /*< Offset to the first chunk from the start of the file. */
44cabdff1aSopenharmony_ci    char        name[ASF_NAME_SIZE + 1]; /*< Name, +1 for NULL-terminator. */
45cabdff1aSopenharmony_ci} ArgoASFFileHeader;
46cabdff1aSopenharmony_ci
47cabdff1aSopenharmony_citypedef struct ArgoASFChunkHeader {
48cabdff1aSopenharmony_ci    uint32_t    num_blocks;     /*< No. blocks in the chunk. */
49cabdff1aSopenharmony_ci    uint32_t    num_samples;    /*< No. samples per channel in a block. Always 32. */
50cabdff1aSopenharmony_ci    uint32_t    unk1;           /*< Unknown */
51cabdff1aSopenharmony_ci    uint16_t    sample_rate;    /*< Sample rate. */
52cabdff1aSopenharmony_ci    uint16_t    unk2;           /*< Unknown. */
53cabdff1aSopenharmony_ci    uint32_t    flags;          /*< Stream flags. */
54cabdff1aSopenharmony_ci} ArgoASFChunkHeader;
55cabdff1aSopenharmony_ci
56cabdff1aSopenharmony_cienum {
57cabdff1aSopenharmony_ci    ASF_CF_BITS_PER_SAMPLE  = (1 << 0), /*< 16-bit if set, 8 otherwise.      */
58cabdff1aSopenharmony_ci    ASF_CF_STEREO           = (1 << 1), /*< Stereo if set, mono otherwise.   */
59cabdff1aSopenharmony_ci    ASF_CF_ALWAYS1_1        = (1 << 2), /*< Unknown, always seems to be set. */
60cabdff1aSopenharmony_ci    ASF_CF_ALWAYS1_2        = (1 << 3), /*< Unknown, always seems to be set. */
61cabdff1aSopenharmony_ci
62cabdff1aSopenharmony_ci    ASF_CF_ALWAYS1          = ASF_CF_ALWAYS1_1 | ASF_CF_ALWAYS1_2,
63cabdff1aSopenharmony_ci    ASF_CF_ALWAYS0          = ~(ASF_CF_BITS_PER_SAMPLE | ASF_CF_STEREO | ASF_CF_ALWAYS1)
64cabdff1aSopenharmony_ci};
65cabdff1aSopenharmony_ci
66cabdff1aSopenharmony_civoid ff_argo_asf_parse_file_header(ArgoASFFileHeader *hdr, const uint8_t *buf);
67cabdff1aSopenharmony_ciint  ff_argo_asf_validate_file_header(AVFormatContext *s, const ArgoASFFileHeader *hdr);
68cabdff1aSopenharmony_civoid ff_argo_asf_parse_chunk_header(ArgoASFChunkHeader *hdr, const uint8_t *buf);
69cabdff1aSopenharmony_ciint  ff_argo_asf_fill_stream(AVFormatContext *s, AVStream *st, const ArgoASFFileHeader *fhdr,
70cabdff1aSopenharmony_ci                             const ArgoASFChunkHeader *ckhdr);
71cabdff1aSopenharmony_ci
72cabdff1aSopenharmony_ci#endif /* AVFORMAT_ARGO_ASF_H */
73