[DVDnav-discuss] [PATCH] Fix dvdnav_audio_stream_format(...)

Andi ace20022 at ymail.com
Thu Mar 21 10:58:45 CET 2013


Hello,

the first patch fixes the return of wrong audio format numbers. 

Imo this could be simplified to directly return attr.audio_format, since audio_format is defined to have just 3 bits 

and therefore the if condition is always true...

Index: dvdnav.c
===================================================================
--- dvdnav.c    (revision 1253)
+++ dvdnav.c    (working copy)
@@ -908,27 +908,10 @@
   attr = vm_get_audio_attr(this->vm, stream);
   pthread_mutex_unlock(&this->vm_lock);
 
-  switch(attr.audio_format) {
-  case 0:
-    format = DVDNAV_FORMAT_AC3;
-    break;
-  case 2: /* MPEG-1 or MPEG-2 without extension bitstream. */
-  case 3: /* MPEG-2 with extension bitstream. */
-    format = DVDNAV_FORMAT_MPEGAUDIO;
-    break;
-  case 4:
-    format = DVDNAV_FORMAT_LPCM;
-    break;
-  case 6:
-    format = DVDNAV_FORMAT_DTS;
-    break;
-  case 7:
-    format = DVDNAV_FORMAT_SDDS;
-    break;
-  default:
+  if (attr.audio_format >=0 && attr.audio_format <= 7)
+    format = attr.audio_format;
+  else
     format = 0xffff;
-    break;
-  }
 
   return format;
 }


The second one removes the then unneeded defines.

Index: dvdnav.h
===================================================================
--- dvdnav.h    (revision 1253)
+++ dvdnav.h    (working copy)
@@ -63,12 +63,6 @@
 #define DVDNAV_STATUS_ERR 0
 #define DVDNAV_STATUS_OK  1
 
-#define DVDNAV_FORMAT_AC3 0
-#define DVDNAV_FORMAT_MPEGAUDIO 3
-#define DVDNAV_FORMAT_LPCM 4
-#define DVDNAV_FORMAT_DTS 5
-#define DVDNAV_FORMAT_SDDS 6
-
 /*********************************************************************
  * initialisation & housekeeping functions                           *
  *********************************************************************/

Best regards,

Andreas
-------------- next part --------------
A non-text attachment was scrubbed...
Name: dvdnav.c.patch
Type: application/octet-stream
Size: 850 bytes
Desc: not available
URL: <http://lists.mplayerhq.hu/pipermail/dvdnav-discuss/attachments/20130321/d3a1467c/attachment.obj>
-------------- next part --------------
A non-text attachment was scrubbed...
Name: dvdnav.h.patch
Type: application/octet-stream
Size: 597 bytes
Desc: not available
URL: <http://lists.mplayerhq.hu/pipermail/dvdnav-discuss/attachments/20130321/d3a1467c/attachment-0001.obj>


More information about the DVDnav-discuss mailing list