avcodec/avformat: Unavpriv avpriv_packet_list_*()

The avpriv_packet_list_put/get/free() functions and the PacketList type
were implemented in libavcodec and exported via the avpriv_ mechanism
solely so that libavformat (and decklink in libavdevice) could use them;
libavcodec itself has no users of them. Exporting them across the library
boundary has the usual drawbacks for shared builds (export/import overhead
and having to keep them around for ABI stability even once unneeded).

Move the implementation and the PacketList/PacketListEntry types to
libavformat and rename the functions to ff_packet_list_*(). libavformat is
the primary user and compiles the new packet_list.c directly; decklink,
the only libavdevice user, gets a private copy for shared builds via the
SHLIBOBJS scheme already used for reverse.o and ccfifo.o (static builds
resolve the symbols from libavformat).

AVPACKET_IS_EMPTY() and ff_side_data_set_prft() remain in
libavcodec/packet_internal.h as they are libavcodec-internal.
This commit is contained in:
Michael Niedermayer
2026-06-21 12:39:23 +02:00
committed by Andreas Rheinhardt
parent 2d3776b8cc
commit 54849fe663
26 changed files with 268 additions and 183 deletions

View File

@@ -53,8 +53,8 @@ OBJS-$(CONFIG_LIBCDIO_INDEV) += libcdio.o
OBJS-$(CONFIG_LIBDC1394_INDEV) += libdc1394.o
# Objects duplicated from other libraries for shared builds
SHLIBOBJS-$(CONFIG_DECKLINK_INDEV) += reverse.o
SHLIBOBJS-$(CONFIG_DECKLINK_OUTDEV) += ccfifo.o
SHLIBOBJS-$(CONFIG_DECKLINK_INDEV) += reverse.o packet_list.o
SHLIBOBJS-$(CONFIG_DECKLINK_OUTDEV) += ccfifo.o packet_list.o
# Windows resource file
SHLIBOBJS-$(HAVE_GNU_WINDRES) += avdeviceres.o

View File

@@ -409,7 +409,7 @@ void ff_decklink_packet_queue_flush(DecklinkPacketQueue *q)
AVPacket pkt;
pthread_mutex_lock(&q->mutex);
while (avpriv_packet_list_get(&q->pkt_list, &pkt) == 0) {
while (ff_packet_list_get(&q->pkt_list, &pkt) == 0) {
av_packet_unref(&pkt);
}
q->nb_packets = 0;
@@ -452,7 +452,7 @@ int ff_decklink_packet_queue_put(DecklinkPacketQueue *q, AVPacket *pkt)
pthread_mutex_lock(&q->mutex);
ret = avpriv_packet_list_put(&q->pkt_list, pkt, NULL, 0);
ret = ff_packet_list_put(&q->pkt_list, pkt, NULL, 0);
if (ret == 0) {
q->nb_packets++;
q->size += pkt_size + sizeof(AVPacket);
@@ -472,7 +472,7 @@ int ff_decklink_packet_queue_get(DecklinkPacketQueue *q, AVPacket *pkt, int bloc
pthread_mutex_lock(&q->mutex);
for (;; ) {
ret = avpriv_packet_list_get(&q->pkt_list, pkt);
ret = ff_packet_list_get(&q->pkt_list, pkt);
if (ret == 0) {
q->nb_packets--;
q->size -= pkt->size + sizeof(AVPacket);

View File

@@ -48,7 +48,7 @@
extern "C" {
#include "libavutil/mem.h"
#include "libavcodec/packet_internal.h"
#include "libavformat/packet_internal.h"
#include "libavfilter/ccfifo.h"
}
#include "libavutil/thread.h"

View File

@@ -39,7 +39,7 @@ extern "C" {
extern "C" {
#include "config.h"
#include "libavcodec/packet_internal.h"
#include "libavformat/packet_internal.h"
#include "libavformat/avformat.h"
#include "libavutil/avassert.h"
#include "libavutil/avutil.h"

View File

@@ -33,7 +33,7 @@
#include <dvdmedia.h>
#include "libavcodec/internal.h"
#include "libavcodec/packet_internal.h"
#include "libavformat/packet_internal.h"
/* EC_DEVICE_LOST is not defined in MinGW dshow headers. */
#ifndef EC_DEVICE_LOST

22
libavdevice/packet_list.c Normal file
View File

@@ -0,0 +1,22 @@
/*
* This file is part of FFmpeg.
*
* FFmpeg is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
* License as published by the Free Software Foundation; either
* version 2.1 of the License, or (at your option) any later version.
*
* FFmpeg is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public
* License along with FFmpeg; if not, write to the Free Software
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
*/
/* decklink is the only libavdevice user of the ff_packet_list_*() API, which
* lives in libavformat; compile a private copy into libavdevice for shared
* builds (static builds resolve the symbols from libavformat). */
#include "libavformat/packet_list.c"

View File

@@ -25,7 +25,7 @@
#include "libavutil/opt.h"
#include "libavutil/parseutils.h"
#include "libavcodec/packet_internal.h"
#include "libavformat/packet_internal.h"
#include "libavformat/demux.h"
#include "libavformat/internal.h"