From patchwork Mon Feb 1 22:44:11 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: James Almer X-Patchwork-Id: 25328 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 9097F44BD9A for ; Tue, 2 Feb 2021 00:44:52 +0200 (EET) Received: from [127.0.1.1] (localhost [127.0.0.1]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTP id 62C66689E7D; Tue, 2 Feb 2021 00:44:52 +0200 (EET) X-Original-To: ffmpeg-devel@ffmpeg.org Delivered-To: ffmpeg-devel@ffmpeg.org Received: from mail-qt1-f173.google.com (mail-qt1-f173.google.com [209.85.160.173]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTPS id EEFBB68068B for ; Tue, 2 Feb 2021 00:44:45 +0200 (EET) Received: by mail-qt1-f173.google.com with SMTP id t17so13623389qtq.2 for ; Mon, 01 Feb 2021 14:44:45 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:subject:date:message-id:mime-version :content-transfer-encoding; bh=LdPaCP6/PN9UE2q3WWTDTNXOquym+2fA5xP6Nwkhp0g=; b=RH3E4//VYl54ga1IkDtQQ/ZrQuPSF5xvFl3+uSm1D7Pn30+cKbSzXjq0RTN7HhNhgO q+rbwp0tWwJXjcIeNpAEfz5rSejRxOWGwUVxcA+RgVWVjMrQsiTmcXoy+5MOg0F+6zLO UetRSA9QC38gm1hAIqBYfoEs+bkjisdh00+kwVZg4/ximGM38Rc5upSNVziOCC3dXRSM 1LnNlC0ZcvueGzbeYtnfGSC53wGzTTLu0Cmbin0L9US4xZqGBV+bby8PrBJ/iB61/0co edtUVfCawaToi+QtPf35m1wuPce8BzqZTQ5TYR3hItx3uO0UZ2iZA69Xe5/jGdE5VASQ 0M8A== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:subject:date:message-id:mime-version :content-transfer-encoding; bh=LdPaCP6/PN9UE2q3WWTDTNXOquym+2fA5xP6Nwkhp0g=; b=keO52cUOPz8B6xNs7ewwgHhwbSbCPA60s9gBUS30u1zgrc/1oFAJGeLbaeXeY9rOVP /2sOmB9mYMQYpSHa9l9RNE+yOWleuMQ3S8DY732Q/HXSTmnjgfEByeXFJwt7Phs1/KGk w9QyprJurER03SdPxYAVKveQkhhMambniFVlsgpi0S8x8f/0JOLf140cDMYZuyiQsAL2 9RNlrBG0yp86tHYy3cRT4EP4q980f/QMGmLHkNKOej1r8SPkjZFQIGItXIGzbcNtdcLs hYHmUKYnXBNM6OXQVm18zW//50btYYxG5jrSKTe9z+/M7NXcAm6P30DVS96s4eyjNDPz fvkA== X-Gm-Message-State: AOAM532N1tovzUyNKU6pv8IAVv4zpSbRsKJDf+2Ifwh2ULY9k8LrEhsU LH40XfCtlOOojicOHlonK8pWmmlVEa4= X-Google-Smtp-Source: ABdhPJwHaqYnC8FZzM3GRpHO8F/6ztEJwubPzKlWA6zMxLj7LosjjHp8YEtFnpCaqyusj+DyKQSSeA== X-Received: by 2002:ac8:37c8:: with SMTP id e8mr17181656qtc.289.1612219484207; Mon, 01 Feb 2021 14:44:44 -0800 (PST) Received: from localhost.localdomain ([181.23.89.132]) by smtp.gmail.com with ESMTPSA id e1sm15812720qkd.135.2021.02.01.14.44.42 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 01 Feb 2021 14:44:43 -0800 (PST) From: James Almer To: ffmpeg-devel@ffmpeg.org Date: Mon, 1 Feb 2021 19:44:11 -0300 Message-Id: <20210201224421.1395-1-jamrial@gmail.com> X-Mailer: git-send-email 2.30.0 MIME-Version: 1.0 Subject: [FFmpeg-devel] [PATCH 00/10] deprecate av_init_packet() and sizeof(AVPacket) as part of the ABI 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 Errors-To: ffmpeg-devel-bounces@ffmpeg.org Sender: "ffmpeg-devel" As the subject says, this puts AVPacket in line with AVFrame, allowing easier extensibility of the struct, and preventing potential undefined behavior in some cases when packets are used uninitialized on stack. This set adapts only a few modules, examples, and the tools, as those were the most complex and the ones that better reflect how AVPackets must be used after the deprecation period. I have a branch ready removing every other instance of av_init_packet() in the tree, and all uses of AVPacket on stack i could find. They are pretty trivial, so i wont bother spamming the ML with 40+ patches until the core changes are upstreamed. It's also not exhaustive, as i'm sure i missed a few cases of stack usage, but they can be removed any time between the deprecation of public sizeof(AVPacket) and it's effective removal 2+ years from now. Then there's the few cases where an AVPacket is part of another public struct, as is the case of AVPacketList, or attached_pic in AVSteam. The latter i could adapt right now, but it would mean a lot of preprocessor checks littering the codebase until removed, so i refrained from doing so. James Almer (10): avformat/mux: use av_packet_alloc() to allocate packets avformat/movenc: use av_packet_alloc() to allocate packets avformat/utils: use av_packet_alloc() to allocate packets doc/examples/demuxing_decoding: use av_packet_alloc() to allocate packets doc/examples/transcode_aac: use av_packet_alloc() to allocate packets doc/examples/transcoding: use av_packet_alloc() to allocate packets fftools/ffprobe: use av_packet_alloc() to allocate packets fftools/ffmpeg: use av_packet_alloc() to allocate packets fftools/ffplay: use av_packet_alloc() to allocate packets avcodec/packet: deprecate av_init_packet() doc/examples/demuxing_decoding.c | 25 +-- doc/examples/transcode_aac.c | 46 +++-- doc/examples/transcoding.c | 48 +++-- fftools/ffmpeg.c | 318 ++++++++++++++++--------------- fftools/ffmpeg.h | 4 + fftools/ffmpeg_opt.c | 5 +- fftools/ffplay.c | 222 ++++++++++++--------- fftools/ffprobe.c | 34 ++-- libavcodec/avpacket.c | 23 ++- libavcodec/packet.h | 23 ++- libavcodec/version.h | 3 + libavformat/avformat.h | 4 + libavformat/internal.h | 6 + libavformat/movenc.c | 101 ++++++---- libavformat/movenc.h | 2 + libavformat/movenchint.c | 19 +- libavformat/mux.c | 44 +++-- libavformat/options.c | 9 + libavformat/utils.c | 106 ++++++----- 19 files changed, 613 insertions(+), 429 deletions(-)