[vlc-commits] access:imem: find the ES category earlier

Steve Lhomme git at videolan.org
Sat Jul 8 18:38:15 CEST 2017


vlc | branch: master | Steve Lhomme <robux4 at videolabs.io> | Wed Jul  5 15:45:00 2017 +0200| [1ba1811704d05c3d9d8982f7b7a5d99e6de8038f] | committer: Jean-Baptiste Kempf

access:imem: find the ES category earlier

Signed-off-by: Jean-Baptiste Kempf <jb at videolan.org>

> http://git.videolan.org/gitweb.cgi/vlc.git/?a=commit;h=1ba1811704d05c3d9d8982f7b7a5d99e6de8038f
---

 modules/access/imem.c | 36 ++++++++++++++++++++++++------------
 1 file changed, 24 insertions(+), 12 deletions(-)

diff --git a/modules/access/imem.c b/modules/access/imem.c
index 873aacaebe..02c80fdeca 100644
--- a/modules/access/imem.c
+++ b/modules/access/imem.c
@@ -390,6 +390,24 @@ static block_t *Block(access_t *access, bool *restrict eof)
     return block;
 }
 
+static inline int GetCategory(vlc_object_t *object)
+{
+    const int cat = var_InheritInteger(object, "imem-cat");
+    switch (cat)
+    {
+    case 1:
+        return AUDIO_ES;
+    case 2:
+        return VIDEO_ES;
+    case 3:
+        return SPU_ES;
+    default:
+        msg_Err(object, "Invalid ES category");
+    case 4:
+        return UNKNOWN_ES;
+    }
+}
+
 /**
  * It opens an imem access_demux.
  */
@@ -403,20 +421,18 @@ static int OpenDemux(vlc_object_t *object)
 
     /* ES format */
     es_format_t fmt;
-    es_format_Init(&fmt, UNKNOWN_ES, 0);
+    es_format_Init(&fmt, GetCategory(object), 0);
 
     fmt.i_id = var_InheritInteger(object, "imem-id");
     fmt.i_group = var_InheritInteger(object, "imem-group");
 
     char *tmp = var_InheritString(object, "imem-codec");
     if (tmp)
-        fmt.i_codec = vlc_fourcc_GetCodecFromString(UNKNOWN_ES, tmp);
+        fmt.i_codec = vlc_fourcc_GetCodecFromString(fmt.i_cat, tmp);
     free(tmp);
 
-    const int cat = var_InheritInteger(object, "imem-cat");
-    switch (cat) {
-    case 1: {
-        es_format_Change( &fmt, AUDIO_ES, 0 );
+    switch (fmt.i_cat) {
+    case AUDIO_ES: {
         fmt.audio.i_channels = var_InheritInteger(object, "imem-channels");
         fmt.audio.i_rate = var_InheritInteger(object, "imem-samplerate");
 
@@ -425,8 +441,7 @@ static int OpenDemux(vlc_object_t *object)
                 fmt.audio.i_channels, fmt.audio.i_rate);
         break;
     }
-    case 2: {
-        es_format_Change( &fmt, VIDEO_ES, 0 );
+    case VIDEO_ES: {
         fmt.video.i_width  = var_InheritInteger(object, "imem-width");
         fmt.video.i_height = var_InheritInteger(object, "imem-height");
         unsigned num, den;
@@ -448,8 +463,7 @@ static int OpenDemux(vlc_object_t *object)
                 fmt.video.i_frame_rate, fmt.video.i_frame_rate_base);
         break;
     }
-    case 3: {
-        es_format_Change( &fmt, SPU_ES, 0 );
+    case SPU_ES: {
         fmt.subs.spu.i_original_frame_width =
             var_InheritInteger(object, "imem-width");
         fmt.subs.spu.i_original_frame_height =
@@ -460,8 +474,6 @@ static int OpenDemux(vlc_object_t *object)
         break;
     }
     default:
-        if (cat != 4)
-            msg_Err(object, "Invalid ES category");
         es_format_Clean(&fmt);
         CloseCommon(sys);
         return VLC_EGENERIC;



More information about the vlc-commits mailing list