avcodec/opus/parse: Move frame_duration tab into a file of its own

This is in preparation for duplicating it into libavformat.

Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
This commit is contained in:
Andreas Rheinhardt
2026-02-06 13:39:39 +01:00
parent 3ab8b976c1
commit 853843d86f
4 changed files with 37 additions and 13 deletions

View File

@@ -8,6 +8,7 @@ OBJS-$(CONFIG_OPUS_DECODER) += \
opus/dec.o \
opus/dec_celt.o \
opus/celt.o \
opus/frame_duration_tab.o \
opus/pvq.o \
opus/silk.o \
opus/tab.o \
@@ -16,6 +17,7 @@ OBJS-$(CONFIG_OPUS_DECODER) += \
OBJS-$(CONFIG_OPUS_PARSER) += \
opus/frame_duration_tab.o \
opus/parser.o \

View File

@@ -0,0 +1,31 @@
/*
* 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
*/
#include "tab.h"
const uint16_t ff_opus_frame_duration[32] = {
480, 960, 1920, 2880,
480, 960, 1920, 2880,
480, 960, 1920, 2880,
480, 960,
480, 960,
120, 240, 480, 960,
120, 240, 480, 960,
120, 240, 480, 960,
120, 240, 480, 960,
};

View File

@@ -36,21 +36,10 @@
#include "mathops.h"
#include "opus.h"
#include "parse.h"
#include "tab.h"
#include "vorbis_data.h"
#if CONFIG_OPUSPARSE
static const uint16_t opus_frame_duration[32] = {
480, 960, 1920, 2880,
480, 960, 1920, 2880,
480, 960, 1920, 2880,
480, 960,
480, 960,
120, 240, 480, 960,
120, 240, 480, 960,
120, 240, 480, 960,
120, 240, 480, 960,
};
/**
* Read a 1- or 2-byte frame length
*/
@@ -258,7 +247,7 @@ int ff_opus_parse_packet(OpusPacket *pkt, const uint8_t *buf, int buf_size,
pkt->data_size = pkt->packet_size - padding;
/* total packet duration cannot be larger than 120ms */
pkt->frame_duration = opus_frame_duration[pkt->config];
pkt->frame_duration = ff_opus_frame_duration[pkt->config];
if (pkt->frame_duration * pkt->frame_count > OPUS_MAX_PACKET_DUR)
goto fail;

View File

@@ -28,6 +28,8 @@
#include "libavutil/attributes_internal.h"
FF_VISIBILITY_PUSH_HIDDEN
extern const uint16_t ff_opus_frame_duration[32];
extern const uint8_t ff_celt_band_end[];
extern const uint8_t ff_opus_default_coupled_streams[];