Skip to content
GitLab
Projects
Groups
Snippets
Help
Loading...
Help
What's new
10
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
Open sidebar
BC
public
external
libvpx
Commits
e3e9fee4
Commit
e3e9fee4
authored
Jul 21, 2016
by
clang-format
Committed by
James Zern
Jul 21, 2016
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
vpx/: apply clang-format
Change-Id: I95922a64568bf289863c1564212b6be5beec36df
parent
4b073bc3
Changes
16
Expand all
Hide whitespace changes
Inline
Side-by-side
Showing
16 changed files
with
2119 additions
and
2362 deletions
+2119
-2362
vpx/internal/vpx_codec_internal.h
vpx/internal/vpx_codec_internal.h
+103
-103
vpx/src/svc_encodeframe.c
vpx/src/svc_encodeframe.c
+69
-94
vpx/src/vpx_codec.c
vpx/src/vpx_codec.c
+20
-45
vpx/src/vpx_decoder.c
vpx/src/vpx_decoder.c
+26
-35
vpx/src/vpx_encoder.c
vpx/src/vpx_encoder.c
+48
-70
vpx/src/vpx_image.c
vpx/src/vpx_image.c
+47
-93
vpx/svc_context.h
vpx/svc_context.h
+10
-13
vpx/vp8.h
vpx/vp8.h
+38
-32
vpx/vp8cx.h
vpx/vp8cx.h
+70
-81
vpx/vp8dx.h
vpx/vp8dx.h
+14
-17
vpx/vpx_codec.h
vpx/vpx_codec.h
+336
-352
vpx/vpx_decoder.h
vpx/vpx_decoder.h
+305
-318
vpx/vpx_encoder.h
vpx/vpx_encoder.h
+823
-887
vpx/vpx_frame_buffer.h
vpx/vpx_frame_buffer.h
+7
-7
vpx/vpx_image.h
vpx/vpx_image.h
+193
-204
vpx/vpx_integer.h
vpx/vpx_integer.h
+10
-11
No files found.
vpx/internal/vpx_codec_internal.h
View file @
e3e9fee4
...
...
@@ -8,7 +8,6 @@
* be found in the AUTHORS file in the root of the source tree.
*/
/*!\file
* \brief Describes the decoder algorithm interface for algorithm
* implementations.
...
...
@@ -61,7 +60,7 @@ extern "C" {
*/
#define VPX_CODEC_INTERNAL_ABI_VERSION (5)
/**<\hideinitializer*/
typedef
struct
vpx_codec_alg_priv
vpx_codec_alg_priv_t
;
typedef
struct
vpx_codec_alg_priv
vpx_codec_alg_priv_t
;
typedef
struct
vpx_codec_priv_enc_mr_cfg
vpx_codec_priv_enc_mr_cfg_t
;
/*!\brief init function pointer prototype
...
...
@@ -77,8 +76,8 @@ typedef struct vpx_codec_priv_enc_mr_cfg vpx_codec_priv_enc_mr_cfg_t;
* \retval #VPX_CODEC_MEM_ERROR
* Memory operation failed.
*/
typedef
vpx_codec_err_t
(
*
vpx_codec_init_fn_t
)(
vpx_codec_ctx_t
*
ctx
,
vpx_codec_priv_enc_mr_cfg_t
*
data
);
typedef
vpx_codec_err_t
(
*
vpx_codec_init_fn_t
)(
vpx_codec_ctx_t
*
ctx
,
vpx_codec_priv_enc_mr_cfg_t
*
data
);
/*!\brief destroy function pointer prototype
*
...
...
@@ -112,8 +111,8 @@ typedef vpx_codec_err_t (*vpx_codec_destroy_fn_t)(vpx_codec_alg_priv_t *ctx);
* \retval #VPX_CODEC_OK
* Bitstream is parsable and stream information updated
*/
typedef
vpx_codec_err_t
(
*
vpx_codec_peek_si_fn_t
)(
const
uint8_t
*
data
,
unsigned
int
data_sz
,
typedef
vpx_codec_err_t
(
*
vpx_codec_peek_si_fn_t
)(
const
uint8_t
*
data
,
unsigned
int
data_sz
,
vpx_codec_stream_info_t
*
si
);
/*!\brief Return information about the current stream.
...
...
@@ -129,7 +128,7 @@ typedef vpx_codec_err_t (*vpx_codec_peek_si_fn_t)(const uint8_t *data,
* \retval #VPX_CODEC_OK
* Bitstream is parsable and stream information updated
*/
typedef
vpx_codec_err_t
(
*
vpx_codec_get_si_fn_t
)(
vpx_codec_alg_priv_t
*
ctx
,
typedef
vpx_codec_err_t
(
*
vpx_codec_get_si_fn_t
)(
vpx_codec_alg_priv_t
*
ctx
,
vpx_codec_stream_info_t
*
si
);
/*!\brief control function pointer prototype
...
...
@@ -193,11 +192,11 @@ typedef const struct vpx_codec_ctrl_fn_map {
* see the descriptions of the other error codes in ::vpx_codec_err_t
* for recoverability capabilities.
*/
typedef
vpx_codec_err_t
(
*
vpx_codec_decode_fn_t
)(
vpx_codec_alg_priv_t
*
ctx
,
const
uint8_t
*
data
,
unsigned
int
data_sz
,
void
*
user_priv
,
long
deadline
);
typedef
vpx_codec_err_t
(
*
vpx_codec_decode_fn_t
)(
vpx_codec_alg_priv_t
*
ctx
,
const
uint8_t
*
data
,
unsigned
int
data_sz
,
void
*
user_priv
,
long
deadline
);
/*!\brief Decoded frames iterator
*
...
...
@@ -206,7 +205,8 @@ typedef vpx_codec_err_t (*vpx_codec_decode_fn_t)(vpx_codec_alg_priv_t *ctx,
* complete when this function returns NULL.
*
* The list of available frames becomes valid upon completion of the
* vpx_codec_decode call, and remains valid until the next call to vpx_codec_decode.
* vpx_codec_decode call, and remains valid until the next call to
* vpx_codec_decode.
*
* \param[in] ctx Pointer to this instance's context
* \param[in out] iter Iterator storage, initialized to NULL
...
...
@@ -215,7 +215,7 @@ typedef vpx_codec_err_t (*vpx_codec_decode_fn_t)(vpx_codec_alg_priv_t *ctx,
* produced will always be in PTS (presentation time stamp) order.
*/
typedef
vpx_image_t
*
(
*
vpx_codec_get_frame_fn_t
)(
vpx_codec_alg_priv_t
*
ctx
,
vpx_codec_iter_t
*
iter
);
vpx_codec_iter_t
*
iter
);
/*!\brief Pass in external frame buffers for the decoder to use.
*
...
...
@@ -244,32 +244,28 @@ typedef vpx_image_t *(*vpx_codec_get_frame_fn_t)(vpx_codec_alg_priv_t *ctx,
* buffers.
*/
typedef
vpx_codec_err_t
(
*
vpx_codec_set_fb_fn_t
)(
vpx_codec_alg_priv_t
*
ctx
,
vpx_get_frame_buffer_cb_fn_t
cb_get
,
vpx_codec_alg_priv_t
*
ctx
,
vpx_get_frame_buffer_cb_fn_t
cb_get
,
vpx_release_frame_buffer_cb_fn_t
cb_release
,
void
*
cb_priv
);
typedef
vpx_codec_err_t
(
*
vpx_codec_encode_fn_t
)(
vpx_codec_alg_priv_t
*
ctx
,
const
vpx_image_t
*
img
,
vpx_codec_pts_t
pts
,
unsigned
long
duration
,
vpx_enc_frame_flags_t
flags
,
unsigned
long
deadline
);
typedef
const
vpx_codec_cx_pkt_t
*
(
*
vpx_codec_get_cx_data_fn_t
)(
vpx_codec_alg_priv_t
*
ctx
,
vpx_codec_iter_t
*
iter
);
typedef
vpx_codec_err_t
(
*
vpx_codec_encode_fn_t
)(
vpx_codec_alg_priv_t
*
ctx
,
const
vpx_image_t
*
img
,
vpx_codec_pts_t
pts
,
unsigned
long
duration
,
vpx_enc_frame_flags_t
flags
,
unsigned
long
deadline
);
typedef
const
vpx_codec_cx_pkt_t
*
(
*
vpx_codec_get_cx_data_fn_t
)(
vpx_codec_alg_priv_t
*
ctx
,
vpx_codec_iter_t
*
iter
);
typedef
vpx_codec_err_t
(
*
vpx_codec_enc_config_set_fn_t
)(
vpx_codec_alg_priv_t
*
ctx
,
const
vpx_codec_enc_cfg_t
*
cfg
);
typedef
vpx_fixed_buf_t
*
(
*
vpx_codec_get_global_headers_fn_t
)(
vpx_codec_alg_priv_t
*
ctx
);
typedef
vpx_codec_err_t
(
*
vpx_codec_enc_config_set_fn_t
)(
vpx_codec_alg_priv_t
*
ctx
,
const
vpx_codec_enc_cfg_t
*
cfg
);
typedef
vpx_fixed_buf_t
*
(
*
vpx_codec_get_global_headers_fn_t
)(
vpx_codec_alg_priv_t
*
ctx
);
typedef
vpx_image_t
*
(
*
vpx_codec_get_preview_frame_fn_t
)(
vpx_codec_alg_priv_t
*
ctx
);
typedef
vpx_image_t
*
(
*
vpx_codec_get_preview_frame_fn_t
)(
vpx_codec_alg_priv_t
*
ctx
);
typedef
vpx_codec_err_t
(
*
vpx_codec_enc_mr_get_mem_loc_fn_t
)(
const
vpx_codec_enc_cfg_t
*
cfg
,
void
**
mem_loc
);
typedef
vpx_codec_err_t
(
*
vpx_codec_enc_mr_get_mem_loc_fn_t
)(
const
vpx_codec_enc_cfg_t
*
cfg
,
void
**
mem_loc
);
/*!\brief usage configuration mapping
*
...
...
@@ -282,7 +278,7 @@ typedef vpx_codec_err_t
*
*/
typedef
const
struct
vpx_codec_enc_cfg_map
{
int
usage
;
int
usage
;
vpx_codec_enc_cfg_t
cfg
;
}
vpx_codec_enc_cfg_map_t
;
...
...
@@ -291,41 +287,47 @@ typedef const struct vpx_codec_enc_cfg_map {
* All decoders \ref MUST expose a variable of this type.
*/
struct
vpx_codec_iface
{
const
char
*
name
;
/**< Identification String */
int
abi_version
;
/**< Implemented ABI version */
vpx_codec_caps_t
caps
;
/**< Decoder capabilities */
vpx_codec_init_fn_t
init
;
/**< \copydoc ::vpx_codec_init_fn_t */
vpx_codec_destroy_fn_t
destroy
;
/**< \copydoc ::vpx_codec_destroy_fn_t */
vpx_codec_ctrl_fn_map_t
*
ctrl_maps
;
/**< \copydoc ::vpx_codec_ctrl_fn_map_t */
const
char
*
name
;
/**< Identification String */
int
abi_version
;
/**< Implemented ABI version */
vpx_codec_caps_t
caps
;
/**< Decoder capabilities */
vpx_codec_init_fn_t
init
;
/**< \copydoc ::vpx_codec_init_fn_t */
vpx_codec_destroy_fn_t
destroy
;
/**< \copydoc ::vpx_codec_destroy_fn_t */
vpx_codec_ctrl_fn_map_t
*
ctrl_maps
;
/**< \copydoc ::vpx_codec_ctrl_fn_map_t */
struct
vpx_codec_dec_iface
{
vpx_codec_peek_si_fn_t
peek_si
;
/**< \copydoc ::vpx_codec_peek_si_fn_t */
vpx_codec_get_si_fn_t
get_si
;
/**< \copydoc ::vpx_codec_get_si_fn_t */
vpx_codec_decode_fn_t
decode
;
/**< \copydoc ::vpx_codec_decode_fn_t */
vpx_codec_get_frame_fn_t
get_frame
;
/**< \copydoc ::vpx_codec_get_frame_fn_t */
vpx_codec_set_fb_fn_t
set_fb_fn
;
/**< \copydoc ::vpx_codec_set_fb_fn_t */
vpx_codec_peek_si_fn_t
peek_si
;
/**< \copydoc ::vpx_codec_peek_si_fn_t */
vpx_codec_get_si_fn_t
get_si
;
/**< \copydoc ::vpx_codec_get_si_fn_t */
vpx_codec_decode_fn_t
decode
;
/**< \copydoc ::vpx_codec_decode_fn_t */
vpx_codec_get_frame_fn_t
get_frame
;
/**< \copydoc ::vpx_codec_get_frame_fn_t */
vpx_codec_set_fb_fn_t
set_fb_fn
;
/**< \copydoc ::vpx_codec_set_fb_fn_t */
}
dec
;
struct
vpx_codec_enc_iface
{
int
cfg_map_count
;
vpx_codec_enc_cfg_map_t
*
cfg_maps
;
/**< \copydoc ::vpx_codec_enc_cfg_map_t */
vpx_codec_encode_fn_t
encode
;
/**< \copydoc ::vpx_codec_encode_fn_t */
vpx_codec_get_cx_data_fn_t
get_cx_data
;
/**< \copydoc ::vpx_codec_get_cx_data_fn_t */
vpx_codec_enc_config_set_fn_t
cfg_set
;
/**< \copydoc ::vpx_codec_enc_config_set_fn_t */
vpx_codec_get_global_headers_fn_t
get_glob_hdrs
;
/**< \copydoc ::vpx_codec_get_global_headers_fn_t */
vpx_codec_get_preview_frame_fn_t
get_preview
;
/**< \copydoc ::vpx_codec_get_preview_frame_fn_t */
vpx_codec_enc_mr_get_mem_loc_fn_t
mr_get_mem_loc
;
/**< \copydoc ::vpx_codec_enc_mr_get_mem_loc_fn_t */
int
cfg_map_count
;
vpx_codec_enc_cfg_map_t
*
cfg_maps
;
/**< \copydoc ::vpx_codec_enc_cfg_map_t */
vpx_codec_encode_fn_t
encode
;
/**< \copydoc ::vpx_codec_encode_fn_t */
vpx_codec_get_cx_data_fn_t
get_cx_data
;
/**< \copydoc ::vpx_codec_get_cx_data_fn_t */
vpx_codec_enc_config_set_fn_t
cfg_set
;
/**< \copydoc ::vpx_codec_enc_config_set_fn_t */
vpx_codec_get_global_headers_fn_t
get_glob_hdrs
;
/**< \copydoc ::vpx_codec_get_global_headers_fn_t */
vpx_codec_get_preview_frame_fn_t
get_preview
;
/**< \copydoc ::vpx_codec_get_preview_frame_fn_t */
vpx_codec_enc_mr_get_mem_loc_fn_t
mr_get_mem_loc
;
/**< \copydoc ::vpx_codec_enc_mr_get_mem_loc_fn_t */
}
enc
;
};
/*!\brief Callback function pointer / user data pair storage */
typedef
struct
vpx_codec_priv_cb_pair
{
union
{
vpx_codec_put_frame_cb_fn_t
put_frame
;
vpx_codec_put_slice_cb_fn_t
put_slice
;
vpx_codec_put_frame_cb_fn_t
put_frame
;
vpx_codec_put_slice_cb_fn_t
put_slice
;
}
u
;
void
*
user_priv
;
void
*
user_priv
;
}
vpx_codec_priv_cb_pair_t
;
/*!\brief Instance private storage
*
* This structure is allocated by the algorithm's init function. It can be
...
...
@@ -335,39 +337,38 @@ typedef struct vpx_codec_priv_cb_pair {
* and the pointer cast to the proper type.
*/
struct
vpx_codec_priv
{
const
char
*
err_detail
;
vpx_codec_flags_t
init_flags
;
const
char
*
err_detail
;
vpx_codec_flags_t
init_flags
;
struct
{
vpx_codec_priv_cb_pair_t
put_frame_cb
;
vpx_codec_priv_cb_pair_t
put_slice_cb
;
vpx_codec_priv_cb_pair_t
put_frame_cb
;
vpx_codec_priv_cb_pair_t
put_slice_cb
;
}
dec
;
struct
{
vpx_fixed_buf_t
cx_data_dst_buf
;
unsigned
int
cx_data_pad_before
;
unsigned
int
cx_data_pad_after
;
vpx_codec_cx_pkt_t
cx_data_pkt
;
unsigned
int
total_encoders
;
vpx_fixed_buf_t
cx_data_dst_buf
;
unsigned
int
cx_data_pad_before
;
unsigned
int
cx_data_pad_after
;
vpx_codec_cx_pkt_t
cx_data_pkt
;
unsigned
int
total_encoders
;
}
enc
;
};
/*
* Multi-resolution encoding internal configuration
*/
struct
vpx_codec_priv_enc_mr_cfg
{
unsigned
int
mr_total_resolutions
;
unsigned
int
mr_encoder_id
;
struct
vpx_rational
mr_down_sampling_factor
;
void
*
mr_low_res_mode_info
;
struct
vpx_codec_priv_enc_mr_cfg
{
unsigned
int
mr_total_resolutions
;
unsigned
int
mr_encoder_id
;
struct
vpx_rational
mr_down_sampling_factor
;
void
*
mr_low_res_mode_info
;
};
#undef VPX_CTRL_USE_TYPE
#define VPX_CTRL_USE_TYPE(id, typ) \
static VPX_INLINE typ id##__value(va_list args) {return va_arg(args, typ);}
static VPX_INLINE typ id##__value(va_list args) {
return va_arg(args, typ);
}
#undef VPX_CTRL_USE_TYPE_DEPRECATED
#define VPX_CTRL_USE_TYPE_DEPRECATED(id, typ) \
static VPX_INLINE typ id##__value(va_list args) {return va_arg(args, typ);}
static VPX_INLINE typ id##__value(va_list args) {
return va_arg(args, typ);
}
#define CAST(id, arg) id##__value(arg)
...
...
@@ -380,10 +381,9 @@ struct vpx_codec_priv_enc_mr_cfg
* the same name as the struct, less the _algo suffix. The CODEC_INTERFACE
* macro is provided to define this getter function automatically.
*/
#define CODEC_INTERFACE(id)\
vpx_codec_iface_t* id(void) { return &id##_algo; }\
vpx_codec_iface_t id##_algo
#define CODEC_INTERFACE(id) \
vpx_codec_iface_t *id(void) { return &id##_algo; } \
vpx_codec_iface_t id##_algo
/* Internal Utility Functions
*
...
...
@@ -391,38 +391,39 @@ struct vpx_codec_priv_enc_mr_cfg
* utilities for manipulating vpx_codec_* data structures.
*/
struct
vpx_codec_pkt_list
{
unsigned
int
cnt
;
unsigned
int
max
;
unsigned
int
cnt
;
unsigned
int
max
;
struct
vpx_codec_cx_pkt
pkts
[
1
];
};
#define vpx_codec_pkt_list_decl(n)\
union {
struct vpx_codec_pkt_list head;
\
struct
{struct
vpx_codec_pkt_list head;\
struct
vpx_codec_cx_pkt pkts[n];} alloc;}
#define vpx_codec_pkt_list_init(m)
\
(m)->alloc.head.cnt = 0,
\
(m)->alloc.head.max = sizeof((m)->alloc.pkts) / sizeof((m)->alloc.pkts[0])
#define vpx_codec_pkt_list_decl(n)
\
union {
\
struct vpx_codec_pkt_list head;
\
struct
{ \
struct vpx_codec_pkt_list head; \
struct vpx_codec_cx_pkt pkts[n];
\
} alloc;
\
}
int
vpx_codec_pkt_list_add
(
struct
vpx_codec_pkt_list
*
,
const
struct
vpx_codec_cx_pkt
*
);
#define vpx_codec_pkt_list_init(m) \
(m)->alloc.head.cnt = 0, \
(m)->alloc.head.max = sizeof((m)->alloc.pkts) / sizeof((m)->alloc.pkts[0])
const
vpx_codec_cx_pkt_t
*
vpx_codec_pkt_list_get
(
struct
vpx_codec_pkt_list
*
list
,
vpx_codec_iter_t
*
iter
);
int
vpx_codec_pkt_list_add
(
struct
vpx_codec_pkt_list
*
,
const
struct
vpx_codec_cx_pkt
*
);
const
vpx_codec_cx_pkt_t
*
vpx_codec_pkt_list_get
(
struct
vpx_codec_pkt_list
*
list
,
vpx_codec_iter_t
*
iter
);
#include <stdio.h>
#include <setjmp.h>
struct
vpx_internal_error_info
{
vpx_codec_err_t
error_code
;
int
has_detail
;
char
detail
[
80
];
int
setjmp
;
jmp_buf
jmp
;
vpx_codec_err_t
error_code
;
int
has_detail
;
char
detail
[
80
];
int
setjmp
;
jmp_buf
jmp
;
};
#define CLANG_ANALYZER_NORETURN
...
...
@@ -434,8 +435,7 @@ struct vpx_internal_error_info {
#endif
void
vpx_internal_error
(
struct
vpx_internal_error_info
*
info
,
vpx_codec_err_t
error
,
const
char
*
fmt
,
vpx_codec_err_t
error
,
const
char
*
fmt
,
...)
CLANG_ANALYZER_NORETURN
;
#ifdef __cplusplus
...
...
vpx/src/svc_encodeframe.c
View file @
e3e9fee4
...
...
@@ -33,8 +33,8 @@
#ifndef MINGW_HAS_SECURE_API
// proto from /usr/x86_64-w64-mingw32/include/sec_api/string_s.h
_CRTIMP
char
*
__cdecl
strtok_s
(
char
*
str
,
const
char
*
delim
,
char
**
context
);
#endif
/* MINGW_HAS_SECURE_API */
#endif
/* __MINGW32__ */
#endif
/* MINGW_HAS_SECURE_API */
#endif
/* __MINGW32__ */
#ifdef _MSC_VER
#define strdup _strdup
...
...
@@ -47,13 +47,11 @@ _CRTIMP char *__cdecl strtok_s(char *str, const char *delim, char **context);
#define MAX_QUANTIZER 63
static
const
int
DEFAULT_SCALE_FACTORS_NUM
[
VPX_SS_MAX_LAYERS
]
=
{
4
,
5
,
7
,
11
,
16
};
static
const
int
DEFAULT_SCALE_FACTORS_NUM
[
VPX_SS_MAX_LAYERS
]
=
{
4
,
5
,
7
,
11
,
16
};
static
const
int
DEFAULT_SCALE_FACTORS_DEN
[
VPX_SS_MAX_LAYERS
]
=
{
16
,
16
,
16
,
16
,
16
};
static
const
int
DEFAULT_SCALE_FACTORS_DEN
[
VPX_SS_MAX_LAYERS
]
=
{
16
,
16
,
16
,
16
,
16
};
typedef
enum
{
QUANTIZER
=
0
,
...
...
@@ -63,20 +61,17 @@ typedef enum {
ALL_OPTION_TYPES
}
LAYER_OPTION_TYPE
;
static
const
int
option_max_values
[
ALL_OPTION_TYPES
]
=
{
63
,
INT_MAX
,
INT_MAX
,
1
};
static
const
int
option_max_values
[
ALL_OPTION_TYPES
]
=
{
63
,
INT_MAX
,
INT_MAX
,
1
};
static
const
int
option_min_values
[
ALL_OPTION_TYPES
]
=
{
0
,
0
,
1
,
0
};
static
const
int
option_min_values
[
ALL_OPTION_TYPES
]
=
{
0
,
0
,
1
,
0
};
// One encoded frame
typedef
struct
FrameData
{
void
*
buf
;
// compressed data buffer
size_t
size
;
// length of compressed data
vpx_codec_frame_flags_t
flags
;
/**< flags for this frame */
struct
FrameData
*
next
;
void
*
buf
;
// compressed data buffer
size_t
size
;
// length of compressed data
vpx_codec_frame_flags_t
flags
;
/**< flags for this frame */
struct
FrameData
*
next
;
}
FrameData
;
static
SvcInternal_t
*
get_svc_internal
(
SvcContext
*
svc_ctx
)
{
...
...
@@ -91,8 +86,7 @@ static SvcInternal_t *get_svc_internal(SvcContext *svc_ctx) {
return
(
SvcInternal_t
*
)
svc_ctx
->
internal
;
}
static
const
SvcInternal_t
*
get_const_svc_internal
(
const
SvcContext
*
svc_ctx
)
{
static
const
SvcInternal_t
*
get_const_svc_internal
(
const
SvcContext
*
svc_ctx
)
{
if
(
svc_ctx
==
NULL
)
return
NULL
;
return
(
const
SvcInternal_t
*
)
svc_ctx
->
internal
;
}
...
...
@@ -102,8 +96,8 @@ static void svc_log_reset(SvcContext *svc_ctx) {
si
->
message_buffer
[
0
]
=
'\0'
;
}
static
int
svc_log
(
SvcContext
*
svc_ctx
,
SVC_LOG_LEVEL
level
,
const
char
*
fmt
,
...)
{
static
int
svc_log
(
SvcContext
*
svc_ctx
,
SVC_LOG_LEVEL
level
,
const
char
*
fmt
,
...)
{
char
buf
[
512
];
int
retval
=
0
;
va_list
ap
;
...
...
@@ -130,14 +124,11 @@ static int svc_log(SvcContext *svc_ctx, SVC_LOG_LEVEL level,
return
retval
;
}
static
vpx_codec_err_t
extract_option
(
LAYER_OPTION_TYPE
type
,
char
*
input
,
int
*
value0
,
int
*
value1
)
{
static
vpx_codec_err_t
extract_option
(
LAYER_OPTION_TYPE
type
,
char
*
input
,
int
*
value0
,
int
*
value1
)
{
if
(
type
==
SCALE_FACTOR
)
{
*
value0
=
strtol
(
input
,
&
input
,
10
);
if
(
*
input
++
!=
'/'
)
return
VPX_CODEC_INVALID_PARAM
;
if
(
*
input
++
!=
'/'
)
return
VPX_CODEC_INVALID_PARAM
;
*
value1
=
strtol
(
input
,
&
input
,
10
);
if
(
*
value0
<
option_min_values
[
SCALE_FACTOR
]
||
...
...
@@ -148,8 +139,7 @@ static vpx_codec_err_t extract_option(LAYER_OPTION_TYPE type,
return
VPX_CODEC_INVALID_PARAM
;
}
else
{
*
value0
=
atoi
(
input
);
if
(
*
value0
<
option_min_values
[
type
]
||
*
value0
>
option_max_values
[
type
])
if
(
*
value0
<
option_min_values
[
type
]
||
*
value0
>
option_max_values
[
type
])
return
VPX_CODEC_INVALID_PARAM
;
}
return
VPX_CODEC_OK
;
...
...
@@ -176,8 +166,7 @@ static vpx_codec_err_t parse_layer_options_from_string(SvcContext *svc_ctx,
for
(
i
=
0
;
i
<
svc_ctx
->
spatial_layers
;
++
i
)
{
if
(
token
!=
NULL
)
{
res
=
extract_option
(
type
,
token
,
option0
+
i
,
option1
+
i
);
if
(
res
!=
VPX_CODEC_OK
)
break
;
if
(
res
!=
VPX_CODEC_OK
)
break
;
token
=
strtok_r
(
NULL
,
delim
,
&
save_ptr
);
}
else
{
break
;
...
...
@@ -186,7 +175,8 @@ static vpx_codec_err_t parse_layer_options_from_string(SvcContext *svc_ctx,
if
(
res
==
VPX_CODEC_OK
&&
i
!=
svc_ctx
->
spatial_layers
)
{
svc_log
(
svc_ctx
,
SVC_LOG_ERROR
,
"svc: layer params type: %d %d values required, "
"but only %d specified
\n
"
,
type
,
svc_ctx
->
spatial_layers
,
i
);
"but only %d specified
\n
"
,
type
,
svc_ctx
->
spatial_layers
,
i
);
res
=
VPX_CODEC_INVALID_PARAM
;
}
free
(
input_string
);
...
...
@@ -233,14 +223,14 @@ static vpx_codec_err_t parse_options(SvcContext *svc_ctx, const char *options) {
si
->
svc_params
.
scaling_factor_den
);
if
(
res
!=
VPX_CODEC_OK
)
break
;
}
else
if
(
strcmp
(
"max-quantizers"
,
option_name
)
==
0
)
{
res
=
parse_layer_options_from_string
(
svc_ctx
,
QUANTIZER
,
option_value
,
si
->
svc_params
.
max_quantizers
,
NULL
);
res
=
parse_layer_options_from_string
(
svc_ctx
,
QUANTIZER
,
option_value
,
si
->
svc_params
.
max_quantizers
,
NULL
);
if
(
res
!=
VPX_CODEC_OK
)
break
;
}
else
if
(
strcmp
(
"min-quantizers"
,
option_name
)
==
0
)
{
res
=
parse_layer_options_from_string
(
svc_ctx
,
QUANTIZER
,
option_value
,
si
->
svc_params
.
min_quantizers
,
NULL
);
res
=
parse_layer_options_from_string
(
svc_ctx
,
QUANTIZER
,
option_value
,
si
->
svc_params
.
min_quantizers
,
NULL
);
if
(
res
!=
VPX_CODEC_OK
)
break
;
}
else
if
(
strcmp
(
"auto-alt-refs"
,
option_name
)
==
0
)
{
res
=
parse_layer_options_from_string
(
svc_ctx
,
AUTO_ALT_REF
,
option_value
,
...
...
@@ -287,8 +277,7 @@ static vpx_codec_err_t parse_options(SvcContext *svc_ctx, const char *options) {
return
res
;
}
vpx_codec_err_t
vpx_svc_set_options
(
SvcContext
*
svc_ctx
,
const
char
*
options
)
{
vpx_codec_err_t
vpx_svc_set_options
(
SvcContext
*
svc_ctx
,
const
char
*
options
)
{
SvcInternal_t
*
const
si
=
get_svc_internal
(
svc_ctx
);
if
(
svc_ctx
==
NULL
||
options
==
NULL
||
si
==
NULL
)
{
return
VPX_CODEC_INVALID_PARAM
;
...
...
@@ -308,34 +297,34 @@ void assign_layer_bitrates(const SvcContext *svc_ctx,
if
(
si
->
bitrates
[
0
]
!=
0
)
{
enc_cfg
->
rc_target_bitrate
=
0
;
for
(
sl
=
0
;
sl
<
svc_ctx
->
spatial_layers
;
++
sl
)
{
enc_cfg
->
ss_target_bitrate
[
sl
*
svc_ctx
->
temporal_layers
]
=
0
;
enc_cfg
->
ss_target_bitrate
[
sl
*
svc_ctx
->
temporal_layers
]
=
0
;
for
(
tl
=
0
;
tl
<
svc_ctx
->
temporal_layers
;
++
tl
)
{
enc_cfg
->
ss_target_bitrate
[
sl
*
svc_ctx
->
temporal_layers
]
+=
(
unsigned
int
)
si
->
bitrates
[
sl
*
svc_ctx
->
temporal_layers
+
tl
];
enc_cfg
->
layer_target_bitrate
[
sl
*
svc_ctx
->
temporal_layers
+
tl
]
=
si
->
bitrates
[
sl
*
svc_ctx
->
temporal_layers
+
tl
];
enc_cfg
->
ss_target_bitrate
[
sl
*
svc_ctx
->
temporal_layers
]
+=
(
unsigned
int
)
si
->
bitrates
[
sl
*
svc_ctx
->
temporal_layers
+
tl
];
enc_cfg
->
layer_target_bitrate
[
sl
*
svc_ctx
->
temporal_layers
+
tl
]
=
si
->
bitrates
[
sl
*
svc_ctx
->
temporal_layers
+
tl
];
}
}
}
else
{
float
total
=
0
;
float
alloc_ratio
[
VPX_MAX_LAYERS
]
=
{
0
};
float
alloc_ratio
[
VPX_MAX_LAYERS
]
=
{
0
};
for
(
sl
=
0
;
sl
<
svc_ctx
->
spatial_layers
;
++
sl
)
{
if
(
si
->
svc_params
.
scaling_factor_den
[
sl
]
>
0
)
{
alloc_ratio
[
sl
]
=
(
float
)(
pow
(
2
,
sl
)
);
alloc_ratio
[
sl
]
=
(
float
)(
pow
(
2
,
sl
));
total
+=
alloc_ratio
[
sl
];
}
}
for
(
sl
=
0
;
sl
<
svc_ctx
->
spatial_layers
;
++
sl
)
{
enc_cfg
->
ss_target_bitrate
[
sl
]
=
spatial_layer_target
=
(
unsigned
int
)(
enc_cfg
->
rc_target_bitrate
*
alloc_ratio
[
sl
]
/
total
);
(
unsigned
int
)(
enc_cfg
->
rc_target_bitrate
*
alloc_ratio
[
sl
]
/
total
);
if
(
svc_ctx
->
temporal_layering_mode
==
3
)
{
enc_cfg
->
layer_target_bitrate
[
sl
*
svc_ctx
->
temporal_layers
]
=
(
spatial_layer_target
*
6
)
/
10
;
// 60%
(
spatial_layer_target
*
6
)
/
10
;
// 60%
enc_cfg
->
layer_target_bitrate
[
sl
*
svc_ctx
->
temporal_layers
+
1
]
=
(
spatial_layer_target
*
8
)
/
10
;
// 80%
(
spatial_layer_target
*
8
)
/
10
;
// 80%
enc_cfg
->
layer_target_bitrate
[
sl
*
svc_ctx
->
temporal_layers
+
2
]
=
spatial_layer_target
;
}
else
if
(
svc_ctx
->
temporal_layering_mode
==
2
||
...
...
@@ -359,7 +348,7 @@ void assign_layer_bitrates(const SvcContext *svc_ctx,
}
}
else
{
float
total
=
0
;
float
alloc_ratio
[
VPX_MAX_LAYERS
]
=
{
0
};
float
alloc_ratio
[
VPX_MAX_LAYERS
]
=
{
0
};
for
(
i
=
0
;
i
<
svc_ctx
->
spatial_layers
;
++
i
)
{
if
(
si
->
svc_params
.
scaling_factor_den
[
i
]
>
0
)
{
...
...
@@ -372,8 +361,9 @@ void assign_layer_bitrates(const SvcContext *svc_ctx,
}
for
(
i
=
0
;
i
<
VPX_SS_MAX_LAYERS
;
++
i
)
{
if
(
total
>
0
)
{
enc_cfg
->
layer_target_bitrate
[
i
]
=
(
unsigned
int
)
(
enc_cfg
->
rc_target_bitrate
*
alloc_ratio
[
i
]
/
total
);
enc_cfg
->
layer_target_bitrate
[
i
]
=
(
unsigned
int
)(
enc_cfg
->
rc_target_bitrate
*
alloc_ratio
[
i
]
/
total
);
}
}
}
...
...
@@ -384,7 +374,7 @@ vpx_codec_err_t vpx_svc_init(SvcContext *svc_ctx, vpx_codec_ctx_t *codec_ctx,
vpx_codec_iface_t
*
iface
,
vpx_codec_enc_cfg_t
*
enc_cfg
)
{
vpx_codec_err_t
res
;
int
i
,
sl
,
tl
;
int
i
,
sl
,
tl
;
SvcInternal_t
*
const
si
=
get_svc_internal
(
svc_ctx
);
if
(
svc_ctx
==
NULL
||
codec_ctx
==
NULL
||
iface
==
NULL
||
enc_cfg
==
NULL
)
{
...
...
@@ -434,23 +424,21 @@ vpx_codec_err_t vpx_svc_init(SvcContext *svc_ctx, vpx_codec_ctx_t *codec_ctx,
res
=
parse_options
(
svc_ctx
,
si
->
options
);
if
(
res
!=
VPX_CODEC_OK
)
return
res
;
if
(
svc_ctx
->
spatial_layers
<
1
)
svc_ctx
->
spatial_layers
=
1
;
if
(
svc_ctx
->
spatial_layers
<
1
)
svc_ctx
->
spatial_layers
=
1
;
if
(
svc_ctx
->
spatial_layers
>
VPX_SS_MAX_LAYERS
)
svc_ctx
->
spatial_layers
=
VPX_SS_MAX_LAYERS
;
if
(
svc_ctx
->
temporal_layers
<
1
)
svc_ctx
->
temporal_layers
=
1
;
if
(
svc_ctx
->
temporal_layers
<
1
)
svc_ctx
->
temporal_layers
=
1
;
if
(
svc_ctx
->
temporal_layers
>
VPX_TS_MAX_LAYERS
)
svc_ctx
->
temporal_layers
=
VPX_TS_MAX_LAYERS
;
if
(
svc_ctx
->
temporal_layers
*
svc_ctx
->
spatial_layers
>
VPX_MAX_LAYERS
)
{
svc_log
(
svc_ctx
,
SVC_LOG_ERROR
,
"spatial layers * temporal layers exceeds the maximum number of "
"allowed layers of %d
\n
"
,
svc_ctx
->
spatial_layers
*
svc_ctx
->
temporal_layers
,
(
int
)
VPX_MAX_LAYERS
);
return
VPX_CODEC_INVALID_PARAM
;
svc_log
(
svc_ctx
,
SVC_LOG_ERROR
,
"spatial layers * temporal layers exceeds the maximum number of "
"allowed layers of %d
\n
"
,
svc_ctx
->
spatial_layers
*
svc_ctx
->
temporal_layers
,
(
int
)
VPX_MAX_LAYERS
);
return
VPX_CODEC_INVALID_PARAM
;
}
assign_layer_bitrates
(
svc_ctx
,
enc_cfg
);
...
...
@@ -462,14 +450,13 @@ vpx_codec_err_t vpx_svc_init(SvcContext *svc_ctx, vpx_codec_ctx_t *codec_ctx,
if
(
svc_ctx
->
temporal_layers
>
1
)
{
int
i
;
for
(
i
=
0
;
i
<
svc_ctx
->
temporal_layers
;
++
i
)
{