[FFmpeg-devel] lavf/matroska*: add support for signed integers

Jan Gerber j at v2v.cc
Fri Nov 15 19:00:37 CET 2013


On 11/15/2013 05:42 PM, Michael Niedermayer wrote:
>>      EBML_STOP,
>> -    EBML_TYPE_COUNT
>> +    EBML_TYPE_COUNT,
>> +    EBML_SINT,
>>  } EbmlType;
>>  
>>  typedef const struct EbmlSyntax {
> 
> EBML_TYPE_COUNT is the number of enum types its used as size for
> some array
> 
ok

>> +    if (size == 0) {
>> +        *num = 0;
>> +    } else {
>> +        *num = avio_r8(pb);
>> +        /* negative value */
>> +        if (*num & 0x80) {
>> +            *num = (-1 << 8) | *num;
>> +        }
> 
> can be simplified with sign_extend()

not sure how that would work, sign_extend looks more complicated to me.
feel free to improve before committing though.

>> +    /* make unsigned */
>> +    if (val >= 0) {
>> +        uval = val;
>> +    } else {
>> +        uval = 0x80 << (bytes - 1);
>> +        uval += val;
>> +        uval |= 0x80 << (bytes - 1);
>> +    }
> 
> this should not be needed
> signed integers are already in twos complement, simply storing them
> bytewise should work

not sure how that would look,
but please improve.

-------------- next part --------------
A non-text attachment was scrubbed...
Name: 0001-lavf-matroska-add-support-for-signed-integers.patch
Type: text/x-diff
Size: 2443 bytes
Desc: not available
URL: <http://ffmpeg.org/pipermail/ffmpeg-devel/attachments/20131115/43d666ea/attachment.bin>


More information about the ffmpeg-devel mailing list