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
df05fd31
Commit
df05fd31
authored
6 years ago
by
Paul B Mahol
Browse files
Options
Downloads
Patches
Plain Diff
avcodec/loco: switch to planar rgb format
Remove now unused step variable.
parent
90ba1765
No related branches found
Branches containing commit
No related tags found
Tags containing commit
No related merge requests found
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
libavcodec/loco.c
+34
-35
34 additions, 35 deletions
libavcodec/loco.c
tests/ref/fate/loco-rgb
+5
-5
5 additions, 5 deletions
tests/ref/fate/loco-rgb
with
39 additions
and
40 deletions
libavcodec/loco.c
+
34
−
35
View file @
df05fd31
...
...
@@ -114,19 +114,19 @@ static inline int loco_get_rice(RICEContext *r)
}
/* LOCO main predictor - LOCO-I/JPEG-LS predictor */
static
inline
int
loco_predict
(
uint8_t
*
data
,
int
stride
,
int
step
)
static
inline
int
loco_predict
(
uint8_t
*
data
,
int
stride
)
{
int
a
,
b
,
c
;
a
=
data
[
-
stride
];
b
=
data
[
-
step
];
c
=
data
[
-
stride
-
step
];
b
=
data
[
-
1
];
c
=
data
[
-
stride
-
1
];
return
mid_pred
(
a
,
a
+
b
-
c
,
b
);
}
static
int
loco_decode_plane
(
LOCOContext
*
l
,
uint8_t
*
data
,
int
width
,
int
height
,
int
stride
,
const
uint8_t
*
buf
,
int
buf_size
,
int
step
)
int
stride
,
const
uint8_t
*
buf
,
int
buf_size
)
{
RICEContext
rc
;
int
val
;
...
...
@@ -153,7 +153,7 @@ static int loco_decode_plane(LOCOContext *l, uint8_t *data, int width, int heigh
/* restore top line */
for
(
i
=
1
;
i
<
width
;
i
++
)
{
val
=
loco_get_rice
(
&
rc
);
data
[
i
*
step
]
=
data
[
i
*
step
-
step
]
+
val
;
data
[
i
]
=
data
[
i
-
1
]
+
val
;
}
data
+=
stride
;
for
(
j
=
1
;
j
<
height
;
j
++
)
{
...
...
@@ -163,7 +163,7 @@ static int loco_decode_plane(LOCOContext *l, uint8_t *data, int width, int heigh
/* restore all other pixels */
for
(
i
=
1
;
i
<
width
;
i
++
)
{
val
=
loco_get_rice
(
&
rc
);
data
[
i
*
step
]
=
loco_predict
(
&
data
[
i
*
step
],
stride
,
step
)
+
val
;
data
[
i
]
=
loco_predict
(
&
data
[
i
],
stride
)
+
val
;
}
data
+=
stride
;
}
...
...
@@ -171,19 +171,18 @@ static int loco_decode_plane(LOCOContext *l, uint8_t *data, int width, int heigh
return
(
get_bits_count
(
&
rc
.
gb
)
+
7
)
>>
3
;
}
static
void
rotate_faulty_loco
(
uint8_t
*
data
,
int
width
,
int
height
,
int
stride
,
int
step
)
static
void
rotate_faulty_loco
(
uint8_t
*
data
,
int
width
,
int
height
,
int
stride
)
{
int
y
;
for
(
y
=
1
;
y
<
height
;
y
++
)
{
if
(
width
>=
y
)
{
memmove
(
data
+
y
*
stride
,
data
+
y
*
(
stride
+
step
),
step
*
(
width
-
y
));
data
+
y
*
(
stride
+
1
),
(
width
-
y
));
if
(
y
+
1
<
height
)
memmove
(
data
+
y
*
stride
+
step
*
(
width
-
y
),
data
+
(
y
+
1
)
*
stride
,
step
*
y
);
memmove
(
data
+
y
*
stride
+
(
width
-
y
),
data
+
(
y
+
1
)
*
stride
,
y
);
}
}
}
...
...
@@ -209,49 +208,49 @@ static int decode_frame(AVCodecContext *avctx,
switch
(
l
->
mode
)
{
case
LOCO_CYUY2
:
case
LOCO_YUY2
:
case
LOCO_UYVY
:
decoded
=
loco_decode_plane
(
l
,
p
->
data
[
0
],
avctx
->
width
,
avctx
->
height
,
p
->
linesize
[
0
],
buf
,
buf_size
,
1
);
p
->
linesize
[
0
],
buf
,
buf_size
);
ADVANCE_BY_DECODED
;
decoded
=
loco_decode_plane
(
l
,
p
->
data
[
1
],
avctx
->
width
/
2
,
avctx
->
height
,
p
->
linesize
[
1
],
buf
,
buf_size
,
1
);
p
->
linesize
[
1
],
buf
,
buf_size
);
ADVANCE_BY_DECODED
;
decoded
=
loco_decode_plane
(
l
,
p
->
data
[
2
],
avctx
->
width
/
2
,
avctx
->
height
,
p
->
linesize
[
2
],
buf
,
buf_size
,
1
);
p
->
linesize
[
2
],
buf
,
buf_size
);
break
;
case
LOCO_CYV12
:
case
LOCO_YV12
:
decoded
=
loco_decode_plane
(
l
,
p
->
data
[
0
],
avctx
->
width
,
avctx
->
height
,
p
->
linesize
[
0
],
buf
,
buf_size
,
1
);
p
->
linesize
[
0
],
buf
,
buf_size
);
ADVANCE_BY_DECODED
;
decoded
=
loco_decode_plane
(
l
,
p
->
data
[
2
],
avctx
->
width
/
2
,
avctx
->
height
/
2
,
p
->
linesize
[
2
],
buf
,
buf_size
,
1
);
p
->
linesize
[
2
],
buf
,
buf_size
);
ADVANCE_BY_DECODED
;
decoded
=
loco_decode_plane
(
l
,
p
->
data
[
1
],
avctx
->
width
/
2
,
avctx
->
height
/
2
,
p
->
linesize
[
1
],
buf
,
buf_size
,
1
);
p
->
linesize
[
1
],
buf
,
buf_size
);
break
;
case
LOCO_CRGB
:
case
LOCO_RGB
:
decoded
=
loco_decode_plane
(
l
,
p
->
data
[
0
]
+
p
->
linesize
[
0
]
*
(
avctx
->
height
-
1
),
avctx
->
width
,
avctx
->
height
,
-
p
->
linesize
[
0
],
buf
,
buf_size
,
3
);
decoded
=
loco_decode_plane
(
l
,
p
->
data
[
1
]
+
p
->
linesize
[
1
]
*
(
avctx
->
height
-
1
),
avctx
->
width
,
avctx
->
height
,
-
p
->
linesize
[
1
],
buf
,
buf_size
);
ADVANCE_BY_DECODED
;
decoded
=
loco_decode_plane
(
l
,
p
->
data
[
0
]
+
p
->
linesize
[
0
]
*
(
avctx
->
height
-
1
)
+
1
,
avctx
->
width
,
avctx
->
height
,
-
p
->
linesize
[
0
],
buf
,
buf_size
,
3
);
decoded
=
loco_decode_plane
(
l
,
p
->
data
[
0
]
+
p
->
linesize
[
0
]
*
(
avctx
->
height
-
1
),
avctx
->
width
,
avctx
->
height
,
-
p
->
linesize
[
0
],
buf
,
buf_size
);
ADVANCE_BY_DECODED
;
decoded
=
loco_decode_plane
(
l
,
p
->
data
[
0
]
+
p
->
linesize
[
0
]
*
(
avctx
->
height
-
1
)
+
2
,
avctx
->
width
,
avctx
->
height
,
-
p
->
linesize
[
0
],
buf
,
buf_size
,
3
);
decoded
=
loco_decode_plane
(
l
,
p
->
data
[
2
]
+
p
->
linesize
[
2
]
*
(
avctx
->
height
-
1
),
avctx
->
width
,
avctx
->
height
,
-
p
->
linesize
[
2
],
buf
,
buf_size
);
if
(
avctx
->
width
&
1
)
rotate_faulty_loco
(
p
->
data
[
0
]
+
p
->
linesize
[
0
]
*
(
avctx
->
height
-
1
),
avctx
->
width
,
avctx
->
height
,
-
p
->
linesize
[
0
],
3
);
rotate_faulty_loco
(
p
->
data
[
1
]
+
p
->
linesize
[
1
]
*
(
avctx
->
height
-
1
),
avctx
->
width
,
avctx
->
height
,
-
p
->
linesize
[
1
]
);
break
;
case
LOCO_CRGBA
:
case
LOCO_RGBA
:
decoded
=
loco_decode_plane
(
l
,
p
->
data
[
0
]
+
p
->
linesize
[
0
]
*
(
avctx
->
height
-
1
),
avctx
->
width
,
avctx
->
height
,
-
p
->
linesize
[
0
],
buf
,
buf_size
,
4
);
decoded
=
loco_decode_plane
(
l
,
p
->
data
[
1
]
+
p
->
linesize
[
1
]
*
(
avctx
->
height
-
1
),
avctx
->
width
,
avctx
->
height
,
-
p
->
linesize
[
1
],
buf
,
buf_size
);
ADVANCE_BY_DECODED
;
decoded
=
loco_decode_plane
(
l
,
p
->
data
[
0
]
+
p
->
linesize
[
0
]
*
(
avctx
->
height
-
1
)
+
1
,
avctx
->
width
,
avctx
->
height
,
-
p
->
linesize
[
0
],
buf
,
buf_size
,
4
);
decoded
=
loco_decode_plane
(
l
,
p
->
data
[
0
]
+
p
->
linesize
[
0
]
*
(
avctx
->
height
-
1
),
avctx
->
width
,
avctx
->
height
,
-
p
->
linesize
[
0
],
buf
,
buf_size
);
ADVANCE_BY_DECODED
;
decoded
=
loco_decode_plane
(
l
,
p
->
data
[
0
]
+
p
->
linesize
[
0
]
*
(
avctx
->
height
-
1
)
+
2
,
avctx
->
width
,
avctx
->
height
,
-
p
->
linesize
[
0
],
buf
,
buf_size
,
4
);
decoded
=
loco_decode_plane
(
l
,
p
->
data
[
2
]
+
p
->
linesize
[
2
]
*
(
avctx
->
height
-
1
),
avctx
->
width
,
avctx
->
height
,
-
p
->
linesize
[
2
],
buf
,
buf_size
);
ADVANCE_BY_DECODED
;
decoded
=
loco_decode_plane
(
l
,
p
->
data
[
0
]
+
p
->
linesize
[
0
]
*
(
avctx
->
height
-
1
)
+
3
,
avctx
->
width
,
avctx
->
height
,
-
p
->
linesize
[
0
],
buf
,
buf_size
,
4
);
decoded
=
loco_decode_plane
(
l
,
p
->
data
[
3
]
+
p
->
linesize
[
3
]
*
(
avctx
->
height
-
1
),
avctx
->
width
,
avctx
->
height
,
-
p
->
linesize
[
3
],
buf
,
buf_size
);
break
;
default:
av_assert0
(
0
);
...
...
@@ -302,7 +301,7 @@ static av_cold int decode_init(AVCodecContext *avctx)
break
;
case
LOCO_CRGB
:
case
LOCO_RGB
:
avctx
->
pix_fmt
=
AV_PIX_FMT_
BGR24
;
avctx
->
pix_fmt
=
AV_PIX_FMT_
GBRP
;
break
;
case
LOCO_CYV12
:
case
LOCO_YV12
:
...
...
@@ -310,7 +309,7 @@ static av_cold int decode_init(AVCodecContext *avctx)
break
;
case
LOCO_CRGBA
:
case
LOCO_RGBA
:
avctx
->
pix_fmt
=
AV_PIX_FMT_
B
GRA
;
avctx
->
pix_fmt
=
AV_PIX_FMT_G
B
RA
P
;
break
;
default:
av_log
(
avctx
,
AV_LOG_INFO
,
"Unknown colorspace, index = %i
\n
"
,
l
->
mode
);
...
...
This diff is collapsed.
Click to expand it.
tests/ref/fate/loco-rgb
+
5
−
5
View file @
df05fd31
...
...
@@ -3,8 +3,8 @@
#codec_id 0: rawvideo
#dimensions 0: 188x128
#sar 0: 0/1
0, 0, 0, 1, 72192, 0x
1847
500c
0, 1, 1, 1, 72192, 0x
1b0e
2e87
0, 2, 2, 1, 72192, 0x
2932
76c8
0, 3, 3, 1, 72192, 0x
743b
9705
0, 4, 4, 1, 72192, 0x
cc1b
2530
0, 0, 0, 1, 72192, 0x
be9f
500c
0, 1, 1, 1, 72192, 0x
afc8
2e87
0, 2, 2, 1, 72192, 0x
3a24
76c8
0, 3, 3, 1, 72192, 0x
1fda
9705
0, 4, 4, 1, 72192, 0x
46b8
2530
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