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
9f78e3a4
Commit
9f78e3a4
authored
Apr 13, 2016
by
Alexandra Hájková
Committed by
Diego Biurrun
Nov 24, 2016
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
svq1dec: Convert to the new bitstream reader
parent
6efbc88a
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
60 additions
and
60 deletions
+60
-60
svq1dec.c
libavcodec/svq1dec.c
+60
-60
No files found.
libavcodec/svq1dec.c
View file @
9f78e3a4
...
@@ -33,7 +33,7 @@
...
@@ -33,7 +33,7 @@
*/
*/
#include "avcodec.h"
#include "avcodec.h"
#include "
get_bits
.h"
#include "
bitstream
.h"
#include "h263.h"
#include "h263.h"
#include "hpeldsp.h"
#include "hpeldsp.h"
#include "internal.h"
#include "internal.h"
...
@@ -55,7 +55,7 @@ typedef struct svq1_pmv_s {
...
@@ -55,7 +55,7 @@ typedef struct svq1_pmv_s {
typedef
struct
SVQ1Context
{
typedef
struct
SVQ1Context
{
HpelDSPContext
hdsp
;
HpelDSPContext
hdsp
;
GetBitContext
gb
;
BitstreamContext
bc
;
AVFrame
*
prev
;
AVFrame
*
prev
;
uint8_t
*
pkt_swapped
;
uint8_t
*
pkt_swapped
;
...
@@ -111,7 +111,7 @@ static const uint8_t string_table[256] = {
...
@@ -111,7 +111,7 @@ static const uint8_t string_table[256] = {
break; \
break; \
} \
} \
/* divide block if next bit set */
\
/* divide block if next bit set */
\
if (
get_bits1(bitbuf) == 0)
\
if (
bitstream_read_bit(bc) == 0)
\
break; \
break; \
/* add child nodes */
\
/* add child nodes */
\
list[n++] = list[i]; \
list[n++] = list[i]; \
...
@@ -145,7 +145,7 @@ static const uint8_t string_table[256] = {
...
@@ -145,7 +145,7 @@ static const uint8_t string_table[256] = {
#define SVQ1_CALC_CODEBOOK_ENTRIES(cbook) \
#define SVQ1_CALC_CODEBOOK_ENTRIES(cbook) \
codebook = (const uint32_t *)cbook[level]; \
codebook = (const uint32_t *)cbook[level]; \
if (stages > 0) \
if (stages > 0) \
bit_cache =
get_bits(bitbuf, 4 * stages);
\
bit_cache =
bitstream_read(bc, 4 * stages);
\
/* calculate codebook entries for this vector */
\
/* calculate codebook entries for this vector */
\
for (j = 0; j < stages; j++) { \
for (j = 0; j < stages; j++) { \
entries[j] = (((bit_cache >> (4 * (stages - j - 1))) & 0xF) + \
entries[j] = (((bit_cache >> (4 * (stages - j - 1))) & 0xF) + \
...
@@ -154,7 +154,7 @@ static const uint8_t string_table[256] = {
...
@@ -154,7 +154,7 @@ static const uint8_t string_table[256] = {
mean -= stages * 128; \
mean -= stages * 128; \
n4 = mean + (mean >> 31) << 16 | (mean & 0xFFFF);
n4 = mean + (mean >> 31) << 16 | (mean & 0xFFFF);
static
int
svq1_decode_block_intra
(
GetBitContext
*
bitbuf
,
uint8_t
*
pixels
,
static
int
svq1_decode_block_intra
(
BitstreamContext
*
bc
,
uint8_t
*
pixels
,
ptrdiff_t
pitch
)
ptrdiff_t
pitch
)
{
{
uint32_t
bit_cache
;
uint32_t
bit_cache
;
...
@@ -180,7 +180,7 @@ static int svq1_decode_block_intra(GetBitContext *bitbuf, uint8_t *pixels,
...
@@ -180,7 +180,7 @@ static int svq1_decode_block_intra(GetBitContext *bitbuf, uint8_t *pixels,
height
=
1
<<
((
3
+
level
)
/
2
);
height
=
1
<<
((
3
+
level
)
/
2
);
/* get number of stages (-1 skips vector, 0 for mean only) */
/* get number of stages (-1 skips vector, 0 for mean only) */
stages
=
get_vlc2
(
bitbuf
,
svq1_intra_multistage
[
level
].
table
,
3
,
3
)
-
1
;
stages
=
bitstream_read_vlc
(
bc
,
svq1_intra_multistage
[
level
].
table
,
3
,
3
)
-
1
;
if
(
stages
==
-
1
)
{
if
(
stages
==
-
1
)
{
for
(
y
=
0
;
y
<
height
;
y
++
)
for
(
y
=
0
;
y
<
height
;
y
++
)
...
@@ -195,7 +195,7 @@ static int svq1_decode_block_intra(GetBitContext *bitbuf, uint8_t *pixels,
...
@@ -195,7 +195,7 @@ static int svq1_decode_block_intra(GetBitContext *bitbuf, uint8_t *pixels,
return
AVERROR_INVALIDDATA
;
/* invalid vector */
return
AVERROR_INVALIDDATA
;
/* invalid vector */
}
}
mean
=
get_vlc2
(
bitbuf
,
svq1_intra_mean
.
table
,
8
,
3
);
mean
=
bitstream_read_vlc
(
bc
,
svq1_intra_mean
.
table
,
8
,
3
);
if
(
stages
==
0
)
{
if
(
stages
==
0
)
{
for
(
y
=
0
;
y
<
height
;
y
++
)
for
(
y
=
0
;
y
<
height
;
y
++
)
...
@@ -219,7 +219,7 @@ static int svq1_decode_block_intra(GetBitContext *bitbuf, uint8_t *pixels,
...
@@ -219,7 +219,7 @@ static int svq1_decode_block_intra(GetBitContext *bitbuf, uint8_t *pixels,
return
0
;
return
0
;
}
}
static
int
svq1_decode_block_non_intra
(
GetBitContext
*
bitbuf
,
uint8_t
*
pixels
,
static
int
svq1_decode_block_non_intra
(
BitstreamContext
*
bc
,
uint8_t
*
pixels
,
ptrdiff_t
pitch
)
ptrdiff_t
pitch
)
{
{
uint32_t
bit_cache
;
uint32_t
bit_cache
;
...
@@ -245,7 +245,7 @@ static int svq1_decode_block_non_intra(GetBitContext *bitbuf, uint8_t *pixels,
...
@@ -245,7 +245,7 @@ static int svq1_decode_block_non_intra(GetBitContext *bitbuf, uint8_t *pixels,
height
=
1
<<
((
3
+
level
)
/
2
);
height
=
1
<<
((
3
+
level
)
/
2
);
/* get number of stages (-1 skips vector, 0 for mean only) */
/* get number of stages (-1 skips vector, 0 for mean only) */
stages
=
get_vlc2
(
bitbuf
,
svq1_inter_multistage
[
level
].
table
,
3
,
2
)
-
1
;
stages
=
bitstream_read_vlc
(
bc
,
svq1_inter_multistage
[
level
].
table
,
3
,
2
)
-
1
;
if
(
stages
==
-
1
)
if
(
stages
==
-
1
)
continue
;
/* skip vector */
continue
;
/* skip vector */
...
@@ -257,7 +257,7 @@ static int svq1_decode_block_non_intra(GetBitContext *bitbuf, uint8_t *pixels,
...
@@ -257,7 +257,7 @@ static int svq1_decode_block_non_intra(GetBitContext *bitbuf, uint8_t *pixels,
return
AVERROR_INVALIDDATA
;
/* invalid vector */
return
AVERROR_INVALIDDATA
;
/* invalid vector */
}
}
mean
=
get_vlc2
(
bitbuf
,
svq1_inter_mean
.
table
,
9
,
3
)
-
256
;
mean
=
bitstream_read_vlc
(
bc
,
svq1_inter_mean
.
table
,
9
,
3
)
-
256
;
SVQ1_CALC_CODEBOOK_ENTRIES
(
ff_svq1_inter_codebooks
);
SVQ1_CALC_CODEBOOK_ENTRIES
(
ff_svq1_inter_codebooks
);
...
@@ -277,7 +277,7 @@ static int svq1_decode_block_non_intra(GetBitContext *bitbuf, uint8_t *pixels,
...
@@ -277,7 +277,7 @@ static int svq1_decode_block_non_intra(GetBitContext *bitbuf, uint8_t *pixels,
return
0
;
return
0
;
}
}
static
int
svq1_decode_motion_vector
(
GetBitContext
*
bitbuf
,
svq1_pmv
*
mv
,
static
int
svq1_decode_motion_vector
(
BitstreamContext
*
bc
,
svq1_pmv
*
mv
,
svq1_pmv
**
pmv
)
svq1_pmv
**
pmv
)
{
{
int
diff
;
int
diff
;
...
@@ -285,11 +285,11 @@ static int svq1_decode_motion_vector(GetBitContext *bitbuf, svq1_pmv *mv,
...
@@ -285,11 +285,11 @@ static int svq1_decode_motion_vector(GetBitContext *bitbuf, svq1_pmv *mv,
for
(
i
=
0
;
i
<
2
;
i
++
)
{
for
(
i
=
0
;
i
<
2
;
i
++
)
{
/* get motion code */
/* get motion code */
diff
=
get_vlc2
(
bitbuf
,
svq1_motion_component
.
table
,
7
,
2
);
diff
=
bitstream_read_vlc
(
bc
,
svq1_motion_component
.
table
,
7
,
2
);
if
(
diff
<
0
)
if
(
diff
<
0
)
return
AVERROR_INVALIDDATA
;
return
AVERROR_INVALIDDATA
;
else
if
(
diff
)
{
else
if
(
diff
)
{
if
(
get_bits1
(
bitbuf
))
if
(
bitstream_read_bit
(
bc
))
diff
=
-
diff
;
diff
=
-
diff
;
}
}
...
@@ -320,7 +320,7 @@ static void svq1_skip_block(uint8_t *current, uint8_t *previous,
...
@@ -320,7 +320,7 @@ static void svq1_skip_block(uint8_t *current, uint8_t *previous,
}
}
}
}
static
int
svq1_motion_inter_block
(
HpelDSPContext
*
hdsp
,
GetBitContext
*
bitbuf
,
static
int
svq1_motion_inter_block
(
HpelDSPContext
*
hdsp
,
BitstreamContext
*
bc
,
uint8_t
*
current
,
uint8_t
*
previous
,
uint8_t
*
current
,
uint8_t
*
previous
,
ptrdiff_t
pitch
,
svq1_pmv
*
motion
,
int
x
,
int
y
,
ptrdiff_t
pitch
,
svq1_pmv
*
motion
,
int
x
,
int
y
,
int
width
,
int
height
)
int
width
,
int
height
)
...
@@ -341,7 +341,7 @@ static int svq1_motion_inter_block(HpelDSPContext *hdsp, GetBitContext *bitbuf,
...
@@ -341,7 +341,7 @@ static int svq1_motion_inter_block(HpelDSPContext *hdsp, GetBitContext *bitbuf,
pmv
[
2
]
=
&
motion
[
x
/
8
+
4
];
pmv
[
2
]
=
&
motion
[
x
/
8
+
4
];
}
}
result
=
svq1_decode_motion_vector
(
b
itbuf
,
&
mv
,
pmv
);
result
=
svq1_decode_motion_vector
(
b
c
,
&
mv
,
pmv
);
if
(
result
!=
0
)
if
(
result
!=
0
)
return
result
;
return
result
;
...
@@ -364,7 +364,7 @@ static int svq1_motion_inter_block(HpelDSPContext *hdsp, GetBitContext *bitbuf,
...
@@ -364,7 +364,7 @@ static int svq1_motion_inter_block(HpelDSPContext *hdsp, GetBitContext *bitbuf,
return
0
;
return
0
;
}
}
static
int
svq1_motion_inter_4v_block
(
HpelDSPContext
*
hdsp
,
GetBitContext
*
bitbuf
,
static
int
svq1_motion_inter_4v_block
(
HpelDSPContext
*
hdsp
,
BitstreamContext
*
bc
,
uint8_t
*
current
,
uint8_t
*
previous
,
uint8_t
*
current
,
uint8_t
*
previous
,
ptrdiff_t
pitch
,
svq1_pmv
*
motion
,
int
x
,
int
y
,
ptrdiff_t
pitch
,
svq1_pmv
*
motion
,
int
x
,
int
y
,
int
width
,
int
height
)
int
width
,
int
height
)
...
@@ -385,7 +385,7 @@ static int svq1_motion_inter_4v_block(HpelDSPContext *hdsp, GetBitContext *bitbu
...
@@ -385,7 +385,7 @@ static int svq1_motion_inter_4v_block(HpelDSPContext *hdsp, GetBitContext *bitbu
pmv
[
2
]
=
&
motion
[(
x
/
8
)
+
4
];
pmv
[
2
]
=
&
motion
[(
x
/
8
)
+
4
];
}
}
result
=
svq1_decode_motion_vector
(
b
itbuf
,
&
mv
,
pmv
);
result
=
svq1_decode_motion_vector
(
b
c
,
&
mv
,
pmv
);
if
(
result
!=
0
)
if
(
result
!=
0
)
return
result
;
return
result
;
...
@@ -398,7 +398,7 @@ static int svq1_motion_inter_4v_block(HpelDSPContext *hdsp, GetBitContext *bitbu
...
@@ -398,7 +398,7 @@ static int svq1_motion_inter_4v_block(HpelDSPContext *hdsp, GetBitContext *bitbu
}
else
{
}
else
{
pmv
[
1
]
=
&
motion
[(
x
/
8
)
+
3
];
pmv
[
1
]
=
&
motion
[(
x
/
8
)
+
3
];
}
}
result
=
svq1_decode_motion_vector
(
b
itbuf
,
&
motion
[
0
],
pmv
);
result
=
svq1_decode_motion_vector
(
b
c
,
&
motion
[
0
],
pmv
);
if
(
result
!=
0
)
if
(
result
!=
0
)
return
result
;
return
result
;
...
@@ -407,7 +407,7 @@ static int svq1_motion_inter_4v_block(HpelDSPContext *hdsp, GetBitContext *bitbu
...
@@ -407,7 +407,7 @@ static int svq1_motion_inter_4v_block(HpelDSPContext *hdsp, GetBitContext *bitbu
pmv
[
1
]
=
&
motion
[
0
];
pmv
[
1
]
=
&
motion
[
0
];
pmv
[
2
]
=
&
motion
[(
x
/
8
)
+
1
];
pmv
[
2
]
=
&
motion
[(
x
/
8
)
+
1
];
result
=
svq1_decode_motion_vector
(
b
itbuf
,
&
motion
[(
x
/
8
)
+
2
],
pmv
);
result
=
svq1_decode_motion_vector
(
b
c
,
&
motion
[(
x
/
8
)
+
2
],
pmv
);
if
(
result
!=
0
)
if
(
result
!=
0
)
return
result
;
return
result
;
...
@@ -416,7 +416,7 @@ static int svq1_motion_inter_4v_block(HpelDSPContext *hdsp, GetBitContext *bitbu
...
@@ -416,7 +416,7 @@ static int svq1_motion_inter_4v_block(HpelDSPContext *hdsp, GetBitContext *bitbu
pmv
[
2
]
=
&
motion
[(
x
/
8
)
+
2
];
pmv
[
2
]
=
&
motion
[(
x
/
8
)
+
2
];
pmv
[
3
]
=
&
motion
[(
x
/
8
)
+
3
];
pmv
[
3
]
=
&
motion
[(
x
/
8
)
+
3
];
result
=
svq1_decode_motion_vector
(
b
itbuf
,
pmv
[
3
],
pmv
);
result
=
svq1_decode_motion_vector
(
b
c
,
pmv
[
3
],
pmv
);
if
(
result
!=
0
)
if
(
result
!=
0
)
return
result
;
return
result
;
...
@@ -446,7 +446,7 @@ static int svq1_motion_inter_4v_block(HpelDSPContext *hdsp, GetBitContext *bitbu
...
@@ -446,7 +446,7 @@ static int svq1_motion_inter_4v_block(HpelDSPContext *hdsp, GetBitContext *bitbu
}
}
static
int
svq1_decode_delta_block
(
AVCodecContext
*
avctx
,
HpelDSPContext
*
hdsp
,
static
int
svq1_decode_delta_block
(
AVCodecContext
*
avctx
,
HpelDSPContext
*
hdsp
,
GetBitContext
*
bitbuf
,
BitstreamContext
*
bc
,
uint8_t
*
current
,
uint8_t
*
previous
,
uint8_t
*
current
,
uint8_t
*
previous
,
ptrdiff_t
pitch
,
svq1_pmv
*
motion
,
int
x
,
int
y
,
ptrdiff_t
pitch
,
svq1_pmv
*
motion
,
int
x
,
int
y
,
int
width
,
int
height
)
int
width
,
int
height
)
...
@@ -455,7 +455,7 @@ static int svq1_decode_delta_block(AVCodecContext *avctx, HpelDSPContext *hdsp,
...
@@ -455,7 +455,7 @@ static int svq1_decode_delta_block(AVCodecContext *avctx, HpelDSPContext *hdsp,
int
result
=
0
;
int
result
=
0
;
/* get block type */
/* get block type */
block_type
=
get_vlc2
(
bitbuf
,
svq1_block_type
.
table
,
2
,
2
);
block_type
=
bitstream_read_vlc
(
bc
,
svq1_block_type
.
table
,
2
,
2
);
/* reset motion vectors */
/* reset motion vectors */
if
(
block_type
==
SVQ1_BLOCK_SKIP
||
block_type
==
SVQ1_BLOCK_INTRA
)
{
if
(
block_type
==
SVQ1_BLOCK_SKIP
||
block_type
==
SVQ1_BLOCK_INTRA
)
{
...
@@ -473,45 +473,45 @@ static int svq1_decode_delta_block(AVCodecContext *avctx, HpelDSPContext *hdsp,
...
@@ -473,45 +473,45 @@ static int svq1_decode_delta_block(AVCodecContext *avctx, HpelDSPContext *hdsp,
break
;
break
;
case
SVQ1_BLOCK_INTER
:
case
SVQ1_BLOCK_INTER
:
result
=
svq1_motion_inter_block
(
hdsp
,
b
itbuf
,
current
,
previous
,
result
=
svq1_motion_inter_block
(
hdsp
,
b
c
,
current
,
previous
,
pitch
,
motion
,
x
,
y
,
width
,
height
);
pitch
,
motion
,
x
,
y
,
width
,
height
);
if
(
result
!=
0
)
{
if
(
result
!=
0
)
{
ff_dlog
(
avctx
,
"Error in svq1_motion_inter_block %i
\n
"
,
result
);
ff_dlog
(
avctx
,
"Error in svq1_motion_inter_block %i
\n
"
,
result
);
break
;
break
;
}
}
result
=
svq1_decode_block_non_intra
(
b
itbuf
,
current
,
pitch
);
result
=
svq1_decode_block_non_intra
(
b
c
,
current
,
pitch
);
break
;
break
;
case
SVQ1_BLOCK_INTER_4V
:
case
SVQ1_BLOCK_INTER_4V
:
result
=
svq1_motion_inter_4v_block
(
hdsp
,
b
itbuf
,
current
,
previous
,
result
=
svq1_motion_inter_4v_block
(
hdsp
,
b
c
,
current
,
previous
,
pitch
,
motion
,
x
,
y
,
width
,
height
);
pitch
,
motion
,
x
,
y
,
width
,
height
);
if
(
result
!=
0
)
{
if
(
result
!=
0
)
{
ff_dlog
(
avctx
,
"Error in svq1_motion_inter_4v_block %i
\n
"
,
result
);
ff_dlog
(
avctx
,
"Error in svq1_motion_inter_4v_block %i
\n
"
,
result
);
break
;
break
;
}
}
result
=
svq1_decode_block_non_intra
(
b
itbuf
,
current
,
pitch
);
result
=
svq1_decode_block_non_intra
(
b
c
,
current
,
pitch
);
break
;
break
;
case
SVQ1_BLOCK_INTRA
:
case
SVQ1_BLOCK_INTRA
:
result
=
svq1_decode_block_intra
(
b
itbuf
,
current
,
pitch
);
result
=
svq1_decode_block_intra
(
b
c
,
current
,
pitch
);
break
;
break
;
}
}
return
result
;
return
result
;
}
}
static
void
svq1_parse_string
(
GetBitContext
*
bitbuf
,
uint8_t
*
out
)
static
void
svq1_parse_string
(
BitstreamContext
*
bc
,
uint8_t
*
out
)
{
{
uint8_t
seed
;
uint8_t
seed
;
int
i
;
int
i
;
out
[
0
]
=
get_bits
(
bitbuf
,
8
);
out
[
0
]
=
bitstream_read
(
bc
,
8
);
seed
=
string_table
[
out
[
0
]];
seed
=
string_table
[
out
[
0
]];
for
(
i
=
1
;
i
<=
out
[
0
];
i
++
)
{
for
(
i
=
1
;
i
<=
out
[
0
];
i
++
)
{
out
[
i
]
=
get_bits
(
bitbuf
,
8
)
^
seed
;
out
[
i
]
=
bitstream_read
(
bc
,
8
)
^
seed
;
seed
=
string_table
[
out
[
i
]
^
seed
];
seed
=
string_table
[
out
[
i
]
^
seed
];
}
}
}
}
...
@@ -519,14 +519,14 @@ static void svq1_parse_string(GetBitContext *bitbuf, uint8_t *out)
...
@@ -519,14 +519,14 @@ static void svq1_parse_string(GetBitContext *bitbuf, uint8_t *out)
static
int
svq1_decode_frame_header
(
AVCodecContext
*
avctx
,
AVFrame
*
frame
)
static
int
svq1_decode_frame_header
(
AVCodecContext
*
avctx
,
AVFrame
*
frame
)
{
{
SVQ1Context
*
s
=
avctx
->
priv_data
;
SVQ1Context
*
s
=
avctx
->
priv_data
;
GetBitContext
*
bitbuf
=
&
s
->
gb
;
BitstreamContext
*
bc
=
&
s
->
bc
;
int
frame_size_code
;
int
frame_size_code
;
skip_bits
(
bitbuf
,
8
);
/* temporal_reference */
bitstream_skip
(
bc
,
8
);
/* temporal_reference */
/* frame type */
/* frame type */
s
->
nonref
=
0
;
s
->
nonref
=
0
;
switch
(
get_bits
(
bitbuf
,
2
))
{
switch
(
bitstream_read
(
bc
,
2
))
{
case
0
:
case
0
:
frame
->
pict_type
=
AV_PICTURE_TYPE_I
;
frame
->
pict_type
=
AV_PICTURE_TYPE_I
;
break
;
break
;
...
@@ -543,10 +543,9 @@ static int svq1_decode_frame_header(AVCodecContext *avctx, AVFrame *frame)
...
@@ -543,10 +543,9 @@ static int svq1_decode_frame_header(AVCodecContext *avctx, AVFrame *frame)
if
(
frame
->
pict_type
==
AV_PICTURE_TYPE_I
)
{
if
(
frame
->
pict_type
==
AV_PICTURE_TYPE_I
)
{
/* unknown fields */
/* unknown fields */
if
(
s
->
frame_code
==
0x50
||
s
->
frame_code
==
0x60
)
{
if
(
s
->
frame_code
==
0x50
||
s
->
frame_code
==
0x60
)
{
int
csum
=
get_bits
(
bitbuf
,
16
);
int
csum
=
bitstream_read
(
bc
,
16
);
csum
=
ff_svq1_packet_checksum
(
bitbuf
->
buffer
,
csum
=
ff_svq1_packet_checksum
(
bc
->
buffer
,
bc
->
size_in_bits
>>
3
,
bitbuf
->
size_in_bits
>>
3
,
csum
);
csum
);
ff_dlog
(
avctx
,
"%s checksum (%02x) for packet data
\n
"
,
ff_dlog
(
avctx
,
"%s checksum (%02x) for packet data
\n
"
,
...
@@ -556,23 +555,23 @@ static int svq1_decode_frame_header(AVCodecContext *avctx, AVFrame *frame)
...
@@ -556,23 +555,23 @@ static int svq1_decode_frame_header(AVCodecContext *avctx, AVFrame *frame)
if
((
s
->
frame_code
^
0x10
)
>=
0x50
)
{
if
((
s
->
frame_code
^
0x10
)
>=
0x50
)
{
uint8_t
msg
[
256
];
uint8_t
msg
[
256
];
svq1_parse_string
(
b
itbuf
,
msg
);
svq1_parse_string
(
b
c
,
msg
);
av_log
(
avctx
,
AV_LOG_INFO
,
av_log
(
avctx
,
AV_LOG_INFO
,
"embedded message:
\"
%s
\"\n
"
,
(
char
*
)
msg
);
"embedded message:
\"
%s
\"\n
"
,
(
char
*
)
msg
);
}
}
skip_bits
(
bitbuf
,
2
);
bitstream_skip
(
bc
,
2
);
skip_bits
(
bitbuf
,
2
);
bitstream_skip
(
bc
,
2
);
skip_bits1
(
bitbuf
);
bitstream_skip
(
bc
,
1
);
/* load frame size */
/* load frame size */
frame_size_code
=
get_bits
(
bitbuf
,
3
);
frame_size_code
=
bitstream_read
(
bc
,
3
);
if
(
frame_size_code
==
7
)
{
if
(
frame_size_code
==
7
)
{
/* load width, height (12 bits each) */
/* load width, height (12 bits each) */
s
->
width
=
get_bits
(
bitbuf
,
12
);
s
->
width
=
bitstream_read
(
bc
,
12
);
s
->
height
=
get_bits
(
bitbuf
,
12
);
s
->
height
=
bitstream_read
(
bc
,
12
);
if
(
!
s
->
width
||
!
s
->
height
)
if
(
!
s
->
width
||
!
s
->
height
)
return
AVERROR_INVALIDDATA
;
return
AVERROR_INVALIDDATA
;
...
@@ -584,22 +583,22 @@ static int svq1_decode_frame_header(AVCodecContext *avctx, AVFrame *frame)
...
@@ -584,22 +583,22 @@ static int svq1_decode_frame_header(AVCodecContext *avctx, AVFrame *frame)
}
}
/* unknown fields */
/* unknown fields */
if
(
get_bits1
(
bitbuf
)
==
1
)
{
if
(
bitstream_read_bit
(
bc
)
==
1
)
{
skip_bits1
(
bitbuf
);
/* use packet checksum if (1) */
bitstream_skip
(
bc
,
1
);
/* use packet checksum if (1) */
skip_bits1
(
bitbuf
);
/* component checksums after image data if (1) */
bitstream_skip
(
bc
,
1
);
/* component checksums after image data if (1) */
if
(
get_bits
(
bitbuf
,
2
)
!=
0
)
if
(
bitstream_read
(
bc
,
2
)
!=
0
)
return
AVERROR_INVALIDDATA
;
return
AVERROR_INVALIDDATA
;
}
}
if
(
get_bits1
(
bitbuf
)
==
1
)
{
if
(
bitstream_read_bit
(
bc
)
==
1
)
{
skip_bits1
(
bitbuf
);
bitstream_skip
(
bc
,
1
);
skip_bits
(
bitbuf
,
4
);
bitstream_skip
(
bc
,
4
);
skip_bits1
(
bitbuf
);
bitstream_skip
(
bc
,
1
);
skip_bits
(
bitbuf
,
2
);
bitstream_skip
(
bc
,
2
);
while
(
get_bits1
(
bitbuf
)
==
1
)
while
(
bitstream_read_bit
(
bc
)
==
1
)
skip_bits
(
bitbuf
,
8
);
bitstream_skip
(
bc
,
8
);
}
}
return
0
;
return
0
;
...
@@ -617,10 +616,10 @@ static int svq1_decode_frame(AVCodecContext *avctx, void *data,
...
@@ -617,10 +616,10 @@ static int svq1_decode_frame(AVCodecContext *avctx, void *data,
svq1_pmv
*
pmv
;
svq1_pmv
*
pmv
;
/* initialize bit buffer */
/* initialize bit buffer */
init_get_bits
(
&
s
->
gb
,
buf
,
buf_size
*
8
);
bitstream_init
(
&
s
->
bc
,
buf
,
buf_size
*
8
);
/* decode frame header */
/* decode frame header */
s
->
frame_code
=
get_bits
(
&
s
->
gb
,
22
);
s
->
frame_code
=
bitstream_read
(
&
s
->
bc
,
22
);
if
((
s
->
frame_code
&
~
0x70
)
||
!
(
s
->
frame_code
&
0x60
))
if
((
s
->
frame_code
&
~
0x70
)
||
!
(
s
->
frame_code
&
0x60
))
return
AVERROR_INVALIDDATA
;
return
AVERROR_INVALIDDATA
;
...
@@ -642,13 +641,14 @@ static int svq1_decode_frame(AVCodecContext *avctx, void *data,
...
@@ -642,13 +641,14 @@ static int svq1_decode_frame(AVCodecContext *avctx, void *data,
memcpy
(
s
->
pkt_swapped
,
buf
,
buf_size
);
memcpy
(
s
->
pkt_swapped
,
buf
,
buf_size
);
buf
=
s
->
pkt_swapped
;
buf
=
s
->
pkt_swapped
;
init_get_bits
(
&
s
->
gb
,
buf
,
buf_size
*
8
);
skip_bits
(
&
s
->
gb
,
22
);
src
=
(
uint32_t
*
)(
s
->
pkt_swapped
+
4
);
src
=
(
uint32_t
*
)(
s
->
pkt_swapped
+
4
);
for
(
i
=
0
;
i
<
4
;
i
++
)
for
(
i
=
0
;
i
<
4
;
i
++
)
src
[
i
]
=
((
src
[
i
]
<<
16
)
|
(
src
[
i
]
>>
16
))
^
src
[
7
-
i
];
src
[
i
]
=
((
src
[
i
]
<<
16
)
|
(
src
[
i
]
>>
16
))
^
src
[
7
-
i
];
bitstream_init
(
&
s
->
bc
,
buf
,
buf_size
*
8
);
bitstream_skip
(
&
s
->
bc
,
22
);
}
}
result
=
svq1_decode_frame_header
(
avctx
,
cur
);
result
=
svq1_decode_frame_header
(
avctx
,
cur
);
...
@@ -695,7 +695,7 @@ static int svq1_decode_frame(AVCodecContext *avctx, void *data,
...
@@ -695,7 +695,7 @@ static int svq1_decode_frame(AVCodecContext *avctx, void *data,
/* keyframe */
/* keyframe */
for
(
y
=
0
;
y
<
height
;
y
+=
16
)
{
for
(
y
=
0
;
y
<
height
;
y
+=
16
)
{
for
(
x
=
0
;
x
<
width
;
x
+=
16
)
{
for
(
x
=
0
;
x
<
width
;
x
+=
16
)
{
result
=
svq1_decode_block_intra
(
&
s
->
gb
,
&
current
[
x
],
result
=
svq1_decode_block_intra
(
&
s
->
bc
,
&
current
[
x
],
linesize
);
linesize
);
if
(
result
!=
0
)
{
if
(
result
!=
0
)
{
av_log
(
avctx
,
AV_LOG_INFO
,
av_log
(
avctx
,
AV_LOG_INFO
,
...
@@ -721,7 +721,7 @@ static int svq1_decode_frame(AVCodecContext *avctx, void *data,
...
@@ -721,7 +721,7 @@ static int svq1_decode_frame(AVCodecContext *avctx, void *data,
for
(
y
=
0
;
y
<
height
;
y
+=
16
)
{
for
(
y
=
0
;
y
<
height
;
y
+=
16
)
{
for
(
x
=
0
;
x
<
width
;
x
+=
16
)
{
for
(
x
=
0
;
x
<
width
;
x
+=
16
)
{
result
=
svq1_decode_delta_block
(
avctx
,
&
s
->
hdsp
,
result
=
svq1_decode_delta_block
(
avctx
,
&
s
->
hdsp
,
&
s
->
gb
,
&
current
[
x
],
&
s
->
bc
,
&
current
[
x
],
previous
,
linesize
,
previous
,
linesize
,
pmv
,
x
,
y
,
width
,
height
);
pmv
,
x
,
y
,
width
,
height
);
if
(
result
!=
0
)
{
if
(
result
!=
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