2 * Copyright (c) 2003-2004, Fran�ois-Olivier Devaux
3 * Copyright (c) 2003-2004, Communications and remote sensing Laboratory, Universite catholique de Louvain, Belgium
6 * Redistribution and use in source and binary forms, with or without
7 * modification, are permitted provided that the following conditions
9 * 1. Redistributions of source code must retain the above copyright
10 * notice, this list of conditions and the following disclaimer.
11 * 2. Redistributions in binary form must reproduce the above copyright
12 * notice, this list of conditions and the following disclaimer in the
13 * documentation and/or other materials provided with the distribution.
15 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS `AS IS'
16 * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
17 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
18 * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE
19 * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
20 * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
21 * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
22 * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
23 * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
24 * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
25 * POSSIBILITY OF SUCH DAMAGE.
34 typedef struct { /* Time To Sample */
39 typedef struct { /* Chunk */
45 typedef struct { /* Sample to chunk */
47 int samples_per_chunk;
49 } mj2_sampletochunk_t;
51 typedef struct { /* Sample */
52 unsigned int sample_size;
54 unsigned int sample_delta;
57 typedef struct { /* URL */
61 typedef struct { /* URN */
66 typedef struct { /* Video Track Parameters */
69 unsigned int creation_time;
70 unsigned int modification_time;
81 int slidingavgbitrate;
93 int CbCr_subsampling_dx;
94 int CbCr_subsampling_dy;
95 // int subsampling_dx;
96 // int subsampling_dy;
98 int sample_description;
101 int compressorname[8];
103 unsigned char fieldcount;
104 unsigned char fieldorder;
105 unsigned char or_fieldcount;
106 unsigned char or_fieldorder;
109 unsigned char num_jp2x;
110 unsigned char *jp2xdata;
116 unsigned int num_samples; /* Number of samples */
120 unsigned char same_sample_size;
122 mj2_tts_t *tts; /* Time to sample */
123 unsigned int num_chunks;
125 int num_samplestochunk;
126 mj2_sampletochunk_t *sampletochunk;
128 jp2_struct_t jp2_struct;
129 mj2_sample_t *sample; /* Sample parameters */
130 } mj2_tk_t; /* Track Parameters */
132 typedef struct { /* Movie */
134 unsigned int minversion;
137 unsigned int creation_time;
138 unsigned int modification_time;
140 unsigned int duration;
148 mj2_tk_t *tk; /* Track Parameters */
159 void mj2_write_ftyp(mj2_movie_t * movie);
162 * Use this function to initialize a standard movie with standard values
163 * It has one sample per chunk
165 int mj2_init_stdmovie(mj2_movie_t * movie);
168 /* int mj2_encode(mj2_movie_t * movie, j2k_cp_t * cp, char *index);
170 * Encode a MJ2 movie from a yuv file
171 * movie: an existing mj2_movie structure (to create a standard one, use mj2_init_stdmovie
172 * cp: coding parameters of j2k images
173 * index: index file name
175 int mj2_encode(mj2_movie_t * movie, j2k_cp_t * cp, char *index);
178 /* int mj2_decode(unsigned char *src, int len, mj2_movie_t * movie,
179 * j2k_cp_t * cp, char *outfile);
181 * Decode a MJ2 movie to a yuv file
182 * src: pointer to memory where frames will be stored
183 * movie: a mj2_movie structure
184 * cp: coding parameters of j2k images
185 * outfile: yuv file name
187 int mj2_decode(unsigned char *src, int len, mj2_movie_t * movie,
188 j2k_cp_t * cp, char *outfile);
192 * Free memory used to encode and decode mj2 files
195 void mj2_memory_free(mj2_movie_t * movie);
197 int mj2_read_struct(FILE *file, mj2_movie_t * movie);
199 void mj2_write_moov(mj2_movie_t * movie);