Skip to content

Commit

Permalink
Merge pull request #11 from membraneframework/fix/quality-option
Browse files Browse the repository at this point in the history
Don't accept quality as an atom in options
  • Loading branch information
bblaszkow06 authored Feb 18, 2019
2 parents ecc6550 + ab8c2f7 commit 79f4cda
Show file tree
Hide file tree
Showing 4 changed files with 16 additions and 13 deletions.
2 changes: 1 addition & 1 deletion c_src/membrane_element_lame/encoder.c
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ UNIFEX_TERM create(UnifexEnv *env, int channels, int bitrate, int quality) {
lame_set_num_channels(lame_state, channels);
lame_set_in_samplerate(lame_state, 44100);
lame_set_brate(lame_state, bitrate);
lame_set_quality(lame_state, quality); /* 2=high 5 = medium 7=low */
lame_set_quality(lame_state, quality);

if (lame_init_params(lame_state) < 0) {
result = create_result_error(env, "lame_init");
Expand Down
17 changes: 10 additions & 7 deletions lib/membrane_element_lame/encoder.ex
Original file line number Diff line number Diff line change
Expand Up @@ -31,11 +31,17 @@ defmodule Membrane.Element.Lame.Encoder do
"""
],
quality: [
type: :atom,
default: :medium,
spec: :low | :medium | :high,
type: :number,
default: 5,
spec: non_neg_integer,
description: """
Quality of the encoded audio.
Value of this parameter affects quality by selecting one of the algorithms
for encoding: `0` being best (and very slow) and `9` being worst.
Recommended values:
* `2` - near-best quality, not too slow
* `5` - good quality, fast
* `7` - ok quality, really fast
"""
]

Expand Down Expand Up @@ -180,9 +186,6 @@ defmodule Membrane.Element.Lame.Encoder do
end
end

defp map_quality_to_value(:low), do: {:ok, 7}
defp map_quality_to_value(:medium), do: {:ok, 5}
defp map_quality_to_value(:high), do: {:ok, 2}
defp map_quality_to_value(quality) when quality in 0..9, do: {:ok, quality}
defp map_quality_to_value(_), do: {:error, :invalid_quality}
end
2 changes: 1 addition & 1 deletion mix.exs
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
defmodule Membrane.Element.Lame.Mixfile do
use Mix.Project

@version "0.2.2"
@version "0.3.0"
@github_url "https://github.com/membraneframework/membrane-element-lame"

def project do
Expand Down
8 changes: 4 additions & 4 deletions mix.lock
Original file line number Diff line number Diff line change
Expand Up @@ -2,13 +2,13 @@
"bimap": {:hex, :bimap, "1.0.0", "80b707adb832cc7670309c85757caf3493b29a3e484cc6eafd65fceaeb107c05", [:mix], [], "hexpm"},
"bunch": {:hex, :bunch, "0.2.0", "dd9b1bc4603582c1fc3e27aaeb9c74181395ba67d3cfd7dbde9a41cc7383f954", [:mix], [], "hexpm"},
"bunch_native": {:hex, :bunch_native, "0.1.1", "9895b2cf5e5c6847af5de80c8d485ea9c69021a21e74c7237ab64e7a225c06c2", [:mix], [{:bundlex, "~> 0.1", [hex: :bundlex, repo: "hexpm", optional: false]}], "hexpm"},
"bundlex": {:hex, :bundlex, "0.1.6", "6df5d053e0bf0b2b3b0ea73cbf8b77279d422fd112de42e19c3c88787e96e3c6", [:mix], [{:bunch, "~> 0.2", [hex: :bunch, repo: "hexpm", optional: false]}], "hexpm"},
"bundlex": {:hex, :bundlex, "0.1.7", "460a93823fdfdae1202c0f9fa45f9a5bcfdf3a371e238dcac4e24744e1d2ee7a", [:mix], [{:bunch, "~> 0.2", [hex: :bunch, repo: "hexpm", optional: false]}], "hexpm"},
"earmark": {:hex, :earmark, "1.3.1", "73812f447f7a42358d3ba79283cfa3075a7580a3a2ed457616d6517ac3738cb9", [:mix], [], "hexpm"},
"espec": {:hex, :espec, "1.6.4", "50a5b7b2931264f7bb73cd8efa6d2b3d5dff47ebbcb4efefaa4b0403d481973b", [:mix], [{:meck, "0.8.12", [hex: :meck, repo: "hexpm", optional: false]}], "hexpm"},
"espec": {:hex, :espec, "1.6.5", "5aab5a353a2d9f350aee549f4c2bbae9ce904578954cddf29705673b66ead427", [:mix], [{:meck, "~> 0.8.13", [hex: :meck, repo: "hexpm", optional: false]}], "hexpm"},
"ex_doc": {:hex, :ex_doc, "0.19.3", "3c7b0f02851f5fc13b040e8e925051452e41248f685e40250d7e40b07b9f8c10", [:mix], [{:earmark, "~> 1.2", [hex: :earmark, repo: "hexpm", optional: false]}, {:makeup_elixir, "~> 0.10", [hex: :makeup_elixir, repo: "hexpm", optional: false]}], "hexpm"},
"makeup": {:hex, :makeup, "0.8.0", "9cf32aea71c7fe0a4b2e9246c2c4978f9070257e5c9ce6d4a28ec450a839b55f", [:mix], [{:nimble_parsec, "~> 0.5.0", [hex: :nimble_parsec, repo: "hexpm", optional: false]}], "hexpm"},
"makeup_elixir": {:hex, :makeup_elixir, "0.13.0", "be7a477997dcac2e48a9d695ec730b2d22418292675c75aa2d34ba0909dcdeda", [:mix], [{:makeup, "~> 0.8", [hex: :makeup, repo: "hexpm", optional: false]}], "hexpm"},
"meck": {:hex, :meck, "0.8.12", "1f7b1a9f5d12c511848fec26bbefd09a21e1432eadb8982d9a8aceb9891a3cf2", [:rebar3], [], "hexpm"},
"meck": {:hex, :meck, "0.8.13", "ffedb39f99b0b99703b8601c6f17c7f76313ee12de6b646e671e3188401f7866", [:rebar3], [], "hexpm"},
"membrane_caps_audio_mpeg": {:hex, :membrane_caps_audio_mpeg, "0.2.0", "9cf9a63f03e25b31cf31445325aa68e60a07d36ee1e759caa1422fa45df49367", [:mix], [], "hexpm"},
"membrane_caps_audio_raw": {:hex, :membrane_caps_audio_raw, "0.1.5", "d4becb167f37fab52700ac7f19bd09b3f580eee3b71f4586b6f0dd1e01f2d5f5", [:mix], [{:bimap, "~> 1.0", [hex: :bimap, repo: "hexpm", optional: false]}, {:bunch, "~> 0.1", [hex: :bunch, repo: "hexpm", optional: false]}, {:membrane_core, "~> 0.2", [hex: :membrane_core, repo: "hexpm", optional: false]}], "hexpm"},
"membrane_common_c": {:hex, :membrane_common_c, "0.2.1", "a436baefab1a1af68366bf8509a2f91dd1c14e629ca97dd09d394bec115e6853", [:mix], [{:bundlex, "~> 0.1.3", [hex: :bundlex, repo: "hexpm", optional: false]}, {:membrane_core, "~> 0.2.0", [hex: :membrane_core, repo: "hexpm", optional: false]}, {:shmex, "~> 0.1.3", [hex: :shmex, repo: "hexpm", optional: false]}, {:unifex, "~> 0.2.0", [hex: :unifex, repo: "hexpm", optional: false]}], "hexpm"},
Expand All @@ -19,5 +19,5 @@
"porcelain": {:hex, :porcelain, "2.0.3", "2d77b17d1f21fed875b8c5ecba72a01533db2013bd2e5e62c6d286c029150fdc", [:mix], [], "hexpm"},
"qex": {:hex, :qex, "0.5.0", "5a3a9becf67d4006377c4c247ffdaaa8ae5b3634a0caadb788dc24d6125068f4", [:mix], [], "hexpm"},
"shmex": {:hex, :shmex, "0.1.4", "77ede75ab2bdd5990807ec6c65055168bbf8a96b2ce52224c2be66a1804ac56f", [:mix], [{:bunch, "~> 0.1", [hex: :bunch, repo: "hexpm", optional: false]}, {:bunch_native, "~> 0.1", [hex: :bunch_native, repo: "hexpm", optional: false]}, {:bundlex, "~> 0.1.3", [hex: :bundlex, repo: "hexpm", optional: false]}], "hexpm"},
"unifex": {:hex, :unifex, "0.2.1", "edbca2dc525f14867723168ce1d4c3d2d8d34aaf1a2e2637c3f95c2a20a0e9bb", [:mix], [{:bunch, "~> 0.1", [hex: :bunch, repo: "hexpm", optional: false]}, {:bundlex, "~> 0.1.5", [hex: :bundlex, repo: "hexpm", optional: false]}, {:shmex, "~> 0.1.3", [hex: :shmex, repo: "hexpm", optional: false]}], "hexpm"},
"unifex": {:hex, :unifex, "0.2.2", "b3ab0c7a027e2d17ce58a516bf76d950a5343e88b07305e6538369a4133f135d", [:mix], [{:bunch, "~> 0.1", [hex: :bunch, repo: "hexpm", optional: false]}, {:bundlex, "~> 0.1.5", [hex: :bundlex, repo: "hexpm", optional: false]}, {:shmex, "~> 0.1.3", [hex: :shmex, repo: "hexpm", optional: false]}], "hexpm"},
}

0 comments on commit 79f4cda

Please sign in to comment.