From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from ffbox0-bg.mplayerhq.hu (ffbox0-bg.ffmpeg.org [79.124.17.100]) by master.gitmailbox.com (Postfix) with ESMTP id 4659B488E1 for ; Tue, 21 May 2024 09:05:49 +0000 (UTC) Received: from [127.0.1.1] (localhost [127.0.0.1]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTP id D908268D41C; Tue, 21 May 2024 12:03:57 +0300 (EEST) Received: from btbn.de (btbn.de [144.76.60.213]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTPS id 472FD68D392 for ; Tue, 21 May 2024 12:03:43 +0300 (EEST) Received: from [authenticated] by btbn.de (Postfix) with ESMTPSA id D754427FFD298; Tue, 21 May 2024 11:03:38 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=rothenpieler.org; s=mail; t=1716282218; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=U3P6IKRdJP8K+iN/gEUIVGT/h7SBYq7YFLCQrmFiMhg=; b=TMBPAs9BbnenoyUFYgnvzl7+fHm/dQ+hd6cY9PGnbp3ghwRNFRAnCdFwYIQTJNVhrhAhQ/ aN8QojK18fUwiG7j5D0zZhqo3ohu2Iz4R17o0F9RMB8Te0cWLXB+d0P0GrqbRCZugo7eHC icifcTodkyyWawyix70H7x4hU8+4y1hP5zvKbA/jGD0LyAxv4chzs3X7ck/2hIMQcsWUpM 10jIxh69NBJXDQTLFTWFjYDh4NwHWc+eAZzdJOBGG/spCNg0Jd60W3bQoYNUFviokGlBG9 a/kh+mUckb6Sm6u4t3db1HSv7I2JzDUpuvBB0JiOFvpU64bfttJXl4ONg1Lw4A== From: Timo Rothenpieler To: ffmpeg-devel@ffmpeg.org Date: Tue, 21 May 2024 11:02:17 +0200 Message-ID: <20240521090316.782-9-timo@rothenpieler.org> X-Mailer: git-send-email 2.43.2 In-Reply-To: <20240521090316.782-1-timo@rothenpieler.org> References: <20240521090316.782-1-timo@rothenpieler.org> MIME-Version: 1.0 Subject: [FFmpeg-devel] [PATCH 08/13] avformat/flvdec: parse enhanced rtmp multichannel info X-BeenThere: ffmpeg-devel@ffmpeg.org X-Mailman-Version: 2.1.29 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: Timo Rothenpieler Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit Errors-To: ffmpeg-devel-bounces@ffmpeg.org Sender: "ffmpeg-devel" Archived-At: List-Archive: List-Post: --- libavformat/flvdec.c | 41 +++++++++++++++++++++++++---------------- 1 file changed, 25 insertions(+), 16 deletions(-) diff --git a/libavformat/flvdec.c b/libavformat/flvdec.c index ee2a1931b2..890958351a 100644 --- a/libavformat/flvdec.c +++ b/libavformat/flvdec.c @@ -1335,8 +1335,6 @@ retry: enhanced_flv = 1; pkt_type = flags & ~FLV_AUDIO_CODECID_MASK; - channels = 0; - if (pkt_type == AudioPacketTypeMultitrack) { av_log(s, AV_LOG_ERROR, "Multitrack audio is unsupported!\n"); return AVERROR_PATCHWELCOME; @@ -1546,12 +1544,9 @@ retry_duration: avcodec_parameters_free(&par); } } else if (stream_type == FLV_STREAM_TYPE_AUDIO) { - if (!st->codecpar->codec_id) { + if (!st->codecpar->codec_id) flv_set_audio_codec(s, st, st->codecpar, codec_id ? codec_id : (flags & FLV_AUDIO_CODECID_MASK)); - flv->last_sample_rate = 0; - flv->last_channels = 0; - } // These are not signalled in the flags anymore channels = 0; @@ -1562,26 +1557,40 @@ retry_duration: channels = avio_r8(s->pb); size -= 2; + av_channel_layout_uninit(&st->codecpar->ch_layout); + if (channel_order == AudioChannelOrderCustom) { + ret = av_channel_layout_custom_init(&st->codecpar->ch_layout, channels); + if (ret < 0) + return ret; + for (i = 0; i < channels; i++) { - avio_r8(s->pb); // audio channel mapping + uint8_t id = avio_r8(s->pb); size--; + + if (id < 18) + st->codecpar->ch_layout.u.map[i].id = id; + else if (id >= 18 && id <= 23) + st->codecpar->ch_layout.u.map[i].id = id - 18 + AV_CHAN_LOW_FREQUENCY_2; + else if (id == 0xFE) + st->codecpar->ch_layout.u.map[i].id = AV_CHAN_UNUSED; + else + st->codecpar->ch_layout.u.map[i].id = AV_CHAN_UNKNOWN; } } else if (channel_order == AudioChannelOrderNative) { - avio_rb32(s->pb); // audio channel flags + uint64_t mask = avio_rb32(s->pb); size -= 4; - } - if (!av_channel_layout_check(&st->codecpar->ch_layout)) { - ///TODO: This can be much more sophisticated with above info. + // The first 18 entries in the mask match ours, but the remaining 6 entries start at AV_CHAN_LOW_FREQUENCY_2 + mask = (mask & 0x3FFFF) | ((mask & 0xFC0000) << (AV_CHAN_LOW_FREQUENCY_2 - 18)); + ret = av_channel_layout_from_mask(&st->codecpar->ch_layout, mask); + if (ret < 0) + return ret; + } else { av_channel_layout_default(&st->codecpar->ch_layout, channels); - flv->last_channels = channels; } - if (channels != flv->last_channels) { - flv->last_channels = channels; - ff_add_param_change(pkt, channels, 0, 0, 0, 0); - } + av_log(s, AV_LOG_DEBUG, "Set channel data from MultiChannel info.\n"); goto leave; } -- 2.43.2 _______________________________________________ ffmpeg-devel mailing list ffmpeg-devel@ffmpeg.org https://ffmpeg.org/mailman/listinfo/ffmpeg-devel To unsubscribe, visit link above, or email ffmpeg-devel-request@ffmpeg.org with subject "unsubscribe".