FFmpeg
Loading...
Searching...
No Matches
id3v2enc.c
Go to the documentation of this file.
1/*
2 * This file is part of FFmpeg.
3 *
4 * FFmpeg is free software; you can redistribute it and/or
5 * modify it under the terms of the GNU Lesser General Public
6 * License as published by the Free Software Foundation; either
7 * version 2.1 of the License, or (at your option) any later version.
8 *
9 * FFmpeg is distributed in the hope that it will be useful,
10 * but WITHOUT ANY WARRANTY; without even the implied warranty of
11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
12 * Lesser General Public License for more details.
13 *
14 * You should have received a copy of the GNU Lesser General Public
15 * License along with FFmpeg; if not, write to the Free Software
16 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
17 */
18
19#include <stdio.h>
20
21#include "libavutil/mem.h"
22#include "libavformat/avio.h"
23#include "libavformat/id3v2.h"
24
25int main(void)
26{
27 for (int version = 3; version <= 4; version++) {
28 ID3v2EncContext id3 = { 0 };
29
30 for (int tag = 0; tag < 3; tag++) {
31 AVIOContext *pb;
32 uint8_t *buf;
33 int initial_len, size;
34
35 /* Test zeroed, reused, and explicitly nonzero contexts. */
36 if (tag == 2)
37 id3.len = 123;
38
39 if (avio_open_dyn_buf(&pb) < 0)
40 return 1;
41
43 initial_len = id3.len;
44 ff_id3v2_finish(&id3, pb, 10);
45 size = avio_close_dyn_buf(pb, &buf);
46 if (size < ID3v2_HEADER_SIZE) {
47 av_free(buf);
48 return 1;
49 }
50 printf("version=%d tag=%d initial_len=%d declared=%d actual=%d\n",
51 version, tag, initial_len, ff_id3v2_tag_len(buf), size);
52 av_free(buf);
53 }
54 }
55 return 0;
56}
Buffered I/O operations.
int avio_close_dyn_buf(AVIOContext *s, uint8_t **pbuffer)
Return the written size and a pointer to the buffer.
Definition aviobuf.c:1369
int avio_open_dyn_buf(AVIOContext **s)
Open a write only memory stream.
Definition aviobuf.c:1324
__device__ int printf(const char *,...)
int ff_id3v2_tag_len(const uint8_t *buf)
Get the length of an ID3v2 tag.
Definition id3v2.c:165
#define ID3v2_DEFAULT_MAGIC
Default magic bytes for ID3v2 header: "ID3".
Definition id3v2.h:35
#define ID3v2_HEADER_SIZE
Definition id3v2.h:30
void ff_id3v2_start(ID3v2EncContext *id3, AVIOContext *pb, int id3v2_version, const char *magic)
Initialize the encoding context and write the header for a new ID3v2 tag.
Definition id3v2enc.c:349
void ff_id3v2_finish(ID3v2EncContext *id3, AVIOContext *pb, int padding_bytes)
Finalize an opened ID3v2 tag.
Definition id3v2enc.c:557
version
Definition libkvazaar.c:313
Memory handling functions.
uint32_t tag
Definition movenc.c:2128
Bytestream IO Context.
Definition avio.h:160
int len
size of the tag written so far
Definition id3v2.h:54
#define av_free(p)
int main(void)
Definition id3v2enc.c:25
int size