From patchwork Mon Jun 19 23:42:34 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Hein-Pieter van Braam X-Patchwork-Id: 4053 Delivered-To: ffmpegpatchwork@gmail.com Received: by 10.103.22.4 with SMTP id 4csp1139824vsw; Mon, 19 Jun 2017 16:43:05 -0700 (PDT) X-Received: by 10.223.170.138 with SMTP id h10mr6388619wrc.153.1497915785710; Mon, 19 Jun 2017 16:43:05 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1497915785; cv=none; d=google.com; s=arc-20160816; b=KiJON2UwXMso61S4jB/KfxK9EBEZxIQsOMEtdJbRePb6oGE2e+P+JWDrrFcPp+2XeW xrJfexeDL/TQMeYfgSTDYjwTG4b/CnuZOMMKhQvQITP+Ogz146HmLCaXG+WF4sgpuc2H kEoa6H5oa/S5NvPVZRPIqi5nebWaI1vxp4FvKxnrU4pkQjY0/RCOALG4sGs7zkf5RiD+ 0sprHkeGPNa9YnWUWAMHQD99T6I5mmInxQc/97PwFAKqnmBJm1PnGeES+wNO8lIiYvro ST5Ig7D/QdVKamyAr/Iq+1ZNanRs8EUjheGGooSwRZNQz5fN/xxe/U0MawWreMeKvju2 XLVQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=sender:errors-to:content-transfer-encoding:mime-version:cc:reply-to :list-subscribe:list-help:list-post:list-archive:list-unsubscribe :list-id:precedence:subject:references:in-reply-to:message-id:date :to:from:dkim-signature:dkim-filter:delivered-to :arc-authentication-results; bh=lkeYLdWQc9yqk3RmFLQU9tTH66x4rrl1YBEXG3sr6K8=; b=M0WTTdmg06h0ce50xyUWWY+ssGC0CEpvEziE+lTSUIs2HefZyu4U6CZa764CaEAjJz 3UzcARgJPCHFGImwZ1HSjtcVu4dsIO4PNJ1DEE7tiu7pMwM9SRR3U0wRmVNnPyBlq7nq j/zLkTBLbYf6xK2BzvH8V9gckuwVSfXMZ30sXzfPvBzW2ETQ6+2EDzzveomCg08ZzrPu 4duMnbZvMXBXVq4wDrNsB5unTfJoZ74DFkz84lU68W+MIT1qsMqD4jmxlMxjRFBEnl/h 1YMTAFooC+tWx4tNDxkjnJa9COZnaf8wpx8RpBHfbn1MeCIyGyG+17afHFX6Tn5fL851 I3ww== ARC-Authentication-Results: i=1; mx.google.com; dkim=neutral (body hash did not verify) header.i=@tmm.cx header.b=L/lX4/Ql; 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=REJECT dis=NONE) header.from=tmm.cx Return-Path: Received: from ffbox0-bg.mplayerhq.hu (ffbox0-bg.ffmpeg.org. [79.124.17.100]) by mx.google.com with ESMTP id n71si11648147wrb.360.2017.06.19.16.43.05; Mon, 19 Jun 2017 16:43:05 -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=@tmm.cx header.b=L/lX4/Ql; 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=REJECT dis=NONE) header.from=tmm.cx Received: from [127.0.1.1] (localhost [127.0.0.1]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTP id E6A8768A634; Tue, 20 Jun 2017 02:42:46 +0300 (EEST) X-Original-To: ffmpeg-devel@ffmpeg.org Delivered-To: ffmpeg-devel@ffmpeg.org Received: from eva.tmm.cx (eva.tmm.cx [5.9.73.21]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTP id 320BC68A59B for ; Tue, 20 Jun 2017 02:42:40 +0300 (EEST) Received: from lola.ttg.global (unknown [92.110.172.3]) by eva.tmm.cx (Postfix) with ESMTPSA id C777D17DD510; Mon, 19 Jun 2017 23:42:44 +0000 (UTC) DKIM-Filter: OpenDKIM Filter v2.11.0 eva.tmm.cx C777D17DD510 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=tmm.cx; s=mail; t=1497915765; bh=bHXokmlqhBcAdRb/YNhsueYuvRAskckJkeesqAjs2vE=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=L/lX4/QloMa5fvTNxThgR3W9e1buPbkveGlTVFiQMWepxupoY3UPBHUhAlRO2+JhP hKmF5fZENTGDOzxu4aQfJBlFKxifxWFrNIj4PfkdJSagi5axr02RVdJh8Jgr6orSgK r74dOdbYSAE38BVDCDNKBIgy4X195om5kjAWHK+c= From: Hein-Pieter van Braam To: FFmpeg development discussions and patches Date: Tue, 20 Jun 2017 01:42:34 +0200 Message-Id: <20170619234238.1364-2-hp@tmm.cx> X-Mailer: git-send-email 2.9.4 In-Reply-To: <20170619234238.1364-1-hp@tmm.cx> References: <20170619234238.1364-1-hp@tmm.cx> X-Spam-Status: No, score=0.0 required=2.4 tests=UNPARSEABLE_RELAY autolearn=ham autolearn_force=no version=3.4.1 X-Spam-Checker-Version: SpamAssassin 3.4.1 (2015-04-28) on eva.tmm.cx Subject: [FFmpeg-devel] [PATCH v2 1/5] Interplay MVE: Implement MVE SEND_BUFFER operation 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: Hein-Pieter van Braam MIME-Version: 1.0 Errors-To: ffmpeg-devel-bounces@ffmpeg.org Sender: "ffmpeg-devel" Interplay MVE movies have a SEND_BUFFER operation. Only after this command does the current decoding buffer get displayed. This is required for the other frame formats. They are fixed-size and can't always encode a full frame worth of pixeldata. This code prevents half-finished frames from being emitted. Signed-off-by: Hein-Pieter van Braam --- libavcodec/interplayvideo.c | 13 ++++++++----- libavformat/ipmovie.c | 16 +++++++++++----- 2 files changed, 19 insertions(+), 10 deletions(-) diff --git a/libavcodec/interplayvideo.c b/libavcodec/interplayvideo.c index df3314d..9fed8f6 100644 --- a/libavcodec/interplayvideo.c +++ b/libavcodec/interplayvideo.c @@ -990,6 +990,7 @@ static int ipvideo_decode_frame(AVCodecContext *avctx, IpvideoContext *s = avctx->priv_data; AVFrame *frame = data; int ret; + int send_buffer; if (av_packet_get_side_data(avpkt, AV_PKT_DATA_PARAM_CHANGE, NULL)) { av_frame_unref(s->last_frame); @@ -999,8 +1000,10 @@ static int ipvideo_decode_frame(AVCodecContext *avctx, if (buf_size < 2) return AVERROR_INVALIDDATA; + send_buffer = AV_RL8(avpkt->data); + /* decoding map contains 4 bits of information per 8x8 block */ - s->decoding_map_size = AV_RL16(avpkt->data); + s->decoding_map_size = AV_RL16(avpkt->data + 1); /* compressed buffer needs to be large enough to at least hold an entire * decoding map */ @@ -1008,9 +1011,9 @@ static int ipvideo_decode_frame(AVCodecContext *avctx, return buf_size; - s->decoding_map = buf + 2; - bytestream2_init(&s->stream_ptr, buf + 2 + s->decoding_map_size, - buf_size - s->decoding_map_size); + s->decoding_map = buf + 3; + bytestream2_init(&s->stream_ptr, buf + 3 + s->decoding_map_size, + buf_size - s->decoding_map_size - 3); if ((ret = ff_get_buffer(avctx, frame, AV_GET_BUFFER_FLAG_REF)) < 0) return ret; @@ -1028,7 +1031,7 @@ static int ipvideo_decode_frame(AVCodecContext *avctx, ipvideo_decode_opcodes(s, frame); - *got_frame = 1; + *got_frame = send_buffer; /* shuffle frames */ av_frame_unref(s->second_last_frame); diff --git a/libavformat/ipmovie.c b/libavformat/ipmovie.c index 29eeaf6..0705d33 100644 --- a/libavformat/ipmovie.c +++ b/libavformat/ipmovie.c @@ -91,6 +91,7 @@ typedef struct IPMVEContext { uint32_t palette[256]; int has_palette; int changed; + uint8_t send_buffer; unsigned int audio_bits; unsigned int audio_channels; @@ -154,9 +155,9 @@ static int load_ipmovie_packet(IPMVEContext *s, AVIOContext *pb, } else if (s->decode_map_chunk_offset) { - /* send both the decode map and the video data together */ + /* send the decode map, the video data, and the send_buffer flag together */ - if (av_new_packet(pkt, 2 + s->decode_map_chunk_size + s->video_chunk_size)) + if (av_new_packet(pkt, 3 + s->decode_map_chunk_size + s->video_chunk_size)) return CHUNK_NOMEM; if (s->has_palette) { @@ -178,8 +179,11 @@ static int load_ipmovie_packet(IPMVEContext *s, AVIOContext *pb, avio_seek(pb, s->decode_map_chunk_offset, SEEK_SET); s->decode_map_chunk_offset = 0; - AV_WL16(pkt->data, s->decode_map_chunk_size); - if (avio_read(pb, pkt->data + 2, s->decode_map_chunk_size) != + AV_WL8(pkt->data, s->send_buffer); + s->send_buffer = 0; + + AV_WL16(pkt->data + 1, s->decode_map_chunk_size); + if (avio_read(pb, pkt->data + 3, s->decode_map_chunk_size) != s->decode_map_chunk_size) { av_packet_unref(pkt); return CHUNK_EOF; @@ -188,7 +192,7 @@ static int load_ipmovie_packet(IPMVEContext *s, AVIOContext *pb, avio_seek(pb, s->video_chunk_offset, SEEK_SET); s->video_chunk_offset = 0; - if (avio_read(pb, pkt->data + 2 + s->decode_map_chunk_size, + if (avio_read(pb, pkt->data + 3 + s->decode_map_chunk_size, s->video_chunk_size) != s->video_chunk_size) { av_packet_unref(pkt); return CHUNK_EOF; @@ -444,6 +448,7 @@ static int process_ipmovie_chunk(IPMVEContext *s, AVIOContext *pb, case OPCODE_SEND_BUFFER: av_log(s->avf, AV_LOG_TRACE, "send buffer\n"); avio_skip(pb, opcode_size); + s->send_buffer = 1; break; case OPCODE_AUDIO_FRAME: @@ -590,6 +595,7 @@ static int ipmovie_read_header(AVFormatContext *s) ipmovie->video_pts = ipmovie->audio_frame_count = 0; ipmovie->audio_chunk_offset = ipmovie->video_chunk_offset = ipmovie->decode_map_chunk_offset = 0; + ipmovie->send_buffer = 0; /* on the first read, this will position the stream at the first chunk */ ipmovie->next_chunk_offset = avio_tell(pb) + 4;