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
5c96f029
Commit
5c96f029
authored
Nov 09, 2013
by
Anton Khirnov
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
mmvideo: use the AVFrame API properly.
parent
2e09096d
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
14 additions
and
12 deletions
+14
-12
mmvideo.c
libavcodec/mmvideo.c
+14
-12
No files found.
libavcodec/mmvideo.c
View file @
5c96f029
...
...
@@ -48,7 +48,7 @@
typedef
struct
MmContext
{
AVCodecContext
*
avctx
;
AVFrame
frame
;
AVFrame
*
frame
;
int
palette
[
AVPALETTE_COUNT
];
GetByteContext
gb
;
}
MmContext
;
...
...
@@ -61,7 +61,9 @@ static av_cold int mm_decode_init(AVCodecContext *avctx)
avctx
->
pix_fmt
=
AV_PIX_FMT_PAL8
;
avcodec_get_frame_defaults
(
&
s
->
frame
);
s
->
frame
=
av_frame_alloc
();
if
(
!
s
->
frame
)
return
AVERROR
(
ENOMEM
);
return
0
;
}
...
...
@@ -105,9 +107,9 @@ static int mm_decode_intra(MmContext * s, int half_horiz, int half_vert)
run_length
*=
2
;
if
(
color
)
{
memset
(
s
->
frame
.
data
[
0
]
+
y
*
s
->
frame
.
linesize
[
0
]
+
x
,
color
,
run_length
);
memset
(
s
->
frame
->
data
[
0
]
+
y
*
s
->
frame
->
linesize
[
0
]
+
x
,
color
,
run_length
);
if
(
half_vert
)
memset
(
s
->
frame
.
data
[
0
]
+
(
y
+
1
)
*
s
->
frame
.
linesize
[
0
]
+
x
,
color
,
run_length
);
memset
(
s
->
frame
->
data
[
0
]
+
(
y
+
1
)
*
s
->
frame
->
linesize
[
0
]
+
x
,
color
,
run_length
);
}
x
+=
run_length
;
...
...
@@ -154,13 +156,13 @@ static int mm_decode_inter(MmContext * s, int half_horiz, int half_vert)
int
replace
=
(
replace_array
>>
(
7
-
j
))
&
1
;
if
(
replace
)
{
int
color
=
bytestream2_get_byte
(
&
data_ptr
);
s
->
frame
.
data
[
0
][
y
*
s
->
frame
.
linesize
[
0
]
+
x
]
=
color
;
s
->
frame
->
data
[
0
][
y
*
s
->
frame
->
linesize
[
0
]
+
x
]
=
color
;
if
(
half_horiz
)
s
->
frame
.
data
[
0
][
y
*
s
->
frame
.
linesize
[
0
]
+
x
+
1
]
=
color
;
s
->
frame
->
data
[
0
][
y
*
s
->
frame
->
linesize
[
0
]
+
x
+
1
]
=
color
;
if
(
half_vert
)
{
s
->
frame
.
data
[
0
][(
y
+
1
)
*
s
->
frame
.
linesize
[
0
]
+
x
]
=
color
;
s
->
frame
->
data
[
0
][(
y
+
1
)
*
s
->
frame
->
linesize
[
0
]
+
x
]
=
color
;
if
(
half_horiz
)
s
->
frame
.
data
[
0
][(
y
+
1
)
*
s
->
frame
.
linesize
[
0
]
+
x
+
1
]
=
color
;
s
->
frame
->
data
[
0
][(
y
+
1
)
*
s
->
frame
->
linesize
[
0
]
+
x
+
1
]
=
color
;
}
}
x
+=
1
+
half_horiz
;
...
...
@@ -189,7 +191,7 @@ static int mm_decode_frame(AVCodecContext *avctx,
buf_size
-=
MM_PREAMBLE_SIZE
;
bytestream2_init
(
&
s
->
gb
,
buf
,
buf_size
);
if
((
res
=
ff_reget_buffer
(
avctx
,
&
s
->
frame
))
<
0
)
{
if
((
res
=
ff_reget_buffer
(
avctx
,
s
->
frame
))
<
0
)
{
av_log
(
avctx
,
AV_LOG_ERROR
,
"reget_buffer() failed
\n
"
);
return
res
;
}
...
...
@@ -209,9 +211,9 @@ static int mm_decode_frame(AVCodecContext *avctx,
if
(
res
<
0
)
return
res
;
memcpy
(
s
->
frame
.
data
[
1
],
s
->
palette
,
AVPALETTE_SIZE
);
memcpy
(
s
->
frame
->
data
[
1
],
s
->
palette
,
AVPALETTE_SIZE
);
if
((
res
=
av_frame_ref
(
data
,
&
s
->
frame
))
<
0
)
if
((
res
=
av_frame_ref
(
data
,
s
->
frame
))
<
0
)
return
res
;
*
got_frame
=
1
;
...
...
@@ -223,7 +225,7 @@ static av_cold int mm_decode_end(AVCodecContext *avctx)
{
MmContext
*
s
=
avctx
->
priv_data
;
av_frame_
unref
(
&
s
->
frame
);
av_frame_
free
(
&
s
->
frame
);
return
0
;
}
...
...
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