From patchwork Tue Jan 14 23:42:11 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Nicolas Gaullier X-Patchwork-Id: 17342 Return-Path: X-Original-To: patchwork@ffaux-bg.ffmpeg.org Delivered-To: patchwork@ffaux-bg.ffmpeg.org Received: from ffbox0-bg.mplayerhq.hu (ffbox0-bg.ffmpeg.org [79.124.17.100]) by ffaux.localdomain (Postfix) with ESMTP id 79E8544BC5B for ; Wed, 15 Jan 2020 01:42:23 +0200 (EET) Received: from [127.0.1.1] (localhost [127.0.0.1]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTP id 4BDDD68A8F1; Wed, 15 Jan 2020 01:42:23 +0200 (EET) X-Original-To: ffmpeg-devel@ffmpeg.org Delivered-To: ffmpeg-devel@ffmpeg.org Received: from smtp-2.arkena.net (smtp-2.arkena.net [95.81.173.75]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTPS id 62E9968A57E for ; Wed, 15 Jan 2020 01:42:17 +0200 (EET) Received: from secu2 (unknown [10.180.103.10]) (using TLSv1 with cipher ADH-AES256-SHA (256/256 bits)) (No client certificate requested) by smtp-2.arkena.net (Postfix) with ESMTPSA id 47y6SS3vqbzHh98; Tue, 14 Jan 2020 23:42:16 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=simple/simple; d=cji.paris; s=20150421; t=1579045336; bh=v/e7hu5ziSHWGzNdPREMz8wQPHLEMCYtPXsWBWD06aA=; h=From:To:Cc:Subject:Date:Message-Id; b=Dzf69QJ7mzqTku7/zRvu7E167ay+C7gqnLajgRQnmPVWyqzAQZM3USEDRwS8WATmU mc0lZsHK4VJtQ8EjHEGWKa8aZRoUt9kH69X2lgSdfjGZm5ZbDuizYGOwhabCZG93ra DbKYwBIrGzyTmHK6IAxWVL1XeO3hb5nY2hOc3/IU= Received: from arkena.com (unknown [172.16.3.159]) by secu2 (Postfix) with ESMTP id 435603FA6D; Wed, 15 Jan 2020 00:42:18 +0100 (CET) From: Nicolas Gaullier To: ffmpeg-devel@ffmpeg.org Date: Wed, 15 Jan 2020 00:42:11 +0100 Message-Id: <20200114234213.3224-2-nicolas.gaullier@cji.paris> X-Mailer: git-send-email 2.14.1.windows.1 In-Reply-To: <20200114234213.3224-1-nicolas.gaullier@cji.paris> References: <20200114234213.3224-1-nicolas.gaullier@cji.paris> Subject: [FFmpeg-devel] [PATCH v7 1/3] avformat/utils: Make find_stream_info get side data from codec context 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: Nicolas Gaullier MIME-Version: 1.0 Errors-To: ffmpeg-devel-bounces@ffmpeg.org Sender: "ffmpeg-devel" This will allow probing input coded side data, and also forwarding them to the output. --- libavformat/utils.c | 18 ++++++++++++++++++ 1 file changed, 18 insertions(+) diff --git a/libavformat/utils.c b/libavformat/utils.c index f3d71642c3..cc9898681a 100644 --- a/libavformat/utils.c +++ b/libavformat/utils.c @@ -3596,6 +3596,21 @@ static int extract_extradata(AVStream *st, const AVPacket *pkt) return 0; } +static int add_coded_side_data(AVStream *st, AVCodecContext *avctx) +{ + int i; + + for (i = 0; i < avctx->nb_coded_side_data; i++) { + const AVPacketSideData *sd_src = &avctx->coded_side_data[i]; + uint8_t *dst_data; + dst_data = av_stream_new_side_data(st, sd_src->type, sd_src->size); + if (!dst_data) + return AVERROR(ENOMEM); + memcpy(dst_data, sd_src->data, sd_src->size); + } + return 0; +} + int avformat_find_stream_info(AVFormatContext *ic, AVDictionary **options) { int i, count = 0, ret = 0, j; @@ -4135,6 +4150,9 @@ FF_ENABLE_DEPRECATION_WARNINGS ret = avcodec_parameters_from_context(st->codecpar, st->internal->avctx); if (ret < 0) goto find_stream_info_err; + ret = add_coded_side_data(st, st->internal->avctx); + if (ret < 0) + goto find_stream_info_err; #if FF_API_LOWRES // The decoder might reduce the video size by the lowres factor. if (st->internal->avctx->lowres && orig_w) {