Mercurial > mplayer.hg
comparison libmpcodecs/ve_xvid4.c @ 29263:0f1b5b68af32
whitespace cosmetics: Remove all trailing whitespace.
author | diego |
---|---|
date | Wed, 13 May 2009 02:58:57 +0000 |
parents | 79aef31ed618 |
children | a972c1a4a012 |
comparison
equal
deleted
inserted
replaced
29262:7d545a6b8aff | 29263:0f1b5b68af32 |
---|---|
254 {"hq_ac", &xvidenc_hqacpred, CONF_TYPE_FLAG, 0, 0, 1, NULL}, | 254 {"hq_ac", &xvidenc_hqacpred, CONF_TYPE_FLAG, 0, 0, 1, NULL}, |
255 {"nohq_ac", &xvidenc_hqacpred, CONF_TYPE_FLAG, 0, 1, 0, NULL}, | 255 {"nohq_ac", &xvidenc_hqacpred, CONF_TYPE_FLAG, 0, 1, 0, NULL}, |
256 {"frame_drop_ratio", &xvidenc_frame_drop_ratio, CONF_TYPE_INT, CONF_RANGE, 0, 100, NULL}, | 256 {"frame_drop_ratio", &xvidenc_frame_drop_ratio, CONF_TYPE_INT, CONF_RANGE, 0, 100, NULL}, |
257 {"max_key_interval", &xvidenc_max_key_interval, CONF_TYPE_INT, CONF_MIN, 0, 0, NULL}, | 257 {"max_key_interval", &xvidenc_max_key_interval, CONF_TYPE_INT, CONF_MIN, 0, 0, NULL}, |
258 {"greyscale", &xvidenc_greyscale, CONF_TYPE_FLAG, 0, 0, 1, NULL}, /* kept for backward compatibility */ | 258 {"greyscale", &xvidenc_greyscale, CONF_TYPE_FLAG, 0, 0, 1, NULL}, /* kept for backward compatibility */ |
259 {"grayscale", &xvidenc_greyscale, CONF_TYPE_FLAG, 0, 0, 1, NULL}, | 259 {"grayscale", &xvidenc_greyscale, CONF_TYPE_FLAG, 0, 0, 1, NULL}, |
260 {"nogreyscale", &xvidenc_greyscale, CONF_TYPE_FLAG, 0, 1, 0, NULL}, | 260 {"nogreyscale", &xvidenc_greyscale, CONF_TYPE_FLAG, 0, 1, 0, NULL}, |
261 {"lumi_mask", &xvidenc_luminance_masking, CONF_TYPE_FLAG, 0, 0, 1, NULL}, | 261 {"lumi_mask", &xvidenc_luminance_masking, CONF_TYPE_FLAG, 0, 0, 1, NULL}, |
262 {"nolumi_mask", &xvidenc_luminance_masking, CONF_TYPE_FLAG, 0, 1, 0, NULL}, | 262 {"nolumi_mask", &xvidenc_luminance_masking, CONF_TYPE_FLAG, 0, 1, 0, NULL}, |
263 {"turbo", &xvidenc_turbo, CONF_TYPE_FLAG, 0, 0, 1, NULL}, | 263 {"turbo", &xvidenc_turbo, CONF_TYPE_FLAG, 0, 0, 1, NULL}, |
264 {"debug", &xvidenc_debug, CONF_TYPE_INT , 0 ,0,-1,NULL}, | 264 {"debug", &xvidenc_debug, CONF_TYPE_INT , 0 ,0,-1,NULL}, |
345 int min_framenum; | 345 int min_framenum; |
346 int max_sse_y; | 346 int max_sse_y; |
347 int max_sse_u; | 347 int max_sse_u; |
348 int max_sse_v; | 348 int max_sse_v; |
349 int max_framenum; | 349 int max_framenum; |
350 | 350 |
351 int pixels; | 351 int pixels; |
352 | 352 |
353 /* DAR/PAR and all that thingies */ | 353 /* DAR/PAR and all that thingies */ |
354 int d_width; | 354 int d_width; |
355 int d_height; | 355 int d_height; |
356 FILE *fvstats; | 356 FILE *fvstats; |
357 } xvid_mplayer_module_t; | 357 } xvid_mplayer_module_t; |
378 int width, int height, int d_width, int d_height, | 378 int width, int height, int d_width, int d_height, |
379 unsigned int flags, unsigned int outfmt) | 379 unsigned int flags, unsigned int outfmt) |
380 { | 380 { |
381 int err; | 381 int err; |
382 xvid_mplayer_module_t *mod = (xvid_mplayer_module_t *)vf->priv; | 382 xvid_mplayer_module_t *mod = (xvid_mplayer_module_t *)vf->priv; |
383 | 383 |
384 /* Complete the muxer initialization */ | 384 /* Complete the muxer initialization */ |
385 mod->mux->bih->biWidth = width; | 385 mod->mux->bih->biWidth = width; |
386 mod->mux->bih->biHeight = height; | 386 mod->mux->bih->biHeight = height; |
387 mod->mux->bih->biSizeImage = | 387 mod->mux->bih->biSizeImage = |
388 mod->mux->bih->biWidth * mod->mux->bih->biHeight * 3 / 2; | 388 mod->mux->bih->biWidth * mod->mux->bih->biHeight * 3 / 2; |
389 mod->mux->aspect = (float)d_width/d_height; | 389 mod->mux->aspect = (float)d_width/d_height; |
390 | 390 |
391 /* Message the FourCC type */ | 391 /* Message the FourCC type */ |
392 mp_msg(MSGT_MENCODER, MSGL_INFO, | 392 mp_msg(MSGT_MENCODER, MSGL_INFO, |
423 if(err<0) { | 423 if(err<0) { |
424 mp_msg(MSGT_MENCODER, MSGL_ERR, | 424 mp_msg(MSGT_MENCODER, MSGL_ERR, |
425 "xvid: xvidcore returned a '%s' error\n", errorstring(err)); | 425 "xvid: xvidcore returned a '%s' error\n", errorstring(err)); |
426 return BAD; | 426 return BAD; |
427 } | 427 } |
428 | 428 |
429 /* Store the encoder instance into the private data */ | 429 /* Store the encoder instance into the private data */ |
430 mod->instance = mod->create.handle; | 430 mod->instance = mod->create.handle; |
431 | 431 |
432 mod->mux->decoder_delay = mod->create.max_bframes ? 1 : 0; | 432 mod->mux->decoder_delay = mod->create.max_bframes ? 1 : 0; |
433 | 433 |
515 | 515 |
516 static int | 516 static int |
517 put_image(struct vf_instance_s* vf, mp_image_t *mpi, double pts) | 517 put_image(struct vf_instance_s* vf, mp_image_t *mpi, double pts) |
518 { | 518 { |
519 int size; | 519 int size; |
520 xvid_enc_stats_t stats; | 520 xvid_enc_stats_t stats; |
521 xvid_mplayer_module_t *mod = (xvid_mplayer_module_t *)vf->priv; | 521 xvid_mplayer_module_t *mod = (xvid_mplayer_module_t *)vf->priv; |
522 | 522 |
523 /* Prepare the stats */ | 523 /* Prepare the stats */ |
524 memset(&stats,0,sizeof( xvid_enc_stats_t)); | 524 memset(&stats,0,sizeof( xvid_enc_stats_t)); |
525 stats.version = XVID_VERSION; | 525 stats.version = XVID_VERSION; |
628 XVID_VERSION_MAJOR(xvid_gbl_info.actual_version), | 628 XVID_VERSION_MAJOR(xvid_gbl_info.actual_version), |
629 XVID_VERSION_MINOR(xvid_gbl_info.actual_version), | 629 XVID_VERSION_MINOR(xvid_gbl_info.actual_version), |
630 XVID_VERSION_PATCH(xvid_gbl_info.actual_version), | 630 XVID_VERSION_PATCH(xvid_gbl_info.actual_version), |
631 xvid_gbl_info.build); | 631 xvid_gbl_info.build); |
632 } | 632 } |
633 | 633 |
634 /* Initialize the xvid_gbl_init structure */ | 634 /* Initialize the xvid_gbl_init structure */ |
635 memset(&xvid_gbl_init, 0, sizeof(xvid_gbl_init_t)); | 635 memset(&xvid_gbl_init, 0, sizeof(xvid_gbl_init_t)); |
636 xvid_gbl_init.version = XVID_VERSION; | 636 xvid_gbl_init.version = XVID_VERSION; |
637 xvid_gbl_init.debug = xvidenc_debug; | 637 xvid_gbl_init.debug = xvidenc_debug; |
638 | 638 |
679 { | 679 { |
680 mp_msg(MSGT_MENCODER,MSGL_ERR, | 680 mp_msg(MSGT_MENCODER,MSGL_ERR, |
681 "xvid:[ERROR] \"%s\" is an invalid profile name\n", xvidenc_profile); | 681 "xvid:[ERROR] \"%s\" is an invalid profile name\n", xvidenc_profile); |
682 return BAD; | 682 return BAD; |
683 } | 683 } |
684 | 684 |
685 /* ------------------------------------------------------------------- | 685 /* ------------------------------------------------------------------- |
686 * Dispatch all settings having an impact on the "create" structure | 686 * Dispatch all settings having an impact on the "create" structure |
687 * This includes plugins as they are passed to encore through the | 687 * This includes plugins as they are passed to encore through the |
688 * create structure | 688 * create structure |
689 * -----------------------------------------------------------------*/ | 689 * -----------------------------------------------------------------*/ |
734 #if XVID_API >= XVID_MAKE_API(4,1) | 734 #if XVID_API >= XVID_MAKE_API(4,1) |
735 /* dxn: always write divx5 userdata */ | 735 /* dxn: always write divx5 userdata */ |
736 if(selected_profile->flags & PROFILE_DXN) | 736 if(selected_profile->flags & PROFILE_DXN) |
737 create->global |= XVID_GLOBAL_DIVX5_USERDATA; | 737 create->global |= XVID_GLOBAL_DIVX5_USERDATA; |
738 #endif | 738 #endif |
739 | 739 |
740 create->max_key_interval = xvidenc_max_key_interval; | 740 create->max_key_interval = xvidenc_max_key_interval; |
741 create->frame_drop_ratio = xvidenc_frame_drop_ratio; | 741 create->frame_drop_ratio = xvidenc_frame_drop_ratio; |
742 create->min_quant[0] = xvidenc_min_quant[0]; | 742 create->min_quant[0] = xvidenc_min_quant[0]; |
743 create->min_quant[1] = xvidenc_min_quant[1]; | 743 create->min_quant[1] = xvidenc_min_quant[1]; |
744 create->min_quant[2] = xvidenc_min_quant[2]; | 744 create->min_quant[2] = xvidenc_min_quant[2]; |
897 /* PAR related initialization */ | 897 /* PAR related initialization */ |
898 frame->par = XVID_PAR_11_VGA; /* Default */ | 898 frame->par = XVID_PAR_11_VGA; /* Default */ |
899 | 899 |
900 if( !(selected_profile->flags & PROFILE_DXN) ) | 900 if( !(selected_profile->flags & PROFILE_DXN) ) |
901 { | 901 { |
902 if(xvidenc_dar_aspect > 0) | 902 if(xvidenc_dar_aspect > 0) |
903 ar = av_d2q(xvidenc_dar_aspect * mod->mux->bih->biHeight / mod->mux->bih->biWidth, 255); | 903 ar = av_d2q(xvidenc_dar_aspect * mod->mux->bih->biHeight / mod->mux->bih->biWidth, 255); |
904 else if(xvidenc_autoaspect) | 904 else if(xvidenc_autoaspect) |
905 ar = av_d2q((float)mod->d_width / mod->d_height * mod->mux->bih->biHeight / mod->mux->bih->biWidth, 255); | 905 ar = av_d2q((float)mod->d_width / mod->d_height * mod->mux->bih->biHeight / mod->mux->bih->biWidth, 255); |
906 else ar.num = ar.den = 0; | 906 else ar.num = ar.den = 0; |
907 | 907 |
908 if(ar.den != 0) { | 908 if(ar.den != 0) { |
909 if(ar.num == 12 && ar.den == 11) | 909 if(ar.num == 12 && ar.den == 11) |
910 frame->par = XVID_PAR_43_PAL; | 910 frame->par = XVID_PAR_43_PAL; |
911 else if(ar.num == 10 && ar.den == 11) | 911 else if(ar.num == 10 && ar.den == 11) |
912 frame->par = XVID_PAR_43_NTSC; | 912 frame->par = XVID_PAR_43_NTSC; |
913 else if(ar.num == 16 && ar.den == 11) | 913 else if(ar.num == 16 && ar.den == 11) |
914 frame->par = XVID_PAR_169_PAL; | 914 frame->par = XVID_PAR_169_PAL; |
915 else if(ar.num == 40 && ar.den == 33) | 915 else if(ar.num == 40 && ar.den == 33) |
916 frame->par = XVID_PAR_169_NTSC; | 916 frame->par = XVID_PAR_169_NTSC; |
917 else | 917 else |
918 { | 918 { |
919 frame->par = XVID_PAR_EXT; | 919 frame->par = XVID_PAR_EXT; |
920 frame->par_width = ar.num; | 920 frame->par_width = ar.num; |
921 frame->par_height= ar.den; | 921 frame->par_height= ar.den; |
922 } | 922 } |
923 | 923 |
924 } else if(xvidenc_par != NULL) { | 924 } else if(xvidenc_par != NULL) { |
925 if(strcasecmp(xvidenc_par, "pal43") == 0) | 925 if(strcasecmp(xvidenc_par, "pal43") == 0) |
926 frame->par = XVID_PAR_43_PAL; | 926 frame->par = XVID_PAR_43_PAL; |
927 else if(strcasecmp(xvidenc_par, "pal169") == 0) | 927 else if(strcasecmp(xvidenc_par, "pal169") == 0) |
928 frame->par = XVID_PAR_169_PAL; | 928 frame->par = XVID_PAR_169_PAL; |
945 frame->par_height = 1; | 945 frame->par_height = 1; |
946 } | 946 } |
947 } | 947 } |
948 | 948 |
949 /* Display par information */ | 949 /* Display par information */ |
950 mp_msg(MSGT_MENCODER, MSGL_INFO, "xvid: par=%d/%d (%s), displayed=%dx%d, sampled=%dx%d\n", | 950 mp_msg(MSGT_MENCODER, MSGL_INFO, "xvid: par=%d/%d (%s), displayed=%dx%d, sampled=%dx%d\n", |
951 ar.num, ar.den, par_string(frame->par), | 951 ar.num, ar.den, par_string(frame->par), |
952 mod->d_width, mod->d_height, mod->mux->bih->biWidth, mod->mux->bih->biHeight); | 952 mod->d_width, mod->d_height, mod->mux->bih->biWidth, mod->mux->bih->biHeight); |
953 } | 953 } |
954 else | 954 else |
955 mp_msg(MSGT_MENCODER, MSGL_INFO, | 955 mp_msg(MSGT_MENCODER, MSGL_INFO, |
1099 mp_msg(MSGT_MENCODER, MSGL_INFO, | 1099 mp_msg(MSGT_MENCODER, MSGL_INFO, |
1100 "xvid: Fixed Quant Rate Control -- quantizer=%d/%d=%2.2f\n", | 1100 "xvid: Fixed Quant Rate Control -- quantizer=%d/%d=%2.2f\n", |
1101 squant.num, | 1101 squant.num, |
1102 squant.den, | 1102 squant.den, |
1103 (float)(squant.num)/(float)(squant.den)); | 1103 (float)(squant.num)/(float)(squant.den)); |
1104 | 1104 |
1105 } else { | 1105 } else { |
1106 mp_msg(MSGT_MENCODER, MSGL_INFO, | 1106 mp_msg(MSGT_MENCODER, MSGL_INFO, |
1107 "xvid: CBR Rate Control -- bitrate=%dkbit/s\n", | 1107 "xvid: CBR Rate Control -- bitrate=%dkbit/s\n", |
1108 xvidenc_bitrate>16000?xvidenc_bitrate/1000:xvidenc_bitrate); | 1108 xvidenc_bitrate>16000?xvidenc_bitrate/1000:xvidenc_bitrate); |
1109 doZones = 1; | 1109 doZones = 1; |
1270 | 1270 |
1271 return FINE; | 1271 return FINE; |
1272 } | 1272 } |
1273 | 1273 |
1274 static void | 1274 static void |
1275 flush_internal_buffers(xvid_mplayer_module_t *mod) | 1275 flush_internal_buffers(xvid_mplayer_module_t *mod) |
1276 { | 1276 { |
1277 int size; | 1277 int size; |
1278 xvid_enc_frame_t *frame = &mod->frame; | 1278 xvid_enc_frame_t *frame = &mod->frame; |
1279 | 1279 |
1280 if (mod->instance == NULL) | 1280 if (mod->instance == NULL) |
1334 mod->max_sse_y = stats->sse_y; | 1334 mod->max_sse_y = stats->sse_y; |
1335 mod->max_sse_u = stats->sse_u; | 1335 mod->max_sse_u = stats->sse_u; |
1336 mod->max_sse_v = stats->sse_v; | 1336 mod->max_sse_v = stats->sse_v; |
1337 mod->max_framenum = mod->frames; | 1337 mod->max_framenum = mod->frames; |
1338 } | 1338 } |
1339 | 1339 |
1340 if (xvidenc_psnr) { | 1340 if (xvidenc_psnr) { |
1341 if (!mod->fvstats) { | 1341 if (!mod->fvstats) { |
1342 char filename[20]; | 1342 char filename[20]; |
1343 time_t today2; | 1343 time_t today2; |
1344 struct tm *today; | 1344 struct tm *today; |
1406 static void *read_matrix(unsigned char *filename) | 1406 static void *read_matrix(unsigned char *filename) |
1407 { | 1407 { |
1408 int i; | 1408 int i; |
1409 unsigned char *matrix; | 1409 unsigned char *matrix; |
1410 FILE *input; | 1410 FILE *input; |
1411 | 1411 |
1412 /* Allocate matrix space */ | 1412 /* Allocate matrix space */ |
1413 if((matrix = malloc(64*sizeof(unsigned char))) == NULL) | 1413 if((matrix = malloc(64*sizeof(unsigned char))) == NULL) |
1414 return NULL; | 1414 return NULL; |
1415 | 1415 |
1416 /* Open the matrix file */ | 1416 /* Open the matrix file */ |
1448 | 1448 |
1449 /* We're done */ | 1449 /* We're done */ |
1450 fclose(input); | 1450 fclose(input); |
1451 | 1451 |
1452 return matrix; | 1452 return matrix; |
1453 | 1453 |
1454 } | 1454 } |
1455 | 1455 |
1456 | 1456 |
1457 static const char * | 1457 static const char * |
1458 par_string(int parcode) | 1458 par_string(int parcode) |