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
libavcodec
rv34_parser.c
Go to the documentation of this file.
1
/*
2
* RV30/40 parser
3
* Copyright (c) 2011 Konstantin Shishkov
4
*
5
* This file is part of FFmpeg.
6
*
7
* FFmpeg 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
* FFmpeg 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 FFmpeg; if not, write to the Free Software
19
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
20
*/
21
22
/**
23
* @file
24
* RV30/40 parser
25
*/
26
27
#include "
parser.h
"
28
#include "
libavutil/intreadwrite.h
"
29
30
typedef
struct
RV34ParseContext
{
31
ParseContext
pc
;
32
int64_t
key_dts
;
33
int
key_pts
;
34
}
RV34ParseContext
;
35
36
static
const
int
rv_to_av_frame_type
[4] = {
37
AV_PICTURE_TYPE_I
,
AV_PICTURE_TYPE_I
,
AV_PICTURE_TYPE_P
,
AV_PICTURE_TYPE_B
,
38
};
39
40
static
int
rv34_parse
(
AVCodecParserContext
*
s
,
41
AVCodecContext
*avctx,
42
const
uint8_t
**poutbuf,
int
*poutbuf_size,
43
const
uint8_t
*
buf
,
int
buf_size)
44
{
45
RV34ParseContext
*pc = s->
priv_data
;
46
int
type
,
pts
, hdr;
47
48
if
(buf_size < 13 + *buf * 8) {
49
*poutbuf =
buf
;
50
*poutbuf_size = buf_size;
51
return
buf_size;
52
}
53
54
hdr =
AV_RB32
(buf + 9 + *buf * 8);
55
if
(avctx->
codec_id
==
AV_CODEC_ID_RV30
) {
56
type = (hdr >> 27) & 3;
57
pts = (hdr >> 7) & 0x1FFF;
58
}
else
{
59
type = (hdr >> 29) & 3;
60
pts = (hdr >> 6) & 0x1FFF;
61
}
62
63
if
(type != 3 && s->
pts
!=
AV_NOPTS_VALUE
) {
64
pc->
key_dts
= s->
pts
;
65
pc->
key_pts
=
pts
;
66
}
else
{
67
if
(type != 3)
68
s->
pts
= pc->
key_dts
+ ((pts - pc->
key_pts
) & 0x1FFF);
69
else
70
s->
pts
= pc->
key_dts
- ((pc->
key_pts
-
pts
) & 0x1FFF);
71
}
72
s->
pict_type
=
rv_to_av_frame_type
[
type
];
73
74
*poutbuf =
buf
;
75
*poutbuf_size = buf_size;
76
return
buf_size;
77
}
78
79
#if CONFIG_RV30_PARSER
80
AVCodecParser
ff_rv30_parser
= {
81
.
codec_ids
= {
AV_CODEC_ID_RV30
},
82
.priv_data_size =
sizeof
(
RV34ParseContext
),
83
.parser_parse =
rv34_parse
,
84
};
85
#endif
86
87
#if CONFIG_RV40_PARSER
88
AVCodecParser
ff_rv40_parser
= {
89
.
codec_ids
= {
AV_CODEC_ID_RV40
},
90
.priv_data_size =
sizeof
(
RV34ParseContext
),
91
.parser_parse =
rv34_parse
,
92
};
93
#endif
s
const char * s
Definition:
avisynth_c.h:768
RV34ParseContext::key_dts
int64_t key_dts
Definition:
rv34_parser.c:32
ParseContext
Definition:
parser.h:28
rv_to_av_frame_type
static const int rv_to_av_frame_type[4]
Definition:
rv34_parser.c:36
AVCodecParser::codec_ids
int codec_ids[5]
Definition:
avcodec.h:5200
ff_rv40_parser
AVCodecParser ff_rv40_parser
uint8_t
uint8_t
Definition:
audio_convert.c:194
RV34ParseContext::pc
ParseContext pc
Definition:
rv34_parser.c:31
AV_RB32
uint64_t_TMPL AV_WL64 unsigned int_TMPL AV_WL32 unsigned int_TMPL AV_WL24 unsigned int_TMPL AV_WL16 uint64_t_TMPL AV_WB64 unsigned int_TMPL AV_RB32
Definition:
bytestream.h:87
parser.h
ff_rv30_parser
AVCodecParser ff_rv30_parser
AVCodecParserContext::pict_type
int pict_type
Definition:
avcodec.h:5040
RV34ParseContext::key_pts
int key_pts
Definition:
rv34_parser.c:33
AVCodecParserContext::priv_data
void * priv_data
Definition:
avcodec.h:5033
AVCodecParser
Definition:
avcodec.h:5199
AV_PICTURE_TYPE_I
Intra.
Definition:
avutil.h:274
rv34_parse
static int rv34_parse(AVCodecParserContext *s, AVCodecContext *avctx, const uint8_t **poutbuf, int *poutbuf_size, const uint8_t *buf, int buf_size)
Definition:
rv34_parser.c:40
intreadwrite.h
AVCodecParserContext
Definition:
avcodec.h:5032
AVCodecContext::codec_id
enum AVCodecID codec_id
Definition:
avcodec.h:1528
AVCodecContext
main external API structure.
Definition:
avcodec.h:1518
AV_CODEC_ID_RV30
Definition:
avcodec.h:286
buf
void * buf
Definition:
avisynth_c.h:690
type
GLint GLenum type
Definition:
opengl_enc.c:105
AV_CODEC_ID_RV40
Definition:
avcodec.h:287
pts
static int64_t pts
Definition:
transcode_aac.c:647
AV_PICTURE_TYPE_B
Bi-dir predicted.
Definition:
avutil.h:276
RV34ParseContext
Definition:
rv34_parser.c:30
AVCodecParserContext::pts
int64_t pts
Definition:
avcodec.h:5051
AV_NOPTS_VALUE
#define AV_NOPTS_VALUE
Undefined timestamp value.
Definition:
avutil.h:248
AV_PICTURE_TYPE_P
Predicted.
Definition:
avutil.h:275
Generated on Sun May 13 2018 02:03:55 for FFmpeg by
1.8.6