From patchwork Wed Oct 26 19:40:21 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Philip Langdale X-Patchwork-Id: 1186 Delivered-To: ffmpegpatchwork@gmail.com Received: by 10.103.140.133 with SMTP id o127csp220107vsd; Wed, 26 Oct 2016 12:52:02 -0700 (PDT) X-Received: by 10.28.193.1 with SMTP id r1mr1505170wmf.11.1477511522390; Wed, 26 Oct 2016 12:52:02 -0700 (PDT) Return-Path: Received: from ffbox0-bg.mplayerhq.hu (ffbox0-bg.ffmpeg.org. [79.124.17.100]) by mx.google.com with ESMTP id s4si4451239wjp.207.2016.10.26.12.52.01; Wed, 26 Oct 2016 12:52:02 -0700 (PDT) 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=@overt.org; dkim=neutral (body hash did not verify) header.i=@overt.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 Received: from [127.0.1.1] (localhost [127.0.0.1]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTP id 1A6F1689E64; Wed, 26 Oct 2016 22:51:20 +0300 (EEST) X-Original-To: ffmpeg-devel@ffmpeg.org Delivered-To: ffmpeg-devel@ffmpeg.org Received: from rs224.mailgun.us (rs224.mailgun.us [209.61.151.224]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTP id A3880689E3C for ; Wed, 26 Oct 2016 22:51:11 +0300 (EEST) DKIM-Signature: a=rsa-sha256; v=1; c=relaxed/relaxed; d=overt.org; q=dns/txt; s=k1; t=1477511473; h=References: In-Reply-To: Message-Id: Date: Subject: Cc: To: From: Sender; bh=47jhom1JL+9+j5fhJcOCITxPUOfuWxBUNc7PrFh6y4w=; b=HIMTYKrS8U6JiHgX7scmZ2yXHj3LvR+VUvITsccfLv+Y6bdDAug+twCSfBJ64/uGWJ8PoVY2 Um7JyLxWOLtJHnwuP7f5OFNZTPoa6exxavq3tEii6qotTwgVf28P6uBMGLV6+nO4Hrq7O+QI TE3BS60rS7IgI91+vGwVUAvLhyQ= DomainKey-Signature: a=rsa-sha1; c=nofws; d=overt.org; s=k1; q=dns; h=Sender: From: To: Cc: Subject: Date: Message-Id: In-Reply-To: References; b=Aoxx2Gn4GHRQIXy8wz1zvm4AUgc3TnknkA4ErRkDSYPXOt5o6kH9/hY5CVldu1Q2T9ec4J 8wV5ji7QyfU5eL/+kx7InYGgX9oQo4K+DutPMuGZlOv5Ys6So806JrSpe5tflraCFlfT7nKN RzxKQObEi5ybDanJ3gN2ZPtkynIA4= X-Mailgun-Sending-Ip: 209.61.151.224 X-Mailgun-Sid: WyIyM2Q3MCIsICJmZm1wZWctZGV2ZWxAZmZtcGVnLm9yZyIsICI0YTg5NjEiXQ== Received: from mail.overt.org (155.208.178.107.bc.googleusercontent.com [107.178.208.155]) by mxa.mailgun.org with ESMTP id 581106b3.7f91f93dad50-in03; Wed, 26 Oct 2016 19:40:35 -0000 (UTC) Received: from authenticated-user (mail.overt.org [107.178.208.155]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by mail.overt.org (Postfix) with ESMTPSA id E736561643; Wed, 26 Oct 2016 19:40:34 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=simple/simple; d=overt.org; s=mail; t=1477510835; bh=yzyOBOKIgS+j/xV6uiZsh122KpF9B8PFdAXBNOpa8ZQ=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=J1OdFtqggDlpV3m7gNAT36cZdhcy5EO9aP/CuJDZczgkDbJeHeT/fSkaUKsWlpNn/ 5xNiWR6kT2mfqJS8TIO4lbDpiKQ3VU2KTFhn4xhHTq0TblcD7ZE85acgE2UsyCm385 bry7O5Zgb4w8Qe6AQAn0Fg755ZPVlRn3HBGxFA0X7LkXRnNWY87dXgzCPaINfk+xwn VKaVrGi1fXbwusNILofgCmCGzms5J/hMWIQ84gS4dbexbMe5ciHJZR5GRWeG+G6UW9 mvSRv3E8NoZijpp3coqKu1y7UQ2HpZF+YftEHgmgQCfrTgNRC3QoHZYMOG9MfzuHoe GwQ8d0BL5Yfdw== From: Philip Langdale To: ffmpeg-devel@ffmpeg.org Date: Wed, 26 Oct 2016 12:40:21 -0700 Message-Id: <20161026194028.26438-4-philipl@overt.org> In-Reply-To: <20161026194028.26438-1-philipl@overt.org> References: <20161026194028.26438-1-philipl@overt.org> Subject: [FFmpeg-devel] [PATCH 03/10] crystalhd: Revert back to letting hardware handle packed b-frames 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: Philip Langdale MIME-Version: 1.0 Errors-To: ffmpeg-devel-bounces@ffmpeg.org Sender: "ffmpeg-devel" I'm not sure why, but the mpeg4_unpack_bframes bsf is not interacting well with seeking. Looking at the code, it should be ok, with possibly one warning shown, but I see it getting stuck for an extended period of time after a seek where a packed frame is cached to be shown later. So, I gave up on that and went back to making the old hardware based path work. Turns out that it wasn't broken except that some samples have a 6 byte drop packet which I wasn't accounting for. Now it works again and seeks are good. Signed-off-by: Philip Langdale --- libavcodec/crystalhd.c | 37 +++++++++++++++++++++++++++++-------- 1 file changed, 29 insertions(+), 8 deletions(-) diff --git a/libavcodec/crystalhd.c b/libavcodec/crystalhd.c index dca58f2..c1ca066 100644 --- a/libavcodec/crystalhd.c +++ b/libavcodec/crystalhd.c @@ -140,6 +140,7 @@ typedef struct { /* Options */ uint32_t sWidth; + uint8_t bframe_bug; } CHDContext; static const AVOption options[] = { @@ -460,14 +461,6 @@ static av_cold int init(AVCodecContext *avctx) format.pMetaData = avctx->extradata; format.metaDataSz = avctx->extradata_size; break; - case BC_MSUBTYPE_DIVX: - avret = init_bsf(avctx, "mpeg4_unpack_bframes"); - if (avret != 0) { - return avret; - } - format.pMetaData = avctx->extradata; - format.metaDataSz = avctx->extradata_size; - break; case BC_MSUBTYPE_H264: format.startCodeSz = 4; // Fall-through @@ -476,6 +469,7 @@ static av_cold int init(AVCodecContext *avctx) case BC_MSUBTYPE_WMV3: case BC_MSUBTYPE_WMVA: case BC_MSUBTYPE_MPEG2VIDEO: + case BC_MSUBTYPE_DIVX: case BC_MSUBTYPE_DIVX311: format.pMetaData = avctx->extradata; format.metaDataSz = avctx->extradata_size; @@ -829,6 +823,17 @@ static inline CopyRet receive_frame(AVCodecContext *avctx, priv->last_picture = output.PicInfo.picture_number - 1; } + if (avctx->codec->id == AV_CODEC_ID_MPEG4 && + output.PicInfo.timeStamp == 0 && priv->bframe_bug) { + if (!priv->bframe_bug) { + av_log(avctx, AV_LOG_VERBOSE, + "CrystalHD: Not returning packed frame twice.\n"); + } + priv->last_picture++; + DtsReleaseOutputBuffs(dev, NULL, FALSE); + return RET_COPY_AGAIN; + } + print_frame_info(priv, &output); if (priv->last_picture + 1 < output.PicInfo.picture_number) { @@ -879,6 +884,22 @@ static int crystalhd_decode_packet(AVCodecContext *avctx, const AVPacket *avpkt) if (avpkt && avpkt->size) { int32_t tx_free = (int32_t)DtsTxFreeSize(dev); + if (!priv->bframe_bug && (avpkt->size == 6 || avpkt->size == 7)) { + /* + * Drop frames trigger the bug + */ + av_log(avctx, AV_LOG_WARNING, + "CrystalHD: Enabling work-around for packed b-frame bug\n"); + priv->bframe_bug = 1; + } else if (priv->bframe_bug && avpkt->size == 8) { + /* + * Delay frames don't trigger the bug + */ + av_log(avctx, AV_LOG_WARNING, + "CrystalHD: Disabling work-around for packed b-frame bug\n"); + priv->bframe_bug = 0; + } + if (priv->bsfc) { AVPacket filter_packet = { 0 };