FFmpeg
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 "
avcodec.h
"
28
#include "
libavutil/intreadwrite.h
"
29
30
typedef
struct
RV34ParseContext
{
31
int64_t
key_dts
;
32
int
key_pts
;
33
}
RV34ParseContext
;
34
35
static
const
int
rv_to_av_frame_type
[4] = {
36
AV_PICTURE_TYPE_I
,
AV_PICTURE_TYPE_I
,
AV_PICTURE_TYPE_P
,
AV_PICTURE_TYPE_B
,
37
};
38
39
static
int
rv34_parse
(
AVCodecParserContext
*
s
,
40
AVCodecContext
*avctx,
41
const
uint8_t **poutbuf,
int
*poutbuf_size,
42
const
uint8_t *buf,
int
buf_size)
43
{
44
RV34ParseContext
*pc =
s
->priv_data;
45
int
type
,
pts
, hdr;
46
47
if
(buf_size < 13 + *buf * 8) {
48
*poutbuf = buf;
49
*poutbuf_size = buf_size;
50
return
buf_size;
51
}
52
53
hdr =
AV_RB32
(buf + 9 + *buf * 8);
54
if
(avctx->
codec_id
==
AV_CODEC_ID_RV30
) {
55
type
= (hdr >> 27) & 3;
56
pts
= (hdr >> 7) & 0x1FFF;
57
}
else
{
58
type
= (hdr >> 29) & 3;
59
pts
= (hdr >> 6) & 0x1FFF;
60
}
61
62
if
(
type
!= 3 &&
s
->pts !=
AV_NOPTS_VALUE
) {
63
pc->
key_dts
=
s
->pts;
64
pc->
key_pts
=
pts
;
65
}
else
{
66
if
(
type
!= 3)
67
s
->pts = pc->
key_dts
+ ((
pts
- pc->
key_pts
) & 0x1FFF);
68
else
69
s
->pts = pc->
key_dts
- ((pc->
key_pts
-
pts
) & 0x1FFF);
70
}
71
s
->pict_type =
rv_to_av_frame_type
[
type
];
72
73
*poutbuf = buf;
74
*poutbuf_size = buf_size;
75
return
buf_size;
76
}
77
78
const
AVCodecParser
ff_rv34_parser
= {
79
.
codec_ids
= {
AV_CODEC_ID_RV30
,
AV_CODEC_ID_RV40
},
80
.priv_data_size =
sizeof
(
RV34ParseContext
),
81
.parser_parse =
rv34_parse
,
82
};
int64_t
long long int64_t
Definition:
coverity.c:34
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:39
rv_to_av_frame_type
static const int rv_to_av_frame_type[4]
Definition:
rv34_parser.c:35
RV34ParseContext::key_pts
int key_pts
Definition:
rv34_parser.c:32
type
it s the only field you need to keep assuming you have a context There is some magic you don t need to care about around this just let it vf type
Definition:
writing_filters.txt:86
pts
static int64_t pts
Definition:
transcode_aac.c:643
intreadwrite.h
s
#define s(width, name)
Definition:
cbs_vp9.c:198
AVCodecContext::codec_id
enum AVCodecID codec_id
Definition:
avcodec.h:455
AV_PICTURE_TYPE_I
@ AV_PICTURE_TYPE_I
Intra.
Definition:
avutil.h:279
AVCodecParser::codec_ids
int codec_ids[7]
Definition:
avcodec.h:2867
AV_NOPTS_VALUE
#define AV_NOPTS_VALUE
Undefined timestamp value.
Definition:
avutil.h:248
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:96
AV_CODEC_ID_RV30
@ AV_CODEC_ID_RV30
Definition:
codec_id.h:120
AV_CODEC_ID_RV40
@ AV_CODEC_ID_RV40
Definition:
codec_id.h:121
RV34ParseContext::key_dts
int64_t key_dts
Definition:
rv34_parser.c:31
ff_rv34_parser
const AVCodecParser ff_rv34_parser
Definition:
rv34_parser.c:78
avcodec.h
AVCodecParserContext
Definition:
avcodec.h:2707
AVCodecContext
main external API structure.
Definition:
avcodec.h:445
AV_PICTURE_TYPE_B
@ AV_PICTURE_TYPE_B
Bi-dir predicted.
Definition:
avutil.h:281
AV_PICTURE_TYPE_P
@ AV_PICTURE_TYPE_P
Predicted.
Definition:
avutil.h:280
AVCodecParser
Definition:
avcodec.h:2866
RV34ParseContext
Definition:
rv34_parser.c:30
Generated on Thu Sep 26 2024 23:15:18 for FFmpeg by
1.8.17