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;
91 int CbCr_subsampling_dx;
92 int CbCr_subsampling_dy;
93 // int subsampling_dx;
94 // int subsampling_dy;
96 int sample_description;
99 int compressorname[8];
101 unsigned char fieldcount;
102 unsigned char fieldorder;
103 unsigned char or_fieldcount;
104 unsigned char or_fieldorder;
107 unsigned char num_jp2x;
108 unsigned char *jp2xdata;
114 unsigned int num_samples; /* Number of samples */
118 unsigned char same_sample_size;
120 mj2_tts_t *tts; /* Time to sample */
121 unsigned int num_chunks;
123 int num_samplestochunk;
124 mj2_sampletochunk_t *sampletochunk;
126 jp2_struct_t jp2_struct;
127 mj2_sample_t *sample; /* Sample parameters */
128 } mj2_tk_t; /* Track Parameters */
130 typedef struct { /* Movie */
132 unsigned int minversion;
135 unsigned int creation_time;
136 unsigned int modification_time;
138 unsigned int duration;
146 mj2_tk_t *tk; /* Track Parameters */
157 void mj2_write_ftyp(mj2_movie_t * movie);
160 * Use this function to initialize a standard movie with standard values
161 * It has one sample per chunk
163 int mj2_init_stdmovie(mj2_movie_t * movie);
166 /* int mj2_encode(mj2_movie_t * movie, j2k_cp_t * cp, char *index);
168 * Encode a MJ2 movie from a yuv file
169 * movie: an existing mj2_movie structure (to create a standard one, use mj2_init_stdmovie
170 * cp: coding parameters of j2k images
171 * index: index file name
173 int mj2_encode(mj2_movie_t * movie, j2k_cp_t * cp, char *index);
176 /* int mj2_decode(unsigned char *src, int len, mj2_movie_t * movie,
177 * j2k_cp_t * cp, char *outfile);
179 * Decode a MJ2 movie to a yuv file
180 * src: pointer to memory where frames will be stored
181 * movie: a mj2_movie structure
182 * cp: coding parameters of j2k images
183 * outfile: yuv file name
185 int mj2_decode(unsigned char *src, int len, mj2_movie_t * movie,
186 j2k_cp_t * cp, char *outfile);
190 * Free memory used to encode and decode mj2 files
193 void mj2_memory_free(mj2_movie_t * movie);
195 int mj2_read_struct(FILE *file, mj2_movie_t * movie);
197 void mj2_write_moov(mj2_movie_t * movie);