Maria1099 / webm

Automatically exported from code.google.com/p/webm
0 stars 0 forks source link

large timebase causes integer overflow, non-monotonic timestamps #468

Closed GoogleCodeExporter closed 9 years ago

GoogleCodeExporter commented 9 years ago
Originally reported as an ffmpeg bug:
  https://ffmpeg.org/trac/ffmpeg/ticket/1014

This is reproducible with vpxenc:
 1) Download video_cut.avi from the bug.
 2) Convert to y4m:
    $ ffmpeg -i video_cut.avi -an -pix_fmt yuv420p -y video_cut.y4m
 3) Encode with vpxenc (the following settings are close enough to what is being used in the bug).
    $ vpxenc -p 2 video_cut.y4m --auto-alt-ref=1 --lag-in-frames=16 --cpu-used=3 --timebase=33333/1000000 --target-bitrate=1000 -o video_cut.webm

video_cut.webm will only have strictly increasing timestamps due to the hack in 
vpxenc.c:

static void
write_webm_block(EbmlGlobal                *glob,
                 const vpx_codec_enc_cfg_t *cfg,
                 const vpx_codec_cx_pkt_t  *pkt)
...
    if(pts_ms <= glob->last_pts_ms)
        pts_ms = glob->last_pts_ms + 1;

Removing this will produce the following:
...
| + SimpleBlock (key, track number 1, 1 frame(s), timecode 0.000s = 
00:00:00.000)
|  + Frame with size 13825
| + SimpleBlock (track number 1, 1 frame(s), timecode 0.033s = 00:00:00.033)
|  + Frame with size 19896
| + SimpleBlock (track number 1, 1 frame(s), timecode 0.000s = 00:00:00.000)
|  + Frame with size 4232
| + SimpleBlock (track number 1, 1 frame(s), timecode 0.033s = 00:00:00.033)

The overflow is within vp8_cx_iface.c, the variable 'round'. Promoting it to 
64-bits produces better results:

--- a/vp8/vp8_cx_iface.c
+++ b/vp8/vp8_cx_iface.c
@@ -891,7 +891,7 @@ static vpx_codec_err_t vp8e_encode(vpx_codec_alg_priv_t  
*ctx,
                 VP8_COMP *cpi = (VP8_COMP *)ctx->cpi;

                 /* Add the frame packet to the list of returned packets. */
-                round = 1000000 * ctx->cfg.g_timebase.num / 2 - 1;
+                round = 1000000LL * ctx->cfg.g_timebase.num / 2 - 1;
                 delta = (dst_end_time_stamp - dst_time_stamp);
                 pkt.kind = VPX_CODEC_CX_FRAME_PKT;
                 pkt.data.frame.pts =

Original issue reported on code.google.com by jz...@google.com on 5 Aug 2012 at 1:08

GoogleCodeExporter commented 9 years ago
Present in: v1.1.0-177-g69babd3

Original comment by jz...@google.com on 5 Aug 2012 at 1:14

GoogleCodeExporter commented 9 years ago
This change has been merged to fix the issue:
 https://gerrit.chromium.org/gerrit/#/c/29547/

Fixed in: v1.1.0-184-g429743c

Original comment by jz...@google.com on 8 Aug 2012 at 10:42