ref: c7ff8876bb228e9aea34db890d22ac87e940cb87
parent: 6021ff3908a39cd2996650a85dbcea09a6c8cb52
author: Martin Storsjö <[email protected]>
date: Wed Feb 26 17:08:41 EST 2014
Add a new public method for initializing SEncParamExt to default values This simplifies forward source compatibility when new fields are added to SEncParamExt - when new fields are added to SEncParamExt, this method makes sure those fields are initialized to the default value - otherwise all API users would have to manually check SEncParamExt every time it is updated to make sure there's no new fields that should be set to a nonzero value by default (e.g. like bEnableFrameSkip).
--- a/codec/api/svc/codec_api.h
+++ b/codec/api/svc/codec_api.h
@@ -59,6 +59,8 @@
virtual int EXTAPI Initialize (const SEncParamBase* pParam) = 0;
virtual int EXTAPI InitializeExt (const SEncParamExt* pParam) = 0;
+ virtual int EXTAPI GetDefaultParams (SEncParamExt* pParam) = 0;
+
virtual int EXTAPI Uninitialize() = 0;
/*
@@ -141,6 +143,8 @@
int (*Initialize) (ISVCEncoder*, const SEncParamBase* pParam);
int (*InitializeExt) (ISVCEncoder*, const SEncParamExt* pParam);
+
+ int (*GetDefaultParams) (ISVCEncoder*, SEncParamExt* pParam);
int (*Uninitialize) (ISVCEncoder*);
--- a/codec/encoder/plus/inc/welsEncoderExt.h
+++ b/codec/encoder/plus/inc/welsEncoderExt.h
@@ -69,6 +69,8 @@
virtual int EXTAPI Initialize (const SEncParamBase* argv);
virtual int EXTAPI InitializeExt (const SEncParamExt* argv);
+ virtual int EXTAPI GetDefaultParams (SEncParamExt* argv);
+
virtual int EXTAPI Uninitialize();
/*
--- a/codec/encoder/plus/src/welsEncoderExt.cpp
+++ b/codec/encoder/plus/src/welsEncoderExt.cpp
@@ -197,6 +197,11 @@
/* Interfaces override from ISVCEncoder */
+int CWelsH264SVCEncoder::GetDefaultParams (SEncParamExt* argv) {
+ SWelsSvcCodingParam::FillDefault(*argv, true);
+ return cmResultSuccess;
+}
+
/*
* SVC Encoder Initialization
*/
--- a/test/c_interface_test.c
+++ b/test/c_interface_test.c
@@ -12,6 +12,7 @@
void CheckEncoderInterface(ISVCEncoder* p, CheckFunc check) {
CHECK(1, p, Initialize);
CHECK(2, p, InitializeExt);
+ CHECK(10, p, GetDefaultParams);
CHECK(3, p, Uninitialize);
CHECK(4, p, EncodeFrame);
CHECK(5, p, EncodeParameterSets);
--- a/test/cpp_interface_test.cpp
+++ b/test/cpp_interface_test.cpp
@@ -30,6 +30,10 @@
EXPECT_TRUE(gThis == this);
return 2;
}
+ virtual int EXTAPI GetDefaultParams(SEncParamExt* pParam) {
+ EXPECT_TRUE(gThis == this);
+ return 10;
+ }
virtual int EXTAPI Uninitialize() {
EXPECT_TRUE(gThis == this);
return 3;