FFmpeg
Data Structures | Macros | Functions | Variables
mp3enc.c File Reference
#include "avformat.h"
#include "avio_internal.h"
#include "id3v1.h"
#include "id3v2.h"
#include "mux.h"
#include "rawenc.h"
#include "libavutil/avstring.h"
#include "libavcodec/mpegaudio.h"
#include "libavcodec/mpegaudiodata.h"
#include "libavcodec/mpegaudiodecheader.h"
#include "libavcodec/packet_internal.h"
#include "libavutil/intreadwrite.h"
#include "libavutil/opt.h"
#include "libavutil/dict.h"
#include "libavutil/avassert.h"
#include "libavutil/crc.h"
#include "libavutil/mathematics.h"
#include "libavutil/replaygain.h"

Go to the source code of this file.

Data Structures

struct  MP3Context
 

Macros

#define XING_NUM_BAGS   400
 
#define XING_TOC_SIZE   100
 
#define XING_SIZE   156
 

Functions

static int id3v1_set_string (AVFormatContext *s, const char *key, uint8_t *buf, int buf_size)
 
static int id3v1_create_tag (AVFormatContext *s, uint8_t *buf)
 
static int mp3_write_xing (AVFormatContext *s)
 
static void mp3_xing_add_frame (MP3Context *mp3, AVPacket *pkt)
 
static int mp3_write_audio_packet (AVFormatContext *s, AVPacket *pkt)
 
static int mp3_queue_flush (AVFormatContext *s)
 
static void mp3_update_xing (AVFormatContext *s)
 
static int mp3_write_trailer (struct AVFormatContext *s)
 
static int query_codec (enum AVCodecID id, int std_compliance)
 
static int mp3_write_packet (AVFormatContext *s, AVPacket *pkt)
 
static int mp3_init (struct AVFormatContext *s)
 Write an ID3v2 header at beginning of stream. More...
 
static int mp3_write_header (struct AVFormatContext *s)
 
static void mp3_deinit (struct AVFormatContext *s)
 

Variables

static const uint8_t xing_offtbl [2][2] = {{32, 17}, {17, 9}}
 
static const AVOption options []
 
static const AVClass mp3_muxer_class
 
const FFOutputFormat ff_mp3_muxer
 

Macro Definition Documentation

◆ XING_NUM_BAGS

#define XING_NUM_BAGS   400

Definition at line 94 of file mp3enc.c.

◆ XING_TOC_SIZE

#define XING_TOC_SIZE   100

Definition at line 95 of file mp3enc.c.

◆ XING_SIZE

#define XING_SIZE   156

Definition at line 97 of file mp3enc.c.

Function Documentation

◆ id3v1_set_string()

static int id3v1_set_string ( AVFormatContext s,
const char *  key,
uint8_t *  buf,
int  buf_size 
)
static

Definition at line 41 of file mp3enc.c.

Referenced by id3v1_create_tag().

◆ id3v1_create_tag()

static int id3v1_create_tag ( AVFormatContext s,
uint8_t *  buf 
)
static

Definition at line 51 of file mp3enc.c.

Referenced by mp3_write_trailer().

◆ mp3_write_xing()

static int mp3_write_xing ( AVFormatContext s)
static

Definition at line 144 of file mp3enc.c.

Referenced by mp3_queue_flush(), and mp3_write_header().

◆ mp3_xing_add_frame()

static void mp3_xing_add_frame ( MP3Context mp3,
AVPacket pkt 
)
static

Definition at line 291 of file mp3enc.c.

Referenced by mp3_write_audio_packet().

◆ mp3_write_audio_packet()

static int mp3_write_audio_packet ( AVFormatContext s,
AVPacket pkt 
)
static

Definition at line 317 of file mp3enc.c.

Referenced by mp3_queue_flush(), and mp3_write_packet().

◆ mp3_queue_flush()

static int mp3_queue_flush ( AVFormatContext s)
static

Definition at line 382 of file mp3enc.c.

Referenced by mp3_write_packet(), and mp3_write_trailer().

◆ mp3_update_xing()

static void mp3_update_xing ( AVFormatContext s)
static

Definition at line 400 of file mp3enc.c.

Referenced by mp3_write_trailer().

◆ mp3_write_trailer()

static int mp3_write_trailer ( struct AVFormatContext s)
static

Definition at line 471 of file mp3enc.c.

◆ query_codec()

static int query_codec ( enum AVCodecID  id,
int  std_compliance 
)
static

Definition at line 493 of file mp3enc.c.

◆ mp3_write_packet()

static int mp3_write_packet ( AVFormatContext s,
AVPacket pkt 
)
static

Definition at line 521 of file mp3enc.c.

◆ mp3_init()

static int mp3_init ( struct AVFormatContext s)
static

Write an ID3v2 header at beginning of stream.

Definition at line 566 of file mp3enc.c.

◆ mp3_write_header()

static int mp3_write_header ( struct AVFormatContext s)
static

Definition at line 611 of file mp3enc.c.

◆ mp3_deinit()

static void mp3_deinit ( struct AVFormatContext s)
static

Definition at line 632 of file mp3enc.c.

Variable Documentation

◆ xing_offtbl

const uint8_t xing_offtbl[2][2] = {{32, 17}, {17, 9}}
static

Definition at line 139 of file mp3enc.c.

Referenced by mp3_parse_info_tag(), mp3_write_audio_packet(), and mp3_write_xing().

◆ options

const AVOption options[]
static
Initial value:
= {
{ "id3v2_version", "Select ID3v2 version to write. Currently 3 and 4 are supported.",
0x42, AV_OPT_TYPE_INT, {.i64 = 4}, 0, 4, AV_OPT_FLAG_ENCODING_PARAM},
{ "write_id3v1", "Enable ID3v1 writing. ID3v1 tags are written in UTF-8 which may not be supported by most software.",
0x42, AV_OPT_TYPE_BOOL, {.i64 = 0}, 0, 1, AV_OPT_FLAG_ENCODING_PARAM},
{ "write_xing", "Write the Xing header containing file duration.",
0x42, AV_OPT_TYPE_BOOL, {.i64 = 1}, 0, 1, AV_OPT_FLAG_ENCODING_PARAM},
{ NULL },
}

Definition at line 504 of file mp3enc.c.

◆ mp3_muxer_class

const AVClass mp3_muxer_class
static
Initial value:
= {
.class_name = "MP3 muxer",
.item_name = av_default_item_name,
.option = options,
}

Definition at line 514 of file mp3enc.c.

◆ ff_mp3_muxer

const FFOutputFormat ff_mp3_muxer
Initial value:
= {
.p.name = "mp3",
.p.long_name = NULL_IF_CONFIG_SMALL("MP3 (MPEG audio layer 3)"),
.p.mime_type = "audio/mpeg",
.p.extensions = "mp3",
.priv_data_size = sizeof(MP3Context),
.p.audio_codec = AV_CODEC_ID_MP3,
.p.video_codec = AV_CODEC_ID_PNG,
.init = mp3_init,
.write_header = mp3_write_header,
.write_packet = mp3_write_packet,
.write_trailer = mp3_write_trailer,
.deinit = mp3_deinit,
.query_codec = query_codec,
.p.flags = AVFMT_NOTIMESTAMPS,
.p.priv_class = &mp3_muxer_class,
}

Definition at line 640 of file mp3enc.c.

AVFMT_NOTIMESTAMPS
#define AVFMT_NOTIMESTAMPS
Format does not need / have any timestamps.
Definition: avformat.h:479
MP3Context
Definition: mp3enc.c:99
AV_CODEC_ID_MP3
@ AV_CODEC_ID_MP3
preferred ID for decoding MPEG audio layer 1, 2 or 3
Definition: codec_id.h:439
mp3_write_header
static int mp3_write_header(struct AVFormatContext *s)
Definition: mp3enc.c:611
AV_OPT_FLAG_ENCODING_PARAM
#define AV_OPT_FLAG_ENCODING_PARAM
a generic parameter which can be set by the user for muxing or encoding
Definition: opt.h:281
query_codec
static int query_codec(enum AVCodecID id, int std_compliance)
Definition: mp3enc.c:493
mp3_write_trailer
static int mp3_write_trailer(struct AVFormatContext *s)
Definition: mp3enc.c:471
AV_CODEC_ID_PNG
@ AV_CODEC_ID_PNG
Definition: codec_id.h:113
LIBAVUTIL_VERSION_INT
#define LIBAVUTIL_VERSION_INT
Definition: version.h:85
NULL
#define NULL
Definition: coverity.c:32
av_default_item_name
const char * av_default_item_name(void *ptr)
Return the context name.
Definition: log.c:237
mp3_write_packet
static int mp3_write_packet(AVFormatContext *s, AVPacket *pkt)
Definition: mp3enc.c:521
NULL_IF_CONFIG_SMALL
#define NULL_IF_CONFIG_SMALL(x)
Return NULL if CONFIG_SMALL is true, otherwise the argument without modification.
Definition: internal.h:115
mp3_deinit
static void mp3_deinit(struct AVFormatContext *s)
Definition: mp3enc.c:632
AV_OPT_TYPE_INT
@ AV_OPT_TYPE_INT
Definition: opt.h:225
options
static const AVOption options[]
Definition: mp3enc.c:504
AV_OPT_TYPE_BOOL
@ AV_OPT_TYPE_BOOL
Definition: opt.h:244
mp3_init
static int mp3_init(struct AVFormatContext *s)
Write an ID3v2 header at beginning of stream.
Definition: mp3enc.c:566
mp3_muxer_class
static const AVClass mp3_muxer_class
Definition: mp3enc.c:514