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
d60f090d
Commit
d60f090d
authored
8 years ago
by
Paul B Mahol
Browse files
Options
Downloads
Patches
Plain Diff
avcodec/fraps: add support for PAL8
Signed-off-by:
Paul B Mahol
<
onemda@gmail.com
>
parent
cde007dc
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/fraps.c
+27
-2
27 additions, 2 deletions
libavcodec/fraps.c
with
27 additions
and
2 deletions
libavcodec/fraps.c
+
27
−
2
View file @
d60f090d
...
@@ -146,6 +146,7 @@ static int decode_frame(AVCodecContext *avctx,
...
@@ -146,6 +146,7 @@ static int decode_frame(AVCodecContext *avctx,
uint32_t
offs
[
4
];
uint32_t
offs
[
4
];
int
i
,
j
,
ret
,
is_chroma
;
int
i
,
j
,
ret
,
is_chroma
;
const
int
planes
=
3
;
const
int
planes
=
3
;
int
is_pal
;
uint8_t
*
out
;
uint8_t
*
out
;
if
(
buf_size
<
4
)
{
if
(
buf_size
<
4
)
{
...
@@ -155,6 +156,7 @@ static int decode_frame(AVCodecContext *avctx,
...
@@ -155,6 +156,7 @@ static int decode_frame(AVCodecContext *avctx,
header
=
AV_RL32
(
buf
);
header
=
AV_RL32
(
buf
);
version
=
header
&
0xff
;
version
=
header
&
0xff
;
is_pal
=
buf
[
1
]
==
2
&&
version
==
1
;
header_size
=
(
header
&
(
1
<<
30
))
?
8
:
4
;
/* bit 30 means pad to 8 bytes */
header_size
=
(
header
&
(
1
<<
30
))
?
8
:
4
;
/* bit 30 means pad to 8 bytes */
if
(
version
>
5
)
{
if
(
version
>
5
)
{
...
@@ -166,7 +168,16 @@ static int decode_frame(AVCodecContext *avctx,
...
@@ -166,7 +168,16 @@ static int decode_frame(AVCodecContext *avctx,
buf
+=
header_size
;
buf
+=
header_size
;
if
(
version
<
2
)
{
if
(
is_pal
)
{
unsigned
needed_size
=
avctx
->
width
*
avctx
->
height
+
1024
;
needed_size
+=
header_size
;
if
(
buf_size
!=
needed_size
)
{
av_log
(
avctx
,
AV_LOG_ERROR
,
"Invalid frame length %d (should be %d)
\n
"
,
buf_size
,
needed_size
);
return
AVERROR_INVALIDDATA
;
}
}
else
if
(
version
<
2
)
{
unsigned
needed_size
=
avctx
->
width
*
avctx
->
height
*
3
;
unsigned
needed_size
=
avctx
->
width
*
avctx
->
height
*
3
;
if
(
version
==
0
)
needed_size
/=
2
;
if
(
version
==
0
)
needed_size
/=
2
;
needed_size
+=
header_size
;
needed_size
+=
header_size
;
...
@@ -209,7 +220,7 @@ static int decode_frame(AVCodecContext *avctx,
...
@@ -209,7 +220,7 @@ static int decode_frame(AVCodecContext *avctx,
f
->
pict_type
=
AV_PICTURE_TYPE_I
;
f
->
pict_type
=
AV_PICTURE_TYPE_I
;
f
->
key_frame
=
1
;
f
->
key_frame
=
1
;
avctx
->
pix_fmt
=
version
&
1
?
AV_PIX_FMT_BGR24
:
AV_PIX_FMT_YUVJ420P
;
avctx
->
pix_fmt
=
version
&
1
?
is_pal
?
AV_PIX_FMT_PAL8
:
AV_PIX_FMT_BGR24
:
AV_PIX_FMT_YUVJ420P
;
avctx
->
color_range
=
version
&
1
?
AVCOL_RANGE_UNSPECIFIED
avctx
->
color_range
=
version
&
1
?
AVCOL_RANGE_UNSPECIFIED
:
AVCOL_RANGE_JPEG
;
:
AVCOL_RANGE_JPEG
;
avctx
->
colorspace
=
version
&
1
?
AVCOL_SPC_UNSPECIFIED
:
AVCOL_SPC_BT709
;
avctx
->
colorspace
=
version
&
1
?
AVCOL_SPC_UNSPECIFIED
:
AVCOL_SPC_BT709
;
...
@@ -245,11 +256,25 @@ static int decode_frame(AVCodecContext *avctx,
...
@@ -245,11 +256,25 @@ static int decode_frame(AVCodecContext *avctx,
break
;
break
;
case
1
:
case
1
:
if
(
is_pal
)
{
uint32_t
*
pal
=
(
uint32_t
*
)
f
->
data
[
1
];
for
(
y
=
0
;
y
<
256
;
y
++
)
{
pal
[
y
]
=
AV_RL32
(
buf
)
|
0xFF000000
;
buf
+=
4
;
}
for
(
y
=
0
;
y
<
avctx
->
height
;
y
++
)
memcpy
(
&
f
->
data
[
0
][
y
*
f
->
linesize
[
0
]],
&
buf
[
y
*
avctx
->
width
],
avctx
->
width
);
}
else
{
/* Fraps v1 is an upside-down BGR24 */
/* Fraps v1 is an upside-down BGR24 */
for
(
y
=
0
;
y
<
avctx
->
height
;
y
++
)
for
(
y
=
0
;
y
<
avctx
->
height
;
y
++
)
memcpy
(
&
f
->
data
[
0
][(
avctx
->
height
-
y
-
1
)
*
f
->
linesize
[
0
]],
memcpy
(
&
f
->
data
[
0
][(
avctx
->
height
-
y
-
1
)
*
f
->
linesize
[
0
]],
&
buf
[
y
*
avctx
->
width
*
3
],
&
buf
[
y
*
avctx
->
width
*
3
],
3
*
avctx
->
width
);
3
*
avctx
->
width
);
}
break
;
break
;
case
2
:
case
2
:
...
...
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