comparison libxvidff.c @ 8315:7ccdcc976edd libavcodec

Do not invade _t POSIX namespace.
author diego
date Sat, 13 Dec 2008 18:16:06 +0000
parents cf4d575b1982
children 19e2f1a50aa7
comparison
equal deleted inserted replaced
8314:e983153e2d72 8315:7ccdcc976edd
42 42
43 /** 43 /**
44 * Structure for the private Xvid context. 44 * Structure for the private Xvid context.
45 * This stores all the private context for the codec. 45 * This stores all the private context for the codec.
46 */ 46 */
47 typedef struct xvid_context { 47 struct xvid_context {
48 void *encoder_handle; /** Handle for Xvid encoder */ 48 void *encoder_handle; /** Handle for Xvid encoder */
49 int xsize, ysize; /** Frame size */ 49 int xsize, ysize; /** Frame size */
50 int vop_flags; /** VOP flags for Xvid encoder */ 50 int vop_flags; /** VOP flags for Xvid encoder */
51 int vol_flags; /** VOL flags for Xvid encoder */ 51 int vol_flags; /** VOL flags for Xvid encoder */
52 int me_flags; /** Motion Estimation flags */ 52 int me_flags; /** Motion Estimation flags */
56 char *twopassbuffer; /** Character buffer for two-pass */ 56 char *twopassbuffer; /** Character buffer for two-pass */
57 char *old_twopassbuffer; /** Old character buffer (two-pass) */ 57 char *old_twopassbuffer; /** Old character buffer (two-pass) */
58 char *twopassfile; /** second pass temp file name */ 58 char *twopassfile; /** second pass temp file name */
59 unsigned char *intra_matrix; /** P-Frame Quant Matrix */ 59 unsigned char *intra_matrix; /** P-Frame Quant Matrix */
60 unsigned char *inter_matrix; /** I-Frame Quant Matrix */ 60 unsigned char *inter_matrix; /** I-Frame Quant Matrix */
61 } xvid_context_t; 61 };
62 62
63 /** 63 /**
64 * Structure for the private first-pass plugin. 64 * Structure for the private first-pass plugin.
65 */ 65 */
66 typedef struct xvid_ff_pass1 { 66 struct xvid_ff_pass1 {
67 int version; /** Xvid version */ 67 int version; /** Xvid version */
68 xvid_context_t *context; /** Pointer to private context */ 68 struct xvid_context *context; /** Pointer to private context */
69 } xvid_ff_pass1_t; 69 };
70 70
71 /* Prototypes - See function implementation for details */ 71 /* Prototypes - See function implementation for details */
72 int xvid_strip_vol_header(AVCodecContext *avctx, unsigned char *frame, unsigned int header_len, unsigned int frame_len); 72 int xvid_strip_vol_header(AVCodecContext *avctx, unsigned char *frame, unsigned int header_len, unsigned int frame_len);
73 int xvid_ff_2pass(void *ref, int opt, void *p1, void *p2); 73 int xvid_ff_2pass(void *ref, int opt, void *p1, void *p2);
74 void xvid_correct_framerate(AVCodecContext *avctx); 74 void xvid_correct_framerate(AVCodecContext *avctx);
82 * @return Returns 0 on success, -1 on failure 82 * @return Returns 0 on success, -1 on failure
83 */ 83 */
84 av_cold int ff_xvid_encode_init(AVCodecContext *avctx) { 84 av_cold int ff_xvid_encode_init(AVCodecContext *avctx) {
85 int xerr, i; 85 int xerr, i;
86 int xvid_flags = avctx->flags; 86 int xvid_flags = avctx->flags;
87 xvid_context_t *x = avctx->priv_data; 87 struct xvid_context *x = avctx->priv_data;
88 uint16_t *intra, *inter; 88 uint16_t *intra, *inter;
89 int fd; 89 int fd;
90 90
91 xvid_plugin_single_t single; 91 xvid_plugin_single_t single;
92 xvid_ff_pass1_t rc2pass1; 92 struct xvid_ff_pass1 rc2pass1;
93 xvid_plugin_2pass2_t rc2pass2; 93 xvid_plugin_2pass2_t rc2pass2;
94 xvid_gbl_init_t xvid_gbl_init; 94 xvid_gbl_init_t xvid_gbl_init;
95 xvid_enc_create_t xvid_enc_create; 95 xvid_enc_create_t xvid_enc_create;
96 xvid_enc_plugin_t plugins[7]; 96 xvid_enc_plugin_t plugins[7];
97 97
206 x->twopassbuffer = NULL; 206 x->twopassbuffer = NULL;
207 x->old_twopassbuffer = NULL; 207 x->old_twopassbuffer = NULL;
208 x->twopassfile = NULL; 208 x->twopassfile = NULL;
209 209
210 if( xvid_flags & CODEC_FLAG_PASS1 ) { 210 if( xvid_flags & CODEC_FLAG_PASS1 ) {
211 memset(&rc2pass1, 0, sizeof(xvid_ff_pass1_t)); 211 memset(&rc2pass1, 0, sizeof(struct xvid_ff_pass1));
212 rc2pass1.version = XVID_VERSION; 212 rc2pass1.version = XVID_VERSION;
213 rc2pass1.context = x; 213 rc2pass1.context = x;
214 x->twopassbuffer = av_malloc(BUFFER_SIZE); 214 x->twopassbuffer = av_malloc(BUFFER_SIZE);
215 x->old_twopassbuffer = av_malloc(BUFFER_SIZE); 215 x->old_twopassbuffer = av_malloc(BUFFER_SIZE);
216 if( x->twopassbuffer == NULL || x->old_twopassbuffer == NULL ) { 216 if( x->twopassbuffer == NULL || x->old_twopassbuffer == NULL ) {
368 */ 368 */
369 int ff_xvid_encode_frame(AVCodecContext *avctx, 369 int ff_xvid_encode_frame(AVCodecContext *avctx,
370 unsigned char *frame, int buf_size, void *data) { 370 unsigned char *frame, int buf_size, void *data) {
371 int xerr, i; 371 int xerr, i;
372 char *tmp; 372 char *tmp;
373 xvid_context_t *x = avctx->priv_data; 373 struct xvid_context *x = avctx->priv_data;
374 AVFrame *picture = data; 374 AVFrame *picture = data;
375 AVFrame *p = &(x->encoded_picture); 375 AVFrame *p = &(x->encoded_picture);
376 376
377 xvid_enc_frame_t xvid_enc_frame; 377 xvid_enc_frame_t xvid_enc_frame;
378 xvid_enc_stats_t xvid_enc_stats; 378 xvid_enc_stats_t xvid_enc_stats;
473 * 473 *
474 * @param avctx AVCodecContext pointer to context 474 * @param avctx AVCodecContext pointer to context
475 * @return Returns 0, success guaranteed 475 * @return Returns 0, success guaranteed
476 */ 476 */
477 av_cold int ff_xvid_encode_close(AVCodecContext *avctx) { 477 av_cold int ff_xvid_encode_close(AVCodecContext *avctx) {
478 xvid_context_t *x = avctx->priv_data; 478 struct xvid_context *x = avctx->priv_data;
479 479
480 xvid_encore(x->encoder_handle, XVID_ENC_DESTROY, NULL, NULL); 480 xvid_encore(x->encoder_handle, XVID_ENC_DESTROY, NULL, NULL);
481 481
482 if( avctx->extradata != NULL ) 482 if( avctx->extradata != NULL )
483 av_free(avctx->extradata); 483 av_free(avctx->extradata);
614 * @param handle Private context handle 614 * @param handle Private context handle
615 * @return Returns XVID_ERR_xxxx on failure, or 0 on success. 615 * @return Returns XVID_ERR_xxxx on failure, or 0 on success.
616 */ 616 */
617 static int xvid_ff_2pass_create(xvid_plg_create_t * param, 617 static int xvid_ff_2pass_create(xvid_plg_create_t * param,
618 void ** handle) { 618 void ** handle) {
619 xvid_ff_pass1_t *x = (xvid_ff_pass1_t *)param->param; 619 struct xvid_ff_pass1 *x = (struct xvid_ff_pass1 *)param->param;
620 char *log = x->context->twopassbuffer; 620 char *log = x->context->twopassbuffer;
621 621
622 /* Do a quick bounds check */ 622 /* Do a quick bounds check */
623 if( log == NULL ) 623 if( log == NULL )
624 return XVID_ERR_FAIL; 624 return XVID_ERR_FAIL;
643 * 643 *
644 * @param ref Context pointer for the plugin 644 * @param ref Context pointer for the plugin
645 * @param param Destrooy context 645 * @param param Destrooy context
646 * @return Returns 0, success guaranteed 646 * @return Returns 0, success guaranteed
647 */ 647 */
648 static int xvid_ff_2pass_destroy(xvid_context_t *ref, 648 static int xvid_ff_2pass_destroy(struct xvid_context *ref,
649 xvid_plg_destroy_t *param) { 649 xvid_plg_destroy_t *param) {
650 /* Currently cannot think of anything to do on destruction */ 650 /* Currently cannot think of anything to do on destruction */
651 /* Still, the framework should be here for reference/use */ 651 /* Still, the framework should be here for reference/use */
652 if( ref->twopassbuffer != NULL ) 652 if( ref->twopassbuffer != NULL )
653 ref->twopassbuffer[0] = 0; 653 ref->twopassbuffer[0] = 0;
659 * 659 *
660 * @param ref Context pointer for the plugin 660 * @param ref Context pointer for the plugin
661 * @param param Frame data 661 * @param param Frame data
662 * @return Returns 0, success guaranteed 662 * @return Returns 0, success guaranteed
663 */ 663 */
664 static int xvid_ff_2pass_before(xvid_context_t *ref, 664 static int xvid_ff_2pass_before(struct xvid_context *ref,
665 xvid_plg_data_t *param) { 665 xvid_plg_data_t *param) {
666 int motion_remove; 666 int motion_remove;
667 int motion_replacements; 667 int motion_replacements;
668 int vop_remove; 668 int vop_remove;
669 669
702 * 702 *
703 * @param ref Context pointer for the plugin 703 * @param ref Context pointer for the plugin
704 * @param param Statistic data 704 * @param param Statistic data
705 * @return Returns XVID_ERR_xxxx on failure, or 0 on success 705 * @return Returns XVID_ERR_xxxx on failure, or 0 on success
706 */ 706 */
707 static int xvid_ff_2pass_after(xvid_context_t *ref, 707 static int xvid_ff_2pass_after(struct xvid_context *ref,
708 xvid_plg_data_t *param) { 708 xvid_plg_data_t *param) {
709 char *log = ref->twopassbuffer; 709 char *log = ref->twopassbuffer;
710 char *frame_types = " ipbs"; 710 char *frame_types = " ipbs";
711 char frame_type; 711 char frame_type;
712 712
768 */ 768 */
769 AVCodec libxvid_encoder = { 769 AVCodec libxvid_encoder = {
770 "libxvid", 770 "libxvid",
771 CODEC_TYPE_VIDEO, 771 CODEC_TYPE_VIDEO,
772 CODEC_ID_XVID, 772 CODEC_ID_XVID,
773 sizeof(xvid_context_t), 773 sizeof(struct xvid_context),
774 ff_xvid_encode_init, 774 ff_xvid_encode_init,
775 ff_xvid_encode_frame, 775 ff_xvid_encode_frame,
776 ff_xvid_encode_close, 776 ff_xvid_encode_close,
777 .pix_fmts= (enum PixelFormat[]){PIX_FMT_YUV420P, PIX_FMT_NONE}, 777 .pix_fmts= (enum PixelFormat[]){PIX_FMT_YUV420P, PIX_FMT_NONE},
778 .long_name= NULL_IF_CONFIG_SMALL("libxvidcore MPEG-4 part 2"), 778 .long_name= NULL_IF_CONFIG_SMALL("libxvidcore MPEG-4 part 2"),