Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Contribute to GitLab
Sign in / Register
Toggle navigation
F
ffmpeg.wasm-core
Project
Project
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
Linshizhi
ffmpeg.wasm-core
Commits
68b94c35
Commit
68b94c35
authored
Nov 30, 2003
by
Michael Niedermayer
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
rv20 decoder
Originally committed as revision 2543 to
svn://svn.ffmpeg.org/ffmpeg/trunk
parent
3e8a5124
Show whitespace changes
Inline
Side-by-side
Showing
7 changed files
with
169 additions
and
29 deletions
+169
-29
allcodecs.c
libavcodec/allcodecs.c
+1
-0
avcodec.h
libavcodec/avcodec.h
+3
-0
h263.c
libavcodec/h263.c
+34
-17
h263data.h
libavcodec/h263data.h
+22
-1
h263dec.c
libavcodec/h263dec.c
+1
-0
mpegvideo.h
libavcodec/mpegvideo.h
+5
-0
rv10.c
libavcodec/rv10.c
+103
-11
No files found.
libavcodec/allcodecs.c
View file @
68b94c35
...
...
@@ -90,6 +90,7 @@ void avcodec_register_all(void)
register_avcodec
(
&
h263i_decoder
);
register_avcodec
(
&
flv_decoder
);
register_avcodec
(
&
rv10_decoder
);
register_avcodec
(
&
rv20_decoder
);
register_avcodec
(
&
svq1_decoder
);
register_avcodec
(
&
svq3_decoder
);
register_avcodec
(
&
wmav1_decoder
);
...
...
libavcodec/avcodec.h
View file @
68b94c35
...
...
@@ -33,6 +33,7 @@ enum CodecID {
CODEC_ID_MPEG2VIDEO_XVMC
,
CODEC_ID_H263
,
CODEC_ID_RV10
,
CODEC_ID_RV20
,
CODEC_ID_MP2
,
CODEC_ID_MP3
,
/* prefered ID for MPEG Audio layer 1, 2 or3 decoding */
CODEC_ID_VORBIS
,
...
...
@@ -1502,6 +1503,7 @@ extern AVCodec h263_encoder;
extern
AVCodec
h263p_encoder
;
extern
AVCodec
flv_encoder
;
extern
AVCodec
rv10_encoder
;
extern
AVCodec
rv20_encoder
;
extern
AVCodec
mjpeg_encoder
;
extern
AVCodec
ljpeg_encoder
;
extern
AVCodec
mpeg4_encoder
;
...
...
@@ -1532,6 +1534,7 @@ extern AVCodec mpeg_xvmc_decoder;
extern
AVCodec
h263i_decoder
;
extern
AVCodec
flv_decoder
;
extern
AVCodec
rv10_decoder
;
extern
AVCodec
rv20_decoder
;
extern
AVCodec
svq1_decoder
;
extern
AVCodec
svq3_decoder
;
extern
AVCodec
dvvideo_decoder
;
...
...
libavcodec/h263.c
View file @
68b94c35
...
...
@@ -185,7 +185,7 @@ void ff_flv_encode_picture_header(MpegEncContext * s, int picture_number)
if
(
s
->
h263_aic
){
s
->
y_dc_scale_table
=
s
->
c_dc_scale_table
=
h263
_aic_dc_scale_table
;
s
->
c_dc_scale_table
=
ff
_aic_dc_scale_table
;
}
else
{
s
->
y_dc_scale_table
=
s
->
c_dc_scale_table
=
ff_mpeg1_dc_scale_table
;
...
...
@@ -288,7 +288,7 @@ void h263_encode_picture_header(MpegEncContext * s, int picture_number)
if
(
s
->
h263_aic
){
s
->
y_dc_scale_table
=
s
->
c_dc_scale_table
=
h263
_aic_dc_scale_table
;
s
->
c_dc_scale_table
=
ff
_aic_dc_scale_table
;
}
else
{
s
->
y_dc_scale_table
=
s
->
c_dc_scale_table
=
ff_mpeg1_dc_scale_table
;
...
...
@@ -1139,11 +1139,12 @@ void h263_encode_mb(MpegEncContext * s,
}
}
else
{
int
li
=
s
->
h263_aic
?
0
:
1
;
assert
(
s
->
mb_intra
);
cbp
=
0
;
for
(
i
=
0
;
i
<
6
;
i
++
)
{
/* Predict DC */
if
(
s
->
h263_aic
&&
s
->
mb_intra
)
{
if
(
s
->
h263_aic
)
{
int16_t
level
=
block
[
i
][
0
];
pred_dc
=
h263_pred_dc
(
s
,
i
,
&
dc_ptr
[
i
]);
...
...
@@ -1286,7 +1287,7 @@ static void h263_pred_acdc(MpegEncContext * s, DCTELEM *block, int n)
/* find prediction */
if
(
n
<
4
)
{
x
=
2
*
s
->
mb_x
+
1
+
(
n
&
1
);
y
=
2
*
s
->
mb_y
+
1
+
(
(
n
&
2
)
>>
1
);
y
=
2
*
s
->
mb_y
+
1
+
(
n
>>
1
);
wrap
=
s
->
mb_width
*
2
+
2
;
dc_val
=
s
->
dc_val
[
0
];
ac_val
=
s
->
ac_val
[
0
][
0
];
...
...
@@ -1310,10 +1311,13 @@ static void h263_pred_acdc(MpegEncContext * s, DCTELEM *block, int n)
c
=
dc_val
[(
x
)
+
(
y
-
1
)
*
wrap
];
/* No prediction outside GOB boundary */
if
(
s
->
first_slice_line
&&
((
n
<
2
)
||
(
n
>
3
)))
c
=
1024
;
pred_dc
=
1024
;
if
(
s
->
first_slice_line
&&
n
!=
3
){
if
(
n
!=
2
)
c
=
1024
;
if
(
n
!=
1
&&
s
->
mb_x
==
s
->
resync_mb_x
)
a
=
1024
;
}
if
(
s
->
ac_pred
)
{
pred_dc
=
1024
;
if
(
s
->
h263_aic_dir
)
{
/* left prediction */
if
(
a
!=
1024
)
{
...
...
@@ -1348,8 +1352,8 @@ static void h263_pred_acdc(MpegEncContext * s, DCTELEM *block, int n)
if
(
block
[
0
]
<
0
)
block
[
0
]
=
0
;
else
if
(
!
(
block
[
0
]
&
1
))
block
[
0
]
++
;
else
block
[
0
]
|=
1
;
/* Update AC/DC tables */
dc_val
[(
x
)
+
(
y
)
*
wrap
]
=
block
[
0
];
...
...
@@ -3517,7 +3521,14 @@ int ff_h263_decode_mb(MpegEncContext *s,
cbp
=
(
cbpc
&
3
)
|
(
cbpy
<<
2
);
if
(
dquant
)
{
change_qscale
(
s
,
quant_tab
[
get_bits
(
&
s
->
gb
,
2
)]);
if
(
s
->
modified_quant
){
if
(
get_bits1
(
&
s
->
gb
))
s
->
qscale
=
modified_quant_tab
[
get_bits1
(
&
s
->
gb
)][
s
->
qscale
];
else
s
->
qscale
=
get_bits
(
&
s
->
gb
,
5
);
}
else
s
->
qscale
+=
quant_tab
[
get_bits
(
&
s
->
gb
,
2
)];
change_qscale
(
s
,
0
);
}
if
((
!
s
->
progressive_sequence
)
&&
(
cbp
||
(
s
->
workaround_bugs
&
FF_BUG_XVID_ILACE
)))
s
->
interlaced_dct
=
get_bits1
(
&
s
->
gb
);
...
...
@@ -3772,7 +3783,14 @@ intra:
}
cbp
=
(
cbpc
&
3
)
|
(
cbpy
<<
2
);
if
(
dquant
)
{
change_qscale
(
s
,
quant_tab
[
get_bits
(
&
s
->
gb
,
2
)]);
if
(
s
->
modified_quant
){
if
(
get_bits1
(
&
s
->
gb
))
s
->
qscale
=
modified_quant_tab
[
get_bits1
(
&
s
->
gb
)][
s
->
qscale
];
else
s
->
qscale
=
get_bits
(
&
s
->
gb
,
5
);
}
else
s
->
qscale
+=
quant_tab
[
get_bits
(
&
s
->
gb
,
2
)];
change_qscale
(
s
,
0
);
}
if
(
!
s
->
progressive_sequence
)
...
...
@@ -4459,9 +4477,7 @@ int h263_decode_picture_header(MpegEncContext *s)
av_log
(
s
->
avctx
,
AV_LOG_ERROR
,
"Independent Segment Decoding not supported
\n
"
);
}
s
->
alt_inter_vlc
=
get_bits1
(
&
s
->
gb
);
if
(
get_bits1
(
&
s
->
gb
)
!=
0
)
{
av_log
(
s
->
avctx
,
AV_LOG_ERROR
,
"Modified Quantization not supported
\n
"
);
}
s
->
modified_quant
=
get_bits1
(
&
s
->
gb
);
skip_bits
(
&
s
->
gb
,
1
);
/* Prevent start code emulation */
...
...
@@ -4532,14 +4548,14 @@ int h263_decode_picture_header(MpegEncContext *s)
if
(
s
->
h263_aic
){
s
->
y_dc_scale_table
=
s
->
c_dc_scale_table
=
h263
_aic_dc_scale_table
;
s
->
c_dc_scale_table
=
ff
_aic_dc_scale_table
;
}
else
{
s
->
y_dc_scale_table
=
s
->
c_dc_scale_table
=
ff_mpeg1_dc_scale_table
;
}
if
(
s
->
avctx
->
debug
&
FF_DEBUG_PICT_INFO
){
av_log
(
s
->
avctx
,
AV_LOG_DEBUG
,
"qp:%d %c size:%d rnd:%d%s%s%s%s%s%s
\n
"
,
av_log
(
s
->
avctx
,
AV_LOG_DEBUG
,
"qp:%d %c size:%d rnd:%d%s%s%s%s%s%s
%s
\n
"
,
s
->
qscale
,
av_get_pict_type_char
(
s
->
pict_type
),
s
->
gb
.
size_in_bits
,
1
-
s
->
no_rounding
,
s
->
obmc
?
" AP"
:
""
,
...
...
@@ -4547,7 +4563,8 @@ int h263_decode_picture_header(MpegEncContext *s)
s
->
h263_long_vectors
?
" LONG"
:
""
,
s
->
h263_plus
?
" +"
:
""
,
s
->
h263_aic
?
" AIC"
:
""
,
s
->
alt_inter_vlc
?
" AIV"
:
""
s
->
alt_inter_vlc
?
" AIV"
:
""
,
s
->
modified_quant
?
" MQ"
:
""
);
}
#if 1
...
...
libavcodec/h263data.h
View file @
68b94c35
...
...
@@ -208,8 +208,29 @@ static const uint16_t h263_format[8][2] = {
{
1408
,
1152
},
};
static
uint8_t
h263
_aic_dc_scale_table
[
32
]
=
{
uint8_t
ff
_aic_dc_scale_table
[
32
]
=
{
// 0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31
0
,
2
,
4
,
6
,
8
,
10
,
12
,
14
,
16
,
18
,
20
,
22
,
24
,
26
,
28
,
30
,
32
,
34
,
36
,
38
,
40
,
42
,
44
,
46
,
48
,
50
,
52
,
54
,
56
,
58
,
60
,
62
};
static
const
uint8_t
modified_quant_tab
[
2
][
32
]
=
{
// 0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31
{
0
,
3
,
1
,
2
,
3
,
4
,
5
,
6
,
7
,
8
,
9
,
9
,
10
,
11
,
12
,
13
,
14
,
15
,
16
,
17
,
18
,
18
,
19
,
20
,
21
,
22
,
23
,
24
,
25
,
26
,
27
,
28
},{
0
,
2
,
3
,
4
,
5
,
6
,
7
,
8
,
9
,
10
,
11
,
13
,
14
,
15
,
16
,
17
,
18
,
19
,
20
,
21
,
22
,
24
,
25
,
26
,
27
,
28
,
29
,
30
,
31
,
31
,
31
,
26
}
};
static
const
uint8_t
chroma_qscale_tab
[
32
]
=
{
// 0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31
0
,
1
,
2
,
3
,
4
,
5
,
6
,
6
,
7
,
8
,
9
,
9
,
10
,
10
,
11
,
11
,
12
,
12
,
12
,
13
,
13
,
13
,
14
,
14
,
14
,
14
,
14
,
15
,
15
,
15
,
15
,
15
};
const
uint16_t
ff_mba_max
[
6
]
=
{
47
,
98
,
395
,
1583
,
6335
,
9215
};
const
uint8_t
ff_mba_length
[
6
]
=
{
6
,
7
,
9
,
11
,
13
,
14
};
libavcodec/h263dec.c
View file @
68b94c35
...
...
@@ -52,6 +52,7 @@ int ff_h263_decode_init(AVCodecContext *avctx)
switch
(
avctx
->
codec
->
id
)
{
case
CODEC_ID_H263
:
s
->
gob_number
=
0
;
s
->
unrestricted_mv
=
0
;
break
;
case
CODEC_ID_MPEG4
:
s
->
time_increment_bits
=
4
;
/* default value for broken headers */
...
...
libavcodec/mpegvideo.h
View file @
68b94c35
...
...
@@ -526,6 +526,7 @@ typedef struct MpegEncContext {
int
h263_aic
;
///< Advanded INTRA Coding (AIC)
int
h263_aic_dir
;
///< AIC direction: 0 = left, 1 = top
int
alt_inter_vlc
;
///< alternative inter vlc
int
modified_quant
;
/* mpeg4 specific */
int
time_increment_resolution
;
...
...
@@ -814,8 +815,12 @@ static inline int get_rl_index(const RLTable *rl, int last, int run, int level)
extern
uint8_t
ff_mpeg4_y_dc_scale_table
[
32
];
extern
uint8_t
ff_mpeg4_c_dc_scale_table
[
32
];
extern
uint8_t
ff_aic_dc_scale_table
[
32
];
extern
const
int16_t
ff_mpeg4_default_intra_matrix
[
64
];
extern
const
int16_t
ff_mpeg4_default_non_intra_matrix
[
64
];
extern
const
uint16_t
ff_mba_max
[
6
];
extern
const
uint8_t
ff_mba_length
[
6
];
int
ff_h263_decode_init
(
AVCodecContext
*
avctx
);
int
ff_h263_decode_frame
(
AVCodecContext
*
avctx
,
void
*
data
,
int
*
data_size
,
...
...
libavcodec/rv10.c
View file @
68b94c35
...
...
@@ -337,6 +337,55 @@ static int rv10_decode_picture_header(MpegEncContext *s)
return
mb_count
;
}
static
int
rv20_decode_picture_header
(
MpegEncContext
*
s
)
{
int
pb_frame
,
seq
,
mb_pos
;
int
i
;
if
(
get_bits
(
&
s
->
gb
,
1
))
s
->
pict_type
=
P_TYPE
;
else
s
->
pict_type
=
I_TYPE
;
pb_frame
=
get_bits
(
&
s
->
gb
,
2
);
if
(
pb_frame
){
av_log
(
s
->
avctx
,
AV_LOG_ERROR
,
"pb frame not supported
\n
"
);
return
-
1
;
}
s
->
qscale
=
get_bits
(
&
s
->
gb
,
5
);
if
(
s
->
qscale
==
0
){
av_log
(
s
->
avctx
,
AV_LOG_ERROR
,
"error, qscale:0
\n
"
);
return
-
1
;
}
seq
=
get_bits
(
&
s
->
gb
,
8
);
for
(
i
=
0
;
i
<
6
;
i
++
){
if
(
s
->
mb_width
*
s
->
mb_height
<
ff_mba_max
[
i
])
break
;
}
mb_pos
=
get_bits
(
&
s
->
gb
,
ff_mba_length
[
i
]);
s
->
mb_x
=
mb_pos
%
s
->
mb_width
;
s
->
mb_y
=
mb_pos
/
s
->
mb_width
;
s
->
no_rounding
=
get_bits1
(
&
s
->
gb
);
s
->
f_code
=
1
;
s
->
unrestricted_mv
=
1
;
s
->
h263_aic
=
s
->
pict_type
==
I_TYPE
;
// s->alt_inter_vlc=1;
// s->obmc=1;
// s->umvplus=1;
// s->modified_quant=1;
if
(
s
->
avctx
->
debug
&
FF_DEBUG_PICT_INFO
){
av_log
(
s
->
avctx
,
AV_LOG_INFO
,
"num:%3d x:%2d y:%2d type:%d qscale:%2d rnd:%d
\n
"
,
seq
,
s
->
mb_x
,
s
->
mb_y
,
s
->
pict_type
,
s
->
qscale
,
s
->
no_rounding
);
}
return
s
->
mb_width
*
s
->
mb_height
-
mb_pos
;
}
static
int
rv10_decode_init
(
AVCodecContext
*
avctx
)
{
MpegEncContext
*
s
=
avctx
->
priv_data
;
...
...
@@ -348,20 +397,26 @@ static int rv10_decode_init(AVCodecContext *avctx)
s
->
width
=
avctx
->
width
;
s
->
height
=
avctx
->
height
;
s
->
h263_rv10
=
1
;
switch
(
avctx
->
sub_id
){
case
0x10000000
:
s
->
rv10_version
=
0
;
s
->
h263_long_vectors
=
0
;
s
->
h263_rv10
=
1
;
break
;
case
0x10003000
:
s
->
rv10_version
=
3
;
s
->
h263_long_vectors
=
1
;
s
->
h263_rv10
=
1
;
break
;
case
0x10003001
:
s
->
rv10_version
=
3
;
s
->
h263_long_vectors
=
0
;
s
->
h263_rv10
=
1
;
break
;
case
0x20001000
:
case
0x20100001
:
case
0x20200002
:
case
0x20101001
:
//added
default:
av_log
(
s
->
avctx
,
AV_LOG_ERROR
,
"unknown header %X
\n
"
,
avctx
->
sub_id
);
}
...
...
@@ -373,8 +428,6 @@ static int rv10_decode_init(AVCodecContext *avctx)
h263_decode_init_vlc
(
s
);
s
->
y_dc_scale_table
=
s
->
c_dc_scale_table
=
ff_mpeg1_dc_scale_table
;
s
->
progressive_sequence
=
1
;
/* init rv vlc */
...
...
@@ -408,8 +461,16 @@ static int rv10_decode_packet(AVCodecContext *avctx,
int
i
,
mb_count
,
mb_pos
,
left
;
init_get_bits
(
&
s
->
gb
,
buf
,
buf_size
*
8
);
#if 0
for(i=0; i<buf_size*8 && i<100; i++)
printf("%d", get_bits1(&s->gb));
printf("\n");
return 0;
#endif
if
(
s
->
codec_id
==
CODEC_ID_RV10
)
mb_count
=
rv10_decode_picture_header
(
s
);
else
mb_count
=
rv20_decode_picture_header
(
s
);
if
(
mb_count
<
0
)
{
av_log
(
s
->
avctx
,
AV_LOG_ERROR
,
"HEADER ERROR
\n
"
);
return
-
1
;
...
...
@@ -426,6 +487,7 @@ static int rv10_decode_packet(AVCodecContext *avctx,
av_log
(
s
->
avctx
,
AV_LOG_ERROR
,
"COUNT ERROR
\n
"
);
return
-
1
;
}
//if(s->pict_type == P_TYPE) return 0;
if
(
s
->
mb_x
==
0
&&
s
->
mb_y
==
0
)
{
if
(
MPV_frame_start
(
s
,
avctx
)
<
0
)
...
...
@@ -437,14 +499,27 @@ static int rv10_decode_packet(AVCodecContext *avctx,
#endif
/* default quantization values */
s
->
y_dc_scale
=
8
;
s
->
c_dc_scale
=
8
;
if
(
s
->
codec_id
==
CODEC_ID_RV10
){
if
(
s
->
mb_y
==
0
)
s
->
first_slice_line
=
1
;
}
else
{
s
->
first_slice_line
=
1
;
s
->
resync_mb_x
=
s
->
mb_x
;
s
->
resync_mb_y
=
s
->
mb_y
;
}
if
(
s
->
h263_aic
){
s
->
y_dc_scale_table
=
s
->
c_dc_scale_table
=
ff_aic_dc_scale_table
;
}
else
{
s
->
y_dc_scale_table
=
s
->
c_dc_scale_table
=
ff_mpeg1_dc_scale_table
;
}
s
->
y_dc_scale
=
s
->
y_dc_scale_table
[
s
->
qscale
];
s
->
c_dc_scale
=
s
->
c_dc_scale_table
[
s
->
qscale
];
s
->
rv10_first_dc_coded
[
0
]
=
0
;
s
->
rv10_first_dc_coded
[
1
]
=
0
;
s
->
rv10_first_dc_coded
[
2
]
=
0
;
if
(
s
->
mb_y
==
0
)
s
->
first_slice_line
=
1
;
s
->
block_wrap
[
0
]
=
s
->
block_wrap
[
1
]
=
s
->
block_wrap
[
2
]
=
...
...
@@ -454,6 +529,7 @@ static int rv10_decode_packet(AVCodecContext *avctx,
ff_init_block_index
(
s
);
/* decode each macroblock */
for
(
i
=
0
;
i
<
mb_count
;
i
++
)
{
int
ret
;
ff_update_block_index
(
s
);
#ifdef DEBUG
printf
(
"**mb x=%d y=%d
\n
"
,
s
->
mb_x
,
s
->
mb_y
);
...
...
@@ -462,7 +538,9 @@ static int rv10_decode_packet(AVCodecContext *avctx,
s
->
dsp
.
clear_blocks
(
s
->
block
[
0
]);
s
->
mv_dir
=
MV_DIR_FORWARD
;
s
->
mv_type
=
MV_TYPE_16X16
;
if
(
ff_h263_decode_mb
(
s
,
s
->
block
)
==
SLICE_ERROR
)
{
ret
=
ff_h263_decode_mb
(
s
,
s
->
block
);
if
(
ret
==
SLICE_ERROR
)
{
av_log
(
s
->
avctx
,
AV_LOG_ERROR
,
"ERROR at MB %d %d
\n
"
,
s
->
mb_x
,
s
->
mb_y
);
return
-
1
;
}
...
...
@@ -472,8 +550,10 @@ static int rv10_decode_packet(AVCodecContext *avctx,
s
->
mb_x
=
0
;
s
->
mb_y
++
;
ff_init_block_index
(
s
);
s
->
first_slice_line
=
0
;
}
if
(
s
->
mb_x
==
s
->
resync_mb_x
)
s
->
first_slice_line
=
0
;
if
(
ret
==
SLICE_END
)
break
;
}
return
buf_size
;
...
...
@@ -539,3 +619,15 @@ AVCodec rv10_decoder = {
rv10_decode_frame
,
CODEC_CAP_DR1
};
AVCodec
rv20_decoder
=
{
"rv20"
,
CODEC_TYPE_VIDEO
,
CODEC_ID_RV20
,
sizeof
(
MpegEncContext
),
rv10_decode_init
,
NULL
,
rv10_decode_end
,
rv10_decode_frame
,
CODEC_CAP_DR1
};
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment