Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
F
FFmpeg
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Container Registry
Model registry
Operate
Environments
Monitor
Incidents
Service Desk
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
libremedia
Tethys
FFmpeg
Commits
6fad5abc
Commit
6fad5abc
authored
8 years ago
by
Alexandra Hájková
Committed by
Diego Biurrun
8 years ago
Browse files
Options
Downloads
Patches
Plain Diff
lagarith: Convert to the new bitstream reader
parent
c3defda0
No related branches found
Branches containing commit
No related tags found
Tags containing commit
No related merge requests found
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
libavcodec/lagarith.c
+11
-11
11 additions, 11 deletions
libavcodec/lagarith.c
libavcodec/lagarithrac.c
+6
-6
6 additions, 6 deletions
libavcodec/lagarithrac.c
libavcodec/lagarithrac.h
+4
-2
4 additions, 2 deletions
libavcodec/lagarithrac.h
with
21 additions
and
19 deletions
libavcodec/lagarith.c
+
11
−
11
View file @
6fad5abc
...
...
@@ -28,7 +28,7 @@
#include
<inttypes.h>
#include
"avcodec.h"
#include
"
get_
bits.h"
#include
"bits
tream
.h"
#include
"mathops.h"
#include
"huffyuvdsp.h"
#include
"lagarithrac.h"
...
...
@@ -101,7 +101,7 @@ static uint8_t lag_calc_zero_run(int8_t x)
return
(
x
<<
1
)
^
(
x
>>
7
);
}
static
int
lag_decode_prob
(
Get
BitContext
*
g
b
,
uint32_t
*
value
)
static
int
lag_decode_prob
(
Bit
stream
Context
*
b
c
,
uint32_t
*
value
)
{
static
const
uint8_t
series
[]
=
{
1
,
2
,
3
,
5
,
8
,
13
,
21
};
int
i
;
...
...
@@ -114,7 +114,7 @@ static int lag_decode_prob(GetBitContext *gb, uint32_t *value)
if
(
prevbit
&&
bit
)
break
;
prevbit
=
bit
;
bit
=
get_bits1
(
gb
);
bit
=
bitstream_read_bit
(
bc
);
if
(
bit
&&
!
prevbit
)
bits
+=
series
[
i
];
}
...
...
@@ -127,7 +127,7 @@ static int lag_decode_prob(GetBitContext *gb, uint32_t *value)
return
0
;
}
val
=
get_bits_long
(
gb
,
bits
);
val
=
bitstream_read
(
bc
,
bits
);
val
|=
1
<<
bits
;
*
value
=
val
-
1
;
...
...
@@ -135,7 +135,7 @@ static int lag_decode_prob(GetBitContext *gb, uint32_t *value)
return
0
;
}
static
int
lag_read_prob_header
(
lag_rac
*
rac
,
Get
BitContext
*
g
b
)
static
int
lag_read_prob_header
(
lag_rac
*
rac
,
Bit
stream
Context
*
b
c
)
{
int
i
,
j
,
scale_factor
;
unsigned
prob
,
cumulative_target
;
...
...
@@ -146,7 +146,7 @@ static int lag_read_prob_header(lag_rac *rac, GetBitContext *gb)
rac
->
prob
[
257
]
=
UINT_MAX
;
/* Read probabilities from bitstream */
for
(
i
=
1
;
i
<
257
;
i
++
)
{
if
(
lag_decode_prob
(
g
b
,
&
rac
->
prob
[
i
])
<
0
)
{
if
(
lag_decode_prob
(
b
c
,
&
rac
->
prob
[
i
])
<
0
)
{
av_log
(
rac
->
avctx
,
AV_LOG_ERROR
,
"Invalid probability encountered.
\n
"
);
return
-
1
;
}
...
...
@@ -156,7 +156,7 @@ static int lag_read_prob_header(lag_rac *rac, GetBitContext *gb)
}
cumul_prob
+=
rac
->
prob
[
i
];
if
(
!
rac
->
prob
[
i
])
{
if
(
lag_decode_prob
(
g
b
,
&
prob
))
{
if
(
lag_decode_prob
(
b
c
,
&
prob
))
{
av_log
(
rac
->
avctx
,
AV_LOG_ERROR
,
"Invalid probability run encountered.
\n
"
);
return
-
1
;
}
...
...
@@ -422,7 +422,7 @@ static int lag_decode_arith_plane(LagarithContext *l, uint8_t *dst,
uint32_t
length
;
uint32_t
offset
=
1
;
int
esc_count
=
src
[
0
];
Get
BitContext
g
b
;
Bit
stream
Context
b
c
;
lag_rac
rac
;
const
uint8_t
*
src_end
=
src
+
src_size
;
...
...
@@ -436,12 +436,12 @@ static int lag_decode_arith_plane(LagarithContext *l, uint8_t *dst,
offset
+=
4
;
}
init_get_b
it
s
(
&
g
b
,
src
+
offset
,
src_size
*
8
);
bitstream_in
it
(
&
b
c
,
src
+
offset
,
src_size
*
8
);
if
(
lag_read_prob_header
(
&
rac
,
&
g
b
)
<
0
)
if
(
lag_read_prob_header
(
&
rac
,
&
b
c
)
<
0
)
return
-
1
;
ff_lag_rac_init
(
&
rac
,
&
g
b
,
length
-
stride
);
ff_lag_rac_init
(
&
rac
,
&
b
c
,
length
-
stride
);
for
(
i
=
0
;
i
<
height
;
i
++
)
read
+=
lag_decode_line
(
l
,
&
rac
,
dst
+
(
i
*
stride
),
width
,
...
...
This diff is collapsed.
Click to expand it.
libavcodec/lagarithrac.c
+
6
−
6
View file @
6fad5abc
...
...
@@ -27,20 +27,20 @@
* @author David Conrad
*/
#include
"
get_
bits.h"
#include
"bits
tream
.h"
#include
"lagarithrac.h"
void
ff_lag_rac_init
(
lag_rac
*
l
,
Get
BitContext
*
g
b
,
int
length
)
void
ff_lag_rac_init
(
lag_rac
*
l
,
Bit
stream
Context
*
b
c
,
int
length
)
{
int
i
,
j
,
left
;
/* According to reference decoder "1st byte is garbage",
* however, it gets skipped by the call to
align_get_bits
()
* however, it gets skipped by the call to
bitstream_align
()
*/
align_get_bits
(
gb
);
left
=
get
_bits_left
(
g
b
)
>>
3
;
bitstream_align
(
bc
);
left
=
bitstream
_bits_left
(
b
c
)
>>
3
;
l
->
bytestream_start
=
l
->
bytestream
=
g
b
->
buffer
+
get_bits_count
(
gb
)
/
8
;
l
->
bytestream
=
b
c
->
buffer
+
bitstream_tell
(
bc
)
/
8
;
l
->
bytestream_end
=
l
->
bytestream_start
+
FFMIN
(
length
,
left
);
l
->
range
=
0x80
;
...
...
This diff is collapsed.
Click to expand it.
libavcodec/lagarithrac.h
+
4
−
2
View file @
6fad5abc
...
...
@@ -31,10 +31,12 @@
#define AVCODEC_LAGARITHRAC_H
#include
<stdint.h>
#include
"libavutil/common.h"
#include
"libavutil/intreadwrite.h"
#include
"avcodec.h"
#include
"
get_
bits.h"
#include
"bits
tream
.h"
typedef
struct
lag_rac
{
AVCodecContext
*
avctx
;
...
...
@@ -51,7 +53,7 @@ typedef struct lag_rac {
uint8_t
range_hash
[
256
];
/**< Hash table mapping upper byte to approximate symbol. */
}
lag_rac
;
void
ff_lag_rac_init
(
lag_rac
*
l
,
Get
BitContext
*
g
b
,
int
length
);
void
ff_lag_rac_init
(
lag_rac
*
l
,
Bit
stream
Context
*
b
c
,
int
length
);
/* TODO: Optimize */
static
inline
void
lag_rac_refill
(
lag_rac
*
l
)
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment