From patchwork Wed Apr 4 08:38:04 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "Dixit, Vishwanath" X-Patchwork-Id: 8320 Delivered-To: ffmpegpatchwork@gmail.com Received: by 10.2.1.70 with SMTP id c67csp4619737jad; Wed, 4 Apr 2018 01:38:23 -0700 (PDT) X-Google-Smtp-Source: AIpwx4+sjAnUQNh3Y24bvI1SCPUbKzpAkKE1oF9B5jC8OMNJUPP2cWSUVLWnNNQ2hwfcQas9ZhYy X-Received: by 10.223.132.230 with SMTP id 93mr11284102wrg.242.1522831103763; Wed, 04 Apr 2018 01:38:23 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1522831103; cv=none; d=google.com; s=arc-20160816; b=sxvbvN/dCThBXoCX1SRypcXcLzwqU4f7kDy7XyMUIvTRARrOsh5G4QK6NgfBBv99pa INGzjCR6dNftEDGgZrwSQk7kJ8ZyJ4F0g/P+uu0qktTjIHKi8HJ3oB3t9I69BiSeoNpd 7pfkqn8NGytC5/MMJrGBfN50HxzNwvrROSpt7HamI0NOqq/wefRuvFP9c5H1KNM0BeiZ x6AUlFRD3GQDpEphDTyPshSIU5Xje3Dd+hlOrR5i4TptvmHiuWWz1US87dfIIw95j9Hg sPAxPHBWqZrndUAX0H1zex2b+PoFwxpTYPfj1DYYjHZpAE/3j6UJfUHwQ/FnX7jG0WS3 CYbQ== 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:feedback-id:references:in-reply-to :message-id:date:to:from:dkim-signature:delivered-to :arc-authentication-results; bh=ZFY8pRIbCaUnjpR6u6lfmjkMo0CuWNpWwRFBDjZ59Xw=; b=WwmVg7fVjPUgxBYp6WUgT3gfHsBkn9zhQpWYqW8eYlBH9jk2rOme0bV1Js2IbA1mml l1jnblg2S3aRxd0nAdp1gWhUli6dgRDnZFG4GTg2KgKkxZxwBO1ZaM2YJCbv9MEdadWv saxq14N3/gZ+Me6J3DRdYefFC5j9geqNcg7dHkR4sJ0eHmj8oXCUAfSNcBCwY79vLX83 N83GNhcimZ+5KtsZ5hliMZYDpwSbh4dVDXIF2mMZxx1kb2HlCGlptXIZtYLNsoEUD9it GXtdokk9RtOwPbA4B3m9BYiJ/7lXaDobX1qFP7ZaVS/YRvYyGjeKL7Tog01Eef7b2Jzb qQ+g== ARC-Authentication-Results: i=1; mx.google.com; dkim=neutral (body hash did not verify) header.i=@smtpservice.net header.s=m78bu0.a1-4.dyn header.b=b5te8mXW; 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=QUARANTINE sp=NONE dis=NONE) header.from=akamai.com Return-Path: Received: from ffbox0-bg.mplayerhq.hu (ffbox0-bg.ffmpeg.org. [79.124.17.100]) by mx.google.com with ESMTP id w59si3635962wrb.43.2018.04.04.01.38.23; Wed, 04 Apr 2018 01:38:23 -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=@smtpservice.net header.s=m78bu0.a1-4.dyn header.b=b5te8mXW; 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=QUARANTINE sp=NONE dis=NONE) header.from=akamai.com Received: from [127.0.1.1] (localhost [127.0.0.1]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTP id 3EC72689C88; Wed, 4 Apr 2018 11:37:51 +0300 (EEST) X-Original-To: ffmpeg-devel@ffmpeg.org Delivered-To: ffmpeg-devel@ffmpeg.org Received: from a1i318.smtp2go.com (a1i318.smtp2go.com [43.228.185.62]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTPS id 6364A689951 for ; Wed, 4 Apr 2018 11:37:50 +0300 (EEST) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=smtpservice.net; s=m78bu0.a1-4.dyn; x=1522831991; h=Feedback-ID: X-Smtpcorp-Track:Message-Id:Date:Subject:To:From:Reply-To:Sender: List-Unsubscribe; bh=s6LtpxSV/sNyxDp/3aiWOPSyumYIXZWFsN6wCscpb2Y=; b=b5te8mXW QUV4T54OYQQoNnG8HV0q7VhCQaEgjp29k/uJuOd07FInct4XBhvxuV2QgcQ6GfhMFXORvAVIVBSls +n3RB/chbuJyzO83UjfhPkx9Qc2l6x1MCLTzdv5sbuWB8MmYqMFzr0koZFkAW9V4SUiMOz0li8ipe uRdKBHPGwviQ9MonWkTDRZo8/x/QrTmhUh+fLYVbkXz5HBfSxk6yioMir19OtlE5MVyffYAkX4N9h eQVpnheIYkpdMXWEovAIve5OWLBrSLWSN7qMlPH77P/pP1qWl2vZLHswoF2C9ynpsTnMZPwSSfyqo 5yeHFpBJ4TpWrGj7LuSwp584Bg==; From: vdixit@akamai.com To: ffmpeg-devel@ffmpeg.org Date: Wed, 4 Apr 2018 14:08:04 +0530 Message-Id: <1522831084-7508-1-git-send-email-vdixit@akamai.com> X-Mailer: git-send-email 1.9.1 In-Reply-To: <1521782854-27249-1-git-send-email-vdixit@akamai.com> References: <1521782854-27249-1-git-send-email-vdixit@akamai.com> X-Smtpcorp-Track: 1f3dvkDIId4vKC.xu7xoh5A0 Feedback-ID: 337386m:337386asVRLGB:337386sKK1D_eiRA:SMTPCORP X-Report-Abuse: Please forward a copy of this message, including all headers, to Subject: [FFmpeg-devel] [PATCH v2 09/11] avformat/dashenc: constructing MPD's bandwidth string locally 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: Vishwanath Dixit MIME-Version: 1.0 Errors-To: ffmpeg-devel-bounces@ffmpeg.org Sender: "ffmpeg-devel" From: Vishwanath Dixit --- libavformat/dashenc.c | 20 +++++++++----------- 1 file changed, 9 insertions(+), 11 deletions(-) diff --git a/libavformat/dashenc.c b/libavformat/dashenc.c index 72431b7..31b0c92 100644 --- a/libavformat/dashenc.c +++ b/libavformat/dashenc.c @@ -78,7 +78,6 @@ typedef struct OutputStream { int64_t first_pts, start_pts, max_pts; int64_t last_dts; int bit_rate; - char bandwidth_str[64]; char codec_str[100]; int written_len; @@ -547,20 +546,25 @@ static int write_adaptation_set(AVFormatContext *s, AVIOContext *out, int as_ind for (i = 0; i < s->nb_streams; i++) { OutputStream *os = &c->streams[i]; + char bandwidth_str[64] = {'\0'}; if (os->as_idx - 1 != as_index) continue; + if (os->bit_rate > 0) + snprintf(bandwidth_str, sizeof(bandwidth_str), " bandwidth=\"%d\"", + os->bit_rate); + if (as->media_type == AVMEDIA_TYPE_VIDEO) { AVStream *st = s->streams[i]; avio_printf(out, "\t\t\tformat_name, os->codec_str, os->bandwidth_str, s->streams[i]->codecpar->width, s->streams[i]->codecpar->height); + i, os->format_name, os->codec_str, bandwidth_str, s->streams[i]->codecpar->width, s->streams[i]->codecpar->height); if (st->avg_frame_rate.num) avio_printf(out, " frameRate=\"%d/%d\"", st->avg_frame_rate.num, st->avg_frame_rate.den); avio_printf(out, ">\n"); } else { avio_printf(out, "\t\t\t\n", - i, os->format_name, os->codec_str, os->bandwidth_str, s->streams[i]->codecpar->sample_rate); + i, os->format_name, os->codec_str, bandwidth_str, s->streams[i]->codecpar->sample_rate); avio_printf(out, "\t\t\t\t\n", s->streams[i]->codecpar->channels); } @@ -914,10 +918,7 @@ static int dash_init(AVFormatContext *s) char filename[1024]; os->bit_rate = s->streams[i]->codecpar->bit_rate; - if (os->bit_rate) { - snprintf(os->bandwidth_str, sizeof(os->bandwidth_str), - " bandwidth=\"%d\"", os->bit_rate); - } else { + if (!os->bit_rate) { int level = s->strict_std_compliance >= FF_COMPLIANCE_STRICT ? AV_LOG_ERROR : AV_LOG_WARNING; av_log(s, level, "No bit rate set for stream %d\n", i); @@ -1232,11 +1233,8 @@ static int dash_flush(AVFormatContext *s, int final, int stream) int64_t bitrate = (int64_t) range_length * 8 * AV_TIME_BASE / av_rescale_q(os->max_pts - os->start_pts, st->time_base, AV_TIME_BASE_Q); - if (bitrate >= 0) { + if (bitrate >= 0) os->bit_rate = bitrate; - snprintf(os->bandwidth_str, sizeof(os->bandwidth_str), - " bandwidth=\"%d\"", os->bit_rate); - } } add_segment(os, os->filename, os->start_pts, os->max_pts - os->start_pts, os->pos, range_length, index_length); av_log(s, AV_LOG_VERBOSE, "Representation %d media segment %d written to: %s\n", i, os->segment_index, os->full_path);