From patchwork Sun Jun 18 01:25:43 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: 4013 Delivered-To: ffmpegpatchwork@gmail.com Received: by 10.103.22.4 with SMTP id 4csp298644vsw; Sat, 17 Jun 2017 18:26:02 -0700 (PDT) X-Received: by 10.223.166.248 with SMTP id t111mr12449874wrc.39.1497749162881; Sat, 17 Jun 2017 18:26:02 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1497749162; cv=none; d=google.com; s=arc-20160816; b=hZfyUeF2t7ezRWbMxQoUVqM9fa9MFs4z8s3X595UOMvBpYWwiloPY8lOgKRml1j2KF bEYh3WdRMFR/rK7SoIiJELyTXljBZaELgjJd0bpR0qlERQlF8RgzBDGTvLpD0X5akqAj p6fYEtgr7IIdxNbDv7x2ws+yRHIlpwHe4khNjOsIY1G344cIFugH1uR4z8b8gNoyEGwz q20bQhZO2cwF0ZqMiMLV6lBVn1yBXqZUBkgbdC7SGMYCY0pqH0ZApoNDGP8UwaHVohoy 6iLRmliWYFDKbur66tpaTINB3+QxPQ+Elcmi1MhSHNB7HzzXYkxO2nKrtb+ipKlQGDxK 7WRA== 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=oUwXVjhg6C7zWptt3jRz0LQpG3hZyB556nUm3tJiEko=; b=dWdcTPFb4E21auJ4oEzOBVmSB/WxARWkBr0Gczidl1Hb4klwJCoPfea9VBuzddOwr/ tXQlCfzqJP/pfeaA0yOuWE0wJHzfh1PWXQLxGHCgrdRGT/VlWVISFlraoliC2yeb9TRM /gYBnzGuXSulj1MB7IUp6qzVdcGmTxJ4vRZreb8dRoteIiaTMBZoX4ID9hICi+ITkWk7 vOgGwAIwq8J5Jdm6IMyjQ8vS2BpliF6WH+qeDMmf7jNpuRijTGksxvM7Xg97PxRfJJPT 976BIj8+m7+ZFns6gcTsyhUbUImUqs5GM8UKgSDlp1/NQTNrSj0J9YGAPTnkSAJa+E0U Z2RQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=neutral (body hash did not verify) header.i=@tmm.cx header.b=QJiDfcLF; 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 g15si6058392wrd.178.2017.06.17.18.26.02; Sat, 17 Jun 2017 18:26: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=@tmm.cx header.b=QJiDfcLF; 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 16960689F92; Sun, 18 Jun 2017 04:25:54 +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 7F486689F68 for ; Sun, 18 Jun 2017 04:25:46 +0300 (EEST) Received: from lola.ttg.global (unknown [92.110.172.3]) by eva.tmm.cx (Postfix) with ESMTPSA id 7374917CE631; Sun, 18 Jun 2017 01:25:49 +0000 (UTC) DKIM-Filter: OpenDKIM Filter v2.11.0 eva.tmm.cx 7374917CE631 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=tmm.cx; s=mail; t=1497749150; bh=dUmRhPGkTmtGgRMETVZt721I9rsxZVGwWGqA5eif06s=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=QJiDfcLFG7RuLy5MOfxL0eCPJyW+aJ5AkNoRsJHCCrsXnTB1kaHmWbUibNan+rnS0 Q8pBMyzyBXchSZFMPwNbYz5Gb7szn/fzXVgezqUb2Y/wyiY2wewfKVv+9U91bCGC3z jmAdOJTZDXP3VB8u4mSA4cc4WBGq6ZBtvQvkcVWs= From: Hein-Pieter van Braam To: FFmpeg development discussions and patches Date: Sun, 18 Jun 2017 03:25:43 +0200 Message-Id: <20170618012547.13614-2-hp@tmm.cx> X-Mailer: git-send-email 2.9.4 In-Reply-To: <20170618012547.13614-1-hp@tmm.cx> References: <20170618012547.13614-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 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 a83909f..db4d919 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;