summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--audio/decode/ad_spdif.c2
-rw-r--r--audio/format.c16
2 files changed, 9 insertions, 9 deletions
diff --git a/audio/decode/ad_spdif.c b/audio/decode/ad_spdif.c
index 3da5def868..0ba88f8366 100644
--- a/audio/decode/ad_spdif.c
+++ b/audio/decode/ad_spdif.c
@@ -36,7 +36,6 @@
struct spdifContext {
struct mp_log *log;
AVFormatContext *lavf_ctx;
- int iec61937_packet_size;
int out_buffer_len;
uint8_t out_buffer[OUTBUF_SIZE];
bool need_close;
@@ -159,7 +158,6 @@ static int init(struct dec_audio *da, const char *decoder)
mp_audio_set_num_channels(&spdif_ctx->fmt, num_channels);
mp_audio_set_format(&spdif_ctx->fmt, sample_format);
spdif_ctx->fmt.rate = samplerate;
- spdif_ctx->iec61937_packet_size = af_format_sample_alignment(sample_format);
if (avformat_write_header(lavf_ctx, &format_opts) < 0) {
MP_FATAL(da, "libavformat spdif initialization failed.\n");
diff --git a/audio/format.c b/audio/format.c
index c2b29b62ad..7f9cb1477e 100644
--- a/audio/format.c
+++ b/audio/format.c
@@ -228,16 +228,18 @@ int af_format_conversion_score(int dst_format, int src_format)
return score;
}
+// Return the number of samples that make up one frame in this format.
+// You get the byte size by multiplying them with sample size and channel count.
int af_format_sample_alignment(int format)
{
switch (format) {
- case AF_FORMAT_S_AAC: return 16384;
- case AF_FORMAT_S_AC3: return 6144;
- case AF_FORMAT_S_DTSHD: return 32768;
- case AF_FORMAT_S_DTS: return 32768;
- case AF_FORMAT_S_EAC3: return 24576;
- case AF_FORMAT_S_MP3: return 4608;
- case AF_FORMAT_S_TRUEHD: return 61440;
+ case AF_FORMAT_S_AAC: return 16384 / 4;
+ case AF_FORMAT_S_AC3: return 6144 / 4;
+ case AF_FORMAT_S_DTSHD: return 32768 / 16;
+ case AF_FORMAT_S_DTS: return 2048 / 4;
+ case AF_FORMAT_S_EAC3: return 24576 / 4;
+ case AF_FORMAT_S_MP3: return 4608 / 4;
+ case AF_FORMAT_S_TRUEHD: return 61440 / 16;
default: return 1;
}
}