Mercurial > libavcodec.hg
comparison ratecontrol.c @ 1031:19de1445beb2 libavcodec
use av_malloc() functions - added av_strdup and av_realloc()
author | bellard |
---|---|
date | Thu, 23 Jan 2003 23:03:09 +0000 |
parents | 3c2b94407f02 |
children | bb5de8a59da8 |
comparison
equal
deleted
inserted
replaced
1030:801f2739264a | 1031:19de1445beb2 |
---|---|
749 for(i=0; i<5; i++){ | 749 for(i=0; i<5; i++){ |
750 available_bits[i]= const_bits[i] + complexity[i]/avg_quantizer[i]; | 750 available_bits[i]= const_bits[i] + complexity[i]/avg_quantizer[i]; |
751 } | 751 } |
752 //printf("%lld %lld %lld %lld\n", available_bits[I_TYPE], available_bits[P_TYPE], available_bits[B_TYPE], all_available_bits); | 752 //printf("%lld %lld %lld %lld\n", available_bits[I_TYPE], available_bits[P_TYPE], available_bits[B_TYPE], all_available_bits); |
753 | 753 |
754 qscale= malloc(sizeof(double)*rcc->num_entries); | 754 qscale= av_malloc(sizeof(double)*rcc->num_entries); |
755 blured_qscale= malloc(sizeof(double)*rcc->num_entries); | 755 blured_qscale= av_malloc(sizeof(double)*rcc->num_entries); |
756 | 756 |
757 for(step=256*256; step>0.0000001; step*=0.5){ | 757 for(step=256*256; step>0.0000001; step*=0.5){ |
758 expected_bits=0; | 758 expected_bits=0; |
759 rate_factor+= step; | 759 rate_factor+= step; |
760 | 760 |
807 } | 807 } |
808 | 808 |
809 // printf("%f %d %f\n", expected_bits, (int)all_available_bits, rate_factor); | 809 // printf("%f %d %f\n", expected_bits, (int)all_available_bits, rate_factor); |
810 if(expected_bits > all_available_bits) rate_factor-= step; | 810 if(expected_bits > all_available_bits) rate_factor-= step; |
811 } | 811 } |
812 free(qscale); | 812 av_free(qscale); |
813 free(blured_qscale); | 813 av_free(blured_qscale); |
814 | 814 |
815 if(abs(expected_bits/all_available_bits - 1.0) > 0.01 ){ | 815 if(abs(expected_bits/all_available_bits - 1.0) > 0.01 ){ |
816 fprintf(stderr, "Error: 2pass curve failed to converge\n"); | 816 fprintf(stderr, "Error: 2pass curve failed to converge\n"); |
817 return -1; | 817 return -1; |
818 } | 818 } |