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
aca21478
Commit
aca21478
authored
Nov 09, 2013
by
Anton Khirnov
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
vmdvideo: use the AVFrame API properly.
parent
3c8ea9d4
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
27 additions
and
21 deletions
+27
-21
vmdav.c
libavcodec/vmdav.c
+27
-21
No files found.
libavcodec/vmdav.c
View file @
aca21478
...
...
@@ -60,7 +60,7 @@
typedef
struct
VmdVideoContext
{
AVCodecContext
*
avctx
;
AVFrame
prev_frame
;
AVFrame
*
prev_frame
;
const
unsigned
char
*
buf
;
int
size
;
...
...
@@ -243,11 +243,11 @@ static int vmd_decode(VmdVideoContext *s, AVFrame *frame)
/* if only a certain region will be updated, copy the entire previous
* frame before the decode */
if
(
s
->
prev_frame
.
data
[
0
]
&&
if
(
s
->
prev_frame
->
data
[
0
]
&&
(
frame_x
||
frame_y
||
(
frame_width
!=
s
->
avctx
->
width
)
||
(
frame_height
!=
s
->
avctx
->
height
)))
{
memcpy
(
frame
->
data
[
0
],
s
->
prev_frame
.
data
[
0
],
memcpy
(
frame
->
data
[
0
],
s
->
prev_frame
->
data
[
0
],
s
->
avctx
->
height
*
frame
->
linesize
[
0
]);
}
...
...
@@ -290,7 +290,7 @@ static int vmd_decode(VmdVideoContext *s, AVFrame *frame)
}
dp
=
&
frame
->
data
[
0
][
frame_y
*
frame
->
linesize
[
0
]
+
frame_x
];
pp
=
&
s
->
prev_frame
.
data
[
0
][
frame_y
*
s
->
prev_frame
.
linesize
[
0
]
+
frame_x
];
pp
=
&
s
->
prev_frame
->
data
[
0
][
frame_y
*
s
->
prev_frame
->
linesize
[
0
]
+
frame_x
];
switch
(
meth
)
{
case
1
:
for
(
i
=
0
;
i
<
frame_height
;
i
++
)
{
...
...
@@ -306,7 +306,7 @@ static int vmd_decode(VmdVideoContext *s, AVFrame *frame)
ofs
+=
len
;
}
else
{
/* interframe pixel copy */
if
(
ofs
+
len
+
1
>
frame_width
||
!
s
->
prev_frame
.
data
[
0
])
if
(
ofs
+
len
+
1
>
frame_width
||
!
s
->
prev_frame
->
data
[
0
])
return
AVERROR_INVALIDDATA
;
memcpy
(
&
dp
[
ofs
],
&
pp
[
ofs
],
len
+
1
);
ofs
+=
len
+
1
;
...
...
@@ -319,7 +319,7 @@ static int vmd_decode(VmdVideoContext *s, AVFrame *frame)
return
AVERROR_INVALIDDATA
;
}
dp
+=
frame
->
linesize
[
0
];
pp
+=
s
->
prev_frame
.
linesize
[
0
];
pp
+=
s
->
prev_frame
->
linesize
[
0
];
}
break
;
...
...
@@ -327,7 +327,7 @@ static int vmd_decode(VmdVideoContext *s, AVFrame *frame)
for
(
i
=
0
;
i
<
frame_height
;
i
++
)
{
bytestream2_get_buffer
(
&
gb
,
dp
,
frame_width
);
dp
+=
frame
->
linesize
[
0
];
pp
+=
s
->
prev_frame
.
linesize
[
0
];
pp
+=
s
->
prev_frame
->
linesize
[
0
];
}
break
;
...
...
@@ -352,7 +352,7 @@ static int vmd_decode(VmdVideoContext *s, AVFrame *frame)
}
}
else
{
/* interframe pixel copy */
if
(
ofs
+
len
+
1
>
frame_width
||
!
s
->
prev_frame
.
data
[
0
])
if
(
ofs
+
len
+
1
>
frame_width
||
!
s
->
prev_frame
->
data
[
0
])
return
AVERROR_INVALIDDATA
;
memcpy
(
&
dp
[
ofs
],
&
pp
[
ofs
],
len
+
1
);
ofs
+=
len
+
1
;
...
...
@@ -365,13 +365,23 @@ static int vmd_decode(VmdVideoContext *s, AVFrame *frame)
return
AVERROR_INVALIDDATA
;
}
dp
+=
frame
->
linesize
[
0
];
pp
+=
s
->
prev_frame
.
linesize
[
0
];
pp
+=
s
->
prev_frame
->
linesize
[
0
];
}
break
;
}
return
0
;
}
static
av_cold
int
vmdvideo_decode_end
(
AVCodecContext
*
avctx
)
{
VmdVideoContext
*
s
=
avctx
->
priv_data
;
av_frame_free
(
&
s
->
prev_frame
);
av_free
(
s
->
unpack_buffer
);
return
0
;
}
static
av_cold
int
vmdvideo_decode_init
(
AVCodecContext
*
avctx
)
{
VmdVideoContext
*
s
=
avctx
->
priv_data
;
...
...
@@ -410,6 +420,12 @@ static av_cold int vmdvideo_decode_init(AVCodecContext *avctx)
palette32
[
i
]
=
(
r
<<
16
)
|
(
g
<<
8
)
|
(
b
);
}
s
->
prev_frame
=
av_frame_alloc
();
if
(
!
s
->
prev_frame
)
{
vmdvideo_decode_end
(
avctx
);
return
AVERROR
(
ENOMEM
);
}
return
0
;
}
...
...
@@ -441,8 +457,8 @@ static int vmdvideo_decode_frame(AVCodecContext *avctx,
memcpy
(
frame
->
data
[
1
],
s
->
palette
,
PALETTE_COUNT
*
4
);
/* shuffle frames */
av_frame_unref
(
&
s
->
prev_frame
);
if
((
ret
=
av_frame_ref
(
&
s
->
prev_frame
,
frame
))
<
0
)
av_frame_unref
(
s
->
prev_frame
);
if
((
ret
=
av_frame_ref
(
s
->
prev_frame
,
frame
))
<
0
)
return
ret
;
*
got_frame
=
1
;
...
...
@@ -451,16 +467,6 @@ static int vmdvideo_decode_frame(AVCodecContext *avctx,
return
buf_size
;
}
static
av_cold
int
vmdvideo_decode_end
(
AVCodecContext
*
avctx
)
{
VmdVideoContext
*
s
=
avctx
->
priv_data
;
av_frame_unref
(
&
s
->
prev_frame
);
av_free
(
s
->
unpack_buffer
);
return
0
;
}
/*
* Audio Decoder
...
...
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