]> git.sesse.net Git - ffmpeg/blobdiff - libavcodec/libmp3lame.c
lavc/g723.1: fix make checkheaders.
[ffmpeg] / libavcodec / libmp3lame.c
index b8c32bc477681e1f92662b6deae403904802aaaa..1e50e0a48b31c8b20e42b3dc6f363a2cd124d0ef 100644 (file)
@@ -26,6 +26,7 @@
 
 #include <lame/lame.h>
 
+#include "libavutil/audioconvert.h"
 #include "libavutil/intreadwrite.h"
 #include "libavutil/log.h"
 #include "libavutil/opt.h"
@@ -76,13 +77,7 @@ static av_cold int mp3lame_encode_init(AVCodecContext *avctx)
     if ((s->gfp = lame_init()) == NULL)
         return AVERROR(ENOMEM);
 
-    /* channels */
-    if (avctx->channels > 2) {
-        av_log(avctx, AV_LOG_ERROR,
-               "Invalid number of channels %d, must be <= 2\n", avctx->channels);
-        ret =  AVERROR(EINVAL);
-        goto error;
-    }
+
     lame_set_num_channels(s->gfp, avctx->channels);
     lame_set_mode(s->gfp, avctx->channels > 1 ? JOINT_STEREO : MONO);
 
@@ -255,9 +250,8 @@ static int mp3lame_encode_frame(AVCodecContext *avctx, AVPacket *avpkt,
     av_dlog(avctx, "in:%d packet-len:%d index:%d\n", avctx->frame_size, len,
             s->buffer_index);
     if (len <= s->buffer_index) {
-        if ((ret = ff_alloc_packet2(avctx, avpkt, len))) {
+        if ((ret = ff_alloc_packet2(avctx, avpkt, len)))
             return ret;
-        }
         memcpy(avpkt->data, s->buffer, len);
         s->buffer_index -= len;
         memmove(s->buffer, s->buffer + len, s->buffer_index);
@@ -309,6 +303,8 @@ AVCodec ff_libmp3lame_encoder = {
                                                              AV_SAMPLE_FMT_S16,
                                                              AV_SAMPLE_FMT_NONE },
     .supported_samplerates = libmp3lame_sample_rates,
+    .channel_layouts       = (const uint64_t[]) { AV_CH_LAYOUT_MONO,
+                                                  AV_CH_LAYOUT_STEREO },
     .long_name             = NULL_IF_CONFIG_SMALL("libmp3lame MP3 (MPEG audio layer 3)"),
     .priv_class            = &libmp3lame_class,
     .defaults              = libmp3lame_defaults,