diff mbox

[FFmpeg-devel,1/2] avformat/mpegenc - log error msgs for unsupported LPCM streams

Message ID 4a8acc62-9dc1-f5d3-f652-f2811ef958b6@gmail.com
State Accepted
Commit 4f8c691040b026d001ff33d38c0e1516a35b946e
Headers show

Commit Message

Gyan Feb. 20, 2018, 3:17 p.m. UTC
From 5f5cc12ff449fecfe668ec4537b8f2bb16d896d7 Mon Sep 17 00:00:00 2001
From: Gyan Doshi <gyandoshi@gmail.com>
Date: Tue, 20 Feb 2018 20:31:28 +0530
Subject: [PATCH 1/2] avformat/mpegenc - log error msgs for unsupported LPCM
 streams

The MPEG-PS muxer only accepts PCM streams having up to 8 channels
and the following sampling rates: 32/44.1/48/96 kHz.
---
 libavformat/mpegenc.c | 15 ++++++++++++---
 1 file changed, 12 insertions(+), 3 deletions(-)

Comments

Michael Niedermayer Feb. 21, 2018, 7:49 p.m. UTC | #1
On Tue, Feb 20, 2018 at 08:47:14PM +0530, Gyan Doshi wrote:
>  mpegenc.c |   15 ++++++++++++---
>  1 file changed, 12 insertions(+), 3 deletions(-)
> ce683c8f43bc80d03c4fb3efaeb9978ed1d2c860  0001-avformat-mpegenc-log-error-msgs-for-unsupported-LPCM.patch
> From 5f5cc12ff449fecfe668ec4537b8f2bb16d896d7 Mon Sep 17 00:00:00 2001
> From: Gyan Doshi <gyandoshi@gmail.com>
> Date: Tue, 20 Feb 2018 20:31:28 +0530
> Subject: [PATCH 1/2] avformat/mpegenc - log error msgs for unsupported LPCM
>  streams
> 
> The MPEG-PS muxer only accepts PCM streams having up to 8 channels
> and the following sampling rates: 32/44.1/48/96 kHz.
> ---
>  libavformat/mpegenc.c | 15 ++++++++++++---
>  1 file changed, 12 insertions(+), 3 deletions(-)

will apply

thx

[...]
diff mbox

Patch

diff --git a/libavformat/mpegenc.c b/libavformat/mpegenc.c
index c84dc52eb9..4c6fa67fb8 100644
--- a/libavformat/mpegenc.c
+++ b/libavformat/mpegenc.c
@@ -375,10 +375,19 @@  static av_cold int mpeg_mux_init(AVFormatContext *ctx)
                     if (lpcm_freq_tab[j] == st->codecpar->sample_rate)
                         break;
                 }
-                if (j == 4)
+                if (j == 4) {
+                    int sr;
+                    av_log(ctx, AV_LOG_ERROR, "Invalid sampling rate for PCM stream.\n");
+                    av_log(ctx, AV_LOG_INFO, "Allowed sampling rates:");
+                    for (sr = 0; sr < 4; sr++)
+                         av_log(ctx, AV_LOG_INFO, " %d", lpcm_freq_tab[sr]);
+                    av_log(ctx, AV_LOG_INFO, "\n");
                     goto fail;
-                if (st->codecpar->channels > 8)
-                    return -1;
+                }
+                if (st->codecpar->channels > 8) {
+                    av_log(ctx, AV_LOG_ERROR, "At most 8 channels allowed for LPCM streams.\n");
+                    goto fail;
+                }
                 stream->lpcm_header[0] = 0x0c;
                 stream->lpcm_header[1] = (st->codecpar->channels - 1) | (j << 4);
                 stream->lpcm_header[2] = 0x80;