Skip to content
GitLab
Menu
Projects
Groups
Snippets
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Sign in / Register
Toggle navigation
Menu
Open sidebar
VideoLAN
dav1d
Commits
4d0c2039
Verified
Commit
4d0c2039
authored
Jan 26, 2019
by
James Almer
Browse files
replace fprintf uses with dav1d_log()
parent
c98bbeb3
Pipeline
#4162
passed with stages
in 5 minutes and 32 seconds
Changes
5
Pipelines
1
Hide whitespace changes
Inline
Side-by-side
src/decode.c
View file @
4d0c2039
...
...
@@ -42,6 +42,7 @@
#include "src/decode.h"
#include "src/dequant_tables.h"
#include "src/env.h"
#include "src/log.h"
#include "src/qm.h"
#include "src/recon.h"
#include "src/ref.h"
...
...
@@ -3089,7 +3090,7 @@ int dav1d_submit_frame(Dav1dContext *const c) {
#endif
#undef assign_bitdepth_case
default:
fprintf
(
stderr
,
"Compiled without support for %d-bit decoding
\n
"
,
dav1d_log
(
c
,
"Compiled without support for %d-bit decoding
\n
"
,
8
+
2
*
f
->
seq_hdr
->
hbd
);
res
=
-
ENOPROTOOPT
;
goto
error
;
...
...
@@ -3184,7 +3185,7 @@ int dav1d_submit_frame(Dav1dContext *const c) {
c
->
n_tile_data
=
0
;
// allocate frame
res
=
dav1d_thread_picture_alloc
(
&
f
->
sr_cur
,
f
->
frame_hdr
->
width
[
1
],
res
=
dav1d_thread_picture_alloc
(
c
,
&
f
->
sr_cur
,
f
->
frame_hdr
->
width
[
1
],
f
->
frame_hdr
->
height
,
f
->
seq_hdr
,
f
->
seq_hdr_ref
,
f
->
frame_hdr
,
f
->
frame_hdr_ref
,
...
...
@@ -3194,7 +3195,7 @@ int dav1d_submit_frame(Dav1dContext *const c) {
if
(
res
<
0
)
goto
error
;
if
(
f
->
frame_hdr
->
super_res
.
enabled
)
{
res
=
dav1d_picture_alloc_copy
(
&
f
->
cur
,
f
->
frame_hdr
->
width
[
0
],
&
f
->
sr_cur
.
p
);
res
=
dav1d_picture_alloc_copy
(
c
,
&
f
->
cur
,
f
->
frame_hdr
->
width
[
0
],
&
f
->
sr_cur
.
p
);
if
(
res
<
0
)
goto
error
;
}
else
{
dav1d_picture_ref
(
&
f
->
cur
,
&
f
->
sr_cur
.
p
);
...
...
src/lib.c
View file @
4d0c2039
...
...
@@ -176,9 +176,9 @@ error:
dav1d_free_aligned
(
c
->
fc
);
}
if
(
c
->
n_fc
>
1
)
free
(
c
->
frame_thread
.
out_delayed
);
dav1d_log
(
c
,
"Failed to allocate memory: %s
\n
"
,
strerror
(
errno
));
dav1d_freep_aligned
(
c_out
);
}
fprintf
(
stderr
,
"Failed to allocate memory: %s
\n
"
,
strerror
(
errno
));
return
-
ENOMEM
;
}
...
...
@@ -259,7 +259,7 @@ static int output_image(Dav1dContext *const c, Dav1dPicture *const out,
}
// Apply film grain to a new copy of the image to avoid corrupting refs
int
res
=
dav1d_picture_alloc_copy
(
out
,
in
->
p
.
w
,
in
);
int
res
=
dav1d_picture_alloc_copy
(
c
,
out
,
in
->
p
.
w
,
in
);
if
(
res
<
0
)
{
dav1d_picture_unref_internal
(
in
);
dav1d_picture_unref_internal
(
out
);
...
...
src/obu.c
View file @
4d0c2039
...
...
@@ -281,7 +281,7 @@ static int parse_seq_hdr(Dav1dContext *const c, GetBits *const gb,
return
0
;
error:
fprintf
(
stderr
,
"Error parsing sequence header
\n
"
);
dav1d_log
(
c
,
"Error parsing sequence header
\n
"
);
return
-
EINVAL
;
}
...
...
@@ -1118,7 +1118,7 @@ static int parse_frame_hdr(Dav1dContext *const c, GetBits *const gb) {
return
0
;
error:
fprintf
(
stderr
,
"Error parsing frame header
\n
"
);
dav1d_log
(
c
,
"Error parsing frame header
\n
"
);
return
-
EINVAL
;
}
...
...
@@ -1142,11 +1142,12 @@ static void parse_tile_hdr(Dav1dContext *const c, GetBits *const gb) {
// Check that we haven't read more than obu_len bytes from the buffer
// since init_bit_pos.
static
int
check_for_overrun
(
GetBits
*
const
gb
,
unsigned
init_bit_pos
,
unsigned
obu_len
)
check_for_overrun
(
Dav1dContext
*
const
c
,
GetBits
*
const
gb
,
unsigned
init_bit_pos
,
unsigned
obu_len
)
{
// Make sure we haven't actually read past the end of the gb buffer
if
(
gb
->
error
)
{
fprintf
(
stderr
,
"Overrun in OBU bit buffer
\n
"
);
dav1d_log
(
c
,
"Overrun in OBU bit buffer
\n
"
);
return
1
;
}
...
...
@@ -1157,7 +1158,7 @@ check_for_overrun(GetBits *const gb, unsigned init_bit_pos, unsigned obu_len)
assert
(
init_bit_pos
<=
pos
);
if
(
pos
-
init_bit_pos
>
8
*
obu_len
)
{
fprintf
(
stderr
,
"Overrun in OBU bit buffer into next OBU
\n
"
);
dav1d_log
(
c
,
"Overrun in OBU bit buffer into next OBU
\n
"
);
return
1
;
}
...
...
@@ -1238,7 +1239,7 @@ int dav1d_parse_obus(Dav1dContext *const c, Dav1dData *const in, int global) {
dav1d_ref_dec
(
&
ref
);
return
res
;
}
if
(
check_for_overrun
(
&
gb
,
init_bit_pos
,
len
))
{
if
(
check_for_overrun
(
c
,
&
gb
,
init_bit_pos
,
len
))
{
dav1d_ref_dec
(
&
ref
);
return
-
EINVAL
;
}
...
...
@@ -1291,7 +1292,7 @@ int dav1d_parse_obus(Dav1dContext *const c, Dav1dData *const in, int global) {
// This is actually a frame header OBU so read the
// trailing bit and check for overrun.
dav1d_get_bits
(
&
gb
,
1
);
if
(
check_for_overrun
(
&
gb
,
init_bit_pos
,
len
))
{
if
(
check_for_overrun
(
c
,
&
gb
,
init_bit_pos
,
len
))
{
c
->
frame_hdr
=
NULL
;
return
-
EINVAL
;
}
...
...
@@ -1323,7 +1324,7 @@ int dav1d_parse_obus(Dav1dContext *const c, Dav1dData *const in, int global) {
parse_tile_hdr
(
c
,
&
gb
);
// Align to the next byte boundary and check for overrun.
dav1d_bytealign_get_bits
(
&
gb
);
if
(
check_for_overrun
(
&
gb
,
init_bit_pos
,
len
))
if
(
check_for_overrun
(
c
,
&
gb
,
init_bit_pos
,
len
))
return
-
EINVAL
;
// The current bit position is a multiple of 8 (because we
// just aligned it) and less than 8*pkt_bytelen because
...
...
@@ -1355,7 +1356,7 @@ int dav1d_parse_obus(Dav1dContext *const c, Dav1dData *const in, int global) {
// ignore OBUs we don't care about
break
;
default:
fprintf
(
stderr
,
"Unknown OBU type %d of size %u
\n
"
,
type
,
len
);
dav1d_log
(
c
,
"Unknown OBU type %d of size %u
\n
"
,
type
,
len
);
return
-
EINVAL
;
}
...
...
@@ -1426,6 +1427,6 @@ int dav1d_parse_obus(Dav1dContext *const c, Dav1dData *const in, int global) {
return
len
+
init_byte_pos
;
error:
fprintf
(
stderr
,
"Error parsing OBU data
\n
"
);
dav1d_log
(
c
,
"Error parsing OBU data
\n
"
);
return
-
EINVAL
;
}
src/picture.c
View file @
4d0c2039
...
...
@@ -38,6 +38,7 @@
#include "common/mem.h"
#include "common/validate.h"
#include "src/log.h"
#include "src/picture.h"
#include "src/ref.h"
#include "src/thread.h"
...
...
@@ -59,8 +60,6 @@ int default_picture_allocator(Dav1dPicture *const p, void *cookie) {
uint8_t
*
data
=
dav1d_alloc_aligned
(
pic_size
,
32
);
if
(
data
==
NULL
)
{
fprintf
(
stderr
,
"Failed to allocate memory of size %zu: %s
\n
"
,
pic_size
,
strerror
(
errno
));
return
-
1
;
}
...
...
@@ -97,7 +96,7 @@ static void free_buffer(const uint8_t *const data, void *const user_data) {
free
(
pic_ctx
);
}
static
int
picture_alloc_with_edges
(
Dav1dPicture
*
const
p
,
static
int
picture_alloc_with_edges
(
Dav1dContext
*
const
c
,
Dav1dPicture
*
const
p
,
const
int
w
,
const
int
h
,
Dav1dSequenceHeader
*
seq_hdr
,
Dav1dRef
*
seq_hdr_ref
,
Dav1dFrameHeader
*
frame_hdr
,
Dav1dRef
*
frame_hdr_ref
,
...
...
@@ -106,7 +105,7 @@ static int picture_alloc_with_edges(Dav1dPicture *const p,
const
size_t
extra
,
void
**
const
extra_ptr
)
{
if
(
p
->
data
[
0
])
{
fprintf
(
stderr
,
"Picture already allocated!
\n
"
);
dav1d_log
(
c
,
"Picture already allocated!
\n
"
);
return
-
1
;
}
assert
(
bpc
>
0
&&
bpc
<=
16
);
...
...
@@ -135,7 +134,7 @@ static int picture_alloc_with_edges(Dav1dPicture *const p,
if
(
!
(
p
->
ref
=
dav1d_ref_wrap
(
p
->
data
[
0
],
free_buffer
,
pic_ctx
)))
{
p_allocator
->
release_picture_callback
(
p
,
p_allocator
->
cookie
);
free
(
pic_ctx
);
fprintf
(
stderr
,
"Failed to wrap picture: %s
\n
"
,
strerror
(
errno
));
dav1d_log
(
c
,
"Failed to wrap picture: %s
\n
"
,
strerror
(
errno
));
return
-
ENOMEM
;
}
...
...
@@ -153,7 +152,7 @@ static int picture_alloc_with_edges(Dav1dPicture *const p,
return
0
;
}
int
dav1d_thread_picture_alloc
(
Dav1dThreadPicture
*
const
p
,
int
dav1d_thread_picture_alloc
(
Dav1dContext
*
const
c
,
Dav1dThreadPicture
*
const
p
,
const
int
w
,
const
int
h
,
Dav1dSequenceHeader
*
seq_hdr
,
Dav1dRef
*
seq_hdr_ref
,
Dav1dFrameHeader
*
frame_hdr
,
Dav1dRef
*
frame_hdr_ref
,
...
...
@@ -164,7 +163,7 @@ int dav1d_thread_picture_alloc(Dav1dThreadPicture *const p,
p
->
t
=
t
;
const
int
res
=
picture_alloc_with_edges
(
&
p
->
p
,
w
,
h
,
picture_alloc_with_edges
(
c
,
&
p
->
p
,
w
,
h
,
seq_hdr
,
seq_hdr_ref
,
frame_hdr
,
frame_hdr_ref
,
bpc
,
props
,
p_allocator
,
...
...
@@ -180,11 +179,11 @@ int dav1d_thread_picture_alloc(Dav1dThreadPicture *const p,
return
res
;
}
int
dav1d_picture_alloc_copy
(
Dav1dPicture
*
const
dst
,
const
int
w
,
int
dav1d_picture_alloc_copy
(
Dav1dContext
*
const
c
,
Dav1dPicture
*
const
dst
,
const
int
w
,
const
Dav1dPicture
*
const
src
)
{
struct
pic_ctx_context
*
const
pic_ctx
=
src
->
ref
->
user_data
;
const
int
res
=
picture_alloc_with_edges
(
dst
,
w
,
src
->
p
.
h
,
const
int
res
=
picture_alloc_with_edges
(
c
,
dst
,
w
,
src
->
p
.
h
,
src
->
seq_hdr
,
src
->
seq_hdr_ref
,
src
->
frame_hdr
,
src
->
frame_hdr_ref
,
src
->
p
.
bpc
,
&
src
->
m
,
&
pic_ctx
->
allocator
,
...
...
src/picture.h
View file @
4d0c2039
...
...
@@ -55,7 +55,7 @@ typedef struct Dav1dThreadPicture {
/*
* Allocate a picture with custom border size.
*/
int
dav1d_thread_picture_alloc
(
Dav1dThreadPicture
*
p
,
int
w
,
int
h
,
int
dav1d_thread_picture_alloc
(
Dav1dContext
*
c
,
Dav1dThreadPicture
*
p
,
int
w
,
int
h
,
Dav1dSequenceHeader
*
seq_hdr
,
Dav1dRef
*
seq_hdr_ref
,
Dav1dFrameHeader
*
frame_hdr
,
Dav1dRef
*
frame_hdr_ref
,
int
bpc
,
const
Dav1dDataProps
*
props
,
...
...
@@ -69,7 +69,7 @@ int dav1d_thread_picture_alloc(Dav1dThreadPicture *p, int w, int h,
* For the more typical use case of allocating a new image of the same
* dimensions, use src->p.w as width.
*/
int
dav1d_picture_alloc_copy
(
Dav1dPicture
*
dst
,
const
int
w
,
int
dav1d_picture_alloc_copy
(
Dav1dContext
*
c
,
Dav1dPicture
*
dst
,
const
int
w
,
const
Dav1dPicture
*
src
);
/**
...
...
Write
Preview
Supports
Markdown
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