[FFmpeg-devel] lavf/matroska*: add support for signed integers
Michael Niedermayer
michaelni at gmx.at
Fri Nov 15 16:37:35 CET 2013
On Fri, Nov 15, 2013 at 11:28:21AM +0100, Jan Gerber wrote:
>
> On 11/14/2013 10:53 PM, Michael Niedermayer wrote:
> >
> > if i try the example from http://matroska.org/technical/specs/index.html
> > 0xFE & 0x80
> > negative = 1
> > 0x7E
> >
> > if(negative)
> > num = 0 - 0x7E
> >
> > this does nt seem to reach the expected -2 which is 0xFE
> >
> > but maybe iam missing something
> >
>
> good catch, fixed version attached.
>
> ---
> libavformat/matroskadec.c | 27 +++++++++++++++++++++++++++
> libavformat/matroskaenc.c | 21 +++++++++++++++++++++
> 2 files changed, 48 insertions(+)
>
>
[...]
> @@ -759,6 +760,31 @@ static int ebml_read_uint(AVIOContext *pb, int size, uint64_t *num)
> }
>
> /*
> + * Read the next element as a signed int.
> + * 0 is success, < 0 is failure.
> + */
> +static int ebml_read_sint(AVIOContext *pb, int size, int64_t *num)
> +{
> + int n = 0;
> +
> + if (size > 8)
> + return AVERROR_INVALIDDATA;
> +
> + *num = avio_r8(pb);
> + if (*num & 0x80) {
> + *num = -1;
> + } else {
> + *num = 0;
> + }
this discards the 7 less significant bits
i think these contain bits from the number to be read
[...]
--
Michael GnuPG fingerprint: 9FF2128B147EF6730BADF133611EC787040B0FAB
Avoid a single point of failure, be that a person or equipment.
-------------- next part --------------
A non-text attachment was scrubbed...
Name: not available
Type: application/pgp-signature
Size: 198 bytes
Desc: Digital signature
URL: <http://ffmpeg.org/pipermail/ffmpeg-devel/attachments/20131115/c5afaf20/attachment.asc>
More information about the ffmpeg-devel
mailing list