diff --git a/codecs/codec_dahdi.c b/codecs/codec_dahdi.c
index c4aa32fb3a829e228d565ed3d1d90dd0cbed104d..caaf99cdf5e99d641f75b486c4290e1e0b7d8954 100644
--- a/codecs/codec_dahdi.c
+++ b/codecs/codec_dahdi.c
@@ -394,7 +394,7 @@ static void dahdi_destroy(struct ast_trans_pvt *pvt)
 {
 	struct codec_dahdi_pvt *dahdip = pvt->pvt;
 
-	switch (dahdip->fmts.dstfmt) {
+	switch (ast_format_id_from_old_bitfield(dahdip->fmts.dstfmt)) {
 	case AST_FORMAT_G729A:
 	case AST_FORMAT_G723_1:
 		ast_atomic_fetchadd_int(&channels.encoders, -1);