From patchwork Fri Feb 2 02:43:49 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Thilo Borgmann X-Patchwork-Id: 7476 Delivered-To: ffmpegpatchwork@gmail.com Received: by 10.2.156.27 with SMTP id q27csp318393jak; Thu, 1 Feb 2018 18:43:01 -0800 (PST) X-Google-Smtp-Source: AH8x2254Cja74L7LUuv2oqLFLD7eqqr4ppjvlCErdZ8dUr8x8dCq4izsysJtlKtzStoV9d0jOfub X-Received: by 10.28.135.142 with SMTP id j136mr24890717wmd.33.1517539381149; Thu, 01 Feb 2018 18:43:01 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1517539381; cv=none; d=google.com; s=arc-20160816; b=ds2vyUrBn5bVEOWL0/s6DX8C2fNJ+e9zVa2N4x6G7tR601JPnIVszT5IECyxB4g+V6 FrTnkfTLw44IC+7dp7FhWLTLS+K1lewNIXRmaBgsb2Xlx8oSsGU1/hkxnodP9hd2N4Yx AvGQV90GMp/Ble1ONt5AP+SInYUEqhN2xDRyEUVRxyKaa3cHHtw/opa1dlPyXKHMIebR l+6MhXemeiRRAVTtd59p+xSZLhIOr5JPrL5VCeacn2hf4k4lj4v3E3vKG4td1bfa8OZK f+NesqkvIopm95Q2zvRP3A66WqNm9+mrpZestVizMS9zuSl82KMy2cHUJHCI061Savtb kAOQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=sender:errors-to:reply-to:list-subscribe:list-help:list-post :list-archive:list-unsubscribe:list-id:precedence:subject :content-language:in-reply-to:mime-version:date:message-id:from :references:to:dkim-signature:delivered-to :arc-authentication-results; bh=PMUC4rJD0foAAey5Gp44zhOoI2ENkiZ2LRy10qe7vzY=; b=uu0KKTVBpTpkmtVmG1uUZr0On3wwwTJCOX/Pxqe3ZuRnjFFpk4+ggN6LS8VyQbu38j n6VxZVsUinombZuYmRB6IbvWPSNMUuMwzHsIr4bDtZRnL1geTPAXvhfG/y/RWuDMnD/J oZ7Dl9gI8SwSj9icm6nGVQSG+Udo3eLXQ9gBQkVDu+GpYsuSTld7XbzqhzJOzvvl5FDp yTd04FtplJ+qrP5Np8nP79szMwwoBLCRkcSL0bRGL3CqjMGPKtIR+FYhd3FO4FzFtOOU L1vDb+O57t0jKrqfc0HLLnFfZAWz0mUN5w9oNxfxzFfwBBSEAu6shXnSjIZkJ9iZz/am SalQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=neutral (body hash did not verify) header.i=@mail.de header.s=mailde201610 header.b=R3LwBdtW; 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=mail.de Return-Path: Received: from ffbox0-bg.mplayerhq.hu (ffbox0-bg.ffmpeg.org. [79.124.17.100]) by mx.google.com with ESMTP id p5si745163wre.264.2018.02.01.18.43.00; Thu, 01 Feb 2018 18:43:01 -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=@mail.de header.s=mailde201610 header.b=R3LwBdtW; 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=mail.de Received: from [127.0.1.1] (localhost [127.0.0.1]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTP id D0C75688310; Fri, 2 Feb 2018 04:42:52 +0200 (EET) X-Original-To: ffmpeg-devel@ffmpeg.org Delivered-To: ffmpeg-devel@ffmpeg.org Received: from shout02.mail.de (shout02.mail.de [213.128.151.217]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTPS id D7C6868824F for ; Fri, 2 Feb 2018 04:42:45 +0200 (EET) Received: from postfix03.mail.de (postfix03.bt.mail.de [10.0.121.127]) by shout02.mail.de (Postfix) with ESMTP id B03486CEB0 for ; Fri, 2 Feb 2018 03:42:51 +0100 (CET) Received: from smtp03.mail.de (smtp03.bt.mail.de [10.0.121.213]) by postfix03.mail.de (Postfix) with ESMTP id 9A90A40180 for ; Fri, 2 Feb 2018 03:42:51 +0100 (CET) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=mail.de; s=mailde201610; t=1517539371; bh=5xiSAxC5tou2FwtXRxo+yoyYYU7xrMcMoZtat8Nags4=; h=Subject:To:References:From:Date:In-Reply-To:From; b=R3LwBdtWE2AruKCpr+lC9zwOwvwQM7QGnbKTK1A2rQ40cgt9f8nsn7LW/j5M46nE2 D3wqywkgR8t8Elq933J1g99PbmzO/a9uJf+TJhg21cJuR9ir8Nyd8+AiudB/k6A5WY RF36zE0aQrpkbYqsfp6Tdj1EI78tsUK2p5lX+sjg= Received: from [127.0.0.1] (localhost [127.0.0.1]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp03.mail.de (Postfix) with ESMTPSA id 6C0B380049 for ; Fri, 2 Feb 2018 03:42:51 +0100 (CET) To: ffmpeg-devel@ffmpeg.org References: <7225d2d3-f8a6-f89b-826f-6d4b9a0c49c0@mail.de> From: Thilo Borgmann Message-ID: <86a53294-793c-8372-4991-c2a8e0bb0b88@mail.de> Date: Fri, 2 Feb 2018 03:43:49 +0100 MIME-Version: 1.0 In-Reply-To: <7225d2d3-f8a6-f89b-826f-6d4b9a0c49c0@mail.de> Content-Language: en-US Subject: [FFmpeg-devel] [V2 PATCH 1/4] lavformat/rm: Add decoding of MLTI chunks, prefer audio, dts for multiple streams, several muxer fixes depending on codec id 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 Errors-To: ffmpeg-devel-bounces@ffmpeg.org Sender: "ffmpeg-devel" All of these should be valid for RMVB (file format version 1). I have no .rm files to test these changes, only .rmhd ones. AAC muxing yet not included, requires file format version 2. However, if all muxer changes are applied, all existing FATE tests involving .rm muxing/demuxing pass for me. -Thilo From c6acdc9eb68b384822345aae7e12e84c05720180 Mon Sep 17 00:00:00 2001 From: Thilo Borgmann Date: Fri, 2 Feb 2018 02:48:34 +0100 Subject: [PATCH 1/4] lavformat/rm: Add decoding of MLTI chunks, prefer audio dts for multiple streams, several muxer fixes depending on codec id --- libavformat/rmdec.c | 35 +++++++++++++++++++++++++++++++---- libavformat/rmenc.c | 30 +++++++++++++++++++++++++----- 2 files changed, 56 insertions(+), 9 deletions(-) diff --git a/libavformat/rmdec.c b/libavformat/rmdec.c index fea71a2..cf3d545 100644 --- a/libavformat/rmdec.c +++ b/libavformat/rmdec.c @@ -330,7 +330,20 @@ int ff_rm_read_mdpr_codecdata(AVFormatContext *s, AVIOContext *pb, codec_pos = avio_tell(pb); v = avio_rb32(pb); - if (v == MKTAG(0xfd, 'a', 'r', '.')) { + if (v == MKBETAG('M', 'L', 'T', 'I')) { + int number_of_streams = avio_rb16(pb); + int number_of_mdpr; + int i; + for (i = 0; i < number_of_streams; i++) { + avio_rb16(pb); + } + number_of_mdpr = avio_rb16(pb); + if (number_of_mdpr != 1) { + avpriv_request_sample(s, "MLTI with multiple MDPR"); + } + avio_rb32(pb); + v = avio_rb32(pb); + } else if (v == MKTAG(0xfd, 'a', 'r', '.')) { /* ra type header */ if (rm_read_audio_stream_info(s, pb, st, rst, 0)) return -1; @@ -1089,7 +1102,9 @@ static int64_t rm_read_dts(AVFormatContext *s, int stream_index, { RMDemuxContext *rm = s->priv_data; int64_t pos, dts; + int64_t pos_audio, dts_audio; int stream_index2, flags, len, h; + int audio_override = 0; pos = *ppos; @@ -1114,20 +1129,32 @@ static int64_t rm_read_dts(AVFormatContext *s, int stream_index, if(!(h & 0x40)){ seq = avio_r8(s->pb); len--; } + if (!(flags & 2) || + (seq & 0x7F) != 1 || + stream_index2 != stream_index) { + audio_override = 0; + } } if((flags&2) && (seq&0x7F) == 1){ av_log(s, AV_LOG_TRACE, "%d %d-%d %"PRId64" %d\n", flags, stream_index2, stream_index, dts, seq); av_add_index_entry(st, pos, dts, 0, 0, AVINDEX_KEYFRAME); - if(stream_index2 == stream_index) + if(stream_index2 == stream_index) { + if (st->codecpar->codec_type == AVMEDIA_TYPE_AUDIO) { + dts_audio = dts; + pos_audio = pos; + audio_override = 1; + } + break; + } } avio_skip(s->pb, len); } - *ppos = pos; - return dts; + *ppos = (audio_override ? pos_audio : pos); + return (audio_override ? dts_audio : dts); } static int rm_read_seek(AVFormatContext *s, int stream_index, diff --git a/libavformat/rmenc.c b/libavformat/rmenc.c index 3bff4da..83b0f3c 100644 --- a/libavformat/rmenc.c +++ b/libavformat/rmenc.c @@ -152,7 +152,13 @@ static int rv10_write_header(AVFormatContext *ctx, } else { desc = "The Video Stream"; mimetype = "video/x-pn-realvideo"; - codec_data_size = 34; + if(stream->par->codec_id == AV_CODEC_ID_RV10 || + stream->par->codec_id == AV_CODEC_ID_RV20 || + stream->par->codec_id == AV_CODEC_ID_RV40) { + codec_data_size = 34; + } else { + codec_data_size = 26 + stream->par->extradata_size; + } } ffio_wfourcc(s,"MDPR"); @@ -245,10 +251,21 @@ static int rv10_write_header(AVFormatContext *ctx, /* video codec info */ avio_wb32(s,34); /* size */ ffio_wfourcc(s, "VIDO"); - if(stream->par->codec_id == AV_CODEC_ID_RV10) + switch (stream->par->codec_id) { + case AV_CODEC_ID_RV10: ffio_wfourcc(s,"RV10"); - else + break; + case AV_CODEC_ID_RV20: ffio_wfourcc(s,"RV20"); + break; + case AV_CODEC_ID_RV30: + ffio_wfourcc(s,"RV30"); + break; + case AV_CODEC_ID_RV40: + ffio_wfourcc(s,"RV40"); + break; + } + avio_wb16(s, stream->par->width); avio_wb16(s, stream->par->height); @@ -346,8 +363,11 @@ static int rm_write_header(AVFormatContext *s) break; case AVMEDIA_TYPE_VIDEO: rm->video_stream = stream; - // TODO: should be avg_frame_rate - stream->frame_rate = av_inv_q(st->time_base); + if (st->codecpar->codec_id == AV_CODEC_ID_RV40) { + stream->frame_rate = st->avg_frame_rate; + } else { + stream->frame_rate = av_inv_q(st->time_base); + } /* XXX: dummy values */ stream->packet_max_size = 4096; stream->nb_packets = 0;