Issue-#3407 : Enhance precision for double to string conversion, useful for GEOTIFF double values
Signed-off-by: Michael Niedermayer <michaelni@gmx.at>
This commit is contained in:
parent
02b63246cf
commit
526049ce61
@ -195,7 +195,7 @@ static char *doubles2str(double *dp, int count, const char *sep)
|
|||||||
char *ap, *ap0;
|
char *ap, *ap0;
|
||||||
uint64_t component_len;
|
uint64_t component_len;
|
||||||
if (!sep) sep = ", ";
|
if (!sep) sep = ", ";
|
||||||
component_len = 15LL + strlen(sep);
|
component_len = 24LL + strlen(sep);
|
||||||
if (count >= (INT_MAX - 1)/component_len)
|
if (count >= (INT_MAX - 1)/component_len)
|
||||||
return NULL;
|
return NULL;
|
||||||
ap = av_malloc(component_len * count + 1);
|
ap = av_malloc(component_len * count + 1);
|
||||||
@ -204,7 +204,7 @@ static char *doubles2str(double *dp, int count, const char *sep)
|
|||||||
ap0 = ap;
|
ap0 = ap;
|
||||||
ap[0] = '\0';
|
ap[0] = '\0';
|
||||||
for (i = 0; i < count; i++) {
|
for (i = 0; i < count; i++) {
|
||||||
unsigned l = snprintf(ap, component_len, "%f%s", dp[i], sep);
|
unsigned l = snprintf(ap, component_len, "%.15g%s", dp[i], sep);
|
||||||
if(l >= component_len) {
|
if(l >= component_len) {
|
||||||
av_free(ap0);
|
av_free(ap0);
|
||||||
return NULL;
|
return NULL;
|
||||||
|
@ -165,7 +165,7 @@ int ff_tadd_doubles_metadata(int count, const char *name, const char *sep,
|
|||||||
av_bprint_init(&bp, 10 * count, 100 * count);
|
av_bprint_init(&bp, 10 * count, 100 * count);
|
||||||
|
|
||||||
for (i = 0; i < count; i++) {
|
for (i = 0; i < count; i++) {
|
||||||
av_bprintf(&bp, "%s%f", auto_sep(count, sep, i, 4), ff_tget_double(gb, le));
|
av_bprintf(&bp, "%s%.15g", auto_sep(count, sep, i, 4), ff_tget_double(gb, le));
|
||||||
}
|
}
|
||||||
|
|
||||||
if ((i = av_bprint_finalize(&bp, &ap))) {
|
if ((i = av_bprint_finalize(&bp, &ap))) {
|
||||||
|
Loading…
Reference in New Issue
Block a user