2009/3/27 chen hecky <[email protected]> > I find it in my whole system, but I don't find it's definition. :-( > -> can you explain it clearly? what do you mean by "find it in my whole system" but "can't find definition" .
> > 2009/3/27 Samul Kevin <[email protected]> > > > 2009/3/24 chen hecky <[email protected]> > > > > > Thank J Aaron Farr, > > > I have studied using Dirac(http://diracvideo.org/), which maybe > replace > > > the > > > FFmpeg, but there are some problem in compiling the programmer from the > > > programmers_guide. > > > > > > > > > > > > ////the programmer codes text.c > > > * > > > #include <errno.h> > > > #include <stdio.h> > > > #include <stdlib.h> > > > > > > > > > > > > /* Include Dirac Encoder Header file */ > > > #include <libdirac_encoder/dirac_encoder.h> > > > //#include "/usr/local/include/dirac/libdirac_encoder/dirac_encoder.h" > > > #define ENCBUF_SIZE (1024*1024) > > > int main (int argc, char **argv) > > > { > > > FILE *in; > > > FILE *out; > > > dirac_encoder_context_t enc_ctx; > > > dirac_encoder_t *encoder; > > > unsigned char *unc_frame; > > > int unc_frame_size; > > > unsigned char enc_frame[ENCBUF_SIZE]; > > > int go = 1; > > > dirac_encoder_state_t state; > > > if (argc < 3) > > > { > > > printf ("Usage : %s input-file output-file\n", argv[0]); > > > exit(0); > > > } > > > /* open input file */ > > > if ( (in = fopen (argv[1], "rb")) == NULL) > > > { > > > perror (argv[1]); > > > exit(errno); > > > } > > > /* open output file */ > > > if ( (out = fopen (argv[2], "wb")) == NULL) > > > { > > > perror (argv[2]); > > > exit(errno); > > > } > > > /* set flag to retrieve locally decoded frames from encoder */ > > > enc_ctx.decode_flag = 1; > > > /* Initialise the encoder with the encoder context */ > > > if ( (encoder = dirac_encoder_init(&enc_ctx, 0)) == NULL) > > > { > > > printf ("Error initialising the encoder\n"); > > > exit(-1); > > > } > > > /* Calculate the size of an uncompressed frame */ > > > unc_frame_size = (encoder->enc_ctx.src_params.height * > > > encoder->enc_ctx.src_params.width) + > > > 2*(encoder->enc_ctx.src_params.chroma_height > > > * encoder->enc_ctx.src_params.chroma_width); > > > /* Allocate memory for an uncompressed frame */ > > > unc_frame = (unsigned char *)malloc(unc_frame_size); > > > /* Main loop */ > > > do > > > { > > > /* > > > * Read one frame of uncompressed data into the buffer and > > > * load it into the encoder > > > */ > > > if ( fread( unc_frame, unc_frame_size, 1, in) == 1) > > > { > > > if (dirac_encoder_load( encoder, unc_frame, unc_frame_size ) < > 0) > > > { > > > fprintf (stderr, "dirac_encoder_load failed. Unrecoverable > > > error...\n"); > > > exit(-1); > > > } > > > } > > > else > > > { > > > /* signal end of sequence to encoder */ > > > dirac_encoder_end_sequence( encoder ); > > > } > > > do > > > { > > > /* > > > * Frame loaded successfully, so now set up the encode > > > * buffer in the encoder handler before calling the > > > * encoding function. > > > */ > > > encoder->enc_buf.buffer = enc_frame; > > > encoder->enc_buf.size = ENCBUF_SIZE; > > > /* Call the encoding function */ > > > state = dirac_encoder_output (encoder); > > > /* > > > * Depending on the return value of the encode function > > > * take appropriate action > > > */ > > > switch (state) > > > { > > > case ENC_STATE_AVAIL: > > > /* > > > * Encoded picture available in enc_buf. Write the > > > * buffer to the output file > > > */ > > > > > > /* Initialise the encoder context with presets for SD576I50 */ > > > dirac_encoder_context_init (&enc_ctx, VIDEO_FORMAT_SD576I50); > > > /* override some of the preset defaults */ > > > /* Set quality factor to 7.5 */ > > > enc_ctx.enc_params.qf = 7.5; > > > /* set input video type to progressive video */ > > > enc_ctx.source_params.source_sampling = 0; > > > > > > > > > fwrite (encoder->enc_buf.buffer, encoder->enc_buf.size, > > > 1, out); > > > /* > > > * In addition to the encoded picture, the following > > metadata > > > * is also available. > > > * encoded picture stats in encoder->enc_pstats > > > * encoded picture params in encoder->enc_pparams > > > */ > > > break; > > > case ENC_STATE_BUFFER: > > > /* > > > * Encoder needs more data to continue processing > > > */ > > > break; > > > case ENC_STATE_EOS: > > > /* > > > * End of sequence info available in enc_buf. Write the > > > * buffer to the output file > > > */ > > > fwrite (encoder->enc_buf.buffer, encoder->enc_buf.size, > > > 1, out); > > > /* > > > * In addition to the encoded picture, the following > > metadata > > > * is also available. > > > * encoded sequence stats in encoder->enc_seqstats > > > */ > > > break; > > > case ENC_STATE_INVALID: > > > default: > > > printf ("Irrecoverable error. quitting..."); > > > free (unc_frame); > > > dirac_encoder_close(encoder); > > > exit(-1); > > > break; > > > } > > > if (encoder->decoded_frame_avail) > > > { > > > /* > > > * Locally decoded frame available in encoder->dec_buf > > > */ > > > } > > > if (encoder->instr_data_avail) > > > { > > > /* > > > * Instrumentation data available in encoder->instr > > > */ > > > } > > > } while (state == ENC_STATE_AVAIL); > > > } while (go); > > > /* Free the encoder resources */ > > > dirac_encoder_close(encoder); > > > /* Free the uncompressed data buffer */ > > > free (unc_frame); > > > fclose (in); > > > fclose (out); > > > } > > > * > > > Some error: > > > > > > *root@:~/Desktop/Test# gcc -I/usr/local/include/dirac text.c > > > text.c: In function ‘main’: > > > > ->>missing any header file which including the definition of > > VIDEO_FORMAT_SD576I50? > > > > > > > > text.c:98: error: ‘VIDEO_FORMAT_SD576I50’ undeclared (first use in this > > > function) > > > > > > > > > > > > text.c:98: error: (Each undeclared identifier is reported only once > > > text.c:98: error: for each function it appears in.) > > > text.c:103: error: ‘dirac_encoder_context_t’ has no member named > > > ‘source_params’* > > > > > > If anyone had used Dirac, can you give some suggestions? > > > > > > > > > Hecky @ Bluesky Dev Team XJTU > > > > > > > > > > > -- > > Bowen Ma a.k.a Samul Kevin @ Bluesky Dev Team XJTU > > > > > > -- > Hecky @ Bluesky Dev Team XJTU > -- Bowen Ma a.k.a Samul Kevin @ Bluesky Dev Team XJTU
