Commit b8c699bfbe for ffmpeg
commit b8c699bfbebd889d7795fb07bd7679b84ab366fb
Author: James Almer <jamrial@gmail.com>
Date: Sat Nov 21 11:29:04 2026 -0300
avcodec/opus/tab: move function definitions to another file
This file is meant to only declare tables.
Signed-off-by: James Almer <jamrial@gmail.com>
diff --git a/libavcodec/opus/parse.h b/libavcodec/opus/parse.h
index 85cb7a782b..edf8bf116a 100644
--- a/libavcodec/opus/parse.h
+++ b/libavcodec/opus/parse.h
@@ -27,6 +27,7 @@
#include "libavcodec/avcodec.h"
#include "opus.h"
+#include "tab.h"
typedef struct OpusPacket {
int packet_size; /**< packet size */
@@ -75,4 +76,34 @@ int ff_opus_parse_packet(OpusPacket *pkt, const uint8_t *buf, int buf_size,
int ff_opus_parse_extradata(AVCodecContext *avctx, OpusParseContext *s,
const uint8_t *header, int header_size);
+/**
+ * @return the duration of an Opus packet in samples at OPUS_TIMESTAMP_RATE,
+ * read from its TOC, or AVERROR_INVALIDDATA if the packet is too
+ * short or longer than 120 ms
+ */
+static inline int ff_opus_packet_samples(const uint8_t *buf, int buf_size)
+{
+ int frame_count, samples;
+
+ if (buf_size < 1)
+ return AVERROR_INVALIDDATA;
+ switch (buf[0] & 3) {
+ case 0:
+ frame_count = 1;
+ break;
+ case 3:
+ if (buf_size < 2)
+ return AVERROR_INVALIDDATA;
+ frame_count = buf[1] & 0x3F;
+ break;
+ default:
+ frame_count = 2;
+ break;
+ }
+ samples = frame_count * ff_opus_frame_duration[buf[0] >> 3];
+ // A packet holds at most 120 ms.
+ return samples > 120 * OPUS_TIMESTAMP_RATE / 1000 ? AVERROR_INVALIDDATA
+ : samples;
+}
+
#endif /* AVCODEC_OPUS_PARSE_H */
diff --git a/libavcodec/opus/tab.h b/libavcodec/opus/tab.h
index 1513b48a11..5e114a1a73 100644
--- a/libavcodec/opus/tab.h
+++ b/libavcodec/opus/tab.h
@@ -37,36 +37,6 @@
FF_VISIBILITY_PUSH_HIDDEN
extern const uint16_t ff_opus_frame_duration[32];
-/**
- * @return the duration of an Opus packet in samples at OPUS_TIMESTAMP_RATE,
- * read from its TOC, or AVERROR_INVALIDDATA if the packet is too
- * short or longer than 120 ms
- */
-static inline int ff_opus_packet_samples(const uint8_t *buf, int buf_size)
-{
- int frame_count, samples;
-
- if (buf_size < 1)
- return AVERROR_INVALIDDATA;
- switch (buf[0] & 3) {
- case 0:
- frame_count = 1;
- break;
- case 3:
- if (buf_size < 2)
- return AVERROR_INVALIDDATA;
- frame_count = buf[1] & 0x3F;
- break;
- default:
- frame_count = 2;
- break;
- }
- samples = frame_count * ff_opus_frame_duration[buf[0] >> 3];
- // A packet holds at most 120 ms.
- return samples > 120 * OPUS_TIMESTAMP_RATE / 1000 ? AVERROR_INVALIDDATA
- : samples;
-}
-
extern const uint8_t ff_celt_band_end[];
extern const uint8_t ff_opus_default_coupled_streams[];
diff --git a/libavformat/matroskadec.c b/libavformat/matroskadec.c
index 745140cebf..dc5194fd23 100644
--- a/libavformat/matroskadec.c
+++ b/libavformat/matroskadec.c
@@ -57,7 +57,7 @@
#include "libavcodec/flac.h"
#include "libavcodec/itut35.h"
#include "libavcodec/mpeg4audio.h"
-#include "libavcodec/opus/tab.h"
+#include "libavcodec/opus/parse.h"
#include "packet_internal.h"
#include "avformat.h"
diff --git a/libavformat/matroskaenc.c b/libavformat/matroskaenc.c
index e2387864eb..136f3a1923 100644
--- a/libavformat/matroskaenc.c
+++ b/libavformat/matroskaenc.c
@@ -70,7 +70,7 @@
#include "libavcodec/itut35.h"
#include "libavcodec/xiph.h"
#include "libavcodec/mpeg4audio.h"
-#include "libavcodec/opus/tab.h"
+#include "libavcodec/opus/parse.h"
/* Level 1 elements we create a SeekHead entry for:
* Info, Tracks, Chapters, Attachments, Tags (potentially twice) and Cues */