# Dirac - A Video Codec

Created by the British Broadcasting Corporation.

dirac_encoder.h
Go to the documentation of this file.
1 /* ***** BEGIN LICENSE BLOCK *****
2 *
3 * $Id: dirac_encoder.h,v 1.28 2008/11/18 23:25:54 asuraparaju Exp $ $Name: Dirac_1_0_2 $
4 *
5 * Version: MPL 1.1/GPL 2.0/LGPL 2.1
6 *
7 * The contents of this file are subject to the Mozilla Public License
8 * Version 1.1 (the "License"); you may not use this file except in compliance
9 * with the License. You may obtain a copy of the License at
10 * http://www.mozilla.org/MPL/
11 *
12 * Software distributed under the License is distributed on an "AS IS" basis,
13 * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License for
14 * the specific language governing rights and limitations under the License.
15 *
16 * The Original Code is BBC Research and Development code.
17 *
18 * The Initial Developer of the Original Code is the British Broadcasting
19 * Corporation.
20 * Portions created by the Initial Developer are Copyright (C) 2004.
21 * All Rights Reserved.
22 *
23 * Contributor(s): Anuradha Suraparaju (Original Author)
24 * Andrew Kennedy,
25 * Thomas Davies
26 * Myo Tun (Brunel University, myo.tun@brunel.ac.uk)
27 *
28 * Alternatively, the contents of this file may be used under the terms of
29 * the GNU General Public License Version 2 (the "GPL"), or the GNU Lesser
30 * Public License Version 2.1 (the "LGPL"), in which case the provisions of
31 * the GPL or the LGPL are applicable instead of those above. If you wish to
32 * allow use of your version of this file only under the terms of the either
33 * the GPL or LGPL and not to allow others to use your version of this file
34 * under the MPL, indicate your decision by deleting the provisions above
35 * and replace them with the notice and other provisions required by the GPL
36 * or LGPL. If you do not delete the provisions above, a recipient may use
37 * your version of this file under the terms of any one of the MPL, the GPL
38 * or the LGPL.
39 * ***** END LICENSE BLOCK ***** */
40
41 #ifndef DIRAC_ENCODER_H
42 #define DIRAC_ENCODER_H
43
44 #include <libdirac_common/dirac_inttypes.h>
45 #include <libdirac_common/dirac_types.h>
46
151 #ifdef __cplusplus
152 extern "C" {
153 #endif
154
156 typedef enum
157 {
158 ENC_STATE_INVALID = -1,
159 ENC_STATE_BUFFER,
160 ENC_STATE_AVAIL,
161 ENC_STATE_EOS
162 } dirac_encoder_state_t ;
163
166 typedef PrefilterType dirac_prefilter_t;
167
170 typedef VideoFormat dirac_encoder_presets_t;
171
174 typedef MVPrecisionType dirac_mvprecision_t;
176 typedef struct
177 {
179 int lossless;
181 float qf;
183 int full_search;
185 int combined_me;
187 int x_range_me;
189 int y_range_me;
191 int L1_sep;
195 int num_L1;
197 float cpd;
199 int xblen;
201 int yblen;
203 int xbsep;
205 int ybsep;
207 int video_format;
209 dirac_wlt_filter_t intra_wlt_filter;
211 dirac_wlt_filter_t inter_wlt_filter;
213 unsigned int wlt_depth;
215 unsigned int spatial_partition;
217 dirac_prefilter_t prefilter;
219 unsigned int prefilter_strength;
221 unsigned int multi_quants;
223 dirac_mvprecision_t mv_precision;
225 int trate;
227 unsigned int picture_coding_mode;
229 int using_ac;
230 } dirac_encparams_t;
231
233 typedef struct
234 {
236 dirac_sourceparams_t src_params;
238 dirac_encparams_t enc_params;
240 int instr_flag;
243 int decode_flag;
244 } dirac_encoder_context_t;
245
258 extern DllExport void dirac_encoder_context_init (dirac_encoder_context_t *enc_ctx, dirac_encoder_presets_t preset);
259
260
262 typedef struct
263 {
265 unsigned char *buffer;
267 int size;
268 } dirac_enc_data_t;
269
271 typedef struct
272 {
274 unsigned int mv_bits;
276 unsigned int ycomp_bits;
278 unsigned int ucomp_bits;
280 unsigned int vcomp_bits;
282 unsigned int pic_bits;
283 } dirac_enc_picstats_t;
284
286 typedef struct
287 {
289 int64_t mv_bits;
291 int64_t seq_bits;
293 int64_t ycomp_bits;
295 int64_t ucomp_bits;
297 int64_t vcomp_bits;
299 int64_t bit_rate;
300 } dirac_enc_seqstats_t;
301
303 typedef struct
304 {
306 int x;
308 int y;
309 } dirac_mv_t;
310
312 typedef struct
313 {
315 float SAD;
317 float mvcost;
318 } dirac_mv_cost_t;
319
321 typedef struct
322 {
324 dirac_picture_type_t ptype;
326 dirac_reference_type_t rtype;
328 int pnum;
330 int num_refs;
332 int refs[2];
334 int xbsep;
336 int ybsep;
338 int sb_xlen;
340 int sb_ylen;
342 int mv_xlen;
344 int mv_ylen;
346 int *sb_split_mode;
348 float *sb_costs;
350 int *pred_mode;
352 float *intra_costs;
354 dirac_mv_cost_t *bipred_costs;
356 short *dc_ycomp;
358 short *dc_ucomp;
360 short *dc_vcomp;
362 dirac_mv_t *mv[2];
364 dirac_mv_cost_t *pred_costs[2];
365 } dirac_instr_t;
366
368 typedef struct
369 {
371 dirac_encoder_context_t enc_ctx;
372
374 int encoded_picture_avail;
375
380 dirac_enc_data_t enc_buf;
381
383 dirac_picparams_t enc_pparams;
384
386 dirac_enc_picstats_t enc_pstats;
387
389 dirac_enc_seqstats_t enc_seqstats;
390
392 int end_of_sequence;
393
394 /* locally decoded frame (NB: not picture) available flag.
395 1 - locally decoded frame available in dec_buf.
396 0 - locally decoded frame not available.
397 */
398 int decoded_frame_avail;
399
404 dirac_framebuf_t dec_buf;
405
407 dirac_picparams_t dec_pparams;
408
412 dirac_instr_t instr;
413
418 int instr_data_avail;
419
421 const void *compressor;
422 } dirac_encoder_t;
423
430 extern DllExport dirac_encoder_t *dirac_encoder_init (const dirac_encoder_context_t *enc_ctx, int verbose);
431
432 #if DIRAC_RESEARCH_VERSION_ATLEAST(1,0,2)
433
440 extern DllExport int dirac_encoder_pts_offset (const dirac_encoder_t *encoder);
441 #endif
442
452 extern DllExport int dirac_encoder_load (dirac_encoder_t *encoder, unsigned char *uncdata, int uncdata_size);
453
464 extern DllExport dirac_encoder_state_t dirac_encoder_output (dirac_encoder_t *encoder);
465
470 extern DllExport void dirac_encoder_end_sequence (dirac_encoder_t *encoder);
471
476 extern DllExport void dirac_encoder_close (dirac_encoder_t *encoder);
477
478 #endif
479 #ifdef __cplusplus
480 }
481 #endif
ENC_STATE_AVAIL
Definition: dirac_encoder.h:160
dirac_encoder_context_t::enc_params
dirac_encparams_t enc_params
Definition: dirac_encoder.h:238
dirac_encoder_t::enc_pparams
dirac_picparams_t enc_pparams
Definition: dirac_encoder.h:383
dirac_instr_t::dc_ycomp
short * dc_ycomp
Definition: dirac_encoder.h:356
dirac_encoder_t::instr
dirac_instr_t instr
Definition: dirac_encoder.h:412
dirac_encparams_t
Definition: dirac_encoder.h:176
dirac_encoder_end_sequence
DllExport void dirac_encoder_end_sequence(dirac_encoder_t *encoder)
dirac_encparams_t::video_format
int video_format
Definition: dirac_encoder.h:207
dirac_mv_cost_t
Definition: dirac_encoder.h:312
dirac_encoder_init
DllExport dirac_encoder_t * dirac_encoder_init(const dirac_encoder_context_t *enc_ctx, int verbose)
dirac_enc_seqstats_t::bit_rate
int64_t bit_rate
Definition: dirac_encoder.h:299
dirac_encoder_t::end_of_sequence
int end_of_sequence
Definition: dirac_encoder.h:392
dirac_encoder_t::enc_pstats
dirac_enc_picstats_t enc_pstats
Definition: dirac_encoder.h:386
dirac_encparams_t::trate
int trate
Definition: dirac_encoder.h:225
dirac_encparams_t::wlt_depth
unsigned int wlt_depth
Definition: dirac_encoder.h:213
dirac_enc_data_t::size
int size
Definition: dirac_encoder.h:267
dirac_instr_t::sb_costs
float * sb_costs
Definition: dirac_encoder.h:348
dirac_enc_picstats_t
Definition: dirac_encoder.h:271
dirac_instr_t::dc_vcomp
short * dc_vcomp
Definition: dirac_encoder.h:360
dirac_encoder_t::enc_seqstats
dirac_enc_seqstats_t enc_seqstats
Definition: dirac_encoder.h:389
dirac_mv_cost_t::SAD
float SAD
Definition: dirac_encoder.h:315
dirac_encparams_t::L1_sep
int L1_sep
Definition: dirac_encoder.h:191
MVPrecisionType
MVPrecisionType
Definition: common_types.h:189
dirac_instr_t::mv_ylen
int mv_ylen
Definition: dirac_encoder.h:344
dirac_instr_t::intra_costs
float * intra_costs
Definition: dirac_encoder.h:352
dirac_encoder_context_t::instr_flag
int instr_flag
Definition: dirac_encoder.h:240
dirac_encparams_t::inter_wlt_filter
dirac_wlt_filter_t inter_wlt_filter
Definition: dirac_encoder.h:211
dirac_instr_t::bipred_costs
dirac_mv_cost_t * bipred_costs
Definition: dirac_encoder.h:354
ReferenceType
ReferenceType
Definition: common_types.h:92
dirac_encparams_t::using_ac
int using_ac
Definition: dirac_encoder.h:229
DllExport
#define DllExport
Definition: dirac_types.h:55
ENC_STATE_INVALID
Definition: dirac_encoder.h:158
dirac_encparams_t::spatial_partition
unsigned int spatial_partition
Definition: dirac_encoder.h:215
dirac_instr_t::num_refs
int num_refs
Definition: dirac_encoder.h:330
dirac_encoder_t::dec_pparams
dirac_picparams_t dec_pparams
Definition: dirac_encoder.h:407
dirac_mv_t
Definition: dirac_encoder.h:303
dirac_instr_t::dc_ucomp
short * dc_ucomp
Definition: dirac_encoder.h:358
dirac_encoder_state_t
dirac_encoder_state_t
Definition: dirac_encoder.h:156
dirac_encparams_t::xbsep
int xbsep
Definition: dirac_encoder.h:203
dirac_instr_t
Definition: dirac_encoder.h:321
dirac_instr_t::xbsep
int xbsep
Definition: dirac_encoder.h:334
dirac_enc_picstats_t::ycomp_bits
unsigned int ycomp_bits
Definition: dirac_encoder.h:276
dirac_encoder_t::compressor
const void * compressor
Definition: dirac_encoder.h:421
dirac_prefilter_t
PrefilterType dirac_prefilter_t
Definition: dirac_encoder.h:166
dirac_encparams_t::qf
float qf
Definition: dirac_encoder.h:181
VideoFormat
VideoFormat
Definition: common_types.h:98
dirac_encoder_t::encoded_picture_avail
int encoded_picture_avail
Definition: dirac_encoder.h:374
dirac_enc_data_t::buffer
unsigned char * buffer
Definition: dirac_encoder.h:265
dirac_instr_t::sb_ylen
int sb_ylen
Definition: dirac_encoder.h:340
dirac_encparams_t::xblen
int xblen
Definition: dirac_encoder.h:199
dirac_encoder_t
Definition: dirac_encoder.h:368
dirac_encparams_t::lossless
int lossless
Definition: dirac_encoder.h:179
dirac_enc_picstats_t::pic_bits
unsigned int pic_bits
Definition: dirac_encoder.h:282
dirac_enc_seqstats_t::mv_bits
int64_t mv_bits
Definition: dirac_encoder.h:289
dirac_encoder_t::dec_buf
dirac_framebuf_t dec_buf
Definition: dirac_encoder.h:404
dirac_instr_t::pnum
int pnum
Definition: dirac_encoder.h:328
dirac_enc_picstats_t::mv_bits
unsigned int mv_bits
Definition: dirac_encoder.h:274
dirac_encparams_t::prefilter
dirac_prefilter_t prefilter
Definition: dirac_encoder.h:217
dirac_encoder_t::enc_buf
dirac_enc_data_t enc_buf
Definition: dirac_encoder.h:380
dirac_inttypes.h
dirac_instr_t::ptype
dirac_picture_type_t ptype
Definition: dirac_encoder.h:324
dirac_enc_seqstats_t::ycomp_bits
int64_t ycomp_bits
Definition: dirac_encoder.h:293
ENC_STATE_BUFFER
Definition: dirac_encoder.h:159
dirac_enc_data_t
Definition: dirac_encoder.h:262
dirac_encoder_t::instr_data_avail
int instr_data_avail
Definition: dirac_encoder.h:418
dirac_encparams_t::full_search
int full_search
Definition: dirac_encoder.h:183
dirac_encparams_t::prefilter_strength
unsigned int prefilter_strength
Definition: dirac_encoder.h:219
dirac_mvprecision_t
MVPrecisionType dirac_mvprecision_t
Definition: dirac_encoder.h:174
dirac_encoder_context_t
Definition: dirac_encoder.h:233
dirac_encparams_t::y_range_me
int y_range_me
Definition: dirac_encoder.h:189
ENC_STATE_EOS
Definition: dirac_encoder.h:161
dirac_encoder_context_t::src_params
dirac_sourceparams_t src_params
Definition: dirac_encoder.h:236
dirac_encparams_t::yblen
int yblen
Definition: dirac_encoder.h:201
dirac_encparams_t::picture_coding_mode
unsigned int picture_coding_mode
Definition: dirac_encoder.h:227
dirac_enc_seqstats_t::seq_bits
int64_t seq_bits
Definition: dirac_encoder.h:291
dirac_encparams_t::x_range_me
int x_range_me
Definition: dirac_encoder.h:187
dirac_framebuf_t
Definition: dirac_types.h:186
dirac_encparams_t::combined_me
int combined_me
Definition: dirac_encoder.h:185
dirac_mv_cost_t::mvcost
float mvcost
Definition: dirac_encoder.h:317
dirac_encoder_output
DllExport dirac_encoder_state_t dirac_encoder_output(dirac_encoder_t *encoder)
dirac_enc_seqstats_t::ucomp_bits
int64_t ucomp_bits
Definition: dirac_encoder.h:295
dirac_picparams_t
Definition: dirac_types.h:173
dirac_encoder_context_init
DllExport void dirac_encoder_context_init(dirac_encoder_context_t *enc_ctx, dirac_encoder_presets_t preset)
dirac_encoder_context_t::decode_flag
int decode_flag
Definition: dirac_encoder.h:243
dirac_mv_t::x
int x
Definition: dirac_encoder.h:306
dirac_encparams_t::num_L1
int num_L1
Definition: dirac_encoder.h:195
dirac_mv_t::y
int y
Definition: dirac_encoder.h:308
WltFilter
WltFilter
Definition: common_types.h:61
dirac_instr_t::pred_mode
int * pred_mode
Definition: dirac_encoder.h:350
dirac_enc_seqstats_t::vcomp_bits
int64_t vcomp_bits
Definition: dirac_encoder.h:297
dirac_instr_t::sb_xlen
int sb_xlen
Definition: dirac_encoder.h:338
dirac_encparams_t::multi_quants
unsigned int multi_quants
Definition: dirac_encoder.h:221
PrefilterType
PrefilterType
Definition: common_types.h:75
dirac_encparams_t::cpd
float cpd
Definition: dirac_encoder.h:197
dirac_instr_t::rtype
dirac_reference_type_t rtype
Definition: dirac_encoder.h:326
dirac_encparams_t::intra_wlt_filter
dirac_wlt_filter_t intra_wlt_filter
Definition: dirac_encoder.h:209
dirac_instr_t::ybsep
int ybsep
Definition: dirac_encoder.h:336
PictureType
PictureType
Definition: common_types.h:86
dirac_encoder_load
DllExport int dirac_encoder_load(dirac_encoder_t *encoder, unsigned char *uncdata, int uncdata_size)
dirac_encparams_t::ybsep
int ybsep
Definition: dirac_encoder.h:205
dirac_instr_t::mv_xlen
int mv_xlen
Definition: dirac_encoder.h:342
dirac_enc_picstats_t::ucomp_bits
unsigned int ucomp_bits
Definition: dirac_encoder.h:278
dirac_encoder_presets_t
VideoFormat dirac_encoder_presets_t
Definition: dirac_encoder.h:170
dirac_types.h
dirac_encoder_t::decoded_frame_avail
int decoded_frame_avail
Definition: dirac_encoder.h:398
dirac_sourceparams_t
Definition: dirac_types.h:143
dirac_instr_t::sb_split_mode
int * sb_split_mode
Definition: dirac_encoder.h:346
dirac_encoder_close
DllExport void dirac_encoder_close(dirac_encoder_t *encoder)
dirac_encoder_t::enc_ctx
dirac_encoder_context_t enc_ctx
Definition: dirac_encoder.h:371
dirac_encparams_t::mv_precision
dirac_mvprecision_t mv_precision
Definition: dirac_encoder.h:223
dirac_enc_seqstats_t
Definition: dirac_encoder.h:286
dirac_enc_picstats_t::vcomp_bits
unsigned int vcomp_bits
Definition: dirac_encoder.h:280

© 2004 British Broadcasting Corporation. Dirac code licensed under the Mozilla Public License (MPL) Version 1.1.
HTML documentation generated by Dimitri van Heesch's excellent Doxygen tool.