From patchwork Tue Jan 31 01:05:49 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: chcunningham@chromium.org X-Patchwork-Id: 2378 Delivered-To: ffmpegpatchwork@gmail.com Received: by 10.103.89.21 with SMTP id n21csp1724353vsb; Mon, 30 Jan 2017 17:37:10 -0800 (PST) X-Received: by 10.223.154.132 with SMTP id a4mr20900473wrc.188.1485826630173; Mon, 30 Jan 2017 17:37:10 -0800 (PST) Return-Path: Received: from ffbox0-bg.mplayerhq.hu (ffbox0-bg.ffmpeg.org. [79.124.17.100]) by mx.google.com with ESMTP id f42si18648315wrf.268.2017.01.30.17.37.09; Mon, 30 Jan 2017 17:37:10 -0800 (PST) Received-SPF: pass (google.com: domain of ffmpeg-devel-bounces@ffmpeg.org designates 79.124.17.100 as permitted sender) client-ip=79.124.17.100; Authentication-Results: mx.google.com; dkim=neutral (body hash did not verify) header.i=@chromium.org; spf=pass (google.com: domain of ffmpeg-devel-bounces@ffmpeg.org designates 79.124.17.100 as permitted sender) smtp.mailfrom=ffmpeg-devel-bounces@ffmpeg.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=chromium.org Received: from [127.0.1.1] (localhost [127.0.0.1]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTP id 6554E68A0B0; Tue, 31 Jan 2017 03:37:04 +0200 (EET) X-Original-To: ffmpeg-devel@ffmpeg.org Delivered-To: ffmpeg-devel@ffmpeg.org Received: from mail-it0-f42.google.com (mail-it0-f42.google.com [209.85.214.42]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTPS id 81F1E689FE0 for ; Tue, 31 Jan 2017 03:36:57 +0200 (EET) Received: by mail-it0-f42.google.com with SMTP id 203so207570082ith.0 for ; Mon, 30 Jan 2017 17:37:00 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=chromium.org; s=google; h=from:to:cc:subject:date:message-id; bh=P1zCOaxefwC9HRZ9z1uumdhWQWnLewjXjRen38LK2nE=; b=LYXjn+nxcVLr1Hrb/8vZkXolE2/UHBwnM3dvyv5oF23B7uXpgOVVernsyWqEdgVqnM fTVXJVj9aTq/Ksu6guzo5zv2a+xYLyBE9fIbbhA57R5cddzWvKubc+Vyi+WJHtzrXbyI NE5VPUbYSMV16UiUZ0D0LpGa+uGCOwuQoiy0w= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id; bh=P1zCOaxefwC9HRZ9z1uumdhWQWnLewjXjRen38LK2nE=; b=Pg0S9oQn7H8C+Silqn4W1E2qb4zK6M+sQp9rLHDUZq9V+hgJjbYHqJk/fm+PdbYsY2 0QLAs6ewsSg3tx3HPZs4jZdVKeSm2gFGfgE1B0HZlVqsntAu6ciUS1YcP3SoMLOJOwES mEiegs74F1381mIhY/AnvRcldpOsuBRaMXLDpUPKPrFbeUREvuGiZWKi1hLH4kukV+Pg Cy9lp/2zXXrj3l2wDrOOrozy/O2cfys3TsSXUma0KkposvEODOkc1E86t6dalfxaer1L 9rfafVEwuxkFEbhU2tUYkEZvAy8AXgixlRxlvbSOADj+vC6UEZBxGIM9LIsPfXNzppSE oVjA== X-Gm-Message-State: AIkVDXIOLU0Dusk2yzIvsbjmJQMPhOhn/rToj/QApX2Phu+vf/KdAxsXBVfzizkxqhHEs0kO X-Received: by 10.84.198.3 with SMTP id o3mr35977655pld.170.1485824781809; Mon, 30 Jan 2017 17:06:21 -0800 (PST) Received: from chcunningham-linux.sea.corp.google.com ([172.31.70.190]) by smtp.gmail.com with ESMTPSA id e127sm35430397pfh.89.2017.01.30.17.06.21 (version=TLS1_2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Mon, 30 Jan 2017 17:06:21 -0800 (PST) From: Chris Cunningham To: ffmpeg-devel@ffmpeg.org Date: Mon, 30 Jan 2017 17:05:49 -0800 Message-Id: <20170131010549.2403-1-chcunningham@chromium.org> X-Mailer: git-send-email 2.11.0.483.g087da7b7c-goog Subject: [FFmpeg-devel] [PATCH] lavf/matroskadec: fix is_keyframe for early Blocks X-BeenThere: ffmpeg-devel@ffmpeg.org X-Mailman-Version: 2.1.20 Precedence: list List-Id: FFmpeg development discussions and patches List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Reply-To: FFmpeg development discussions and patches Cc: Chris Cunningham MIME-Version: 1.0 Errors-To: ffmpeg-devel-bounces@ffmpeg.org Sender: "ffmpeg-devel" Blocks are marked as key frames whenever the "reference" field is zero. This is incorrect for non-keyframe Blocks that take a refernce on a keyframe at time zero. Now using -1 to denote "no reference". Reported to chromium at http://crbug.com/497889 (contains sample) --- libavformat/matroskadec.c | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/libavformat/matroskadec.c b/libavformat/matroskadec.c index e6737a70b2..0d033b574c 100644 --- a/libavformat/matroskadec.c +++ b/libavformat/matroskadec.c @@ -89,6 +89,7 @@ typedef const struct EbmlSyntax { int list_elem_size; int data_offset; union { + int64_t i; uint64_t u; double f; const char *s; @@ -696,7 +697,7 @@ static const EbmlSyntax matroska_blockgroup[] = { { MATROSKA_ID_SIMPLEBLOCK, EBML_BIN, 0, offsetof(MatroskaBlock, bin) }, { MATROSKA_ID_BLOCKDURATION, EBML_UINT, 0, offsetof(MatroskaBlock, duration) }, { MATROSKA_ID_DISCARDPADDING, EBML_SINT, 0, offsetof(MatroskaBlock, discard_padding) }, - { MATROSKA_ID_BLOCKREFERENCE, EBML_SINT, 0, offsetof(MatroskaBlock, reference) }, + { MATROSKA_ID_BLOCKREFERENCE, EBML_SINT, 0, offsetof(MatroskaBlock, reference), { .i = -1 } }, { MATROSKA_ID_CODECSTATE, EBML_NONE }, { 1, EBML_UINT, 0, offsetof(MatroskaBlock, non_simple), { .u = 1 } }, { 0 } @@ -1071,6 +1072,8 @@ static int ebml_parse_nest(MatroskaDemuxContext *matroska, EbmlSyntax *syntax, for (i = 0; syntax[i].id; i++) switch (syntax[i].type) { + case EBML_SINT: + *(int64_t *) ((char *) data + syntax[i].data_offset) = syntax[i].def.i; case EBML_UINT: *(uint64_t *) ((char *) data + syntax[i].data_offset) = syntax[i].def.u; break; @@ -3361,7 +3364,7 @@ static int matroska_parse_cluster_incremental(MatroskaDemuxContext *matroska) matroska->current_cluster_num_blocks = blocks_list->nb_elem; i = blocks_list->nb_elem - 1; if (blocks[i].bin.size > 0 && blocks[i].bin.data) { - int is_keyframe = blocks[i].non_simple ? !blocks[i].reference : -1; + int is_keyframe = blocks[i].non_simple ? blocks[i].reference == -1 : -1; uint8_t* additional = blocks[i].additional.size > 0 ? blocks[i].additional.data : NULL; if (!blocks[i].non_simple) @@ -3399,7 +3402,7 @@ static int matroska_parse_cluster(MatroskaDemuxContext *matroska) blocks = blocks_list->elem; for (i = 0; i < blocks_list->nb_elem; i++) if (blocks[i].bin.size > 0 && blocks[i].bin.data) { - int is_keyframe = blocks[i].non_simple ? !blocks[i].reference : -1; + int is_keyframe = blocks[i].non_simple ? blocks[i].reference == -1 : -1; res = matroska_parse_block(matroska, blocks[i].bin.data, blocks[i].bin.size, blocks[i].bin.pos, cluster.timecode, blocks[i].duration,