From patchwork Wed Mar 8 01:57:50 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Michael Niedermayer X-Patchwork-Id: 2797 Delivered-To: ffmpegpatchwork@gmail.com Received: by 10.103.50.79 with SMTP id y76csp823056vsy; Tue, 7 Mar 2017 17:58:04 -0800 (PST) X-Received: by 10.28.127.13 with SMTP id a13mr3150886wmd.96.1488938284687; Tue, 07 Mar 2017 17:58:04 -0800 (PST) Return-Path: Received: from ffbox0-bg.mplayerhq.hu (ffbox0-bg.ffmpeg.org. [79.124.17.100]) by mx.google.com with ESMTP id j140si21191667wmg.23.2017.03.07.17.58.04; Tue, 07 Mar 2017 17:58:04 -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; 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 Received: from [127.0.1.1] (localhost [127.0.0.1]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTP id 7C1CD680D6D; Wed, 8 Mar 2017 03:57:47 +0200 (EET) X-Original-To: ffmpeg-devel@ffmpeg.org Delivered-To: ffmpeg-devel@ffmpeg.org Received: from vie01a-dmta-pe02-3.mx.upcmail.net (vie01a-dmta-pe02-3.mx.upcmail.net [62.179.121.159]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTPS id B2230680AA5 for ; Wed, 8 Mar 2017 03:57:40 +0200 (EET) Received: from [172.31.216.43] (helo=vie01a-pemc-psmtp-pe01) by vie01a-dmta-pe02.mx.upcmail.net with esmtp (Exim 4.87) (envelope-from ) id 1clQrR-0005tX-53 for ffmpeg-devel@ffmpeg.org; Wed, 08 Mar 2017 02:57:53 +0100 Received: from localhost ([213.47.41.20]) by vie01a-pemc-psmtp-pe01 with SMTP @ mailcloud.upcmail.net id tDxq1u0110S5wYM01DxrED; Wed, 08 Mar 2017 02:57:52 +0100 X-SourceIP: 213.47.41.20 From: Michael Niedermayer To: FFmpeg development discussions and patches Date: Wed, 8 Mar 2017 02:57:50 +0100 Message-Id: <20170308015750.28592-1-michael@niedermayer.cc> X-Mailer: git-send-email 2.11.0 Subject: [FFmpeg-devel] [PATCH] avcodec: Add AV_CODEC_FLAG2_DONT_SPLIT_SIDE_DATA 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 MIME-Version: 1.0 Errors-To: ffmpeg-devel-bounces@ffmpeg.org Sender: "ffmpeg-devel" This allows to test or use the code without av_packet_split_side_data() or allows applications to separate the side data handling out not running it automatically. It also makes it easier to change the default behavior Signed-off-by: Michael Niedermayer --- libavcodec/avcodec.h | 5 +++++ libavcodec/utils.c | 12 ++++++++---- 2 files changed, 13 insertions(+), 4 deletions(-) diff --git a/libavcodec/avcodec.h b/libavcodec/avcodec.h index af054f3194..92e930249e 100644 --- a/libavcodec/avcodec.h +++ b/libavcodec/avcodec.h @@ -910,6 +910,11 @@ typedef struct RcOverride{ */ #define AV_CODEC_FLAG2_FAST (1 << 0) /** + * Do not split side data. + * @see AVFMT_FLAG_KEEP_SIDE_DATA + */ +#define AV_CODEC_FLAG2_DONT_SPLIT_SIDE_DATA (1 << 1) +/** * Skip bitstream encoding. */ #define AV_CODEC_FLAG2_NO_OUTPUT (1 << 2) diff --git a/libavcodec/utils.c b/libavcodec/utils.c index db3adb18d4..94278c6950 100644 --- a/libavcodec/utils.c +++ b/libavcodec/utils.c @@ -2250,7 +2250,8 @@ int attribute_align_arg avcodec_decode_video2(AVCodecContext *avctx, AVFrame *pi if ((avctx->codec->capabilities & AV_CODEC_CAP_DELAY) || avpkt->size || (avctx->active_thread_type & FF_THREAD_FRAME)) { - int did_split = av_packet_split_side_data(&tmp); + int did_split = (avctx->flags2 & AV_CODEC_FLAG2_DONT_SPLIT_SIDE_DATA) ? + 0 : av_packet_split_side_data(&tmp); ret = apply_param_change(avctx, &tmp); if (ret < 0) goto fail; @@ -2356,7 +2357,8 @@ int attribute_align_arg avcodec_decode_audio4(AVCodecContext *avctx, uint8_t discard_reason = 0; // copy to ensure we do not change avpkt AVPacket tmp = *avpkt; - int did_split = av_packet_split_side_data(&tmp); + int did_split = (avctx->flags2 & AV_CODEC_FLAG2_DONT_SPLIT_SIDE_DATA) ? + 0 : av_packet_split_side_data(&tmp); ret = apply_param_change(avctx, &tmp); if (ret < 0) goto fail; @@ -2669,7 +2671,8 @@ int avcodec_decode_subtitle2(AVCodecContext *avctx, AVSubtitle *sub, if ((avctx->codec->capabilities & AV_CODEC_CAP_DELAY) || avpkt->size) { AVPacket pkt_recoded; AVPacket tmp = *avpkt; - int did_split = av_packet_split_side_data(&tmp); + int did_split = (avctx->flags2 & AV_CODEC_FLAG2_DONT_SPLIT_SIDE_DATA) ? + 0 : av_packet_split_side_data(&tmp); //apply_param_change(avctx, &tmp); if (did_split) { @@ -2860,7 +2863,8 @@ int attribute_align_arg avcodec_send_packet(AVCodecContext *avctx, const AVPacke if (avctx->codec->send_packet) { if (avpkt) { AVPacket tmp = *avpkt; - int did_split = av_packet_split_side_data(&tmp); + int did_split = (avctx->flags2 & AV_CODEC_FLAG2_DONT_SPLIT_SIDE_DATA) ? + 0 : av_packet_split_side_data(&tmp); ret = apply_param_change(avctx, &tmp); if (ret >= 0) ret = avctx->codec->send_packet(avctx, &tmp);