Web lists-archives.com

Re: [MPlayer-dev-eng] [PATCH] force lavf for flac because native demuxer cant handle album art




On Sat, 26 Sep 2015 08:04:57 -0400
compn <tempn@xxxxxxxxx> wrote:

> http://samples.ffmpeg.org/flac/Chelsea%20Wolfe%20-%20Pain%20Is%20Beauty%20-%2001%20-%20Feral%20Love.flac
> 
> i forgot if this is all that needs to be done...
> 
> using demuxer lavf now gets mplayer to show album art, which may not be
> a desired result for some users.
> 
> -compn
> 
The attached patch fixes it with the internal demuxer.
Please test.

Ciao,
 Roberto
Index: demux_audio.c
===================================================================
--- demux_audio.c	(revisione 37526)
+++ demux_audio.c	(copia locale)
@@ -261,6 +261,21 @@
 }
 #endif
 
+static void skip_flac_metadata(demuxer_t *demuxer)
+{
+  stream_t *s = demuxer->stream;
+  unsigned char blk_type;
+
+  mp_msg(MSGT_DEMUX,MSGL_V,"demux_audio: skipping flac metadata\n");
+  do {
+    int blk_len;
+    blk_type = stream_read_char (s);
+    blk_len = stream_read_int24(s);
+    mp_msg(MSGT_DEMUX,MSGL_DBG2,"Blk type %2x, size = %6x\n",blk_type, blk_len);
+    stream_skip (s, blk_len);
+  } while (!(blk_type & 0x80));
+}
+
 /**
  * @brief Determine the number of frames of a file encoded with
  *        variable bitrate mode (VBR).
@@ -595,7 +610,8 @@
     sh_audio->needs_parsing = 1;
     stream_seek(s,demuxer->movi_start);
   } break;
-  case fLaC:
+  case fLaC: {
+	    int have_metadata = 0;
 	    sh_audio->format = mmioFOURCC('f', 'L', 'a', 'C');
 	    demuxer->movi_start = stream_tell(s) - 4;
 	    demuxer->movi_end = s->end_pos;
@@ -604,7 +620,12 @@
 	      int64_t size = demuxer->movi_end - demuxer->movi_start;
 	      int64_t num_samples;
 	      int32_t srate;
-	      stream_skip(s, 14);
+	      int header_size;
+	      have_metadata = !(stream_read_char(s) & 0x80);
+	      header_size = stream_read_int24(s);
+	      if (header_size != 0x22)
+	        mp_msg(MSGT_DEMUX,MSGL_WARN,"demux_audio: unexpected flac header size: 0x%x\n", header_size);
+	      stream_skip(s, 10);
 	      srate = stream_read_int24(s) >> 4;
 	      num_samples  = stream_read_char(s) & 0xf;
 	      num_samples <<= 32;
@@ -611,12 +632,17 @@
 	      num_samples |= stream_read_dword(s);
 	      if (num_samples && srate)
 	        sh_audio->i_bps = size * srate / num_samples;
+	      stream_skip(s, 16);
 	    }
 	    if (sh_audio->i_bps < 1) // guess value to prevent crash
 	      sh_audio->i_bps = 64 * 1024;
 	    sh_audio->needs_parsing = 1;
+	    if (have_metadata) { // Remove this block if reenabling get_metadata
+	      skip_flac_metadata(demuxer);
+	      demuxer->movi_start = stream_tell(s);
+	    }
 //	    get_flac_metadata (demuxer);
-	    break;
+	    } break;
   }
 
   priv = malloc(sizeof(da_priv_t));
_______________________________________________
MPlayer-dev-eng mailing list
MPlayer-dev-eng@xxxxxxxxxxxx
https://lists.mplayerhq.hu/mailman/listinfo/mplayer-dev-eng