Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
F
FFmpeg
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Container Registry
Model registry
Operate
Environments
Monitor
Incidents
Service Desk
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
libremedia
Tethys
FFmpeg
Commits
bc63a760
Commit
bc63a760
authored
11 years ago
by
Andrey Utkin
Committed by
Michael Niedermayer
11 years ago
Browse files
Options
Downloads
Patches
Plain Diff
pngenc: Add 'dpi', 'dpm' options
Signed-off-by:
Michael Niedermayer
<
michaelni@gmx.at
>
parent
c0a30dd2
No related branches found
Branches containing commit
No related tags found
Tags containing commit
No related merge requests found
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
doc/encoders.texi
+13
-0
13 additions, 0 deletions
doc/encoders.texi
libavcodec/pngenc.c
+36
-3
36 additions, 3 deletions
libavcodec/pngenc.c
with
49 additions
and
3 deletions
doc/encoders.texi
+
13
−
0
View file @
bc63a760
...
@@ -777,6 +777,19 @@ Override the x264 configuration using a :-separated list of key=value parameters
...
@@ -777,6 +777,19 @@ Override the x264 configuration using a :-separated list of key=value parameters
Encoding avpresets for common usages are provided so they can be used with the
Encoding avpresets for common usages are provided so they can be used with the
general presets system (e.g. passing the @code{-pre} option).
general presets system (e.g. passing the @code{-pre} option).
@section png
PNG image encoder.
@subsection Private options
@table @option
@item dpi @var{integer}
Set physical density of pixels, in dots per inch, unset by default
@item dpm @var{integer}
Set physical density of pixels, in dots per meter, unset by default
@end table
@section ProRes
@section ProRes
Apple ProRes encoder.
Apple ProRes encoder.
...
...
This diff is collapsed.
Click to expand it.
libavcodec/pngenc.c
+
36
−
3
View file @
bc63a760
...
@@ -25,6 +25,7 @@
...
@@ -25,6 +25,7 @@
#include
"png.h"
#include
"png.h"
#include
"libavutil/avassert.h"
#include
"libavutil/avassert.h"
#include
"libavutil/opt.h"
/* TODO:
/* TODO:
* - add 2, 4 and 16 bit depth support
* - add 2, 4 and 16 bit depth support
...
@@ -37,6 +38,7 @@
...
@@ -37,6 +38,7 @@
#define IOBUF_SIZE 4096
#define IOBUF_SIZE 4096
typedef
struct
PNGEncContext
{
typedef
struct
PNGEncContext
{
AVClass
*
class
;
DSPContext
dsp
;
DSPContext
dsp
;
uint8_t
*
bytestream
;
uint8_t
*
bytestream
;
...
@@ -48,6 +50,8 @@ typedef struct PNGEncContext {
...
@@ -48,6 +50,8 @@ typedef struct PNGEncContext {
z_stream
zstream
;
z_stream
zstream
;
uint8_t
buf
[
IOBUF_SIZE
];
uint8_t
buf
[
IOBUF_SIZE
];
int
dpi
;
///< Physical pixel density, in dots per inch, if set
int
dpm
;
///< Physical pixel density, in dots per meter, if set
}
PNGEncContext
;
}
PNGEncContext
;
static
void
png_get_interlaced_row
(
uint8_t
*
dst
,
int
row_size
,
static
void
png_get_interlaced_row
(
uint8_t
*
dst
,
int
row_size
,
...
@@ -331,9 +335,15 @@ static int encode_frame(AVCodecContext *avctx, AVPacket *pkt,
...
@@ -331,9 +335,15 @@ static int encode_frame(AVCodecContext *avctx, AVPacket *pkt,
png_write_chunk
(
&
s
->
bytestream
,
MKTAG
(
'I'
,
'H'
,
'D'
,
'R'
),
s
->
buf
,
13
);
png_write_chunk
(
&
s
->
bytestream
,
MKTAG
(
'I'
,
'H'
,
'D'
,
'R'
),
s
->
buf
,
13
);
AV_WB32
(
s
->
buf
,
avctx
->
sample_aspect_ratio
.
num
);
if
(
s
->
dpm
)
{
AV_WB32
(
s
->
buf
+
4
,
avctx
->
sample_aspect_ratio
.
den
);
AV_WB32
(
s
->
buf
,
s
->
dpm
);
s
->
buf
[
8
]
=
0
;
/* unit specifier is unknown */
AV_WB32
(
s
->
buf
+
4
,
s
->
dpm
);
s
->
buf
[
8
]
=
1
;
/* unit specifier is meter */
}
else
{
AV_WB32
(
s
->
buf
,
avctx
->
sample_aspect_ratio
.
num
);
AV_WB32
(
s
->
buf
+
4
,
avctx
->
sample_aspect_ratio
.
den
);
s
->
buf
[
8
]
=
0
;
/* unit specifier is unknown */
}
png_write_chunk
(
&
s
->
bytestream
,
MKTAG
(
'p'
,
'H'
,
'Y'
,
's'
),
s
->
buf
,
9
);
png_write_chunk
(
&
s
->
bytestream
,
MKTAG
(
'p'
,
'H'
,
'Y'
,
's'
),
s
->
buf
,
9
);
/* put the palette if needed */
/* put the palette if needed */
...
@@ -458,9 +468,31 @@ static av_cold int png_enc_init(AVCodecContext *avctx){
...
@@ -458,9 +468,31 @@ static av_cold int png_enc_init(AVCodecContext *avctx){
if
(
avctx
->
pix_fmt
==
AV_PIX_FMT_MONOBLACK
)
if
(
avctx
->
pix_fmt
==
AV_PIX_FMT_MONOBLACK
)
s
->
filter_type
=
PNG_FILTER_VALUE_NONE
;
s
->
filter_type
=
PNG_FILTER_VALUE_NONE
;
if
(
s
->
dpi
&&
s
->
dpm
)
{
av_log
(
avctx
,
AV_LOG_ERROR
,
"Only one of 'dpi' or 'dpm' options should be set
\n
"
);
return
AVERROR
(
EINVAL
);
}
else
if
(
s
->
dpi
)
{
s
->
dpm
=
s
->
dpi
*
10000
/
254
;
}
return
0
;
return
0
;
}
}
#define OFFSET(x) offsetof(PNGEncContext, x)
#define VE AV_OPT_FLAG_VIDEO_PARAM | AV_OPT_FLAG_ENCODING_PARAM
static
const
AVOption
options
[]
=
{
{
"dpi"
,
"Set image resolution (in dots per inch)"
,
OFFSET
(
dpi
),
AV_OPT_TYPE_INT
,
{.
i64
=
0
},
0
,
0x10000
,
VE
},
{
"dpm"
,
"Set image resolution (in dots per meter)"
,
OFFSET
(
dpm
),
AV_OPT_TYPE_INT
,
{.
i64
=
0
},
0
,
0x10000
,
VE
},
{
NULL
}
};
static
const
AVClass
pngenc_class
=
{
.
class_name
=
"PNG encoder"
,
.
item_name
=
av_default_item_name
,
.
option
=
options
,
.
version
=
LIBAVUTIL_VERSION_INT
,
};
AVCodec
ff_png_encoder
=
{
AVCodec
ff_png_encoder
=
{
.
name
=
"png"
,
.
name
=
"png"
,
.
type
=
AVMEDIA_TYPE_VIDEO
,
.
type
=
AVMEDIA_TYPE_VIDEO
,
...
@@ -478,4 +510,5 @@ AVCodec ff_png_encoder = {
...
@@ -478,4 +510,5 @@ AVCodec ff_png_encoder = {
AV_PIX_FMT_MONOBLACK
,
AV_PIX_FMT_NONE
AV_PIX_FMT_MONOBLACK
,
AV_PIX_FMT_NONE
},
},
.
long_name
=
NULL_IF_CONFIG_SMALL
(
"PNG (Portable Network Graphics) image"
),
.
long_name
=
NULL_IF_CONFIG_SMALL
(
"PNG (Portable Network Graphics) image"
),
.
priv_class
=
&
pngenc_class
,
};
};
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment