diff options
| author | jhurst <jhurst@cinecert.com> | 2014-09-21 13:27:43 +0000 |
|---|---|---|
| committer | jhurst <> | 2014-09-21 13:27:43 +0000 |
| commit | ab3e3df49a9d4a44a3bf11211e31bdeac3ef7bcf (patch) | |
| tree | 52023c92807dde6cb56835e957349327f1b9df0b /src/AS_DCP.cpp | |
| parent | 8d24b6effb0377fc3041c2e024e7c5593caecc52 (diff) | |
imf bugs
date parse bug
timed-text transform removed
Diffstat (limited to 'src/AS_DCP.cpp')
| -rwxr-xr-x | src/AS_DCP.cpp | 42 |
1 files changed, 41 insertions, 1 deletions
diff --git a/src/AS_DCP.cpp b/src/AS_DCP.cpp index 223d52a..1abd092 100755 --- a/src/AS_DCP.cpp +++ b/src/AS_DCP.cpp @@ -1,5 +1,5 @@ /* -Copyright (c) 2004-2009, John Hurst +Copyright (c) 2004-2014, John Hurst All rights reserved. Redistribution and use in source and binary forms, with or without @@ -39,6 +39,46 @@ ASDCP::Version() } + +//------------------------------------------------------------------------------------------ +// + +// Encodes a rational number as a string having a single delimiter character between +// numerator and denominator. Retuns the buffer pointer to allow convenient in-line use. +const char* +ASDCP::EncodeRational(const Rational& rational, char* str_buf, ui32_t buf_len, char delimiter) +{ + assert(str_buf); + snprintf(str_buf, buf_len, "%u%c%u", rational.Numerator, delimiter, rational.Denominator); + return str_buf; +} + +// Decodes a rational number havng a single non-digit delimiter character between +// the numerator and denominator. Returns false if the string does not contain +// the expected syntax. +bool +ASDCP::DecodeRational(const char* str_rational, Rational& rational) +{ + assert(str_rational); + rational.Numerator = strtol(str_rational, 0, 10); + + const char* p = str_rational; + while ( *p && isdigit(*p) ) + { + ++p; + } + + if ( p[0] == 0 || p[1] == 0 ) + { + return false; + } + + ++p; + rational.Denominator = strtol(p, 0, 10); + return true; +} + + //------------------------------------------------------------------------------------------ // // frame buffer base class implementation |
