aboutsummaryrefslogtreecommitdiffstats
path: root/libavformat/mp3enc.c
diff options
context:
space:
mode:
authorMichael Niedermayer <michaelni@gmx.at>2011-07-09 02:06:40 +0200
committerMichael Niedermayer <michaelni@gmx.at>2011-07-09 02:06:40 +0200
commit58257ea29e0716a50dc742959de876606ed22416 (patch)
treea4949244816d4eb7a4231b1798b54bea4a79d4e5 /libavformat/mp3enc.c
parent971c04066c601bdd38ed5e8eb585d2f5ba211fe2 (diff)
parentbda168d2b0210dda84f1a9d32c8aa4653d1674d5 (diff)
downloadffmpeg-58257ea29e0716a50dc742959de876606ed22416.tar.gz
Merge remote-tracking branch 'qatar/master'
* qatar/master: (28 commits) mp3enc: write a xing frame containing number of frames in the file lavf: update AVStream.nb_frames when muxing. ffmpeg: remove unused variables from InputStream. doc: update ffmpeg -ar and -ac documentation to reflect reality. ffmpeg: remove pointless if (nb_input_files) ffmpeg: merge input_files_ts_offset into input_files. ffmpeg: merge input_codecs into input_streams. ffmpeg: drop AV prefixes from struct names. ffmpeg: deprecate loop_input and loop_output options gif: add loop private option. img2: add loop private option. AVOptions: in av_opt_find() don't return named constants unless unit is specified. x11grab: replace undocumented nomouse hackery with a private option. dict: extend documentation. lls: whitespace cosmetics docs: Use proper markup for a literal command line option docs: Remove a remark that isn't relevant any longer docs: Explain how to regenerate import libraries with MSVC tools docs: Mention that libraries for MSVC can be built with a cross compiler docs: Remove old docs that mention setting up a build environment with lib.exe ... Conflicts: doc/ffmpeg.texi doc/general.texi ffmpeg.c libavcodec/Makefile libavcodec/dnxhddata.c libavformat/mp3enc.c libavformat/utils.c libavutil/Makefile tests/copycooker.sh Merged-by: Michael Niedermayer <michaelni@gmx.at>
Diffstat (limited to 'libavformat/mp3enc.c')
-rw-r--r--libavformat/mp3enc.c43
1 files changed, 29 insertions, 14 deletions
diff --git a/libavformat/mp3enc.c b/libavformat/mp3enc.c
index 50342bb950..46b65a55d9 100644
--- a/libavformat/mp3enc.c
+++ b/libavformat/mp3enc.c
@@ -21,10 +21,14 @@
#include <strings.h>
#include "avformat.h"
+#include "avio_internal.h"
#include "id3v1.h"
#include "id3v2.h"
#include "rawenc.h"
#include "libavutil/avstring.h"
+#include "libavcodec/mpegaudio.h"
+#include "libavcodec/mpegaudiodata.h"
+#include "libavcodec/mpegaudiodecheader.h"
#include "libavutil/intreadwrite.h"
#include "libavutil/opt.h"
#include "libavcodec/mpegaudio.h"
@@ -132,15 +136,39 @@ static int id3v2_put_ttag(AVFormatContext *s, const char *str1, const char *str2
return len + ID3v2_HEADER_SIZE;
}
+#define VBR_NUM_BAGS 400
+#define VBR_TOC_SIZE 100
+typedef struct MP3Context {
+ const AVClass *class;
+ int id3v2_version;
+ int64_t frames_offset;
+ int32_t frames;
+ int32_t size;
+ uint32_t want;
+ uint32_t seen;
+ uint32_t pos;
+ uint64_t bag[VBR_NUM_BAGS];
+} MP3Context;
+
static int mp2_write_trailer(struct AVFormatContext *s)
{
uint8_t buf[ID3v1_TAG_SIZE];
+ MP3Context *mp3 = s->priv_data;
/* write the id3v1 tag */
if (id3v1_create_tag(s, buf) > 0) {
avio_write(s->pb, buf, ID3v1_TAG_SIZE);
- avio_flush(s->pb);
}
+
+ /* write number of frames */
+ if (mp3 && mp3->frames_offset) {
+ avio_seek(s->pb, mp3->frames_offset, SEEK_SET);
+ avio_wb32(s->pb, s->streams[0]->nb_frames);
+ avio_seek(s->pb, 0, SEEK_END);
+ }
+
+ avio_flush(s->pb);
+
return 0;
}
@@ -160,19 +188,6 @@ AVOutputFormat ff_mp2_muxer = {
#endif
#if CONFIG_MP3_MUXER
-#define VBR_NUM_BAGS 400
-#define VBR_TOC_SIZE 100
-typedef struct MP3Context {
- const AVClass *class;
- int id3v2_version;
- int64_t frames_offset;
- int32_t frames;
- int32_t size;
- uint32_t want;
- uint32_t seen;
- uint32_t pos;
- uint64_t bag[VBR_NUM_BAGS];
-} MP3Context;
static const AVOption options[] = {
{ "id3v2_version", "Select ID3v2 version to write. Currently 3 and 4 are supported.",