FFmpeg
Loading...
Searching...
No Matches
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 "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.
 
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.

Referenced by mp3_xing_add_frame().

◆ XING_TOC_SIZE

#define XING_TOC_SIZE   100

Definition at line 96 of file mp3enc.c.

Referenced by mp3_update_xing(), and mp3_write_xing().

◆ XING_SIZE

#define XING_SIZE   156

Definition at line 98 of file mp3enc.c.

Referenced by mp3_update_xing(), and mp3_write_xing().

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 384 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 402 of file mp3enc.c.

Referenced by mp3_write_trailer().

◆ mp3_write_trailer()

static int mp3_write_trailer ( struct AVFormatContext * s)
static

Definition at line 477 of file mp3enc.c.

◆ query_codec()

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

Definition at line 499 of file mp3enc.c.

◆ mp3_write_packet()

static int mp3_write_packet ( AVFormatContext * s,
AVPacket * pkt )
static

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

◆ mp3_write_header()

static int mp3_write_header ( struct AVFormatContext * s)
static

Definition at line 621 of file mp3enc.c.

◆ mp3_deinit()

static void mp3_deinit ( struct AVFormatContext * s)
static

Definition at line 642 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 },
}
#define NULL
Definition coverity.c:32
#define AV_OPT_FLAG_ENCODING_PARAM
A generic parameter which can be set by the user for muxing or encoding.
Definition opt.h:351
@ AV_OPT_TYPE_INT
Underlying C type is int.
Definition opt.h:258
@ AV_OPT_TYPE_BOOL
Underlying C type is int.
Definition opt.h:326

Definition at line 514 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,
}
const char * av_default_item_name(void *ptr)
Return the context name.
Definition log.c:241
#define LIBAVUTIL_VERSION_INT
Definition version.h:85

Definition at line 524 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,
}
#define AVFMT_NOTIMESTAMPS
Format does not need / have any timestamps.
Definition avformat.h:498
@ AV_CODEC_ID_PNG
Definition codec_id.h:111
@ AV_CODEC_ID_MP3
preferred ID for decoding MPEG audio layer 1, 2 or 3
Definition codec_id.h:454
static int query_codec(enum AVCodecID id, int std_compliance)
Definition img2enc.c:361
#define NULL_IF_CONFIG_SMALL(x)
Return NULL if CONFIG_SMALL is true, otherwise the argument without modification.
Definition internal.h:88
static const AVClass mp3_muxer_class
Definition mp3enc.c:524
static int mp3_init(struct AVFormatContext *s)
Write an ID3v2 header at beginning of stream.
Definition mp3enc.c:576
static void mp3_deinit(struct AVFormatContext *s)
Definition mp3enc.c:642
static int mp3_write_header(struct AVFormatContext *s)
Definition mp3enc.c:621
static int mp3_write_packet(AVFormatContext *s, AVPacket *pkt)
Definition mp3enc.c:531
static int mp3_write_trailer(struct AVFormatContext *s)
Definition mp3enc.c:477

Definition at line 650 of file mp3enc.c.