sbc: Add bitpool capability.

This commit is contained in:
Luiz Augusto von Dentz 2007-10-29 15:02:26 +00:00 committed by Tim-Philipp Müller
parent f2441fe654
commit a2152f6c12
4 changed files with 40 additions and 6 deletions

View file

@ -33,6 +33,7 @@
#define SBC_ENC_DEFAULT_MODE CFG_MODE_AUTO #define SBC_ENC_DEFAULT_MODE CFG_MODE_AUTO
#define SBC_ENC_DEFAULT_BLOCKS 16 #define SBC_ENC_DEFAULT_BLOCKS 16
#define SBC_ENC_DEFAULT_SUB_BANDS 8 #define SBC_ENC_DEFAULT_SUB_BANDS 8
#define SBC_ENC_DEFAULT_BITPOOL 53
#define SBC_ENC_DEFAULT_ALLOCATION CFG_ALLOCATION_AUTO #define SBC_ENC_DEFAULT_ALLOCATION CFG_ALLOCATION_AUTO
GST_DEBUG_CATEGORY_STATIC (sbc_enc_debug); GST_DEBUG_CATEGORY_STATIC (sbc_enc_debug);
@ -112,7 +113,8 @@ GST_STATIC_PAD_TEMPLATE ("src", GST_PAD_SRC, GST_PAD_ALWAYS,
"mode = (string) { mono, dual, stereo, joint }, " "mode = (string) { mono, dual, stereo, joint }, "
"blocks = (int) { 4, 8, 12, 16 }, " "blocks = (int) { 4, 8, 12, 16 }, "
"subbands = (int) { 4, 8 }, " "subbands = (int) { 4, 8 }, "
"allocation = (string) { snr, loudness }")); "allocation = (string) { snr, loudness },"
"bitpool = (int) [ 2, 64 ]"));
static GstCaps * static GstCaps *
@ -147,6 +149,8 @@ sbc_enc_generate_srcpad_caps (GstSbcEnc * enc, GstCaps * caps)
else else
enc->sbc.allocation = enc->allocation; enc->sbc.allocation = enc->allocation;
enc->sbc.bitpool = SBC_ENC_DEFAULT_BITPOOL;
mode = gst_sbc_get_mode_string (enc->sbc.joint); mode = gst_sbc_get_mode_string (enc->sbc.joint);
allocation = gst_sbc_get_allocation_string (enc->sbc.allocation); allocation = gst_sbc_get_allocation_string (enc->sbc.allocation);
@ -156,7 +160,8 @@ sbc_enc_generate_srcpad_caps (GstSbcEnc * enc, GstCaps * caps)
"mode", G_TYPE_STRING, mode, "mode", G_TYPE_STRING, mode,
"subbands", G_TYPE_INT, enc->sbc.subbands, "subbands", G_TYPE_INT, enc->sbc.subbands,
"blocks", G_TYPE_INT, enc->sbc.blocks, "blocks", G_TYPE_INT, enc->sbc.blocks,
"allocation", G_TYPE_STRING, allocation, NULL); "allocation", G_TYPE_STRING, allocation,
"bitpool", G_TYPE_INT, enc->sbc.bitpool, NULL);
return src_caps; return src_caps;
} }

View file

@ -53,9 +53,10 @@ GST_STATIC_PAD_TEMPLATE ("src", GST_PAD_SRC, GST_PAD_ALWAYS,
"mode = (string) { mono, dual, stereo, joint }, " "mode = (string) { mono, dual, stereo, joint }, "
"blocks = (int) { 4, 8, 12, 16 }, " "blocks = (int) { 4, 8, 12, 16 }, "
"subbands = (int) { 4, 8 }, " "subbands = (int) { 4, 8 }, "
"allocation = (string) { snr, loudness }")); "allocation = (string) { snr, loudness },"
"bitpool = (int) [ 2, 64 ]"));
/* reates a fixed caps from the caps given. */ /* Creates a fixed caps from the caps given. */
static GstCaps * static GstCaps *
sbc_parse_select_caps (GstSbcParse * parse, GstCaps * caps) sbc_parse_select_caps (GstSbcParse * parse, GstCaps * caps)
{ {
@ -63,7 +64,7 @@ sbc_parse_select_caps (GstSbcParse * parse, GstCaps * caps)
GstStructure *structure; GstStructure *structure;
const GValue *value; const GValue *value;
gboolean error = FALSE; gboolean error = FALSE;
gint temp, rate, channels, blocks, subbands; gint temp, rate, channels, blocks, subbands, bitpool;
const gchar *allocation = NULL; const gchar *allocation = NULL;
const gchar *mode = NULL; const gchar *mode = NULL;
const gchar *error_message = NULL; const gchar *error_message = NULL;
@ -134,6 +135,20 @@ sbc_parse_select_caps (GstSbcParse * parse, GstCaps * caps)
subbands = temp; subbands = temp;
} }
if (!gst_structure_has_field (structure, "bitpool")) {
error = TRUE;
error_message = "no bitpool";
goto error;
} else {
value = gst_structure_get_value (structure, "bitpool");
if (GST_VALUE_HOLDS_INT_RANGE (value)) {
temp = gst_sbc_select_bitpool_from_range (value);
} else {
temp = g_value_get_int (value);
}
bitpool = temp;
}
if (!gst_structure_has_field (structure, "allocation")) { if (!gst_structure_has_field (structure, "allocation")) {
error = TRUE; error = TRUE;
error_message = "no allocation."; error_message = "no allocation.";
@ -172,11 +187,13 @@ error:
"mode", G_TYPE_STRING, mode, "mode", G_TYPE_STRING, mode,
"blocks", G_TYPE_INT, blocks, "blocks", G_TYPE_INT, blocks,
"subbands", G_TYPE_INT, subbands, "subbands", G_TYPE_INT, subbands,
"allocation", G_TYPE_STRING, allocation, NULL); "allocation", G_TYPE_STRING, allocation,
"bitpool", G_TYPE_INT, bitpool, NULL);
parse->sbc.rate = rate; parse->sbc.rate = rate;
parse->sbc.channels = channels; parse->sbc.channels = channels;
parse->sbc.blocks = blocks; parse->sbc.blocks = blocks;
parse->sbc.subbands = subbands; parse->sbc.subbands = subbands;
parse->sbc.bitpool = bitpool;
parse->sbc.joint = gst_sbc_get_mode_int (mode); parse->sbc.joint = gst_sbc_get_mode_int (mode);
parse->sbc.allocation = gst_sbc_get_allocation_mode_int (allocation); parse->sbc.allocation = gst_sbc_get_allocation_mode_int (allocation);

View file

@ -112,6 +112,16 @@ gst_sbc_select_subbands_from_range (const GValue * value)
return gst_value_get_int_range_max (value); return gst_value_get_int_range_max (value);
} }
/*
* Selects one bitpool option from a range
* TODO - use a better approach to this (it is selecting the maximum value)
*/
gint
gst_sbc_select_bitpool_from_range (const GValue * value)
{
return gst_value_get_int_range_max (value);
}
/* /*
* Selects one allocation mode from the ones on the list * Selects one allocation mode from the ones on the list
* TODO - use a better approach * TODO - use a better approach

View file

@ -35,6 +35,8 @@ gint gst_sbc_select_blocks_from_range(const GValue *value);
gint gst_sbc_select_subbands_from_list(const GValue *value); gint gst_sbc_select_subbands_from_list(const GValue *value);
gint gst_sbc_select_subbands_from_range(const GValue *value); gint gst_sbc_select_subbands_from_range(const GValue *value);
gint gst_sbc_select_bitpool_from_range(const GValue *value);
const gchar *gst_sbc_get_allocation_from_list(const GValue *value); const gchar *gst_sbc_get_allocation_from_list(const GValue *value);
gint gst_sbc_get_allocation_mode_int(const gchar *allocation); gint gst_sbc_get_allocation_mode_int(const gchar *allocation);
const gchar *gst_sbc_get_allocation_string(int alloc); const gchar *gst_sbc_get_allocation_string(int alloc);