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
ed006ae4
Commit
ed006ae4
authored
Apr 07, 2016
by
Alexandra Hájková
Committed by
Anton Khirnov
Nov 18, 2016
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
4xm: Convert to the new bitstream reader
Signed-off-by:
Anton Khirnov
<
anton@khirnov.net
>
parent
b2518080
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
14 additions
and
13 deletions
+14
-13
4xm.c
libavcodec/4xm.c
+14
-13
No files found.
libavcodec/4xm.c
View file @
ed006ae4
...
@@ -29,11 +29,12 @@
...
@@ -29,11 +29,12 @@
#include "libavutil/frame.h"
#include "libavutil/frame.h"
#include "libavutil/imgutils.h"
#include "libavutil/imgutils.h"
#include "libavutil/intreadwrite.h"
#include "libavutil/intreadwrite.h"
#include "avcodec.h"
#include "avcodec.h"
#include "bitstream.h"
#include "blockdsp.h"
#include "blockdsp.h"
#include "bswapdsp.h"
#include "bswapdsp.h"
#include "bytestream.h"
#include "bytestream.h"
#include "get_bits.h"
#include "internal.h"
#include "internal.h"
#define BLOCK_TYPE_VLC_BITS 5
#define BLOCK_TYPE_VLC_BITS 5
...
@@ -136,8 +137,8 @@ typedef struct FourXContext {
...
@@ -136,8 +137,8 @@ typedef struct FourXContext {
BswapDSPContext
bbdsp
;
BswapDSPContext
bbdsp
;
uint16_t
*
frame_buffer
;
uint16_t
*
frame_buffer
;
uint16_t
*
last_frame_buffer
;
uint16_t
*
last_frame_buffer
;
GetBitContext
pre_gb
;
///<
ac/dc prefix
BitstreamContext
pre_bc
;
//
ac/dc prefix
GetBitContext
gb
;
BitstreamContext
bc
;
GetByteContext
g
;
GetByteContext
g
;
GetByteContext
g2
;
GetByteContext
g2
;
int
mv
[
256
];
int
mv
[
256
];
...
@@ -352,8 +353,8 @@ static int decode_p_block(FourXContext *f, uint16_t *dst, uint16_t *src,
...
@@ -352,8 +353,8 @@ static int decode_p_block(FourXContext *f, uint16_t *dst, uint16_t *src,
return
AVERROR_INVALIDDATA
;
return
AVERROR_INVALIDDATA
;
h
=
1
<<
log2h
;
h
=
1
<<
log2h
;
code
=
get_vlc2
(
&
f
->
gb
,
block_type_vlc
[
1
-
(
f
->
version
>
1
)][
index
].
table
,
code
=
bitstream_read_vlc
(
&
f
->
bc
,
block_type_vlc
[
1
-
(
f
->
version
>
1
)][
index
].
table
,
BLOCK_TYPE_VLC_BITS
,
1
);
BLOCK_TYPE_VLC_BITS
,
1
);
if
(
code
<
0
||
code
>
6
)
if
(
code
<
0
||
code
>
6
)
return
AVERROR_INVALIDDATA
;
return
AVERROR_INVALIDDATA
;
...
@@ -453,7 +454,7 @@ static int decode_p_frame(FourXContext *f, const uint8_t *buf, int length)
...
@@ -453,7 +454,7 @@ static int decode_p_frame(FourXContext *f, const uint8_t *buf, int length)
bitstream_size
/
4
);
bitstream_size
/
4
);
memset
((
uint8_t
*
)
f
->
bitstream_buffer
+
bitstream_size
,
memset
((
uint8_t
*
)
f
->
bitstream_buffer
+
bitstream_size
,
0
,
AV_INPUT_BUFFER_PADDING_SIZE
);
0
,
AV_INPUT_BUFFER_PADDING_SIZE
);
init_get_bits
(
&
f
->
gb
,
f
->
bitstream_buffer
,
8
*
bitstream_size
);
bitstream_init
(
&
f
->
bc
,
f
->
bitstream_buffer
,
8
*
bitstream_size
);
wordstream_offset
=
extra
+
bitstream_size
;
wordstream_offset
=
extra
+
bitstream_size
;
bytestream_offset
=
extra
+
bitstream_size
+
wordstream_size
;
bytestream_offset
=
extra
+
bitstream_size
+
wordstream_size
;
...
@@ -484,19 +485,19 @@ static int decode_i_block(FourXContext *f, int16_t *block)
...
@@ -484,19 +485,19 @@ static int decode_i_block(FourXContext *f, int16_t *block)
int
code
,
i
,
j
,
level
,
val
;
int
code
,
i
,
j
,
level
,
val
;
/* DC coef */
/* DC coef */
val
=
get_vlc2
(
&
f
->
pre_gb
,
f
->
pre_vlc
.
table
,
ACDC_VLC_BITS
,
3
);
val
=
bitstream_read_vlc
(
&
f
->
pre_bc
,
f
->
pre_vlc
.
table
,
ACDC_VLC_BITS
,
3
);
if
(
val
>>
4
)
if
(
val
>>
4
)
av_log
(
f
->
avctx
,
AV_LOG_ERROR
,
"error dc run != 0
\n
"
);
av_log
(
f
->
avctx
,
AV_LOG_ERROR
,
"error dc run != 0
\n
"
);
if
(
val
)
if
(
val
)
val
=
get_xbits
(
&
f
->
gb
,
val
);
val
=
bitstream_read_xbits
(
&
f
->
bc
,
val
);
val
=
val
*
dequant_table
[
0
]
+
f
->
last_dc
;
val
=
val
*
dequant_table
[
0
]
+
f
->
last_dc
;
f
->
last_dc
=
block
[
0
]
=
val
;
f
->
last_dc
=
block
[
0
]
=
val
;
/* AC coefs */
/* AC coefs */
i
=
1
;
i
=
1
;
for
(;;)
{
for
(;;)
{
code
=
get_vlc2
(
&
f
->
pre_gb
,
f
->
pre_vlc
.
table
,
ACDC_VLC_BITS
,
3
);
code
=
bitstream_read_vlc
(
&
f
->
pre_bc
,
f
->
pre_vlc
.
table
,
ACDC_VLC_BITS
,
3
);
/* EOB */
/* EOB */
if
(
code
==
0
)
if
(
code
==
0
)
...
@@ -504,7 +505,7 @@ static int decode_i_block(FourXContext *f, int16_t *block)
...
@@ -504,7 +505,7 @@ static int decode_i_block(FourXContext *f, int16_t *block)
if
(
code
==
0xf0
)
{
if
(
code
==
0xf0
)
{
i
+=
16
;
i
+=
16
;
}
else
{
}
else
{
level
=
get_xbits
(
&
f
->
gb
,
code
&
0xf
);
level
=
bitstream_read_xbits
(
&
f
->
bc
,
code
&
0xf
);
i
+=
code
>>
4
;
i
+=
code
>>
4
;
if
(
i
>=
64
)
{
if
(
i
>=
64
)
{
av_log
(
f
->
avctx
,
AV_LOG_ERROR
,
"run %d oveflow
\n
"
,
i
);
av_log
(
f
->
avctx
,
AV_LOG_ERROR
,
"run %d oveflow
\n
"
,
i
);
...
@@ -764,7 +765,7 @@ static int decode_i_frame(FourXContext *f, const uint8_t *buf, int length)
...
@@ -764,7 +765,7 @@ static int decode_i_frame(FourXContext *f, const uint8_t *buf, int length)
return
AVERROR_INVALIDDATA
;
return
AVERROR_INVALIDDATA
;
}
}
init_get_bits
(
&
f
->
gb
,
buf
+
4
,
8
*
bitstream_size
);
bitstream_init
(
&
f
->
bc
,
buf
+
4
,
8
*
bitstream_size
);
prestream_size
=
length
+
buf
-
prestream
;
prestream_size
=
length
+
buf
-
prestream
;
...
@@ -776,7 +777,7 @@ static int decode_i_frame(FourXContext *f, const uint8_t *buf, int length)
...
@@ -776,7 +777,7 @@ static int decode_i_frame(FourXContext *f, const uint8_t *buf, int length)
prestream_size
/
4
);
prestream_size
/
4
);
memset
((
uint8_t
*
)
f
->
bitstream_buffer
+
prestream_size
,
memset
((
uint8_t
*
)
f
->
bitstream_buffer
+
prestream_size
,
0
,
AV_INPUT_BUFFER_PADDING_SIZE
);
0
,
AV_INPUT_BUFFER_PADDING_SIZE
);
init_get_bits
(
&
f
->
pre_gb
,
f
->
bitstream_buffer
,
8
*
prestream_size
);
bitstream_init
(
&
f
->
pre_bc
,
f
->
bitstream_buffer
,
8
*
prestream_size
);
f
->
last_dc
=
0
*
128
*
8
*
8
;
f
->
last_dc
=
0
*
128
*
8
*
8
;
...
@@ -789,7 +790,7 @@ static int decode_i_frame(FourXContext *f, const uint8_t *buf, int length)
...
@@ -789,7 +790,7 @@ static int decode_i_frame(FourXContext *f, const uint8_t *buf, int length)
}
}
}
}
if
(
get_vlc2
(
&
f
->
pre_gb
,
f
->
pre_vlc
.
table
,
ACDC_VLC_BITS
,
3
)
!=
256
)
if
(
bitstream_read_vlc
(
&
f
->
pre_bc
,
f
->
pre_vlc
.
table
,
ACDC_VLC_BITS
,
3
)
!=
256
)
av_log
(
f
->
avctx
,
AV_LOG_ERROR
,
"end mismatch
\n
"
);
av_log
(
f
->
avctx
,
AV_LOG_ERROR
,
"end mismatch
\n
"
);
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