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
5290e02a
Commit
5290e02a
authored
Nov 09, 2013
by
Anton Khirnov
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
nuv: use the AVFrame API properly.
parent
d56a114a
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
20 additions
and
17 deletions
+20
-17
nuv.c
libavcodec/nuv.c
+20
-17
No files found.
libavcodec/nuv.c
View file @
5290e02a
...
...
@@ -31,7 +31,7 @@
#include "rtjpeg.h"
typedef
struct
{
AVFrame
pic
;
AVFrame
*
pic
;
int
codec_frameheader
;
int
quality
;
int
width
,
height
;
...
...
@@ -137,7 +137,7 @@ static int codec_reinit(AVCodecContext *avctx, int width, int height,
c
->
decomp_buf
=
ptr
;
ff_rtjpeg_decode_init
(
&
c
->
rtj
,
&
c
->
dsp
,
c
->
width
,
c
->
height
,
c
->
lq
,
c
->
cq
);
av_frame_unref
(
&
c
->
pic
);
av_frame_unref
(
c
->
pic
);
}
else
if
(
quality
!=
c
->
quality
)
ff_rtjpeg_decode_init
(
&
c
->
rtj
,
&
c
->
dsp
,
c
->
width
,
c
->
height
,
c
->
lq
,
c
->
cq
);
...
...
@@ -232,23 +232,23 @@ static int decode_frame(AVCodecContext *avctx, void *data, int *got_frame,
}
if
(
keyframe
)
{
av_frame_unref
(
&
c
->
pic
);
av_frame_unref
(
c
->
pic
);
init_frame
=
1
;
}
result
=
ff_reget_buffer
(
avctx
,
&
c
->
pic
);
result
=
ff_reget_buffer
(
avctx
,
c
->
pic
);
if
(
result
<
0
)
{
av_log
(
avctx
,
AV_LOG_ERROR
,
"get_buffer() failed
\n
"
);
return
result
;
}
if
(
init_frame
)
{
memset
(
c
->
pic
.
data
[
0
],
0
,
avctx
->
height
*
c
->
pic
.
linesize
[
0
]);
memset
(
c
->
pic
.
data
[
1
],
0x80
,
avctx
->
height
*
c
->
pic
.
linesize
[
1
]
/
2
);
memset
(
c
->
pic
.
data
[
2
],
0x80
,
avctx
->
height
*
c
->
pic
.
linesize
[
2
]
/
2
);
memset
(
c
->
pic
->
data
[
0
],
0
,
avctx
->
height
*
c
->
pic
->
linesize
[
0
]);
memset
(
c
->
pic
->
data
[
1
],
0x80
,
avctx
->
height
*
c
->
pic
->
linesize
[
1
]
/
2
);
memset
(
c
->
pic
->
data
[
2
],
0x80
,
avctx
->
height
*
c
->
pic
->
linesize
[
2
]
/
2
);
}
c
->
pic
.
pict_type
=
keyframe
?
AV_PICTURE_TYPE_I
:
AV_PICTURE_TYPE_P
;
c
->
pic
.
key_frame
=
keyframe
;
c
->
pic
->
pict_type
=
keyframe
?
AV_PICTURE_TYPE_I
:
AV_PICTURE_TYPE_P
;
c
->
pic
->
key_frame
=
keyframe
;
// decompress/copy/whatever data
switch
(
comptype
)
{
case
NUV_LZO
:
...
...
@@ -258,19 +258,19 @@ static int decode_frame(AVCodecContext *avctx, void *data, int *got_frame,
av_log
(
avctx
,
AV_LOG_ERROR
,
"uncompressed frame too short
\n
"
);
height
=
buf_size
/
c
->
width
/
3
*
2
;
}
copy_frame
(
&
c
->
pic
,
buf
,
c
->
width
,
height
);
copy_frame
(
c
->
pic
,
buf
,
c
->
width
,
height
);
break
;
}
case
NUV_RTJPEG_IN_LZO
:
case
NUV_RTJPEG
:
ret
=
ff_rtjpeg_decode_frame_yuv420
(
&
c
->
rtj
,
&
c
->
pic
,
buf
,
buf_size
);
ret
=
ff_rtjpeg_decode_frame_yuv420
(
&
c
->
rtj
,
c
->
pic
,
buf
,
buf_size
);
if
(
ret
<
0
)
return
ret
;
break
;
case
NUV_BLACK
:
memset
(
c
->
pic
.
data
[
0
],
0
,
c
->
width
*
c
->
height
);
memset
(
c
->
pic
.
data
[
1
],
128
,
c
->
width
*
c
->
height
/
4
);
memset
(
c
->
pic
.
data
[
2
],
128
,
c
->
width
*
c
->
height
/
4
);
memset
(
c
->
pic
->
data
[
0
],
0
,
c
->
width
*
c
->
height
);
memset
(
c
->
pic
->
data
[
1
],
128
,
c
->
width
*
c
->
height
/
4
);
memset
(
c
->
pic
->
data
[
2
],
128
,
c
->
width
*
c
->
height
/
4
);
break
;
case
NUV_COPY_LAST
:
/* nothing more to do here */
...
...
@@ -280,7 +280,7 @@ static int decode_frame(AVCodecContext *avctx, void *data, int *got_frame,
return
AVERROR_INVALIDDATA
;
}
if
((
result
=
av_frame_ref
(
picture
,
&
c
->
pic
))
<
0
)
if
((
result
=
av_frame_ref
(
picture
,
c
->
pic
))
<
0
)
return
result
;
*
got_frame
=
1
;
...
...
@@ -292,8 +292,11 @@ static av_cold int decode_init(AVCodecContext *avctx)
NuvContext
*
c
=
avctx
->
priv_data
;
int
ret
;
c
->
pic
=
av_frame_alloc
();
if
(
!
c
->
pic
)
return
AVERROR
(
ENOMEM
);
avctx
->
pix_fmt
=
AV_PIX_FMT_YUV420P
;
c
->
pic
.
data
[
0
]
=
NULL
;
c
->
decomp_buf
=
NULL
;
c
->
quality
=
-
1
;
c
->
width
=
0
;
...
...
@@ -317,7 +320,7 @@ static av_cold int decode_end(AVCodecContext *avctx)
NuvContext
*
c
=
avctx
->
priv_data
;
av_freep
(
&
c
->
decomp_buf
);
av_frame_
unref
(
&
c
->
pic
);
av_frame_
free
(
&
c
->
pic
);
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