diff mbox series

[FFmpeg-devel,09/11] avformat/aptxdec: Use ff_pcm_read_packet

Message ID AM7PR03MB66604F8BB2A8BE630A40ACA48FCA9@AM7PR03MB6660.eurprd03.prod.outlook.com
State Superseded
Headers show
Series [FFmpeg-devel,01/11] tests/fate-run: Allow multiple inputs for transcode() | expand

Checks

Context Check Description
andriy/make_x86 success Make finished
andriy/make_fate_x86 success Make fate finished
andriy/make_ppc success Make finished
andriy/make_fate_ppc fail Make fate failed

Commit Message

Andreas Rheinhardt Aug. 29, 2021, 9:27 p.m. UTC
It automatically honours block_align and it clears the
AV_PKT_FLAG_CORRUPT flag which up until now was always set
for the last packet if the number of input blocks was not
divisible by 256 (or equivalently: if the number of input
samples was not divisible by 1024).

It reads more data at once; this necessitated updates to
FATE reference files.

Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
---
One could easily implement seeking for this format via ff_pcm_read_seek;
but it would fail miserably for damaged inputs.

 libavformat/Makefile   |  4 ++--
 libavformat/aptxdec.c  | 15 +++------------
 tests/ref/fate/aptx    | 15 +++------------
 tests/ref/fate/aptx-hd | 15 +++------------
 4 files changed, 11 insertions(+), 38 deletions(-)
diff mbox series

Patch

diff --git a/libavformat/Makefile b/libavformat/Makefile
index 7e0f587b41..becf07867d 100644
--- a/libavformat/Makefile
+++ b/libavformat/Makefile
@@ -99,9 +99,9 @@  OBJS-$(CONFIG_APM_DEMUXER)               += apm.o
 OBJS-$(CONFIG_APM_MUXER)                 += apm.o rawenc.o
 OBJS-$(CONFIG_APNG_DEMUXER)              += apngdec.o
 OBJS-$(CONFIG_APNG_MUXER)                += apngenc.o
-OBJS-$(CONFIG_APTX_DEMUXER)              += aptxdec.o
+OBJS-$(CONFIG_APTX_DEMUXER)              += aptxdec.o pcm.o
 OBJS-$(CONFIG_APTX_MUXER)                += rawenc.o
-OBJS-$(CONFIG_APTX_HD_DEMUXER)           += aptxdec.o
+OBJS-$(CONFIG_APTX_HD_DEMUXER)           += aptxdec.o pcm.o
 OBJS-$(CONFIG_APTX_HD_MUXER)             += rawenc.o
 OBJS-$(CONFIG_AQTITLE_DEMUXER)           += aqtitledec.o subtitles.o
 OBJS-$(CONFIG_ARGO_ASF_DEMUXER)          += argo_asf.o
diff --git a/libavformat/aptxdec.c b/libavformat/aptxdec.c
index a5ed921e2c..2cbf9a2cb8 100644
--- a/libavformat/aptxdec.c
+++ b/libavformat/aptxdec.c
@@ -22,6 +22,7 @@ 
 
 #include "libavutil/opt.h"
 #include "avformat.h"
+#include "pcm.h"
 
 #define APTX_BLOCK_SIZE   4
 #define APTX_PACKET_SIZE  (256*APTX_BLOCK_SIZE)
@@ -70,16 +71,6 @@  static int aptx_hd_read_header(AVFormatContext *s)
     return 0;
 }
 
-static int aptx_read_packet(AVFormatContext *s, AVPacket *pkt)
-{
-    return av_get_packet(s->pb, pkt, APTX_PACKET_SIZE);
-}
-
-static int aptx_hd_read_packet(AVFormatContext *s, AVPacket *pkt)
-{
-    return av_get_packet(s->pb, pkt, APTX_HD_PACKET_SIZE);
-}
-
 static const AVOption aptx_options[] = {
     { "sample_rate", "", offsetof(AptXDemuxerContext, sample_rate), AV_OPT_TYPE_INT, {.i64 = 48000}, 0, INT_MAX, AV_OPT_FLAG_DECODING_PARAM },
     { NULL },
@@ -99,7 +90,7 @@  const AVInputFormat ff_aptx_demuxer = {
     .extensions     = "aptx",
     .priv_data_size = sizeof(AptXDemuxerContext),
     .read_header    = aptx_read_header,
-    .read_packet    = aptx_read_packet,
+    .read_packet    = ff_pcm_read_packet,
     .flags          = AVFMT_GENERIC_INDEX,
     .priv_class     = &aptx_demuxer_class,
 };
@@ -112,7 +103,7 @@  const AVInputFormat ff_aptx_hd_demuxer = {
     .extensions     = "aptxhd",
     .priv_data_size = sizeof(AptXDemuxerContext),
     .read_header    = aptx_hd_read_header,
-    .read_packet    = aptx_hd_read_packet,
+    .read_packet    = ff_pcm_read_packet,
     .flags          = AVFMT_GENERIC_INDEX,
     .priv_class     = &aptx_demuxer_class,
 };
diff --git a/tests/ref/fate/aptx b/tests/ref/fate/aptx
index ff890f6943..bf43d7612a 100644
--- a/tests/ref/fate/aptx
+++ b/tests/ref/fate/aptx
@@ -6,15 +6,6 @@  e36494e4eaa69dceb9746e784f928198 *tests/data/fate/aptx.aptx
 #sample_rate 0: 48000
 #channel_layout 0: 3
 #channel_layout_name 0: stereo
-0,          0,          0,     1024,     4096, 0x42e145b7
-0,       1024,       1024,     1024,     4096, 0xfe24da5f
-0,       2048,       2048,     1024,     4096, 0x5c9d2323
-0,       3072,       3072,     1024,     4096, 0xc7e155cf
-0,       4096,       4096,     1024,     4096, 0xff114281
-0,       5120,       5120,     1024,     4096, 0xd60bb6b0
-0,       6144,       6144,     1024,     4096, 0x2beaa892
-0,       7168,       7168,     1024,     4096, 0xc74c71ca
-0,       8192,       8192,     1024,     4096, 0xf49880cc
-0,       9216,       9216,     1024,     4096, 0x9eae2532
-0,      10240,      10240,     1024,     4096, 0x096863b2
-0,      11264,      11264,      736,     2944, 0x533118a3
+0,          0,          0,     4096,    16384, 0x443e9917
+0,       4096,       4096,     4096,    16384, 0xc83613ab
+0,       8192,       8192,     3808,    15232, 0xbf702262
diff --git a/tests/ref/fate/aptx-hd b/tests/ref/fate/aptx-hd
index c924186ef8..bbb1bc090b 100644
--- a/tests/ref/fate/aptx-hd
+++ b/tests/ref/fate/aptx-hd
@@ -6,15 +6,6 @@ 
 #sample_rate 0: 48000
 #channel_layout 0: 3
 #channel_layout_name 0: stereo
-0,          0,          0,     1024,     8192, 0x85791bdb
-0,       1024,       1024,     1024,     8192, 0x8db6dfa9
-0,       2048,       2048,     1024,     8192, 0x617b2190
-0,       3072,       3072,     1024,     8192, 0x733c4d71
-0,       4096,       4096,     1024,     8192, 0xb254420c
-0,       5120,       5120,     1024,     8192, 0xc166b305
-0,       6144,       6144,     1024,     8192, 0x93e8a20e
-0,       7168,       7168,     1024,     8192, 0xd91c6790
-0,       8192,       8192,     1024,     8192, 0xee6584ae
-0,       9216,       9216,     1024,     8192, 0x74a6246d
-0,      10240,      10240,     1024,     8192, 0xa20e6fb6
-0,      11264,      11264,      736,     5888, 0x06a6f058
+0,          0,          0,     4096,    32768, 0x6a926a94
+0,       4096,       4096,     4096,    32768, 0xa3dffebe
+0,       8192,       8192,     3808,    30464, 0xa3560947