Libav
Main Page
Related Pages
Modules
Data Structures
Files
Examples
File List
Globals
libavformat
filmstripenc.c
Go to the documentation of this file.
1
/*
2
* Adobe Filmstrip muxer
3
* Copyright (c) 2010 Peter Ross
4
*
5
* This file is part of Libav.
6
*
7
* Libav is free software; you can redistribute it and/or
8
* modify it under the terms of the GNU Lesser General Public
9
* License as published by the Free Software Foundation; either
10
* version 2.1 of the License, or (at your option) any later version.
11
*
12
* Libav is distributed in the hope that it will be useful,
13
* but WITHOUT ANY WARRANTY; without even the implied warranty of
14
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
15
* Lesser General Public License for more details.
16
*
17
* You should have received a copy of the GNU Lesser General Public
18
* License along with Libav; if not, write to the Free Software
19
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
20
*/
21
27
#include "
libavutil/intreadwrite.h
"
28
#include "
avformat.h
"
29
30
#define RAND_TAG MKBETAG('R','a','n','d')
31
32
typedef
struct
{
33
int
nb_frames
;
34
}
FilmstripMuxContext
;
35
36
static
int
write_header
(
AVFormatContext
*s)
37
{
38
if
(s->
streams
[0]->
codec
->
pix_fmt
!=
AV_PIX_FMT_RGBA
) {
39
av_log
(s,
AV_LOG_ERROR
,
"only AV_PIX_FMT_RGBA is supported\n"
);
40
return
AVERROR_INVALIDDATA
;
41
}
42
return
0;
43
}
44
45
static
int
write_packet
(
AVFormatContext
*s,
AVPacket
*pkt)
46
{
47
FilmstripMuxContext
*film = s->
priv_data
;
48
avio_write
(s->
pb
, pkt->
data
, pkt->
size
);
49
film->
nb_frames
++;
50
return
0;
51
}
52
53
static
int
write_trailer
(
AVFormatContext
*s)
54
{
55
FilmstripMuxContext
*film = s->
priv_data
;
56
AVIOContext
*pb = s->
pb
;
57
AVStream
*st = s->
streams
[0];
58
int
i;
59
60
avio_wb32
(pb,
RAND_TAG
);
61
avio_wb32
(pb, film->
nb_frames
);
62
avio_wb16
(pb, 0);
// packing method
63
avio_wb16
(pb, 0);
// reserved
64
avio_wb16
(pb, st->
codec
->
width
);
65
avio_wb16
(pb, st->
codec
->
height
);
66
avio_wb16
(pb, 0);
// leading
67
avio_wb16
(pb, 1/
av_q2d
(st->
codec
->
time_base
));
68
for
(i = 0; i < 16; i++)
69
avio_w8
(pb, 0x00);
// reserved
70
71
return
0;
72
}
73
74
AVOutputFormat
ff_filmstrip_muxer
= {
75
.
name
=
"filmstrip"
,
76
.long_name =
NULL_IF_CONFIG_SMALL
(
"Adobe Filmstrip"
),
77
.extensions =
"flm"
,
78
.priv_data_size =
sizeof
(
FilmstripMuxContext
),
79
.audio_codec =
AV_CODEC_ID_NONE
,
80
.video_codec =
AV_CODEC_ID_RAWVIDEO
,
81
.
write_header
=
write_header
,
82
.
write_packet
=
write_packet
,
83
.
write_trailer
=
write_trailer
,
84
};
AVIOContext
Bytestream IO Context.
Definition:
avio.h:68
AVERROR_INVALIDDATA
#define AVERROR_INVALIDDATA
Invalid data found when processing input.
Definition:
error.h:54
AV_CODEC_ID_NONE
Definition:
avcodec.h:106
AVPacket::size
int size
Definition:
avcodec.h:974
AVCodecContext::pix_fmt
enum AVPixelFormat pix_fmt
Pixel format, see AV_PIX_FMT_xxx.
Definition:
avcodec.h:1247
write_trailer
static int write_trailer(AVFormatContext *s)
Definition:
filmstripenc.c:53
AVCodecContext::time_base
AVRational time_base
This is the fundamental unit of time (in seconds) in terms of which frame timestamps are represented...
Definition:
avcodec.h:1173
AVFormatContext
Format I/O context.
Definition:
avformat.h:871
FilmstripMuxContext::nb_frames
int nb_frames
Definition:
filmstripenc.c:33
ff_filmstrip_muxer
AVOutputFormat ff_filmstrip_muxer
Definition:
filmstripenc.c:74
AVFormatContext::streams
AVStream ** streams
A list of all streams in the file.
Definition:
avformat.h:935
av_q2d
static double av_q2d(AVRational a)
Convert rational to double.
Definition:
rational.h:69
AVPacket::data
uint8_t * data
Definition:
avcodec.h:973
avio_write
void avio_write(AVIOContext *s, const unsigned char *buf, int size)
Definition:
aviobuf.c:165
FilmstripMuxContext
Definition:
filmstripenc.c:32
AV_LOG_ERROR
#define AV_LOG_ERROR
Something went wrong and cannot losslessly be recovered.
Definition:
log.h:123
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:142
av_log
void av_log(void *avcl, int level, const char *fmt,...)
Definition:
log.c:148
AV_PIX_FMT_RGBA
packed RGBA 8:8:8:8, 32bpp, RGBARGBA...
Definition:
pixfmt.h:96
AVStream::codec
AVCodecContext * codec
Codec context associated with this stream.
Definition:
avformat.h:702
intreadwrite.h
AVCodecContext::width
int width
picture width / height.
Definition:
avcodec.h:1217
AVOutputFormat::name
const char * name
Definition:
avformat.h:437
AVCodecContext::height
int height
Definition:
avcodec.h:1217
AVStream
Stream structure.
Definition:
avformat.h:683
AVFormatContext::pb
AVIOContext * pb
I/O context.
Definition:
avformat.h:913
avio_w8
void avio_w8(AVIOContext *s, int b)
Definition:
aviobuf.c:144
write_packet
static int write_packet(AVFormatContext *s, AVPacket *pkt)
Definition:
filmstripenc.c:45
avio_wb16
void avio_wb16(AVIOContext *s, unsigned int val)
Definition:
aviobuf.c:342
RAND_TAG
#define RAND_TAG
Definition:
filmstripenc.c:30
avformat.h
Main libavformat public API header.
AVOutputFormat
Definition:
avformat.h:436
AVFormatContext::priv_data
void * priv_data
Format private data.
Definition:
avformat.h:899
avio_wb32
void avio_wb32(AVIOContext *s, unsigned int val)
Definition:
aviobuf.c:268
AV_CODEC_ID_RAWVIDEO
Definition:
avcodec.h:124
AVPacket
This structure stores compressed data.
Definition:
avcodec.h:950
write_header
static int write_header(AVFormatContext *s)
Definition:
filmstripenc.c:36
Generated on Tue Aug 19 2014 10:51:16 for Libav by
1.8.7