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
a4d126dc
Commit
a4d126dc
authored
Mar 23, 2016
by
Anton Khirnov
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
svq3: eliminate remaining H264Context usage.
parent
7bbdae81
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
33 additions
and
56 deletions
+33
-56
svq3.c
libavcodec/svq3.c
+33
-56
No files found.
libavcodec/svq3.c
View file @
a4d126dc
...
@@ -47,8 +47,6 @@
...
@@ -47,8 +47,6 @@
#include "avcodec.h"
#include "avcodec.h"
#include "mpegutils.h"
#include "mpegutils.h"
#include "h264.h"
#include "h264.h"
#include "h264_mvpred.h"
#include "h264data.h"
#include "golomb.h"
#include "golomb.h"
#include "hpeldsp.h"
#include "hpeldsp.h"
#include "mathops.h"
#include "mathops.h"
...
@@ -67,7 +65,7 @@
...
@@ -67,7 +65,7 @@
*/
*/
typedef
struct
SVQ3Context
{
typedef
struct
SVQ3Context
{
H264Context
h
;
AVCodecContext
*
avctx
;
H264DSPContext
h264dsp
;
H264DSPContext
h264dsp
;
H264PredContext
hpc
;
H264PredContext
hpc
;
...
@@ -100,6 +98,7 @@ typedef struct SVQ3Context {
...
@@ -100,6 +98,7 @@ typedef struct SVQ3Context {
int
prev_frame_num
;
int
prev_frame_num
;
enum
AVPictureType
pict_type
;
enum
AVPictureType
pict_type
;
int
low_delay
;
int
mb_x
,
mb_y
;
int
mb_x
,
mb_y
;
int
mb_xy
;
int
mb_xy
;
...
@@ -410,7 +409,6 @@ static inline void svq3_mc_dir_part(SVQ3Context *s,
...
@@ -410,7 +409,6 @@ static inline void svq3_mc_dir_part(SVQ3Context *s,
int
mx
,
int
my
,
int
dxy
,
int
mx
,
int
my
,
int
dxy
,
int
thirdpel
,
int
dir
,
int
avg
)
int
thirdpel
,
int
dir
,
int
avg
)
{
{
H264Context
*
h
=
&
s
->
h
;
const
H264Picture
*
pic
=
(
dir
==
0
)
?
s
->
last_pic
:
s
->
next_pic
;
const
H264Picture
*
pic
=
(
dir
==
0
)
?
s
->
last_pic
:
s
->
next_pic
;
uint8_t
*
src
,
*
dest
;
uint8_t
*
src
,
*
dest
;
int
i
,
emu
=
0
;
int
i
,
emu
=
0
;
...
@@ -448,7 +446,7 @@ static inline void svq3_mc_dir_part(SVQ3Context *s,
...
@@ -448,7 +446,7 @@ static inline void svq3_mc_dir_part(SVQ3Context *s,
:
s
->
hdsp
.
put_pixels_tab
)[
blocksize
][
dxy
](
dest
,
src
,
linesize
,
:
s
->
hdsp
.
put_pixels_tab
)[
blocksize
][
dxy
](
dest
,
src
,
linesize
,
height
);
height
);
if
(
!
(
h
->
flags
&
AV_CODEC_FLAG_GRAY
))
{
if
(
!
(
s
->
avctx
->
flags
&
AV_CODEC_FLAG_GRAY
))
{
mx
=
mx
+
(
mx
<
(
int
)
x
)
>>
1
;
mx
=
mx
+
(
mx
<
(
int
)
x
)
>>
1
;
my
=
my
+
(
my
<
(
int
)
y
)
>>
1
;
my
=
my
+
(
my
<
(
int
)
y
)
>>
1
;
width
=
width
>>
1
;
width
=
width
>>
1
;
...
@@ -485,7 +483,6 @@ static inline int svq3_mc_dir(SVQ3Context *s, int size, int mode,
...
@@ -485,7 +483,6 @@ static inline int svq3_mc_dir(SVQ3Context *s, int size, int mode,
int
dir
,
int
avg
)
int
dir
,
int
avg
)
{
{
int
i
,
j
,
k
,
mx
,
my
,
dx
,
dy
,
x
,
y
;
int
i
,
j
,
k
,
mx
,
my
,
dx
,
dy
,
x
,
y
;
H264Context
*
h
=
&
s
->
h
;
const
int
part_width
=
((
size
&
5
)
==
4
)
?
4
:
16
>>
(
size
&
1
);
const
int
part_width
=
((
size
&
5
)
==
4
)
?
4
:
16
>>
(
size
&
1
);
const
int
part_height
=
16
>>
((
unsigned
)(
size
+
1
)
/
3
);
const
int
part_height
=
16
>>
((
unsigned
)(
size
+
1
)
/
3
);
const
int
extra_width
=
(
mode
==
PREDICT_MODE
)
?
-
16
*
6
:
0
;
const
int
extra_width
=
(
mode
==
PREDICT_MODE
)
?
-
16
*
6
:
0
;
...
@@ -533,7 +530,7 @@ static inline int svq3_mc_dir(SVQ3Context *s, int size, int mode,
...
@@ -533,7 +530,7 @@ static inline int svq3_mc_dir(SVQ3Context *s, int size, int mode,
dx
=
svq3_get_se_golomb
(
&
s
->
gb_slice
);
dx
=
svq3_get_se_golomb
(
&
s
->
gb_slice
);
if
(
dx
==
INVALID_VLC
||
dy
==
INVALID_VLC
)
{
if
(
dx
==
INVALID_VLC
||
dy
==
INVALID_VLC
)
{
av_log
(
h
->
avctx
,
AV_LOG_ERROR
,
"invalid MV vlc
\n
"
);
av_log
(
s
->
avctx
,
AV_LOG_ERROR
,
"invalid MV vlc
\n
"
);
return
-
1
;
return
-
1
;
}
}
}
}
...
@@ -616,7 +613,6 @@ static av_always_inline int dctcoef_get(int16_t *mb, int index)
...
@@ -616,7 +613,6 @@ static av_always_inline int dctcoef_get(int16_t *mb, int index)
}
}
static
av_always_inline
void
hl_decode_mb_predict_luma
(
SVQ3Context
*
s
,
static
av_always_inline
void
hl_decode_mb_predict_luma
(
SVQ3Context
*
s
,
const
H264Context
*
h
,
int
mb_type
,
int
mb_type
,
const
int
*
block_offset
,
const
int
*
block_offset
,
int
linesize
,
int
linesize
,
...
@@ -655,7 +651,7 @@ static av_always_inline void hl_decode_mb_predict_luma(SVQ3Context *s,
...
@@ -655,7 +651,7 @@ static av_always_inline void hl_decode_mb_predict_luma(SVQ3Context *s,
}
}
}
}
static
void
hl_decode_mb
(
SVQ3Context
*
s
,
const
H264Context
*
h
)
static
void
hl_decode_mb
(
SVQ3Context
*
s
)
{
{
const
int
mb_x
=
s
->
mb_x
;
const
int
mb_x
=
s
->
mb_x
;
const
int
mb_y
=
s
->
mb_y
;
const
int
mb_y
=
s
->
mb_y
;
...
@@ -665,7 +661,7 @@ static void hl_decode_mb(SVQ3Context *s, const H264Context *h)
...
@@ -665,7 +661,7 @@ static void hl_decode_mb(SVQ3Context *s, const H264Context *h)
int
linesize
,
uvlinesize
;
int
linesize
,
uvlinesize
;
int
i
,
j
;
int
i
,
j
;
const
int
*
block_offset
=
&
s
->
block_offset
[
0
];
const
int
*
block_offset
=
&
s
->
block_offset
[
0
];
const
int
block_h
=
16
>>
h
->
chroma_y_shift
;
const
int
block_h
=
16
>>
1
;
linesize
=
s
->
cur_pic
->
f
->
linesize
[
0
];
linesize
=
s
->
cur_pic
->
f
->
linesize
[
0
];
uvlinesize
=
s
->
cur_pic
->
f
->
linesize
[
1
];
uvlinesize
=
s
->
cur_pic
->
f
->
linesize
[
1
];
...
@@ -681,7 +677,7 @@ static void hl_decode_mb(SVQ3Context *s, const H264Context *h)
...
@@ -681,7 +677,7 @@ static void hl_decode_mb(SVQ3Context *s, const H264Context *h)
s
->
hpc
.
pred8x8
[
s
->
chroma_pred_mode
](
dest_cb
,
uvlinesize
);
s
->
hpc
.
pred8x8
[
s
->
chroma_pred_mode
](
dest_cb
,
uvlinesize
);
s
->
hpc
.
pred8x8
[
s
->
chroma_pred_mode
](
dest_cr
,
uvlinesize
);
s
->
hpc
.
pred8x8
[
s
->
chroma_pred_mode
](
dest_cr
,
uvlinesize
);
hl_decode_mb_predict_luma
(
s
,
h
,
mb_type
,
block_offset
,
linesize
,
dest_y
);
hl_decode_mb_predict_luma
(
s
,
mb_type
,
block_offset
,
linesize
,
dest_y
);
}
}
hl_decode_mb_idct_luma
(
s
,
mb_type
,
block_offset
,
linesize
,
dest_y
);
hl_decode_mb_idct_luma
(
s
,
mb_type
,
block_offset
,
linesize
,
dest_y
);
...
@@ -705,7 +701,6 @@ static void hl_decode_mb(SVQ3Context *s, const H264Context *h)
...
@@ -705,7 +701,6 @@ static void hl_decode_mb(SVQ3Context *s, const H264Context *h)
static
int
svq3_decode_mb
(
SVQ3Context
*
s
,
unsigned
int
mb_type
)
static
int
svq3_decode_mb
(
SVQ3Context
*
s
,
unsigned
int
mb_type
)
{
{
H264Context
*
h
=
&
s
->
h
;
int
i
,
j
,
k
,
m
,
dir
,
mode
;
int
i
,
j
,
k
,
m
,
dir
,
mode
;
int
cbp
=
0
;
int
cbp
=
0
;
uint32_t
vlc
;
uint32_t
vlc
;
...
@@ -846,7 +841,7 @@ static int svq3_decode_mb(SVQ3Context *s, unsigned int mb_type)
...
@@ -846,7 +841,7 @@ static int svq3_decode_mb(SVQ3Context *s, unsigned int mb_type)
vlc
=
svq3_get_ue_golomb
(
&
s
->
gb_slice
);
vlc
=
svq3_get_ue_golomb
(
&
s
->
gb_slice
);
if
(
vlc
>=
25
)
{
if
(
vlc
>=
25
)
{
av_log
(
h
->
avctx
,
AV_LOG_ERROR
,
av_log
(
s
->
avctx
,
AV_LOG_ERROR
,
"luma prediction:%"
PRIu32
"
\n
"
,
vlc
);
"luma prediction:%"
PRIu32
"
\n
"
,
vlc
);
return
-
1
;
return
-
1
;
}
}
...
@@ -858,7 +853,7 @@ static int svq3_decode_mb(SVQ3Context *s, unsigned int mb_type)
...
@@ -858,7 +853,7 @@ static int svq3_decode_mb(SVQ3Context *s, unsigned int mb_type)
left
[
2
]
=
svq3_pred_1
[
top
[
1
]
+
1
][
left
[
1
]
+
1
][
svq3_pred_0
[
vlc
][
1
]];
left
[
2
]
=
svq3_pred_1
[
top
[
1
]
+
1
][
left
[
1
]
+
1
][
svq3_pred_0
[
vlc
][
1
]];
if
(
left
[
1
]
==
-
1
||
left
[
2
]
==
-
1
)
{
if
(
left
[
1
]
==
-
1
||
left
[
2
]
==
-
1
)
{
av_log
(
h
->
avctx
,
AV_LOG_ERROR
,
"weird prediction
\n
"
);
av_log
(
s
->
avctx
,
AV_LOG_ERROR
,
"weird prediction
\n
"
);
return
-
1
;
return
-
1
;
}
}
}
}
...
@@ -874,7 +869,7 @@ static int svq3_decode_mb(SVQ3Context *s, unsigned int mb_type)
...
@@ -874,7 +869,7 @@ static int svq3_decode_mb(SVQ3Context *s, unsigned int mb_type)
if
(
mb_type
==
8
)
{
if
(
mb_type
==
8
)
{
ff_h264_check_intra4x4_pred_mode
(
s
->
intra4x4_pred_mode_cache
,
ff_h264_check_intra4x4_pred_mode
(
s
->
intra4x4_pred_mode_cache
,
h
->
avctx
,
s
->
top_samples_available
,
s
->
avctx
,
s
->
top_samples_available
,
s
->
left_samples_available
);
s
->
left_samples_available
);
s
->
top_samples_available
=
(
s
->
mb_y
==
0
)
?
0x33FF
:
0xFFFF
;
s
->
top_samples_available
=
(
s
->
mb_y
==
0
)
?
0x33FF
:
0xFFFF
;
...
@@ -892,9 +887,9 @@ static int svq3_decode_mb(SVQ3Context *s, unsigned int mb_type)
...
@@ -892,9 +887,9 @@ static int svq3_decode_mb(SVQ3Context *s, unsigned int mb_type)
dir
=
ff_h264_i_mb_type_info
[
mb_type
-
8
].
pred_mode
;
dir
=
ff_h264_i_mb_type_info
[
mb_type
-
8
].
pred_mode
;
dir
=
(
dir
>>
1
)
^
3
*
(
dir
&
1
)
^
1
;
dir
=
(
dir
>>
1
)
^
3
*
(
dir
&
1
)
^
1
;
if
((
s
->
intra16x16_pred_mode
=
ff_h264_check_intra_pred_mode
(
h
->
avctx
,
s
->
top_samples_available
,
if
((
s
->
intra16x16_pred_mode
=
ff_h264_check_intra_pred_mode
(
s
->
avctx
,
s
->
top_samples_available
,
s
->
left_samples_available
,
dir
,
0
))
<
0
)
{
s
->
left_samples_available
,
dir
,
0
))
<
0
)
{
av_log
(
h
->
avctx
,
AV_LOG_ERROR
,
"ff_h264_check_intra_pred_mode < 0
\n
"
);
av_log
(
s
->
avctx
,
AV_LOG_ERROR
,
"ff_h264_check_intra_pred_mode < 0
\n
"
);
return
s
->
intra16x16_pred_mode
;
return
s
->
intra16x16_pred_mode
;
}
}
...
@@ -922,7 +917,7 @@ static int svq3_decode_mb(SVQ3Context *s, unsigned int mb_type)
...
@@ -922,7 +917,7 @@ static int svq3_decode_mb(SVQ3Context *s, unsigned int mb_type)
if
(
!
IS_INTRA16x16
(
mb_type
)
&&
if
(
!
IS_INTRA16x16
(
mb_type
)
&&
(
!
IS_SKIP
(
mb_type
)
||
s
->
pict_type
==
AV_PICTURE_TYPE_B
))
{
(
!
IS_SKIP
(
mb_type
)
||
s
->
pict_type
==
AV_PICTURE_TYPE_B
))
{
if
((
vlc
=
svq3_get_ue_golomb
(
&
s
->
gb_slice
))
>=
48
)
{
if
((
vlc
=
svq3_get_ue_golomb
(
&
s
->
gb_slice
))
>=
48
)
{
av_log
(
h
->
avctx
,
AV_LOG_ERROR
,
"cbp_vlc=%"
PRIu32
"
\n
"
,
vlc
);
av_log
(
s
->
avctx
,
AV_LOG_ERROR
,
"cbp_vlc=%"
PRIu32
"
\n
"
,
vlc
);
return
-
1
;
return
-
1
;
}
}
...
@@ -934,7 +929,7 @@ static int svq3_decode_mb(SVQ3Context *s, unsigned int mb_type)
...
@@ -934,7 +929,7 @@ static int svq3_decode_mb(SVQ3Context *s, unsigned int mb_type)
s
->
qscale
+=
svq3_get_se_golomb
(
&
s
->
gb_slice
);
s
->
qscale
+=
svq3_get_se_golomb
(
&
s
->
gb_slice
);
if
(
s
->
qscale
>
31u
)
{
if
(
s
->
qscale
>
31u
)
{
av_log
(
h
->
avctx
,
AV_LOG_ERROR
,
"qscale:%d
\n
"
,
s
->
qscale
);
av_log
(
s
->
avctx
,
AV_LOG_ERROR
,
"qscale:%d
\n
"
,
s
->
qscale
);
return
-
1
;
return
-
1
;
}
}
}
}
...
@@ -942,7 +937,7 @@ static int svq3_decode_mb(SVQ3Context *s, unsigned int mb_type)
...
@@ -942,7 +937,7 @@ static int svq3_decode_mb(SVQ3Context *s, unsigned int mb_type)
AV_ZERO128
(
s
->
mb_luma_dc
[
0
]
+
0
);
AV_ZERO128
(
s
->
mb_luma_dc
[
0
]
+
0
);
AV_ZERO128
(
s
->
mb_luma_dc
[
0
]
+
8
);
AV_ZERO128
(
s
->
mb_luma_dc
[
0
]
+
8
);
if
(
svq3_decode_block
(
&
s
->
gb_slice
,
s
->
mb_luma_dc
[
0
],
0
,
1
))
{
if
(
svq3_decode_block
(
&
s
->
gb_slice
,
s
->
mb_luma_dc
[
0
],
0
,
1
))
{
av_log
(
h
->
avctx
,
AV_LOG_ERROR
,
av_log
(
s
->
avctx
,
AV_LOG_ERROR
,
"error while decoding intra luma dc
\n
"
);
"error while decoding intra luma dc
\n
"
);
return
-
1
;
return
-
1
;
}
}
...
@@ -961,7 +956,7 @@ static int svq3_decode_mb(SVQ3Context *s, unsigned int mb_type)
...
@@ -961,7 +956,7 @@ static int svq3_decode_mb(SVQ3Context *s, unsigned int mb_type)
s
->
non_zero_count_cache
[
scan8
[
k
]]
=
1
;
s
->
non_zero_count_cache
[
scan8
[
k
]]
=
1
;
if
(
svq3_decode_block
(
&
s
->
gb_slice
,
&
s
->
mb
[
16
*
k
],
index
,
type
))
{
if
(
svq3_decode_block
(
&
s
->
gb_slice
,
&
s
->
mb
[
16
*
k
],
index
,
type
))
{
av_log
(
h
->
avctx
,
AV_LOG_ERROR
,
av_log
(
s
->
avctx
,
AV_LOG_ERROR
,
"error while decoding block
\n
"
);
"error while decoding block
\n
"
);
return
-
1
;
return
-
1
;
}
}
...
@@ -971,7 +966,7 @@ static int svq3_decode_mb(SVQ3Context *s, unsigned int mb_type)
...
@@ -971,7 +966,7 @@ static int svq3_decode_mb(SVQ3Context *s, unsigned int mb_type)
if
((
cbp
&
0x30
))
{
if
((
cbp
&
0x30
))
{
for
(
i
=
1
;
i
<
3
;
++
i
)
for
(
i
=
1
;
i
<
3
;
++
i
)
if
(
svq3_decode_block
(
&
s
->
gb_slice
,
&
s
->
mb
[
16
*
16
*
i
],
0
,
3
))
{
if
(
svq3_decode_block
(
&
s
->
gb_slice
,
&
s
->
mb
[
16
*
16
*
i
],
0
,
3
))
{
av_log
(
h
->
avctx
,
AV_LOG_ERROR
,
av_log
(
s
->
avctx
,
AV_LOG_ERROR
,
"error while decoding chroma dc block
\n
"
);
"error while decoding chroma dc block
\n
"
);
return
-
1
;
return
-
1
;
}
}
...
@@ -983,7 +978,7 @@ static int svq3_decode_mb(SVQ3Context *s, unsigned int mb_type)
...
@@ -983,7 +978,7 @@ static int svq3_decode_mb(SVQ3Context *s, unsigned int mb_type)
s
->
non_zero_count_cache
[
scan8
[
k
]]
=
1
;
s
->
non_zero_count_cache
[
scan8
[
k
]]
=
1
;
if
(
svq3_decode_block
(
&
s
->
gb_slice
,
&
s
->
mb
[
16
*
k
],
1
,
1
))
{
if
(
svq3_decode_block
(
&
s
->
gb_slice
,
&
s
->
mb
[
16
*
k
],
1
,
1
))
{
av_log
(
h
->
avctx
,
AV_LOG_ERROR
,
av_log
(
s
->
avctx
,
AV_LOG_ERROR
,
"error while decoding chroma ac block
\n
"
);
"error while decoding chroma ac block
\n
"
);
return
-
1
;
return
-
1
;
}
}
...
@@ -997,7 +992,7 @@ static int svq3_decode_mb(SVQ3Context *s, unsigned int mb_type)
...
@@ -997,7 +992,7 @@ static int svq3_decode_mb(SVQ3Context *s, unsigned int mb_type)
s
->
cur_pic
->
mb_type
[
mb_xy
]
=
mb_type
;
s
->
cur_pic
->
mb_type
[
mb_xy
]
=
mb_type
;
if
(
IS_INTRA
(
mb_type
))
if
(
IS_INTRA
(
mb_type
))
s
->
chroma_pred_mode
=
ff_h264_check_intra_pred_mode
(
h
->
avctx
,
s
->
top_samples_available
,
s
->
chroma_pred_mode
=
ff_h264_check_intra_pred_mode
(
s
->
avctx
,
s
->
top_samples_available
,
s
->
left_samples_available
,
DC_PRED8x8
,
1
);
s
->
left_samples_available
,
DC_PRED8x8
,
1
);
return
0
;
return
0
;
...
@@ -1006,7 +1001,6 @@ static int svq3_decode_mb(SVQ3Context *s, unsigned int mb_type)
...
@@ -1006,7 +1001,6 @@ static int svq3_decode_mb(SVQ3Context *s, unsigned int mb_type)
static
int
svq3_decode_slice_header
(
AVCodecContext
*
avctx
)
static
int
svq3_decode_slice_header
(
AVCodecContext
*
avctx
)
{
{
SVQ3Context
*
s
=
avctx
->
priv_data
;
SVQ3Context
*
s
=
avctx
->
priv_data
;
H264Context
*
h
=
&
s
->
h
;
const
int
mb_xy
=
s
->
mb_xy
;
const
int
mb_xy
=
s
->
mb_xy
;
int
i
,
header
;
int
i
,
header
;
unsigned
slice_id
;
unsigned
slice_id
;
...
@@ -1051,7 +1045,7 @@ static int svq3_decode_slice_header(AVCodecContext *avctx)
...
@@ -1051,7 +1045,7 @@ static int svq3_decode_slice_header(AVCodecContext *avctx)
}
}
if
((
slice_id
=
svq3_get_ue_golomb
(
&
s
->
gb_slice
))
>=
3
)
{
if
((
slice_id
=
svq3_get_ue_golomb
(
&
s
->
gb_slice
))
>=
3
)
{
av_log
(
h
->
avctx
,
AV_LOG_ERROR
,
"illegal slice type %u
\n
"
,
slice_id
);
av_log
(
s
->
avctx
,
AV_LOG_ERROR
,
"illegal slice type %u
\n
"
,
slice_id
);
return
-
1
;
return
-
1
;
}
}
...
@@ -1115,7 +1109,6 @@ static void init_dequant4_coeff_table(SVQ3Context *s)
...
@@ -1115,7 +1109,6 @@ static void init_dequant4_coeff_table(SVQ3Context *s)
static
av_cold
int
svq3_decode_init
(
AVCodecContext
*
avctx
)
static
av_cold
int
svq3_decode_init
(
AVCodecContext
*
avctx
)
{
{
SVQ3Context
*
s
=
avctx
->
priv_data
;
SVQ3Context
*
s
=
avctx
->
priv_data
;
H264Context
*
h
=
&
s
->
h
;
int
m
,
x
,
y
;
int
m
,
x
,
y
;
unsigned
char
*
extradata
;
unsigned
char
*
extradata
;
unsigned
char
*
extradata_end
;
unsigned
char
*
extradata_end
;
...
@@ -1138,29 +1131,17 @@ static av_cold int svq3_decode_init(AVCodecContext *avctx)
...
@@ -1138,29 +1131,17 @@ static av_cold int svq3_decode_init(AVCodecContext *avctx)
if
(
!
s
->
cur_pic
->
f
||
!
s
->
last_pic
->
f
||
!
s
->
next_pic
->
f
)
if
(
!
s
->
cur_pic
->
f
||
!
s
->
last_pic
->
f
||
!
s
->
next_pic
->
f
)
return
AVERROR
(
ENOMEM
);
return
AVERROR
(
ENOMEM
);
if
(
ff_h264_decode_init
(
avctx
)
<
0
)
return
-
1
;
// we will overwrite it later during decoding
av_frame_free
(
&
h
->
cur_pic
.
f
);
ff_h264dsp_init
(
&
s
->
h264dsp
,
8
,
1
);
ff_h264dsp_init
(
&
s
->
h264dsp
,
8
,
1
);
ff_h264_pred_init
(
&
s
->
hpc
,
AV_CODEC_ID_SVQ3
,
8
,
1
);
ff_h264_pred_init
(
&
s
->
hpc
,
AV_CODEC_ID_SVQ3
,
8
,
1
);
ff_videodsp_init
(
&
s
->
vdsp
,
8
);
ff_videodsp_init
(
&
s
->
vdsp
,
8
);
h
->
sps
.
bit_depth_luma
=
8
;
h
->
chroma_format_idc
=
1
;
ff_hpeldsp_init
(
&
s
->
hdsp
,
avctx
->
flags
);
ff_hpeldsp_init
(
&
s
->
hdsp
,
avctx
->
flags
);
ff_tpeldsp_init
(
&
s
->
tdsp
);
ff_tpeldsp_init
(
&
s
->
tdsp
);
h
->
flags
=
avctx
->
flags
;
h
->
picture_structure
=
PICT_FRAME
;
avctx
->
pix_fmt
=
AV_PIX_FMT_YUVJ420P
;
avctx
->
pix_fmt
=
AV_PIX_FMT_YUVJ420P
;
avctx
->
color_range
=
AVCOL_RANGE_JPEG
;
avctx
->
color_range
=
AVCOL_RANGE_JPEG
;
h
->
chroma_x_shift
=
h
->
chroma_y_shift
=
1
;
s
->
avctx
=
avctx
;
s
->
halfpel_flag
=
1
;
s
->
halfpel_flag
=
1
;
s
->
thirdpel_flag
=
1
;
s
->
thirdpel_flag
=
1
;
s
->
unknown_flag
=
0
;
s
->
unknown_flag
=
0
;
...
@@ -1234,7 +1215,7 @@ static av_cold int svq3_decode_init(AVCodecContext *avctx)
...
@@ -1234,7 +1215,7 @@ static av_cold int svq3_decode_init(AVCodecContext *avctx)
skip_bits1
(
&
gb
);
skip_bits1
(
&
gb
);
skip_bits1
(
&
gb
);
skip_bits1
(
&
gb
);
h
->
low_delay
=
get_bits1
(
&
gb
);
s
->
low_delay
=
get_bits1
(
&
gb
);
/* unknown field */
/* unknown field */
skip_bits1
(
&
gb
);
skip_bits1
(
&
gb
);
...
@@ -1243,7 +1224,7 @@ static av_cold int svq3_decode_init(AVCodecContext *avctx)
...
@@ -1243,7 +1224,7 @@ static av_cold int svq3_decode_init(AVCodecContext *avctx)
skip_bits
(
&
gb
,
8
);
skip_bits
(
&
gb
,
8
);
s
->
unknown_flag
=
get_bits1
(
&
gb
);
s
->
unknown_flag
=
get_bits1
(
&
gb
);
avctx
->
has_b_frames
=
!
h
->
low_delay
;
avctx
->
has_b_frames
=
!
s
->
low_delay
;
if
(
s
->
unknown_flag
)
{
if
(
s
->
unknown_flag
)
{
#if CONFIG_ZLIB
#if CONFIG_ZLIB
unsigned
watermark_width
=
svq3_get_ue_golomb
(
&
gb
);
unsigned
watermark_width
=
svq3_get_ue_golomb
(
&
gb
);
...
@@ -1381,13 +1362,12 @@ static int svq3_decode_frame(AVCodecContext *avctx, void *data,
...
@@ -1381,13 +1362,12 @@ static int svq3_decode_frame(AVCodecContext *avctx, void *data,
{
{
const
uint8_t
*
buf
=
avpkt
->
data
;
const
uint8_t
*
buf
=
avpkt
->
data
;
SVQ3Context
*
s
=
avctx
->
priv_data
;
SVQ3Context
*
s
=
avctx
->
priv_data
;
H264Context
*
h
=
&
s
->
h
;
int
buf_size
=
avpkt
->
size
;
int
buf_size
=
avpkt
->
size
;
int
ret
,
m
,
i
;
int
ret
,
m
,
i
;
/* special case for last picture */
/* special case for last picture */
if
(
buf_size
==
0
)
{
if
(
buf_size
==
0
)
{
if
(
s
->
next_pic
->
f
->
data
[
0
]
&&
!
h
->
low_delay
&&
!
s
->
last_frame_output
)
{
if
(
s
->
next_pic
->
f
->
data
[
0
]
&&
!
s
->
low_delay
&&
!
s
->
last_frame_output
)
{
ret
=
av_frame_ref
(
data
,
s
->
next_pic
->
f
);
ret
=
av_frame_ref
(
data
,
s
->
next_pic
->
f
);
if
(
ret
<
0
)
if
(
ret
<
0
)
return
ret
;
return
ret
;
...
@@ -1457,7 +1437,7 @@ static int svq3_decode_frame(AVCodecContext *avctx, void *data,
...
@@ -1457,7 +1437,7 @@ static int svq3_decode_frame(AVCodecContext *avctx, void *data,
}
}
if
(
avctx
->
debug
&
FF_DEBUG_PICT_INFO
)
if
(
avctx
->
debug
&
FF_DEBUG_PICT_INFO
)
av_log
(
h
->
avctx
,
AV_LOG_DEBUG
,
av_log
(
s
->
avctx
,
AV_LOG_DEBUG
,
"%c hpel:%d, tpel:%d aqp:%d qp:%d, slice_num:%02X
\n
"
,
"%c hpel:%d, tpel:%d aqp:%d qp:%d, slice_num:%02X
\n
"
,
av_get_picture_type_char
(
s
->
pict_type
),
av_get_picture_type_char
(
s
->
pict_type
),
s
->
halfpel_flag
,
s
->
thirdpel_flag
,
s
->
halfpel_flag
,
s
->
thirdpel_flag
,
...
@@ -1482,7 +1462,7 @@ static int svq3_decode_frame(AVCodecContext *avctx, void *data,
...
@@ -1482,7 +1462,7 @@ static int svq3_decode_frame(AVCodecContext *avctx, void *data,
s
->
frame_num_offset
+=
256
;
s
->
frame_num_offset
+=
256
;
if
(
s
->
frame_num_offset
==
0
||
if
(
s
->
frame_num_offset
==
0
||
s
->
frame_num_offset
>=
s
->
prev_frame_num_offset
)
{
s
->
frame_num_offset
>=
s
->
prev_frame_num_offset
)
{
av_log
(
h
->
avctx
,
AV_LOG_ERROR
,
"error in B-frame picture id
\n
"
);
av_log
(
s
->
avctx
,
AV_LOG_ERROR
,
"error in B-frame picture id
\n
"
);
return
-
1
;
return
-
1
;
}
}
}
else
{
}
else
{
...
@@ -1527,26 +1507,26 @@ static int svq3_decode_frame(AVCodecContext *avctx, void *data,
...
@@ -1527,26 +1507,26 @@ static int svq3_decode_frame(AVCodecContext *avctx, void *data,
else
if
(
s
->
pict_type
==
AV_PICTURE_TYPE_B
&&
mb_type
>=
4
)
else
if
(
s
->
pict_type
==
AV_PICTURE_TYPE_B
&&
mb_type
>=
4
)
mb_type
+=
4
;
mb_type
+=
4
;
if
(
mb_type
>
33
||
svq3_decode_mb
(
s
,
mb_type
))
{
if
(
mb_type
>
33
||
svq3_decode_mb
(
s
,
mb_type
))
{
av_log
(
h
->
avctx
,
AV_LOG_ERROR
,
av_log
(
s
->
avctx
,
AV_LOG_ERROR
,
"error while decoding MB %d %d
\n
"
,
s
->
mb_x
,
s
->
mb_y
);
"error while decoding MB %d %d
\n
"
,
s
->
mb_x
,
s
->
mb_y
);
return
-
1
;
return
-
1
;
}
}
if
(
mb_type
!=
0
)
if
(
mb_type
!=
0
)
hl_decode_mb
(
s
,
h
);
hl_decode_mb
(
s
);
if
(
s
->
pict_type
!=
AV_PICTURE_TYPE_B
&&
!
h
->
low_delay
)
if
(
s
->
pict_type
!=
AV_PICTURE_TYPE_B
&&
!
s
->
low_delay
)
s
->
cur_pic
->
mb_type
[
s
->
mb_x
+
s
->
mb_y
*
s
->
mb_stride
]
=
s
->
cur_pic
->
mb_type
[
s
->
mb_x
+
s
->
mb_y
*
s
->
mb_stride
]
=
(
s
->
pict_type
==
AV_PICTURE_TYPE_P
&&
mb_type
<
8
)
?
(
mb_type
-
1
)
:
-
1
;
(
s
->
pict_type
==
AV_PICTURE_TYPE_P
&&
mb_type
<
8
)
?
(
mb_type
-
1
)
:
-
1
;
}
}
ff_draw_horiz_band
(
avctx
,
s
->
cur_pic
->
f
,
ff_draw_horiz_band
(
avctx
,
s
->
cur_pic
->
f
,
s
->
last_pic
->
f
->
data
[
0
]
?
s
->
last_pic
->
f
:
NULL
,
s
->
last_pic
->
f
->
data
[
0
]
?
s
->
last_pic
->
f
:
NULL
,
16
*
s
->
mb_y
,
16
,
h
->
picture_structure
,
0
,
16
*
s
->
mb_y
,
16
,
PICT_FRAME
,
0
,
h
->
low_delay
);
s
->
low_delay
);
}
}
if
(
s
->
pict_type
==
AV_PICTURE_TYPE_B
||
h
->
low_delay
)
if
(
s
->
pict_type
==
AV_PICTURE_TYPE_B
||
s
->
low_delay
)
ret
=
av_frame_ref
(
data
,
s
->
cur_pic
->
f
);
ret
=
av_frame_ref
(
data
,
s
->
cur_pic
->
f
);
else
if
(
s
->
last_pic
->
f
->
data
[
0
])
else
if
(
s
->
last_pic
->
f
->
data
[
0
])
ret
=
av_frame_ref
(
data
,
s
->
last_pic
->
f
);
ret
=
av_frame_ref
(
data
,
s
->
last_pic
->
f
);
...
@@ -1554,7 +1534,7 @@ static int svq3_decode_frame(AVCodecContext *avctx, void *data,
...
@@ -1554,7 +1534,7 @@ static int svq3_decode_frame(AVCodecContext *avctx, void *data,
return
ret
;
return
ret
;
/* Do not output the last pic after seeking. */
/* Do not output the last pic after seeking. */
if
(
s
->
last_pic
->
f
->
data
[
0
]
||
h
->
low_delay
)
if
(
s
->
last_pic
->
f
->
data
[
0
]
||
s
->
low_delay
)
*
got_frame
=
1
;
*
got_frame
=
1
;
if
(
s
->
pict_type
!=
AV_PICTURE_TYPE_B
)
{
if
(
s
->
pict_type
!=
AV_PICTURE_TYPE_B
)
{
...
@@ -1569,7 +1549,6 @@ static int svq3_decode_frame(AVCodecContext *avctx, void *data,
...
@@ -1569,7 +1549,6 @@ static int svq3_decode_frame(AVCodecContext *avctx, void *data,
static
av_cold
int
svq3_decode_end
(
AVCodecContext
*
avctx
)
static
av_cold
int
svq3_decode_end
(
AVCodecContext
*
avctx
)
{
{
SVQ3Context
*
s
=
avctx
->
priv_data
;
SVQ3Context
*
s
=
avctx
->
priv_data
;
H264Context
*
h
=
&
s
->
h
;
free_picture
(
avctx
,
s
->
cur_pic
);
free_picture
(
avctx
,
s
->
cur_pic
);
free_picture
(
avctx
,
s
->
next_pic
);
free_picture
(
avctx
,
s
->
next_pic
);
...
@@ -1585,8 +1564,6 @@ static av_cold int svq3_decode_end(AVCodecContext *avctx)
...
@@ -1585,8 +1564,6 @@ static av_cold int svq3_decode_end(AVCodecContext *avctx)
av_freep
(
&
s
->
edge_emu_buffer
);
av_freep
(
&
s
->
edge_emu_buffer
);
av_freep
(
&
s
->
mb2br_xy
);
av_freep
(
&
s
->
mb2br_xy
);
ff_h264_free_context
(
h
);
return
0
;
return
0
;
}
}
...
...
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