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 24E7B45744 for ; Wed, 21 Jun 2023 17:00:17 +0000 (UTC) Received: from [127.0.1.1] (localhost [127.0.0.1]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTP id A252968C12A; Wed, 21 Jun 2023 20:00:02 +0300 (EEST) Received: from mail-oa1-f52.google.com (mail-oa1-f52.google.com [209.85.160.52]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTPS id 85DD468C09C for ; Wed, 21 Jun 2023 19:59:54 +0300 (EEST) Received: by mail-oa1-f52.google.com with SMTP id 586e51a60fabf-1a9db19d663so5700667fac.3 for ; Wed, 21 Jun 2023 09:59:54 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20221208; t=1687366793; x=1689958793; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:to:from:from:to:cc:subject:date:message-id :reply-to; bh=CK3bPumCvV+HIQ/hOv2WtnJOvkh3xK28gii8BkbgSYc=; b=QNxw0QMAFdGbeh8FswtNNt+09k3R+0A/3Cno2pZBsEpyKBPTEibErT1PVSyl58gGEl bXbMTVdjK1J0eeo/YYipr14FOT7HXCZL06dhUDAp+XdXDbzp8AwuNlzEXp71+lQO7fJL 9Y8kizfzhKLfiCNZusJQkQ79EO9v5yL4WUU3LQOWERAr3OjT30Zxl9P7H3yFMrdg3iA4 QEKhBJgThIT78MpORtpnZE7gW4szv/vmUDEoGOT/liIcGQtnsFX5dNCpe0aK3QZjIZWo x+tgBbW2l9GHsC3jgzzm8S0/AbgBAlggE6TYazS5GPkNczmas5Ks6AWAvseXL+Jqq3+k MF2Q== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20221208; t=1687366793; x=1689958793; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=CK3bPumCvV+HIQ/hOv2WtnJOvkh3xK28gii8BkbgSYc=; b=MqMthaAx4x3JwErvRpx9xm1C+M+h9Un91JuGxrs43CnWBRCNPKPf3eweZg4VEv3x+G 4699mIPvOlkGXFNXk28nv2b+WPbrQ6xBLUUvs0NY9zviOL07jRmntikopQRO+NEKu6gQ uBSURC2vXeyWIRBaZjq1sF6HK9wIJGTH2RSP8beWqA/TL1ornvF5fJGhS7XuYsrewaK9 L1IlC7crz9A22GRW6436VoMiEoJcld37IdpSGGhQq3FLG/TTvGxh/FgIcMhvQdO8r062 IS5tSVYqBty3UMGf856Bw3V5eu7Tvanr+NPGuXdAv5Gyef89IS8iQ96QdzoIkgr983pw JKBg== X-Gm-Message-State: AC+VfDx+SIVlOc0Dvs/a5KqisBOqsAwJ5OVnGFDgxGIReThQ/iBCAQ1e 9gnON1kdl3sI/l1c5Vu4/dPA49toi6k= X-Google-Smtp-Source: ACHHUZ4fKBSgnRNe8aH2fggUHE7aMyNDStPtGd/lKGN5qcyUPJpMJxrOo4G4rJEDYSESZ/aKTSptcg== X-Received: by 2002:a05:6871:23c2:b0:177:cbb6:ba2 with SMTP id xy2-20020a05687123c200b00177cbb60ba2mr12912263oab.53.1687366792892; Wed, 21 Jun 2023 09:59:52 -0700 (PDT) Received: from localhost.localdomain (host197.190-225-105.telecom.net.ar. [190.225.105.197]) by smtp.gmail.com with ESMTPSA id z17-20020a056870c21100b001aa0d9cdf4csm3004692oae.43.2023.06.21.09.59.51 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 21 Jun 2023 09:59:52 -0700 (PDT) From: James Almer To: ffmpeg-devel@ffmpeg.org Date: Wed, 21 Jun 2023 13:59:49 -0300 Message-ID: <20230621165949.1112-3-jamrial@gmail.com> X-Mailer: git-send-email 2.41.0 In-Reply-To: <20230621165949.1112-1-jamrial@gmail.com> References: <20230621165949.1112-1-jamrial@gmail.com> MIME-Version: 1.0 Subject: [FFmpeg-devel] [PATCH 3/3] avcodec/evc_frame_merge: copy input packet props to output 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 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: Signed-off-by: James Almer --- libavcodec/evc_frame_merge_bsf.c | 23 ++++++++++++++++++++--- 1 file changed, 20 insertions(+), 3 deletions(-) diff --git a/libavcodec/evc_frame_merge_bsf.c b/libavcodec/evc_frame_merge_bsf.c index 36ffec5736..8a09c12dbb 100644 --- a/libavcodec/evc_frame_merge_bsf.c +++ b/libavcodec/evc_frame_merge_bsf.c @@ -34,7 +34,7 @@ typedef struct AccessUnitBuffer { } AccessUnitBuffer; typedef struct EVCFMergeContext { - AVPacket *in; + AVPacket *in, *buffer_pkt; EVCParamSets ps; EVCParserPoc poc; AccessUnitBuffer au_buffer; @@ -67,6 +67,7 @@ static void evc_frame_merge_flush(AVBSFContext *bsf) ff_evc_ps_free(&ctx->ps); av_packet_unref(ctx->in); + av_packet_unref(ctx->buffer_pkt); ctx->au_buffer.data_size = 0; } @@ -146,7 +147,7 @@ static int parse_nal_unit(AVBSFContext *bsf, const uint8_t *buf, int buf_size) static int evc_frame_merge_filter(AVBSFContext *bsf, AVPacket *out) { EVCFMergeContext *ctx = bsf->priv_data; - AVPacket *in = ctx->in; + AVPacket *in = ctx->in, *buffer_pkt = ctx->buffer_pkt; size_t data_size; int au_end_found = 0, err; @@ -162,6 +163,16 @@ static int evc_frame_merge_filter(AVBSFContext *bsf, AVPacket *out) break; return err; } + /* Buffer packets with timestamps (there should be at most one per AU) + * or any packet if buffer_pkt is empty. The latter is needed to + * passthrough positions in case there are no timestamps like with + * the raw EVC demuxer. */ + if (!buffer_pkt->data || + in->pts != AV_NOPTS_VALUE && buffer_pkt->pts == AV_NOPTS_VALUE) { + err = av_packet_ref(buffer_pkt, in); + if (err < 0) + goto end; + } } // Buffer size is not enough for buffer to store NAL unit 4-bytes prefix (length) @@ -210,9 +221,13 @@ static int evc_frame_merge_filter(AVBSFContext *bsf, AVPacket *out) ctx->au_buffer.data_size = 0; err = av_new_packet(out, data_size); + if (err < 0) + goto end; + err = av_packet_copy_props(out, buffer_pkt); if (err < 0) goto end; + av_packet_unref(buffer_pkt); memcpy(out->data, ctx->au_buffer.data, data_size); err = 0; @@ -227,7 +242,8 @@ static int evc_frame_merge_init(AVBSFContext *bsf) EVCFMergeContext *ctx = bsf->priv_data; ctx->in = av_packet_alloc(); - if (!ctx->in) + ctx->buffer_pkt = av_packet_alloc(); + if (!ctx->in || !ctx->buffer_pkt) return AVERROR(ENOMEM); return 0; @@ -238,6 +254,7 @@ static void evc_frame_merge_close(AVBSFContext *bsf) EVCFMergeContext *ctx = bsf->priv_data; av_packet_free(&ctx->in); + av_packet_free(&ctx->buffer_pkt); ff_evc_ps_free(&ctx->ps); ctx->au_buffer.capacity = 0; -- 2.41.0 _______________________________________________ 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".