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
22eafdf2
Commit
22eafdf2
authored
Oct 24, 2006
by
Kostya Shishkov
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
PGM 16-bit gray support
Originally committed as revision 6780 to
svn://svn.ffmpeg.org/ffmpeg/trunk
parent
ae912c5b
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
12 additions
and
4 deletions
+12
-4
pnm.c
libavcodec/pnm.c
+12
-4
No files found.
libavcodec/pnm.c
View file @
22eafdf2
...
@@ -70,7 +70,7 @@ static int common_init(AVCodecContext *avctx){
...
@@ -70,7 +70,7 @@ static int common_init(AVCodecContext *avctx){
static
int
pnm_decode_header
(
AVCodecContext
*
avctx
,
PNMContext
*
const
s
){
static
int
pnm_decode_header
(
AVCodecContext
*
avctx
,
PNMContext
*
const
s
){
char
buf1
[
32
],
tuple_type
[
32
];
char
buf1
[
32
],
tuple_type
[
32
];
int
h
,
w
,
depth
,
maxval
;
;
int
h
,
w
,
depth
,
maxval
;
pnm_get
(
s
,
buf1
,
sizeof
(
buf1
));
pnm_get
(
s
,
buf1
,
sizeof
(
buf1
));
if
(
!
strcmp
(
buf1
,
"P4"
))
{
if
(
!
strcmp
(
buf1
,
"P4"
))
{
...
@@ -142,8 +142,9 @@ static int pnm_decode_header(AVCodecContext *avctx, PNMContext * const s){
...
@@ -142,8 +142,9 @@ static int pnm_decode_header(AVCodecContext *avctx, PNMContext * const s){
return
-
1
;
return
-
1
;
if
(
avctx
->
pix_fmt
!=
PIX_FMT_MONOWHITE
)
{
if
(
avctx
->
pix_fmt
!=
PIX_FMT_MONOWHITE
)
{
pnm_get
(
s
,
buf1
,
sizeof
(
buf1
));
pnm_get
(
s
,
buf1
,
sizeof
(
buf1
));
if
(
atoi
(
buf1
)
==
65535
&&
avctx
->
pix_fmt
==
PIX_FMT_GRAY8
)
avctx
->
pix_fmt
=
PIX_FMT_GRAY16BE
;
}
}
/* more check if YUV420 */
/* more check if YUV420 */
if
(
avctx
->
pix_fmt
==
PIX_FMT_YUV420P
)
{
if
(
avctx
->
pix_fmt
==
PIX_FMT_YUV420P
)
{
if
((
avctx
->
width
&
1
)
!=
0
)
if
((
avctx
->
width
&
1
)
!=
0
)
...
@@ -194,6 +195,9 @@ static int pnm_decode_frame(AVCodecContext *avctx,
...
@@ -194,6 +195,9 @@ static int pnm_decode_frame(AVCodecContext *avctx,
case
PIX_FMT_GRAY8
:
case
PIX_FMT_GRAY8
:
n
=
avctx
->
width
;
n
=
avctx
->
width
;
goto
do_read
;
goto
do_read
;
case
PIX_FMT_GRAY16BE
:
n
=
avctx
->
width
*
2
;
goto
do_read
;
case
PIX_FMT_MONOWHITE
:
case
PIX_FMT_MONOWHITE
:
case
PIX_FMT_MONOBLACK
:
case
PIX_FMT_MONOBLACK
:
n
=
(
avctx
->
width
+
7
)
>>
3
;
n
=
(
avctx
->
width
+
7
)
>>
3
;
...
@@ -292,6 +296,10 @@ static int pnm_encode_frame(AVCodecContext *avctx, unsigned char *outbuf, int bu
...
@@ -292,6 +296,10 @@ static int pnm_encode_frame(AVCodecContext *avctx, unsigned char *outbuf, int bu
c
=
'5'
;
c
=
'5'
;
n
=
avctx
->
width
;
n
=
avctx
->
width
;
break
;
break
;
case
PIX_FMT_GRAY16BE
:
c
=
'5'
;
n
=
avctx
->
width
*
2
;
break
;
case
PIX_FMT_RGB24
:
case
PIX_FMT_RGB24
:
c
=
'6'
;
c
=
'6'
;
n
=
avctx
->
width
*
3
;
n
=
avctx
->
width
*
3
;
...
@@ -310,7 +318,7 @@ static int pnm_encode_frame(AVCodecContext *avctx, unsigned char *outbuf, int bu
...
@@ -310,7 +318,7 @@ static int pnm_encode_frame(AVCodecContext *avctx, unsigned char *outbuf, int bu
s
->
bytestream
+=
strlen
(
s
->
bytestream
);
s
->
bytestream
+=
strlen
(
s
->
bytestream
);
if
(
avctx
->
pix_fmt
!=
PIX_FMT_MONOWHITE
)
{
if
(
avctx
->
pix_fmt
!=
PIX_FMT_MONOWHITE
)
{
snprintf
(
s
->
bytestream
,
s
->
bytestream_end
-
s
->
bytestream
,
snprintf
(
s
->
bytestream
,
s
->
bytestream_end
-
s
->
bytestream
,
"%d
\n
"
,
25
5
);
"%d
\n
"
,
(
avctx
->
pix_fmt
!=
PIX_FMT_GRAY16BE
)
?
255
:
6553
5
);
s
->
bytestream
+=
strlen
(
s
->
bytestream
);
s
->
bytestream
+=
strlen
(
s
->
bytestream
);
}
}
...
@@ -537,7 +545,7 @@ AVCodec pgm_encoder = {
...
@@ -537,7 +545,7 @@ AVCodec pgm_encoder = {
pnm_encode_frame
,
pnm_encode_frame
,
NULL
,
//encode_end,
NULL
,
//encode_end,
pnm_decode_frame
,
pnm_decode_frame
,
.
pix_fmts
=
(
enum
PixelFormat
[]){
PIX_FMT_GRAY8
,
-
1
},
.
pix_fmts
=
(
enum
PixelFormat
[]){
PIX_FMT_GRAY8
,
PIX_FMT_GRAY16BE
,
-
1
},
};
};
#endif // CONFIG_PGM_ENCODER
#endif // CONFIG_PGM_ENCODER
...
...
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