lavf/matroska*: DiscardPadding is a signed integer
authorJan Gerber <j@v2v.cc>
Thu, 14 Nov 2013 11:58:28 +0000 (12:58 +0100)
committerMichael Niedermayer <michaelni@gmx.at>
Tue, 7 Jan 2014 02:05:30 +0000 (03:05 +0100)
according to the Matriska Specification
 http://matroska.org/technical/specs/index.html
DiscardPadding is a signed integer.

Tested-by: Jan Gerber <j@v2v.cc>
Tested-by: James Almer <jamrial@gmail.com>
Signed-off-by: Michael Niedermayer <michaelni@gmx.at>
(cherry picked from commit f4b1ca99ff86c6ba78e1b4730c85eac0d5a5817a)

Signed-off-by: Michael Niedermayer <michaelni@gmx.at>
libavformat/matroskadec.c
libavformat/matroskaenc.c

index 09f7969..77f9188 100644 (file)
@@ -293,7 +293,7 @@ typedef struct {
     EbmlBin  bin;
     uint64_t additional_id;
     EbmlBin  additional;
-    uint64_t discard_padding;
+    int64_t discard_padding;
 } MatroskaBlock;
 
 static EbmlSyntax ebml_header[] = {
@@ -571,7 +571,7 @@ static EbmlSyntax matroska_blockgroup[] = {
     { MATROSKA_ID_BLOCKADDITIONS, EBML_NEST, 0, 0, {.n=matroska_blockadditions} },
     { MATROSKA_ID_SIMPLEBLOCK,    EBML_BIN,  0, offsetof(MatroskaBlock,bin) },
     { MATROSKA_ID_BLOCKDURATION,  EBML_UINT, 0, offsetof(MatroskaBlock,duration) },
-    { MATROSKA_ID_DISCARDPADDING, EBML_UINT, 0, offsetof(MatroskaBlock,discard_padding) },
+    { MATROSKA_ID_DISCARDPADDING, EBML_SINT, 0, offsetof(MatroskaBlock,discard_padding) },
     { MATROSKA_ID_BLOCKREFERENCE, EBML_UINT, 0, offsetof(MatroskaBlock,reference) },
     { MATROSKA_ID_CODECSTATE,     EBML_NONE },
     { 1,                          EBML_UINT, 0, offsetof(MatroskaBlock,non_simple), {.u=1} },
@@ -2415,7 +2415,7 @@ static int matroska_parse_frame(MatroskaDemuxContext *matroska,
                                 uint64_t timecode, uint64_t lace_duration,
                                 int64_t pos, int is_keyframe,
                                 uint8_t *additional, uint64_t additional_id, int additional_size,
-                                uint64_t discard_padding)
+                                int64_t discard_padding)
 {
     MatroskaTrackEncoding *encodings = track->encodings.elem;
     uint8_t *pkt_data = data;
@@ -2552,7 +2552,7 @@ static int matroska_parse_block(MatroskaDemuxContext *matroska, uint8_t *data,
                                 int size, int64_t pos, uint64_t cluster_time,
                                 uint64_t block_duration, int is_keyframe,
                                 uint8_t *additional, uint64_t additional_id, int additional_size,
-                                int64_t cluster_pos, uint64_t discard_padding)
+                                int64_t cluster_pos, int64_t discard_padding)
 {
     uint64_t timecode = AV_NOPTS_VALUE;
     MatroskaTrack *track;
index 0263cbc..60b6e5e 100644 (file)
@@ -1317,7 +1317,8 @@ static void mkv_write_block(AVFormatContext *s, AVIOContext *pb,
     uint8_t *data = NULL, *side_data = NULL;
     int offset = 0, size = pkt->size, side_data_size = 0;
     int64_t ts = mkv->tracks[pkt->stream_index].write_dts ? pkt->dts : pkt->pts;
-    uint64_t additional_id = 0, discard_padding = 0;
+    uint64_t additional_id = 0;
+    int64_t discard_padding = 0;
     ebml_master block_group, block_additions, block_more;
 
     av_log(s, AV_LOG_DEBUG, "Writing block at offset %" PRIu64 ", size %d, "
@@ -1376,7 +1377,7 @@ static void mkv_write_block(AVFormatContext *s, AVIOContext *pb,
         av_free(data);
 
     if (discard_padding) {
-        put_ebml_uint(pb, MATROSKA_ID_DISCARDPADDING, discard_padding);
+        put_ebml_sint(pb, MATROSKA_ID_DISCARDPADDING, discard_padding);
     }
 
     if (side_data_size && additional_id == 1) {