00001 /* ***** BEGIN LICENSE BLOCK ***** 00002 * 00003 * $Id: dirac_encoder.h,v 1.1 2005/01/30 05:11:41 gabest Exp $ $Name: $ 00004 * 00005 * Version: MPL 1.1/GPL 2.0/LGPL 2.1 00006 * 00007 * The contents of this file are subject to the Mozilla Public License 00008 * Version 1.1 (the "License"); you may not use this file except in compliance 00009 * with the License. You may obtain a copy of the License at 00010 * http://www.mozilla.org/MPL/ 00011 * 00012 * Software distributed under the License is distributed on an "AS IS" basis, 00013 * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License for 00014 * the specific language governing rights and limitations under the License. 00015 * 00016 * The Original Code is BBC Research and Development code. 00017 * 00018 * The Initial Developer of the Original Code is the British Broadcasting 00019 * Corporation. 00020 * Portions created by the Initial Developer are Copyright (C) 2004. 00021 * All Rights Reserved. 00022 * 00023 * Contributor(s): Anuradha Suraparaju (Original Author) 00024 * 00025 * Alternatively, the contents of this file may be used under the terms of 00026 * the GNU General Public License Version 2 (the "GPL"), or the GNU Lesser 00027 * Public License Version 2.1 (the "LGPL"), in which case the provisions of 00028 * the GPL or the LGPL are applicable instead of those above. If you wish to 00029 * allow use of your version of this file only under the terms of the either 00030 * the GPL or LGPL and not to allow others to use your version of this file 00031 * under the MPL, indicate your decision by deleting the provisions above 00032 * and replace them with the notice and other provisions required by the GPL 00033 * or LGPL. If you do not delete the provisions above, a recipient may use 00034 * your version of this file under the terms of any one of the MPL, the GPL 00035 * or the LGPL. 00036 * ***** END LICENSE BLOCK ***** */ 00037 00038 #ifndef DIRAC_ENCODER_H 00039 #define DIRAC_ENCODER_H 00040 00041 #include <libdirac_common/dirac_types.h> 00042 00141 #ifdef __cplusplus 00142 extern "C" { 00143 #endif 00144 00146 typedef enum 00147 { 00148 ENC_STATE_INVALID = -1, 00149 ENC_STATE_BUFFER, 00150 ENC_STATE_AVAIL 00151 } dirac_encoder_state_t ; 00152 00155 typedef enum 00156 { 00157 CIF, 00158 SD576, 00159 HD720, 00160 HD1080 00161 } dirac_encoder_presets_t; 00162 00164 typedef struct 00165 { 00167 float qf; 00169 int L1_sep; 00173 int num_L1; 00175 float cpd; 00177 int xblen; 00179 int yblen; 00181 int xbsep; 00183 int ybsep; 00184 } dirac_encparams_t; 00185 00187 typedef struct 00188 { 00190 dirac_seqparams_t seq_params; 00192 dirac_encparams_t enc_params; 00194 int instr_flag; 00197 int decode_flag; 00198 } dirac_encoder_context_t; 00199 00282 extern DllExport void dirac_encoder_context_init (dirac_encoder_context_t *enc_ctx, dirac_encoder_presets_t preset); 00283 00284 00286 typedef struct 00287 { 00289 unsigned char *buffer; 00291 int size; 00292 } dirac_enc_data_t; 00293 00295 typedef struct 00296 { 00298 unsigned int mv_bits; 00300 unsigned int mv_hdr_bits; 00302 unsigned int ycomp_bits; 00304 unsigned int ycomp_hdr_bits; 00306 unsigned int ucomp_bits; 00308 unsigned int ucomp_hdr_bits; 00310 unsigned int vcomp_bits; 00312 unsigned int vcomp_hdr_bits; 00314 unsigned int frame_bits; 00316 unsigned int frame_hdr_bits; 00317 } dirac_enc_framestats_t; 00318 00320 typedef struct 00321 { 00323 unsigned int mv_bits; 00325 unsigned int seq_bits; 00327 unsigned int seq_hdr_bits; 00329 unsigned int ycomp_bits; 00331 unsigned int ucomp_bits; 00333 unsigned int vcomp_bits; 00335 unsigned int bit_rate; 00336 } dirac_enc_seqstats_t; 00337 00339 typedef struct 00340 { 00342 int x; 00344 int y; 00345 } dirac_mv_t; 00346 00348 typedef struct 00349 { 00351 float SAD; 00353 float mvcost; 00354 } dirac_mv_cost_t; 00355 00357 typedef struct 00358 { 00360 dirac_frame_type_t ftype; 00362 int fnum; 00364 int num_refs; 00366 int refs[2]; 00368 int xbsep; 00370 int ybsep; 00372 int mb_xlen; 00374 int mb_ylen; 00376 int mv_xlen; 00378 int mv_ylen; 00380 int *mb_split_mode; 00382 int *mb_common_mode; 00384 float *mb_costs; 00386 int *pred_mode; 00388 float *intra_costs; 00390 dirac_mv_cost_t *bipred_costs; 00392 short *dc_ycomp; 00394 short *dc_ucomp; 00396 short *dc_vcomp; 00398 dirac_mv_t *mv[2]; 00400 dirac_mv_cost_t *pred_costs[2]; 00401 } dirac_instr_t; 00402 00404 typedef struct 00405 { 00407 dirac_encoder_context_t enc_ctx; 00408 00410 int encoded_frame_avail; 00411 00416 dirac_enc_data_t enc_buf; 00417 00419 dirac_frameparams_t enc_fparams; 00420 00422 dirac_enc_framestats_t enc_fstats; 00423 00425 dirac_enc_seqstats_t enc_seqstats; 00426 00428 int end_of_sequence; 00429 00430 /* locally decoded frame available flag. 00431 1 - locally decoded frame available in dec_buf. 00432 0 - locally decoded frame not available. 00433 */ 00434 int decoded_frame_avail; 00435 00440 dirac_framebuf_t dec_buf; 00441 00443 dirac_frameparams_t dec_fparams; 00444 00448 dirac_instr_t instr; 00449 00454 int instr_data_avail; 00455 00457 const void *compressor; 00458 } dirac_encoder_t; 00459 00466 extern DllExport dirac_encoder_t *dirac_encoder_init (const dirac_encoder_context_t *enc_ctx, int verbose); 00467 00477 extern DllExport int dirac_encoder_load (dirac_encoder_t *encoder, unsigned char *uncdata, int uncdata_size); 00478 00488 extern DllExport dirac_encoder_state_t dirac_encoder_output (dirac_encoder_t *encoder); 00489 00497 extern DllExport int dirac_encoder_end_sequence (dirac_encoder_t *encoder); 00498 00503 extern DllExport void dirac_encoder_close (dirac_encoder_t *encoder); 00504 00505 #endif 00506 #ifdef __cplusplus 00507 } 00508 #endif