]> git.sesse.net Git - vlc/blobdiff - modules/codec/flac.c
omxil: get rid of debug ifdefs
[vlc] / modules / codec / flac.c
index b57c3a43098aa94cc3333560718c09d8f350581f..b2ee916ab8ce3f6c6632e8eb58d0a1b8ff5dffc8 100644 (file)
@@ -134,7 +134,12 @@ static void Interleave( int32_t *p_out, const int32_t * const *pp_in,
 
     for( unsigned j = 0; j < i_samples; j++ )
         for( unsigned i = 0; i < i_nb_channels; i++ )
-            p_out[j * i_nb_channels + i] = pp_in[pi_index[i]][j] << shift;
+        {
+            union { int32_t i; uint32_t u; } spl;
+
+            spl.u = ((uint32_t)pp_in[pi_index[i]][j]) << shift;
+            p_out[j * i_nb_channels + i] = spl.i;
+        }
 }
 
 /*****************************************************************************
@@ -584,12 +589,15 @@ EncoderWriteCallback( const FLAC__StreamEncoder *encoder,
             msg_Dbg( p_enc, "Writing STREAMINFO: %zu", bytes );
 
             /* Backup the STREAMINFO metadata block */
-            p_enc->fmt_out.i_extra = STREAMINFO_SIZE;
-            p_enc->fmt_out.p_extra = xmalloc( STREAMINFO_SIZE );
-            memcpy(p_enc->fmt_out.p_extra, buffer + 4, STREAMINFO_SIZE );
+            p_enc->fmt_out.i_extra = STREAMINFO_SIZE + 8;
+            p_enc->fmt_out.p_extra = xmalloc( STREAMINFO_SIZE + 8);
+            memcpy(p_enc->fmt_out.p_extra, "fLaC", 4);
+            memcpy((uint8_t*)p_enc->fmt_out.p_extra + 4, buffer, STREAMINFO_SIZE );
+            /* Fake this as the last metadata block */
+            ((uint8_t*)p_enc->fmt_out.p_extra)[4] |= 0x80;
         }
         p_sys->i_headers++;
-        return FLAC__STREAM_DECODER_WRITE_STATUS_CONTINUE;
+        return FLAC__STREAM_ENCODER_WRITE_STATUS_OK;
     }
 
     p_block = block_Alloc( bytes );
@@ -607,7 +615,7 @@ EncoderWriteCallback( const FLAC__StreamEncoder *encoder,
 
     block_ChainAppend( &p_sys->p_chain, p_block );
 
-    return FLAC__STREAM_DECODER_WRITE_STATUS_CONTINUE;
+    return FLAC__STREAM_ENCODER_WRITE_STATUS_OK;
 }
 /*****************************************************************************
  * EncoderMetadataCallback: called by libflac to output metadata