Skip to content
Projects
Groups
Snippets
Help
Loading...
Sign in / Register
Toggle navigation
F
ffmpeg
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
Packages
Packages
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
submodule
ffmpeg
Commits
6acac061
Commit
6acac061
authored
Mar 17, 2012
by
Kostya Shishkov
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
prores: allow user to set fixed quantiser
parent
8bc5d90a
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
39 additions
and
13 deletions
+39
-13
proresenc.c
libavcodec/proresenc.c
+39
-13
No files found.
libavcodec/proresenc.c
View file @
6acac061
...
@@ -184,6 +184,7 @@ typedef struct ProresContext {
...
@@ -184,6 +184,7 @@ typedef struct ProresContext {
int
num_slices
;
int
num_slices
;
int
num_planes
;
int
num_planes
;
int
bits_per_mb
;
int
bits_per_mb
;
int
force_quant
;
char
*
vendor
;
char
*
vendor
;
int
quant_sel
;
int
quant_sel
;
...
@@ -397,7 +398,9 @@ static int encode_slice(AVCodecContext *avctx, const AVFrame *pic,
...
@@ -397,7 +398,9 @@ static int encode_slice(AVCodecContext *avctx, const AVFrame *pic,
int
plane_factor
,
is_chroma
;
int
plane_factor
,
is_chroma
;
uint16_t
*
qmat
;
uint16_t
*
qmat
;
if
(
quant
<
MAX_STORED_Q
)
{
if
(
ctx
->
force_quant
)
{
qmat
=
ctx
->
quants
[
0
];
}
else
if
(
quant
<
MAX_STORED_Q
)
{
qmat
=
ctx
->
quants
[
quant
];
qmat
=
ctx
->
quants
[
quant
];
}
else
{
}
else
{
qmat
=
ctx
->
custom_q
;
qmat
=
ctx
->
custom_q
;
...
@@ -750,6 +753,7 @@ static int encode_frame(AVCodecContext *avctx, AVPacket *pkt,
...
@@ -750,6 +753,7 @@ static int encode_frame(AVCodecContext *avctx, AVPacket *pkt,
// slices
// slices
for
(
y
=
0
;
y
<
ctx
->
mb_height
;
y
++
)
{
for
(
y
=
0
;
y
<
ctx
->
mb_height
;
y
++
)
{
mbs_per_slice
=
ctx
->
mbs_per_slice
;
mbs_per_slice
=
ctx
->
mbs_per_slice
;
if
(
!
ctx
->
force_quant
)
{
for
(
x
=
mb
=
0
;
x
<
ctx
->
mb_width
;
x
+=
mbs_per_slice
,
mb
++
)
{
for
(
x
=
mb
=
0
;
x
<
ctx
->
mb_width
;
x
+=
mbs_per_slice
,
mb
++
)
{
while
(
ctx
->
mb_width
-
x
<
mbs_per_slice
)
while
(
ctx
->
mb_width
-
x
<
mbs_per_slice
)
mbs_per_slice
>>=
1
;
mbs_per_slice
>>=
1
;
...
@@ -761,10 +765,11 @@ static int encode_frame(AVCodecContext *avctx, AVPacket *pkt,
...
@@ -761,10 +765,11 @@ static int encode_frame(AVCodecContext *avctx, AVPacket *pkt,
ctx
->
slice_q
[
x
]
=
ctx
->
nodes
[
q
].
quant
;
ctx
->
slice_q
[
x
]
=
ctx
->
nodes
[
q
].
quant
;
q
=
ctx
->
nodes
[
q
].
prev_node
;
q
=
ctx
->
nodes
[
q
].
prev_node
;
}
}
}
mbs_per_slice
=
ctx
->
mbs_per_slice
;
mbs_per_slice
=
ctx
->
mbs_per_slice
;
for
(
x
=
mb
=
0
;
x
<
ctx
->
mb_width
;
x
+=
mbs_per_slice
,
mb
++
)
{
for
(
x
=
mb
=
0
;
x
<
ctx
->
mb_width
;
x
+=
mbs_per_slice
,
mb
++
)
{
q
=
ctx
->
slice_q
[
mb
];
q
=
ctx
->
force_quant
?
ctx
->
force_quant
:
ctx
->
slice_q
[
mb
];
while
(
ctx
->
mb_width
-
x
<
mbs_per_slice
)
while
(
ctx
->
mb_width
-
x
<
mbs_per_slice
)
mbs_per_slice
>>=
1
;
mbs_per_slice
>>=
1
;
...
@@ -859,6 +864,8 @@ static av_cold int encode_init(AVCodecContext *avctx)
...
@@ -859,6 +864,8 @@ static av_cold int encode_init(AVCodecContext *avctx)
return
AVERROR_INVALIDDATA
;
return
AVERROR_INVALIDDATA
;
}
}
ctx
->
force_quant
=
avctx
->
global_quality
/
FF_QP2LAMBDA
;
if
(
!
ctx
->
force_quant
)
{
if
(
!
ctx
->
bits_per_mb
)
{
if
(
!
ctx
->
bits_per_mb
)
{
for
(
i
=
0
;
i
<
NUM_MB_LIMITS
-
1
;
i
++
)
for
(
i
=
0
;
i
<
NUM_MB_LIMITS
-
1
;
i
++
)
if
(
prores_mb_limits
[
i
]
>=
ctx
->
mb_width
*
ctx
->
mb_height
)
if
(
prores_mb_limits
[
i
]
>=
ctx
->
mb_width
*
ctx
->
mb_height
)
...
@@ -869,10 +876,6 @@ static av_cold int encode_init(AVCodecContext *avctx)
...
@@ -869,10 +876,6 @@ static av_cold int encode_init(AVCodecContext *avctx)
return
AVERROR_INVALIDDATA
;
return
AVERROR_INVALIDDATA
;
}
}
ctx
->
frame_size
=
ctx
->
num_slices
*
(
2
+
2
*
ctx
->
num_planes
+
(
2
*
mps
*
ctx
->
bits_per_mb
)
/
8
)
+
200
;
min_quant
=
ctx
->
profile_info
->
min_quant
;
min_quant
=
ctx
->
profile_info
->
min_quant
;
max_quant
=
ctx
->
profile_info
->
max_quant
;
max_quant
=
ctx
->
profile_info
->
max_quant
;
for
(
i
=
min_quant
;
i
<
MAX_STORED_Q
;
i
++
)
{
for
(
i
=
min_quant
;
i
<
MAX_STORED_Q
;
i
++
)
{
...
@@ -880,13 +883,6 @@ static av_cold int encode_init(AVCodecContext *avctx)
...
@@ -880,13 +883,6 @@ static av_cold int encode_init(AVCodecContext *avctx)
ctx
->
quants
[
i
][
j
]
=
ctx
->
quant_mat
[
j
]
*
i
;
ctx
->
quants
[
i
][
j
]
=
ctx
->
quant_mat
[
j
]
*
i
;
}
}
avctx
->
codec_tag
=
ctx
->
profile_info
->
tag
;
av_log
(
avctx
,
AV_LOG_DEBUG
,
"profile %d, %d slices, %d bits per MB
\n
"
,
ctx
->
profile
,
ctx
->
num_slices
,
ctx
->
bits_per_mb
);
av_log
(
avctx
,
AV_LOG_DEBUG
,
"estimated frame size %d
\n
"
,
ctx
->
frame_size
);
ctx
->
nodes
=
av_malloc
((
ctx
->
slices_width
+
1
)
*
TRELLIS_WIDTH
ctx
->
nodes
=
av_malloc
((
ctx
->
slices_width
+
1
)
*
TRELLIS_WIDTH
*
sizeof
(
*
ctx
->
nodes
));
*
sizeof
(
*
ctx
->
nodes
));
if
(
!
ctx
->
nodes
)
{
if
(
!
ctx
->
nodes
)
{
...
@@ -904,6 +900,36 @@ static av_cold int encode_init(AVCodecContext *avctx)
...
@@ -904,6 +900,36 @@ static av_cold int encode_init(AVCodecContext *avctx)
encode_close
(
avctx
);
encode_close
(
avctx
);
return
AVERROR
(
ENOMEM
);
return
AVERROR
(
ENOMEM
);
}
}
}
else
{
int
ls
=
0
;
if
(
ctx
->
force_quant
>
64
)
{
av_log
(
avctx
,
AV_LOG_ERROR
,
"too large quantiser, maximum is 64
\n
"
);
return
AVERROR_INVALIDDATA
;
}
for
(
j
=
0
;
j
<
64
;
j
++
)
{
ctx
->
quants
[
0
][
j
]
=
ctx
->
quant_mat
[
j
]
*
ctx
->
force_quant
;
ls
+=
av_log2
((
1
<<
11
)
/
ctx
->
quants
[
0
][
j
])
*
2
+
1
;
}
ctx
->
bits_per_mb
=
ls
*
8
;
if
(
ctx
->
chroma_factor
==
CFACTOR_Y444
)
ctx
->
bits_per_mb
+=
ls
*
4
;
if
(
ctx
->
num_planes
==
4
)
ctx
->
bits_per_mb
+=
ls
*
4
;
}
ctx
->
frame_size
=
ctx
->
num_slices
*
(
2
+
2
*
ctx
->
num_planes
+
(
2
*
mps
*
ctx
->
bits_per_mb
)
/
8
)
+
200
;
avctx
->
codec_tag
=
ctx
->
profile_info
->
tag
;
av_log
(
avctx
,
AV_LOG_DEBUG
,
"profile %d, %d slices, %d bits per MB
\n
"
,
ctx
->
profile
,
ctx
->
num_slices
,
ctx
->
bits_per_mb
);
av_log
(
avctx
,
AV_LOG_DEBUG
,
"estimated frame size %d
\n
"
,
ctx
->
frame_size
);
return
0
;
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