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 */
70 unsigned int creation_time;
71 unsigned int modification_time;
82 int slidingavgbitrate;
92 int CbCr_subsampling_dx;
93 int CbCr_subsampling_dy;
97 int sample_description;
100 int compressorname[8];
102 unsigned char fieldcount;
103 unsigned char fieldorder;
104 unsigned char or_fieldcount;
105 unsigned char or_fieldorder;
108 unsigned char num_jp2x;
109 unsigned char *jp2xdata;
115 unsigned int num_samples; /* Number of samples */
119 unsigned char same_sample_size;
121 mj2_tts_t *tts; /* Time to sample */
122 unsigned int num_chunks;
124 int num_samplestochunk;
125 mj2_sampletochunk_t *sampletochunk;
127 jp2_struct_t jp2_struct;
128 mj2_sample_t *sample; /* Sample parameters */
129 } mj2_tk_t; /* Track Parameters */
131 typedef struct { /* Movie */
133 unsigned int minversion;
137 unsigned int creation_time;
138 unsigned int modification_time;
140 unsigned int duration;
148 mj2_tk_t *tk; /* Track Parameters */
158 * Use this function to initialize a standard movie with standard values
159 * It has one sample per chunk
161 int mj2_init_stdmovie(mj2_movie_t * movie);
164 /* int mj2_encode(mj2_movie_t * movie, j2k_cp_t * cp, char *index);
166 * Encode a MJ2 movie from a yuv file
167 * movie: an existing mj2_movie structure (to create a standard one, use mj2_init_stdmovie
168 * cp: coding parameters of j2k images
169 * index: index file name
171 int mj2_encode(mj2_movie_t * movie, j2k_cp_t * cp, char *index);
174 /* int mj2_decode(unsigned char *src, int len, mj2_movie_t * movie,
175 * j2k_cp_t * cp, char *outfile);
177 * Decode a MJ2 movie to a yuv file
178 * src: pointer to memory where frames will be stored
179 * movie: a mj2_movie structure
180 * cp: coding parameters of j2k images
181 * outfile: yuv file name
183 int mj2_decode(unsigned char *src, int len, mj2_movie_t * movie,
184 j2k_cp_t * cp, char *outfile);
188 * Free memory used to encode and decode mj2 files
191 void mj2_memory_free(mj2_movie_t * movie);