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
49df339f
Commit
49df339f
authored
12 years ago
by
Kostya Shishkov
Browse files
Options
Downloads
Patches
Plain Diff
mss1: merge decode_intra() and decode_inter()
They have most of their code in common.
parent
b42be2d5
No related branches found
Branches containing commit
No related tags found
Tags containing commit
No related merge requests found
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
libavcodec/mss1.c
+14
-50
14 additions, 50 deletions
libavcodec/mss1.c
with
14 additions
and
50 deletions
libavcodec/mss1.c
+
14
−
50
View file @
49df339f
...
@@ -80,6 +80,7 @@ typedef struct MSS1Context {
...
@@ -80,6 +80,7 @@ typedef struct MSS1Context {
int
mask_linesize
;
int
mask_linesize
;
uint32_t
pal
[
256
];
uint32_t
pal
[
256
];
int
free_colours
;
int
free_colours
;
int
keyframe
;
Model
intra_region
,
inter_region
;
Model
intra_region
,
inter_region
;
Model
pivot
,
edge_mode
,
split_mode
;
Model
pivot
,
edge_mode
,
split_mode
;
PixContext
intra_pix_ctx
,
inter_pix_ctx
;
PixContext
intra_pix_ctx
,
inter_pix_ctx
;
...
@@ -607,44 +608,6 @@ static int decode_region_intra(MSS1Context *ctx, ArithCoder *acoder,
...
@@ -607,44 +608,6 @@ static int decode_region_intra(MSS1Context *ctx, ArithCoder *acoder,
return
0
;
return
0
;
}
}
static
int
decode_intra
(
MSS1Context
*
ctx
,
ArithCoder
*
acoder
,
int
x
,
int
y
,
int
width
,
int
height
)
{
int
mode
,
pivot
;
if
(
ctx
->
corrupted
)
return
-
1
;
mode
=
arith_get_model_sym
(
acoder
,
&
ctx
->
split_mode
);
switch
(
mode
)
{
case
SPLIT_VERT
:
pivot
=
decode_pivot
(
ctx
,
acoder
,
height
);
if
(
ctx
->
corrupted
)
return
-
1
;
if
(
decode_intra
(
ctx
,
acoder
,
x
,
y
,
width
,
pivot
))
return
-
1
;
if
(
decode_intra
(
ctx
,
acoder
,
x
,
y
+
pivot
,
width
,
height
-
pivot
))
return
-
1
;
break
;
case
SPLIT_HOR
:
pivot
=
decode_pivot
(
ctx
,
acoder
,
width
);
if
(
ctx
->
corrupted
)
return
-
1
;
if
(
decode_intra
(
ctx
,
acoder
,
x
,
y
,
pivot
,
height
))
return
-
1
;
if
(
decode_intra
(
ctx
,
acoder
,
x
+
pivot
,
y
,
width
-
pivot
,
height
))
return
-
1
;
break
;
case
SPLIT_NONE
:
return
decode_region_intra
(
ctx
,
acoder
,
x
,
y
,
width
,
height
);
default:
return
-
1
;
}
return
0
;
}
static
int
decode_region_inter
(
MSS1Context
*
ctx
,
ArithCoder
*
acoder
,
static
int
decode_region_inter
(
MSS1Context
*
ctx
,
ArithCoder
*
acoder
,
int
x
,
int
y
,
int
width
,
int
height
)
int
x
,
int
y
,
int
width
,
int
height
)
{
{
...
@@ -674,8 +637,8 @@ static int decode_region_inter(MSS1Context *ctx, ArithCoder *acoder,
...
@@ -674,8 +637,8 @@ static int decode_region_inter(MSS1Context *ctx, ArithCoder *acoder,
return
0
;
return
0
;
}
}
static
int
decode_
inter
(
MSS1Context
*
ctx
,
ArithCoder
*
acoder
,
static
int
decode_
rect
(
MSS1Context
*
ctx
,
ArithCoder
*
acoder
,
int
x
,
int
y
,
int
width
,
int
height
)
int
x
,
int
y
,
int
width
,
int
height
)
{
{
int
mode
,
pivot
;
int
mode
,
pivot
;
...
@@ -687,20 +650,23 @@ static int decode_inter(MSS1Context *ctx, ArithCoder *acoder,
...
@@ -687,20 +650,23 @@ static int decode_inter(MSS1Context *ctx, ArithCoder *acoder,
switch
(
mode
)
{
switch
(
mode
)
{
case
SPLIT_VERT
:
case
SPLIT_VERT
:
pivot
=
decode_pivot
(
ctx
,
acoder
,
height
);
pivot
=
decode_pivot
(
ctx
,
acoder
,
height
);
if
(
decode_
inter
(
ctx
,
acoder
,
x
,
y
,
width
,
pivot
))
if
(
decode_
rect
(
ctx
,
acoder
,
x
,
y
,
width
,
pivot
))
return
-
1
;
return
-
1
;
if
(
decode_
inter
(
ctx
,
acoder
,
x
,
y
+
pivot
,
width
,
height
-
pivot
))
if
(
decode_
rect
(
ctx
,
acoder
,
x
,
y
+
pivot
,
width
,
height
-
pivot
))
return
-
1
;
return
-
1
;
break
;
break
;
case
SPLIT_HOR
:
case
SPLIT_HOR
:
pivot
=
decode_pivot
(
ctx
,
acoder
,
width
);
pivot
=
decode_pivot
(
ctx
,
acoder
,
width
);
if
(
decode_
inter
(
ctx
,
acoder
,
x
,
y
,
pivot
,
height
))
if
(
decode_
rect
(
ctx
,
acoder
,
x
,
y
,
pivot
,
height
))
return
-
1
;
return
-
1
;
if
(
decode_
inter
(
ctx
,
acoder
,
x
+
pivot
,
y
,
width
-
pivot
,
height
))
if
(
decode_
rect
(
ctx
,
acoder
,
x
+
pivot
,
y
,
width
-
pivot
,
height
))
return
-
1
;
return
-
1
;
break
;
break
;
case
SPLIT_NONE
:
case
SPLIT_NONE
:
return
decode_region_inter
(
ctx
,
acoder
,
x
,
y
,
width
,
height
);
if
(
ctx
->
keyframe
)
return
decode_region_intra
(
ctx
,
acoder
,
x
,
y
,
width
,
height
);
else
return
decode_region_inter
(
ctx
,
acoder
,
x
,
y
,
width
,
height
);
default:
default:
return
-
1
;
return
-
1
;
}
}
...
@@ -732,21 +698,19 @@ static int mss1_decode_frame(AVCodecContext *avctx, void *data, int *data_size,
...
@@ -732,21 +698,19 @@ static int mss1_decode_frame(AVCodecContext *avctx, void *data, int *data_size,
c
->
pic_start
=
c
->
pic
.
data
[
0
]
+
c
->
pic
.
linesize
[
0
]
*
(
avctx
->
height
-
1
);
c
->
pic_start
=
c
->
pic
.
data
[
0
]
+
c
->
pic
.
linesize
[
0
]
*
(
avctx
->
height
-
1
);
c
->
pic_stride
=
-
c
->
pic
.
linesize
[
0
];
c
->
pic_stride
=
-
c
->
pic
.
linesize
[
0
];
if
(
!
arith_get_bit
(
&
acoder
))
{
c
->
keyframe
=
!
arith_get_bit
(
&
acoder
);
if
(
c
->
keyframe
)
{
codec_reset
(
c
);
codec_reset
(
c
);
pal_changed
=
decode_pal
(
c
,
&
acoder
);
pal_changed
=
decode_pal
(
c
,
&
acoder
);
c
->
corrupted
=
decode_intra
(
c
,
&
acoder
,
0
,
0
,
avctx
->
width
,
avctx
->
height
);
c
->
pic
.
key_frame
=
1
;
c
->
pic
.
key_frame
=
1
;
c
->
pic
.
pict_type
=
AV_PICTURE_TYPE_I
;
c
->
pic
.
pict_type
=
AV_PICTURE_TYPE_I
;
}
else
{
}
else
{
if
(
c
->
corrupted
)
if
(
c
->
corrupted
)
return
AVERROR_INVALIDDATA
;
return
AVERROR_INVALIDDATA
;
c
->
corrupted
=
decode_inter
(
c
,
&
acoder
,
0
,
0
,
avctx
->
width
,
avctx
->
height
);
c
->
pic
.
key_frame
=
0
;
c
->
pic
.
key_frame
=
0
;
c
->
pic
.
pict_type
=
AV_PICTURE_TYPE_P
;
c
->
pic
.
pict_type
=
AV_PICTURE_TYPE_P
;
}
}
c
->
corrupted
=
decode_rect
(
c
,
&
acoder
,
0
,
0
,
avctx
->
width
,
avctx
->
height
);
if
(
c
->
corrupted
)
if
(
c
->
corrupted
)
return
AVERROR_INVALIDDATA
;
return
AVERROR_INVALIDDATA
;
memcpy
(
c
->
pic
.
data
[
1
],
c
->
pal
,
AVPALETTE_SIZE
);
memcpy
(
c
->
pic
.
data
[
1
],
c
->
pal
,
AVPALETTE_SIZE
);
...
...
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