61 buf[126] = atoi(tag->
value);
77 #define XING_NUM_BAGS 400
78 #define XING_TOC_SIZE 100
80 #define XING_MAX_SIZE (32 + 4 + 4 + 4 + 4 + XING_TOC_SIZE)
119 int srate_idx, i, channels;
131 else if (codec->
sample_rate == base_freq / 2) ver = 0x2;
132 else if (codec->
sample_rate == base_freq / 4) ver = 0x0;
148 "not writing Xing header.\n");
153 bitrate_idx = (ver == 3) ? 5 : 8;
157 header |= (0x7 << 5 | ver << 3 | 0x1 << 1 | 0x1) << 16;
158 header |= (bitrate_idx << 4 | srate_idx << 2) << 8;
159 header |= channels << 6;
172 mp3->
size = mpah.frame_size;
182 mpah.frame_size -= 4 + xing_offset + 4 + 4 + 4 + 4 +
XING_TOC_SIZE;
204 mp3->
bag[i / 2] = mp3->
bag[i];
209 mp3->
pos = XING_NUM_BAGS / 2;
240 int ret = 0, write = 1;
245 while ((pktl = mp3->
queue)) {
275 int seek_point = 256LL * mp3->
bag[j] / mp3->
size;
289 "attached pictures.\n");
308 .mime_type =
"audio/x-mpeg",
309 .extensions =
"mp2,m2a",
320 {
"id3v2_version",
"Select ID3v2 version to write. Currently 3 and 4 are supported.",
322 {
"write_id3v1",
"Enable ID3v1 writing. ID3v1 tags are written in UTF-8 which may not be supported by most software.",
327 static const AVClass mp3_muxer_class = {
396 "audio stream is required.\n");
427 .mime_type =
"audio/x-mpeg",
436 .priv_class = &mp3_muxer_class,
struct MP3Context MP3Context
void av_free_packet(AVPacket *pkt)
Free a packet.
void ff_id3v2_start(ID3v2EncContext *id3, AVIOContext *pb, int id3v2_version, const char *magic)
Initialize an ID3v2 tag.
static int mp3_write_audio_packet(AVFormatContext *s, AVPacket *pkt)
#define ID3v2_DEFAULT_MAGIC
Default magic bytes for ID3v2 header: "ID3".
int64_t avio_seek(AVIOContext *s, int64_t offset, int whence)
fseek() equivalent for AVIOContext.
AVDictionaryEntry * av_dict_get(AVDictionary *m, const char *key, const AVDictionaryEntry *prev, int flags)
Get a dictionary entry with matching key.
mpeg audio layer common tables.
uint64_t bag[XING_NUM_BAGS]
void av_freep(void *arg)
Free a memory block which has been allocated with av_malloc(z)() or av_realloc() and set the pointer ...
const char * class_name
The name of the class; usually it is the same name as the context structure type to which the AVClass...
#define av_assert0(cond)
assert() equivalent, that is always enabled.
static void mp3_update_xing(AVFormatContext *s)
static int mp3_write_trailer(struct AVFormatContext *s)
const uint16_t avpriv_mpa_freq_tab[3]
static const uint8_t xing_offtbl[2][2]
static av_always_inline int64_t avio_tell(AVIOContext *s)
ftell() equivalent for AVIOContext.
void avio_write(AVIOContext *s, const unsigned char *buf, int size)
static av_always_inline void ffio_wfourcc(AVIOContext *pb, const uint8_t *s)
void(* destruct)(struct AVPacket *)
#define NULL_IF_CONFIG_SMALL(x)
Return NULL if CONFIG_SMALL is true, otherwise the argument without modification. ...
preferred ID for decoding MPEG audio layer 1, 2 or 3
simple assert() macros that are a bit more flexible than ISO C assert().
void av_log(void *avcl, int level, const char *fmt,...)
void ff_id3v2_finish(ID3v2EncContext *id3, AVIOContext *pb)
Finalize an opened ID3v2 tag.
size_t av_strlcpy(char *dst, const char *src, size_t size)
Copy the string src to dst, but no more than size - 1 bytes, and null-terminate dst.
AVCodecContext * codec
Codec context associated with this stream.
unsigned int nb_streams
A list of all streams in the file.
int seekable
A combination of AVIO_SEEKABLE_ flags or 0 when the stream is not seekable.
int ff_id3v2_write_metadata(AVFormatContext *s, ID3v2EncContext *id3)
Convert and write all global metadata from s into an ID3v2 tag.
void ffio_fill(AVIOContext *s, int b, int count)
int av_strcasecmp(const char *a, const char *b)
static void mp3_write_xing(AVFormatContext *s)
#define AV_OPT_FLAG_ENCODING_PARAM
#define AVFMT_NOTIMESTAMPS
enum AVMediaType codec_type
int sample_rate
samples per second
AVIOContext * pb
I/O context.
void avio_w8(AVIOContext *s, int b)
main external API structure.
Describe the class of an AVClass context structure.
#define FF_ARRAY_ELEMS(a)
static int id3v1_set_string(AVFormatContext *s, const char *key, uint8_t *buf, int buf_size)
int ff_id3v2_write_apic(AVFormatContext *s, ID3v2EncContext *id3, AVPacket *pkt)
Write an attached picture from pkt into an ID3v2 tag.
const OptionDef options[]
static int mp3_queue_flush(AVFormatContext *s)
struct AVPacketList * next
mpeg audio declarations for both encoder and decoder.
int64_t nb_frames
number of frames in this stream if known or 0
int channels
number of audio channels
void * priv_data
Format private data.
static void write_header(FFV1Context *f)
void avio_wb32(AVIOContext *s, unsigned int val)
static int id3v1_create_tag(AVFormatContext *s, uint8_t *buf)
const char *const ff_id3v1_genre_str[ID3v1_GENRE_MAX+1]
ID3v1 genres.
This structure stores compressed data.
void * av_mallocz(size_t size)
Allocate a block of size bytes with alignment suitable for all memory accesses (including vectors if ...
static void mp3_xing_add_frame(MP3Context *mp3, AVPacket *pkt)