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

James Almer jamrial at gmail.com
Mon Nov 25 09:30:18 CET 2013


On 15/11/13 5:37 PM, Michael Niedermayer wrote:
> On Fri, Nov 15, 2013 at 07:00:37PM +0100, Jan Gerber wrote:
>> 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.
> 
> ok, applied and improved

This should be backported to 2.1 alongside cddd15ba and f4b1ca99.

And 74906d37, while not fully related, could be backported to versions 1.1, 
1.2, 2.0 and 2.1 while at it.


More information about the ffmpeg-devel mailing list