1 /*
2  * Copyright (C) 2007 Marco Gerards <marco@gnu.org>
3  * Copyright (C) 2009 David Conrad
4  * Copyright (C) 2011 Jordi Ortiz
5  *
6  * This file is part of FFmpeg.
7  *
8  * FFmpeg is free software; you can redistribute it and/or
9  * modify it under the terms of the GNU Lesser General Public
10  * License as published by the Free Software Foundation; either
11  * version 2.1 of the License, or (at your option) any later version.
12  *
13  * FFmpeg is distributed in the hope that it will be useful,
14  * but WITHOUT ANY WARRANTY; without even the implied warranty of
15  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
16  * Lesser General Public License for more details.
17  *
18  * You should have received a copy of the GNU Lesser General Public
19  * License along with FFmpeg; if not, write to the Free Software
20  * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
21  */
22 
23 module ffmpeg.libavcodec.dirac;
24 
25 extern (C):
26 import ffmpeg; @nogc nothrow:
27 
28 /**
29  * @file
30  * Interface to Dirac Decoder/Encoder
31  * @author Marco Gerards <marco@gnu.org>
32  * @author David Conrad
33  * @author Jordi Ortiz
34  */
35 
36 /**
37  * The spec limits the number of wavelet decompositions to 4 for both
38  * level 1 (VC-2) and 128 (long-gop default).
39  * 5 decompositions is the maximum before >16-bit buffers are needed.
40  * Schroedinger allows this for DD 9,7 and 13,7 wavelets only, limiting
41  * the others to 4 decompositions (or 3 for the fidelity filter).
42  *
43  * We use this instead of MAX_DECOMPOSITIONS to save some memory.
44  */
45 enum MAX_DWT_LEVELS = 5;
46 
47 /**
48  * Parse code values:
49  *
50  * Dirac Specification ->
51  * 9.6.1  Table 9.1
52  *
53  * VC-2 Specification  ->
54  * 10.4.1 Table 10.1
55  */
56 
57 enum DiracParseCodes
58 {
59     DIRAC_PCODE_SEQ_HEADER = 0x00,
60     DIRAC_PCODE_END_SEQ = 0x10,
61     DIRAC_PCODE_AUX = 0x20,
62     DIRAC_PCODE_PAD = 0x30,
63     DIRAC_PCODE_PICTURE_CODED = 0x08,
64     DIRAC_PCODE_PICTURE_RAW = 0x48,
65     DIRAC_PCODE_PICTURE_LOW_DEL = 0xC8,
66     DIRAC_PCODE_PICTURE_HQ = 0xE8,
67     DIRAC_PCODE_INTER_NOREF_CO1 = 0x0A,
68     DIRAC_PCODE_INTER_NOREF_CO2 = 0x09,
69     DIRAC_PCODE_INTER_REF_CO1 = 0x0D,
70     DIRAC_PCODE_INTER_REF_CO2 = 0x0E,
71     DIRAC_PCODE_INTRA_REF_CO = 0x0C,
72     DIRAC_PCODE_INTRA_REF_RAW = 0x4C,
73     DIRAC_PCODE_INTRA_REF_PICT = 0xCC,
74     DIRAC_PCODE_MAGIC = 0x42424344
75 }
76 
77 struct DiracVersionInfo
78 {
79     int major;
80     int minor;
81 }
82 
83 struct AVDiracSeqHeader
84 {
85     uint width;
86     uint height;
87     ubyte chroma_format; ///< 0: 444  1: 422  2: 420
88 
89     ubyte interlaced;
90     ubyte top_field_first;
91 
92     ubyte frame_rate_index; ///< index into dirac_frame_rate[]
93     ubyte aspect_ratio_index; ///< index into dirac_aspect_ratio[]
94 
95     ushort clean_width;
96     ushort clean_height;
97     ushort clean_left_offset;
98     ushort clean_right_offset;
99 
100     ubyte pixel_range_index; ///< index into dirac_pixel_range_presets[]
101     ubyte color_spec_index; ///< index into dirac_color_spec_presets[]
102 
103     int profile;
104     int level;
105 
106     AVRational framerate;
107     AVRational sample_aspect_ratio;
108 
109     AVPixelFormat pix_fmt;
110     AVColorRange color_range;
111     AVColorPrimaries color_primaries;
112     AVColorTransferCharacteristic color_trc;
113     AVColorSpace colorspace;
114 
115     DiracVersionInfo version_;
116     int bit_depth;
117 }
118 
119 /**
120  * Parse a Dirac sequence header.
121  *
122  * @param dsh this function will allocate and fill an AVDiracSeqHeader struct
123  *            and write it into this pointer. The caller must free it with
124  *            av_free().
125  * @param buf the data buffer
126  * @param buf_size the size of the data buffer in bytes
127  * @param log_ctx if non-NULL, this function will log errors here
128  * @return 0 on success, a negative AVERROR code on failure
129  */
130 int av_dirac_parse_sequence_header (
131     AVDiracSeqHeader** dsh,
132     const(ubyte)* buf,
133     size_t buf_size,
134     void* log_ctx);
135 
136 /* AVCODEC_DIRAC_H */