Skip to content
Projects
Groups
Snippets
Help
Loading...
Sign in / Register
Toggle navigation
F
ffmpeg
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
Packages
Packages
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
submodule
ffmpeg
Commits
c5e01d91
Commit
c5e01d91
authored
Apr 10, 2016
by
Alexandra Hájková
Committed by
Anton Khirnov
Nov 18, 2016
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
hq_hqa: Convert to the new bitstream reader
Signed-off-by:
Anton Khirnov
<
anton@khirnov.net
>
parent
b2c56301
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
24 additions
and
24 deletions
+24
-24
hq_hqa.c
libavcodec/hq_hqa.c
+24
-24
No files found.
libavcodec/hq_hqa.c
View file @
c5e01d91
...
@@ -24,8 +24,8 @@
...
@@ -24,8 +24,8 @@
#include "libavutil/intreadwrite.h"
#include "libavutil/intreadwrite.h"
#include "avcodec.h"
#include "avcodec.h"
#include "bitstream.h"
#include "canopus.h"
#include "canopus.h"
#include "get_bits.h"
#include "internal.h"
#include "internal.h"
#include "hq_hqa.h"
#include "hq_hqa.h"
...
@@ -59,7 +59,7 @@ static inline void put_blocks(HQContext *c, AVFrame *pic,
...
@@ -59,7 +59,7 @@ static inline void put_blocks(HQContext *c, AVFrame *pic,
pic
->
linesize
[
plane
]
<<
ilace
,
block1
);
pic
->
linesize
[
plane
]
<<
ilace
,
block1
);
}
}
static
int
hq_decode_block
(
HQContext
*
c
,
GetBitContext
*
gb
,
int16_t
block
[
64
],
static
int
hq_decode_block
(
HQContext
*
c
,
BitstreamContext
*
bc
,
int16_t
block
[
64
],
int
qsel
,
int
is_chroma
,
int
is_hqa
)
int
qsel
,
int
is_chroma
,
int
is_hqa
)
{
{
const
int32_t
*
q
;
const
int32_t
*
q
;
...
@@ -68,15 +68,15 @@ static int hq_decode_block(HQContext *c, GetBitContext *gb, int16_t block[64],
...
@@ -68,15 +68,15 @@ static int hq_decode_block(HQContext *c, GetBitContext *gb, int16_t block[64],
memset
(
block
,
0
,
64
*
sizeof
(
*
block
));
memset
(
block
,
0
,
64
*
sizeof
(
*
block
));
if
(
!
is_hqa
)
{
if
(
!
is_hqa
)
{
block
[
0
]
=
get_sbits
(
gb
,
9
)
<<
6
;
block
[
0
]
=
bitstream_read_signed
(
bc
,
9
)
<<
6
;
q
=
ff_hq_quants
[
qsel
][
is_chroma
][
get_bits
(
gb
,
2
)];
q
=
ff_hq_quants
[
qsel
][
is_chroma
][
bitstream_read
(
bc
,
2
)];
}
else
{
}
else
{
q
=
ff_hq_quants
[
qsel
][
is_chroma
][
get_bits
(
gb
,
2
)];
q
=
ff_hq_quants
[
qsel
][
is_chroma
][
bitstream_read
(
bc
,
2
)];
block
[
0
]
=
get_sbits
(
gb
,
9
)
<<
6
;
block
[
0
]
=
bitstream_read_signed
(
bc
,
9
)
<<
6
;
}
}
for
(;;)
{
for
(;;)
{
val
=
get_vlc2
(
gb
,
c
->
hq_ac_vlc
.
table
,
9
,
2
);
val
=
bitstream_read_vlc
(
bc
,
c
->
hq_ac_vlc
.
table
,
9
,
2
);
if
(
val
<
0
)
if
(
val
<
0
)
return
AVERROR_INVALIDDATA
;
return
AVERROR_INVALIDDATA
;
...
@@ -91,16 +91,16 @@ static int hq_decode_block(HQContext *c, GetBitContext *gb, int16_t block[64],
...
@@ -91,16 +91,16 @@ static int hq_decode_block(HQContext *c, GetBitContext *gb, int16_t block[64],
}
}
static
int
hq_decode_mb
(
HQContext
*
c
,
AVFrame
*
pic
,
static
int
hq_decode_mb
(
HQContext
*
c
,
AVFrame
*
pic
,
GetBitContext
*
gb
,
int
x
,
int
y
)
BitstreamContext
*
bc
,
int
x
,
int
y
)
{
{
int
qgroup
,
flag
;
int
qgroup
,
flag
;
int
i
,
ret
;
int
i
,
ret
;
qgroup
=
get_bits
(
gb
,
4
);
qgroup
=
bitstream_read
(
bc
,
4
);
flag
=
get_bits1
(
gb
);
flag
=
bitstream_read_bit
(
bc
);
for
(
i
=
0
;
i
<
8
;
i
++
)
{
for
(
i
=
0
;
i
<
8
;
i
++
)
{
ret
=
hq_decode_block
(
c
,
gb
,
c
->
block
[
i
],
qgroup
,
i
>=
4
,
0
);
ret
=
hq_decode_block
(
c
,
bc
,
c
->
block
[
i
],
qgroup
,
i
>=
4
,
0
);
if
(
ret
<
0
)
if
(
ret
<
0
)
return
ret
;
return
ret
;
}
}
...
@@ -117,7 +117,7 @@ static int hq_decode_frame(HQContext *ctx, AVFrame *pic,
...
@@ -117,7 +117,7 @@ static int hq_decode_frame(HQContext *ctx, AVFrame *pic,
int
prof_num
,
size_t
data_size
)
int
prof_num
,
size_t
data_size
)
{
{
const
HQProfile
*
profile
;
const
HQProfile
*
profile
;
GetBitContext
gb
;
BitstreamContext
bc
;
const
uint8_t
*
perm
,
*
src
=
ctx
->
gbc
.
buffer
;
const
uint8_t
*
perm
,
*
src
=
ctx
->
gbc
.
buffer
;
uint32_t
slice_off
[
21
];
uint32_t
slice_off
[
21
];
int
slice
,
start_off
,
next_off
,
i
,
ret
;
int
slice
,
start_off
,
next_off
,
i
,
ret
;
...
@@ -160,11 +160,11 @@ static int hq_decode_frame(HQContext *ctx, AVFrame *pic,
...
@@ -160,11 +160,11 @@ static int hq_decode_frame(HQContext *ctx, AVFrame *pic,
"Invalid slice size %zu.
\n
"
,
data_size
);
"Invalid slice size %zu.
\n
"
,
data_size
);
break
;
break
;
}
}
init_get_bits
(
&
gb
,
src
+
slice_off
[
slice
],
bitstream_init
(
&
bc
,
src
+
slice_off
[
slice
],
(
slice_off
[
slice
+
1
]
-
slice_off
[
slice
])
*
8
);
(
slice_off
[
slice
+
1
]
-
slice_off
[
slice
])
*
8
);
for
(
i
=
0
;
i
<
(
next_off
-
start_off
)
*
profile
->
tab_w
;
i
++
)
{
for
(
i
=
0
;
i
<
(
next_off
-
start_off
)
*
profile
->
tab_w
;
i
++
)
{
ret
=
hq_decode_mb
(
ctx
,
pic
,
&
gb
,
perm
[
0
]
*
16
,
perm
[
1
]
*
16
);
ret
=
hq_decode_mb
(
ctx
,
pic
,
&
bc
,
perm
[
0
]
*
16
,
perm
[
1
]
*
16
);
if
(
ret
<
0
)
{
if
(
ret
<
0
)
{
av_log
(
ctx
->
avctx
,
AV_LOG_ERROR
,
av_log
(
ctx
->
avctx
,
AV_LOG_ERROR
,
"Error decoding macroblock %d at slice %d.
\n
"
,
i
,
slice
);
"Error decoding macroblock %d at slice %d.
\n
"
,
i
,
slice
);
...
@@ -178,12 +178,12 @@ static int hq_decode_frame(HQContext *ctx, AVFrame *pic,
...
@@ -178,12 +178,12 @@ static int hq_decode_frame(HQContext *ctx, AVFrame *pic,
}
}
static
int
hqa_decode_mb
(
HQContext
*
c
,
AVFrame
*
pic
,
int
qgroup
,
static
int
hqa_decode_mb
(
HQContext
*
c
,
AVFrame
*
pic
,
int
qgroup
,
GetBitContext
*
gb
,
int
x
,
int
y
)
BitstreamContext
*
bc
,
int
x
,
int
y
)
{
{
int
flag
=
0
;
int
flag
=
0
;
int
i
,
ret
,
cbp
;
int
i
,
ret
,
cbp
;
cbp
=
get_vlc2
(
gb
,
c
->
hqa_cbp_vlc
.
table
,
5
,
1
);
cbp
=
bitstream_read_vlc
(
bc
,
c
->
hqa_cbp_vlc
.
table
,
5
,
1
);
for
(
i
=
0
;
i
<
12
;
i
++
)
for
(
i
=
0
;
i
<
12
;
i
++
)
memset
(
c
->
block
[
i
],
0
,
sizeof
(
*
c
->
block
));
memset
(
c
->
block
[
i
],
0
,
sizeof
(
*
c
->
block
));
...
@@ -191,7 +191,7 @@ static int hqa_decode_mb(HQContext *c, AVFrame *pic, int qgroup,
...
@@ -191,7 +191,7 @@ static int hqa_decode_mb(HQContext *c, AVFrame *pic, int qgroup,
c
->
block
[
i
][
0
]
=
-
128
*
(
1
<<
6
);
c
->
block
[
i
][
0
]
=
-
128
*
(
1
<<
6
);
if
(
cbp
)
{
if
(
cbp
)
{
flag
=
get_bits1
(
gb
);
flag
=
bitstream_read_bit
(
bc
);
cbp
|=
cbp
<<
4
;
cbp
|=
cbp
<<
4
;
if
(
cbp
&
0x3
)
if
(
cbp
&
0x3
)
...
@@ -201,7 +201,7 @@ static int hqa_decode_mb(HQContext *c, AVFrame *pic, int qgroup,
...
@@ -201,7 +201,7 @@ static int hqa_decode_mb(HQContext *c, AVFrame *pic, int qgroup,
for
(
i
=
0
;
i
<
12
;
i
++
)
{
for
(
i
=
0
;
i
<
12
;
i
++
)
{
if
(
!
(
cbp
&
(
1
<<
i
)))
if
(
!
(
cbp
&
(
1
<<
i
)))
continue
;
continue
;
ret
=
hq_decode_block
(
c
,
gb
,
c
->
block
[
i
],
qgroup
,
i
>=
8
,
1
);
ret
=
hq_decode_block
(
c
,
bc
,
c
->
block
[
i
],
qgroup
,
i
>=
8
,
1
);
if
(
ret
<
0
)
if
(
ret
<
0
)
return
ret
;
return
ret
;
}
}
...
@@ -217,7 +217,7 @@ static int hqa_decode_mb(HQContext *c, AVFrame *pic, int qgroup,
...
@@ -217,7 +217,7 @@ static int hqa_decode_mb(HQContext *c, AVFrame *pic, int qgroup,
return
0
;
return
0
;
}
}
static
int
hqa_decode_slice
(
HQContext
*
ctx
,
AVFrame
*
pic
,
GetBitContext
*
gb
,
static
int
hqa_decode_slice
(
HQContext
*
ctx
,
AVFrame
*
pic
,
BitstreamContext
*
bc
,
int
quant
,
int
slice_no
,
int
w
,
int
h
)
int
quant
,
int
slice_no
,
int
w
,
int
h
)
{
{
int
i
,
j
,
off
;
int
i
,
j
,
off
;
...
@@ -226,7 +226,7 @@ static int hqa_decode_slice(HQContext *ctx, AVFrame *pic, GetBitContext *gb,
...
@@ -226,7 +226,7 @@ static int hqa_decode_slice(HQContext *ctx, AVFrame *pic, GetBitContext *gb,
for
(
i
=
0
;
i
<
h
;
i
+=
16
)
{
for
(
i
=
0
;
i
<
h
;
i
+=
16
)
{
off
=
(
slice_no
*
16
+
i
*
3
)
&
0x70
;
off
=
(
slice_no
*
16
+
i
*
3
)
&
0x70
;
for
(
j
=
off
;
j
<
w
;
j
+=
128
)
{
for
(
j
=
off
;
j
<
w
;
j
+=
128
)
{
ret
=
hqa_decode_mb
(
ctx
,
pic
,
quant
,
gb
,
j
,
i
);
ret
=
hqa_decode_mb
(
ctx
,
pic
,
quant
,
bc
,
j
,
i
);
if
(
ret
<
0
)
{
if
(
ret
<
0
)
{
av_log
(
ctx
->
avctx
,
AV_LOG_ERROR
,
av_log
(
ctx
->
avctx
,
AV_LOG_ERROR
,
"Error decoding macroblock at %dx%d.
\n
"
,
i
,
j
);
"Error decoding macroblock at %dx%d.
\n
"
,
i
,
j
);
...
@@ -240,7 +240,7 @@ static int hqa_decode_slice(HQContext *ctx, AVFrame *pic, GetBitContext *gb,
...
@@ -240,7 +240,7 @@ static int hqa_decode_slice(HQContext *ctx, AVFrame *pic, GetBitContext *gb,
static
int
hqa_decode_frame
(
HQContext
*
ctx
,
AVFrame
*
pic
,
size_t
data_size
)
static
int
hqa_decode_frame
(
HQContext
*
ctx
,
AVFrame
*
pic
,
size_t
data_size
)
{
{
GetBitContext
gb
;
BitstreamContext
bc
;
const
int
num_slices
=
8
;
const
int
num_slices
=
8
;
uint32_t
slice_off
[
9
];
uint32_t
slice_off
[
9
];
int
i
,
slice
,
ret
;
int
i
,
slice
,
ret
;
...
@@ -285,10 +285,10 @@ static int hqa_decode_frame(HQContext *ctx, AVFrame *pic, size_t data_size)
...
@@ -285,10 +285,10 @@ static int hqa_decode_frame(HQContext *ctx, AVFrame *pic, size_t data_size)
"Invalid slice size %zu.
\n
"
,
data_size
);
"Invalid slice size %zu.
\n
"
,
data_size
);
break
;
break
;
}
}
init_get_bits
(
&
gb
,
src
+
slice_off
[
slice
],
bitstream_init
(
&
bc
,
src
+
slice_off
[
slice
],
(
slice_off
[
slice
+
1
]
-
slice_off
[
slice
])
*
8
);
(
slice_off
[
slice
+
1
]
-
slice_off
[
slice
])
*
8
);
ret
=
hqa_decode_slice
(
ctx
,
pic
,
&
gb
,
quant
,
slice
,
width
,
height
);
ret
=
hqa_decode_slice
(
ctx
,
pic
,
&
bc
,
quant
,
slice
,
width
,
height
);
if
(
ret
<
0
)
if
(
ret
<
0
)
return
ret
;
return
ret
;
}
}
...
...
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