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
04f30711
Commit
04f30711
authored
11 years ago
by
Anton Khirnov
Browse files
Options
Downloads
Patches
Plain Diff
xan: use the AVFrame API properly.
parent
f3cd23fb
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/xan.c
+23
-17
23 additions, 17 deletions
libavcodec/xan.c
with
23 additions
and
17 deletions
libavcodec/xan.c
+
23
−
17
View file @
04f30711
...
...
@@ -52,7 +52,7 @@
typedef
struct
XanContext
{
AVCodecContext
*
avctx
;
AVFrame
last_frame
;
AVFrame
*
last_frame
;
const
unsigned
char
*
buf
;
int
size
;
...
...
@@ -71,6 +71,19 @@ typedef struct XanContext {
}
XanContext
;
static
av_cold
int
xan_decode_end
(
AVCodecContext
*
avctx
)
{
XanContext
*
s
=
avctx
->
priv_data
;
av_frame_free
(
&
s
->
last_frame
);
av_freep
(
&
s
->
buffer1
);
av_freep
(
&
s
->
buffer2
);
av_freep
(
&
s
->
palettes
);
return
0
;
}
static
av_cold
int
xan_decode_init
(
AVCodecContext
*
avctx
)
{
XanContext
*
s
=
avctx
->
priv_data
;
...
...
@@ -91,6 +104,12 @@ static av_cold int xan_decode_init(AVCodecContext *avctx)
return
AVERROR
(
ENOMEM
);
}
s
->
last_frame
=
av_frame_alloc
();
if
(
!
s
->
last_frame
)
{
xan_decode_end
(
avctx
);
return
AVERROR
(
ENOMEM
);
}
return
0
;
}
...
...
@@ -234,7 +253,7 @@ static inline void xan_wc3_copy_pixel_run(XanContext *s, AVFrame *frame,
return
;
palette_plane
=
frame
->
data
[
0
];
prev_palette_plane
=
s
->
last_frame
.
data
[
0
];
prev_palette_plane
=
s
->
last_frame
->
data
[
0
];
if
(
!
prev_palette_plane
)
prev_palette_plane
=
palette_plane
;
stride
=
frame
->
linesize
[
0
];
...
...
@@ -582,8 +601,8 @@ static int xan_decode_frame(AVCodecContext *avctx,
if
(
xan_wc3_decode_frame
(
s
,
frame
)
<
0
)
return
AVERROR_INVALIDDATA
;
av_frame_unref
(
&
s
->
last_frame
);
if
((
ret
=
av_frame_ref
(
&
s
->
last_frame
,
frame
))
<
0
)
av_frame_unref
(
s
->
last_frame
);
if
((
ret
=
av_frame_ref
(
s
->
last_frame
,
frame
))
<
0
)
return
ret
;
*
got_frame
=
1
;
...
...
@@ -592,19 +611,6 @@ static int xan_decode_frame(AVCodecContext *avctx,
return
buf_size
;
}
static
av_cold
int
xan_decode_end
(
AVCodecContext
*
avctx
)
{
XanContext
*
s
=
avctx
->
priv_data
;
av_frame_unref
(
&
s
->
last_frame
);
av_freep
(
&
s
->
buffer1
);
av_freep
(
&
s
->
buffer2
);
av_freep
(
&
s
->
palettes
);
return
0
;
}
AVCodec
ff_xan_wc3_decoder
=
{
.
name
=
"xan_wc3"
,
.
long_name
=
NULL_IF_CONFIG_SMALL
(
"Wing Commander III / Xan"
),
...
...
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