Change in ...libosmocore[master]: codec/ecu: Introduce new generic Error Concealment Unit abstraction

2019-09-02 Thread laforge
laforge has posted comments on this change. ( 
https://gerrit.osmocom.org/c/libosmocore/+/15026 )

Change subject: codec/ecu: Introduce new generic Error Concealment Unit 
abstraction
..


Patch Set 4: Code-Review+2


--
To view, visit https://gerrit.osmocom.org/c/libosmocore/+/15026
To unsubscribe, or for help writing mail filters, visit 
https://gerrit.osmocom.org/settings

Gerrit-Project: libosmocore
Gerrit-Branch: master
Gerrit-Change-Id: I4d33c9c7c2d4c7462ff38a49c178b65accae1915
Gerrit-Change-Number: 15026
Gerrit-PatchSet: 4
Gerrit-Owner: laforge 
Gerrit-Reviewer: Jenkins Builder
Gerrit-Reviewer: dexter 
Gerrit-Reviewer: fixeria 
Gerrit-Reviewer: laforge 
Gerrit-Comment-Date: Mon, 02 Sep 2019 09:13:49 +
Gerrit-HasComments: No
Gerrit-Has-Labels: Yes
Gerrit-MessageType: comment


Change in ...libosmocore[master]: codec/ecu: Introduce new generic Error Concealment Unit abstraction

2019-09-02 Thread laforge
laforge has submitted this change and it was merged. ( 
https://gerrit.osmocom.org/c/libosmocore/+/15026 )

Change subject: codec/ecu: Introduce new generic Error Concealment Unit 
abstraction
..

codec/ecu: Introduce new generic Error Concealment Unit abstraction

We don't want to expose the details of a given ECU implementation to
the user (e.g. osmo-bts), but have a generic abstraction layer where
an ECU implementation can simply register a few call-back functions
with the generic core.

As the developer and copyright holder of the related code, I hereby
state that any ECU implementation using 'struct osmo_ecu_ops' and
registering with the 'osmo_ecu_register()' function shall not be
considered as a derivative work under any applicable copyright law;
the copyleft terms of GPLv2 shall hence not apply to any such ECU
implementation.

The intent of the above exception is to allow anyone to combine
third party Error Concealment Unit implementations with libosmocore,
including but not limited to such published by ETSI.

Change-Id: I4d33c9c7c2d4c7462ff38a49c178b65accae1915
---
M include/osmocom/codec/ecu.h
M src/codec/Makefile.am
A src/codec/ecu.c
M src/codec/ecu_fr.c
M tests/codec/codec_ecu_fr_test.c
M tests/codec/codec_ecu_fr_test.ok
6 files changed, 447 insertions(+), 1 deletion(-)

Approvals:
  laforge: Looks good to me, approved
  fixeria: Looks good to me, but someone else must approve
  Jenkins Builder: Verified



diff --git a/include/osmocom/codec/ecu.h b/include/osmocom/codec/ecu.h
index ec0a2f8..ec94670 100644
--- a/include/osmocom/codec/ecu.h
+++ b/include/osmocom/codec/ecu.h
@@ -13,3 +13,57 @@

 void osmo_ecu_fr_reset(struct osmo_ecu_fr_state *state, const uint8_t *frame);
 int osmo_ecu_fr_conceal(struct osmo_ecu_fr_state *state, uint8_t *frame);
+
+enum osmo_ecu_codec {
+   OSMO_ECU_CODEC_HR,
+   OSMO_ECU_CODEC_FR,
+   OSMO_ECU_CODEC_EFR,
+   OSMO_ECU_CODEC_AMR,
+   _NUM_OSMO_ECU_CODECS
+};
+
+/***
+ * Generic ECU abstraction layer below
+ ***/
+
+/* As the developer and copyright holder of the related code, I hereby
+ * state that any ECU implementation using 'struct osmo_ecu_ops' and
+ * registering with the 'osmo_ecu_register()' function shall not be
+ * considered as a derivative work under any applicable copyright law;
+ * the copyleft terms of GPLv2 shall hence not apply to any such ECU
+ * implementation.
+ *
+ * The intent of the above exception is to allow anyone to combine third
+ * party Error Concealment Unit implementations with libosmocodec.
+ * including but not limited to such published by ETSI.
+ *
+ *   -- Harald Welte  on August 1, 2019.
+ */
+
+struct osmo_ecu_state {
+   enum osmo_ecu_codec codec;
+   uint8_t data[0];
+};
+
+/* initialize an ECU instance */
+struct osmo_ecu_state *osmo_ecu_init(void *ctx, enum osmo_ecu_codec codec);
+
+/* destroy an ECU instance */
+void osmo_ecu_destroy(struct osmo_ecu_state *st);
+
+/* process a received frame a substitute/erroneous frame */
+int osmo_ecu_frame_in(struct osmo_ecu_state *st, bool bfi,
+ const uint8_t *frame, unsigned int frame_bytes);
+
+/* generate output data for a substitute/erroneous frame */
+int osmo_ecu_frame_out(struct osmo_ecu_state *st, uint8_t *frame_out);
+
+struct osmo_ecu_ops {
+   struct osmo_ecu_state * (*init)(void *ctx, enum osmo_ecu_codec codec);
+   void (*destroy)(struct osmo_ecu_state *);
+   int (*frame_in)(struct osmo_ecu_state *st, bool bfi,
+   const uint8_t *frame, unsigned int frame_bytes);
+   int (*frame_out)(struct osmo_ecu_state *st, uint8_t *frame_out);
+};
+
+int osmo_ecu_register(const struct osmo_ecu_ops *ops, enum osmo_ecu_codec 
codec);
diff --git a/src/codec/Makefile.am b/src/codec/Makefile.am
index b522d43..c9d7a22 100644
--- a/src/codec/Makefile.am
+++ b/src/codec/Makefile.am
@@ -13,6 +13,6 @@

 lib_LTLIBRARIES = libosmocodec.la

-libosmocodec_la_SOURCES = gsm610.c gsm620.c gsm660.c gsm690.c ecu_fr.c
+libosmocodec_la_SOURCES = gsm610.c gsm620.c gsm660.c gsm690.c ecu.c ecu_fr.c
 libosmocodec_la_LDFLAGS = -version-info $(LIBVERSION) -no-undefined
 libosmocodec_la_LIBADD = $(top_builddir)/src/libosmocore.la
diff --git a/src/codec/ecu.c b/src/codec/ecu.c
new file mode 100644
index 000..db7148c
--- /dev/null
+++ b/src/codec/ecu.c
@@ -0,0 +1,118 @@
+/* Core infrastructure for ECU implementations */
+
+/* (C) 2019 by Harald Welte 
+ *
+ * All Rights Reserved
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation; either version 2 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY 

Change in ...libosmocore[master]: codec/ecu: Introduce new generic Error Concealment Unit abstraction

2019-08-02 Thread laforge
laforge has posted comments on this change. ( 
https://gerrit.osmocom.org/c/libosmocore/+/15026 )

Change subject: codec/ecu: Introduce new generic Error Concealment Unit 
abstraction
..


Patch Set 4:

(1 comment)

https://gerrit.osmocom.org/#/c/15026/4/include/osmocom/codec/ecu.h
File include/osmocom/codec/ecu.h:

https://gerrit.osmocom.org/#/c/15026/4/include/osmocom/codec/ecu.h@45
PS4, Line 45: uint8_t data[0];
> Not sure if it's a good idea to use a flexible array member here. […]
it's a very typcial pattern in linux kernel development, hence that's what I'm 
using here, too.  In general, the "data" part is allocated always at the same 
time as the osmo_ecu_state.  Allocating them both at the same time avoids 
malloc pressure, can help avoid memory fragmentation, allows the use of 
"offsetof" to get from inner to outer struct (rather than having to use an 
explicit back-pointer) and avoids the risk of ever only freeing one of the two.



--
To view, visit https://gerrit.osmocom.org/c/libosmocore/+/15026
To unsubscribe, or for help writing mail filters, visit 
https://gerrit.osmocom.org/settings

Gerrit-Project: libosmocore
Gerrit-Branch: master
Gerrit-Change-Id: I4d33c9c7c2d4c7462ff38a49c178b65accae1915
Gerrit-Change-Number: 15026
Gerrit-PatchSet: 4
Gerrit-Owner: laforge 
Gerrit-Reviewer: Jenkins Builder
Gerrit-Reviewer: dexter 
Gerrit-Reviewer: fixeria 
Gerrit-Reviewer: laforge 
Gerrit-Comment-Date: Fri, 02 Aug 2019 07:19:47 +
Gerrit-HasComments: Yes
Gerrit-Has-Labels: No
Comment-In-Reply-To: fixeria 
Gerrit-MessageType: comment


Change in ...libosmocore[master]: codec/ecu: Introduce new generic Error Concealment Unit abstraction

2019-08-01 Thread fixeria
fixeria has posted comments on this change. ( 
https://gerrit.osmocom.org/c/libosmocore/+/15026 )

Change subject: codec/ecu: Introduce new generic Error Concealment Unit 
abstraction
..


Patch Set 4:

(1 comment)

https://gerrit.osmocom.org/#/c/15026/4/include/osmocom/codec/ecu.h
File include/osmocom/codec/ecu.h:

https://gerrit.osmocom.org/#/c/15026/4/include/osmocom/codec/ecu.h@45
PS4, Line 45: uint8_t data[0];
Not sure if it's a good idea to use a flexible array member here. Why not just 
a 'void *' pointer? What are the benefits of such strict co-allocation?



--
To view, visit https://gerrit.osmocom.org/c/libosmocore/+/15026
To unsubscribe, or for help writing mail filters, visit 
https://gerrit.osmocom.org/settings

Gerrit-Project: libosmocore
Gerrit-Branch: master
Gerrit-Change-Id: I4d33c9c7c2d4c7462ff38a49c178b65accae1915
Gerrit-Change-Number: 15026
Gerrit-PatchSet: 4
Gerrit-Owner: laforge 
Gerrit-Reviewer: Jenkins Builder
Gerrit-Reviewer: dexter 
Gerrit-Reviewer: fixeria 
Gerrit-Comment-Date: Thu, 01 Aug 2019 21:59:26 +
Gerrit-HasComments: Yes
Gerrit-Has-Labels: No
Gerrit-MessageType: comment


Change in ...libosmocore[master]: codec/ecu: Introduce new generic Error Concealment Unit abstraction

2019-08-01 Thread fixeria
fixeria has posted comments on this change. ( 
https://gerrit.osmocom.org/c/libosmocore/+/15026 )

Change subject: codec/ecu: Introduce new generic Error Concealment Unit 
abstraction
..


Patch Set 4: Code-Review+1


--
To view, visit https://gerrit.osmocom.org/c/libosmocore/+/15026
To unsubscribe, or for help writing mail filters, visit 
https://gerrit.osmocom.org/settings

Gerrit-Project: libosmocore
Gerrit-Branch: master
Gerrit-Change-Id: I4d33c9c7c2d4c7462ff38a49c178b65accae1915
Gerrit-Change-Number: 15026
Gerrit-PatchSet: 4
Gerrit-Owner: laforge 
Gerrit-Reviewer: Jenkins Builder
Gerrit-Reviewer: dexter 
Gerrit-Reviewer: fixeria 
Gerrit-Comment-Date: Thu, 01 Aug 2019 21:56:41 +
Gerrit-HasComments: No
Gerrit-Has-Labels: Yes
Gerrit-MessageType: comment


Change in ...libosmocore[master]: codec/ecu: Introduce new generic Error Concealment Unit abstraction

2019-08-01 Thread laforge
Hello dexter, Jenkins Builder,

I'd like you to reexamine a change. Please visit

https://gerrit.osmocom.org/c/libosmocore/+/15026

to look at the new patch set (#4).

Change subject: codec/ecu: Introduce new generic Error Concealment Unit 
abstraction
..

codec/ecu: Introduce new generic Error Concealment Unit abstraction

We don't want to expose the details of a given ECU implementation to
the user (e.g. osmo-bts), but have a generic abstraction layer where
an ECU implementation can simply register a few call-back functions
with the generic core.

As the developer and copyright holder of the related code, I hereby
state that any ECU implementation using 'struct osmo_ecu_ops' and
registering with the 'osmo_ecu_register()' function shall not be
considered as a derivative work under any applicable copyright law;
the copyleft terms of GPLv2 shall hence not apply to any such ECU
implementation.

The intent of the above exception is to allow anyone to combine
third party Error Concealment Unit implementations with libosmocore,
including but not limited to such published by ETSI.

Change-Id: I4d33c9c7c2d4c7462ff38a49c178b65accae1915
---
M include/osmocom/codec/ecu.h
M src/codec/Makefile.am
A src/codec/ecu.c
M src/codec/ecu_fr.c
M tests/codec/codec_ecu_fr_test.c
M tests/codec/codec_ecu_fr_test.ok
6 files changed, 447 insertions(+), 1 deletion(-)


  git pull ssh://gerrit.osmocom.org:29418/libosmocore refs/changes/26/15026/4
--
To view, visit https://gerrit.osmocom.org/c/libosmocore/+/15026
To unsubscribe, or for help writing mail filters, visit 
https://gerrit.osmocom.org/settings

Gerrit-Project: libosmocore
Gerrit-Branch: master
Gerrit-Change-Id: I4d33c9c7c2d4c7462ff38a49c178b65accae1915
Gerrit-Change-Number: 15026
Gerrit-PatchSet: 4
Gerrit-Owner: laforge 
Gerrit-Reviewer: Jenkins Builder
Gerrit-Reviewer: dexter 
Gerrit-MessageType: newpatchset


Change in ...libosmocore[master]: codec/ecu: Introduce new generic Error Concealment Unit abstraction

2019-08-01 Thread laforge
Hello dexter, Jenkins Builder,

I'd like you to reexamine a change. Please visit

https://gerrit.osmocom.org/c/libosmocore/+/15026

to look at the new patch set (#3).

Change subject: codec/ecu: Introduce new generic Error Concealment Unit 
abstraction
..

codec/ecu: Introduce new generic Error Concealment Unit abstraction

We don't want to expose the details of a given ECU implementation to
the user (e.g. osmo-bts), but have a generic abstraction layer where
an ECU implementation can simply register a few call-back functions
with the generic core.

As the developer and copyright holder of the related code, I hereby
state that any ECU implementation using 'struct osmo_ecu_ops' and
registering with the 'osmo_ecu_register()' function shall not be
considered as a derivative work under any applicable copyright law;
the copyleft terms of GPLv2 shall hence not apply to any such ECU
implementation.

The intent of the above exception is to allow anyone to combine
third party Error Concealment Unit implementations with libosmocore,
including but not limited to such published by ETSI.

Change-Id: I4d33c9c7c2d4c7462ff38a49c178b65accae1915
---
M include/osmocom/codec/ecu.h
M src/codec/Makefile.am
A src/codec/ecu.c
M src/codec/ecu_fr.c
M tests/codec/codec_ecu_fr_test.c
M tests/codec/codec_ecu_fr_test.ok
6 files changed, 445 insertions(+), 1 deletion(-)


  git pull ssh://gerrit.osmocom.org:29418/libosmocore refs/changes/26/15026/3
--
To view, visit https://gerrit.osmocom.org/c/libosmocore/+/15026
To unsubscribe, or for help writing mail filters, visit 
https://gerrit.osmocom.org/settings

Gerrit-Project: libosmocore
Gerrit-Branch: master
Gerrit-Change-Id: I4d33c9c7c2d4c7462ff38a49c178b65accae1915
Gerrit-Change-Number: 15026
Gerrit-PatchSet: 3
Gerrit-Owner: laforge 
Gerrit-Reviewer: Jenkins Builder
Gerrit-Reviewer: dexter 
Gerrit-MessageType: newpatchset


Change in ...libosmocore[master]: codec/ecu: Introduce new generic Error Concealment Unit abstraction

2019-08-01 Thread laforge
laforge has uploaded this change for review. ( 
https://gerrit.osmocom.org/c/libosmocore/+/15026


Change subject: codec/ecu: Introduce new generic Error Concealment Unit 
abstraction
..

codec/ecu: Introduce new generic Error Concealment Unit abstraction

We don't want to expose the details of a given ECU implementation to
the user (e.g. osmo-bts), but have a generic abstraction layer where
an ECU implementation can simply register a few call-back functions
with the generic core.

As the developer and copyright holder of the related code, I hereby
state that any ECU implementation using 'struct osmo_ecu_ops' and
registering with the 'osmo_ecu_register()' function shall not be
considered as a derivative work under any applicable copyright law;
the copyleft terms of GPLv2 shall hence not apply to any such ECU
implementation.

The intent of the above exception is to allow anyone to combine
third party Error Concealment Unit implementations with libosmocore,
including but not limited to such published by ETSI.

Change-Id: I4d33c9c7c2d4c7462ff38a49c178b65accae1915
---
M include/osmocom/codec/ecu.h
M src/codec/Makefile.am
A src/codec/ecu.c
M src/codec/ecu_fr.c
M tests/codec/codec_ecu_fr_test.c
M tests/codec/codec_ecu_fr_test.ok
6 files changed, 445 insertions(+), 1 deletion(-)



  git pull ssh://gerrit.osmocom.org:29418/libosmocore refs/changes/26/15026/1

diff --git a/include/osmocom/codec/ecu.h b/include/osmocom/codec/ecu.h
index f7a29a0..a566712 100644
--- a/include/osmocom/codec/ecu.h
+++ b/include/osmocom/codec/ecu.h
@@ -13,3 +13,57 @@

 void osmo_ecu_fr_reset(struct osmo_ecu_fr_state *state, uint8_t *frame);
 int osmo_ecu_fr_conceal(struct osmo_ecu_fr_state *state, uint8_t *frame);
+
+enum osmo_ecu_codec {
+   OSMO_ECU_CODEC_HR,
+   OSMO_ECU_CODEC_FR,
+   OSMO_ECU_CODEC_EFR,
+   OSMO_ECU_CODEC_AMR,
+   _NUM_OSMO_ECU_CODECS
+};
+
+/***
+ * Generic ECU abstraction layer below
+ ***/
+
+/* As the developer and copyright holder of the related code, I hereby
+ * state that any ECU implementation using 'struct osmo_ecu_ops' and
+ * registering with the 'osmo_ecu_register()' function shall not be
+ * considered as a derivative work under any applicable copyright law;
+ * the copyleft terms of GPLv2 shall hence not apply to any such ECU
+ * implementation.
+ *
+ * The intent of the above exception is to allow anyone to combine third
+ * party Error Concealment Unit implementations with libosmocodec.
+ * including but not limited to such published by ETSI.
+ *
+ *   -- Harald Welte  on August 1, 2019.
+ */
+
+struct osmo_ecu_state {
+   enum osmo_ecu_codec codec;
+   uint8_t data[0];
+};
+
+/* initialize an ECU instance */
+struct osmo_ecu_state *osmo_ecu_init(void *ctx, enum osmo_ecu_codec codec);
+
+/* destroy an ECU instance */
+void osmo_ecu_destroy(struct osmo_ecu_state *st);
+
+/* process a received frame a substitute/erroneous frame */
+int osmo_ecu_frame_in(struct osmo_ecu_state *st, bool bfi,
+ const uint8_t *frame, unsigned int frame_bytes);
+
+/* generate output data for a substitute/erroneous frame */
+int osmo_ecu_frame_out(struct osmo_ecu_state *st, uint8_t *frame_out);
+
+struct osmo_ecu_ops {
+   struct osmo_ecu_state * (*init)(void *ctx, enum osmo_ecu_codec codec);
+   void (*destroy)(struct osmo_ecu_state *);
+   int (*frame_in)(struct osmo_ecu_state *st, bool bfi,
+   const uint8_t *frame, unsigned int frame_bytes);
+   int (*frame_out)(struct osmo_ecu_state *st, uint8_t *frame_out);
+};
+
+int osmo_ecu_register(const struct osmo_ecu_ops *ops, enum osmo_ecu_codec 
codec);
diff --git a/src/codec/Makefile.am b/src/codec/Makefile.am
index b522d43..c9d7a22 100644
--- a/src/codec/Makefile.am
+++ b/src/codec/Makefile.am
@@ -13,6 +13,6 @@

 lib_LTLIBRARIES = libosmocodec.la

-libosmocodec_la_SOURCES = gsm610.c gsm620.c gsm660.c gsm690.c ecu_fr.c
+libosmocodec_la_SOURCES = gsm610.c gsm620.c gsm660.c gsm690.c ecu.c ecu_fr.c
 libosmocodec_la_LDFLAGS = -version-info $(LIBVERSION) -no-undefined
 libosmocodec_la_LIBADD = $(top_builddir)/src/libosmocore.la
diff --git a/src/codec/ecu.c b/src/codec/ecu.c
new file mode 100644
index 000..db7148c
--- /dev/null
+++ b/src/codec/ecu.c
@@ -0,0 +1,118 @@
+/* Core infrastructure for ECU implementations */
+
+/* (C) 2019 by Harald Welte 
+ *
+ * All Rights Reserved
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation; either version 2 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or