diff --git a/codecs/codec_dahdi.c b/codecs/codec_dahdi.c
index ccd323ae6866f8cc6e8bbfaf689de7b30cf44c60..5fedc25cb0672046b570e7c066812fc6ec902039 100644
--- a/codecs/codec_dahdi.c
+++ b/codecs/codec_dahdi.c
@@ -396,7 +396,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);