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
863a670e
Commit
863a670e
authored
Nov 09, 2013
by
Anton Khirnov
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
pcxenc: use the AVFrame API properly.
parent
7ca97aa7
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
15 additions
and
17 deletions
+15
-17
pcxenc.c
libavcodec/pcxenc.c
+15
-17
No files found.
libavcodec/pcxenc.c
View file @
863a670e
...
...
@@ -30,19 +30,23 @@
#include "bytestream.h"
#include "internal.h"
typedef
struct
PCXContext
{
AVFrame
picture
;
}
PCXContext
;
static
const
uint32_t
monoblack_pal
[
16
]
=
{
0x000000
,
0xFFFFFF
};
static
av_cold
int
pcx_encode_init
(
AVCodecContext
*
avctx
)
{
PCXContext
*
s
=
avctx
->
priv_data
;
avctx
->
coded_frame
=
av_frame_alloc
();
if
(
!
avctx
->
coded_frame
)
return
AVERROR
(
ENOMEM
);
avctx
->
coded_frame
->
pict_type
=
AV_PICTURE_TYPE_I
;
avctx
->
coded_frame
->
key_frame
=
1
;
avcodec_get_frame_defaults
(
&
s
->
picture
)
;
avctx
->
coded_frame
=
&
s
->
picture
;
return
0
;
}
static
av_cold
int
pcx_encode_close
(
AVCodecContext
*
avctx
)
{
av_frame_free
(
&
avctx
->
coded_frame
);
return
0
;
}
...
...
@@ -99,8 +103,6 @@ static int pcx_rle_encode( uint8_t *dst, int dst_size,
static
int
pcx_encode_frame
(
AVCodecContext
*
avctx
,
AVPacket
*
pkt
,
const
AVFrame
*
frame
,
int
*
got_packet
)
{
PCXContext
*
s
=
avctx
->
priv_data
;
AVFrame
*
const
pict
=
&
s
->
picture
;
const
uint8_t
*
buf_end
;
uint8_t
*
buf
;
...
...
@@ -108,10 +110,6 @@ static int pcx_encode_frame(AVCodecContext *avctx, AVPacket *pkt,
const
uint32_t
*
pal
=
NULL
;
const
uint8_t
*
src
;
*
pict
=
*
frame
;
pict
->
pict_type
=
AV_PICTURE_TYPE_I
;
pict
->
key_frame
=
1
;
if
(
avctx
->
width
>
65535
||
avctx
->
height
>
65535
)
{
av_log
(
avctx
,
AV_LOG_ERROR
,
"image dimensions do not fit in 16 bits
\n
"
);
return
-
1
;
...
...
@@ -130,7 +128,7 @@ static int pcx_encode_frame(AVCodecContext *avctx, AVPacket *pkt,
case
AV_PIX_FMT_PAL8
:
bpp
=
8
;
nplanes
=
1
;
pal
=
(
uint32_t
*
)
pict
->
data
[
1
];
pal
=
(
uint32_t
*
)
frame
->
data
[
1
];
break
;
case
AV_PIX_FMT_MONOBLACK
:
bpp
=
1
;
...
...
@@ -172,7 +170,7 @@ static int pcx_encode_frame(AVCodecContext *avctx, AVPacket *pkt,
while
(
buf
-
pkt
->
data
<
128
)
*
buf
++=
0
;
src
=
pict
->
data
[
0
];
src
=
frame
->
data
[
0
];
for
(
y
=
0
;
y
<
avctx
->
height
;
y
++
)
{
if
((
written
=
pcx_rle_encode
(
buf
,
buf_end
-
buf
,
...
...
@@ -181,7 +179,7 @@ static int pcx_encode_frame(AVCodecContext *avctx, AVPacket *pkt,
return
-
1
;
}
buf
+=
written
;
src
+=
pict
->
linesize
[
0
];
src
+=
frame
->
linesize
[
0
];
}
if
(
nplanes
==
1
&&
bpp
==
8
)
{
...
...
@@ -207,8 +205,8 @@ AVCodec ff_pcx_encoder = {
.
long_name
=
NULL_IF_CONFIG_SMALL
(
"PC Paintbrush PCX image"
),
.
type
=
AVMEDIA_TYPE_VIDEO
,
.
id
=
AV_CODEC_ID_PCX
,
.
priv_data_size
=
sizeof
(
PCXContext
),
.
init
=
pcx_encode_init
,
.
close
=
pcx_encode_close
,
.
encode2
=
pcx_encode_frame
,
.
pix_fmts
=
(
const
enum
AVPixelFormat
[]){
AV_PIX_FMT_RGB24
,
...
...
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