FFmpeg
Data Structures | Macros | Functions | Variables
mp3enc.c File Reference
#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 "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
 
AVOutputFormat ff_mp3_muxer
 

Macro Definition Documentation

◆ XING_NUM_BAGS

#define XING_NUM_BAGS   400

Definition at line 93 of file mp3enc.c.

◆ XING_TOC_SIZE

#define XING_TOC_SIZE   100

Definition at line 94 of file mp3enc.c.

◆ XING_SIZE

#define XING_SIZE   156

Definition at line 96 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 40 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 50 of file mp3enc.c.

Referenced by mp3_write_trailer().

◆ mp3_write_xing()

static int mp3_write_xing ( AVFormatContext s)
static

Definition at line 143 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 290 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 316 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 381 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 399 of file mp3enc.c.

Referenced by mp3_write_trailer().

◆ mp3_write_trailer()

static int mp3_write_trailer ( struct AVFormatContext s)
static

Definition at line 470 of file mp3enc.c.

◆ query_codec()

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

Definition at line 492 of file mp3enc.c.

◆ mp3_write_packet()

static int mp3_write_packet ( AVFormatContext s,
AVPacket pkt 
)
static

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

◆ mp3_write_header()

static int mp3_write_header ( struct AVFormatContext s)
static

Definition at line 610 of file mp3enc.c.

◆ mp3_deinit()

static void mp3_deinit ( struct AVFormatContext s)
static

Definition at line 631 of file mp3enc.c.

Variable Documentation

◆ xing_offtbl

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

Definition at line 138 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 503 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 513 of file mp3enc.c.

◆ ff_mp3_muxer

AVOutputFormat ff_mp3_muxer
Initial value:
= {
.name = "mp3",
.long_name = NULL_IF_CONFIG_SMALL("MP3 (MPEG audio layer 3)"),
.mime_type = "audio/mpeg",
.extensions = "mp3",
.priv_data_size = sizeof(MP3Context),
.audio_codec = AV_CODEC_ID_MP3,
.video_codec = AV_CODEC_ID_PNG,
.deinit = mp3_deinit,
.priv_class = &mp3_muxer_class,
}

Definition at line 639 of file mp3enc.c.

init
static av_cold int init(AVCodecContext *avctx)
Definition: avrndec.c:31
AVFMT_NOTIMESTAMPS
#define AVFMT_NOTIMESTAMPS
Format does not need / have any timestamps.
Definition: avformat.h:462
MP3Context
Definition: mp3enc.c:98
AV_CODEC_ID_MP3
@ AV_CODEC_ID_MP3
preferred ID for decoding MPEG audio layer 1, 2 or 3
Definition: codec_id.h:425
mp3_write_header
static int mp3_write_header(struct AVFormatContext *s)
Definition: mp3enc.c:610
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:278
query_codec
static int query_codec(enum AVCodecID id, int std_compliance)
Definition: mp3enc.c:492
mp3_write_trailer
static int mp3_write_trailer(struct AVFormatContext *s)
Definition: mp3enc.c:470
AV_CODEC_ID_PNG
@ AV_CODEC_ID_PNG
Definition: codec_id.h:110
LIBAVUTIL_VERSION_INT
#define LIBAVUTIL_VERSION_INT
Definition: version.h:85
NULL
#define NULL
Definition: coverity.c:32
write_trailer
static int write_trailer(AVFormatContext *s1)
Definition: v4l2enc.c:98
av_default_item_name
const char * av_default_item_name(void *ptr)
Return the context name.
Definition: log.c:235
mp3_write_packet
static int mp3_write_packet(AVFormatContext *s, AVPacket *pkt)
Definition: mp3enc.c:520
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:117
write_packet
static void write_packet(OutputFile *of, AVPacket *pkt, OutputStream *ost, int unqueue)
Definition: ffmpeg.c:729
mp3_deinit
static void mp3_deinit(struct AVFormatContext *s)
Definition: mp3enc.c:631
AV_OPT_TYPE_INT
@ AV_OPT_TYPE_INT
Definition: opt.h:225
options
static const AVOption options[]
Definition: mp3enc.c:503
AV_OPT_TYPE_BOOL
@ AV_OPT_TYPE_BOOL
Definition: opt.h:242
flags
#define flags(name, subs,...)
Definition: cbs_av1.c:561
write_header
static void write_header(FFV1Context *f)
Definition: ffv1enc.c:346
mp3_init
static int mp3_init(struct AVFormatContext *s)
Write an ID3v2 header at beginning of stream.
Definition: mp3enc.c:565
mp3_muxer_class
static const AVClass mp3_muxer_class
Definition: mp3enc.c:513