FFmpeg
Loading...
Searching...
No Matches
libavformat
tests
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
25
int
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
42
ff_id3v2_start
(&id3, pb,
version
,
ID3v2_DEFAULT_MAGIC
);
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
}
avio.h
Buffered I/O operations.
avio_close_dyn_buf
int avio_close_dyn_buf(AVIOContext *s, uint8_t **pbuffer)
Return the written size and a pointer to the buffer.
Definition
aviobuf.c:1369
avio_open_dyn_buf
int avio_open_dyn_buf(AVIOContext **s)
Open a write only memory stream.
Definition
aviobuf.c:1324
printf
__device__ int printf(const char *,...)
ff_id3v2_tag_len
int ff_id3v2_tag_len(const uint8_t *buf)
Get the length of an ID3v2 tag.
Definition
id3v2.c:165
id3v2.h
ID3v2_DEFAULT_MAGIC
#define ID3v2_DEFAULT_MAGIC
Default magic bytes for ID3v2 header: "ID3".
Definition
id3v2.h:35
ID3v2_HEADER_SIZE
#define ID3v2_HEADER_SIZE
Definition
id3v2.h:30
ff_id3v2_start
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
ff_id3v2_finish
void ff_id3v2_finish(ID3v2EncContext *id3, AVIOContext *pb, int padding_bytes)
Finalize an opened ID3v2 tag.
Definition
id3v2enc.c:557
version
version
Definition
libkvazaar.c:313
mem.h
Memory handling functions.
tag
uint32_t tag
Definition
movenc.c:2128
AVIOContext
Bytestream IO Context.
Definition
avio.h:160
ID3v2EncContext
Definition
id3v2.h:51
ID3v2EncContext::len
int len
size of the tag written so far
Definition
id3v2.h:54
av_free
#define av_free(p)
Definition
tableprint_vlc.h:34
main
int main(void)
Definition
id3v2enc.c:25
size
int size
Definition
twinvq_data.h:10344
Generated on Sun Oct 11 2026 19:21:13 for FFmpeg by
1.13.2