FFmpeg
Main Page
Related Pages
Modules
Namespaces
Data Structures
Files
Examples
File List
Globals
All
Data Structures
Namespaces
Files
Functions
Variables
Typedefs
Enumerations
Enumerator
Macros
Groups
Pages
libavformat
ivfenc.c
Go to the documentation of this file.
1
/*
2
* Copyright (c) 2010 Reimar Döffinger
3
*
4
* This file is part of FFmpeg.
5
*
6
* FFmpeg is free software; you can redistribute it and/or
7
* modify it under the terms of the GNU Lesser General Public
8
* License as published by the Free Software Foundation; either
9
* version 2.1 of the License, or (at your option) any later version.
10
*
11
* FFmpeg is distributed in the hope that it will be useful,
12
* but WITHOUT ANY WARRANTY; without even the implied warranty of
13
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
14
* Lesser General Public License for more details.
15
*
16
* You should have received a copy of the GNU Lesser General Public
17
* License along with FFmpeg; if not, write to the Free Software
18
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
19
*/
20
#include "
avformat.h
"
21
#include "
libavutil/intreadwrite.h
"
22
23
static
int
ivf_write_header
(
AVFormatContext
*
s
)
24
{
25
AVCodecContext
*ctx;
26
AVIOContext
*pb = s->
pb
;
27
28
if
(s->
nb_streams
!= 1) {
29
av_log
(s,
AV_LOG_ERROR
,
"Format supports only exactly one video stream\n"
);
30
return
AVERROR
(EINVAL);
31
}
32
ctx = s->
streams
[0]->
codec
;
33
if
(ctx->
codec_type
!=
AVMEDIA_TYPE_VIDEO
||
34
!(ctx->
codec_id
==
AV_CODEC_ID_VP8
|| ctx->
codec_id
==
AV_CODEC_ID_VP9
)) {
35
av_log
(s,
AV_LOG_ERROR
,
"Currently only VP8 and VP9 are supported!\n"
);
36
return
AVERROR
(EINVAL);
37
}
38
avio_write
(pb,
"DKIF"
, 4);
39
avio_wl16
(pb, 0);
// version
40
avio_wl16
(pb, 32);
// header length
41
avio_wl32
(pb, ctx->
codec_tag
? ctx->
codec_tag
: ctx->
codec_id
==
AV_CODEC_ID_VP9
?
AV_RL32
(
"VP90"
) :
AV_RL32
(
"VP80"
));
42
avio_wl16
(pb, ctx->
width
);
43
avio_wl16
(pb, ctx->
height
);
44
avio_wl32
(pb, s->
streams
[0]->
time_base
.
den
);
45
avio_wl32
(pb, s->
streams
[0]->
time_base
.
num
);
46
avio_wl64
(pb, s->
streams
[0]->
duration
);
// TODO: duration or number of frames?!?
47
48
return
0;
49
}
50
51
static
int
ivf_write_packet
(
AVFormatContext
*
s
,
AVPacket
*
pkt
)
52
{
53
AVIOContext
*pb = s->
pb
;
54
avio_wl32
(pb, pkt->
size
);
55
avio_wl64
(pb, pkt->
pts
);
56
avio_write
(pb, pkt->
data
, pkt->
size
);
57
58
return
0;
59
}
60
61
AVOutputFormat
ff_ivf_muxer
= {
62
.
name
=
"ivf"
,
63
.long_name =
NULL_IF_CONFIG_SMALL
(
"On2 IVF"
),
64
.extensions =
"ivf"
,
65
.audio_codec =
AV_CODEC_ID_NONE
,
66
.video_codec =
AV_CODEC_ID_VP8
,
67
.write_header =
ivf_write_header
,
68
.write_packet =
ivf_write_packet
,
69
};
AV_CODEC_ID_VP9
Definition:
avcodec.h:276
avio_wl16
void avio_wl16(AVIOContext *s, unsigned int val)
Definition:
aviobuf.c:416
s
const char * s
Definition:
avisynth_c.h:631
AVIOContext
Bytestream IO Context.
Definition:
avio.h:111
AV_CODEC_ID_NONE
Definition:
avcodec.h:103
ivf_write_header
static int ivf_write_header(AVFormatContext *s)
Definition:
ivfenc.c:23
AVRational::num
int num
numerator
Definition:
rational.h:44
AVPacket::size
int size
Definition:
avcodec.h:1163
ff_ivf_muxer
AVOutputFormat ff_ivf_muxer
Definition:
ivfenc.c:61
pkt
static AVPacket pkt
Definition:
demuxing_decoding.c:54
ivf_write_packet
static int ivf_write_packet(AVFormatContext *s, AVPacket *pkt)
Definition:
ivfenc.c:51
AVFormatContext
Format I/O context.
Definition:
avformat.h:1272
avio_wl32
void avio_wl32(AVIOContext *s, unsigned int val)
Definition:
aviobuf.c:318
AVFormatContext::streams
AVStream ** streams
A list of all streams in the file.
Definition:
avformat.h:1340
AVPacket::data
uint8_t * data
Definition:
avcodec.h:1162
avio_write
void avio_write(AVIOContext *s, const unsigned char *buf, int size)
Definition:
aviobuf.c:177
av_log
#define av_log(a,...)
Definition:
tableprint_vlc.h:28
avio_wl64
void avio_wl64(AVIOContext *s, uint64_t val)
Definition:
aviobuf.c:404
AV_LOG_ERROR
#define AV_LOG_ERROR
Something went wrong and cannot losslessly be recovered.
Definition:
log.h:176
AVERROR
#define AVERROR(e)
Definition:
error.h:43
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:175
AVStream::codec
AVCodecContext * codec
Codec context associated with this stream.
Definition:
avformat.h:861
AVFormatContext::nb_streams
unsigned int nb_streams
Number of elements in AVFormatContext.streams.
Definition:
avformat.h:1328
intreadwrite.h
AVCodecContext::width
int width
picture width / height.
Definition:
avcodec.h:1414
AVOutputFormat::name
const char * name
Definition:
avformat.h:513
AV_CODEC_ID_VP8
Definition:
avcodec.h:248
AVCodecContext::height
int height
Definition:
avcodec.h:1414
AVCodecContext::codec_type
enum AVMediaType codec_type
Definition:
avcodec.h:1249
AVCodecContext::codec_id
enum AVCodecID codec_id
Definition:
avcodec.h:1258
AVFormatContext::pb
AVIOContext * pb
I/O context.
Definition:
avformat.h:1314
AVCodecContext
main external API structure.
Definition:
avcodec.h:1241
AVCodecContext::codec_tag
unsigned int codec_tag
fourcc (LSB first, so "ABCD" -> ('D'<<24) + ('C'<<16) + ('B'<<8) + 'A').
Definition:
avcodec.h:1273
AVStream::duration
int64_t duration
Decoding: duration of the stream, in stream time base.
Definition:
avformat.h:901
avformat.h
Main libavformat public API header.
AVOutputFormat
Definition:
avformat.h:512
AVRational::den
int den
denominator
Definition:
rational.h:45
AVMEDIA_TYPE_VIDEO
Definition:
avutil.h:194
AVStream::time_base
AVRational time_base
This is the fundamental unit of time (in seconds) in terms of which frame timestamps are represented...
Definition:
avformat.h:884
AV_RL32
uint64_t_TMPL AV_WL64 unsigned int_TMPL AV_RL32
Definition:
bytestream.h:85
AVPacket
This structure stores compressed data.
Definition:
avcodec.h:1139
AVPacket::pts
int64_t pts
Presentation timestamp in AVStream->time_base units; the time at which the decompressed packet will b...
Definition:
avcodec.h:1155
Generated on Wed Jun 10 2015 01:56:57 for FFmpeg by
1.8.6