]> git.sesse.net Git - ffmpeg/blobdiff - libavcodec/mp3lameaudio.c
No more HTML in Changelog
[ffmpeg] / libavcodec / mp3lameaudio.c
index 44fc5a572006f4f02be7f7aa2fd1ef60c3ae33e5..4e1660d4ebd585878f82d2ed0da1fbbcc1e8cef5 100644 (file)
@@ -2,29 +2,32 @@
  * Interface to libmp3lame for mp3 encoding
  * Copyright (c) 2002 Lennert Buytenhek <buytenh@gnu.org>
  *
- * This program is free software; you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as published by
- * the Free Software Foundation; either version 2 of the License, or
- * (at your option) any later version.
+ * This library 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 of the License, or (at your option) any later version.
  *
- * This program is distributed in the hope that it will be useful,
+ * This library 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 General Public License for more details.
+ * 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 General Public License
- * along with this program; if not, write to the Free Software
- * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library; if not, write to the Free Software
+ * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
+ */
+/**
+ * @file mp3lameaudio.c
+ * Interface to libmp3lame for mp3 encoding.
  */
 
 #include "avcodec.h"
-#include <math.h>
 #include "mpegaudio.h"
 #include <lame/lame.h>
 
 typedef struct Mp3AudioContext {
        lame_global_flags *gfp;
-       int first_frame;
        int stereo;
 } Mp3AudioContext;
 
@@ -36,7 +39,6 @@ static int MP3lame_encode_init(AVCodecContext *avctx)
        if (avctx->channels > 2)
                return -1;
 
-       s->first_frame = 1;
        s->stereo = avctx->channels > 1 ? 1 : 0;
 
        if ((s->gfp = lame_init()) == NULL)
@@ -53,7 +55,9 @@ static int MP3lame_encode_init(AVCodecContext *avctx)
                goto err_close;
 
        avctx->frame_size = MPA_FRAME_SIZE;
-       avctx->key_frame = 1;
+    
+        avctx->coded_frame= avcodec_alloc_frame();
+        avctx->coded_frame->key_frame= 1;
 
        return 0;
 
@@ -78,15 +82,14 @@ int MP3lame_encode_frame(AVCodecContext *avctx,
                        frame, buf_size);
        }
 
-       /* lame 3.91 outputs the first frame as garbage */
-       if (s->first_frame)
-               s->first_frame = num = 0;
        return num;
 }
 
 int MP3lame_encode_close(AVCodecContext *avctx)
 {
        Mp3AudioContext *s = avctx->priv_data;
+    
+        av_freep(&avctx->coded_frame);
 
        lame_close(s->gfp);
        return 0;