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 "libavutil/mem.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 95 of file mp3enc.c.

◆ XING_TOC_SIZE

#define XING_TOC_SIZE   100

Definition at line 96 of file mp3enc.c.

◆ XING_SIZE

#define XING_SIZE   156

Definition at line 98 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 42 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 52 of file mp3enc.c.

Referenced by mp3_write_trailer().

◆ mp3_write_xing()

static int mp3_write_xing ( AVFormatContext s)
static

Definition at line 145 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 292 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 318 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 383 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 401 of file mp3enc.c.

Referenced by mp3_write_trailer().

◆ mp3_write_trailer()

static int mp3_write_trailer ( struct AVFormatContext s)
static

Definition at line 474 of file mp3enc.c.

◆ query_codec()

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

Definition at line 496 of file mp3enc.c.

◆ mp3_write_packet()

static int mp3_write_packet ( AVFormatContext s,
AVPacket pkt 
)
static

Definition at line 528 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 573 of file mp3enc.c.

◆ mp3_write_header()

static int mp3_write_header ( struct AVFormatContext s)
static

Definition at line 618 of file mp3enc.c.

◆ mp3_deinit()

static void mp3_deinit ( struct AVFormatContext s)
static

Definition at line 639 of file mp3enc.c.

Variable Documentation

◆ xing_offtbl

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

Definition at line 140 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 511 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 521 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 647 of file mp3enc.c.

AVFMT_NOTIMESTAMPS
#define AVFMT_NOTIMESTAMPS
Format does not need / have any timestamps.
Definition: avformat.h:479
MP3Context
Definition: mp3enc.c:100
AV_CODEC_ID_MP3
@ AV_CODEC_ID_MP3
preferred ID for decoding MPEG audio layer 1, 2 or 3
Definition: codec_id.h:447
mp3_write_header
static int mp3_write_header(struct AVFormatContext *s)
Definition: mp3enc.c:618
query_codec
static int query_codec(enum AVCodecID id, int std_compliance)
Definition: mp3enc.c:496
mp3_write_trailer
static int mp3_write_trailer(struct AVFormatContext *s)
Definition: mp3enc.c:474
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:528
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:352
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:94
mp3_deinit
static void mp3_deinit(struct AVFormatContext *s)
Definition: mp3enc.c:639
AV_OPT_TYPE_INT
@ AV_OPT_TYPE_INT
Underlying C type is int.
Definition: opt.h:259
options
static const AVOption options[]
Definition: mp3enc.c:511
AV_OPT_TYPE_BOOL
@ AV_OPT_TYPE_BOOL
Underlying C type is int.
Definition: opt.h:327
mp3_init
static int mp3_init(struct AVFormatContext *s)
Write an ID3v2 header at beginning of stream.
Definition: mp3enc.c:573
mp3_muxer_class
static const AVClass mp3_muxer_class
Definition: mp3enc.c:521