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
4579adb0
Commit
4579adb0
authored
Sep 08, 2004
by
Alex Beregszaszi
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
new signed golomb routines
Originally committed as revision 3444 to
svn://svn.ffmpeg.org/ffmpeg/trunk
parent
b2a1c771
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
68 additions
and
13 deletions
+68
-13
ffv1.c
libavcodec/ffv1.c
+2
-8
golomb.h
libavcodec/golomb.h
+66
-5
No files found.
libavcodec/ffv1.c
View file @
4579adb0
...
...
@@ -324,10 +324,8 @@ static inline void put_vlc_symbol(PutBitContext *pb, VlcState * const state, int
code
=
v
^
((
2
*
state
->
drift
+
state
->
count
)
>>
31
);
#endif
code
=
-
2
*
code
-
1
;
code
^=
(
code
>>
31
);
//printf("v:%d/%d bias:%d error:%d drift:%d count:%d k:%d\n", v, code, state->bias, state->error_sum, state->drift, state->count, k);
set_
ur_golomb
(
pb
,
code
,
k
,
12
,
bits
);
set_
sr_golomb_ffv1
(
pb
,
code
,
k
,
12
,
bits
);
update_vlc_state
(
state
,
v
);
}
...
...
@@ -344,13 +342,9 @@ static inline int get_vlc_symbol(GetBitContext *gb, VlcState * const state, int
assert
(
k
<=
8
);
v
=
get_
ur_golomb
(
gb
,
k
,
12
,
bits
);
v
=
get_
sr_golomb_ffv1
(
gb
,
k
,
12
,
bits
);
//printf("v:%d bias:%d error:%d drift:%d count:%d k:%d", v, state->bias, state->error_sum, state->drift, state->count, k);
v
++
;
if
(
v
&
1
)
v
=
(
v
>>
1
);
else
v
=
-
(
v
>>
1
);
#if 0 // JPEG LS
if(k==0 && 2*state->drift <= - state->count) v ^= (-1);
#else
...
...
libavcodec/golomb.h
View file @
4579adb0
/*
* exp golomb vlc stuff
* Copyright (c) 2003 Michael Niedermayer <michaelni@gmx.at>
* Copyright (c) 2004 Alex Beregszaszi
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
...
...
@@ -22,7 +23,7 @@
* @file golomb.h
* @brief
* exp golomb vlc stuff
* @author Michael Niedermayer <michaelni@gmx.at>
* @author Michael Niedermayer <michaelni@gmx.at>
and Alex Beregszaszi
*/
#define INVALID_VLC 0x80000000
...
...
@@ -260,13 +261,37 @@ static inline int get_ur_golomb_jpegls(GetBitContext *gb, int k, int limit, int
}
/**
* read unsigned golomb rice code (flac).
* read signed golomb rice code (ffv1).
*/
static
inline
int
get_sr_golomb_ffv1
(
GetBitContext
*
gb
,
int
k
,
int
limit
,
int
esc_len
){
int
v
=
get_ur_golomb
(
gb
,
k
,
limit
,
esc_len
);
v
++
;
if
(
v
&
1
)
return
v
>>
1
;
else
return
-
(
v
>>
1
);
// return (v>>1) ^ -(v&1);
}
/**
* read signed golomb rice code (flac).
*/
static
inline
int
get_sr_golomb_flac
(
GetBitContext
*
gb
,
int
k
,
int
limit
,
int
esc_len
){
int
v
=
get_ur_golomb_jpegls
(
gb
,
k
,
limit
,
esc_len
);
return
(
v
>>
1
)
^
-
(
v
&
1
);
}
/**
* read signed golomb rice code (sonic).
*/
static
inline
int
get_sr_golomb_sonic
(
GetBitContext
*
gb
,
int
k
,
int
limit
,
int
esc_len
){
int
v
=
get_ur_golomb
(
gb
,
k
,
limit
,
esc_len
);
v
++
;
if
(
v
&
1
)
return
-
(
v
>>
1
);
else
return
v
>>
1
;
}
#ifdef TRACE
static
inline
int
get_ue
(
GetBitContext
*
s
,
char
*
file
,
char
*
func
,
int
line
){
...
...
@@ -278,7 +303,7 @@ static inline int get_ue(GetBitContext *s, char *file, char *func, int line){
print_bin
(
bits
,
len
);
printf
(
"%5d %2d %3d ue @%5d in %s %s:%d
\n
"
,
bits
,
len
,
i
,
pos
,
file
,
func
,
line
);
av_log
(
NULL
,
AV_LOG_DEBUG
,
"%5d %2d %3d ue @%5d in %s %s:%d
\n
"
,
bits
,
len
,
i
,
pos
,
file
,
func
,
line
);
return
i
;
}
...
...
@@ -292,7 +317,7 @@ static inline int get_se(GetBitContext *s, char *file, char *func, int line){
print_bin
(
bits
,
len
);
printf
(
"%5d %2d %3d se @%5d in %s %s:%d
\n
"
,
bits
,
len
,
i
,
pos
,
file
,
func
,
line
);
av_log
(
NULL
,
AV_LOG_DEBUG
,
"%5d %2d %3d se @%5d in %s %s:%d
\n
"
,
bits
,
len
,
i
,
pos
,
file
,
func
,
line
);
return
i
;
}
...
...
@@ -306,7 +331,7 @@ static inline int get_te(GetBitContext *s, int r, char *file, char *func, int li
print_bin
(
bits
,
len
);
printf
(
"%5d %2d %3d te @%5d in %s %s:%d
\n
"
,
bits
,
len
,
i
,
pos
,
file
,
func
,
line
);
av_log
(
NULL
,
AV_LOG_DEBUG
,
"%5d %2d %3d te @%5d in %s %s:%d
\n
"
,
bits
,
len
,
i
,
pos
,
file
,
func
,
line
);
return
i
;
}
...
...
@@ -403,3 +428,39 @@ static inline void set_ur_golomb_jpegls(PutBitContext *pb, int i, int k, int lim
put_bits
(
pb
,
esc_len
,
i
-
1
);
}
}
/**
* write signed golomb rice code (ffv1).
*/
static
inline
void
set_sr_golomb_ffv1
(
PutBitContext
*
pb
,
int
i
,
int
k
,
int
limit
,
int
esc_len
){
int
v
;
v
=
-
2
*
i
-
1
;
v
^=
(
v
>>
31
);
set_ur_golomb
(
pb
,
v
,
k
,
limit
,
esc_len
);
}
/**
* write signed golomb rice code (flac).
*/
static
inline
void
set_sr_golomb_flac
(
PutBitContext
*
pb
,
int
i
,
int
k
,
int
limit
,
int
esc_len
){
int
v
;
v
=
-
2
*
i
-
1
;
v
^=
(
v
>>
31
);
set_ur_golomb_jpegls
(
pb
,
v
,
k
,
limit
,
esc_len
);
}
/**
* write signed golomb rice code (sonic).
*/
static
inline
void
set_sr_golomb_sonic
(
PutBitContext
*
pb
,
int
i
,
int
k
,
int
limit
,
int
esc_len
){
int
v
;
v
=
2
*
i
-
1
;
if
(
v
<
0
)
v
^=
-
1
;
set_ur_golomb
(
pb
,
v
,
k
,
limit
,
esc_len
);
}
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