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
698d5eb5
Commit
698d5eb5
authored
Feb 01, 2018
by
Jérôme Martinez
Committed by
Michael Niedermayer
Feb 06, 2018
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
avcodec/ffv1: Support for RGBA64 and GBRAP16
Signed-off-by:
Michael Niedermayer
<
michael@niedermayer.cc
>
parent
204c7caf
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
41 additions
and
12 deletions
+41
-12
ffv1dec.c
libavcodec/ffv1dec.c
+10
-4
ffv1dec_template.c
libavcodec/ffv1dec_template.c
+7
-2
ffv1enc.c
libavcodec/ffv1enc.c
+14
-2
ffv1enc_template.c
libavcodec/ffv1enc_template.c
+10
-4
No files found.
libavcodec/ffv1dec.c
View file @
698d5eb5
...
...
@@ -336,14 +336,16 @@ static int decode_slice(AVCodecContext *c, void *arg)
decode_plane
(
fs
,
p
->
data
[
0
]
+
ps
*
x
+
y
*
p
->
linesize
[
0
]
,
width
,
height
,
p
->
linesize
[
0
],
0
,
2
);
decode_plane
(
fs
,
p
->
data
[
0
]
+
ps
*
x
+
y
*
p
->
linesize
[
0
]
+
1
,
width
,
height
,
p
->
linesize
[
0
],
1
,
2
);
}
else
if
(
f
->
use32bit
)
{
uint8_t
*
planes
[
3
]
=
{
p
->
data
[
0
]
+
ps
*
x
+
y
*
p
->
linesize
[
0
],
uint8_t
*
planes
[
4
]
=
{
p
->
data
[
0
]
+
ps
*
x
+
y
*
p
->
linesize
[
0
],
p
->
data
[
1
]
+
ps
*
x
+
y
*
p
->
linesize
[
1
],
p
->
data
[
2
]
+
ps
*
x
+
y
*
p
->
linesize
[
2
]
};
p
->
data
[
2
]
+
ps
*
x
+
y
*
p
->
linesize
[
2
],
p
->
data
[
3
]
+
ps
*
x
+
y
*
p
->
linesize
[
3
]
};
decode_rgb_frame32
(
fs
,
planes
,
width
,
height
,
p
->
linesize
);
}
else
{
uint8_t
*
planes
[
3
]
=
{
p
->
data
[
0
]
+
ps
*
x
+
y
*
p
->
linesize
[
0
],
uint8_t
*
planes
[
4
]
=
{
p
->
data
[
0
]
+
ps
*
x
+
y
*
p
->
linesize
[
0
],
p
->
data
[
1
]
+
ps
*
x
+
y
*
p
->
linesize
[
1
],
p
->
data
[
2
]
+
ps
*
x
+
y
*
p
->
linesize
[
2
]
};
p
->
data
[
2
]
+
ps
*
x
+
y
*
p
->
linesize
[
2
],
p
->
data
[
3
]
+
ps
*
x
+
y
*
p
->
linesize
[
3
]
};
decode_rgb_frame
(
fs
,
planes
,
width
,
height
,
p
->
linesize
);
}
if
(
fs
->
ac
!=
AC_GOLOMB_RICE
&&
f
->
version
>
2
)
{
...
...
@@ -694,6 +696,10 @@ static int read_header(FFV1Context *f)
f
->
avctx
->
pix_fmt
=
AV_PIX_FMT_GBRP16
;
f
->
use32bit
=
1
;
}
else
if
(
f
->
avctx
->
bits_per_raw_sample
==
16
&&
f
->
transparency
)
{
f
->
avctx
->
pix_fmt
=
AV_PIX_FMT_GBRAP16
;
f
->
use32bit
=
1
;
}
}
else
{
av_log
(
f
->
avctx
,
AV_LOG_ERROR
,
"colorspace not supported
\n
"
);
return
AVERROR
(
ENOSYS
);
...
...
libavcodec/ffv1dec_template.c
View file @
698d5eb5
...
...
@@ -107,13 +107,14 @@ static av_always_inline int RENAME(decode_line)(FFV1Context *s, int w,
return
0
;
}
static
void
RENAME
(
decode_rgb_frame
)(
FFV1Context
*
s
,
uint8_t
*
src
[
3
],
int
w
,
int
h
,
int
stride
[
3
])
static
void
RENAME
(
decode_rgb_frame
)(
FFV1Context
*
s
,
uint8_t
*
src
[
4
],
int
w
,
int
h
,
int
stride
[
4
])
{
int
x
,
y
,
p
;
TYPE
*
sample
[
4
][
2
];
int
lbd
=
s
->
avctx
->
bits_per_raw_sample
<=
8
;
int
bits
=
s
->
avctx
->
bits_per_raw_sample
>
0
?
s
->
avctx
->
bits_per_raw_sample
:
8
;
int
offset
=
1
<<
bits
;
int
transparency
=
s
->
transparency
;
for
(
x
=
0
;
x
<
4
;
x
++
)
{
sample
[
x
][
0
]
=
RENAME
(
s
->
sample_buffer
)
+
x
*
2
*
(
w
+
6
)
+
3
;
...
...
@@ -125,7 +126,7 @@ static void RENAME(decode_rgb_frame)(FFV1Context *s, uint8_t *src[3], int w, int
memset
(
RENAME
(
s
->
sample_buffer
),
0
,
8
*
(
w
+
6
)
*
sizeof
(
*
RENAME
(
s
->
sample_buffer
)));
for
(
y
=
0
;
y
<
h
;
y
++
)
{
for
(
p
=
0
;
p
<
3
+
s
->
transparency
;
p
++
)
{
for
(
p
=
0
;
p
<
3
+
transparency
;
p
++
)
{
TYPE
*
temp
=
sample
[
p
][
0
];
// FIXME: try a normal buffer
sample
[
p
][
0
]
=
sample
[
p
][
1
];
...
...
@@ -158,10 +159,14 @@ static void RENAME(decode_rgb_frame)(FFV1Context *s, uint8_t *src[3], int w, int
*
((
uint16_t
*
)(
src
[
0
]
+
x
*
2
+
stride
[
0
]
*
y
))
=
g
;
*
((
uint16_t
*
)(
src
[
1
]
+
x
*
2
+
stride
[
1
]
*
y
))
=
b
;
*
((
uint16_t
*
)(
src
[
2
]
+
x
*
2
+
stride
[
2
]
*
y
))
=
r
;
if
(
transparency
)
*
((
uint16_t
*
)(
src
[
3
]
+
x
*
2
+
stride
[
3
]
*
y
))
=
a
;
}
else
{
*
((
uint16_t
*
)(
src
[
0
]
+
x
*
2
+
stride
[
0
]
*
y
))
=
b
;
*
((
uint16_t
*
)(
src
[
1
]
+
x
*
2
+
stride
[
1
]
*
y
))
=
g
;
*
((
uint16_t
*
)(
src
[
2
]
+
x
*
2
+
stride
[
2
]
*
y
))
=
r
;
if
(
transparency
)
*
((
uint16_t
*
)(
src
[
3
]
+
x
*
2
+
stride
[
3
]
*
y
))
=
a
;
}
}
}
...
...
libavcodec/ffv1enc.c
View file @
698d5eb5
...
...
@@ -624,6 +624,14 @@ FF_ENABLE_DEPRECATION_WARNINGS
s
->
chroma_planes
=
1
;
s
->
bits_per_raw_sample
=
8
;
break
;
case
AV_PIX_FMT_RGBA64
:
s
->
colorspace
=
1
;
s
->
transparency
=
1
;
s
->
chroma_planes
=
1
;
s
->
bits_per_raw_sample
=
16
;
s
->
use32bit
=
1
;
s
->
version
=
FFMAX
(
s
->
version
,
1
);
break
;
case
AV_PIX_FMT_RGB48
:
s
->
colorspace
=
1
;
s
->
chroma_planes
=
1
;
...
...
@@ -649,10 +657,12 @@ FF_ENABLE_DEPRECATION_WARNINGS
if
(
!
avctx
->
bits_per_raw_sample
&&
!
s
->
bits_per_raw_sample
)
s
->
bits_per_raw_sample
=
14
;
case
AV_PIX_FMT_GBRP16
:
case
AV_PIX_FMT_GBRAP16
:
if
(
!
avctx
->
bits_per_raw_sample
&&
!
s
->
bits_per_raw_sample
)
s
->
bits_per_raw_sample
=
16
;
else
if
(
!
s
->
bits_per_raw_sample
)
s
->
bits_per_raw_sample
=
avctx
->
bits_per_raw_sample
;
s
->
transparency
=
desc
->
nb_components
==
4
||
desc
->
nb_components
==
2
;
s
->
colorspace
=
1
;
s
->
chroma_planes
=
1
;
if
(
s
->
bits_per_raw_sample
>=
16
)
{
...
...
@@ -1024,9 +1034,10 @@ static int encode_slice(AVCodecContext *c, void *arg)
const
int
ps
=
av_pix_fmt_desc_get
(
c
->
pix_fmt
)
->
comp
[
0
].
step
;
int
ret
;
RangeCoder
c_bak
=
fs
->
c
;
const
uint8_t
*
planes
[
3
]
=
{
p
->
data
[
0
]
+
ps
*
x
+
y
*
p
->
linesize
[
0
],
const
uint8_t
*
planes
[
4
]
=
{
p
->
data
[
0
]
+
ps
*
x
+
y
*
p
->
linesize
[
0
],
p
->
data
[
1
]
?
p
->
data
[
1
]
+
ps
*
x
+
y
*
p
->
linesize
[
1
]
:
NULL
,
p
->
data
[
2
]
?
p
->
data
[
2
]
+
ps
*
x
+
y
*
p
->
linesize
[
2
]
:
NULL
};
p
->
data
[
2
]
?
p
->
data
[
2
]
+
ps
*
x
+
y
*
p
->
linesize
[
2
]
:
NULL
,
p
->
data
[
3
]
?
p
->
data
[
3
]
+
ps
*
x
+
y
*
p
->
linesize
[
3
]
:
NULL
};
fs
->
slice_coding_mode
=
0
;
if
(
f
->
version
>
3
)
{
...
...
@@ -1318,6 +1329,7 @@ AVCodec ff_ffv1_encoder = {
AV_PIX_FMT_YA8
,
AV_PIX_FMT_GRAY10
,
AV_PIX_FMT_GRAY12
,
AV_PIX_FMT_GBRP16
,
AV_PIX_FMT_RGB48
,
AV_PIX_FMT_GBRAP16
,
AV_PIX_FMT_RGBA64
,
AV_PIX_FMT_NONE
},
...
...
libavcodec/ffv1enc_template.c
View file @
698d5eb5
...
...
@@ -122,8 +122,8 @@ static av_always_inline int RENAME(encode_line)(FFV1Context *s, int w,
return
0
;
}
static
int
RENAME
(
encode_rgb_frame
)(
FFV1Context
*
s
,
const
uint8_t
*
src
[
3
],
int
w
,
int
h
,
const
int
stride
[
3
])
static
int
RENAME
(
encode_rgb_frame
)(
FFV1Context
*
s
,
const
uint8_t
*
src
[
4
],
int
w
,
int
h
,
const
int
stride
[
4
])
{
int
x
,
y
,
p
,
i
;
const
int
ring_size
=
s
->
context_model
?
3
:
2
;
...
...
@@ -132,6 +132,8 @@ static int RENAME(encode_rgb_frame)(FFV1Context *s, const uint8_t *src[3],
int
packed
=
!
src
[
1
];
int
bits
=
s
->
bits_per_raw_sample
>
0
?
s
->
bits_per_raw_sample
:
8
;
int
offset
=
1
<<
bits
;
int
transparency
=
s
->
transparency
;
int
packed_size
=
(
3
+
transparency
)
*
2
;
s
->
run_index
=
0
;
...
...
@@ -152,14 +154,18 @@ static int RENAME(encode_rgb_frame)(FFV1Context *s, const uint8_t *src[3],
r
=
(
v
>>
16
)
&
0xFF
;
a
=
v
>>
24
;
}
else
if
(
packed
)
{
const
uint16_t
*
p
=
((
const
uint16_t
*
)(
src
[
0
]
+
x
*
6
+
stride
[
0
]
*
y
));
const
uint16_t
*
p
=
((
const
uint16_t
*
)(
src
[
0
]
+
x
*
packed_size
+
stride
[
0
]
*
y
));
r
=
p
[
0
];
g
=
p
[
1
];
b
=
p
[
2
];
if
(
transparency
)
a
=
p
[
3
];
}
else
if
(
sizeof
(
TYPE
)
==
4
)
{
g
=
*
((
const
uint16_t
*
)(
src
[
0
]
+
x
*
2
+
stride
[
0
]
*
y
));
b
=
*
((
const
uint16_t
*
)(
src
[
1
]
+
x
*
2
+
stride
[
1
]
*
y
));
r
=
*
((
const
uint16_t
*
)(
src
[
2
]
+
x
*
2
+
stride
[
2
]
*
y
));
if
(
transparency
)
a
=
*
((
const
uint16_t
*
)(
src
[
3
]
+
x
*
2
+
stride
[
3
]
*
y
));
}
else
{
b
=
*
((
const
uint16_t
*
)(
src
[
0
]
+
x
*
2
+
stride
[
0
]
*
y
));
g
=
*
((
const
uint16_t
*
)(
src
[
1
]
+
x
*
2
+
stride
[
1
]
*
y
));
...
...
@@ -179,7 +185,7 @@ static int RENAME(encode_rgb_frame)(FFV1Context *s, const uint8_t *src[3],
sample
[
2
][
0
][
x
]
=
r
;
sample
[
3
][
0
][
x
]
=
a
;
}
for
(
p
=
0
;
p
<
3
+
s
->
transparency
;
p
++
)
{
for
(
p
=
0
;
p
<
3
+
transparency
;
p
++
)
{
int
ret
;
sample
[
p
][
0
][
-
1
]
=
sample
[
p
][
1
][
0
];
sample
[
p
][
1
][
w
]
=
sample
[
p
][
1
][
w
-
1
];
...
...
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