[FFmpeg-devel] [PATCH 2/7] avformat/spdif, s337m: use shared code from avcodec
ffnicolasg at sfr.fr
ffnicolasg at sfr.fr
Wed Dec 4 16:14:04 EET 2024
From: Nicolas Gaullier <nicolas.gaullier at cji.paris>
---
libavformat/Makefile | 6 +++---
libavformat/s337m.c | 3 ++-
libavformat/spdif.c | 42 ------------------------------------------
libavformat/spdif.h | 1 -
libavformat/spdifdec.c | 3 ++-
libavformat/spdifenc.c | 3 ++-
6 files changed, 9 insertions(+), 49 deletions(-)
delete mode 100644 libavformat/spdif.c
diff --git a/libavformat/Makefile b/libavformat/Makefile
index 7ca68a7036..52aa64d43b 100644
--- a/libavformat/Makefile
+++ b/libavformat/Makefile
@@ -531,7 +531,7 @@ OBJS-$(CONFIG_RTSP_DEMUXER) += rtsp.o rtspdec.o httpauth.o \
urldecode.o
OBJS-$(CONFIG_RTSP_MUXER) += rtsp.o rtspenc.o httpauth.o \
urldecode.o
-OBJS-$(CONFIG_S337M_DEMUXER) += s337m.o spdif.o
+OBJS-$(CONFIG_S337M_DEMUXER) += s337m.o
OBJS-$(CONFIG_SAMI_DEMUXER) += samidec.o subtitles.o
OBJS-$(CONFIG_SAP_DEMUXER) += sapdec.o
OBJS-$(CONFIG_SAP_MUXER) += sapenc.o
@@ -563,8 +563,8 @@ OBJS-$(CONFIG_SMUSH_DEMUXER) += smush.o
OBJS-$(CONFIG_SOL_DEMUXER) += sol.o pcm.o
OBJS-$(CONFIG_SOX_DEMUXER) += soxdec.o pcm.o
OBJS-$(CONFIG_SOX_MUXER) += soxenc.o rawenc.o
-OBJS-$(CONFIG_SPDIF_DEMUXER) += spdif.o spdifdec.o
-OBJS-$(CONFIG_SPDIF_MUXER) += spdif.o spdifenc.o
+OBJS-$(CONFIG_SPDIF_DEMUXER) += spdifdec.o
+OBJS-$(CONFIG_SPDIF_MUXER) += spdifenc.o
OBJS-$(CONFIG_SPEEX_MUXER) += oggenc.o \
vorbiscomment.o
OBJS-$(CONFIG_SRT_DEMUXER) += srtdec.o subtitles.o
diff --git a/libavformat/s337m.c b/libavformat/s337m.c
index 4518f032d2..feb0f66cb3 100644
--- a/libavformat/s337m.c
+++ b/libavformat/s337m.c
@@ -19,6 +19,7 @@
*/
#include "libavutil/intreadwrite.h"
+#include "libavcodec/spdif_s337m_parser_internal.h"
#include "avformat.h"
#include "demux.h"
#include "internal.h"
@@ -171,7 +172,7 @@ static int s337m_read_packet(AVFormatContext *s, AVPacket *pkt)
return ret < 0 ? ret : AVERROR_EOF;
if (IS_16LE_MARKER(state))
- ff_spdif_bswap_buf16((uint16_t *)pkt->data, (uint16_t *)pkt->data, pkt->size >> 1);
+ avpriv_spdif_s337m_bswap_buf16((uint16_t *)pkt->data, (uint16_t *)pkt->data, pkt->size >> 1);
else
bswap_buf24(pkt->data, pkt->size);
diff --git a/libavformat/spdif.c b/libavformat/spdif.c
deleted file mode 100644
index 604141a261..0000000000
--- a/libavformat/spdif.c
+++ /dev/null
@@ -1,42 +0,0 @@
-/*
- * IEC 61937 common code
- * Copyright (c) 2009 Bartlomiej Wolowiec
- *
- * 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 "spdif.h"
-#include "libavutil/bswap.h"
-
-//TODO move to DSP
-void ff_spdif_bswap_buf16(uint16_t *dst, const uint16_t *src, int w)
-{
- int i;
-
- for (i = 0; i + 8 <= w; i += 8) {
- dst[i + 0] = av_bswap16(src[i + 0]);
- dst[i + 1] = av_bswap16(src[i + 1]);
- dst[i + 2] = av_bswap16(src[i + 2]);
- dst[i + 3] = av_bswap16(src[i + 3]);
- dst[i + 4] = av_bswap16(src[i + 4]);
- dst[i + 5] = av_bswap16(src[i + 5]);
- dst[i + 6] = av_bswap16(src[i + 6]);
- dst[i + 7] = av_bswap16(src[i + 7]);
- }
- for (; i < w; i++)
- dst[i + 0] = av_bswap16(src[i + 0]);
-}
diff --git a/libavformat/spdif.h b/libavformat/spdif.h
index 0039fcfe5c..b5ab70022b 100644
--- a/libavformat/spdif.h
+++ b/libavformat/spdif.h
@@ -58,7 +58,6 @@ static const uint16_t spdif_mpeg_pkt_offset[2][3] = {
{ 1536, 4608, 4608 }, // MPEG-1
};
-void ff_spdif_bswap_buf16(uint16_t *dst, const uint16_t *src, int w);
int ff_spdif_read_packet(AVFormatContext *s, AVPacket *pkt);
int ff_spdif_probe(const uint8_t *p_buf, int buf_size, enum AVCodecID *codec);
diff --git a/libavformat/spdifdec.c b/libavformat/spdifdec.c
index dcfe471f45..0879a315e7 100644
--- a/libavformat/spdifdec.c
+++ b/libavformat/spdifdec.c
@@ -29,6 +29,7 @@
#include "libavcodec/ac3defs.h"
#include "libavcodec/adts_parser.h"
+#include "libavcodec/spdif_s337m_parser_internal.h"
#include "avformat.h"
#include "demux.h"
@@ -215,7 +216,7 @@ int ff_spdif_read_packet(AVFormatContext *s, AVPacket *pkt)
if (avio_read(pb, pkt->data, pkt->size) < pkt->size) {
return AVERROR_EOF;
}
- ff_spdif_bswap_buf16((uint16_t *)pkt->data, (uint16_t *)pkt->data, pkt->size >> 1);
+ avpriv_spdif_s337m_bswap_buf16((uint16_t *)pkt->data, (uint16_t *)pkt->data, pkt->size >> 1);
ret = spdif_get_offset_and_codec(s, data_type, pkt->data,
&offset, &codec_id);
diff --git a/libavformat/spdifenc.c b/libavformat/spdifenc.c
index ab3f73da0d..09ebd7c992 100644
--- a/libavformat/spdifenc.c
+++ b/libavformat/spdifenc.c
@@ -54,6 +54,7 @@
#include "libavcodec/adts_parser.h"
#include "libavcodec/dca.h"
#include "libavcodec/dca_syncwords.h"
+#include "libavcodec/spdif_s337m_parser_internal.h"
#include "libavutil/mem.h"
#include "libavutil/opt.h"
@@ -659,7 +660,7 @@ static int spdif_write_packet(struct AVFormatContext *s, AVPacket *pkt)
av_fast_malloc(&ctx->buffer, &ctx->buffer_size, ctx->out_bytes + AV_INPUT_BUFFER_PADDING_SIZE);
if (!ctx->buffer)
return AVERROR(ENOMEM);
- ff_spdif_bswap_buf16((uint16_t *)ctx->buffer, (const uint16_t *)ctx->out_buf, ctx->out_bytes >> 1);
+ avpriv_spdif_s337m_bswap_buf16((uint16_t *)ctx->buffer, (const uint16_t *)ctx->out_buf, ctx->out_bytes >> 1);
avio_write(s->pb, ctx->buffer, ctx->out_bytes & ~1);
}
--
2.30.2
More information about the ffmpeg-devel
mailing list