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
95db8c75
Commit
95db8c75
authored
Mar 29, 2016
by
Vittorio Giovara
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
screenpresso: Add extended pixel format support
Signed-off-by:
Vittorio Giovara
<
vittorio.giovara@gmail.com
>
parent
b5f47d95
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
31 additions
and
15 deletions
+31
-15
screenpresso.c
libavcodec/screenpresso.c
+31
-15
No files found.
libavcodec/screenpresso.c
View file @
95db8c75
...
@@ -30,7 +30,7 @@
...
@@ -30,7 +30,7 @@
* rebuilt frame (not the reference), and since there is no coordinate system
* rebuilt frame (not the reference), and since there is no coordinate system
* they contain exactly as many pixel as the keyframe.
* they contain exactly as many pixel as the keyframe.
*
*
* Supports: BGR
24
* Supports: BGR
A, BGR24, RGB555
*/
*/
#include <stdint.h>
#include <stdint.h>
...
@@ -79,10 +79,8 @@ static av_cold int screenpresso_init(AVCodecContext *avctx)
...
@@ -79,10 +79,8 @@ static av_cold int screenpresso_init(AVCodecContext *avctx)
if
(
!
ctx
->
current
)
if
(
!
ctx
->
current
)
return
AVERROR
(
ENOMEM
);
return
AVERROR
(
ENOMEM
);
avctx
->
pix_fmt
=
AV_PIX_FMT_BGR24
;
/* Allocate maximum size possible, a full RGBA frame */
ctx
->
inflated_size
=
avctx
->
width
*
avctx
->
height
*
4
;
/* Allocate maximum size possible, a full frame */
ctx
->
inflated_size
=
avctx
->
width
*
avctx
->
height
*
3
;
ctx
->
inflated_buf
=
av_malloc
(
ctx
->
inflated_size
);
ctx
->
inflated_buf
=
av_malloc
(
ctx
->
inflated_size
);
if
(
!
ctx
->
inflated_buf
)
if
(
!
ctx
->
inflated_buf
)
return
AVERROR
(
ENOMEM
);
return
AVERROR
(
ENOMEM
);
...
@@ -108,7 +106,7 @@ static int screenpresso_decode_frame(AVCodecContext *avctx, void *data,
...
@@ -108,7 +106,7 @@ static int screenpresso_decode_frame(AVCodecContext *avctx, void *data,
ScreenpressoContext
*
ctx
=
avctx
->
priv_data
;
ScreenpressoContext
*
ctx
=
avctx
->
priv_data
;
AVFrame
*
frame
=
data
;
AVFrame
*
frame
=
data
;
uLongf
length
=
ctx
->
inflated_size
;
uLongf
length
=
ctx
->
inflated_size
;
int
keyframe
;
int
keyframe
,
component_size
,
src_linesize
;
int
ret
;
int
ret
;
/* Size check */
/* Size check */
...
@@ -118,13 +116,28 @@ static int screenpresso_decode_frame(AVCodecContext *avctx, void *data,
...
@@ -118,13 +116,28 @@ static int screenpresso_decode_frame(AVCodecContext *avctx, void *data,
}
}
/* Basic sanity check, but not really harmful */
/* Basic sanity check, but not really harmful */
if
((
avpkt
->
data
[
0
]
!=
0x73
&&
avpkt
->
data
[
0
]
!=
0x72
)
||
if
(
avpkt
->
data
[
0
]
!=
0x73
&&
avpkt
->
data
[
0
]
!=
0x72
)
avpkt
->
data
[
1
]
!=
8
)
{
// bpp probably
av_log
(
avctx
,
AV_LOG_WARNING
,
"Unknown header 0x%02X
\n
"
,
avpkt
->
data
[
0
]);
av_log
(
avctx
,
AV_LOG_WARNING
,
"Unknown header 0x%02X%02X
\n
"
,
avpkt
->
data
[
0
],
avpkt
->
data
[
1
]);
}
keyframe
=
(
avpkt
->
data
[
0
]
==
0x73
);
keyframe
=
(
avpkt
->
data
[
0
]
==
0x73
);
/* Pixel size */
component_size
=
((
avpkt
->
data
[
1
]
>>
2
)
&
0x03
)
+
1
;
switch
(
component_size
)
{
case
2
:
avctx
->
pix_fmt
=
AV_PIX_FMT_RGB555LE
;
break
;
case
3
:
avctx
->
pix_fmt
=
AV_PIX_FMT_BGR24
;
break
;
case
4
:
avctx
->
pix_fmt
=
AV_PIX_FMT_BGRA
;
break
;
default:
av_log
(
avctx
,
AV_LOG_ERROR
,
"Invalid bits per pixel value (%d)
\n
"
,
component_size
);
return
AVERROR_INVALIDDATA
;
}
/* Inflate the frame after the 2 byte header */
/* Inflate the frame after the 2 byte header */
ret
=
uncompress
(
ctx
->
inflated_buf
,
&
length
,
ret
=
uncompress
(
ctx
->
inflated_buf
,
&
length
,
avpkt
->
data
+
2
,
avpkt
->
size
-
2
);
avpkt
->
data
+
2
,
avpkt
->
size
-
2
);
...
@@ -137,18 +150,21 @@ static int screenpresso_decode_frame(AVCodecContext *avctx, void *data,
...
@@ -137,18 +150,21 @@ static int screenpresso_decode_frame(AVCodecContext *avctx, void *data,
if
(
ret
<
0
)
if
(
ret
<
0
)
return
ret
;
return
ret
;
/* Codec has aligned strides */
src_linesize
=
FFALIGN
(
avctx
->
width
*
component_size
,
4
);
/* When a keyframe is found, copy it (flipped) */
/* When a keyframe is found, copy it (flipped) */
if
(
keyframe
)
if
(
keyframe
)
av_image_copy_plane
(
ctx
->
current
->
data
[
0
]
+
av_image_copy_plane
(
ctx
->
current
->
data
[
0
]
+
ctx
->
current
->
linesize
[
0
]
*
(
avctx
->
height
-
1
),
ctx
->
current
->
linesize
[
0
]
*
(
avctx
->
height
-
1
),
-
1
*
ctx
->
current
->
linesize
[
0
],
-
1
*
ctx
->
current
->
linesize
[
0
],
ctx
->
inflated_buf
,
avctx
->
width
*
3
,
ctx
->
inflated_buf
,
src_linesize
,
avctx
->
width
*
3
,
avctx
->
height
);
avctx
->
width
*
component_size
,
avctx
->
height
);
/* Otherwise sum the delta on top of the current frame */
/* Otherwise sum the delta on top of the current frame */
else
else
sum_delta_flipped
(
ctx
->
current
->
data
[
0
],
ctx
->
current
->
linesize
[
0
],
sum_delta_flipped
(
ctx
->
current
->
data
[
0
],
ctx
->
current
->
linesize
[
0
],
ctx
->
inflated_buf
,
avctx
->
width
*
3
,
ctx
->
inflated_buf
,
src_linesize
,
avctx
->
width
*
3
,
avctx
->
height
);
avctx
->
width
*
component_size
,
avctx
->
height
);
/* Frame is ready to be output */
/* Frame is ready to be output */
ret
=
av_frame_ref
(
frame
,
ctx
->
current
);
ret
=
av_frame_ref
(
frame
,
ctx
->
current
);
...
...
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